PvmfMediaInputNodeOutPort::PvmfMediaInputNodeOutPort(PvmfMediaInputNode* aNode, const char* aName) : OsclTimerObject(OsclActiveObject::EPriorityNominal, "PvmfMediaInputNodeOutPort") , PvmfPortBaseImpl(PVMF_MEDIAIO_NODE_OUTPUT_PORT_TAG //this port handles its own port activity , this, aName) , iNode(aNode) , iState(PvmfMediaInputNodeOutPort::PORT_STATE_BUFFERING) , inum_text_sample(0) , imax_num_sample(0) { iNALType = 0; iCmdId = 0; iMioInfoErrorCmdId = 0; AddToScheduler(); iFormatType = PVMF_MIME_FORMAT_UNKNOWN; iPeer = NULL; iWriteState = EWriteOK; iMediaDataAllocMemPool = OSCL_NEW(OsclMemPoolFixedChunkAllocator, (PVMIO_MEDIADATA_POOLNUM)); iMediaDataMemPool = OSCL_NEW(OsclMemPoolFixedChunkAllocator, (PVMIO_MEDIADATA_POOLNUM)); iMediaDataAlloc = OSCL_NEW(PvmfMediaInputDataBufferAlloc, (iMediaDataAllocMemPool)); iDataPathLogger = PVLogger::GetLoggerObject("datapath.sourcenode"); #ifdef _TEST_AE_EROR_HANDLING iTimeStampJunk = 0x000FFFFF; #endif }
OsclComponentRegistryElement::OsclComponentRegistryElement(const OsclComponentRegistryElement&v) : iId(NULL) , iFactory(v.iFactory) , iComponentId(v.iComponentId) { iId = OSCL_NEW(OSCL_HeapString<OsclMemAllocator>, (*v.iId)); }
OSCL_EXPORT_REF int PV2WayMIO::AddFormat(PVMFFileInputSettings& aformat) { CodecSpecifier* temp = OSCL_NEW(FileCodecSpecifier, (aformat)); iFormatsMap[temp->GetFormat()] = temp; iFormats->push_back(temp->GetFormat()); return 0; }
OSCL_EXPORT_REF int PV2WayMIO::AddFormat(PVMFFormatType aformat) { CodecSpecifier* temp = OSCL_NEW(CharCodecSpecifier, (aformat)); iFormatsMap[temp->GetFormat()] = temp; iFormats->push_back(temp->GetFormat()); return 0; }
OSCL_EXPORT_REF int PV2WayMIO::AddFormat(LipSyncDummyMIOSettings& aformat) { CodecSpecifier* temp = OSCL_NEW(DummyMIOCodecSpecifier, (aformat)); iFormatsMap[temp->GetFormat()] = temp; iFormats->push_back(temp->GetFormat()); return 0; }
OMX_ERRORTYPE OmxComponentFactoryDynamicCreate(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN OMX_PTR pAppData, OMX_IN OMX_PTR pProxy, OMX_STRING aOmxLibName, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount) { OMX_ERRORTYPE returnStatus = OMX_ErrorUndefined; OsclSharedLibrary* lib = NULL; // If aOmxLib is NULL, this is the first time this method has been called if (NULL == aOmxLib) { OSCL_StackString<OMX_MAX_LIB_PATH> Libname(aOmxLibName); lib = OSCL_NEW(OsclSharedLibrary, (Libname)); } else { lib = (OsclSharedLibrary *) aOmxLib; } // Load the associated library. If successful, call the corresponding // create function located inside the loaded library OsclLibStatus loadStatus = OsclLibSuccess; if (aRefCount == 0) { loadStatus = lib->LoadLib(); } if (loadStatus == OsclLibSuccess) { aRefCount++; // look for the interface OsclAny* interfacePtr = NULL; if (OsclLibSuccess == lib->QueryInterface(PV_OMX_SHARED_INTERFACE, (OsclAny*&)interfacePtr)) { // the interface ptr should be ok, but check just in case if (interfacePtr != NULL) { OmxSharedLibraryInterface* omxIntPtr = OSCL_DYNAMIC_CAST(OmxSharedLibraryInterface*, interfacePtr); OsclUuid *temp = (OsclUuid*) aOsclUuid; OsclAny* createCompTemp = omxIntPtr->QueryOmxComponentInterface(*temp, PV_OMX_CREATE_INTERFACE); // check if the component contains the correct ptr if (createCompTemp != NULL) { // createComp is the function pointer to store the creation function // for the omx component located inside the loaded library OMX_ERRORTYPE(*createComp)(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN OMX_PTR pAppData, OMX_IN OMX_PTR pProxy, OMX_STRING aOmxLibName, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount); createComp = OSCL_DYNAMIC_CAST(OMX_ERRORTYPE(*)(OMX_OUT OMX_HANDLETYPE * pHandle, OMX_IN OMX_PTR pAppData, OMX_IN OMX_PTR , OMX_STRING, OMX_PTR &, OMX_PTR , OMX_U32 &), createCompTemp); // call the component AO factory inside the loaded library returnStatus = (*createComp)(pHandle, pAppData, pProxy, aOmxLibName, aOmxLib, aOsclUuid, aRefCount); // Store the shared library so it can be closed later aOmxLib = (OMX_PTR) lib; } }
OsclAsyncFile* OsclAsyncFile::NewL(OsclNativeFile& aFile, int32 aCacheSize, PVLogger* aLogger) { OsclAsyncFile* self = OSCL_NEW(OsclAsyncFile, (aFile, aCacheSize, aLogger)); OsclError::PushL(self); self->ConstructL(); OsclError::Pop(); return self; }
OsclAsyncFileBuffer* OsclAsyncFileBuffer::NewL(int32 aBufferSize, int32 aId) { OsclAsyncFileBuffer* self = OSCL_NEW(OsclAsyncFileBuffer, (aBufferSize, aId)); OsclError::PushL(self); self->ConstructL(); OsclError::Pop(); return self; }
OSCL_EXPORT_REF void PVMFBufferDataSource::Start() { iMediaDataAlloc = OSCL_NEW(PVMFSimpleMediaBufferCombinedAlloc, (&iMemAlloc)); unsigned ave_sample_sz = (iMinSampleSz + iMaxSampleSz) / 2; unsigned frequency = (iBitrate >> 3) / ave_sample_sz; iSampleInterval = 1000 / frequency; iTimer .SetFrequency(frequency); iTimer.SetObserver(this); iTimer.Request(1/*timer id*/, ave_sample_sz/*timer info*/ , 1/*num ticks*/, this, 1/*recurring*/); }
PVMFStreamingManagerNode* PVMFStreamingManagerNode::New(int32 aPriority) { PVMFStreamingManagerNode* smNode = NULL; smNode = OSCL_NEW(PVMFStreamingManagerNode, (aPriority)); if (smNode) { smNode->Construct(); } return smNode; }
PVMFCPMPluginInterface* PVMFCPMPassThruPlugInOMA1::CreatePlugIn(bool aFailAuthorizeUsage, bool aCancelAcquireLicense, bool aSourceInitDataNotSupported, PVMFCPMContentType aCPMContentType) { PVMFCPMPassThruPlugInOMA1* plugIn = NULL; int32 err; OSCL_TRY(err, /* * Create pass thru OMA1.0 Plugin */ plugIn = OSCL_NEW(PVMFCPMPassThruPlugInOMA1, (aFailAuthorizeUsage, aCancelAcquireLicense, aSourceInitDataNotSupported, aCPMContentType)); );
OSCL_EXPORT_REF PVMFNodeInterface* PVMFAACFFParserNodeFactory::CreatePVMFAACFFParserNode(int32 aPriority) { PVMFNodeInterface* node = NULL; node = OSCL_NEW(PVMFAACFFParserNode, (aPriority)); if (node == NULL) { OSCL_LEAVE(OsclErrNoMemory); } return node; }
PVMFCPMPluginInterface* PVMFCPMPassThruPlugInOMA1::CreatePlugIn(PVMFOma1PassthruPluginFactoryTestModeParams aPluginParams) { PVMFCPMPassThruPlugInOMA1* plugIn = NULL; int32 err; OSCL_TRY(err, /* * Create pass thru OMA1.0 Plugin */ plugIn = OSCL_NEW(PVMFCPMPassThruPlugInOMA1, (aPluginParams)); );
OSCL_EXPORT_REF PVMFJitterBufferMisc* PVMFJitterBufferMisc::New(PVMFJitterBufferMiscObserver* aObserver, PVMFMediaClock& aClientPlaybackClock, Oscl_Vector<PVMFJitterBufferPortParams*, OsclMemAllocator>& aPortParamsQueue) { int32 err = OsclErrNone; PVMFJitterBufferMisc* ptr = NULL; OSCL_TRY(err, ptr = OSCL_NEW(PVMFJitterBufferMisc, (aObserver, aClientPlaybackClock, aPortParamsQueue)); ptr->Construct()); if (err != OsclErrNone) { ptr = NULL; } return ptr; }
uint32 TSC_324m::UserInputIndicationRecv(PS_ControlMsgHeader pReceiveInf) { PS_UserInputIndication pUserInputIndication = (PS_UserInputIndication)pReceiveInf->pParameter; CPVUserInput* uii = NULL; uint16 duration = 0; PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "TSC_324m: User Input Indication Received - index(%d)\n", pUserInputIndication->index)); switch (pUserInputIndication->index) { case 1: /* alphanumeric */ PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "TSC_324m: User Input Indication Received - alphanumeric size(%d)", pUserInputIndication->alphanumeric->size)); uii = OSCL_NEW(CPVUserInputAlphanumeric, (pUserInputIndication->alphanumeric->data, pUserInputIndication->alphanumeric->size)); break; case 3: /* signal */ PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "TSC_324m: User Input Indication Received - signal option_of_duration(%d), option_of_signalRtp(%d), signalType(%d)", pUserInputIndication->signal->option_of_duration, pUserInputIndication->signal->option_of_signalRtp, pUserInputIndication->signal->signalType.size)); if (pUserInputIndication->signal->option_of_duration) { duration = pUserInputIndication->signal->duration; } uii = OSCL_NEW(CPVUserInputDtmf, (*pUserInputIndication->signal->signalType.data, false, duration)); break; default: PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "TSC_324m: User Input Indication Received - unrecognized type\n")); } if (uii) { if (iTSC_324mObserver) iTSC_324mObserver->UserInputReceived(uii); OSCL_DELETE(uii); } return iTerminalStatus; }
OsclComponentRegistryElement& OsclComponentRegistryElement::operator=(const OsclComponentRegistryElement & src) { if (iId) { OSCL_HeapString<OsclMemAllocator>* id = (OSCL_HeapString<OsclMemAllocator>*)iId; OSCL_DELETE(id); iId = NULL; } iId = OSCL_NEW(OSCL_HeapString<OsclMemAllocator>, (*src.iId)); iFactory = src.iFactory; iComponentId = src.iComponentId; return *this; }
bool user_input_test::start_async_test() { if (iIsDTMF) { iUserInput = OSCL_NEW(CPVUserInputDtmf, (DTMF_TEST_INPUT, DTMF_TEST_UPDATE, DTMF_TEST_DURATION)); } else { iUserInput = OSCL_NEW(CPVUserInputAlphanumeric, (alphanumericTestString, ALPHANUMERIC_STRING_LENGTH)); } if (iUserInput == NULL) { test_is_true(false); return false; } return test_base::start_async_test();; }
TPVStatusCode H223LowerLayer::Open() { unsigned pdu_rate = (unsigned)(1000.0 / (float)H223_MIN_SAMPLE_INTERVAL + .5) + 1; iMemFragmentAlloc = OSCL_NEW(PVMFBufferPoolAllocator, ()); iMemFragmentAlloc->SetLeaveOnAllocFailure(false); iMemFragmentAlloc->size((uint16)(pdu_rate*2), (uint16)(iSendPduSz + H223_SEND_PDU_SIZE_EXTRA)); iMediaMsgPoolAlloc = OSCL_NEW(OsclMemPoolFixedChunkAllocator, (pdu_rate)); iMediaMsgPoolAlloc->enablenullpointerreturn(); uint media_data_imp_size = oscl_mem_aligned_size(sizeof(PVMFMediaFragGroup<OsclMemAllocator>)) + oscl_mem_aligned_size(sizeof(OsclRefCounterDA)); iMediaDataImplMemAlloc = OSCL_NEW(OsclMemPoolFixedChunkAllocator, (pdu_rate, media_data_imp_size)); iMediaDataImplMemAlloc->enablenullpointerreturn(); iDispatchPacketAlloc = OSCL_NEW(PVMFMediaFragGroupCombinedAlloc<OsclMemAllocator>, (pdu_rate, 30, iMediaDataImplMemAlloc)); iDispatchPacketAlloc->create(); iDemuxBufferSize = (uint32)((float)(H223_DEMUX_BUFFER_INTERVAL_MS * iBitrate) / 8000.0); PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223LowerLayer::Open iBitrate=%d, iDemuxBufferSize=%d", iBitrate, iDemuxBufferSize)); iDemuxBufferPos = iDemuxBuffer = (uint8*)OSCL_DEFAULT_MALLOC(H223_DEMUX_BUFFER_SIZE); iIdleSyncCheckBuffer = (uint8*)OSCL_DEFAULT_MALLOC(H223_DEMUX_BUFFER_SIZE); return EPVT_Success; }
// Factory functions PVMFNodeInterface* Mp4NodesCoreLibraryLoader::CreateMp4ParserNode(int32 aPriority) { OsclSharedLibrary* mp4SharedLibrary = NULL; OSCL_StackString<NODE_REGISTRY_LIB_NAME_MAX_LENGTH> libname(MP4_LIB_NAME); // Need to load the library for the node mp4SharedLibrary = OSCL_NEW(OsclSharedLibrary, (libname)); OsclLibStatus result = mp4SharedLibrary->LoadLib(); if (OsclLibSuccess != result) { return NULL; } mp4SharedLibrary->AddRef(); // Query for create function OsclAny* interfacePtr = NULL; mp4SharedLibrary->QueryInterface(PV_NODE_INTERFACE, (OsclAny*&)interfacePtr); NodeSharedLibraryInterface* nodeIntPtr = OSCL_DYNAMIC_CAST(NodeSharedLibraryInterface*, interfacePtr); OsclAny* createFuncTemp = nodeIntPtr->QueryNodeInterface(KPVMFMP4FFParserNodeUuid, PV_CREATE_NODE_INTERFACE); LPFN_NODE_CREATE_FUNC nodeCreateFunc = OSCL_DYNAMIC_CAST(PVMFNodeInterface * (*)(int32), createFuncTemp); if (NULL != nodeCreateFunc) { PVMFNodeInterface* node = NULL; // call the real node factory function node = (*(nodeCreateFunc))(aPriority); if (NULL == node) { mp4SharedLibrary->RemoveRef(); if (OsclLibSuccess == mp4SharedLibrary->Close()) { // Close will unload the library if refcount is 0 OSCL_DELETE(mp4SharedLibrary); } return NULL; } node->SetSharedLibraryPtr(mp4SharedLibrary); return node; } return NULL; }
CPV2WayRecDatapath *CPV2WayRecDatapath::NewL(PVLogger *aLogger, TPV2WayMediaType aFormat, CPV2WayDataChannelDatapath &aDatapath, CPV324m2Way *a2Way) { CPV2WayRecDatapath *self = OSCL_NEW(CPV2WayRecDatapath, (aLogger, aFormat, aDatapath, a2Way)); OsclError::LeaveIfNull(self); if (self) { OSCL_TRAPSTACK_PUSH(self); self->ConstructL(); } OSCL_TRAPSTACK_POP(); return self; }
OSCL_EXPORT_REF void PVMp4FFComposerPort::setParametersSync(PvmiMIOSession session, PvmiKvp* parameters, int num_elements, PvmiKvp*& ret_kvp) { OSCL_UNUSED_ARG(session); ret_kvp = NULL; if (iFormat == PVMF_MIME_H264_VIDEO_MP4) { //this code is specific to H264 file format for (int32 i = 0; i < num_elements; i++)//assuming the memory is allocated for key { if (pv_mime_strcmp(parameters->key, VIDEO_AVC_OUTPUT_SPS_CUR_VALUE) == 0) { memfrag_sps = (OsclMemoryFragment *)(OSCL_MALLOC(sizeof(OsclMemoryFragment))); memfrag_sps->len = parameters->capacity; memfrag_sps->ptr = (uint8*)(OSCL_MALLOC(sizeof(uint8) * memfrag_sps->len)); oscl_memcpy((void*)memfrag_sps->ptr, (const void*)parameters->value.key_specific_value, memfrag_sps->len); iNode->memvector_sps.push_back(memfrag_sps); //storing SPS in the vector iNode->iNum_SPS_Set += 1; } if (pv_mime_strcmp(parameters->key, VIDEO_AVC_OUTPUT_PPS_CUR_VALUE) == 0) { memfrag_pps = (OsclMemoryFragment *)(OSCL_MALLOC(sizeof(OsclMemoryFragment))); memfrag_pps->len = parameters->capacity; memfrag_pps->ptr = (uint8*)(OSCL_MALLOC(sizeof(uint8) * memfrag_pps->len)); oscl_memcpy((void*)memfrag_pps->ptr, (const void*)parameters->value.key_specific_value, memfrag_pps->len); iNode->memvector_pps.push_back(memfrag_pps); //storing PPS in the vector iNode->iNum_PPS_Set += 1; } } } if (iFormat == PVMF_MIME_3GPP_TIMEDTEXT) { for (int32 i = 0; i < num_elements; i++)//assuming the memory is allocated for keys { if (pv_mime_strcmp(parameters->key, TIMED_TEXT_OUTPUT_CONFIG_INFO_CUR_VALUE) == 0) { PVA_FF_TextSampleDescInfo* ptempDecoderinfo = OSCL_STATIC_CAST(PVA_FF_TextSampleDescInfo*, parameters->value.key_specific_value); PVA_FF_TextSampleDescInfo* pDecoderinfo = OSCL_NEW(PVA_FF_TextSampleDescInfo, (*ptempDecoderinfo)); iNode->textdecodervector.push_back(pDecoderinfo); } } }
TSC_component* TSCComponentRegistry::Create(PVMFSessionId aSession, const PVUuid& aUuid, PVInterface*& aInterfacePtr, const OsclAny* aContext) { OSCL_UNUSED_ARG(aSession); OSCL_UNUSED_ARG(aContext); TSC_component* component = NULL; if (aUuid == PVUuidH324ComponentInterface) { component = OSCL_NEW(TSC_component, (iTSCstatemanager, iTSCcapability, iTSClc, iTSCblc, iTSCclc, iTSCmt)); aInterfacePtr = (PVMFComponentInterface*)component; aInterfacePtr->addRef(); component->removeRef(); } return component; }
void OmxDecTestFlushPort::Run() { switch (iState) { case StateUnLoaded: { PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "OmxDecTestFlushPort::Run() - StateUnLoaded IN")); OMX_ERRORTYPE Err; OMX_BOOL Status; if (!iCallbacks->initCallbacks()) { PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "OmxDecTestFlushPort::Run() - ERROR initCallbacks failed, OUT")); StopOnError(); break; } ipAppPriv = (AppPrivateType*) oscl_malloc(sizeof(AppPrivateType)); CHECK_MEM(ipAppPriv, "Component_Handle"); ipAppPriv->Handle = NULL; //Allocate bitstream buffer for AVC component if (0 == oscl_strcmp(iFormat, "H264")) { ipAVCBSO = OSCL_NEW(AVCBitstreamObject, (ipInputFile)); CHECK_MEM(ipAVCBSO, "Bitstream_Buffer"); } //Allocate bitstream buffer for MPEG4/H263 component if (0 == oscl_strcmp(iFormat, "M4V") || 0 == oscl_strcmp(iFormat, "H263")) { ipBitstreamBuffer = (OMX_U8*) oscl_malloc(BIT_BUFF_SIZE); CHECK_MEM(ipBitstreamBuffer, "Bitstream_Buffer") ipBitstreamBufferPointer = ipBitstreamBuffer; } //Allocate bitstream buffer for MP3 component if (0 == oscl_strcmp(iFormat, "MP3")) { ipMp3Bitstream = OSCL_NEW(Mp3BitstreamObject, (ipInputFile)); CHECK_MEM(ipMp3Bitstream, "Bitstream_Buffer"); } //This should be the first call to the component to load it. Err = OMX_MasterInit(); CHECK_ERROR(Err, "OMX_MasterInit"); PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OmxDecTestFlushPort::Run() - OMX_MasterInit done")); Status = PrepareComponent(); if (OMX_FALSE == Status) { PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OmxDecTestFlushPort::Run() Error while loading component OUT")); iState = StateError; if (iInputParameters.inPtr) { oscl_free(iInputParameters.inPtr); iInputParameters.inPtr = NULL; } RunIfNotReady(); break; } #if PROXY_INTERFACE ipThreadSafeHandlerEventHandler = OSCL_NEW(EventHandlerThreadSafeCallbackAO, (this, EVENT_HANDLER_QUEUE_DEPTH, "EventHandlerAO")); ipThreadSafeHandlerEmptyBufferDone = OSCL_NEW(EmptyBufferDoneThreadSafeCallbackAO, (this, iInBufferCount, "EmptyBufferDoneAO")); ipThreadSafeHandlerFillBufferDone = OSCL_NEW(FillBufferDoneThreadSafeCallbackAO, (this, iOutBufferCount, "FillBufferDoneAO")); if ((NULL == ipThreadSafeHandlerEventHandler) || (NULL == ipThreadSafeHandlerEmptyBufferDone) || (NULL == ipThreadSafeHandlerFillBufferDone)) { PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "OmxDecTestFlushPort::Run() - Error, ThreadSafe Callback Handler initialization failed, OUT")); iState = StateUnLoaded; OsclExecScheduler* sched = OsclExecScheduler::Current(); sched->StopScheduler(); } #endif if (StateError != iState) { iState = StateLoaded; PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "OmxDecTestFlushPort::Run() - StateUnLoaded OUT, moving to next state")); } RunIfNotReady(); } break; case StateLoaded: { OMX_ERRORTYPE Err; OMX_U32 ii; PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "OmxDecTestFlushPort::Run() - StateLoaded IN")); // allocate memory for ipInBuffer ipInBuffer = (OMX_BUFFERHEADERTYPE**) oscl_malloc(sizeof(OMX_BUFFERHEADERTYPE*) * iInBufferCount); CHECK_MEM(ipInBuffer, "InputBufferHeader"); ipInputAvail = (OMX_BOOL*) oscl_malloc(sizeof(OMX_BOOL) * iInBufferCount); CHECK_MEM(ipInputAvail, "InputBufferFlag"); /* Initialize all the buffers to NULL */ for (ii = 0; ii < iInBufferCount; ii++) { ipInBuffer[ii] = NULL; } //allocate memory for output buffer ipOutBuffer = (OMX_BUFFERHEADERTYPE**) oscl_malloc(sizeof(OMX_BUFFERHEADERTYPE*) * iOutBufferCount); CHECK_MEM(ipOutBuffer, "OutputBuffer"); ipOutReleased = (OMX_BOOL*) oscl_malloc(sizeof(OMX_BOOL) * iOutBufferCount); CHECK_MEM(ipOutReleased, "OutputBufferFlag"); /* Initialize all the buffers to NULL */ for (ii = 0; ii < iOutBufferCount; ii++) { ipOutBuffer[ii] = NULL; } Err = OMX_SendCommand(ipAppPriv->Handle, OMX_CommandStateSet, OMX_StateIdle, NULL); CHECK_ERROR(Err, "SendCommand Loaded->Idle"); PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OmxDecTestFlushPort::Run() - Sent State Transition Command from Loaded->Idle")); iPendingCommands = 1; PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OmxDecTestFlushPort::Run() - Allocating %d input and %d output buffers", iInBufferCount, iOutBufferCount)); //These calls are required because the control of in & out buffer should be with the testapp. for (ii = 0; ii < iInBufferCount; ii++) { Err = OMX_AllocateBuffer(ipAppPriv->Handle, &ipInBuffer[ii], iInputPortIndex, NULL, iInBufferSize); CHECK_ERROR(Err, "AllocateBuffer_Input"); PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OmxDecTestFlushPort::Run() - Called AllocateBuffer for buffer index %d on port %d", ii, iInputPortIndex)); ipInputAvail[ii] = OMX_TRUE; ipInBuffer[ii]->nInputPortIndex = iInputPortIndex; } if (StateError == iState) { PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "OmxDecTestFlushPort::Run() - AllocateBuffer Error, StateLoaded OUT")); RunIfNotReady(); break; } for (ii = 0; ii < iOutBufferCount; ii++) { Err = OMX_AllocateBuffer(ipAppPriv->Handle, &ipOutBuffer[ii], iOutputPortIndex, NULL, iOutBufferSize); CHECK_ERROR(Err, "AllocateBuffer_Output"); PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OmxDecTestFlushPort::Run() - Called AllocateBuffer for buffer index %d on port %d", ii, iOutputPortIndex)); ipOutReleased[ii] = OMX_TRUE; ipOutBuffer[ii]->nOutputPortIndex = iOutputPortIndex; ipOutBuffer[ii]->nInputPortIndex = 0; } if (StateError == iState) { PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "OmxDecTestFlushPort::Run() - AllocateBuffer Error, StateLoaded OUT")); RunIfNotReady(); break; } PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "OmxDecTestFlushPort::Run() - StateLoaded OUT, Moving to next state")); } break; case StateIdle: { PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "OmxDecTestFlushPort::Run() - StateIdle IN")); OMX_ERRORTYPE Err = OMX_ErrorNone; Err = OMX_FillThisBuffer(ipAppPriv->Handle, ipOutBuffer[0]); CHECK_ERROR(Err, "FillThisBuffer"); PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OmxDecTestFlushPort::Run() - FillThisBuffer command called for initiating dynamic port reconfiguration")); ipOutReleased[0] = OMX_FALSE; Err = OMX_SendCommand(ipAppPriv->Handle, OMX_CommandStateSet, OMX_StateExecuting, NULL); CHECK_ERROR(Err, "SendCommand Idle->Executing"); PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OmxDecTestFlushPort::Run() - Sent State Transition Command from Idle->Executing")); iPendingCommands = 1; PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "OmxDecTestFlushPort::Run() - StateIdle OUT")); } break; case StateDecodeHeader: { PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "OmxDecTestFlushPort::Run() - StateDecodeHeader IN, Sending configuration input buffers to the component to start dynamic port reconfiguration")); if (!iFlagDecodeHeader) { (*this.*pGetInputFrame)(); //For AAC component , send one more frame apart from the config frame, so that we can receive the callback if (0 == oscl_strcmp(iFormat, "AAC") || 0 == oscl_strcmp(iFormat, "AMR")) { (*this.*pGetInputFrame)(); } iFlagDecodeHeader = OMX_TRUE; iFrameCount++; //Proceed to executing state and if Port settings changed callback comes, //then do the dynamic port reconfiguration iState = StateExecuting; RunIfNotReady(); } PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "OmxDecTestFlushPort::Run() - StateDecodeHeader OUT")); } break; case StateDisablePort: { OMX_ERRORTYPE Err = OMX_ErrorNone; OMX_U32 ii; PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "OmxDecTestFlushPort::Run() - StateDisablePort IN")); if (!iDisableRun) { if (!iFlagDisablePort) { Err = OMX_SendCommand(ipAppPriv->Handle, OMX_CommandPortDisable, iOutputPortIndex, NULL); CHECK_ERROR(Err, "SendCommand_PortDisable"); PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OmxDecTestFlushPort::Run() - Sent Command for OMX_CommandPortDisable on port %d as a part of dynamic port reconfiguration", iOutputPortIndex)); iPendingCommands = 1; iFlagDisablePort = OMX_TRUE; RunIfNotReady(); } else { //Wait for all the buffers to be returned on output port before freeing them //This wait is required because of the queueing delay in all the Callbacks for (ii = 0; ii < iOutBufferCount; ii++) { if (OMX_FALSE == ipOutReleased[ii]) { break; } } if (ii != iOutBufferCount) { PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OmxDecTestFlushPort::Run() - Not all the output buffers returned by component yet, wait for it")); RunIfNotReady(); break; } for (ii = 0; ii < iOutBufferCount; ii++) { if (ipOutBuffer[ii]) { Err = OMX_FreeBuffer(ipAppPriv->Handle, iOutputPortIndex, ipOutBuffer[ii]); CHECK_ERROR(Err, "FreeBuffer_Output_DynamicReconfig"); ipOutBuffer[ii] = NULL; PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OmxDecTestFlushPort::Run() - Called FreeBuffer for buffer index %d on port %d", ii, iOutputPortIndex)); } } if (StateError == iState) { PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "OmxDecTestFlushPort::Run() - Error occured in this state, StateDisablePort OUT")); RunIfNotReady(); break; } iDisableRun = OMX_TRUE; } } PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "OmxDecTestFlushPort::Run() - StateDisablePort OUT")); } break; case StateDynamicReconfig: { OMX_ERRORTYPE Err = OMX_ErrorNone; PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "OmxDecTestFlushPort::Run() - StateDynamicReconfig IN")); INIT_GETPARAMETER_STRUCT(OMX_PARAM_PORTDEFINITIONTYPE, iParamPort); iParamPort.nPortIndex = iOutputPortIndex; Err = OMX_GetParameter(ipAppPriv->Handle, OMX_IndexParamPortDefinition, &iParamPort); CHECK_ERROR(Err, "GetParameter_DynamicReconfig"); PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OmxDecTestFlushPort::Run() - GetParameter called for OMX_IndexParamPortDefinition on port %d", iParamPort.nPortIndex)); Err = OMX_SendCommand(ipAppPriv->Handle, OMX_CommandPortEnable, iOutputPortIndex, NULL); CHECK_ERROR(Err, "SendCommand_PortEnable"); PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OmxDecTestFlushPort::Run() - Sent Command for OMX_CommandPortEnable on port %d as a part of dynamic port reconfiguration", iOutputPortIndex)); iPendingCommands = 1; if (0 == oscl_strcmp(iFormat, "H264") || 0 == oscl_strcmp(iFormat, "H263") || 0 == oscl_strcmp(iFormat, "M4V") || 0 == oscl_strcmp(iFormat, "RV")) { iOutBufferSize = ((iParamPort.format.video.nFrameWidth + 15) & ~15) * ((iParamPort.format.video.nFrameHeight + 15) & ~15) * 3 / 2; if (iOutBufferSize < iParamPort.nBufferSize) { iOutBufferSize = iParamPort.nBufferSize; } } else if (0 == oscl_strcmp(iFormat, "WMV")) { iOutBufferSize = ((iParamPort.format.video.nFrameWidth + 3) & ~3) * ((iParamPort.format.video.nFrameHeight + 3) & ~3) * 3 / 2; if (iOutBufferSize < iParamPort.nBufferSize) { iOutBufferSize = iParamPort.nBufferSize; } } else { //For audio components take the size from the component iOutBufferSize = iParamPort.nBufferSize; } PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OmxDecTestFlushPort::Run() - Allocating buffer again after port reconfigutauion has been complete")); for (OMX_U32 ii = 0; ii < iOutBufferCount; ii++) { Err = OMX_AllocateBuffer(ipAppPriv->Handle, &ipOutBuffer[ii], iOutputPortIndex, NULL, iOutBufferSize); CHECK_ERROR(Err, "AllocateBuffer_Output_DynamicReconfig"); ipOutReleased[ii] = OMX_TRUE; PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OmxDecTestFlushPort::Run() - AllocateBuffer called for buffer index %d on port %d", ii, iOutputPortIndex)); } if (StateError == iState) { PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "OmxDecTestFlushPort::Run() - Error occured in this state, StateDynamicReconfig OUT")); RunIfNotReady(); break; } PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "OmxDecTestFlushPort::Run() - StateDynamicReconfig OUT")); } break; case StateExecuting: { OMX_U32 Index; OMX_BOOL MoreOutput; OMX_ERRORTYPE Err = OMX_ErrorNone; PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "OmxDecTestFlushPort::Run() - StateExecuting IN")); //After Processing N number of buffers, send the flush command on both the ports if ((iFrameCount > TEST_NUM_BUFFERS_TO_PROCESS) && (OMX_FALSE == iFlushCommandSent)) { Err = OMX_SendCommand(ipAppPriv->Handle, OMX_CommandFlush, OMX_ALL, NULL); CHECK_ERROR(Err, "SendCommand OMX_CommandFlush"); PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OmxDecTestFlushPort::Run() - Sending Flush Command on each port")); //Expecting 2 callbacks from each port iPendingCommands = 2; iFlushCommandSent = OMX_TRUE; } else { MoreOutput = OMX_TRUE; while (MoreOutput) { Index = 0; while (OMX_FALSE == ipOutReleased[Index] && Index < iOutBufferCount) { Index++; } if (Index != iOutBufferCount) { //This call is being made only once per frame Err = OMX_FillThisBuffer(ipAppPriv->Handle, ipOutBuffer[Index]); CHECK_ERROR(Err, "FillThisBuffer"); //Reset this till u receive the callback for output buffer free ipOutReleased[Index] = OMX_FALSE; PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OmxDecTestFlushPort::Run() - FillThisBuffer command called for output buffer index %d", Index)); } else { MoreOutput = OMX_FALSE; } } //while (MoreOutput) loop end here if (!iStopProcessingInput || (OMX_ErrorInsufficientResources == iStatusExecuting)) { // find available input buffer Index = 0; while (OMX_FALSE == ipInputAvail[Index] && Index < iInBufferCount) { Index++; } if (Index != iInBufferCount) { iStatusExecuting = (*this.*pGetInputFrame)(); iFrameCount++; } } else if (OMX_FALSE == iEosFlagExecuting) { //Only send one successful dummy buffer with flag set to signal EOS Index = 0; while (OMX_FALSE == ipInputAvail[Index] && Index < iInBufferCount) { Index++; } if (Index != iInBufferCount) { ipInBuffer[Index]->nFlags |= OMX_BUFFERFLAG_EOS; ipInBuffer[Index]->nFilledLen = 0; Err = OMX_EmptyThisBuffer(ipAppPriv->Handle, ipInBuffer[Index]); CHECK_ERROR(Err, "EmptyThisBuffer_EOS"); ipInputAvail[Index] = OMX_FALSE; // mark unavailable iEosFlagExecuting = OMX_TRUE; PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OmxDecTestFlushPort::Run() - Input buffer sent to the component with OMX_BUFFERFLAG_EOS flag set")); } } //else if (OMX_FALSE == iEosFlagExecuting) else { //nothing to do here } RunIfNotReady(); } //else of if ((iFrameCount > TEST_NUM_BUFFERS_TO_PROCESS) && (OMX_FALSE == iFlushCommandSent)) ends here PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "OmxDecTestFlushPort::Run() - StateExecuting OUT")); } break; case StateIntermediate: { PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "OmxDecTestFlushPort::Run() - StateIntermediate IN, for verification if ip/op buffers")); /* check whether all the buffers are returned on each port after a flush comand, * then change the Client AO state back to executing to resume processing */ if (OMX_TRUE == VerifyAllBuffersReturned()) { // All buffers have returned, change the AO state back to executing to resume processing //Note that component is already in Executing state iState = StateExecuting; } else { // not all buffers have been returned yet, remain in StateIntermediate and reschedule } PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "OmxDecTestFlushPort::Run() - StateIntermediate OUT")); RunIfNotReady(); } break; case StateStopping: { OMX_ERRORTYPE Err = OMX_ErrorNone; PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "OmxDecTestFlushPort::Run() - StateStopping IN")); //stop execution by state transition to Idle state. if (!iFlagStopping) { Err = OMX_SendCommand(ipAppPriv->Handle, OMX_CommandStateSet, OMX_StateIdle, NULL); CHECK_ERROR(Err, "SendCommand Executing->Idle"); PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OmxDecTestFlushPort::Run() - Sent State Transition Command from Executing->Idle")); iPendingCommands = 1; iFlagStopping = OMX_TRUE; } PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "OmxDecTestFlushPort::Run() - StateStopping OUT")); } break; case StateCleanUp: { OMX_U32 ii; OMX_ERRORTYPE Err = OMX_ErrorNone; PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "OmxDecTestFlushPort::Run() - StateCleanUp IN")); if (!iFlagCleanUp) { //Added a check here to verify whether all the ip/op buffers are returned back by the component or not //in case of Executing->Idle state transition if (OMX_FALSE == VerifyAllBuffersReturned()) { // not all buffers have been returned yet, reschedule RunIfNotReady(); break; } //Destroy the component by state transition to Loaded state Err = OMX_SendCommand(ipAppPriv->Handle, OMX_CommandStateSet, OMX_StateLoaded, NULL); CHECK_ERROR(Err, "SendCommand Idle->Loaded"); PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OmxDecTestFlushPort::Run() - Sent State Transition Command from Idle->Loaded")); iPendingCommands = 1; if (ipInBuffer) { for (ii = 0; ii < iInBufferCount; ii++) { if (ipInBuffer[ii]) { Err = OMX_FreeBuffer(ipAppPriv->Handle, iInputPortIndex, ipInBuffer[ii]); CHECK_ERROR(Err, "FreeBuffer_Input"); ipInBuffer[ii] = NULL; PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OmxDecTestFlushPort::Run() - Called FreeBuffer for buffer index %d on port %d", ii, iInputPortIndex)); } } oscl_free(ipInBuffer); ipInBuffer = NULL; } if (ipInputAvail) { oscl_free(ipInputAvail); ipInputAvail = NULL; } if (ipOutBuffer) { for (ii = 0; ii < iOutBufferCount; ii++) { if (ipOutBuffer[ii]) { Err = OMX_FreeBuffer(ipAppPriv->Handle, iOutputPortIndex, ipOutBuffer[ii]); CHECK_ERROR(Err, "FreeBuffer_Output"); ipOutBuffer[ii] = NULL; PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OmxDecTestFlushPort::Run() - Called FreeBuffer for buffer index %d on port %d", ii, iOutputPortIndex)); } } oscl_free(ipOutBuffer); ipOutBuffer = NULL; } if (ipOutReleased) { oscl_free(ipOutReleased); ipOutReleased = NULL; } iFlagCleanUp = OMX_TRUE; } PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "OmxDecTestFlushPort::Run() - StateCleanUp OUT")); } break; /********* FREE THE HANDLE & CLOSE FILES FOR THE COMPONENT ********/ case StateStop: { OMX_U8 TestName[] = "FLUSH_PORT_TEST"; OMX_ERRORTYPE Err = OMX_ErrorNone; PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "OmxDecTestFlushPort::Run() - StateStop IN")); if (ipAppPriv) { if (ipAppPriv->Handle) { PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OmxDecTestFlushPort::Run() - Free the Component Handle")); Err = OMX_MasterFreeHandle(ipAppPriv->Handle); if (OMX_ErrorNone != Err) { PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "OmxDecTestFlushPort::Run() - FreeHandle Error")); iTestStatus = OMX_FALSE; } } } PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OmxDecTestFlushPort::Run() - De-initialize the omx component")); Err = OMX_MasterDeinit(); if (OMX_ErrorNone != Err) { PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "OmxDecTestFlushPort::Run() - OMX_MasterDeinit Error")); iTestStatus = OMX_FALSE; } if (0 == oscl_strcmp(iFormat, "H264")) { if (ipAVCBSO) { OSCL_DELETE(ipAVCBSO); ipAVCBSO = NULL; } } if (0 == oscl_strcmp(iFormat, "M4V") || 0 == oscl_strcmp(iFormat, "H263")) { if (ipBitstreamBuffer) { oscl_free(ipBitstreamBufferPointer); ipBitstreamBuffer = NULL; ipBitstreamBufferPointer = NULL; } } if (0 == oscl_strcmp(iFormat, "MP3")) { if (ipMp3Bitstream) { OSCL_DELETE(ipMp3Bitstream); ipMp3Bitstream = NULL; } } if (iOutputParameters) { oscl_free(iOutputParameters); iOutputParameters = NULL; } if (ipAppPriv) { oscl_free(ipAppPriv); ipAppPriv = NULL; } #if PROXY_INTERFACE if (ipThreadSafeHandlerEventHandler) { OSCL_DELETE(ipThreadSafeHandlerEventHandler); ipThreadSafeHandlerEventHandler = NULL; } if (ipThreadSafeHandlerEmptyBufferDone) { OSCL_DELETE(ipThreadSafeHandlerEmptyBufferDone); ipThreadSafeHandlerEmptyBufferDone = NULL; } if (ipThreadSafeHandlerFillBufferDone) { OSCL_DELETE(ipThreadSafeHandlerFillBufferDone); ipThreadSafeHandlerFillBufferDone = NULL; } #endif //VerifyOutput(TestName); if (OMX_FALSE == iTestStatus) { #ifdef PRINT_RESULT fprintf(iConsOutFile, "%s: Fail \n", TestName); #endif PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO, (0, "OmxDecTestFlushPort::Run() - %s : Fail", TestName)); } else { #ifdef PRINT_RESULT fprintf(iConsOutFile, "%s: Success \n", TestName); #endif PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO, (0, "OmxDecTestFlushPort::Run() - %s : Success", TestName)); } iState = StateUnLoaded; OsclExecScheduler* sched = OsclExecScheduler::Current(); sched->StopScheduler(); } break; case StateError: { //Do all the cleanup's and exit from here OMX_U32 ii; PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "OmxDecTestFlushPort::Run() - StateError IN")); iTestStatus = OMX_FALSE; if (ipInBuffer) { for (ii = 0; ii < iInBufferCount; ii++) { if (ipInBuffer[ii]) { OMX_FreeBuffer(ipAppPriv->Handle, iInputPortIndex, ipInBuffer[ii]); ipInBuffer[ii] = NULL; PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OmxDecTestFlushPort::Run() - Called FreeBuffer for buffer index %d on port %d", ii, iInputPortIndex)); } } oscl_free(ipInBuffer); ipInBuffer = NULL; } if (ipInputAvail) { oscl_free(ipInputAvail); ipInputAvail = NULL; } if (ipOutBuffer) { for (ii = 0; ii < iOutBufferCount; ii++) { if (ipOutBuffer[ii]) { OMX_FreeBuffer(ipAppPriv->Handle, iOutputPortIndex, ipOutBuffer[ii]); ipOutBuffer[ii] = NULL; PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OmxDecTestFlushPort::Run() - Called FreeBuffer for buffer index %d on port %d", ii, iOutputPortIndex)); } } oscl_free(ipOutBuffer); ipOutBuffer = NULL; } if (ipOutReleased) { oscl_free(ipOutReleased); ipOutReleased = NULL; } iState = StateStop; RunIfNotReady(); PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "OmxDecTestFlushPort::Run() - StateError OUT")); } break; default: { break; } } return ; }
void pv_metadata_engine_test::CommandCompleted(const PVCmdResponse& aResponse) { //if this callback is from pvme thread, then push it across the thread //boundary. if (iPVMEContainer.iMode == PV_METADATA_ENGINE_THREADED_MODE) { if (!iThreadSafeCommandQueue.IsInThread()) { PVCmdResponse* cmd = OSCL_NEW(PVCmdResponse, (aResponse)); iThreadSafeCommandQueue.AddToQueue(cmd); return; } } if (aResponse.GetCmdId() != iCurrentCmdId) { // Wrong command ID. PVMEATB_TEST_IS_TRUE(false); iState = STATE_RESET; RunIfNotReady(); return; } if (aResponse.GetContext() != NULL) { if (aResponse.GetContext() == (OsclAny*)&iContextObject) { if (iContextObject != iContextObjectRefValue) { // Context data value was corrupted PVMEATB_TEST_IS_TRUE(false); iState = STATE_RESET; RunIfNotReady(); return; } } else { // Context data pointer was corrupted PVMEATB_TEST_IS_TRUE(false); iState = STATE_RESET; RunIfNotReady(); return; } } switch (iState) { case STATE_INIT: if (aResponse.GetCmdStatus() == PVMFSuccess) { PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iPerfLogger, PVLOGMSG_INFO, (0, "PVMetadataEngineTest::Init completed sucessfully ClockInMS=%d", OsclTickCount::TicksToMsec(OsclTickCount::TickCount()))); iState = STATE_SETMETADATAKEYS; RunIfNotReady(); } else { // Init failed PVMEATB_TEST_IS_TRUE(false); PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iPerfLogger, PVLOGMSG_INFO, (0, "PVMetadataEngineTest::Init failed ClockInMS=%d", OsclTickCount::TicksToMsec(OsclTickCount::TickCount()))); iState = STATE_RESET; RunIfNotReady(); } break; case STATE_GETMETADATA: if (aResponse.GetCmdStatus() == PVMFSuccess) { end_time = OsclTickCount::TicksToMsec(OsclTickCount::TickCount()); AverageGetMetaDataTimeInMS = AverageGetMetaDataTimeInMS + (end_time - start_time); if (MaxGetMetaDataTime < (end_time - start_time)) { MaxGetMetaDataTime = (end_time - start_time); } if (metadataForFirstClip == true) //If this is the first clip { MinGetMetaDataTime = (end_time - start_time); } if (MinGetMetaDataTime > (end_time - start_time)) { MinGetMetaDataTime = (end_time - start_time); } PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iPerfLogger, PVLOGMSG_INFO, (0, "PVMetadataEngineTest::GetMetaData completed sucessfully ClockInMS=(%d), TimeTakenInMS=(%d)", end_time, (end_time - start_time))); PrintSupportedMetaDataKeys(); if (it < iClips.end()) { iState = STATE_GETMETADATA; metadataForFirstClip = false; } else { iState = STATE_RESET; } RunIfNotReady(); } else { // GetMetadata failed PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iPerfLogger, PVLOGMSG_INFO, (0, "PVMetadataEngineTest::GetMetadata failed ClockInMS=%d", OsclTickCount::TicksToMsec(OsclTickCount::TickCount()))); PVMEATB_TEST_IS_TRUE(false); iState = STATE_RESET; RunIfNotReady(); } break; case STATE_RESET: if (aResponse.GetCmdStatus() == PVMFSuccess) { PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iPerfLogger, PVLOGMSG_INFO, (0, "PVMetadataEngineTest::Reset completed sucessfully ClockInMS=%d", OsclTickCount::TicksToMsec(OsclTickCount::TickCount()))); PVMEATB_TEST_IS_TRUE(true); iState = STATE_DELETE; RunIfNotReady(); } break; default: { // Testing error if this is reached PVMEATB_TEST_IS_TRUE(false); iState = STATE_RESET; RunIfNotReady(); } break; } }
void OmxEncTestCompRole::Run() { switch (iState) { case StateUnLoaded: { OMX_ERRORTYPE Err; OMX_U32 ii; OMX_U32 NumComps = 0; OMX_STRING* pCompOfRole = NULL; PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "OmxEncTestCompRole::Run() - StateUnLoaded IN")); #if PROXY_INTERFACE ipThreadSafeHandlerEventHandler = OSCL_NEW(OmxEncEventHandlerThreadSafeCallbackAO, (this, EVENT_HANDLER_QUEUE_DEPTH, "EventHandlerAO")); ipThreadSafeHandlerEmptyBufferDone = OSCL_NEW(OmxEncEmptyBufferDoneThreadSafeCallbackAO, (this, EMPTY_BUFFER_DONE_QUEUE_DEPTH, "EmptyBufferDoneAO")); ipThreadSafeHandlerFillBufferDone = OSCL_NEW(OmxEncFillBufferDoneThreadSafeCallbackAO, (this, FILL_BUFFER_DONE_QUEUE_DEPTH, "FillBufferDoneAO")); if ((NULL == ipThreadSafeHandlerEventHandler) || (NULL == ipThreadSafeHandlerEmptyBufferDone) || (NULL == ipThreadSafeHandlerFillBufferDone)) { PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "OmxEncTestCompRole::Run() - Error, ThreadSafe Callback Handler initialization failed, OUT")); iState = StateUnLoaded; OsclExecScheduler* sched = OsclExecScheduler::Current(); sched->StopScheduler(); } #endif if (!iCallbacks->initCallbacks()) { PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "OmxEncTestCompRole::Run() - ERROR initCallbacks failed, OUT")); iTestStatus = OMX_FALSE; iState = StateStop; RunIfNotReady(); break; } ipAppPriv = (AppPrivateType*) oscl_malloc(sizeof(AppPrivateType)); CHECK_MEM_ROLE_TEST(ipAppPriv, "Component_Handle"); //This should be the first call to the component to load it. Err = OMX_MasterInit(); CHECK_ERROR_ROLE_TEST(Err, "OMX_MasterInit"); PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OmxEncTestCompRole::Run() - OMX_MasterInit done")); if (NULL != iRole) { PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OmxEncTestCompRole::Run() - Finding out the components that can support the role %s", iRole)); //Given the role, determine the component first & then get the handle // Call once to find out the number of components that can fit the role Err = OMX_MasterGetComponentsOfRole(iRole, &NumComps, NULL); if (OMX_ErrorNone != Err || NumComps < 1) { PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "OmxEncTestCompRole::Run() - ERROR, No component can handle the specified role %s", iRole)); iTestStatus = OMX_FALSE; ipAppPriv->Handle = NULL; iState = StateStop; RunIfNotReady(); break; } pCompOfRole = (OMX_STRING*) oscl_malloc(NumComps * sizeof(OMX_STRING)); CHECK_MEM_ROLE_TEST(pCompOfRole, "ComponentRoleArray"); for (ii = 0; ii < NumComps; ii++) { pCompOfRole[ii] = (OMX_STRING) oscl_malloc(PV_OMX_MAX_COMPONENT_NAME_LENGTH * sizeof(OMX_U8)); CHECK_MEM_ROLE_TEST(pCompOfRole[ii], "ComponentRoleArray"); } if (OMX_FALSE == iTestStatus) { PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "OmxEncTestCompRole::Run() - Error occured in this state, StateUnLoaded OUT")); break; } // call 2nd time to get the component names Err = OMX_MasterGetComponentsOfRole(iRole, &NumComps, (OMX_U8**) pCompOfRole); CHECK_ERROR_ROLE_TEST(Err, "GetComponentsOfRole"); for (ii = 0; ii < NumComps; ii++) { // try to create component Err = OMX_MasterGetHandle(&ipAppPriv->Handle, (OMX_STRING) pCompOfRole[ii], (OMX_PTR) this, iCallbacks->getCallbackStruct()); // if successful, no need to continue if ((OMX_ErrorNone == Err) && (NULL != ipAppPriv->Handle)) { PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OmxEncTestCompRole::Run() - Got Handle for the component %s", pCompOfRole[ii])); break; } else { PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "OmxEncTestCompRole::Run() - ERROR, Cannot get component %s handle, try another if possible", pCompOfRole[ii])); } } CHECK_ERROR_ROLE_TEST(Err, "GetHandle"); CHECK_MEM_ROLE_TEST(ipAppPriv->Handle, "ComponentHandle"); } //Free the role of component arrays if (pCompOfRole) { for (ii = 0; ii < NumComps; ii++) { oscl_free(pCompOfRole[ii]); pCompOfRole[ii] = NULL; } oscl_free(pCompOfRole); pCompOfRole = NULL; } iState = StateStop; PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "OmxEncTestCompRole::Run() - StateUnLoaded OUT, moving to next state")); RunIfNotReady(); } break; /********* FREE THE HANDLE & CLOSE FILES FOR THE COMPONENT ********/ case StateStop: { OMX_U8 TestName[] = "GET_ROLES_TEST"; OMX_ERRORTYPE Err = OMX_ErrorNone; PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "OmxEncTestCompRole::Run() - StateStop IN")); if (ipAppPriv) { if (ipAppPriv->Handle) { PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OmxEncTestCompRole::Run() - Free the Component Handle")); Err = OMX_MasterFreeHandle(ipAppPriv->Handle); if (OMX_ErrorNone != Err) { PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "OmxEncTestCompRole::Run() - FreeHandle Error")); iTestStatus = OMX_FALSE; } } } PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OmxEncTestCompRole::Run() - De-initialize the omx component")); Err = OMX_MasterDeinit(); if (OMX_ErrorNone != Err) { PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "OmxEncTestCompRole::Run() - OMX_MasterDeinit Error")); iTestStatus = OMX_FALSE; } if (ipAppPriv) { oscl_free(ipAppPriv); ipAppPriv = NULL; } #if PROXY_INTERFACE OSCL_DELETE(ipThreadSafeHandlerEventHandler); ipThreadSafeHandlerEventHandler = NULL; OSCL_DELETE(ipThreadSafeHandlerEmptyBufferDone); ipThreadSafeHandlerEmptyBufferDone = NULL; OSCL_DELETE(ipThreadSafeHandlerFillBufferDone); ipThreadSafeHandlerFillBufferDone = NULL; #endif if (OMX_FALSE == iTestStatus) { #ifdef PRINT_RESULT printf("%s: Fail \n", TestName); #endif PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO, (0, "OmxComponentEncTest::VerifyOutput() - %s : Fail", TestName)); } else { #ifdef PRINT_RESULT printf("%s: Success \n", TestName); OMX_ENC_TEST(true); iTestCase->TestCompleted(); #endif PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO, (0, "OmxComponentEncTest::VerifyOutput() - %s : Success", TestName)); } PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "OmxEncTestCompRole::Run() - StateStop OUT")); iState = StateUnLoaded; OsclExecScheduler* sched = OsclExecScheduler::Current(); sched->StopScheduler(); } break; default: { break; } } return ; }
/* ======================================================================== */ OSCL_EXPORT_REF PVWavParserReturnCode PV_Wav_Parser::InitWavParser(OSCL_wString& aClip, Oscl_FileServer* aFileSession) { //buffer uint8 iBuffer[36]; // If a WAV file is already open, close it first and delete the file pointer CleanupWAVFile(); // Open the file (aClip) ipWAVFile = OSCL_NEW(Oscl_File, (4096)); if (ipWAVFile == NULL) { return PVWAVPARSER_READ_ERROR; } if (ipWAVFile->Open(aClip.get_cstr(), (Oscl_File::MODE_READ | Oscl_File::MODE_BINARY), *aFileSession) != 0) { OSCL_DELETE(ipWAVFile); ipWAVFile = NULL; return PVWAVPARSER_READ_ERROR; } // Get file size at the very first time int32 filesize = 0; if (ipWAVFile->Seek(0, Oscl_File::SEEKEND)) { CleanupWAVFile(); return PVWAVPARSER_MISC_ERROR; } filesize = ipWAVFile->Tell(); if (filesize <= 0) { CleanupWAVFile(); return PVWAVPARSER_MISC_ERROR; } if (ipWAVFile->Seek(0, Oscl_File::SEEKSET)) { CleanupWAVFile(); return PVWAVPARSER_MISC_ERROR; } int32 filepos = 0; // read 12 bytes of data for complete WAVE header including RIFF chunk dDescriptor uint32 bytesread = 0; if (ReadData(iBuffer, 12, bytesread) != PVWAVPARSER_OK) { CleanupWAVFile(); return PVWAVPARSER_READ_ERROR; } if (bytesread != 12) { CleanupWAVFile(); return PVWAVPARSER_READ_ERROR; } // Update file position counter by 36 bytes filepos += 12; // Check for RIFF/RIFX uint8* pBuffer = &iBuffer[0]; if (pBuffer[0] == 'R' && pBuffer[1] == 'I' && pBuffer[2] == 'F' && pBuffer[3] == 'F') { isLittleEndian = 1; // Little endian data } else if (pBuffer[0] == 'R' && pBuffer[1] == 'I' && pBuffer[2] == 'F' && pBuffer[3] == 'X') { isLittleEndian = 0; // Big endian data } else { CleanupWAVFile(); return PVWAVPARSER_UNSUPPORTED_FORMAT; } // If a .wav file is clipped manually , the ChunkSize would not relate to the file size. However, we // should still attempt to play that clip for the existing length of the file. To enforce the restriction, // we may opt to uncomment the following lines of code. // To read ChunkSize (in RIFF chunk descriptor) from little endian /* uint32 ChunkSize; ChunkSize = (((*(pBuffer + 7)) <<24)|((*(pBuffer + 6)) << 16)|((*(pBuffer + 5)) << 8)|(*(pBuffer + 4))); if((int32)ChunkSize!= (filesize - 8)) { CleanupWAVFile(); return PVWAVPARSER_MISC_ERROR; } */ // Check for WAVE in Format field if (pBuffer[ 8] != 'W' || pBuffer[ 9] != 'A' || pBuffer[10] != 'V' || pBuffer[11] != 'E') { CleanupWAVFile(); return PVWAVPARSER_UNSUPPORTED_FORMAT; } uint32 SubChunk_Size = 0; bool fmtSubchunkFound = false; while (!fmtSubchunkFound) { // read 8 bytes from file to check for next subchunk bytesread = 0; if (ReadData(iBuffer, 8, bytesread) != PVWAVPARSER_OK) { CleanupWAVFile(); return PVWAVPARSER_READ_ERROR; } if (bytesread != 8) { CleanupWAVFile(); return PVWAVPARSER_READ_ERROR; } // Update file position counter by 8 bytes filepos += 8; uint8* pTempBuffer = &iBuffer[0]; SubChunk_Size = (((*(pTempBuffer + 7)) << 24) | ((*(pTempBuffer + 6)) << 16) | ((*(pTempBuffer + 5)) << 8) | (*(pTempBuffer + 4))); // typecast filesize as uint32 - to get to this point, it MUST be // greater than 0. if ((filepos + SubChunk_Size) > (uint32)filesize) { CleanupWAVFile(); return PVWAVPARSER_MISC_ERROR; } // Check for FMT subchunk if (pTempBuffer[0] != 'f' || pTempBuffer[1] != 'm' || pTempBuffer[2] != 't' || pTempBuffer[3] != ' ') { // "fmt " chunk not found - Unknown subchunk filepos += SubChunk_Size; if (ipWAVFile->Seek(filepos, Oscl_File::SEEKSET)) { CleanupWAVFile(); return PVWAVPARSER_MISC_ERROR; } } else fmtSubchunkFound = true; } if (ReadData(iBuffer, 16, bytesread) != PVWAVPARSER_OK) { CleanupWAVFile(); return PVWAVPARSER_READ_ERROR; } if (bytesread != 16) { CleanupWAVFile(); return PVWAVPARSER_READ_ERROR; } filepos += 16; pBuffer = &iBuffer[0]; AudioFormat = (unsigned short)(((*(pBuffer + 1)) << 8) | (*pBuffer)); // Save AudioFormat (PCM = 1) xLawTable = NULL; NumChannels = (unsigned short)(((*(pBuffer + 3)) << 8) | (*(pBuffer + 2))); // Save Number of Channels SampleRate = (((*(pBuffer + 7)) << 24) | ((*(pBuffer + 6)) << 16) | ((*(pBuffer + 5)) << 8) | (*(pBuffer + 4))); // Save Sampling rate ByteRate = (((*(pBuffer + 11)) << 24) | ((*(pBuffer + 10)) << 16) | ((*(pBuffer + 9)) << 8) | (*(pBuffer + 8))); // Save ByteRate ( == SampleRate*NumChannels*BitsPerSample/8) BlockAlign = (unsigned short)(((*(pBuffer + 13)) << 8) | (*(pBuffer + 12))); // Save BlockAlign ( == NumChannels*BitsPerSample/8) BitsPerSample = (unsigned short)(((*(pBuffer + 15)) << 8) | (*(pBuffer + 14))); // Save BitsPerSample (8 bits == 8, 16 bits == 16 etc.) BytesPerSample = (BitsPerSample + 7) / 8; // compute (ceil(BitsPerSample/8)) // Check for SubChunk_Size (It should be 16 for PCM) // skip remaining bytes if any because we don't currently support any compressed audio formats if (SubChunk_Size != 16) { // seek ahead by Subchunk1_Size - 16 filepos += SubChunk_Size - 16; if (ipWAVFile->Seek(filepos, Oscl_File::SEEKSET)) { CleanupWAVFile(); return PVWAVPARSER_MISC_ERROR; } } bool DataSubchunkFound = false; while (!DataSubchunkFound) { // read 8 bytes from file to check for next subchunk bytesread = 0; if (ReadData(iBuffer, 8, bytesread) != PVWAVPARSER_OK) { CleanupWAVFile(); return PVWAVPARSER_READ_ERROR; } if (bytesread != 8) { CleanupWAVFile(); return PVWAVPARSER_READ_ERROR; } // Update file position counter by 8 bytes filepos += 8; uint8* pTempBuffer = &iBuffer[0]; //It means that some unknown subchunk is present // Calculate SubChunk Size SubChunk_Size = (((*(pTempBuffer + 7)) << 24) | ((*(pTempBuffer + 6)) << 16) | ((*(pTempBuffer + 5)) << 8) | (*(pTempBuffer + 4))); // Check for DATA subchunk ID if (pTempBuffer[0] != 'd' || pTempBuffer[1] != 'a' || pTempBuffer[2] != 't' || pTempBuffer[3] != 'a') { // we need to skip this many bytes filepos += SubChunk_Size; // seek file pointer to current file position if (ipWAVFile->Seek(filepos, Oscl_File::SEEKSET)) { CleanupWAVFile(); return PVWAVPARSER_MISC_ERROR; } } else { // data subchunk found // header size equals current file pos iHeaderSize = filepos; //data subchunk is found DataSubchunkFound = true; // Read data SubChunk Size (is number of bytes in data or PCMBytesPresent) PCMBytesPresent = SubChunk_Size; iEndOfDataSubChunkOffset = filepos + PCMBytesPresent; //This is where the DataSubChunk is supposed to end //(this check is required to avoid memory crash if any of BytesPerSample or NumChannels is '0') if (BytesPerSample && NumChannels) { NumSamples = ((PCMBytesPresent / (BytesPerSample)) / NumChannels); } } } //return error if any of these value is not given in wav file header //(AudioFormat check is done at node level) if (!NumChannels || !NumSamples || !SampleRate || !BitsPerSample || !BytesPerSample || !ByteRate) { CleanupWAVFile(); return PVWAVPARSER_UNSUPPORTED_FORMAT; //any error fom parse will be handled as PVMFFailure at corresponsding node level } return PVWAVPARSER_OK; }
PVAviFileHeader::PVAviFileHeader(PVFile *aFp, uint32 aHdrSize) { iHeaderTotalSize = aHdrSize; uint32 bytesRead = 0; uint32 chunkType = 0; uint32 oldChkType = 0; iError = PV_AVI_FILE_PARSER_SUCCESS; for (uint32 ii = 0; ii < iStreamList.size(); ii++) { iStreamList.pop_back(); } uint32 streamListSz = 0; while (bytesRead < iHeaderTotalSize) { oldChkType = chunkType; if ((iError = PVAviFileParserUtils::ReadNextChunkType(aFp, chunkType)) != PV_AVI_FILE_PARSER_SUCCESS) { if ((PV_AVI_FILE_PARSER_UNSUPPORTED_CHUNK == iError)) { PVAVIFILE_LOGINFO((0, "PVAviFileHeader::PVAviFileHeader: Unsupported chunk")); uint32 chksz = 0; if (oldChkType != LIST) { //get the size of unsupported chunk and skip it. if (PVAviFileParserUtils::read32(aFp, chksz, true) != PV_AVI_FILE_PARSER_SUCCESS) { PVAVIFILE_LOGERROR((0, "PVAviFileHeader::PVAviFileHeader: File Read Error")); iError = PV_AVI_FILE_PARSER_READ_ERROR; break; } aFp->Seek(chksz, Oscl_File::SEEKCUR); bytesRead += chksz + CHUNK_SIZE + CHUNK_SIZE; //data + chunk size + chunk type } else { //skip the entire list if not supported aFp->Seek((streamListSz - CHUNK_SIZE), Oscl_File::SEEKCUR); //subtract list name read above bytesRead += streamListSz; } PVAVIFILE_LOGINFO((0, "PVAviFileHeader::PVAviFileHeader: Unsupported chunk skipped")); iError = PV_AVI_FILE_PARSER_SUCCESS; continue; } else { break; } } bytesRead += CHUNK_SIZE; if (bytesRead > iHeaderTotalSize) { PVAVIFILE_LOGERROR((0, "PVAviFileHeader::PVAviFileHeader: File Size & Byte Count mismatch")); iError = PV_AVI_FILE_PARSER_BYTE_COUNT_ERROR; break; } if (AVIH == chunkType) { uint32 aviStrSize = 0; if (PVAviFileParserUtils::read32(aFp, aviStrSize, true) != PV_AVI_FILE_PARSER_SUCCESS) { PVAVIFILE_LOGERROR((0, "PVAviFileHeader::PVAviFileHeader: File Read Error")); iError = PV_AVI_FILE_PARSER_READ_ERROR; break; } bytesRead += CHUNK_SIZE; if (bytesRead > iHeaderTotalSize) { PVAVIFILE_LOGERROR((0, "PVAviFileHeader::PVAviFileHeader: File Size & Byte Count mismatch")); iError = PV_AVI_FILE_PARSER_BYTE_COUNT_ERROR; break; } if ((aviStrSize <= 0) || (aviStrSize > iHeaderTotalSize)) { PVAVIFILE_LOGERROR((0, "PVAviFileHeader::PVAviFileHeader: AVIH size greater than file header size")); iError = PV_AVI_FILE_PARSER_WRONG_SIZE; break; } if ((iError = ParseMainHeader(aFp)) != PV_AVI_FILE_PARSER_SUCCESS) { PVAVIFILE_LOGERROR((0, "PVAviFileHeader::PVAviFileHeader: Error encountered while parsing File Header")); break; } bytesRead += aviStrSize; if (bytesRead > iHeaderTotalSize) { PVAVIFILE_LOGERROR((0, "PVAviFileHeader::PVAviFileHeader: File Size & Byte Count mismatch")); iError = PV_AVI_FILE_PARSER_BYTE_COUNT_ERROR; break; } } else if (LIST == chunkType) { if (PVAviFileParserUtils::read32(aFp, streamListSz, true) != PV_AVI_FILE_PARSER_SUCCESS) { PVAVIFILE_LOGERROR((0, "PVAviFileHeader::PVAviFileHeader: File Read Error")); iError = PV_AVI_FILE_PARSER_READ_ERROR; break; } bytesRead += CHUNK_SIZE; if (bytesRead > iHeaderTotalSize) { PVAVIFILE_LOGERROR((0, "PVAviFileHeader::PVAviFileHeader: File Size & Byte Count mismatch")); iError = PV_AVI_FILE_PARSER_BYTE_COUNT_ERROR; break; } if ((streamListSz <= 0) || (streamListSz > iHeaderTotalSize)) { PVAVIFILE_LOGERROR((0, "PVAviFileHeader::PVAviFileHeader: stream list soze greater tha file header size")); iError = PV_AVI_FILE_PARSER_WRONG_SIZE; break; } } else if (STRL == chunkType) { PVAVIFILE_LOGINFO((0, "PVAviFileHeader::PVAviFileHeader: Found stream list")); PVAviFileStreamlist* strlst = OSCL_NEW(PVAviFileStreamlist, (aFp, (streamListSz - CHUNK_SIZE))); //subtract 4 bytes of List type from list size if (strlst != NULL) { if ((iError = strlst->GetStatus()) != PV_AVI_FILE_PARSER_SUCCESS) { OSCL_DELETE(strlst); strlst = NULL; break; } } iStreamList.push_back(*strlst); bytesRead += streamListSz - CHUNK_SIZE; if (bytesRead > iHeaderTotalSize) { PVAVIFILE_LOGERROR((0, "PVAviFileHeader::PVAviFileHeader: File Size & Byte Count mismatch")); iError = PV_AVI_FILE_PARSER_BYTE_COUNT_ERROR; break; } OSCL_DELETE(strlst); } else if (JUNK == chunkType) { PVAVIFILE_LOGINFO((0, "PVAviFileParser::ParseFile: Skip Junk data")); uint32 junkSize = 0; if (PVAviFileParserUtils::read32(aFp, junkSize, true) != PV_AVI_FILE_PARSER_SUCCESS) { PVAVIFILE_LOGERROR((0, "PVAviFileHeader::PVAviFileHeader: File Read Error")); iError = PV_AVI_FILE_PARSER_READ_ERROR; break; } bytesRead += CHUNK_SIZE; if (bytesRead > iHeaderTotalSize) { PVAVIFILE_LOGERROR((0, "PVAviFileHeader::PVAviFileHeader: File Size & Byte Count mismatch")); iError = PV_AVI_FILE_PARSER_BYTE_COUNT_ERROR; break; } if ((junkSize <= 0) || (junkSize > iHeaderTotalSize)) { PVAVIFILE_LOGERROR((0, "PVAviFileHeader::PVAviFileHeader: Junk data size more than file header size")); iError = PV_AVI_FILE_PARSER_WRONG_SIZE; break; } aFp->Seek(junkSize, Oscl_File::SEEKCUR); bytesRead += junkSize; if (bytesRead > iHeaderTotalSize) { PVAVIFILE_LOGERROR((0, "PVAviFileHeader::PVAviFileHeader: File Size & Byte Count mismatch")); iError = PV_AVI_FILE_PARSER_BYTE_COUNT_ERROR; break; } } else { PVAVIFILE_LOGERROR((0, "PVAviFileHeader::PVAviFileHeader: Chunk not supported in file main header")); iError = PV_AVI_FILE_PARSER_WRONG_CHUNK; break; } } if ((PV_AVI_FILE_PARSER_SUCCESS == iError) && (iStreamList.size() != iMainHeader.iStreams)) { PVAVIFILE_LOGERROR((0, "PVAviFileHeader::PVAviFileHeader: ")); iError = PV_AVI_FILE_PARSER_ERROR_NUM_STREAM; } }
/* Delete this */ OSCL_EXPORT_REF CPVH223Multiplex* AllocateH223Mux(TPVLoopbackMode aLoopbackMode) { return OSCL_NEW(CPVH223Multiplex, (aLoopbackMode)); }
OsclComponentRegistryElement::OsclComponentRegistryElement(OSCL_String& compid, OsclComponentFactory fac) : iId(NULL) , iFactory(fac) { iId = OSCL_NEW(OSCL_HeapString<OsclMemAllocator>, (compid)); }
void OmxDecTestWithoutMarker::Run() { switch (iState) { case StateUnLoaded: { PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "OmxDecTestWithoutMarker::Run() - StateUnLoaded IN")); OMX_ERRORTYPE Err; OMX_BOOL Status; if (!iCallbacks->initCallbacks()) { PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "OmxDecTestWithoutMarker::Run() - ERROR initCallbacks failed, OUT")); StopOnError(); break; } ipAppPriv = (AppPrivateType*) oscl_malloc(sizeof(AppPrivateType)); CHECK_MEM(ipAppPriv, "Component_Handle"); ipAppPriv->Handle = NULL; //Allocate bitstream buffer for AVC component if (0 == oscl_strcmp(iFormat, "H264")) { ipAVCBSO = OSCL_NEW(AVCBitstreamObject, (ipInputFile)); CHECK_MEM(ipAVCBSO, "Bitstream_Buffer"); } //Allocate bitstream buffer for MPEG4/H263 component if (0 == oscl_strcmp(iFormat, "M4V") || 0 == oscl_strcmp(iFormat, "H263")) { ipBitstreamBuffer = (OMX_U8*) oscl_malloc(BIT_BUFF_SIZE); CHECK_MEM(ipBitstreamBuffer, "Bitstream_Buffer") ipBitstreamBufferPointer = ipBitstreamBuffer; } iNoMarkerBitTest = OMX_TRUE; //This should be the first call to the component to load it. Err = OMX_MasterInit(); CHECK_ERROR(Err, "OMX_MasterInit"); PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OmxDecTestWithoutMarker::Run() - OMX_MasterInit done")); Status = PrepareComponent(); if (OMX_FALSE == Status) { PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OmxDecTestWithoutMarker::Run() Error while loading component OUT")); iState = StateError; if (iInputParameters.inPtr) { oscl_free(iInputParameters.inPtr); iInputParameters.inPtr = NULL; } RunIfNotReady(); break; } #if PROXY_INTERFACE ipThreadSafeHandlerEventHandler = OSCL_NEW(OmxEventHandlerThreadSafeCallbackAO, (this, EVENT_HANDLER_QUEUE_DEPTH, "EventHandlerAO")); ipThreadSafeHandlerEmptyBufferDone = OSCL_NEW(OmxEmptyBufferDoneThreadSafeCallbackAO, (this, iInBufferCount, "EmptyBufferDoneAO")); ipThreadSafeHandlerFillBufferDone = OSCL_NEW(OmxFillBufferDoneThreadSafeCallbackAO, (this, iOutBufferCount, "FillBufferDoneAO")); if ((NULL == ipThreadSafeHandlerEventHandler) || (NULL == ipThreadSafeHandlerEmptyBufferDone) || (NULL == ipThreadSafeHandlerFillBufferDone)) { PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "OmxDecTestWithoutMarker::Run() - Error ThreadSafe Callback Handler initialization failed, OUT")); iState = StateUnLoaded; OsclExecScheduler* sched = OsclExecScheduler::Current(); sched->StopScheduler(); } #endif if (StateError != iState) { iState = StateLoaded; PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "OmxDecTestWithoutMarker::Run() - StateUnLoaded OUT, moving to next state")); } RunIfNotReady(); } break; case StateLoaded: { OMX_ERRORTYPE Err; OMX_U32 ii; PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "OmxDecTestWithoutMarker::Run() - StateLoaded IN")); // allocate memory for ipInBuffer ipInBuffer = (OMX_BUFFERHEADERTYPE**) oscl_malloc(sizeof(OMX_BUFFERHEADERTYPE*) * iInBufferCount); CHECK_MEM(ipInBuffer, "InputBufferHeader"); ipInputAvail = (OMX_BOOL*) oscl_malloc(sizeof(OMX_BOOL) * iInBufferCount); CHECK_MEM(ipInputAvail, "InputBufferFlag"); /* Initialize all the buffers to NULL */ for (ii = 0; ii < iInBufferCount; ii++) { ipInBuffer[ii] = NULL; } //allocate memory for output buffer ipOutBuffer = (OMX_BUFFERHEADERTYPE**) oscl_malloc(sizeof(OMX_BUFFERHEADERTYPE*) * iOutBufferCount); CHECK_MEM(ipOutBuffer, "OutputBuffer"); ipOutReleased = (OMX_BOOL*) oscl_malloc(sizeof(OMX_BOOL) * iOutBufferCount); CHECK_MEM(ipOutReleased, "OutputBufferFlag"); /* Initialize all the buffers to NULL */ for (ii = 0; ii < iOutBufferCount; ii++) { ipOutBuffer[ii] = NULL; } Err = OMX_SendCommand(ipAppPriv->Handle, OMX_CommandStateSet, OMX_StateIdle, NULL); CHECK_ERROR(Err, "SendCommand Loaded->Idle"); PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OmxDecTestWithoutMarker::Run() - Sent State Transition Command from Loaded->Idle")); iPendingCommands = 1; PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OmxDecTestWithoutMarker::Run() - Allocating %d input and %d output buffers", iInBufferCount, iOutBufferCount)); //These calls are required because the control of in & out buffer should be with the testapp. for (ii = 0; ii < iInBufferCount; ii++) { Err = OMX_AllocateBuffer(ipAppPriv->Handle, &ipInBuffer[ii], iInputPortIndex, NULL, iInBufferSize); CHECK_ERROR(Err, "AllocateBuffer_Input"); PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OmxDecTestWithoutMarker::Run() - Called AllocateBuffer for buffer index %d on port %d", ii, iInputPortIndex)); ipInputAvail[ii] = OMX_TRUE; ipInBuffer[ii]->nInputPortIndex = iInputPortIndex; } if (StateError == iState) { PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "OmxDecTestWithoutMarker::Run() - AllocateBuffer Error, StateLoaded OUT")); RunIfNotReady(); break; } for (ii = 0; ii < iOutBufferCount; ii++) { Err = OMX_AllocateBuffer(ipAppPriv->Handle, &ipOutBuffer[ii], iOutputPortIndex, NULL, iOutBufferSize); CHECK_ERROR(Err, "AllocateBuffer_Output"); PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OmxDecTestWithoutMarker::Run() - Called AllocateBuffer for buffer index %d on port %d", ii, iOutputPortIndex)); ipOutReleased[ii] = OMX_TRUE; ipOutBuffer[ii]->nOutputPortIndex = iOutputPortIndex; ipOutBuffer[ii]->nInputPortIndex = 0; } if (StateError == iState) { PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "OmxDecTestWithoutMarker::Run() - AllocateBuffer Error, StateLoaded OUT")); RunIfNotReady(); break; } PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "OmxDecTestWithoutMarker::Run() - StateLoaded OUT, Moving to next state")); } break; case StateIdle: { PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "OmxDecTestWithoutMarker::Run() - StateIdle IN")); OMX_ERRORTYPE Err = OMX_ErrorNone; /*Send an output buffer before dynamic reconfig */ Err = OMX_FillThisBuffer(ipAppPriv->Handle, ipOutBuffer[0]); CHECK_ERROR(Err, "FillThisBuffer"); PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OmxDecTestWithoutMarker::Run() - FillThisBuffer command called for initiating dynamic port reconfiguration")); ipOutReleased[0] = OMX_FALSE; Err = OMX_SendCommand(ipAppPriv->Handle, OMX_CommandStateSet, OMX_StateExecuting, NULL); CHECK_ERROR(Err, "SendCommand Idle->Executing"); PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OmxDecTestWithoutMarker::Run() - Sent State Transition Command from Idle->Executing")); iPendingCommands = 1; PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "OmxDecTestWithoutMarker::Run() - StateIdle OUT")); } break; case StateDecodeHeader: { PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "OmxDecTestWithoutMarker::Run() - StateDecodeHeader IN, Sending configuration input buffers to the component to start dynamic port reconfiguration")); if (!iFlagDecodeHeader) { if (0 == oscl_strcmp(iFormat, "WMV") || 0 == oscl_strcmp(iFormat, "WMA") || 0 == oscl_strcmp(iFormat, "RV") || 0 == oscl_strcmp(iFormat, "RA")) { (*this.*pGetInputFrame)(); } else { GetInput(); } iFlagDecodeHeader = OMX_TRUE; //Proceed to executing state and if Port settings changed callback comes, //then do the dynamic port reconfiguration iState = StateExecuting; RunIfNotReady(); } PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "OmxDecTestWithoutMarker::Run() - StateDecodeHeader OUT")); } break; case StateDisablePort: { OMX_ERRORTYPE Err = OMX_ErrorNone; OMX_U32 ii; PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "OmxDecTestWithoutMarker::Run() - StateDisablePort IN")); if (!iDisableRun) { if (!iFlagDisablePort) { Err = OMX_SendCommand(ipAppPriv->Handle, OMX_CommandPortDisable, iOutputPortIndex, NULL); CHECK_ERROR(Err, "SendCommand_PortDisable"); PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OmxDecTestWithoutMarker::Run() - Sent Command for OMX_CommandPortDisable on port %d as a part of dynamic port reconfiguration", iOutputPortIndex)); iPendingCommands = 1; iFlagDisablePort = OMX_TRUE; RunIfNotReady(); } else { //Wait for all the buffers to be returned on output port before freeing them //This wait is required because of the queueing delay in all the Callbacks for (ii = 0; ii < iOutBufferCount; ii++) { if (OMX_FALSE == ipOutReleased[ii]) { break; } } if (ii != iOutBufferCount) { PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OmxDecTestWithoutMarker::Run() - Not all the output buffers returned by component yet, wait for it")); RunIfNotReady(); break; } for (ii = 0; ii < iOutBufferCount; ii++) { if (ipOutBuffer[ii]) { Err = OMX_FreeBuffer(ipAppPriv->Handle, iOutputPortIndex, ipOutBuffer[ii]); CHECK_ERROR(Err, "FreeBuffer_Output_DynamicReconfig"); ipOutBuffer[ii] = NULL; PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OmxDecTestWithoutMarker::Run() - Called FreeBuffer for buffer index %d on port %d", ii, iOutputPortIndex)); } } if (ipOutBuffer) { oscl_free(ipOutBuffer); ipOutBuffer = NULL; } if (ipOutReleased) { oscl_free(ipOutReleased); ipOutReleased = NULL; } if (StateError == iState) { PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "OmxDecTestWithoutMarker::Run() - Error occured in this state, StateDisablePort OUT")); RunIfNotReady(); break; } iDisableRun = OMX_TRUE; } } PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "OmxDecTestWithoutMarker::Run() - StateDisablePort OUT")); } break; case StateDynamicReconfig: { OMX_BOOL Status = OMX_TRUE; PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "OmxDecTestWithoutMarker::Run() - StateDynamicReconfig IN")); Status = HandlePortReEnable(); if (OMX_FALSE == Status) { PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "OmxDecTestWithoutMarker::Run() - Error occured in this state, StateDynamicReconfig OUT")); iState = StateError; RunIfNotReady(); break; } PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "OmxDecTestWithoutMarker::Run() - StateDynamicReconfig OUT")); } break; case StateExecuting: { OMX_U32 Index; OMX_BOOL MoreOutput; OMX_ERRORTYPE Err = OMX_ErrorNone; PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "OmxDecTestWithoutMarker::Run() - StateExecuting IN")); MoreOutput = OMX_TRUE; while (MoreOutput) { Index = 0; while (OMX_FALSE == ipOutReleased[Index] && Index < iOutBufferCount) { Index++; } if (Index != iOutBufferCount) { //This call is being made only once per frame Err = OMX_FillThisBuffer(ipAppPriv->Handle, ipOutBuffer[Index]); CHECK_ERROR(Err, "FillThisBuffer"); //Make this flag OMX_TRUE till u receive the callback for output buffer free ipOutReleased[Index] = OMX_FALSE; PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OmxDecTestWithoutMarker::Run() - FillThisBuffer command called for output buffer index %d", Index)); } else { MoreOutput = OMX_FALSE; } } if (!iStopProcessingInput || (OMX_ErrorInsufficientResources == iStatusExecuting)) { if (0 == oscl_strcmp(iFormat, "WMV") || 0 == oscl_strcmp(iFormat, "WMA") || 0 == oscl_strcmp(iFormat, "RV") || 0 == oscl_strcmp(iFormat, "RA")) { iStatusExecuting = (*this.*pGetInputFrame)(); } else { iStatusExecuting = GetInput(); } } else if (OMX_FALSE == iEosFlagExecuting) { //Only send one successful dummy buffer with flag set to signal EOS Index = 0; while (OMX_FALSE == ipInputAvail[Index] && Index < iInBufferCount) { Index++; } if (Index != iInBufferCount) { ipInBuffer[Index]->nFlags |= OMX_BUFFERFLAG_EOS; ipInBuffer[Index]->nFilledLen = 0; Err = OMX_EmptyThisBuffer(ipAppPriv->Handle, ipInBuffer[Index]); CHECK_ERROR(Err, "EmptyThisBuffer_EOS"); ipInputAvail[Index] = OMX_FALSE; // mark unavailable iEosFlagExecuting = OMX_TRUE; PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OmxDecTestWithoutMarker::Run() - Input buffer sent to the component with OMX_BUFFERFLAG_EOS flag set")); } } else { //nothing to do here } PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "OmxDecTestWithoutMarker::Run() - StateExecuting OUT")); RunIfNotReady(); } break; case StateStopping: { OMX_ERRORTYPE Err = OMX_ErrorNone; PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "OmxDecTestWithoutMarker::Run() - StateStopping IN")); //stop execution by state transition to Idle state. if (!iFlagStopping) { Err = OMX_SendCommand(ipAppPriv->Handle, OMX_CommandStateSet, OMX_StateIdle, NULL); CHECK_ERROR(Err, "SendCommand Executing->Idle"); PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OmxDecTestWithoutMarker::Run() - Sent State Transition Command from Executing->Idle")); iPendingCommands = 1; iFlagStopping = OMX_TRUE; } PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "OmxDecTestWithoutMarker::Run() - StateStopping OUT")); } break; case StateCleanUp: { OMX_U32 ii; OMX_ERRORTYPE Err = OMX_ErrorNone; PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "OmxDecTestWithoutMarker::Run() - StateCleanUp IN")); if (!iFlagCleanUp) { //Added a check here to verify whether all the ip/op buffers are returned back by the component or not //in case of Executing->Idle state transition if (OMX_FALSE == VerifyAllBuffersReturned()) { // not all buffers have been returned yet, reschedule RunIfNotReady(); break; } //Destroy the component by state transition to Loaded state Err = OMX_SendCommand(ipAppPriv->Handle, OMX_CommandStateSet, OMX_StateLoaded, NULL); CHECK_ERROR(Err, "SendCommand Idle->Loaded"); PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OmxDecTestWithoutMarker::Run() - Sent State Transition Command from Idle->Loaded")); iPendingCommands = 1; if (ipInBuffer) { for (ii = 0; ii < iInBufferCount; ii++) { if (ipInBuffer[ii]) { Err = OMX_FreeBuffer(ipAppPriv->Handle, iInputPortIndex, ipInBuffer[ii]); CHECK_ERROR(Err, "FreeBuffer_Input"); ipInBuffer[ii] = NULL; PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OmxDecTestWithoutMarker::Run() - Called FreeBuffer for buffer index %d on port %d", ii, iInputPortIndex)); } } oscl_free(ipInBuffer); ipInBuffer = NULL; } if (ipInputAvail) { oscl_free(ipInputAvail); ipInputAvail = NULL; } if (ipOutBuffer) { for (ii = 0; ii < iOutBufferCount; ii++) { if (ipOutBuffer[ii]) { Err = OMX_FreeBuffer(ipAppPriv->Handle, iOutputPortIndex, ipOutBuffer[ii]); CHECK_ERROR(Err, "FreeBuffer_Output"); ipOutBuffer[ii] = NULL; PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OmxDecTestWithoutMarker::Run() - Called FreeBuffer for buffer index %d on port %d", ii, iOutputPortIndex)); } } oscl_free(ipOutBuffer); ipOutBuffer = NULL; } if (ipOutReleased) { oscl_free(ipOutReleased); ipOutReleased = NULL; } iFlagCleanUp = OMX_TRUE; } PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "OmxDecTestWithoutMarker::Run() - StateCleanUp OUT")); } break; /********* FREE THE HANDLE & CLOSE FILES FOR THE COMPONENT ********/ case StateStop: { OMX_U8 TestName[] = "WITHOUT_MARKER_BIT_TEST"; OMX_ERRORTYPE Err = OMX_ErrorNone; PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "OmxDecTestWithoutMarker::Run() - StateStop IN")); if (ipAppPriv) { if (ipAppPriv->Handle) { PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OmxDecTestWithoutMarker::Run() - Free the Component Handle")); Err = OMX_MasterFreeHandle(ipAppPriv->Handle); if (OMX_ErrorNone != Err) { PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "OmxDecTestWithoutMarker::Run() - FreeHandle Error")); iTestStatus = OMX_FALSE; } } } PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OmxDecTestWithoutMarker::Run() - De-initialize the omx component")); Err = OMX_MasterDeinit(); if (OMX_ErrorNone != Err) { PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "OmxDecTestWithoutMarker::Run() - OMX_MasterDeinit Error")); iTestStatus = OMX_FALSE; } if (0 == oscl_strcmp(iFormat, "H264")) { if (ipAVCBSO) { OSCL_DELETE(ipAVCBSO); ipAVCBSO = NULL; } } if (0 == oscl_strcmp(iFormat, "M4V") || 0 == oscl_strcmp(iFormat, "H263")) { if (ipBitstreamBuffer) { oscl_free(ipBitstreamBufferPointer); ipBitstreamBuffer = NULL; ipBitstreamBufferPointer = NULL; } } if (iOutputParameters) { oscl_free(iOutputParameters); iOutputParameters = NULL; } if (ipAppPriv) { oscl_free(ipAppPriv); ipAppPriv = NULL; } #if PROXY_INTERFACE if (ipThreadSafeHandlerEventHandler) { OSCL_DELETE(ipThreadSafeHandlerEventHandler); ipThreadSafeHandlerEventHandler = NULL; } if (ipThreadSafeHandlerEmptyBufferDone) { OSCL_DELETE(ipThreadSafeHandlerEmptyBufferDone); ipThreadSafeHandlerEmptyBufferDone = NULL; } if (ipThreadSafeHandlerFillBufferDone) { OSCL_DELETE(ipThreadSafeHandlerFillBufferDone); ipThreadSafeHandlerFillBufferDone = NULL; } #endif VerifyOutput(TestName); PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "OmxDecTestWithoutMarker::Run() - StateStop OUT")); iState = StateUnLoaded; OsclExecScheduler* sched = OsclExecScheduler::Current(); sched->StopScheduler(); } break; case StateError: { //Do all the cleanup's and exit from here OMX_U32 ii; PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "OmxDecTestWithoutMarker::Run() - StateError IN")); iTestStatus = OMX_FALSE; if (ipInBuffer) { for (ii = 0; ii < iInBufferCount; ii++) { if (ipInBuffer[ii]) { OMX_FreeBuffer(ipAppPriv->Handle, iInputPortIndex, ipInBuffer[ii]); ipInBuffer[ii] = NULL; PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OmxDecTestWithoutMarker::Run() - Called FreeBuffer for buffer index %d on port %d", ii, iInputPortIndex)); } } oscl_free(ipInBuffer); ipInBuffer = NULL; } if (ipInputAvail) { oscl_free(ipInputAvail); ipInputAvail = NULL; } if (ipOutBuffer) { for (ii = 0; ii < iOutBufferCount; ii++) { if (ipOutBuffer[ii]) { OMX_FreeBuffer(ipAppPriv->Handle, iOutputPortIndex, ipOutBuffer[ii]); ipOutBuffer[ii] = NULL; PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OmxDecTestWithoutMarker::Run() - Called FreeBuffer for buffer index %d on port %d", ii, iOutputPortIndex)); } } oscl_free(ipOutBuffer); ipOutBuffer = NULL; } if (ipOutReleased) { oscl_free(ipOutReleased); ipOutReleased = NULL; } iState = StateStop; RunIfNotReady(); PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "OmxDecTestWithoutMarker::Run() - StateError OUT")); } break; default: { break; } } return ; }