OMX_BOOL OmxAacDecoder::AacDecInit(OMX_U32 aDesiredChannels) { Int Status; iMemReq = PVMP4AudioDecoderGetMemRequirements(); ipMem = oscl_malloc(iMemReq); if (0 == ipMem) { return OMX_FALSE; } oscl_memset(&iExt, 0, sizeof(tPVMP4AudioDecoderExternal)); iExt.inputBufferCurrentLength = 0; iExt.remainderBits = 0; // Not needed anymore. iExt.inputBufferMaxLength = PVMP4AUDIODECODER_INBUFSIZE; iExt.outputFormat = OUTPUTFORMAT_16PCM_INTERLEAVED; iExt.desiredChannels = aDesiredChannels; iExt.aacPlusEnabled = TRUE; iAacInitFlag = 0; iInputUsedLength = 0; //This var is required to do init again inbetween iNumOfChannels = aDesiredChannels; Status = PVMP4AudioDecoderInitLibrary(&iExt, ipMem); return OMX_TRUE; }
OMADRMKMSBox:: OMADRMKMSBox(MP4_FF_FILE *fp, uint32 size, uint32 type) : FullAtom(fp, size, type) { _pODKMData = NULL; if (!_success) { if (_mp4ErrorCode != ATOM_VERSION_NOT_SUPPORTED) { _mp4ErrorCode = READ_OMADRM_KMS_BOX_FAILED; } return; } /* Seek back to atom start */ AtomUtils::rewindFilePointerByN(fp, DEFAULT_FULL_ATOM_SIZE); /* Read the entire contents of the atom into memory */ _pODKMData = (uint8*)(oscl_malloc(sizeof(uint8) * (_size))); if (!AtomUtils::readByteData(fp, _size, _pODKMData)) { _success = false; _mp4ErrorCode = READ_OMADRM_KMS_BOX_FAILED; return; } return; }
void PVA_FF_DecoderSpecificInfo::addInfo(uint8 *info, uint32 size) { _infoSize = size; _pinfo = (uint8 *)oscl_malloc(_infoSize); oscl_memcpy(_pinfo, info, _infoSize); }
/* These two functions are for callback functions of AvcHandle */ int32 CBAVC_Malloc_OMX(void* aUserData, int32 aSize, int32 aAttribute) { OSCL_UNUSED_ARG(aUserData); OSCL_UNUSED_ARG(aAttribute); void* pPtr; pPtr = oscl_malloc(aSize); return (int32) pPtr; }
bool AVCSampleEntry::createDecoderSpecificInfo(MP4_FF_FILE *fp) { uint32 numSPS = getNumSequenceParamSets(); uint32 numPPS = getNumPictureParamSets(); uint32 totalSPSLen = getTotalSeqParameterSetLength(); uint32 totalPPSLen = getTotalPictureParameterSetLength(); uint32 len = (numSPS * 2) + (numPPS * 2) + totalSPSLen + totalPPSLen; if ((int32)len > 0) { PV_MP4_FF_NEW(fp->auditCB, DecoderSpecificInfo, (fp, true), _decoderSpecificInfo); uint8* info = (uint8*)(oscl_malloc(sizeof(uint8) * len)); if (!info) return false; // malloc failed (unlikely) uint8* destPtr = info; if (numSPS > 0) { for (uint32 i = 0; i < numSPS; i++) { uint16 len = 0; uint8* ptr = NULL; if (getSequenceParamSet(i, len, ptr) == false) { OSCL_FREE(info); return false; } oscl_memcpy(destPtr, &len, sizeof(uint16)); destPtr += sizeof(uint16); oscl_memcpy(destPtr, ptr, len); destPtr += len; } } if (numPPS > 0) { for (uint32 i = 0; i < numPPS; i++) { uint16 len = 0; uint8* ptr = NULL; if (getPictureParamSet(i, len, ptr) == false) { OSCL_FREE(info); return false; } oscl_memcpy(destPtr, &len, sizeof(uint16)); destPtr += sizeof(uint16); oscl_memcpy(destPtr, ptr, len); destPtr += len; } } _decoderSpecificInfo->setInfoSize(len); _decoderSpecificInfo->setInfo(info); } return true; }
int CbAvcDecMalloc(void *userData, int32 size, int attribute) { OSCL_UNUSED_ARG(userData); OSCL_UNUSED_ARG(attribute); uint8 *mem; mem = (uint8*) oscl_malloc(size); return (int)mem; }
int PVAVCDecoder::AVC_DPBAlloc(uint frame_size_in_mbs, uint num_buffers) { int ii; uint frame_size = (frame_size_in_mbs << 8) + (frame_size_in_mbs << 7); if (iDPB) oscl_free(iDPB); // free previous one first iDPB = (uint8*) oscl_malloc(sizeof(uint8) * frame_size * num_buffers); if (iDPB == NULL) { return 0; } iNumFrames = num_buffers; if (iFrameUsed) oscl_free(iFrameUsed); // free previous one iFrameUsed = (bool*) oscl_malloc(sizeof(bool) * num_buffers); if (iFrameUsed == NULL) { return 0; } if (iFramePtr) oscl_free(iFramePtr); // free previous one iFramePtr = (uint8**) oscl_malloc(sizeof(uint8*) * num_buffers); if (iFramePtr == NULL) { return 0; } iFramePtr[0] = iDPB; iFrameUsed[0] = false; for (ii = 1; ii < (int)num_buffers; ii++) { iFrameUsed[ii] = false; iFramePtr[ii] = iFramePtr[ii-1] + frame_size; } return 1; }
int32 AvcDecoder_OMX::ActivateSPS_OMX(void* aUserData, uint aSizeInMbs, uint aNumBuffers) { OSCL_UNUSED_ARG(aUserData); PVAVCDecGetSeqInfo(&(AvcHandle), &(SeqInfo)); if (pDpbBuffer) { oscl_free(pDpbBuffer); pDpbBuffer = NULL; } FrameSize = (aSizeInMbs << 7) * 3; pDpbBuffer = (uint8*) oscl_malloc(aNumBuffers * (FrameSize)); return 1; }
void PVMFProtocolEngineNodeRegistry::AddLoadableModules() { LOGINFO((0, "PVMFProtocolEngineNodeRegistry::AddLoadableModules() IN")); #if USE_LOADABLE_MODULES OsclConfigFileList aCfgList; // collects all config files from the project specified directory if (NULL != PV_DYNAMIC_LOADING_CONFIG_FILE_PATH) { OSCL_HeapString<OsclMemAllocator> configFilePath = PV_DYNAMIC_LOADING_CONFIG_FILE_PATH; aCfgList.Populate(configFilePath); } // populate libraries from all config files for (uint k = 0; k < aCfgList.Size(); k++) { OsclLibraryList libList; libList.Populate(PVMF_PROTOCOL_ENGINE_NODE_REGISTRY_POPULATOR_INTERFACE, aCfgList.GetConfigfileAt(k)); for (uint32 i = 0; i < libList.Size(); i++) { OsclSharedLibrary* lib = OSCL_NEW(OsclSharedLibrary, ()); if (lib->LoadLib(libList.GetLibraryPathAt(i)) == OsclLibSuccess) { OsclAny* interfacePtr = NULL; OsclLibStatus result = lib->QueryInterface(PVMF_PROTOCOL_ENGINE_NODE_REGISTRY_POPULATOR_INTERFACE, (OsclAny*&)interfacePtr); if (result == OsclLibSuccess && interfacePtr != NULL) { struct PVProtocolEngineNodeSharedLibInfo *libInfo = (struct PVProtocolEngineNodeSharedLibInfo *)oscl_malloc(sizeof(struct PVProtocolEngineNodeSharedLibInfo)); if (NULL != libInfo) { libInfo->iLib = lib; PVMFProtocolEngineNodeRegistryPopulatorInterface* nodeLibIntPtr = OSCL_DYNAMIC_CAST(PVMFProtocolEngineNodeRegistryPopulatorInterface*, interfacePtr); libInfo->iNodeLibIfacePtr = nodeLibIntPtr; nodeLibIntPtr->Register(this); // save for depopulation later iNodeLibInfoList.push_front(libInfo); continue; } } } lib->Close(); OSCL_DELETE(lib); }
PVMFStatus PVAMRFFRecognizerPlugin::Recognize(PVMFDataStreamFactory& aSourceDataStreamFactory, PVMFRecognizerMIMEStringList* aFormatHint, Oscl_Vector<PVMFRecognizerResult, OsclMemAllocator>& aRecognizerResult) { OSCL_UNUSED_ARG(aFormatHint); OSCL_wHeapString<OsclMemAllocator> tmpfilename; Oscl_FileServer fileServ; PVFile pvfile; pvfile.SetCPM(&aSourceDataStreamFactory); if (!(pvfile.Open(tmpfilename.get_cstr(), Oscl_File::MODE_READ | Oscl_File::MODE_BINARY, fileServ))) { char* readData = NULL; readData = (char*)(oscl_malloc(sizeof(char) * AMRFF_MIN_DATA_SIZE_FOR_RECOGNITION)); if (readData != NULL) { int bytesRead = 0; bytesRead = pvfile.Read(readData, sizeof(char), AMRFF_MIN_DATA_SIZE_FOR_RECOGNITION); if (bytesRead != AMRFF_MIN_DATA_SIZE_FOR_RECOGNITION) { pvfile.Close(); oscl_free(readData); return PVMFFailure; } if (readData[0] == '#' && readData[1] == '!' && readData[2] == 'A' && readData[3] == 'M' && readData[4] == 'R') { PVMFRecognizerResult result; result.iRecognizedFormat = PVMF_MIME_AMRFF; result.iRecognitionConfidence = PVMFRecognizerConfidenceCertain; aRecognizerResult.push_back(result); } } pvfile.Close(); oscl_free(readData); return PVMFFailure; } else { return PVMFFailure; } return PVMFSuccess; }
Word16 GSMInitEncode(void **state_data, Flag dtx, Word8 *id) { Speech_Encode_FrameState* s; OSCL_UNUSED_ARG(id); if (state_data == NULL) { /* fprintf(stderr, "Speech_Encode_Frame_init: invalid parameter\n"); */ return -1; } *state_data = NULL; /* allocate memory */ if ((s = (Speech_Encode_FrameState *) oscl_malloc(sizeof(Speech_Encode_FrameState))) == NULL) { /* fprintf(stderr, "Speech_Encode_Frame_init: can not malloc state " "structure\n"); */ return -1; } s->pre_state = NULL; s->cod_amr_state = NULL; s->dtx = dtx; if (Pre_Process_init(&s->pre_state) || cod_amr_init(&s->cod_amr_state, s->dtx)) { Speech_Encode_FrameState** temp = &s; GSMEncodeFrameExit((void**)temp); return -1; } Speech_Encode_Frame_reset(s); *state_data = (void *)s; return 0; }
Word16 dtx_enc_init(dtx_encState **st, const Word16* lsp_init_data_ptr) { dtx_encState* s; if (st == (dtx_encState **) NULL) { return(-1); } *st = NULL; /* allocate memory */ if ((s = (dtx_encState *) oscl_malloc(sizeof(dtx_encState))) == NULL) { return(-1); } dtx_enc_reset(s, lsp_init_data_ptr); *st = s; return(0); }
Word16 dtx_enc_init(dtx_encState **st) { dtx_encState* s; if (st == (dtx_encState **) NULL) { return(-1); } *st = NULL; /* allocate memory */ if ((s = (dtx_encState *) oscl_malloc(sizeof(dtx_encState))) == NULL) { return(-1); } dtx_enc_reset(s); *st = s; return(0); }
Word16 p_ol_wgh_init(pitchOLWghtState **state) { pitchOLWghtState* s; if (state == (pitchOLWghtState **) NULL) { /* fprintf(stderr, "p_ol_wgh_init: invalid parameter\n"); */ return -1; } *state = NULL; /* allocate memory */ if ((s = (pitchOLWghtState *) oscl_malloc(sizeof(pitchOLWghtState))) == NULL) { /* fprintf(stderr, "p_ol_wgh_init: can not malloc state structure\n"); */ return -1; } p_ol_wgh_reset(s); *state = s; return 0; }
PVMFStatus PVMp4FFComposerNode::GetConfigParameter(PvmiKvp*& aParameters, int& aNumParamElements, int32 aIndex, PvmiKvpAttr aReqattr) { PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMp4FFComposerNode::GetConfigParameter() In")); aNumParamElements = 0; // Allocate memory for the KVP aParameters = (PvmiKvp*)oscl_malloc(sizeof(PvmiKvp)); if (NULL == aParameters) { PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMp4FFComposerNode::GetConfigParameter() Memory allocation for KVP failed")); return PVMFErrNoMemory; } oscl_memset(aParameters, 0, sizeof(PvmiKvp)); // Allocate memory for the key string in KVP PvmiKeyType memblock = (PvmiKeyType)oscl_malloc(MP4CONFIG_KEYSTRING_SIZE * sizeof(char)); if (NULL == memblock) { oscl_free(aParameters); PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMp4FFComposerNode::GetConfigParameter() Memory allocation for key string failed")); return PVMFErrNoMemory; } oscl_strset(memblock, 0, MP4CONFIG_KEYSTRING_SIZE * sizeof(char)); // Assign the key string buffer to KVP aParameters[0].key = memblock; // Copy the key string oscl_strncat(aParameters[0].key, _STRLIT_CHAR("x-pvmf/composer/mp4/"), 7); oscl_strncat(aParameters[0].key, MP4ComposerNodeConfig_BaseKeys[aIndex].iString, oscl_strlen(MP4ComposerNodeConfig_BaseKeys[aIndex].iString)); oscl_strncat(aParameters[0].key, _STRLIT_CHAR(";type=value;valtype="), 20); switch (MP4ComposerNodeConfig_BaseKeys[aIndex].iValueType) { case PVMI_KVPVALTYPE_BITARRAY32: oscl_strncat(aParameters[0].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_BITARRAY32_STRING), oscl_strlen(PVMI_KVPVALTYPE_BITARRAY32_STRING)); break; case PVMI_KVPVALTYPE_KSV: oscl_strncat(aParameters[0].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_KSV_STRING), oscl_strlen(PVMI_KVPVALTYPE_KSV_STRING)); break; case PVMI_KVPVALTYPE_BOOL: oscl_strncat(aParameters[0].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_BOOL_STRING), oscl_strlen(PVMI_KVPVALTYPE_BOOL_STRING)); break; case PVMI_KVPVALTYPE_INT32: if (aReqattr == PVMI_KVPATTR_CUR) { oscl_strncat(aParameters[0].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_INT32_STRING), oscl_strlen(PVMI_KVPVALTYPE_RANGE_UINT32_STRING)); } break; case PVMI_KVPVALTYPE_CHARPTR: oscl_strncat(aParameters[0].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_CHARPTR_STRING), oscl_strlen(PVMI_KVPVALTYPE_CHARPTR_STRING)); break; case PVMI_KVPVALTYPE_UINT32: default: if (PVMI_KVPATTR_CAP == aReqattr) { oscl_strncat(aParameters[0].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_RANGE_UINT32_STRING), oscl_strlen(PVMI_KVPVALTYPE_RANGE_UINT32_STRING)); } else { oscl_strncat(aParameters[0].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_UINT32_STRING), oscl_strlen(PVMI_KVPVALTYPE_UINT32_STRING)); } break; } aParameters[0].key[MP4CONFIG_KEYSTRING_SIZE-1] = 0; // Copy the requested info switch (aIndex) { case PRESENTATION_TIMESCALE: // "presentation-timescale" if (PVMI_KVPATTR_CUR == aReqattr) { // Return current value aParameters[0].value.uint32_value = iPresentationTimescale; } else if (PVMI_KVPATTR_DEF == aReqattr) { // return default } else { // Return capability } break; case PV_CACHE_SIZE: // "pv-cache-size" if (PVMI_KVPATTR_CUR == aReqattr) { // set any parameter here aParameters[0].value.uint32_value = iCacheSize; } else if (PVMI_KVPATTR_DEF == aReqattr) { // return default aParameters[0].value.uint32_value = DEFAULT_CAHCE_SIZE; } else { // Return capability range_uint32* rui32 = (range_uint32*)oscl_malloc(sizeof(range_uint32)); if (NULL == rui32) { oscl_free(aParameters[0].key); oscl_free(aParameters); PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMp4FFComposerNode::GetConfigParameter() Memory allocation for range uint32 failed")); return PVMFErrNoMemory; } rui32->min = MIN_CACHE_SIZE; rui32->max = MAX_CACHE_SIZE; aParameters[0].value.key_specific_value = (void*)rui32; } break; #ifdef _TEST_AE_ERROR_HANDLING case ERROR_START_ADDMEMFRAG: if (PVMI_KVPATTR_CUR == aReqattr) { // Return current value aParameters[0].value.bool_value = iErrorHandlingAddMemFrag; } else if (PVMI_KVPATTR_DEF == aReqattr) { // return default aParameters[0].value.bool_value = true; } else { // Return capability } break; case ERROR_START_ADDTRACK: if (PVMI_KVPATTR_CUR == aReqattr) { // Return current value aParameters[0].value.bool_value = iErrorHandlingAddTrack; } else if (PVMI_KVPATTR_DEF == aReqattr) { // return default aParameters[0].value.bool_value = true; } else { // Return capability } break; #endif default: // Invalid index oscl_free(aParameters[0].key); oscl_free(aParameters); PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMp4FFComposerNode::GetConfigParameter() Invalid index to composer node parameter")); return PVMFErrNotSupported; } aNumParamElements = 1; PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMp4FFComposerNode::GetConfigParameter() Out")); return PVMFSuccess; }
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 ; }
// Constructor TrackFragmentAtom::TrackFragmentAtom(MP4_FF_FILE *fp, uint32 &size, uint32 type, uint32 movieFragmentCurrentOffset, uint32 movieFragmentBaseOffset, uint32 moofSize, TrackDurationContainer *trackDurationContainer, Oscl_Vector<TrackExtendsAtom*, OsclMemAllocator> *trackExtendAtomVec, bool &parseTrafCompletely, bool &trafParsingCompleted, uint32 &countOfTrunsParsed) : Atom(fp, size, type) { OSCL_UNUSED_ARG(movieFragmentCurrentOffset); _pTrackFragmentHeaderAtom = NULL; _pTrackFragmentRunAtom = NULL; _pinput = NULL; _commonFilePtr = NULL; _fileSize = 0; _currentTrackFragmentRunSampleNumber = 0; _currentPlaybackSampleTimestamp = 0; _movieFragmentOffset = 0; _prevSampleOffset = 0; _trackEndDuration = 0; _startTrackFragmentTSOffset = 0; _pFragmentptrOffsetVec = NULL; _peekPlaybackSampleNumber = 0; _default_duration = 0; _use_default_duratoin = false; _pTrackDurationContainer = trackDurationContainer; tf_flags = 0; trun_offset = 0; trunParsingCompleted = true; iLogger = PVLogger::GetLoggerObject("mp4ffparser_traf"); iStateVarLogger = PVLogger::GetLoggerObject("mp4ffparser_mediasamplestats_traf"); iParsedDataLogger = PVLogger::GetLoggerObject("mp4ffparser_parseddata_traf"); OsclAny*ptr = oscl_malloc(sizeof(MP4_FF_FILE)); if (ptr == NULL) { _success = false; _mp4ErrorCode = MEMORY_ALLOCATION_FAILED; return; } _pinput = OSCL_PLACEMENT_NEW(ptr, MP4_FF_FILE(*fp)); _pinput->_fileServSession = fp->_fileServSession; _pinput->_pvfile.SetCPM(fp->_pvfile.GetCPM()); _pinput->_fileSize = fp->_fileSize; _pinput->_pvfile.Copy(fp->_pvfile); uint32 trun_start = 0; uint32 count = size - DEFAULT_ATOM_SIZE; uint32 _movieFragmentBaseOffset = movieFragmentBaseOffset - DEFAULT_ATOM_SIZE; bool bdo_present = false; uint32 base_data_offset = _movieFragmentBaseOffset; trackId = 0; trun_offset = moofSize + DEFAULT_ATOM_SIZE; if (_success) { PV_MP4_FF_NEW(fp->auditCB, trackFragmentRunAtomVecType, (), _pTrackFragmentRunAtomVec); while (count > 0) { uint32 atomType = UNKNOWN_ATOM; uint32 atomSize = 0; AtomUtils::getNextAtomType(fp, atomSize, atomType); if (atomType == TRACK_FRAGMENT_HEADER_ATOM) { if (_pTrackFragmentHeaderAtom == NULL) { PV_MP4_FF_NEW(fp->auditCB, TrackFragmentHeaderAtom, (fp, atomSize, atomType), _pTrackFragmentHeaderAtom); if (!_pTrackFragmentHeaderAtom->MP4Success()) { _success = false; _mp4ErrorCode = READ_MOVIE_EXTENDS_HEADER_FAILED; return; } count -= _pTrackFragmentHeaderAtom->getSize(); trackId = _pTrackFragmentHeaderAtom->getTrackId(); tf_flags = _pTrackFragmentHeaderAtom->getFlags(); PVMF_MP4FFPARSER_LOGMEDIASAMPELSTATEVARIABLES((0, "@@@@@@@@@@@@@@@****** Track ID= %d ********@@@@@@@@@@@@@@@@", trackId)); PVMF_MP4FFPARSER_LOGMEDIASAMPELSTATEVARIABLES((0, "#### tf_flag =0x%x######", tf_flags)); if (tf_flags & 0x000001) { uint64 bdo = _pTrackFragmentHeaderAtom->getBaseDataOffset(); base_data_offset = Oscl_Int64_Utils::get_uint64_lower32(bdo); bdo_present = true; } else base_data_offset = _movieFragmentBaseOffset; trun_start = base_data_offset; if (trackDurationContainer != NULL) { for (int32 i = 0; i < trackDurationContainer->getNumTrackInfoVec(); i++) { TrackDurationInfo* trackInfo = trackDurationContainer->getTrackdurationInfoAt(i); if (trackInfo->trackId == trackId) { _trackEndDuration = trackInfo->trackDuration; _startTrackFragmentTSOffset = _trackEndDuration; } } } } else { //duplicate atom count -= atomSize; atomSize -= DEFAULT_ATOM_SIZE; AtomUtils::seekFromCurrPos(fp, atomSize); } } else if (atomType == TRACK_FRAGMENT_RUN_ATOM) { uint32 trunsParsed = countOfTrunsParsed; if (countOfTrunsParsed > COUNT_OF_TRUNS_PARSED_THRESHOLD) { countOfTrunsParsed = COUNT_OF_TRUNS_PARSED_THRESHOLD; } // here we want parser to parse complete TRUN atom. PV_MP4_FF_NEW(fp->auditCB, TrackFragmentRunAtom, (fp, atomSize, atomType, base_data_offset, trun_start, trun_offset, _trackEndDuration, bdo_present, trunParsingCompleted, countOfTrunsParsed), _pTrackFragmentRunAtom); countOfTrunsParsed = trunsParsed + 1; if (!_pTrackFragmentRunAtom->MP4Success()) { _success = false; _mp4ErrorCode = READ_TRACK_EXTENDS_ATOM_FAILED; return; } bdo_present = false; count -= _pTrackFragmentRunAtom->getSize(); size = count; uint32 trunFlags = _pTrackFragmentRunAtom->getFlags(); if (!(trunFlags & 0x000100)) { _use_default_duratoin = true; if (tf_flags & 0x000008) { _default_duration = _pTrackFragmentHeaderAtom->getDefaultSampleDuration(); _pTrackFragmentRunAtom->setDefaultDuration(_default_duration); } else { for (uint32 idx = 0; idx < trackExtendAtomVec->size(); idx++) { TrackExtendsAtom* pTrackExtendAtom = (*trackExtendAtomVec)[idx]; uint32 id = pTrackExtendAtom->getTrackId(); if (id == trackId) { uint32 trexDefaultDuration = pTrackExtendAtom->getDefaultSampleDuration(); _default_duration = trexDefaultDuration; _pTrackFragmentRunAtom->setDefaultDuration(trexDefaultDuration); } } } } if (!(trunFlags & 0x000200)) { if (tf_flags & 0x000010) _pTrackFragmentRunAtom->setDefaultSampleSize(_pTrackFragmentHeaderAtom->getDefaultSampleSize(), trun_offset); else { for (uint32 idx = 0; idx < trackExtendAtomVec->size(); idx++) { TrackExtendsAtom* pTrackExtendAtom = (*trackExtendAtomVec)[idx]; uint32 id = pTrackExtendAtom->getTrackId(); if (id == trackId) { uint32 trexDefaultSampleSize = pTrackExtendAtom->getDefaultSampleSize(); _pTrackFragmentRunAtom->setDefaultSampleSize(trexDefaultSampleSize, trun_offset); } } } } _pTrackFragmentRunAtomVec->push_back(_pTrackFragmentRunAtom); _trackEndDuration = _pTrackFragmentRunAtom->GetSampleTimeStamp(); PVMF_MP4FFPARSER_LOGMEDIASAMPELSTATEVARIABLES((0, "****** tr_flag =0x%x ********", trunFlags)); if (!parseTrafCompletely) { trafParsingCompleted = false; uint64 duration = _trackEndDuration; trackDurationContainer->updateTrackDurationForTrackId(trackId, duration); break; } } else { count -= atomSize; atomSize -= DEFAULT_ATOM_SIZE; AtomUtils::seekFromCurrPos(fp, atomSize); } uint64 track_duration = _trackEndDuration; trackDurationContainer->updateTrackDurationForTrackId(trackId, track_duration); trafParsingCompleted = true; } } else {
// Stream-in ctor CompositionOffsetAtom::CompositionOffsetAtom(MP4_FF_FILE *fp, uint32 mediaType, uint32 size, uint32 type, OSCL_wString& filename, uint32 parsingMode): FullAtom(fp, size, type), OsclTimerObject(OsclActiveObject::EPriorityNominal, "CompositionOffsetAtom") { _psampleCountVec = NULL; _psampleOffsetVec = NULL; MT_SampleCount = NULL; MT_EntryCount = NULL; iMarkerTableCreation = false; MT_Table_Size = 0; _currGetSampleCount = 0; _currGetIndex = -1; _currGetTimeOffset = 0; _currPeekSampleCount = 0; _currPeekIndex = -1; _currPeekTimeOffset = 0; MT_Counter = 1; addSampleCount = 0; prevSampleCount = 0; entrycountTraversed = 0; refSample = MT_SAMPLECOUNT_INCREMENT; MT_j = 1; _mediaType = mediaType; _parsed_entry_cnt = 0; _fileptr = NULL; _parsing_mode = 0; _parsing_mode = parsingMode; _stbl_buff_size = CTTS_MIN_SAMPLE_TABLE_SIZE; _next_buff_number = 0; _curr_buff_number = 0; _curr_entry_point = 0; _stbl_fptr_vec = NULL; iLogger = PVLogger::GetLoggerObject("mp4ffparser"); iStateVarLogger = PVLogger::GetLoggerObject("mp4ffparser_mediasamplestats"); iParsedDataLogger = PVLogger::GetLoggerObject("mp4ffparser_parseddata"); iMarkerTableCreation = false; /* Add this AO to the scheduler */ if (OsclExecScheduler::Current() != NULL) { if (!IsAdded()) { AddToScheduler(); } } if (_success) { if (!AtomUtils::read32(fp, _entryCount)) { _success = false; } PVMF_MP4FFPARSER_LOGPARSEDINFO((0, "CompositionOffsetAtom::CompositionOffsetAtom- _entryCount =%d", _entryCount)); uint32 dataSize = _size - (DEFAULT_FULL_ATOM_SIZE + 4); uint32 entrySize = (4 + 4); if ((_entryCount*entrySize) > dataSize) { _success = false; } if (_success) { if (_entryCount > 0) { if (parsingMode == 1) { // cache size is 4K so that optimization // should work if entry_count is greater than 4K if (_entryCount > _stbl_buff_size) { uint32 fptrBuffSize = (_entryCount / _stbl_buff_size) + 1; PV_MP4_FF_ARRAY_NEW(NULL, uint32, (fptrBuffSize), _stbl_fptr_vec); if (_stbl_fptr_vec == NULL) { _success = false; _mp4ErrorCode = MEMORY_ALLOCATION_FAILED; return; } PV_MP4_FF_ARRAY_NEW(NULL, uint32, (_stbl_buff_size), _psampleCountVec); if (_psampleCountVec == NULL) { _success = false; _mp4ErrorCode = MEMORY_ALLOCATION_FAILED; return; } PV_MP4_FF_ARRAY_NEW(NULL, uint32, (_stbl_buff_size), _psampleOffsetVec); if (_psampleOffsetVec == NULL) { PV_MP4_ARRAY_DELETE(NULL, _psampleOffsetVec); _psampleOffsetVec = NULL; _success = false; _mp4ErrorCode = MEMORY_ALLOCATION_FAILED; return; } for (uint32 idx = 0; idx < _stbl_buff_size; idx++) //initialization { _psampleCountVec[idx] = 0; _psampleOffsetVec[idx] = 0; } OsclAny* ptr = (MP4_FF_FILE *)(oscl_malloc(sizeof(MP4_FF_FILE))); if (ptr == NULL) { _success = false; _mp4ErrorCode = MEMORY_ALLOCATION_FAILED; return; } _fileptr = OSCL_PLACEMENT_NEW(ptr, MP4_FF_FILE()); _fileptr->_fileServSession = fp->_fileServSession; _fileptr->_pvfile.SetCPM(fp->_pvfile.GetCPM()); _fileptr->_pvfile.SetFileHandle(fp->_pvfile.iFileHandle); if (AtomUtils::OpenMP4File(filename, Oscl_File::MODE_READ | Oscl_File::MODE_BINARY, _fileptr) != 0) { _success = false; _mp4ErrorCode = FILE_OPEN_FAILED; } _fileptr->_fileSize = fp->_fileSize; int32 _head_offset = AtomUtils::getCurrentFilePosition(fp); AtomUtils::seekFromCurrPos(fp, dataSize); AtomUtils::seekFromStart(_fileptr, _head_offset); return; } else { _parsing_mode = 0; _stbl_buff_size = _entryCount; } } else { _stbl_buff_size = _entryCount; } PV_MP4_FF_ARRAY_NEW(NULL, uint32, (_entryCount), _psampleCountVec); if (_psampleCountVec == NULL) { _success = false; _mp4ErrorCode = MEMORY_ALLOCATION_FAILED; return; } PV_MP4_FF_ARRAY_NEW(NULL, uint32, (_entryCount), _psampleOffsetVec); if (_psampleOffsetVec == NULL) { PV_MP4_ARRAY_DELETE(NULL, _psampleOffsetVec); _psampleOffsetVec = NULL; _success = false; _mp4ErrorCode = MEMORY_ALLOCATION_FAILED; return; } for (uint32 idx = 0; idx < _entryCount; idx++) //initialization { _psampleCountVec[idx] = 0; _psampleOffsetVec[idx] = 0; } uint32 number = 0; uint32 offset = 0; for (_parsed_entry_cnt = 0; _parsed_entry_cnt < _entryCount; _parsed_entry_cnt++) { if (!AtomUtils::read32(fp, number)) { _success = false; break; } if (!AtomUtils::read32(fp, offset)) { _success = false; break; } _psampleCountVec[_parsed_entry_cnt] = (number); _psampleOffsetVec[_parsed_entry_cnt] = (offset); } } } if (!_success) { _mp4ErrorCode = READ_TIME_TO_SAMPLE_ATOM_FAILED; } } else { if (_mp4ErrorCode != ATOM_VERSION_NOT_SUPPORTED) _mp4ErrorCode = READ_TIME_TO_SAMPLE_ATOM_FAILED; } }
PVA_FF_InterLeaveBuffer::PVA_FF_InterLeaveBuffer(uint32 mediaType, uint32 codecType, uint32 trackId) { _trackId = trackId; _mediaType = mediaType; _codecType = codecType; _lastChunkEndTime = 0; _maxInterLeaveBufferSize = 0; _currInterLeaveBufferSize = 0; _lastInterLeaveBufferTS = 0; _lastSampleTS = 0; // initialise interleaved buffers for audio or video track( max size) if ((uint32) mediaType == MEDIA_TYPE_AUDIO) { if (codecType == CODEC_TYPE_AMR_AUDIO) { _interLeaveBuffer = (uint8 *)(oscl_malloc(sizeof(uint8) * AMR_INTERLEAVE_BUFFER_SIZE)); _maxInterLeaveBufferSize = AMR_INTERLEAVE_BUFFER_SIZE; } else if (codecType == CODEC_TYPE_AAC_AUDIO) { _interLeaveBuffer = (uint8 *)(oscl_malloc(sizeof(uint8) * AAC_INTERLEAVE_BUFFER_SIZE)); _maxInterLeaveBufferSize = AAC_INTERLEAVE_BUFFER_SIZE; } else if (codecType == CODEC_TYPE_AMR_WB_AUDIO) { _interLeaveBuffer = (uint8 *)(oscl_malloc(sizeof(uint8) * AMR_WB_INTERLEAVE_BUFFER_SIZE)); _maxInterLeaveBufferSize = AMR_WB_INTERLEAVE_BUFFER_SIZE; } else if (codecType == CODEC_TYPE_QCELP_AUDIO) { _interLeaveBuffer = (uint8 *)(oscl_malloc(sizeof(uint8) * QCELP_INTERLEAVE_BUFFER_SIZE)); _maxInterLeaveBufferSize = QCELP_INTERLEAVE_BUFFER_SIZE; } } if ((uint32) mediaType == MEDIA_TYPE_VISUAL) { _interLeaveBuffer = (uint8 *)(oscl_malloc(sizeof(uint8) * VIDEO_INTERLEAVE_BUFFER_SIZE)); _maxInterLeaveBufferSize = VIDEO_INTERLEAVE_BUFFER_SIZE; } if ((uint32) _mediaType == MEDIA_TYPE_TEXT) { _interLeaveBuffer = (uint8 *)(oscl_malloc(sizeof(uint8) * TEXT_INTERLEAVE_BUFFER_SIZE)); _maxInterLeaveBufferSize = TEXT_INTERLEAVE_BUFFER_SIZE; } // initialise vectors to store sample parameters present in interleaved buffers PV_MP4_FF_NEW(fp->auditCB, uint32VecType, (), _pTimeStampVec); PV_MP4_FF_NEW(fp->auditCB, uint32VecType, (), _pSampleSizeVec); PV_MP4_FF_NEW(fp->auditCB, uint8VecType, (), _pSampleFlagsVec); PV_MP4_FF_NEW(fp->auditCB, int32VecType, (), _pIndexVec); }
PVAviFileStreamlist::PVAviFileStreamlist(PVFile *aFp, uint32 aStrListSz) { iCodecSpecificHdrDataSize = 0; iStreamListSize = aStrListSz; ipCodecSpecificHdrData = NULL; iError = PV_AVI_FILE_PARSER_SUCCESS; uint32 bytesRead = 0; uint32 chunkType = 0; while (bytesRead < iStreamListSize) { if ((iError = PVAviFileParserUtils::ReadNextChunkType(aFp, chunkType)) != PV_AVI_FILE_PARSER_SUCCESS) { PVAVIFILE_LOGINFO((0, "PVAviFileStreamlist::PVAviFileStreamlist: Unsupported chunk")); if (PV_AVI_FILE_PARSER_UNSUPPORTED_CHUNK == iError) { uint32 chksz = 0; if (PV_AVI_FILE_PARSER_SUCCESS != PVAviFileParserUtils::read32(aFp, chksz, true)) { PVAVIFILE_LOGERROR((0, "PVAviFileStreamlist::PVAviFileStreamlist: 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 PVAVIFILE_LOGINFO((0, "PVAviFileStreamlist::PVAviFileStreamlist: Unsupported Chunk Skipped")); iError = PV_AVI_FILE_PARSER_SUCCESS; continue; } else { PVAVIFILE_LOGERROR((0, "PVAviFileStreamlist::PVAviFileStreamlist: File Read Error")); iError = PV_AVI_FILE_PARSER_READ_ERROR; break; } } bytesRead += CHUNK_SIZE; if (STRH == chunkType) { PVAVIFILE_LOGINFO((0, "PVAviFileStreamlist::PVAviFileStreamlist: Found Stream Header")); uint32 aviStrhSize = 0; if (PV_AVI_FILE_PARSER_SUCCESS != PVAviFileParserUtils::read32(aFp, aviStrhSize, true)) { PVAVIFILE_LOGERROR((0, "PVAviFileStreamlist::PVAviFileStreamlist: File Read Error")); iError = PV_AVI_FILE_PARSER_READ_ERROR; break; } bytesRead += CHUNK_SIZE; if (bytesRead > iStreamListSize) { PVAVIFILE_LOGERROR((0, "PVAviFileStreamlist::PVAviFileStreamlist: File & Byte Count mismatch")); iError = PV_AVI_FILE_PARSER_BYTE_COUNT_ERROR; break; } if ((aviStrhSize <= 0) || (aviStrhSize > iStreamListSize)) { PVAVIFILE_LOGERROR((0, "PVAviFileStreamlist::PVAviFileStreamlist: stream header size greater than stream list size")); iError = PV_AVI_FILE_PARSER_WRONG_SIZE; break; } if ((iError = ParseStreamHeader(aFp, aviStrhSize)) != PV_AVI_FILE_PARSER_SUCCESS) { PVAVIFILE_LOGERROR((0, "PVAviFileStreamlist::PVAviFileStreamlist: ParseStreamHeader function error")); break; } bytesRead += aviStrhSize; if (bytesRead > iStreamListSize) { PVAVIFILE_LOGERROR((0, "PVAviFileStreamlist::PVAviFileStreamlist: File Size & Byte Count Mismatch")); iError = PV_AVI_FILE_PARSER_BYTE_COUNT_ERROR; break; } } else if (STRF == chunkType) { PVAVIFILE_LOGINFO((0, "PVAviFileStreamlist::PVAviFileStreamlist: Found Stream Format Header")); uint32 aviStrfSize = 0; if (PV_AVI_FILE_PARSER_SUCCESS != PVAviFileParserUtils::read32(aFp, aviStrfSize, true)) { PVAVIFILE_LOGERROR((0, "PVAviFileStreamlist::PVAviFileStreamlist: File Read Error")); iError = PV_AVI_FILE_PARSER_READ_ERROR; break; } bytesRead += CHUNK_SIZE; if (bytesRead > iStreamListSize) { PVAVIFILE_LOGERROR((0, "PVAviFileStreamlist::PVAviFileStreamlist: File Size & Byte Count Mismatch")); iError = PV_AVI_FILE_PARSER_BYTE_COUNT_ERROR; break; } if ((aviStrfSize <= 0) || (aviStrfSize > iStreamListSize)) { PVAVIFILE_LOGERROR((0, "PVAviFileStreamlist::PVAviFileStreamlist: Stream Format Header Size Greater Than Stream List Size")); iError = PV_AVI_FILE_PARSER_WRONG_SIZE; break; } if ((iError = ParseStreamFormat(aFp, aviStrfSize)) != PV_AVI_FILE_PARSER_SUCCESS) { PVAVIFILE_LOGERROR((0, "PVAviFileStreamlist::PVAviFileStreamlist: ParseStreamFormat returned error")); break; } bytesRead += aviStrfSize; if (bytesRead > iStreamListSize) { PVAVIFILE_LOGERROR((0, "PVAviFileStreamlist::PVAviFileStreamlist: File Size & Byte Count Mismatch")); iError = PV_AVI_FILE_PARSER_BYTE_COUNT_ERROR; break; } } else if (STRD == chunkType) { if (PV_AVI_FILE_PARSER_SUCCESS != PVAviFileParserUtils::read32(aFp, iCodecSpecificHdrDataSize, true)) { PVAVIFILE_LOGERROR((0, "PVAviFileStreamlist::PVAviFileStreamlist: File Read Error")); iError = PV_AVI_FILE_PARSER_READ_ERROR; break; } bytesRead += CHUNK_SIZE; if ((iCodecSpecificHdrDataSize <= 0) || (iCodecSpecificHdrDataSize > iStreamListSize)) { PVAVIFILE_LOGERROR((0, "PVAviFileStreamlist::PVAviFileStreamlist: File Size & Byte Count Mismatch")); iError = PV_AVI_FILE_PARSER_WRONG_SIZE; break; } ipCodecSpecificHdrData = NULL; ipCodecSpecificHdrData = (uint8*)oscl_malloc(iCodecSpecificHdrDataSize); if (!ipCodecSpecificHdrData) { PVAVIFILE_LOGERROR((0, "PVAviFileStreamlist::PVAviFileStreamlist: Unable to allocate memory.")); iError = PV_AVI_FILE_PARSER_INSUFFICIENT_MEMORY; break; } if (0 == PVAviFileParserUtils::read8(aFp, ipCodecSpecificHdrData, iCodecSpecificHdrDataSize)) { PVAVIFILE_LOGERROR((0, "PVAviFileStreamlist::PVAviFileStreamlist: File Read Error")); iError = PV_AVI_FILE_PARSER_READ_ERROR; break; } bytesRead += iCodecSpecificHdrDataSize; if (bytesRead > iStreamListSize) { PVAVIFILE_LOGERROR((0, "PVAviFileStreamlist::PVAviFileStreamlist: File Size & Byte Count Mismatch")); iError = PV_AVI_FILE_PARSER_BYTE_COUNT_ERROR; break; } } else if (STRN == chunkType) { PVAVIFILE_LOGINFO((0, "PVAviFileStreamlist::PVAviFileStreamlist: Found stream name")); uint32 strnSz = 0; if (PV_AVI_FILE_PARSER_SUCCESS != PVAviFileParserUtils::read32(aFp, strnSz, true)) { PVAVIFILE_LOGERROR((0, "PVAviFileStreamlist::PVAviFileStreamlist: File Read Error")); iError = PV_AVI_FILE_PARSER_READ_ERROR; break; } bytesRead += CHUNK_SIZE; if (strnSz >= MAX_STRN_SZ) { uint8* strn = (uint8*)oscl_malloc(strnSz); if (!strn) { PVAVIFILE_LOGERROR((0, "PVAviFileStreamlist::PVAviFileStreamlist: Unable to allocate memory.")); iError = PV_AVI_FILE_PARSER_INSUFFICIENT_MEMORY; break; } if (PVAviFileParserUtils::read8(aFp, strn, strnSz) == 0) { PVAVIFILE_LOGERROR((0, "PVAviFileStreamlist::PVAviFileStreamlist: File Read Error")); iError = PV_AVI_FILE_PARSER_READ_ERROR; break; } oscl_strncpy(iStreamName, (char*)strn, (MAX_STRN_SZ - 1)); iStreamName[MAX_STRN_SZ - 1] = '\0'; oscl_free(strn); } else { if (PVAviFileParserUtils::read8(aFp, (uint8*)iStreamName, strnSz) == 0) { PVAVIFILE_LOGERROR((0, "PVAviFileStreamlist::PVAviFileStreamlist: File Read Error")); iError = PV_AVI_FILE_PARSER_READ_ERROR; break; } } bytesRead += strnSz; if (bytesRead > iStreamListSize) { PVAVIFILE_LOGERROR((0, "PVAviFileStreamlist::PVAviFileStreamlist: File Size & Byte Count Mismatch")); iError = PV_AVI_FILE_PARSER_BYTE_COUNT_ERROR; break; } } else if (JUNK == chunkType) { PVAVIFILE_LOGINFO((0, "PVAviFileStreamlist::PVAviFileStreamlist: Skip Junk Data")); uint32 junkSize = 0; if (PV_AVI_FILE_PARSER_SUCCESS != PVAviFileParserUtils::read32(aFp, junkSize, true)) { PVAVIFILE_LOGERROR((0, "PVAviFileStreamlist::PVAviFileStreamlist: File Read Error")); iError = PV_AVI_FILE_PARSER_READ_ERROR; break; } bytesRead += CHUNK_SIZE; if (bytesRead > iStreamListSize) { PVAVIFILE_LOGERROR((0, "PVAviFileStreamlist::PVAviFileStreamlist: File Size & Byte Count Mismatch")); iError = PV_AVI_FILE_PARSER_BYTE_COUNT_ERROR; break; } if ((junkSize <= 0) || (junkSize > iStreamListSize)) { PVAVIFILE_LOGERROR((0, "PVAviFileStreamlist::PVAviFileStreamlist: Junk data size more than stream list size")); iError = PV_AVI_FILE_PARSER_WRONG_SIZE; break; } aFp->Seek(junkSize, Oscl_File::SEEKCUR); bytesRead += junkSize; if (bytesRead > iStreamListSize) { PVAVIFILE_LOGERROR((0, "PVAviFileStreamlist::PVAviFileStreamlist: File Size & Byte Count Mismatch")); iError = PV_AVI_FILE_PARSER_BYTE_COUNT_ERROR; break; } } else { PVAVIFILE_LOGERROR((0, "PVAviFileStreamlist::PVAviFileStreamlist: Unexpected chunk in stream list")); iError = PV_AVI_FILE_PARSER_WRONG_CHUNK; break; } } //while(bytesRead <= iStreamListSize) }
PVMFStatus PVMFFileOutputNode::GetConfigParameter(PvmiKvp*& aParameters, int& aNumParamElements, int32 aIndex, PvmiKvpAttr aReqattr) { PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFFileOutputNode::GetConfigParameter() In")); aNumParamElements = 0; // Allocate memory for the KVP aParameters = (PvmiKvp*)oscl_malloc(sizeof(PvmiKvp)); if (aParameters == NULL) { PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFFileOutputNode::GetConfigParameter() Memory allocation for KVP failed")); return PVMFErrNoMemory; } oscl_memset(aParameters, 0, sizeof(PvmiKvp)); // Allocate memory for the key string in KVP PvmiKeyType memblock = (PvmiKeyType)oscl_malloc(FILEOUTPUTCONFIG_KEYSTRING_SIZE * sizeof(char)); if (NULL == memblock) { oscl_free(aParameters); PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFFileOutputNode::GetConfigParameter() Memory allocation for key string failed")); return PVMFErrNoMemory; } oscl_strset(memblock, 0, FILEOUTPUTCONFIG_KEYSTRING_SIZE * sizeof(char)); // Assign the key string buffer to KVP aParameters[0].key = memblock; // Copy the key string oscl_strncat(aParameters[0].key, _STRLIT_CHAR("x-pvmf/file/output/"), 21); oscl_strncat(aParameters[0].key, FileOutputNodeConfig_BaseKeys[aIndex].iString, oscl_strlen(FileOutputNodeConfig_BaseKeys[aIndex].iString)); oscl_strncat(aParameters[0].key, _STRLIT_CHAR(";type=value;valtype="), 20); switch (FileOutputNodeConfig_BaseKeys[aIndex].iValueType) { case PVMI_KVPVALTYPE_BITARRAY32: oscl_strncat(aParameters[0].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_BITARRAY32_STRING), oscl_strlen(PVMI_KVPVALTYPE_BITARRAY32_STRING)); break; case PVMI_KVPVALTYPE_KSV: oscl_strncat(aParameters[0].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_KSV_STRING), oscl_strlen(PVMI_KVPVALTYPE_KSV_STRING)); break; case PVMI_KVPVALTYPE_BOOL: oscl_strncat(aParameters[0].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_BOOL_STRING), oscl_strlen(PVMI_KVPVALTYPE_BOOL_STRING)); break; case PVMI_KVPVALTYPE_INT32: if (aReqattr == PVMI_KVPATTR_CUR) { oscl_strncat(aParameters[0].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_INT32_STRING), oscl_strlen(PVMI_KVPVALTYPE_RANGE_UINT32_STRING)); } break; case PVMI_KVPVALTYPE_UINT32: default: if (PVMI_KVPATTR_CAP == aReqattr) { oscl_strncat(aParameters[0].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_RANGE_UINT32_STRING), oscl_strlen(PVMI_KVPVALTYPE_RANGE_UINT32_STRING)); } else { oscl_strncat(aParameters[0].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_UINT32_STRING), oscl_strlen(PVMI_KVPVALTYPE_UINT32_STRING)); } break; } aParameters[0].key[FILEOUTPUTCONFIG_KEYSTRING_SIZE-1] = 0; // Copy the requested info switch (aIndex) { case PARAMETER1: // "parameter1" if (PVMI_KVPATTR_CUR == aReqattr) { // Return current value // get the parameter value here } else if (PVMI_KVPATTR_DEF == aReqattr) { // return default } else { // Return capability } break; case PARAMETER2: // "parameter2" if (PVMI_KVPATTR_CUR == aReqattr) { // Return current value // get the parameter value here } else if (PVMI_KVPATTR_DEF == aReqattr) { // return default } else { // Return capability } break; default: // Invalid index oscl_free(aParameters[0].key); oscl_free(aParameters); PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFFileOutputNode::GetConfigParameter() Invalid index to file output node parameter")); return PVMFErrNotSupported; } aNumParamElements = 1; PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFFileOutputNode::GetConfigParameter() Out")); return PVMFSuccess; }
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 ; }
// Stream-in ctor // Create and return a new SampleToChunkAtom by reading in from an ifstream SampleToChunkAtom::SampleToChunkAtom(MP4_FF_FILE *fp, uint32 size, uint32 type, OSCL_wString& filename, uint32 parsingMode) : FullAtom(fp, size, type) { _pfirstChunkVec = NULL; _psamplesPerChunkVec = NULL; _psampleDescriptionIndexVec = NULL; _Index = 0; _numChunksInRun = 0; _majorGetIndex = 0; _currGetChunk = -1; _numGetChunksInRun = 0; _currGetSampleCount = 0; _firstGetSampleInCurrChunk = 0; _numGetSamplesPerChunk = 0; _currGetSDI = 0; _majorPeekIndex = 0; _currPeekChunk = -1; _numPeekChunksInRun = 0; _currPeekSampleCount = 0; _firstPeekSampleInCurrChunk = 0; _numPeekSamplesPerChunk = 0; _currPeekSDI = 0; _parsed_entry_cnt = 0; _fileptr = NULL; _stbl_buff_size = MAX_CACHED_TABLE_ENTRIES_FILE; _next_buff_number = 0; _curr_buff_number = 0; _curr_entry_point = 0; _stbl_fptr_vec = NULL; _parsing_mode = parsingMode; iLogger = PVLogger::GetLoggerObject("mp4ffparser"); iStateVarLogger = PVLogger::GetLoggerObject("mp4ffparser_mediasamplestats"); iParsedDataLogger = PVLogger::GetLoggerObject("mp4ffparser_parseddata"); if (_success) { _currentChunkNumber = 0; _maxNumSamplesPerChunk = DEFAULT_MAX_NUM_SAMPLES_PER_CHUNK; _maxChunkDataSize = DEFAULT_MAX_CHUNK_DATA_SIZE; if (!AtomUtils::read32(fp, _entryCount)) { _success = false; } PVMF_MP4FFPARSER_LOGPARSEDINFO((0, "SampleToChunkAtom::SampleToChunkAtom- _entryCount =%d", _entryCount)); TOsclFileOffset dataSize = _size - (DEFAULT_FULL_ATOM_SIZE + 4); uint32 entrySize = (4 + 4 + 4); if ((TOsclFileOffset)(_entryCount*entrySize) > dataSize) { _success = false; } if (_success) { if (_entryCount > 0) { if (_parsing_mode) { if ((_entryCount > _stbl_buff_size)) // cahce size is 4K so that optimization should work if entry_count is greater than 4K { uint32 fptrBuffSize = (_entryCount / _stbl_buff_size) + 1; PV_MP4_FF_ARRAY_NEW(NULL, TOsclFileOffset, (fptrBuffSize), _stbl_fptr_vec); if (_stbl_fptr_vec == NULL) { _success = false; _mp4ErrorCode = MEMORY_ALLOCATION_FAILED; return; } PV_MP4_FF_ARRAY_NEW(NULL, uint32, (_stbl_buff_size), _pfirstChunkVec); if (_pfirstChunkVec == NULL) { _success = false; _mp4ErrorCode = MEMORY_ALLOCATION_FAILED; return; } PV_MP4_FF_ARRAY_NEW(NULL, uint32, (_stbl_buff_size), _psamplesPerChunkVec); if (_psamplesPerChunkVec == NULL) { _success = false; _mp4ErrorCode = MEMORY_ALLOCATION_FAILED; return; } PV_MP4_FF_ARRAY_NEW(NULL, uint32, (_stbl_buff_size), _psampleDescriptionIndexVec); if (_psampleDescriptionIndexVec == NULL) { _success = false; _mp4ErrorCode = MEMORY_ALLOCATION_FAILED; return; } { OsclAny* ptr = (MP4_FF_FILE *)(oscl_malloc(sizeof(MP4_FF_FILE))); if (ptr == NULL) { _success = false; _mp4ErrorCode = MEMORY_ALLOCATION_FAILED; return; } _fileptr = OSCL_PLACEMENT_NEW(ptr, MP4_FF_FILE()); _fileptr->_fileServSession = fp->_fileServSession; _fileptr->_pvfile.SetCPM(fp->_pvfile.GetCPM()); _fileptr->_pvfile.SetFileHandle(fp->_pvfile.iFileHandle); if (AtomUtils::OpenMP4File(filename, Oscl_File::MODE_READ | Oscl_File::MODE_BINARY, _fileptr) != 0) { _success = false; _mp4ErrorCode = FILE_OPEN_FAILED; } _fileptr->_fileSize = fp->_fileSize; } TOsclFileOffset _head_offset = AtomUtils::getCurrentFilePosition(fp); AtomUtils::seekFromCurrPos(fp, dataSize); AtomUtils::seekFromStart(_fileptr, _head_offset); ParseEntryUnit(0); uint32 firstsamplenum = 0; resetStateVariables(firstsamplenum); return; } else { _parsing_mode = 0; _stbl_buff_size = _entryCount; } } else { _parsing_mode = 0; _stbl_buff_size = _entryCount; } PV_MP4_FF_ARRAY_NEW(NULL, uint32, (_entryCount), _pfirstChunkVec); PV_MP4_FF_ARRAY_NEW(NULL, uint32, (_entryCount), _psamplesPerChunkVec); PV_MP4_FF_ARRAY_NEW(NULL, uint32, (_entryCount), _psampleDescriptionIndexVec); uint32 firstChunk; uint32 samplesPerChunk; uint32 sampleDescrIndex; uint32 offSet = 0; uint32 prevFirstChunk = 0; uint32 j = 0; for (uint32 i = 0; i < _entryCount; i++) { if (!AtomUtils::read32(fp, firstChunk)) { _success = false; break; } if (i == 0) offSet = firstChunk; if (!AtomUtils::read32(fp, samplesPerChunk)) { _success = false; break; } if (!AtomUtils::read32(fp, sampleDescrIndex)) { _success = false; break; } if (firstChunk > prevFirstChunk) { _pfirstChunkVec[j] = (firstChunk - offSet); _psamplesPerChunkVec[j] = (samplesPerChunk); _psampleDescriptionIndexVec[j] = (sampleDescrIndex); prevFirstChunk = firstChunk; j++; } } _entryCount = j; uint32 firstsamplenum = 0; resetStateVariables(firstsamplenum); } else { _pfirstChunkVec = NULL; _psamplesPerChunkVec = NULL; _psampleDescriptionIndexVec = NULL; } } if (!_success) { _mp4ErrorCode = READ_SAMPLE_TO_CHUNK_ATOM_FAILED; PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>SampleToChunkAtom::SampleToChunkAtom- Read SampleToChunk Atom failed %d", _mp4ErrorCode)); } } else { if (_mp4ErrorCode != ATOM_VERSION_NOT_SUPPORTED) { _mp4ErrorCode = READ_SAMPLE_TO_CHUNK_ATOM_FAILED; PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>SampleToChunkAtom::SampleToChunkAtom- Read SampleToChunk Atom failed %d", _mp4ErrorCode)); } } }
// Ctor to create a new ChunkOffsetAtom by reading in from an ifstream ChunkOffsetAtom::ChunkOffsetAtom(MP4_FF_FILE *fp, uint32 size, uint32 type, OSCL_wString& filename, uint32 parsingMode) : FullAtom(fp, size, type) { _pchunkOffsets = NULL; _stbl_buff_size = MAX_CACHED_TABLE_ENTRIES_FILE; _next_buff_number = 0; _curr_buff_number = 0; _curr_entry_point = 0; _stbl_fptr_vec = NULL; _parsed_entry_cnt = 0; _parsingMode = parsingMode; _fileptr = NULL; if (_success) { _currentDataOffset = 0; if (!AtomUtils::read32(fp, _entryCount)) { _success = false; } uint32 dataSize = _size - (DEFAULT_FULL_ATOM_SIZE + 4); uint32 entrySize = 4; if ((_entryCount*entrySize) > dataSize) { _success = false; } if (_success) { if (_entryCount > 0) { if (_parsingMode == 1) { // cache size is 4K so that optimization should work if entry_count is greater than 4K if ((_entryCount > _stbl_buff_size)) { uint32 fptrBuffSize = (_entryCount / _stbl_buff_size) + 1; PV_MP4_FF_ARRAY_NEW(NULL, uint32, (fptrBuffSize), _stbl_fptr_vec); if (_stbl_fptr_vec == NULL) { _success = false; _mp4ErrorCode = MEMORY_ALLOCATION_FAILED; return; } PV_MP4_FF_ARRAY_NEW(NULL, uint32, (_stbl_buff_size), _pchunkOffsets); if (_pchunkOffsets == NULL) { _success = false; _mp4ErrorCode = MEMORY_ALLOCATION_FAILED; return; } { OsclAny* ptr = (MP4_FF_FILE *)(oscl_malloc(sizeof(MP4_FF_FILE))); if (ptr == NULL) { _success = false; _mp4ErrorCode = MEMORY_ALLOCATION_FAILED; return; } _fileptr = OSCL_PLACEMENT_NEW(ptr, MP4_FF_FILE()); _fileptr->_fileServSession = fp->_fileServSession; _fileptr->_pvfile.SetCPM(fp->_pvfile.GetCPM()); if (AtomUtils::OpenMP4File(filename, Oscl_File::MODE_READ | Oscl_File::MODE_BINARY, _fileptr) != 0) { _success = false; _mp4ErrorCode = FILE_OPEN_FAILED; } _fileptr->_fileSize = fp->_fileSize; } int32 _head_offset = AtomUtils::getCurrentFilePosition(fp); AtomUtils::seekFromCurrPos(fp, dataSize); AtomUtils::seekFromStart(_fileptr, _head_offset); return; } else { _parsingMode = 0; _stbl_buff_size = _entryCount; } } else { _stbl_buff_size = _entryCount; } _parsingMode = 0; PV_MP4_FF_ARRAY_NEW(NULL, uint32, (_entryCount), _pchunkOffsets); uint32 offset = 0; for (uint32 i = 0; i < _entryCount; i++) { if (!AtomUtils::read32(fp, offset)) { _success = false; break; } _pchunkOffsets[i] = offset; } _parsed_entry_cnt = _entryCount; } else { _pchunkOffsets = NULL; } } if (!_success) { _mp4ErrorCode = READ_CHUNK_OFFSET_ATOM_FAILED; } } else { if (_mp4ErrorCode != ATOM_VERSION_NOT_SUPPORTED) _mp4ErrorCode = READ_CHUNK_OFFSET_ATOM_FAILED; } }
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 ; }
OMX_ERRORTYPE H263EncRegister(OMXGlobalData *data) { OMX_S32 ii; ComponentRegistrationType* pCRT = (ComponentRegistrationType*) oscl_malloc(sizeof(ComponentRegistrationType)); if (pCRT) { pCRT->ComponentName = (OMX_STRING)"OMX.PV.h263enc"; pCRT->RoleString[0] = (OMX_STRING)"video_encoder.h263"; pCRT->NumberOfRolesSupported = 1; pCRT->SharedLibraryOsclUuid = NULL; #if USE_DYNAMIC_LOAD_OMX_COMPONENTS pCRT->FunctionPtrCreateComponent = &OmxComponentFactoryDynamicCreate; pCRT->FunctionPtrDestroyComponent = &OmxComponentFactoryDynamicDestructor; pCRT->SharedLibraryName = (OMX_STRING)"libomx_m4venc_sharedlibrary"; pCRT->SharedLibraryPtr = NULL; OsclUuid *temp = (OsclUuid *) oscl_malloc(sizeof(OsclUuid)); if (temp == NULL) { oscl_free(pCRT); // free allocated memory return OMX_ErrorInsufficientResources; } OSCL_PLACEMENT_NEW(temp, PV_OMX_H263ENC_UUID); pCRT->SharedLibraryOsclUuid = (OMX_PTR) temp; pCRT->SharedLibraryRefCounter = 0; #endif #if REGISTER_OMX_H263ENC_COMPONENT #if (DYNAMIC_LOAD_OMX_H263ENC_COMPONENT == 0) pCRT->FunctionPtrCreateComponent = &H263EncOmxComponentFactory; pCRT->FunctionPtrDestroyComponent = &H263EncOmxComponentDestructor; pCRT->SharedLibraryName = NULL; pCRT->SharedLibraryPtr = NULL; if (pCRT->SharedLibraryOsclUuid) oscl_free(pCRT->SharedLibraryOsclUuid); pCRT->SharedLibraryOsclUuid = NULL; pCRT->SharedLibraryRefCounter = 0; #endif #endif } else { return OMX_ErrorInsufficientResources; } for (ii = 0; ii < MAX_SUPPORTED_COMPONENTS; ii++) { if (NULL == data->ipRegTemplateList[ii]) { data->ipRegTemplateList[ii] = pCRT; break; } } if (MAX_SUPPORTED_COMPONENTS == ii) { return OMX_ErrorInsufficientResources; } return OMX_ErrorNone; }
void pv_metadata_engine_test::ReadClipsFile() { char* iClip; char ClipsFileName[255]; int32 err = 0; Oscl_FileServer fileServer; err = fileServer.Connect(); if (0 == err) { Oscl_File *ClipsFile = new Oscl_File; // Full path of ClipsFile is: SOURCENAME_PREPEND_STRING + pvlogger.ini oscl_strncpy(ClipsFileName, SOURCENAME_PREPEND_STRING, oscl_strlen(SOURCENAME_PREPEND_STRING) + 1); oscl_strcat(ClipsFileName, "Clips.txt"); printf("\nPath for Clips File is %s\n", ClipsFileName); err = ClipsFile->Open(ClipsFileName, Oscl_File::MODE_READ, fileServer); if (0 == err) { int len = 0; if (0 == ClipsFile->Seek(0, Oscl_File::SEEKSET)) { while (!ClipsFile->EndOfFile()) { iClip = (char*)oscl_malloc(200); iClip[0] = '\0'; fgetline(ClipsFile, iClip, 127); len = oscl_strlen(iClip); if (len == 0 || iClip[0] == '\n' || (iClip[0] == '\r' && iClip[1] == '\n')) { numOfClips--; oscl_free(iClip); } else if (iClip[len-1] == '\n' && iClip[len-2] == '\r') { iClip[len-2] = '\0'; iClips.push_back(iClip); } else if (iClip[len-1] == '\n' && iClip[len-2] != '\r') { iClip[len-1] = '\0'; iClips.push_back(iClip); } else { iClip[len] = '\0'; iClips.push_back(iClip); } numOfClips++; } ClipsFile->Close(); printf("\nClips are\n"); for (it = iClips.begin(); it < iClips.end(); it++) { printf("\n%s\n", *it); } it = iClips.begin(); iClipFilePresent = true; } } delete(ClipsFile); } fileServer.Close(); }
// Stream-in ctor TimeToSampleAtom::TimeToSampleAtom(MP4_FF_FILE *fp, uint32 mediaType, uint32 size, uint32 type, OSCL_wString& filename, uint32 parsingMode) : FullAtom(fp, size, type) { _psampleCountVec = NULL; _psampleDeltaVec = NULL; _currGetSampleCount = 0; _currGetIndex = -1; _currGetTimeDelta = 0; _currPeekSampleCount = 0; _currPeekIndex = -1; _currPeekTimeDelta = 0; _mediaType = mediaType; _parsed_entry_cnt = 0; _fileptr = NULL; _parsing_mode = 0; _parsing_mode = parsingMode; _stbl_buff_size = MAX_CACHED_TABLE_ENTRIES_FILE; _next_buff_number = 0; _curr_buff_number = 0; _curr_entry_point = 0; _stbl_fptr_vec = NULL; iLogger = PVLogger::GetLoggerObject("mp4ffparser"); iStateVarLogger = PVLogger::GetLoggerObject("mp4ffparser_mediasamplestats"); iParsedDataLogger = PVLogger::GetLoggerObject("mp4ffparser_parseddata"); if (_success) { if (!AtomUtils::read32(fp, _entryCount)) { _success = false; } PVMF_MP4FFPARSER_LOGPARSEDINFO((0, "TimeToSampleAtom::TimeToSampleAtom- _entryCount =%d", _entryCount)); uint32 dataSize = _size - (DEFAULT_FULL_ATOM_SIZE + 4); uint32 entrySize = (4 + 4); if ((_entryCount*entrySize) > dataSize) { _success = false; } if (_success) { if (_entryCount > 0) { if (parsingMode == 1) { // cache size is 4K so that optimization should work if entry_count is greater than 4K if ((_entryCount > _stbl_buff_size)) { uint32 fptrBuffSize = (_entryCount / _stbl_buff_size) + 1; PV_MP4_FF_ARRAY_NEW(NULL, uint32, (fptrBuffSize), _stbl_fptr_vec); if (_stbl_fptr_vec == NULL) { _success = false; _mp4ErrorCode = MEMORY_ALLOCATION_FAILED; return; } PV_MP4_FF_ARRAY_NEW(NULL, uint32, (_stbl_buff_size), _psampleCountVec); if (_psampleCountVec == NULL) { _success = false; _mp4ErrorCode = MEMORY_ALLOCATION_FAILED; return; } PV_MP4_FF_ARRAY_NEW(NULL, uint32, (_stbl_buff_size), _psampleDeltaVec); if (_psampleDeltaVec == NULL) { PV_MP4_ARRAY_DELETE(NULL, _psampleDeltaVec); _psampleDeltaVec = NULL; _success = false; _mp4ErrorCode = MEMORY_ALLOCATION_FAILED; return; } for (uint32 idx = 0; idx < _stbl_buff_size; idx++) //initialization { _psampleCountVec[idx] = 0; _psampleDeltaVec[idx] = 0; } OsclAny* ptr = (MP4_FF_FILE *)(oscl_malloc(sizeof(MP4_FF_FILE))); if (ptr == NULL) { _success = false; _mp4ErrorCode = MEMORY_ALLOCATION_FAILED; return; } _fileptr = OSCL_PLACEMENT_NEW(ptr, MP4_FF_FILE()); _fileptr->_fileServSession = fp->_fileServSession; _fileptr->_pvfile.SetCPM(fp->_pvfile.GetCPM()); _fileptr->_pvfile.SetFileHandle(fp->_pvfile.iFileHandle); if (AtomUtils::OpenMP4File(filename, Oscl_File::MODE_READ | Oscl_File::MODE_BINARY, _fileptr) != 0) { _success = false; _mp4ErrorCode = FILE_OPEN_FAILED; } _fileptr->_fileSize = fp->_fileSize; int32 _head_offset = AtomUtils::getCurrentFilePosition(fp); AtomUtils::seekFromCurrPos(fp, dataSize); AtomUtils::seekFromStart(_fileptr, _head_offset); return; } else { _parsing_mode = 0; _stbl_buff_size = _entryCount; } } else { _stbl_buff_size = _entryCount; } PV_MP4_FF_ARRAY_NEW(NULL, uint32, (_entryCount), _psampleCountVec); if (_psampleCountVec == NULL) { _success = false; _mp4ErrorCode = MEMORY_ALLOCATION_FAILED; return; } PV_MP4_FF_ARRAY_NEW(NULL, uint32, (_entryCount), _psampleDeltaVec); if (_psampleDeltaVec == NULL) { PV_MP4_ARRAY_DELETE(NULL, _psampleDeltaVec); _psampleDeltaVec = NULL; _success = false; _mp4ErrorCode = MEMORY_ALLOCATION_FAILED; return; } for (uint32 idx = 0; idx < _entryCount; idx++) //initialization { _psampleCountVec[idx] = 0; _psampleDeltaVec[idx] = 0; } uint32 number = 0; uint32 delta = 0; for (_parsed_entry_cnt = 0; _parsed_entry_cnt < _entryCount; _parsed_entry_cnt++) { if (!AtomUtils::read32(fp, number)) { _success = false; break; } if (!AtomUtils::read32(fp, delta)) { _success = false; break; } _psampleCountVec[_parsed_entry_cnt] = (number); _psampleDeltaVec[_parsed_entry_cnt] = (delta); } } } if (!_success) { _mp4ErrorCode = READ_TIME_TO_SAMPLE_ATOM_FAILED; } } else { if (_mp4ErrorCode != ATOM_VERSION_NOT_SUPPORTED) _mp4ErrorCode = READ_TIME_TO_SAMPLE_ATOM_FAILED; } }