OMX_ERRORTYPE VideoFilter::FlushComponent(OMX_U32 nPortIndex) { LOG_DEBUG("Flush filter port: %d\n", (int)nPortIndex); if(nPortIndex == IN_PORT) { FlushInputBuffer(); tsmFlush(hTsHandle); while(InBufferHdrList.GetNodeCnt()>0) { OMX_BUFFERHEADERTYPE *pBufferHdr = NULL; pBufferHdr = InBufferHdrList.GetNode(0); InBufferHdrList.Remove(pBufferHdr); ports[IN_PORT]->SendBuffer(pBufferHdr); } ReturnInputBuffer(); bLastInput = OMX_FALSE; bLastOutput = OMX_FALSE; nDecodeOnly = 0; bGetNewSegment = OMX_TRUE; } if(nPortIndex == OUT_PORT) { FlushOutputBuffer(); while(1) { OMX_BUFFERHEADERTYPE *pBufferHdr = NULL; pBufferHdr = GetFirstOutBufferHdrFromList(); if(pBufferHdr == NULL) break; ports[OUT_PORT]->SendBuffer(pBufferHdr); } bNeedOutBuffer = OMX_TRUE; } return OMX_ErrorNone; }
OMX_ERRORTYPE VideoFilter::ProcessInBufferFlags() { if(pInBufferHdr->nFlags & OMX_BUFFERFLAG_STARTTIME) bGetNewSegment = OMX_TRUE; if(bGetNewSegment == OMX_TRUE && (!(pInBufferHdr->nFlags & OMX_BUFFERFLAG_CODECCONFIG))) { LOG_DEBUG("Get New sement buffer, ts %lld\n", pInBufferHdr->nTimeStamp); bGetNewSegment = OMX_FALSE; bNewSegment = OMX_TRUE; bLastInput = OMX_FALSE; bLastOutput = OMX_FALSE; if(pInBufferHdr->nFlags & OMX_BUFFERFLAG_STARTTRICK) { LOG_DEBUG("Set ts manager to FIFO mode.\n"); tsmFlush(hTsHandle, pInBufferHdr->nTimeStamp, MODE_FIFO); } else { LOG_DEBUG("Set ts manager to AI mode.\n"); tsmFlush(hTsHandle, pInBufferHdr->nTimeStamp, MODE_AI); } } if(bLastInput != OMX_FALSE) { LOG_DEBUG("Filter drop input buffers in EOS state.\n"); ReturnInputBuffer(); return OMX_ErrorNoMore; } if(pInBufferHdr->nFlags & OMX_BUFFERFLAG_EOS) { bLastInput = OMX_TRUE; bNeedInputBuffer = OMX_FALSE; pInBufferHdr->nTimeStamp = -1; pInBufferHdr->nFilledLen = 0; return OMX_ErrorNone; } if(!(pInBufferHdr->nFlags & OMX_BUFFERFLAG_ENDOFFRAME) && bFilterSupportPartilInput != OMX_TRUE) { ProcessPartialInput(); return OMX_ErrorNotReady; } if(PartialInputHdr.pBuffer != NULL) { ProcessPartialInput(); pInBufferHdr = &PartialInputHdr; } if(pInBufferHdr->nFlags & OMX_BUFFERFLAG_DECODEONLY) nDecodeOnly ++; if(pInBufferHdr->nFlags & OMX_BUFFERFLAG_CODECCONFIG && pInBufferHdr->nFilledLen > 0) { if(pCodecData == NULL) { pCodecData = FSL_MALLOC(pInBufferHdr->nFilledLen); if(pCodecData == NULL) { SendEvent(OMX_EventError, OMX_ErrorInsufficientResources, 0, NULL); return OMX_ErrorInsufficientResources; } } else { pCodecData = FSL_REALLOC(pCodecData, nCodecDataLen + pInBufferHdr->nFilledLen); if(pCodecData == NULL) { SendEvent(OMX_EventError, OMX_ErrorInsufficientResources, 0, NULL); return OMX_ErrorInsufficientResources; } } fsl_osal_memcpy((char *)pCodecData + nCodecDataLen, pInBufferHdr->pBuffer, pInBufferHdr->nFilledLen); nCodecDataLen += pInBufferHdr->nFilledLen; LOG_INFO("Get Codec configure data, len: %d\n", nCodecDataLen); ReturnInputBuffer(); return OMX_ErrorNotReady; } return OMX_ErrorNone; }