00001
00031 #include <omxcore.h>
00032 #include <omx_base_audio_port.h>
00033 #include <omx_filereader_component.h>
00034
00035 #define MAX_COMPONENT_FILEREADER 1
00036
00038 static OMX_U32 noFilereaderInstance=0;
00039
00040 #define DEFAULT_FILENAME_LENGTH 256
00041
00044 OMX_ERRORTYPE omx_filereader_component_Constructor(OMX_COMPONENTTYPE *openmaxStandComp,OMX_STRING cComponentName) {
00045
00046 OMX_ERRORTYPE err = OMX_ErrorNone;
00047 omx_base_audio_PortType *pPort;
00048 omx_filereader_component_PrivateType* omx_filereader_component_Private;
00049 OMX_U32 i;
00050
00051 DEBUG(DEB_LEV_FUNCTION_NAME,"In %s \n",__func__);
00052
00053 if (!openmaxStandComp->pComponentPrivate) {
00054 openmaxStandComp->pComponentPrivate = calloc(1, sizeof(omx_filereader_component_PrivateType));
00055 if(openmaxStandComp->pComponentPrivate == NULL) {
00056 return OMX_ErrorInsufficientResources;
00057 }
00058 }
00059
00060 omx_filereader_component_Private = openmaxStandComp->pComponentPrivate;
00061 omx_filereader_component_Private->ports = NULL;
00062
00063 err = omx_base_source_Constructor(openmaxStandComp, cComponentName);
00064
00066 if (omx_filereader_component_Private->sPortTypesParam.nPorts && !omx_filereader_component_Private->ports) {
00067 omx_filereader_component_Private->ports = calloc(omx_filereader_component_Private->sPortTypesParam.nPorts, sizeof(omx_base_PortType *));
00068 if (!omx_filereader_component_Private->ports) {
00069 return OMX_ErrorInsufficientResources;
00070 }
00071 for (i=0; i < omx_filereader_component_Private->sPortTypesParam.nPorts; i++) {
00072 omx_filereader_component_Private->ports[i] = calloc(1, sizeof(omx_base_audio_PortType));
00073 if (!omx_filereader_component_Private->ports[i]) {
00074 return OMX_ErrorInsufficientResources;
00075 }
00076 }
00077 }
00078
00079 base_audio_port_Constructor(openmaxStandComp, &omx_filereader_component_Private->ports[0], 0, OMX_FALSE);
00080
00081 pPort = (omx_base_audio_PortType *) omx_filereader_component_Private->ports[OMX_BASE_SOURCE_OUTPUTPORT_INDEX];
00082
00088
00089 pPort->sPortParam.nBufferSize = DEFAULT_OUT_BUFFER_SIZE;
00090
00091 omx_filereader_component_Private->BufferMgmtCallback = omx_filereader_component_BufferMgmtCallback;
00092
00093 setHeader(&omx_filereader_component_Private->sTimeStamp, sizeof(OMX_TIME_CONFIG_TIMESTAMPTYPE));
00094 omx_filereader_component_Private->sTimeStamp.nPortIndex=0;
00095 omx_filereader_component_Private->sTimeStamp.nTimestamp=0x0;
00096
00097 omx_filereader_component_Private->destructor = omx_filereader_component_Destructor;
00098 omx_filereader_component_Private->messageHandler = omx_filereader_component_MessageHandler;
00099
00100 noFilereaderInstance++;
00101 if(noFilereaderInstance > MAX_COMPONENT_FILEREADER) {
00102 return OMX_ErrorInsufficientResources;
00103 }
00104
00105 openmaxStandComp->SetParameter = omx_filereader_component_SetParameter;
00106 openmaxStandComp->GetParameter = omx_filereader_component_GetParameter;
00107 openmaxStandComp->SetConfig = omx_filereader_component_SetConfig;
00108 openmaxStandComp->GetConfig = omx_filereader_component_GetConfig;
00109 openmaxStandComp->GetExtensionIndex = omx_filereader_component_GetExtensionIndex;
00110
00111
00112
00113 omx_filereader_component_Private->avformatReady = OMX_FALSE;
00114 if(!omx_filereader_component_Private->avformatSyncSem) {
00115 omx_filereader_component_Private->avformatSyncSem = calloc(1,sizeof(tsem_t));
00116 if(omx_filereader_component_Private->avformatSyncSem == NULL) return OMX_ErrorInsufficientResources;
00117 tsem_init(omx_filereader_component_Private->avformatSyncSem, 0);
00118 }
00119 omx_filereader_component_Private->sInputFileName = malloc(DEFAULT_FILENAME_LENGTH);
00120 memset(omx_filereader_component_Private->sInputFileName,0,DEFAULT_FILENAME_LENGTH);
00121
00122 omx_filereader_component_Private->audio_coding_type = OMX_AUDIO_CodingMP3;
00123
00124 return err;
00125 }
00126
00129 OMX_ERRORTYPE omx_filereader_component_Destructor(OMX_COMPONENTTYPE *openmaxStandComp) {
00130 omx_filereader_component_PrivateType* omx_filereader_component_Private = openmaxStandComp->pComponentPrivate;
00131 OMX_U32 i;
00132
00133 if(omx_filereader_component_Private->avformatSyncSem) {
00134 tsem_deinit(omx_filereader_component_Private->avformatSyncSem);
00135 free(omx_filereader_component_Private->avformatSyncSem);
00136 omx_filereader_component_Private->avformatSyncSem=NULL;
00137 }
00138
00139 if(omx_filereader_component_Private->sInputFileName) {
00140 free(omx_filereader_component_Private->sInputFileName);
00141 }
00142
00143
00144 if (omx_filereader_component_Private->ports) {
00145 for (i=0; i < omx_filereader_component_Private->sPortTypesParam.nPorts; i++) {
00146 if(omx_filereader_component_Private->ports[i])
00147 omx_filereader_component_Private->ports[i]->PortDestructor(omx_filereader_component_Private->ports[i]);
00148 }
00149 free(omx_filereader_component_Private->ports);
00150 omx_filereader_component_Private->ports=NULL;
00151 }
00152
00153 noFilereaderInstance--;
00154 DEBUG(DEB_LEV_FUNCTION_NAME,"In %s \n",__func__);
00155 return omx_base_source_Destructor(openmaxStandComp);
00156 }
00157
00160 OMX_ERRORTYPE omx_filereader_component_Init(OMX_COMPONENTTYPE *openmaxStandComp) {
00161
00162 omx_filereader_component_PrivateType* omx_filereader_component_Private = openmaxStandComp->pComponentPrivate;
00163 int error;
00164 OMX_VENDOR_EXTRADATATYPE *pExtraData;
00165
00166 DEBUG(DEB_LEV_FUNCTION_NAME,"In %s \n",__func__);
00167
00168 avcodec_init();
00169 av_register_all();
00170
00173 error = av_open_input_file(&omx_filereader_component_Private->avformatcontext,
00174 (char*)omx_filereader_component_Private->sInputFileName,
00175 omx_filereader_component_Private->avinputformat,
00176 0,
00177 omx_filereader_component_Private->avformatparameters);
00178
00179 if(error != 0) {
00180 DEBUG(DEB_LEV_ERR,"Couldn't Open Input Stream error=%d File Name=%s--\n",
00181 error,(char*)omx_filereader_component_Private->sInputFileName);
00182
00183 (*(omx_filereader_component_Private->callbacks->EventHandler))
00184 (openmaxStandComp,
00185 omx_filereader_component_Private->callbackData,
00186 OMX_EventError,
00187 OMX_ErrorFormatNotDetected,
00188 0,
00189 NULL);
00190
00191 return OMX_ErrorBadParameter;
00192 }
00193
00194 av_find_stream_info(omx_filereader_component_Private->avformatcontext);
00195
00196 if(omx_filereader_component_Private->audio_coding_type == OMX_AUDIO_CodingMP3) {
00197 DEBUG(DEB_LEV_SIMPLE_SEQ,"In %s Audio Coding Type Mp3\n",__func__);
00198 } else if(omx_filereader_component_Private->audio_coding_type == OMX_AUDIO_CodingVORBIS) {
00199 DEBUG(DEB_LEV_SIMPLE_SEQ,"In %s Audio Coding Type OGG\n",__func__);
00200 } else if(omx_filereader_component_Private->audio_coding_type == OMX_AUDIO_CodingAAC) {
00201 DEBUG(DEB_LEV_SIMPLE_SEQ,"In %s Audio Coding Type AAC\n",__func__);
00202 } else {
00203 DEBUG(DEB_LEV_ERR,"In %s Ouch!! No Audio Coding Type Selected\n",__func__);
00204 }
00205
00206 DEBUG(DEB_LEV_SIMPLE_SEQ,"In %s Extra data size=%d\n",__func__,omx_filereader_component_Private->avformatcontext->streams[0]->codec->extradata_size);
00207
00209 omx_filereader_component_Private->bIsEOSSent = OMX_FALSE;
00210
00214
00215 pExtraData = malloc(sizeof(OMX_VENDOR_EXTRADATATYPE));
00216 pExtraData->nPortIndex = 0;
00217 pExtraData->nDataSize = omx_filereader_component_Private->avformatcontext->streams[0]->codec->extradata_size;
00218 pExtraData->pData = omx_filereader_component_Private->avformatcontext->streams[0]->codec->extradata;
00219
00220 (*(omx_filereader_component_Private->callbacks->EventHandler))
00221 (openmaxStandComp,
00222 omx_filereader_component_Private->callbackData,
00223 OMX_EventPortFormatDetected,
00224 OMX_IndexParamAudioPortFormat,
00225 0,
00226 NULL);
00227
00228 (*(omx_filereader_component_Private->callbacks->EventHandler))
00229 (openmaxStandComp,
00230 omx_filereader_component_Private->callbackData,
00231 OMX_EventPortSettingsChanged,
00232 OMX_IndexParamCommonExtraQuantData,
00233 0,
00234 pExtraData);
00235
00236 omx_filereader_component_Private->avformatReady = OMX_TRUE;
00237
00238 tsem_up(omx_filereader_component_Private->avformatSyncSem);
00239
00240 free(pExtraData);
00241 return OMX_ErrorNone;
00242 }
00243
00246 OMX_ERRORTYPE omx_filereader_component_Deinit(OMX_COMPONENTTYPE *openmaxStandComp) {
00247
00248 omx_filereader_component_PrivateType* omx_filereader_component_Private = openmaxStandComp->pComponentPrivate;
00249
00250 DEBUG(DEB_LEV_FUNCTION_NAME, "In %s \n",__func__);
00252 av_close_input_file(omx_filereader_component_Private->avformatcontext);
00253
00254 omx_filereader_component_Private->avformatReady = OMX_FALSE;
00255 tsem_reset(omx_filereader_component_Private->avformatSyncSem);
00256
00257 return OMX_ErrorNone;
00258 }
00259
00260
00265 void omx_filereader_component_BufferMgmtCallback(OMX_COMPONENTTYPE *openmaxStandComp, OMX_BUFFERHEADERTYPE* pOutputBuffer) {
00266
00267 omx_filereader_component_PrivateType* omx_filereader_component_Private = openmaxStandComp->pComponentPrivate;
00268 int error;
00269
00270 DEBUG(DEB_LEV_FUNCTION_NAME,"In %s \n",__func__);
00271
00272 if (omx_filereader_component_Private->avformatReady == OMX_FALSE) {
00273 if(omx_filereader_component_Private->state == OMX_StateExecuting) {
00274
00275 tsem_down(omx_filereader_component_Private->avformatSyncSem);
00276 } else {
00277 return;
00278 }
00279 }
00280
00281 pOutputBuffer->nFilledLen = 0;
00282 pOutputBuffer->nOffset = 0;
00283
00284 if(omx_filereader_component_Private->sTimeStamp.nTimestamp != 0x0) {
00285 av_seek_frame(omx_filereader_component_Private->avformatcontext, 0, omx_filereader_component_Private->sTimeStamp.nTimestamp, AVSEEK_FLAG_ANY);
00286 DEBUG(DEB_LEV_ERR, "Seek Timestamp %llx \n",omx_filereader_component_Private->sTimeStamp.nTimestamp);
00287 omx_filereader_component_Private->sTimeStamp.nTimestamp = 0x0;
00288 }
00289
00290 error = av_read_frame(omx_filereader_component_Private->avformatcontext, &omx_filereader_component_Private->pkt);
00291 if(error < 0) {
00292 DEBUG(DEB_LEV_FULL_SEQ,"In %s EOS - no more packet,state=%x\n",__func__,
00293 omx_filereader_component_Private->state);
00294 if(omx_filereader_component_Private->bIsEOSSent == OMX_FALSE) {
00295 pOutputBuffer->nFlags = OMX_BUFFERFLAG_EOS;
00296 omx_filereader_component_Private->bIsEOSSent = OMX_TRUE;
00297 }
00298 } else {
00299 DEBUG(DEB_LEV_SIMPLE_SEQ,"\n packet size : %d \n",omx_filereader_component_Private->pkt.size);
00301 memcpy(pOutputBuffer->pBuffer, omx_filereader_component_Private->pkt.data, omx_filereader_component_Private->pkt.size);
00302 pOutputBuffer->nFilledLen = omx_filereader_component_Private->pkt.size;
00303 pOutputBuffer->nTimeStamp = omx_filereader_component_Private->pkt.dts;
00304
00305 if(pOutputBuffer->nTimeStamp == 0x80000000) {
00306 pOutputBuffer->nTimeStamp=0x0;
00307 }
00308 }
00309
00310 av_free_packet(&omx_filereader_component_Private->pkt);
00311
00313 DEBUG(DEB_LEV_FULL_SEQ, "One output buffer %x len=%d is full returning\n", (int)pOutputBuffer->pBuffer, (int)pOutputBuffer->nFilledLen);
00314 }
00315
00316 OMX_ERRORTYPE omx_filereader_component_SetParameter(
00317 OMX_IN OMX_HANDLETYPE hComponent,
00318 OMX_IN OMX_INDEXTYPE nParamIndex,
00319 OMX_IN OMX_PTR ComponentParameterStructure) {
00320
00321 OMX_ERRORTYPE err = OMX_ErrorNone;
00322 OMX_AUDIO_PARAM_PORTFORMATTYPE *pAudioPortFormat;
00323 OMX_AUDIO_PARAM_MP3TYPE * pAudioMp3;
00324 OMX_U32 portIndex;
00325 OMX_U32 i;
00326 OMX_U32 nFileNameLength;
00327
00328
00329 OMX_COMPONENTTYPE *openmaxStandComp = (OMX_COMPONENTTYPE*)hComponent;
00330 omx_filereader_component_PrivateType* omx_filereader_component_Private = openmaxStandComp->pComponentPrivate;
00331 omx_base_audio_PortType* pPort = (omx_base_audio_PortType *) omx_filereader_component_Private->ports[OMX_BASE_SOURCE_OUTPUTPORT_INDEX];
00332
00333 if(ComponentParameterStructure == NULL) {
00334 return OMX_ErrorBadParameter;
00335 }
00336
00337 DEBUG(DEB_LEV_SIMPLE_SEQ, " Setting parameter %i\n", nParamIndex);
00338
00339 switch(nParamIndex) {
00340 case OMX_IndexParamAudioPortFormat:
00341 pAudioPortFormat = (OMX_AUDIO_PARAM_PORTFORMATTYPE*)ComponentParameterStructure;
00342 portIndex = pAudioPortFormat->nPortIndex;
00343
00344 err = omx_base_component_ParameterSanityCheck(hComponent, portIndex, pAudioPortFormat, sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE));
00345 if(err!=OMX_ErrorNone) {
00346 DEBUG(DEB_LEV_ERR, "In %s Parameter Check Error=%x\n",__func__,err);
00347 break;
00348 }
00349 if (portIndex < 1) {
00350 memcpy(&pPort->sAudioParam,pAudioPortFormat,sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE));
00351 } else {
00352 return OMX_ErrorBadPortIndex;
00353 }
00354 break;
00355 case OMX_IndexParamAudioMp3:
00356 pAudioMp3 = (OMX_AUDIO_PARAM_MP3TYPE*)ComponentParameterStructure;
00357
00358 err = omx_base_component_ParameterSanityCheck(hComponent, pAudioMp3->nPortIndex, pAudioMp3, sizeof(OMX_AUDIO_PARAM_MP3TYPE));
00359 if(err!=OMX_ErrorNone) {
00360 DEBUG(DEB_LEV_ERR, "In %s Parameter Check Error=%x\n",__func__,err);
00361 break;
00362 }
00363 break;
00364 case OMX_IndexVendorFileReadInputFilename :
00365 nFileNameLength = strlen((char *)ComponentParameterStructure) + 1;
00366 if(nFileNameLength > DEFAULT_FILENAME_LENGTH) {
00367 free(omx_filereader_component_Private->sInputFileName);
00368 omx_filereader_component_Private->sInputFileName = malloc(nFileNameLength);
00369 }
00370 strcpy(omx_filereader_component_Private->sInputFileName, (char *)ComponentParameterStructure);
00371 omx_filereader_component_Private->bIsEOSSent = OMX_FALSE;
00373 for(i = 0; omx_filereader_component_Private->sInputFileName[i] != '\0'; i++);
00374 if(omx_filereader_component_Private->sInputFileName[i - 1] == '3') {
00375 omx_filereader_component_Private->audio_coding_type = OMX_AUDIO_CodingMP3;
00376 } else if(omx_filereader_component_Private->sInputFileName[i - 1] == 'g') {
00377 omx_filereader_component_Private->audio_coding_type = OMX_AUDIO_CodingVORBIS;
00378 } else if(omx_filereader_component_Private->sInputFileName[i - 1] == 'c') {
00379 omx_filereader_component_Private->audio_coding_type = OMX_AUDIO_CodingAAC;
00380 } else {
00381 return OMX_ErrorBadParameter;
00382 }
00384 if(omx_filereader_component_Private->audio_coding_type == OMX_AUDIO_CodingMP3) {
00385 strcpy(pPort->sPortParam.format.audio.cMIMEType, "audio/mpeg");
00386 pPort->sPortParam.format.audio.eEncoding = OMX_AUDIO_CodingMP3;
00387 pPort->sAudioParam.eEncoding = OMX_AUDIO_CodingMP3;
00388 } else if(omx_filereader_component_Private->audio_coding_type == OMX_AUDIO_CodingVORBIS) {
00389 strcpy(pPort->sPortParam.format.audio.cMIMEType, "audio/vorbis");
00390 pPort->sPortParam.format.audio.eEncoding = OMX_AUDIO_CodingVORBIS;
00391 pPort->sAudioParam.eEncoding = OMX_AUDIO_CodingVORBIS;
00392 } else if(omx_filereader_component_Private->audio_coding_type == OMX_AUDIO_CodingAAC) {
00393 strcpy(pPort->sPortParam.format.audio.cMIMEType, "audio/aac");
00394 pPort->sPortParam.format.audio.eEncoding = OMX_AUDIO_CodingAAC;
00395 pPort->sAudioParam.eEncoding = OMX_AUDIO_CodingAAC;
00396 }
00397 break;
00398 default:
00399 return omx_base_component_SetParameter(hComponent, nParamIndex, ComponentParameterStructure);
00400 }
00401 return err;
00402 }
00403
00404 OMX_ERRORTYPE omx_filereader_component_GetParameter(
00405 OMX_IN OMX_HANDLETYPE hComponent,
00406 OMX_IN OMX_INDEXTYPE nParamIndex,
00407 OMX_INOUT OMX_PTR ComponentParameterStructure) {
00408
00409 OMX_ERRORTYPE err = OMX_ErrorNone;
00410 OMX_AUDIO_PARAM_PORTFORMATTYPE *pAudioPortFormat;
00411 OMX_COMPONENTTYPE *openmaxStandComp = (OMX_COMPONENTTYPE*)hComponent;
00412 omx_filereader_component_PrivateType* omx_filereader_component_Private = openmaxStandComp->pComponentPrivate;
00413 omx_base_audio_PortType *pPort = (omx_base_audio_PortType *) omx_filereader_component_Private->ports[OMX_BASE_SOURCE_OUTPUTPORT_INDEX];
00414 if (ComponentParameterStructure == NULL) {
00415 return OMX_ErrorBadParameter;
00416 }
00417
00418 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s Getting parameter %08x\n",__func__, nParamIndex);
00419
00420
00421 switch(nParamIndex) {
00422 case OMX_IndexParamAudioInit:
00423 if ((err = checkHeader(ComponentParameterStructure, sizeof(OMX_PORT_PARAM_TYPE))) != OMX_ErrorNone) {
00424 break;
00425 }
00426 memcpy(ComponentParameterStructure, &omx_filereader_component_Private->sPortTypesParam, sizeof(OMX_PORT_PARAM_TYPE));
00427 break;
00428 case OMX_IndexParamAudioPortFormat:
00429 pAudioPortFormat = (OMX_AUDIO_PARAM_PORTFORMATTYPE*)ComponentParameterStructure;
00430 if ((err = checkHeader(ComponentParameterStructure, sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE))) != OMX_ErrorNone) {
00431 break;
00432 }
00433 if (pAudioPortFormat->nPortIndex < 1) {
00434 memcpy(pAudioPortFormat, &pPort->sAudioParam, sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE));
00435 } else {
00436 return OMX_ErrorBadPortIndex;
00437 }
00438 break;
00439 case OMX_IndexVendorFileReadInputFilename :
00440 strcpy((char *)ComponentParameterStructure, "still no filename");
00441 break;
00442 default:
00443 return omx_base_component_GetParameter(hComponent, nParamIndex, ComponentParameterStructure);
00444 }
00445 return err;
00446 }
00447
00451 OMX_ERRORTYPE omx_filereader_component_MessageHandler(OMX_COMPONENTTYPE* openmaxStandComp,internalRequestMessageType *message) {
00452 omx_filereader_component_PrivateType* omx_filereader_component_Private = (omx_filereader_component_PrivateType*)openmaxStandComp->pComponentPrivate;
00453 OMX_ERRORTYPE err = OMX_ErrorNone;
00454 OMX_STATETYPE oldState = omx_filereader_component_Private->state;
00455
00456 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s\n", __func__);
00457
00458
00459 err = omx_base_component_MessageHandler(openmaxStandComp,message);
00460
00461 if (message->messageType == OMX_CommandStateSet){
00462 if ((message->messageParam == OMX_StateExecuting) && (oldState == OMX_StateIdle)) {
00463 err = omx_filereader_component_Init(openmaxStandComp);
00464 if(err!=OMX_ErrorNone) {
00465 DEBUG(DEB_LEV_ERR, "In %s File Reader Init Failed Error=%x\n",__func__,err);
00466 return err;
00467 }
00468 } else if ((message->messageParam == OMX_StateIdle) && (oldState == OMX_StateExecuting)) {
00469 err = omx_filereader_component_Deinit(openmaxStandComp);
00470 if(err!=OMX_ErrorNone) {
00471 DEBUG(DEB_LEV_ERR, "In %s File Reader Deinit Failed Error=%x\n",__func__,err);
00472 return err;
00473 }
00474 }
00475 }
00476
00477 return err;
00478 }
00479
00481 OMX_ERRORTYPE omx_filereader_component_SetConfig(
00482 OMX_IN OMX_HANDLETYPE hComponent,
00483 OMX_IN OMX_INDEXTYPE nIndex,
00484 OMX_IN OMX_PTR pComponentConfigStructure) {
00485
00486 OMX_TIME_CONFIG_TIMESTAMPTYPE* sTimeStamp;
00487 OMX_COMPONENTTYPE *openmaxStandComp = (OMX_COMPONENTTYPE *)hComponent;
00488 omx_filereader_component_PrivateType* omx_filereader_component_Private = openmaxStandComp->pComponentPrivate;
00489 OMX_ERRORTYPE err = OMX_ErrorNone;
00490 omx_base_audio_PortType *pPort;
00491
00492 switch (nIndex) {
00493 case OMX_IndexConfigTimePosition :
00494 sTimeStamp = (OMX_TIME_CONFIG_TIMESTAMPTYPE*)pComponentConfigStructure;
00495
00496 if (sTimeStamp->nPortIndex >= (omx_filereader_component_Private->sPortTypesParam.nStartPortNumber + omx_filereader_component_Private->sPortTypesParam.nPorts)) {
00497 DEBUG(DEB_LEV_ERR, "Bad Port index %i when the component has %i ports\n", (int)sTimeStamp->nPortIndex, (int)omx_filereader_component_Private->sPortTypesParam.nPorts);
00498 return OMX_ErrorBadPortIndex;
00499 }
00500
00501 err= checkHeader(sTimeStamp , sizeof(OMX_TIME_CONFIG_TIMESTAMPTYPE));
00502 if(err != OMX_ErrorNone) {
00503 return err;
00504 }
00505
00506 if (sTimeStamp->nPortIndex < 1) {
00507 pPort= (omx_base_audio_PortType *)omx_filereader_component_Private->ports[sTimeStamp->nPortIndex];
00508 memcpy(&omx_filereader_component_Private->sTimeStamp,sTimeStamp,sizeof(OMX_TIME_CONFIG_TIMESTAMPTYPE));
00509 } else {
00510 return OMX_ErrorBadPortIndex;
00511 }
00512 return OMX_ErrorNone;
00513 default:
00514 return omx_base_component_SetConfig(hComponent, nIndex, pComponentConfigStructure);
00515 }
00516 return OMX_ErrorNone;
00517 }
00518
00520 OMX_ERRORTYPE omx_filereader_component_GetConfig(
00521 OMX_IN OMX_HANDLETYPE hComponent,
00522 OMX_IN OMX_INDEXTYPE nIndex,
00523 OMX_IN OMX_PTR pComponentConfigStructure) {
00524
00525 OMX_VENDOR_EXTRADATATYPE sExtraData;
00526 OMX_COMPONENTTYPE *openmaxStandComp = (OMX_COMPONENTTYPE *)hComponent;
00527 omx_filereader_component_PrivateType* omx_filereader_component_Private = openmaxStandComp->pComponentPrivate;
00528
00529 switch (nIndex) {
00530 case OMX_IndexVendorAudioExtraData:
00531 sExtraData.nPortIndex = 0;
00532 sExtraData.nDataSize = omx_filereader_component_Private->avformatcontext->streams[0]->codec->extradata_size;
00533 sExtraData.pData = omx_filereader_component_Private->avformatcontext->streams[0]->codec->extradata;
00534 memcpy(pComponentConfigStructure, &sExtraData, sizeof(OMX_VENDOR_EXTRADATATYPE));
00535 break;
00536 default:
00537 return omx_base_component_GetConfig(hComponent, nIndex, pComponentConfigStructure);
00538 }
00539 return OMX_ErrorNone;
00540 }
00541
00542 OMX_ERRORTYPE omx_filereader_component_GetExtensionIndex(
00543 OMX_IN OMX_HANDLETYPE hComponent,
00544 OMX_IN OMX_STRING cParameterName,
00545 OMX_OUT OMX_INDEXTYPE* pIndexType) {
00546
00547 DEBUG(DEB_LEV_FUNCTION_NAME,"In %s \n",__func__);
00548
00549 if(strcmp(cParameterName,"OMX.ST.index.param.filereader.inputfilename") == 0) {
00550 *pIndexType = OMX_IndexVendorFileReadInputFilename;
00551 } else if(strcmp(cParameterName,"OMX.ST.index.config.audioextradata") == 0) {
00552 *pIndexType = OMX_IndexVendorAudioExtraData;
00553 } else {
00554 return OMX_ErrorBadParameter;
00555 }
00556 return OMX_ErrorNone;
00557 }