00001
00039 #include "omxparsertest.h"
00040
00041 #define MPEG4_TYPE_SEL 1
00042 #define AVC_TYPE_SEL 2
00043 #define VIDEO_COMPONENT_NAME_BASE "OMX.st.video_decoder"
00044 #define AUDIO_COMPONENT_NAME_BASE "OMX.st.audio_decoder"
00045 #define VIDEO_BASE_ROLE "video_decoder.avc"
00046 #define AUDIO_BASE_ROLE "audio_decoder.mp3"
00047 #define VIDEO_DEC_MPEG4_ROLE "video_decoder.mpeg4"
00048 #define VIDEO_DEC_H264_ROLE "video_decoder.avc"
00049 #define AUDIO_DEC_MP3_ROLE "audio_decoder.mp3"
00050 #define AUDIO_DEC_AAC_ROLE "audio_decoder.aac"
00051 #define VIDEO_SINK "OMX.st.fbdev.fbdev_sink"
00052 #define COLOR_CONV "OMX.st.video_colorconv.ffmpeg"
00053 #define AUDIO_SINK "OMX.st.alsa.alsasink"
00054 #define AUDIO_EFFECT "OMX.st.volume.component"
00055 #define COMPONENT_NAME_BASE_LEN 20
00056 #define PARSER_3GP "OMX.st.parser.3gp"
00057 #define extradata_size 1024
00058 #define VIDEO_PORT_INDEX 0
00059 #define AUDIO_PORT_INDEX 1
00060
00061 OMX_COLOR_FORMATTYPE COLOR_CONV_OUT_RGB_FORMAT = OMX_COLOR_Format24bitRGB888;
00062
00063 OMX_BUFFERHEADERTYPE *outBufferParseVideo[2], *outBufferParseAudio[2];
00064 OMX_BUFFERHEADERTYPE *inBufferVideoDec[2], *outBufferVideoDec[2];
00065 OMX_BUFFERHEADERTYPE *inBufferAudioDec[2],*outBufferAudioDec[2];
00067 OMX_BUFFERHEADERTYPE *inBufferColorconv[2], *outBufferColorconv[2];
00068 OMX_BUFFERHEADERTYPE *inBufferSinkVideo[2];
00069
00070 OMX_BUFFERHEADERTYPE *inBufferVolume[2], *outBufferVolume[2];
00071 OMX_BUFFERHEADERTYPE *inBufferSinkAudio[2];
00072 int buffer_in_size = BUFFER_IN_SIZE;
00073 int buffer_out_size = BUFFER_OUT_SIZE;
00074 static OMX_BOOL bEOS=OMX_FALSE;
00075
00076 static OMX_PARAM_PORTDEFINITIONTYPE paramPortVideo, paramPortAudio;
00077 OMX_PARAM_PORTDEFINITIONTYPE decparamPortVideo;
00078 OMX_PARAM_PORTDEFINITIONTYPE decparamPortAudio;
00079
00080 OMX_CALLBACKTYPE videodeccallbacks = {
00081 .EventHandler = videodecEventHandler,
00082 .EmptyBufferDone = videodecEmptyBufferDone,
00083 .FillBufferDone = videodecFillBufferDone
00084 };
00085
00086 OMX_CALLBACKTYPE colorconv_callbacks = {
00087 .EventHandler = colorconvEventHandler,
00088 .EmptyBufferDone = colorconvEmptyBufferDone,
00089 .FillBufferDone = colorconvFillBufferDone
00090 };
00091
00092 OMX_CALLBACKTYPE fbdev_sink_callbacks = {
00093 .EventHandler = fb_sinkEventHandler,
00094 .EmptyBufferDone = fb_sinkEmptyBufferDone,
00095 .FillBufferDone = NULL
00096 };
00097
00098 OMX_CALLBACKTYPE parser3gpcallbacks = {
00099 .EventHandler = parser3gpEventHandler,
00100 .EmptyBufferDone = NULL,
00101 .FillBufferDone = parser3gpFillBufferDone
00102 };
00103
00104 OMX_CALLBACKTYPE audiodeccallbacks = {
00105 .EventHandler = audiodecEventHandler,
00106 .EmptyBufferDone = audiodecEmptyBufferDone,
00107 .FillBufferDone = audiodecFillBufferDone
00108 };
00109
00110 OMX_CALLBACKTYPE audiosinkcallbacks = {
00111 .EventHandler = audiosinkEventHandler,
00112 .EmptyBufferDone = audiosinkEmptyBufferDone,
00113 .FillBufferDone = NULL
00114 };
00115
00116 OMX_CALLBACKTYPE volumecallbacks = {
00117 .EventHandler = volumeEventHandler,
00118 .EmptyBufferDone = volumeEmptyBufferDone,
00119 .FillBufferDone = volumeFillBufferDone
00120 };
00121
00122 OMX_U32 out_width = 0, new_out_width = 0;
00123 OMX_U32 out_height = 0, new_out_height = 0;
00124
00125 FILE *fd = 0;
00126 appPrivateType* appPriv;
00127
00128 char *input_file, *output_file_audio, *output_file_video;
00129
00130 FILE *outfileAudio, *outfileVideo;
00131
00132 int flagIsAudioOutputFileExpected;
00133 int flagIsVideoOutputFileExpected;
00134 int flagDecodedOutputReceived;
00135 int flagInputReceived;
00136 int flagIsDisplayRequested;
00137 int flagSetupTunnel;
00138
00139 static void setHeader(OMX_PTR header, OMX_U32 size) {
00140 OMX_VERSIONTYPE* ver = (OMX_VERSIONTYPE*)(header + sizeof(OMX_U32));
00141 *((OMX_U32*)header) = size;
00142
00143 ver->s.nVersionMajor = VERSIONMAJOR;
00144 ver->s.nVersionMinor = VERSIONMINOR;
00145 ver->s.nRevision = VERSIONREVISION;
00146 ver->s.nStep = VERSIONSTEP;
00147 }
00148
00152 int SetPortParametersAudio() {
00153 OMX_ERRORTYPE err = OMX_ErrorNone;
00154
00155
00156
00157 paramPortAudio.nPortIndex = AUDIO_PORT_INDEX;
00158 setHeader(¶mPortAudio, sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
00159 err = OMX_GetParameter(appPriv->parser3gphandle, OMX_IndexParamPortDefinition, ¶mPortAudio);
00160 if(err != OMX_ErrorNone) {
00161 DEBUG(DEB_LEV_ERR,"\n error in parser3gp port settings get\n");
00162 exit(1);
00163 }
00164
00165
00166
00167 decparamPortAudio.nPortIndex = 0;
00168 setHeader(&decparamPortAudio, sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
00169 err = OMX_GetParameter(appPriv->audiodechandle, OMX_IndexParamPortDefinition, &decparamPortAudio);
00170 if(err != OMX_ErrorNone) {
00171 DEBUG(DEB_LEV_ERR,"\n error in audiodechandle settings get\n");
00172 exit(1);
00173 }
00174
00175 decparamPortAudio.format.audio.eEncoding=paramPortAudio.format.audio.eEncoding;
00176 err = OMX_SetParameter(appPriv->audiodechandle, OMX_IndexParamPortDefinition, &decparamPortAudio);
00177 if(err != OMX_ErrorNone) {
00178 DEBUG(DEB_LEV_ERR,"Error %08x setting audiodec input port param --- \n",err);
00179 exit(1);
00180 }
00181
00182
00183 decparamPortAudio.nPortIndex = 1;
00184 setHeader(&decparamPortAudio, sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
00185 err = OMX_GetParameter(appPriv->audiodechandle, OMX_IndexParamPortDefinition, &decparamPortAudio);
00186 if(err != OMX_ErrorNone) {
00187 DEBUG(DEB_LEV_ERR,"\n error in audiodechandle settings get\n");
00188 exit(1);
00189 }
00190
00191 decparamPortAudio.format.audio.eEncoding=paramPortAudio.format.audio.eEncoding;
00192 err = OMX_SetParameter(appPriv->audiodechandle, OMX_IndexParamPortDefinition, &decparamPortAudio);
00193 if(err != OMX_ErrorNone) {
00194 DEBUG(DEB_LEV_ERR,"Error %08x setting audiodec output port param --- \n",err);
00195 exit(1);
00196 }
00197
00198 return err;
00199 }
00200
00204 int SetPortParametersVideo() {
00205 OMX_ERRORTYPE err = OMX_ErrorNone;
00206 OMX_PARAM_PORTDEFINITIONTYPE omx_colorconvPortDefinition;
00207
00208
00209
00210 paramPortVideo.nPortIndex = VIDEO_PORT_INDEX;
00211 setHeader(¶mPortVideo, sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
00212 err = OMX_GetParameter(appPriv->parser3gphandle, OMX_IndexParamPortDefinition, ¶mPortVideo);
00213 if(err != OMX_ErrorNone) {
00214 DEBUG(DEB_LEV_ERR,"\n error in parser3gp port settings get\n");
00215 exit(1);
00216 }
00217
00218
00219
00220 decparamPortVideo.nPortIndex = 0;
00221 setHeader(&decparamPortVideo, sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
00222 err = OMX_GetParameter(appPriv->videodechandle, OMX_IndexParamPortDefinition, &decparamPortVideo);
00223 if(err != OMX_ErrorNone) {
00224 DEBUG(DEB_LEV_ERR,"\n error in videodechandle settings get\n");
00225 exit(1);
00226 }
00227
00228 decparamPortVideo.format.video.eCompressionFormat=paramPortVideo.format.video.eCompressionFormat;
00229 decparamPortVideo.format.video.nFrameWidth=paramPortVideo.format.video.nFrameWidth;
00230 decparamPortVideo.format.video.nFrameHeight=paramPortVideo.format.video.nFrameHeight;
00231 err = OMX_SetParameter(appPriv->videodechandle, OMX_IndexParamPortDefinition, &decparamPortVideo);
00232 if(err != OMX_ErrorNone) {
00233 DEBUG(DEB_LEV_ERR,"Error %08x setting videodec input port param --- \n",err);
00234 exit(1);
00235 }
00236
00237
00238 decparamPortVideo.nPortIndex = 1;
00239 setHeader(&decparamPortVideo, sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
00240 err = OMX_GetParameter(appPriv->videodechandle, OMX_IndexParamPortDefinition, &decparamPortVideo);
00241 if(err != OMX_ErrorNone) {
00242 DEBUG(DEB_LEV_ERR,"\n error in videodechandle settings get\n");
00243 exit(1);
00244 }
00245
00246 decparamPortVideo.format.video.eCompressionFormat=paramPortVideo.format.video.eCompressionFormat;
00247 decparamPortVideo.format.video.nFrameWidth=paramPortVideo.format.video.nFrameWidth;
00248 decparamPortVideo.format.video.nFrameHeight=paramPortVideo.format.video.nFrameHeight;
00249 err = OMX_SetParameter(appPriv->videodechandle, OMX_IndexParamPortDefinition, &decparamPortVideo);
00250 if(err != OMX_ErrorNone) {
00251 DEBUG(DEB_LEV_ERR,"Error %08x setting videodec output port param --- \n",err);
00252 exit(1);
00253 }
00254
00255 new_out_width = paramPortVideo.format.video.nFrameWidth;
00256 new_out_height = paramPortVideo.format.video.nFrameHeight;
00257 DEBUG(DEB_LEV_SIMPLE_SEQ, "input picture width : %d height : %d \n", (int)new_out_width, (int)new_out_height);
00258
00262 if(flagIsDisplayRequested == 1) {
00266 omx_colorconvPortDefinition.nPortIndex = 0;
00267 setHeader(&omx_colorconvPortDefinition, sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
00268 err = OMX_GetParameter(appPriv->colorconv_handle, OMX_IndexParamPortDefinition, &omx_colorconvPortDefinition);
00269 omx_colorconvPortDefinition.format.video.nFrameWidth = new_out_width;
00270 omx_colorconvPortDefinition.format.video.nFrameHeight = new_out_height;
00271 err = OMX_SetParameter(appPriv->colorconv_handle, OMX_IndexParamPortDefinition, &omx_colorconvPortDefinition);
00272 if(err!=OMX_ErrorNone) {
00273 DEBUG(DEB_LEV_ERR, "In %s Setting Input Port Definition Error=%x\n",__func__,err);
00274 return err;
00275 }
00279 omx_colorconvPortDefinition.nPortIndex = 1;
00280 err = OMX_GetParameter(appPriv->colorconv_handle, OMX_IndexParamPortDefinition, &omx_colorconvPortDefinition);
00281 omx_colorconvPortDefinition.format.video.nFrameWidth = new_out_width;
00282 omx_colorconvPortDefinition.format.video.nFrameHeight = new_out_height;
00283 err = OMX_SetParameter(appPriv->colorconv_handle, OMX_IndexParamPortDefinition, &omx_colorconvPortDefinition);
00284 if(err!=OMX_ErrorNone) {
00285 DEBUG(DEB_LEV_ERR, "In %s Setting Output Port Definition Error=%x\n",__func__,err);
00286 return err;
00287 }
00291 paramPortVideo.nPortIndex = 1;
00292 setHeader(¶mPortVideo, sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
00293 err = OMX_GetParameter(appPriv->videodechandle, OMX_IndexParamPortDefinition, ¶mPortVideo);
00294 omx_colorconvPortDefinition.nPortIndex = 0;
00295 setHeader(&omx_colorconvPortDefinition, sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
00296 err = OMX_GetParameter(appPriv->colorconv_handle, OMX_IndexParamPortDefinition, &omx_colorconvPortDefinition);
00297 omx_colorconvPortDefinition.format.video.eColorFormat = paramPortVideo.format.video.eColorFormat;
00298 err = OMX_SetParameter(appPriv->colorconv_handle, OMX_IndexParamPortDefinition, &omx_colorconvPortDefinition);
00299 if(err==OMX_ErrorBadParameter) {
00300 DEBUG(DEB_LEV_ERR,"\n bad parameter of input color format - exiting\n");
00301 exit(1);
00302 }
00304 omx_colorconvPortDefinition.nPortIndex = 1;
00305 err = OMX_GetParameter(appPriv->colorconv_handle, OMX_IndexParamPortDefinition, &omx_colorconvPortDefinition);
00306 omx_colorconvPortDefinition.format.video.eColorFormat = COLOR_CONV_OUT_RGB_FORMAT;
00307 err = OMX_SetParameter(appPriv->colorconv_handle, OMX_IndexParamPortDefinition, &omx_colorconvPortDefinition);
00308 if(err==OMX_ErrorBadParameter) {
00309 DEBUG(DEB_LEV_ERR,"\n bad parameter of output color format setting- exiting\n");
00310 exit(1);
00311 }
00315 omx_colorconvPortDefinition.nPortIndex = 1;
00316 err = OMX_GetParameter(appPriv->colorconv_handle, OMX_IndexParamPortDefinition, &omx_colorconvPortDefinition);
00317 omx_colorconvPortDefinition.nPortIndex = 0;
00318 err = OMX_SetParameter(appPriv->videosinkhandle, OMX_IndexParamPortDefinition, &omx_colorconvPortDefinition);
00319 if(err != OMX_ErrorNone) {
00320 DEBUG(DEB_LEV_ERR,"\n error in setting the inputport param of the sink component- exiting\n");
00321 exit(1);
00322 }
00323 }
00324 return err;
00325 }
00326
00327 void display_help() {
00328 printf("\n");
00329 printf("Usage: omxparsertest -vo outfileVideo.yuv -ap outfileAudio.pcm [-t] [-h] [-d] input_filename\n");
00330 printf("\n");
00331 printf(" -ao outfileAudio.pcm \n");
00332 printf(" -vo outfileVideo.yuv \n");
00333 printf(" If this option is specified, the output is written to user specified outfiles\n");
00334 printf(" N.B : This option is not needed if you use the sink component\n");
00335 printf("\n");
00336 printf(" -h: Displays this help\n");
00337 printf("\n");
00338 printf(" -d: Uses the video and alsa sink component to display the video and play the audio output \n");
00339 printf(" input_filename is the user specified input file name\n");
00340 printf("\n");
00341 printf(" -t: Tunneling option - if this option is selected then by default the color converter, \n");
00342 printf(" video sink, volume control and alsa sink components are selected even if these options \n");
00343 printf(" are not specified - the components are tunneled between themselves\n");
00344 printf("\n");
00345 exit(1);
00346 }
00347
00348 OMX_ERRORTYPE test_OMX_ComponentNameEnum() {
00349 char * name;
00350 int index;
00351
00352 OMX_ERRORTYPE err = OMX_ErrorNone;
00353
00354 DEBUG(DEFAULT_MESSAGES, "GENERAL TEST %s\n",__func__);
00355 name = malloc(OMX_MAX_STRINGNAME_SIZE);
00356 index = 0;
00357 while(1) {
00358 err = OMX_ComponentNameEnum (name, OMX_MAX_STRINGNAME_SIZE, index);
00359 if ((name != NULL) && (err == OMX_ErrorNone)) {
00360 DEBUG(DEFAULT_MESSAGES, "component %i is %s\n",index, name);
00361 } else break;
00362 if (err != OMX_ErrorNone) break;
00363 index++;
00364 }
00365 free(name);
00366 name = NULL;
00367 DEBUG(DEFAULT_MESSAGES, "GENERAL TEST %s result %i\n",__func__, err);
00368 return err;
00369 }
00370
00371 OMX_ERRORTYPE test_OMX_RoleEnum(OMX_STRING component_name) {
00372 OMX_U32 no_of_roles;
00373 OMX_U8 **string_of_roles;
00374 OMX_ERRORTYPE err = OMX_ErrorNone;
00375 int index;
00376
00377 DEBUG(DEFAULT_MESSAGES, "GENERAL TEST %s\n",__func__);
00378 DEBUG(DEB_LEV_SIMPLE_SEQ, "Getting roles of %s. Passing Null first...\n", component_name);
00379 err = OMX_GetRolesOfComponent(component_name, &no_of_roles, NULL);
00380 if (err != OMX_ErrorNone) {
00381 DEBUG(DEB_LEV_ERR, "Not able to retrieve the number of roles of the given component\n");
00382 DEBUG(DEFAULT_MESSAGES, "GENERAL TEST %s result %i\n",__func__, err);
00383 return err;
00384 }
00385 DEBUG(DEFAULT_MESSAGES, "The number of roles for the component %s is: %i\n", component_name, (int)no_of_roles);
00386
00387 if(no_of_roles == 0) {
00388 DEBUG(DEB_LEV_ERR, "The Number or roles is 0.\nThe component selected is not correct for the purpose of this test.\nExiting...\n");
00389 err = OMX_ErrorInvalidComponentName;
00390 } else {
00391 string_of_roles = (OMX_U8**)malloc(no_of_roles * sizeof(OMX_STRING));
00392 for (index = 0; index<no_of_roles; index++) {
00393 *(string_of_roles + index) = (OMX_U8 *)malloc(no_of_roles*OMX_MAX_STRINGNAME_SIZE);
00394 }
00395 DEBUG(DEB_LEV_SIMPLE_SEQ, "...then buffers\n");
00396
00397 err = OMX_GetRolesOfComponent(component_name, &no_of_roles, string_of_roles);
00398 if (err != OMX_ErrorNone) {
00399 DEBUG(DEB_LEV_ERR, "Not able to retrieve the roles of the given component\n");
00400 } else if(string_of_roles != NULL) {
00401 for (index = 0; index < no_of_roles; index++) {
00402 DEBUG(DEFAULT_MESSAGES, "The role %i for the component: %s \n", (index + 1), *(string_of_roles+index));
00403 }
00404 } else {
00405 DEBUG(DEB_LEV_ERR, "role string is NULL!!! Exiting...\n");
00406 err = OMX_ErrorInvalidComponentName;
00407 }
00408 for (index = 0; index<no_of_roles; index++) {
00409 free(*(string_of_roles + index));
00410 }
00411 free(string_of_roles);
00412 }
00413 DEBUG(DEFAULT_MESSAGES, "GENERAL TEST %s result %i\n",__func__, err);
00414 return err;
00415 }
00416
00417 OMX_ERRORTYPE test_OMX_ComponentEnumByRole(OMX_STRING role_name) {
00418 OMX_U32 no_of_comp_per_role;
00419 OMX_U8 **string_of_comp_per_role;
00420 OMX_ERRORTYPE err;
00421 int index;
00422
00423 DEBUG(DEFAULT_MESSAGES, "GENERAL TEST %s\n",__func__);
00424
00425 DEBUG(DEFAULT_MESSAGES, "Getting number of components per role for %s\n", role_name);
00426
00427 err = OMX_GetComponentsOfRole(role_name, &no_of_comp_per_role, NULL);
00428 if (err != OMX_ErrorNone) {
00429 DEBUG(DEB_LEV_ERR, "Not able to retrieve the number of components of a given role\n");
00430 DEBUG(DEFAULT_MESSAGES, "GENERAL TEST %s result %i\n",__func__, err);
00431 return err;
00432 }
00433 DEBUG(DEFAULT_MESSAGES, "Number of components per role for %s is %i\n", role_name, (int)no_of_comp_per_role);
00434
00435 string_of_comp_per_role = (OMX_U8**)malloc(no_of_comp_per_role * sizeof(OMX_STRING));
00436 for (index = 0; index<no_of_comp_per_role; index++) {
00437 string_of_comp_per_role[index] = malloc(OMX_MAX_STRINGNAME_SIZE);
00438 }
00439
00440 err = OMX_GetComponentsOfRole(role_name, &no_of_comp_per_role, string_of_comp_per_role);
00441 if (err != OMX_ErrorNone) {
00442 DEBUG(DEB_LEV_ERR, "Not able to retrieve the components of a given role\n");
00443 DEBUG(DEFAULT_MESSAGES, "GENERAL TEST %s result %i\n",__func__, err);
00444 for (index = 0; index<no_of_comp_per_role; index++) {
00445 if(string_of_comp_per_role[index]) {
00446 free(string_of_comp_per_role[index]);
00447 string_of_comp_per_role[index] = NULL;
00448 }
00449 }
00450
00451 if(string_of_comp_per_role) {
00452 free(string_of_comp_per_role);
00453 string_of_comp_per_role = NULL;
00454 }
00455 return err;
00456 }
00457
00458 DEBUG(DEFAULT_MESSAGES, " The components are:\n");
00459 for (index = 0; index < no_of_comp_per_role; index++) {
00460 DEBUG(DEFAULT_MESSAGES, "%s\n", string_of_comp_per_role[index]);
00461 }
00462 for (index = 0; index<no_of_comp_per_role; index++) {
00463 if(string_of_comp_per_role[index]) {
00464 free(string_of_comp_per_role[index]);
00465 string_of_comp_per_role[index] = NULL;
00466 }
00467 }
00468
00469 if(string_of_comp_per_role) {
00470 free(string_of_comp_per_role);
00471 string_of_comp_per_role = NULL;
00472 }
00473 DEBUG(DEFAULT_MESSAGES, "GENERAL TEST %s result OMX_ErrorNone\n",__func__);
00474 return OMX_ErrorNone;
00475 }
00476
00477 OMX_ERRORTYPE test_OpenClose(OMX_STRING component_name) {
00478 OMX_ERRORTYPE err = OMX_ErrorNone;
00479
00480 DEBUG(DEFAULT_MESSAGES, "GENERAL TEST %s\n",__func__);
00481 if(component_name==AUDIO_COMPONENT_NAME_BASE){
00482 err = OMX_GetHandle(&appPriv->audiodechandle, component_name, NULL, &audiodeccallbacks);
00483 if(err != OMX_ErrorNone) {
00484 DEBUG(DEB_LEV_ERR, "No component found\n");
00485 } else {
00486 err = OMX_FreeHandle(appPriv->audiodechandle);
00487 if(err != OMX_ErrorNone) {
00488 DEBUG(DEB_LEV_ERR, "In %s err %08x in Free Handle\n",__func__,err);
00489 }
00490 }
00491 } else if(component_name==VIDEO_COMPONENT_NAME_BASE){
00492 err = OMX_GetHandle(&appPriv->videodechandle, component_name, NULL , &videodeccallbacks);
00493 if(err != OMX_ErrorNone) {
00494 DEBUG(DEB_LEV_ERR, "No component found\n");
00495 } else {
00496 err = OMX_FreeHandle(appPriv->videodechandle);
00497 if(err != OMX_ErrorNone) {
00498 DEBUG(DEB_LEV_ERR, "In %s err %08x in Free Handle\n",__func__,err);
00499 }
00500 }
00501 }
00502
00503 DEBUG(DEFAULT_MESSAGES, "GENERAL TEST %s result %i\n",__func__, err);
00504 return err;
00505 }
00506
00507 int main(int argc, char** argv) {
00508 int argn_dec;
00509 char *temp = NULL;
00510 OMX_ERRORTYPE err;
00511 OMX_INDEXTYPE eIndexParamFilename;
00512 OMX_PARAM_COMPONENTROLETYPE sComponentRole;
00513 int gain=-1;
00514 OMX_AUDIO_CONFIG_VOLUMETYPE sVolume;
00515
00516
00517 if(argc < 2){
00518 display_help();
00519 } else {
00520 flagIsVideoOutputFileExpected = 0;
00521 flagIsAudioOutputFileExpected = 0;
00522 flagDecodedOutputReceived = 0;
00523 flagInputReceived = 0;
00524 flagSetupTunnel = 0;
00525 flagIsDisplayRequested = 0;
00526
00527 argn_dec = 1;
00528 while (argn_dec < argc) {
00529 if (*(argv[argn_dec]) == '-') {
00530 if (flagIsVideoOutputFileExpected || flagIsAudioOutputFileExpected) {
00531 display_help();
00532 }
00533 switch (*(argv[argn_dec] + 1)) {
00534 case 'h' :
00535 display_help();
00536 break;
00537 case 't' :
00538 flagSetupTunnel = 1;
00539 flagIsDisplayRequested = 1;
00540 break;
00541 case 'd':
00542 flagIsDisplayRequested = 1;
00543 break;
00544 case 'a' :
00545 if(*(argv[argn_dec] + 2)=='o'){
00546 flagIsAudioOutputFileExpected = 1;
00547 }
00548 break;
00549 case 'v' :
00550 if(*(argv[argn_dec] + 2)=='o'){
00551 flagIsVideoOutputFileExpected = 1;
00552 }
00553 break;
00554 default:
00555 display_help();
00556 }
00557 } else {
00558 if (flagIsVideoOutputFileExpected) {
00559 if(strstr(argv[argn_dec], ".yuv") != NULL) {
00560 output_file_video = malloc(strlen(argv[argn_dec]) * sizeof(char) + 1);
00561 strcpy(output_file_video,argv[argn_dec]);
00562 }
00563 flagIsVideoOutputFileExpected = 0;
00564 flagDecodedOutputReceived = 1;
00565 } else if (flagIsAudioOutputFileExpected){
00566 if (strstr(argv[argn_dec], ".pcm") != NULL) {
00567 output_file_audio = malloc(strlen(argv[argn_dec]) * sizeof(char) + 1);
00568 strcpy(output_file_audio,argv[argn_dec]);
00569 }
00570 flagIsAudioOutputFileExpected = 0;
00571 flagDecodedOutputReceived = 1;
00572 } else {
00573 input_file = malloc(strlen(argv[argn_dec]) * sizeof(char) + 1);
00574 strcpy(input_file,argv[argn_dec]);
00575 flagInputReceived = 1;
00576 }
00577 }
00578 argn_dec++;
00579 }
00580
00582 if ((!flagInputReceived) || ((strstr(input_file, ".3gp") == NULL))) {
00583 DEBUG(DEB_LEV_ERR, "\n you must specify appropriate input file of .3gp format\n");
00584 display_help();
00585 }
00586
00588
00589 if(flagIsAudioOutputFileExpected || flagIsVideoOutputFileExpected) {
00590 DEBUG(DEB_LEV_ERR, "\n you must specify appropriate output audio and video file names \n");
00591 display_help();
00592 }
00593
00594 if(flagDecodedOutputReceived) {
00595 if(flagIsDisplayRequested || flagSetupTunnel) {
00596 flagDecodedOutputReceived = 0;
00597 DEBUG(DEB_LEV_ERR, "Display Requested or Components are tunneled. No FILE Output will be produced\n");
00598 }
00599 }
00600
00601 DEBUG(DEFAULT_MESSAGES, "Options selected:\n");
00602 if(flagDecodedOutputReceived) {
00603 DEBUG(DEFAULT_MESSAGES, "Decode file %s to produce audio file %s and video file %s\n", input_file, output_file_audio, output_file_video);
00604 } else {
00605 DEBUG(DEFAULT_MESSAGES, "As audio and video sink components are chose, no output file is generated even if specified\n");
00606 }
00607 if(flagIsDisplayRequested) {
00608 DEBUG(DEFAULT_MESSAGES, "See the movie being played....\n");
00609 }
00610 if(flagSetupTunnel) {
00611 DEBUG(DEFAULT_MESSAGES,"The components are tunneled between themselves\n");
00612 }
00613 }
00614
00615 if(!flagIsDisplayRequested) {
00616 if(output_file_audio==NULL || output_file_video==NULL) {
00617 DEBUG(DEB_LEV_ERR, "\n Error in specifying audio/video output filename ....,\n");
00618 if(output_file_audio==NULL) DEBUG(DEB_LEV_ERR, " For audio output specify a filename with .pcm extension\n");
00619 if(output_file_video==NULL) DEBUG(DEB_LEV_ERR, " For video output specify a filename with .yuv extension\n");
00620 display_help();
00621 exit(1);
00622 }
00623 outfileAudio = fopen(output_file_audio, "wb");
00624 if(outfileAudio == NULL) {
00625 DEBUG(DEB_LEV_ERR, "Error in opening output file %s\n", output_file_audio);
00626 exit(1);
00627 }
00628 outfileVideo = fopen(output_file_video, "wb");
00629 if(outfileVideo == NULL) {
00630 DEBUG(DEB_LEV_ERR, "Error in opening output file %s\n", output_file_video);
00631 exit(1);
00632 }
00633 }
00634
00636 out_width = 640;
00637 out_height = 480;
00638
00640 appPriv = malloc(sizeof(appPrivateType));
00641 appPriv->parser3gpEventSem = malloc(sizeof(tsem_t));
00642 appPriv->videoDecoderEventSem = malloc(sizeof(tsem_t));
00643 appPriv->audioDecoderEventSem = malloc(sizeof(tsem_t));
00644 if(flagIsDisplayRequested == 1) {
00645 appPriv->fbdevSinkEventSem = malloc(sizeof(tsem_t));
00646 appPriv->colorconvEventSem = malloc(sizeof(tsem_t));
00647 appPriv->audioSinkEventSem = malloc(sizeof(tsem_t));
00648 appPriv->volumeEventSem = malloc(sizeof(tsem_t));
00649 }
00650 appPriv->eofSem = malloc(sizeof(tsem_t));
00651
00652 tsem_init(appPriv->parser3gpEventSem, 0);
00653 tsem_init(appPriv->videoDecoderEventSem, 0);
00654 tsem_init(appPriv->audioDecoderEventSem, 0);
00655 if(flagIsDisplayRequested == 1) {
00656 tsem_init(appPriv->fbdevSinkEventSem, 0);
00657 tsem_init(appPriv->colorconvEventSem, 0);
00658 tsem_init(appPriv->audioSinkEventSem, 0);
00659 tsem_init(appPriv->volumeEventSem, 0);
00660 }
00661 tsem_init(appPriv->eofSem, 0);
00662
00664 err = OMX_Init();
00665 if (err != OMX_ErrorNone) {
00666 DEBUG(DEB_LEV_ERR, "The OpenMAX core can not be initialized. Exiting...\n");
00667 exit(1);
00668 }else {
00669 DEBUG(DEB_LEV_SIMPLE_SEQ, "Omx core is initialized \n");
00670 }
00671
00672 DEBUG(DEFAULT_MESSAGES, "------------------------------------\n");
00673 test_OMX_ComponentNameEnum();
00674 DEBUG(DEFAULT_MESSAGES, "------------------------------------\n");
00675 test_OMX_RoleEnum(VIDEO_COMPONENT_NAME_BASE);
00676 DEBUG(DEFAULT_MESSAGES, "------------------------------------\n");
00677 test_OMX_ComponentEnumByRole(VIDEO_BASE_ROLE);
00678 DEBUG(DEFAULT_MESSAGES, "------------------------------------\n");
00679 test_OMX_RoleEnum(AUDIO_COMPONENT_NAME_BASE);
00680 DEBUG(DEFAULT_MESSAGES, "------------------------------------\n");
00681 test_OMX_ComponentEnumByRole(AUDIO_BASE_ROLE);
00682 DEBUG(DEFAULT_MESSAGES, "------------------------------------\n");
00683 test_OpenClose(VIDEO_COMPONENT_NAME_BASE);
00684 DEBUG(DEFAULT_MESSAGES, "------------------------------------\n");
00685 test_OpenClose(AUDIO_COMPONENT_NAME_BASE);
00686 DEBUG(DEFAULT_MESSAGES, "------------------------------------\n");
00687
00688 DEBUG(DEFAULT_MESSAGES, "The component selected for video decoding is %s\n Role is decided by the decoder\n", VIDEO_COMPONENT_NAME_BASE);
00689 DEBUG(DEFAULT_MESSAGES, "The component selected for audio decoding is %s\n Role is decided by the decoder\n", AUDIO_COMPONENT_NAME_BASE);
00690
00691 DEBUG(DEB_LEV_SIMPLE_SEQ, "Using Parser3gp \n");
00693 err = OMX_GetHandle(&appPriv->parser3gphandle, PARSER_3GP, NULL , &parser3gpcallbacks);
00694 if(err != OMX_ErrorNone) {
00695 DEBUG(DEB_LEV_ERR, "Parser3gp Component Not Found\n");
00696 exit(1);
00697 } else {
00698 DEBUG(DEFAULT_MESSAGES, "Parser3gp Component Found\n");
00699 }
00700
00701
00703 err = OMX_GetHandle(&appPriv->videodechandle, VIDEO_COMPONENT_NAME_BASE, NULL, &videodeccallbacks);
00704 if(err != OMX_ErrorNone){
00705 DEBUG(DEB_LEV_ERR, "No video decoder component found. Exiting...\n");
00706 exit(1);
00707 } else {
00708 DEBUG(DEFAULT_MESSAGES, "The component for video decoding is %s\n", VIDEO_COMPONENT_NAME_BASE);
00709 }
00710
00712 DEBUG(DEB_LEV_SIMPLE_SEQ, "Getting Audio %s Decoder Handle\n",AUDIO_COMPONENT_NAME_BASE);
00713 err = OMX_GetHandle(&appPriv->audiodechandle, AUDIO_COMPONENT_NAME_BASE, NULL, &audiodeccallbacks);
00714 if(err != OMX_ErrorNone) {
00715 DEBUG(DEB_LEV_ERR, "Audio Decoder Component Not Found\n");
00716 exit(1);
00717 }
00718 DEBUG(DEFAULT_MESSAGES, "The Component for audio deoding is %s \n", AUDIO_COMPONENT_NAME_BASE);
00719
00721 if(flagIsDisplayRequested) {
00723 err = OMX_GetHandle(&appPriv->colorconv_handle, COLOR_CONV, NULL, &colorconv_callbacks);
00724 if(err != OMX_ErrorNone){
00725 DEBUG(DEB_LEV_ERR, "No color converter component found. Exiting...\n");
00726 exit(1);
00727 } else {
00728 DEBUG(DEFAULT_MESSAGES, "Found The component for color converter \n");
00729 }
00730
00732 err = OMX_GetHandle(&appPriv->videosinkhandle, VIDEO_SINK, NULL, &fbdev_sink_callbacks);
00733 if(err != OMX_ErrorNone){
00734 DEBUG(DEB_LEV_ERR, "No video sink component component found. Exiting...\n");
00735 exit(1);
00736 } else {
00737 DEBUG(DEFAULT_MESSAGES, "Found The video sink component for color converter \n");
00738 }
00739
00741 err = OMX_GetHandle(&appPriv->audiosinkhandle, AUDIO_SINK, NULL , &audiosinkcallbacks);
00742 if(err != OMX_ErrorNone){
00743 DEBUG(DEB_LEV_ERR, "No audio sink found. Exiting...\n");
00744 exit(1);
00745 } else {
00746 DEBUG(DEFAULT_MESSAGES, "Found The alsa sink component for audio \n");
00747 }
00748
00750 DEBUG(DEFAULT_MESSAGES, "Getting Handle for Component %s\n", AUDIO_EFFECT);
00751 err = OMX_GetHandle(&appPriv->volumehandle, AUDIO_EFFECT, NULL , &volumecallbacks);
00752 if(err != OMX_ErrorNone){
00753 DEBUG(DEB_LEV_ERR, "No volume component found. Exiting...\n");
00754 exit(1);
00755 } else {
00756 DEBUG(DEFAULT_MESSAGES, "Found The volume component for audio \n");
00757 }
00758
00759 if((gain >= 0) && (gain <100)) {
00760 err = OMX_GetConfig(appPriv->volumehandle, OMX_IndexConfigAudioVolume, &sVolume);
00761 if(err!=OMX_ErrorNone) {
00762 DEBUG(DEB_LEV_ERR,"Error %08x In OMX_GetConfig 0 \n",err);
00763 }
00764 sVolume.sVolume.nValue = gain;
00765 DEBUG(DEFAULT_MESSAGES, "Setting Gain %d \n", gain);
00766 err = OMX_SetConfig(appPriv->volumehandle, OMX_IndexConfigAudioVolume, &sVolume);
00767 if(err!=OMX_ErrorNone) {
00768 DEBUG(DEB_LEV_ERR,"Error %08x In OMX_SetConfig 0 \n",err);
00769 }
00770 }
00771 }
00772
00773
00775 err = OMX_GetExtensionIndex(appPriv->parser3gphandle,"OMX.ST.index.param.parser3gp.inputfilename",&eIndexParamFilename);
00776 if(err != OMX_ErrorNone) {
00777 DEBUG(DEB_LEV_ERR,"\n error in get extension index\n");
00778 exit(1);
00779 } else {
00780 DEBUG(DEB_LEV_SIMPLE_SEQ,"FileName Param index : %x \n",eIndexParamFilename);
00781 temp = (char *)malloc(25);
00782 OMX_GetParameter(appPriv->parser3gphandle,eIndexParamFilename,temp);
00783 err = OMX_SetParameter(appPriv->parser3gphandle,eIndexParamFilename,input_file);
00784 if(err != OMX_ErrorNone) {
00785 DEBUG(DEB_LEV_ERR,"\n error in input format - exiting\n");
00786 exit(1);
00787 }
00788 }
00789
00790 if (flagSetupTunnel) {
00791 DEBUG(DEB_LEV_SIMPLE_SEQ, "Setting up Tunnel\n");
00792 err = OMX_SetupTunnel(appPriv->parser3gphandle, VIDEO_PORT_INDEX, appPriv->videodechandle, 0);
00793 if(err != OMX_ErrorNone) {
00794 DEBUG(DEB_LEV_ERR, "Set up Tunnel parser3gp to video decoder Failed\n");
00795 exit(1);
00796 }
00797 err = OMX_SetupTunnel(appPriv->parser3gphandle, AUDIO_PORT_INDEX, appPriv->audiodechandle, 0);
00798 if(err != OMX_ErrorNone) {
00799 DEBUG(DEB_LEV_ERR, "Set up Tunnel parser3gp to audio decoder Failed\n");
00800 exit(1);
00801 }
00802 err = OMX_SetupTunnel(appPriv->videodechandle, 1, appPriv->colorconv_handle, 0);
00803 if(err != OMX_ErrorNone) {
00804 DEBUG(DEB_LEV_ERR, "Set up Tunnel video decoder to color converter Failed\n");
00805 exit(1);
00806 }
00807 err = OMX_SetupTunnel(appPriv->colorconv_handle, 1, appPriv->videosinkhandle, 0);
00808 if(err != OMX_ErrorNone) {
00809 DEBUG(DEB_LEV_ERR, "Set up Tunnel colort converter to video sink Failed\n");
00810 exit(1);
00811 }
00812 err = OMX_SetupTunnel(appPriv->audiodechandle, 1, appPriv->volumehandle, 0);
00813 if(err != OMX_ErrorNone) {
00814 DEBUG(DEB_LEV_ERR, "Set up Tunnel Failed\n");
00815 exit(1);
00816 }
00817 err = OMX_SetupTunnel(appPriv->volumehandle, 1, appPriv->audiosinkhandle, 0);
00818 if(err != OMX_ErrorNone) {
00819 DEBUG(DEB_LEV_ERR, "Set up Tunnel Failed\n");
00820 exit(1);
00821 }
00822
00823 DEBUG(DEB_LEV_SIMPLE_SEQ, "Set up Tunnel Completed\n");
00824
00825
00826
00827
00828 OMX_PARAM_BUFFERSUPPLIERTYPE sBufferSupplier;
00829 sBufferSupplier.nPortIndex = 0;
00830 sBufferSupplier.eBufferSupplier = OMX_BufferSupplyInput;
00831 setHeader(&sBufferSupplier, sizeof(OMX_PARAM_BUFFERSUPPLIERTYPE));
00832
00833 err = OMX_SetParameter(appPriv->videodechandle, OMX_IndexParamCompBufferSupplier, &sBufferSupplier);
00834 if(err!=OMX_ErrorNone) {
00835 DEBUG(DEB_LEV_ERR, "In %s Setting Video Decoder Input Port Buffer Supplier Error=%x\n",__func__,err);
00836 return err;
00837 }
00838 err = OMX_SetParameter(appPriv->audiodechandle, OMX_IndexParamCompBufferSupplier, &sBufferSupplier);
00839 if(err!=OMX_ErrorNone) {
00840 DEBUG(DEB_LEV_ERR, "In %s Setting Audio Decoder Input Port Buffer Supplier Error=%x\n",__func__,err);
00841 return err;
00842 }
00843 }
00844
00846 OMX_SendCommand(appPriv->parser3gphandle, OMX_CommandStateSet, OMX_StateIdle, NULL);
00847
00848 if (flagSetupTunnel) {
00849 DEBUG(DEB_LEV_SIMPLE_SEQ, "Send Command Idle to Video Dec\n");
00850
00851 err = OMX_SendCommand(appPriv->videodechandle, OMX_CommandStateSet, OMX_StateIdle, NULL);
00852 err = OMX_SendCommand(appPriv->audiodechandle, OMX_CommandStateSet, OMX_StateIdle, NULL);
00853 if (flagIsDisplayRequested) {
00854 DEBUG(DEB_LEV_SIMPLE_SEQ, "Send Command Idle to Audio and Video Sink\n");
00855 err = OMX_SendCommand(appPriv->colorconv_handle, OMX_CommandStateSet, OMX_StateIdle, NULL);
00856 err = OMX_SendCommand(appPriv->videosinkhandle, OMX_CommandStateSet, OMX_StateIdle, NULL);
00857 err = OMX_SendCommand(appPriv->volumehandle, OMX_CommandStateSet, OMX_StateIdle, NULL);
00858 err = OMX_SendCommand(appPriv->audiosinkhandle, OMX_CommandStateSet, OMX_StateIdle, NULL);
00859 }
00860 }
00861
00862
00863
00864 if (!flagSetupTunnel) {
00865 outBufferParseVideo[0] = outBufferParseVideo[1] = NULL;
00866 outBufferParseAudio[0] = outBufferParseAudio[1] = NULL;
00868 err = OMX_AllocateBuffer(appPriv->parser3gphandle, &outBufferParseVideo[0], VIDEO_PORT_INDEX, NULL, buffer_out_size);
00869 if(err != OMX_ErrorNone) {
00870 DEBUG(DEB_LEV_ERR, "Unable to allocate Video buffer 1 in parser3gp \n");
00871 exit(1);
00872 }
00873 err = OMX_AllocateBuffer(appPriv->parser3gphandle, &outBufferParseVideo[1], VIDEO_PORT_INDEX, NULL, buffer_out_size);
00874 if(err != OMX_ErrorNone) {
00875 DEBUG(DEB_LEV_ERR, "Unable to allocate Video buffer 2 in parser3gp \n");
00876 exit(1);
00877 }
00878
00880 err = OMX_AllocateBuffer(appPriv->parser3gphandle, &outBufferParseAudio[0], AUDIO_PORT_INDEX, NULL, buffer_out_size);
00881 if(err != OMX_ErrorNone) {
00882 DEBUG(DEB_LEV_ERR, "Unable to allocate Audio buffer 1 in parser3gp \n");
00883 exit(1);
00884 }
00885 err = OMX_AllocateBuffer(appPriv->parser3gphandle, &outBufferParseAudio[1], AUDIO_PORT_INDEX, NULL, buffer_out_size);
00886 if(err != OMX_ErrorNone) {
00887 DEBUG(DEB_LEV_ERR, "Unable to allocate Audio buffer 2 in parser3gp \n");
00888 exit(1);
00889 }
00890 }
00891
00892
00893 tsem_down(appPriv->parser3gpEventSem);
00894 DEBUG(DEFAULT_MESSAGES,"Parser3gp in idle state \n");
00895
00896
00897 if (flagSetupTunnel) {
00898 tsem_down(appPriv->videoDecoderEventSem);
00899 tsem_down(appPriv->audioDecoderEventSem);
00900 if (flagIsDisplayRequested) {
00901 tsem_down(appPriv->colorconvEventSem);
00902 tsem_down(appPriv->fbdevSinkEventSem);
00903 tsem_down(appPriv->volumeEventSem);
00904 tsem_down(appPriv->audioSinkEventSem);
00905 }
00906 DEBUG(DEFAULT_MESSAGES,"All tunneled components in idle state \n");
00907 }
00908
00909 err = OMX_SendCommand(appPriv->parser3gphandle, OMX_CommandStateSet, OMX_StateExecuting, NULL);
00910 if(err != OMX_ErrorNone) {
00911 DEBUG(DEB_LEV_ERR,"Parser 3gp state executing failed\n");
00912 exit(1);
00913 }
00914
00915 tsem_down(appPriv->parser3gpEventSem);
00916 DEBUG(DEFAULT_MESSAGES,"Parser3gp in executing state \n");
00917
00918
00919
00920 tsem_down(appPriv->parser3gpEventSem);
00921 tsem_down(appPriv->parser3gpEventSem);
00922 DEBUG(DEFAULT_MESSAGES,"Parser3gp Port Settings Changed event \n");
00923
00924
00925
00926 if(flagSetupTunnel){
00927 tsem_down(appPriv->parser3gpEventSem);
00928 tsem_down(appPriv->parser3gpEventSem);
00929 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s Parser 3gp Component Ports Disabled\n", __func__);
00930 tsem_down(appPriv->videoDecoderEventSem);
00931 tsem_down(appPriv->videoDecoderEventSem);
00932 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s Video decoder Component Port Disabled\n", __func__);
00933 tsem_down(appPriv->audioDecoderEventSem);
00934 tsem_down(appPriv->audioDecoderEventSem);
00935 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s Audio decoder Component Port Disabled\n", __func__);
00936 if(flagIsDisplayRequested){
00937 tsem_down(appPriv->colorconvEventSem);
00938 tsem_down(appPriv->colorconvEventSem);
00939 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s Color Converter Component Port Disabled\n", __func__);
00940 tsem_down(appPriv->fbdevSinkEventSem);
00941 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s Video Sink Port Disabled\n", __func__);
00942 tsem_down(appPriv->volumeEventSem);
00943 tsem_down(appPriv->volumeEventSem);
00944 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s Volume Component Port Disabled\n", __func__);
00945 tsem_down(appPriv->audioSinkEventSem);
00946 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s Audio Sink Port Disabled\n", __func__);
00947 }
00948 }
00949
00950
00951 SetPortParametersVideo();
00952 setHeader(&sComponentRole, sizeof(OMX_PARAM_COMPONENTROLETYPE));
00953 err = OMX_GetParameter(appPriv->videodechandle,OMX_IndexParamStandardComponentRole,&sComponentRole);
00954 switch(paramPortVideo.format.video.eCompressionFormat){
00955 case OMX_VIDEO_CodingMPEG4:
00956 strcpy((char*)&sComponentRole.cRole[0], VIDEO_DEC_MPEG4_ROLE);
00957 break;
00958 case OMX_VIDEO_CodingAVC:
00959 strcpy((char*)&sComponentRole.cRole[0], VIDEO_DEC_H264_ROLE);
00960 break;
00961 default :
00962 DEBUG(DEB_LEV_ERR,"Error only MPEG4 and AVC(h.264) are supported %08x\n",paramPortVideo.format.video.eCompressionFormat);
00963 }
00964 err = OMX_SetParameter(appPriv->videodechandle,OMX_IndexParamStandardComponentRole,&sComponentRole);
00965 if(err != OMX_ErrorNone) {
00966 DEBUG(DEB_LEV_ERR,"\n error in input video format - exiting\n");
00967 exit(1);
00968 }
00969
00970
00971 SetPortParametersAudio();
00972 setHeader(&sComponentRole, sizeof(OMX_PARAM_COMPONENTROLETYPE));
00973 err = OMX_GetParameter(appPriv->audiodechandle, OMX_IndexParamStandardComponentRole,&sComponentRole);
00974 switch(paramPortAudio.format.audio.eEncoding){
00975 case OMX_AUDIO_CodingMP3:
00976 strcpy((char*)&sComponentRole.cRole[0], AUDIO_DEC_MP3_ROLE);
00977 break;
00978 case OMX_AUDIO_CodingAAC:
00979 strcpy((char*)&sComponentRole.cRole[0], AUDIO_DEC_AAC_ROLE);
00980 break;
00981 default :
00982 DEBUG(DEB_LEV_ERR,"Error only MP3 and AAC role are supported %08x\n",paramPortAudio.format.audio.eEncoding);
00983 }
00984 err = OMX_SetParameter(appPriv->audiodechandle,OMX_IndexParamStandardComponentRole,&sComponentRole);
00985 if(err != OMX_ErrorNone) {
00986 DEBUG(DEB_LEV_ERR,"\n error in input audio format - exiting\n");
00987 exit(1);
00988 }
00989
00990 if (flagSetupTunnel) {
00991
00992 err = OMX_SendCommand(appPriv->parser3gphandle, OMX_CommandPortEnable, -1, NULL);
00993 err = OMX_SendCommand(appPriv->videodechandle, OMX_CommandPortEnable, -1, NULL);
00994 err = OMX_SendCommand(appPriv->audiodechandle, OMX_CommandPortEnable, -1, NULL);
00995 err = OMX_SendCommand(appPriv->colorconv_handle, OMX_CommandPortEnable, 0, NULL);
00996 err = OMX_SendCommand(appPriv->colorconv_handle, OMX_CommandPortEnable, 1, NULL);
00997 err = OMX_SendCommand(appPriv->volumehandle, OMX_CommandPortEnable, 0, NULL);
00998 err = OMX_SendCommand(appPriv->volumehandle, OMX_CommandPortEnable, 1, NULL);
00999 err = OMX_SendCommand(appPriv->videosinkhandle, OMX_CommandPortEnable, 0, NULL);
01000 err = OMX_SendCommand(appPriv->audiosinkhandle, OMX_CommandPortEnable, 0, NULL);
01001 if(err != OMX_ErrorNone) {
01002 DEBUG(DEB_LEV_ERR,"audio sink port enable failed\n");
01003 exit(1);
01004 }
01005
01006 tsem_down(appPriv->parser3gpEventSem);
01007 tsem_down(appPriv->parser3gpEventSem);
01008 tsem_down(appPriv->videoDecoderEventSem);
01009 tsem_down(appPriv->videoDecoderEventSem);
01010 tsem_down(appPriv->audioDecoderEventSem);
01011 tsem_down(appPriv->audioDecoderEventSem);
01012 tsem_down(appPriv->colorconvEventSem);
01013 tsem_down(appPriv->colorconvEventSem);
01014 tsem_down(appPriv->volumeEventSem);
01015 tsem_down(appPriv->volumeEventSem);
01016 tsem_down(appPriv->fbdevSinkEventSem);
01017 tsem_down(appPriv->audioSinkEventSem);
01018 DEBUG(DEB_LEV_SIMPLE_SEQ,"All ports enabled\n");
01019 }
01020
01021
01022 if (!flagSetupTunnel) {
01023 err = OMX_SendCommand(appPriv->videodechandle, OMX_CommandStateSet, OMX_StateIdle, NULL);
01024
01028 err = OMX_UseBuffer(appPriv->videodechandle, &inBufferVideoDec[0], 0, NULL, buffer_out_size, outBufferParseVideo[0]->pBuffer);
01029 if(err != OMX_ErrorNone) {
01030 DEBUG(DEB_LEV_ERR, "Unable to use the parser3gp comp allocate buffer\n");
01031 exit(1);
01032 }
01033 err = OMX_UseBuffer(appPriv->videodechandle, &inBufferVideoDec[1], 0, NULL, buffer_out_size, outBufferParseVideo[1]->pBuffer);
01034 if(err != OMX_ErrorNone) {
01035 DEBUG(DEB_LEV_ERR, "Unable to use the parser3gp comp allocate buffer\n");
01036 exit(1);
01037 }
01038
01039
01040 err = OMX_AllocateBuffer(appPriv->videodechandle, &outBufferVideoDec[0], 1, NULL, buffer_out_size);
01041 if(err != OMX_ErrorNone) {
01042 DEBUG(DEB_LEV_ERR, "Unable to allocate buffer in video dec\n");
01043 exit(1);
01044 }
01045 err = OMX_AllocateBuffer(appPriv->videodechandle, &outBufferVideoDec[1], 1, NULL, buffer_out_size);
01046 if(err != OMX_ErrorNone) {
01047 DEBUG(DEB_LEV_ERR, "Unable to allocate buffer in video dec\n");
01048 exit(1);
01049 }
01050
01051 err = OMX_SendCommand(appPriv->audiodechandle, OMX_CommandStateSet, OMX_StateIdle, NULL);
01052
01056 err = OMX_UseBuffer(appPriv->audiodechandle, &inBufferAudioDec[0], 0, NULL, buffer_out_size, outBufferParseAudio[0]->pBuffer);
01057 if(err != OMX_ErrorNone) {
01058 DEBUG(DEB_LEV_ERR, "Unable to use the parser3gp allocate buffer\n");
01059 exit(1);
01060 }
01061 err = OMX_UseBuffer(appPriv->audiodechandle, &inBufferAudioDec[1], 0, NULL, buffer_out_size, outBufferParseAudio[1]->pBuffer);
01062 if(err != OMX_ErrorNone) {
01063 DEBUG(DEB_LEV_ERR, "Unable to use the parser3gp allocate buffer\n");
01064 exit(1);
01065 }
01066
01067
01068 err = OMX_AllocateBuffer(appPriv->audiodechandle, &outBufferAudioDec[0], 1, NULL, buffer_out_size);
01069 if(err != OMX_ErrorNone) {
01070 DEBUG(DEB_LEV_ERR, "Unable to allocate buffer in audio dec\n");
01071 exit(1);
01072 }
01073 err = OMX_AllocateBuffer(appPriv->audiodechandle, &outBufferAudioDec[1], 1, NULL, buffer_out_size);
01074 if(err != OMX_ErrorNone) {
01075 DEBUG(DEB_LEV_ERR, "Unable to allocate buffer in audio dec\n");
01076 exit(1);
01077 }
01078
01079
01080 tsem_down(appPriv->videoDecoderEventSem);
01081 tsem_down(appPriv->audioDecoderEventSem);
01082 }
01083
01084
01085 if (flagIsDisplayRequested && (!flagSetupTunnel)) {
01086 err = OMX_SendCommand(appPriv->colorconv_handle, OMX_CommandStateSet, OMX_StateIdle, NULL);
01087
01088 err = OMX_UseBuffer(appPriv->colorconv_handle, &inBufferColorconv[0], 0, NULL, buffer_out_size, outBufferVideoDec[0]->pBuffer);
01089 if(err != OMX_ErrorNone) {
01090 DEBUG(DEB_LEV_ERR, "Unable to use the allocated buffer\n");
01091 exit(1);
01092 }
01093 err = OMX_UseBuffer(appPriv->colorconv_handle, &inBufferColorconv[1], 0, NULL, buffer_out_size, outBufferVideoDec[1]->pBuffer);
01094 if(err != OMX_ErrorNone) {
01095 DEBUG(DEB_LEV_ERR, "Unable to use the allocated buffer\n");
01096 exit(1);
01097 }
01098
01099 err = OMX_AllocateBuffer(appPriv->colorconv_handle, &outBufferColorconv[0], 1, NULL, buffer_out_size);
01100 if(err != OMX_ErrorNone) {
01101 DEBUG(DEB_LEV_ERR, "Unable to allocate buffer in Color Converter 1\n");
01102 exit(1);
01103 }
01104 err = OMX_AllocateBuffer(appPriv->colorconv_handle, &outBufferColorconv[1], 1, NULL, buffer_out_size);
01105 if(err != OMX_ErrorNone) {
01106 DEBUG(DEB_LEV_ERR, "Unable to allocate buffer in Color Converter 2\n");
01107 exit(1);
01108 }
01109
01110
01111 tsem_down(appPriv->colorconvEventSem);
01112 DEBUG(DEB_LEV_SIMPLE_SEQ,"color converter state idle\n");
01113
01114 err = OMX_SendCommand(appPriv->videosinkhandle, OMX_CommandStateSet, OMX_StateIdle, NULL);
01115
01116 err = OMX_UseBuffer(appPriv->videosinkhandle, &inBufferSinkVideo[0], 0, NULL, buffer_out_size, outBufferColorconv[0]->pBuffer);
01117 if(err != OMX_ErrorNone) {
01118 DEBUG(DEB_LEV_ERR, "Unable to use the allocated buffer\n");
01119 exit(1);
01120 }
01121 err = OMX_UseBuffer(appPriv->videosinkhandle, &inBufferSinkVideo[1], 0, NULL, buffer_out_size, outBufferColorconv[1]->pBuffer);
01122 if(err != OMX_ErrorNone) {
01123 DEBUG(DEB_LEV_ERR, "Unable to use the allocated buffer\n");
01124 exit(1);
01125 }
01126 tsem_down(appPriv->fbdevSinkEventSem);
01127 DEBUG(DEB_LEV_SIMPLE_SEQ,"video sink state idle\n");
01128
01129
01130 err = OMX_SendCommand(appPriv->volumehandle, OMX_CommandStateSet, OMX_StateIdle, NULL);
01131
01132 err = OMX_UseBuffer(appPriv->volumehandle, &inBufferVolume[0], 0, NULL, buffer_out_size, outBufferAudioDec[0]->pBuffer);
01133 if(err != OMX_ErrorNone) {
01134 DEBUG(DEB_LEV_ERR, "Unable to use the allocated buffer\n");
01135 exit(1);
01136 }
01137 err = OMX_UseBuffer(appPriv->volumehandle, &inBufferVolume[1], 0, NULL, buffer_out_size, outBufferAudioDec[1]->pBuffer);
01138 if(err != OMX_ErrorNone) {
01139 DEBUG(DEB_LEV_ERR, "Unable to use the allocated buffer\n");
01140 exit(1);
01141 }
01142
01143 err = OMX_AllocateBuffer(appPriv->volumehandle, &outBufferVolume[0], 1, NULL, buffer_out_size);
01144 if(err != OMX_ErrorNone) {
01145 DEBUG(DEB_LEV_ERR, "Unable to allocate buffer in volume 1\n");
01146 exit(1);
01147 }
01148 err = OMX_AllocateBuffer(appPriv->volumehandle, &outBufferVolume[1], 1, NULL, buffer_out_size);
01149 if(err != OMX_ErrorNone) {
01150 DEBUG(DEB_LEV_ERR, "Unable to allocate buffer in volume 2\n");
01151 exit(1);
01152 }
01153
01154 tsem_down(appPriv->volumeEventSem);
01155 DEBUG(DEB_LEV_SIMPLE_SEQ,"volume state idle\n");
01156
01157 err = OMX_SendCommand(appPriv->audiosinkhandle, OMX_CommandStateSet, OMX_StateIdle, NULL);
01158
01159 err = OMX_UseBuffer(appPriv->audiosinkhandle, &inBufferSinkAudio[0], 0, NULL, buffer_out_size, outBufferVolume[0]->pBuffer);
01160 if(err != OMX_ErrorNone) {
01161 DEBUG(DEB_LEV_ERR, "Unable to use the allocated buffer\n");
01162 exit(1);
01163 }
01164 err = OMX_UseBuffer(appPriv->audiosinkhandle, &inBufferSinkAudio[1], 0, NULL, buffer_out_size, outBufferVolume[1]->pBuffer);
01165 if(err != OMX_ErrorNone) {
01166 DEBUG(DEB_LEV_ERR, "Unable to use the allocated buffer\n");
01167 exit(1);
01168 }
01169
01170 tsem_down(appPriv->audioSinkEventSem);
01171 DEBUG(DEB_LEV_SIMPLE_SEQ,"audio sink state idle\n");
01172 }
01173
01174 err = OMX_SendCommand(appPriv->videodechandle, OMX_CommandStateSet, OMX_StateExecuting, NULL);
01175 if(err != OMX_ErrorNone) {
01176 DEBUG(DEB_LEV_ERR,"video decoder state executing failed\n");
01177 exit(1);
01178 }
01179 tsem_down(appPriv->videoDecoderEventSem);
01180
01181 err = OMX_SendCommand(appPriv->audiodechandle, OMX_CommandStateSet, OMX_StateExecuting, NULL);
01182 if(err != OMX_ErrorNone) {
01183 DEBUG(DEB_LEV_ERR,"audio decoder state executing failed\n");
01184 exit(1);
01185 }
01186
01187
01188 tsem_down(appPriv->audioDecoderEventSem);
01189
01190 if (flagIsDisplayRequested) {
01191 err = OMX_SendCommand(appPriv->colorconv_handle, OMX_CommandStateSet, OMX_StateExecuting, NULL);
01192 if(err != OMX_ErrorNone) {
01193 DEBUG(DEB_LEV_ERR,"color converter state executing failed\n");
01194 exit(1);
01195 }
01196 DEBUG(DEB_LEV_SIMPLE_SEQ,"waiting for color converter state executing\n");
01197 tsem_down(appPriv->colorconvEventSem);
01198
01199 DEBUG(DEB_LEV_SIMPLE_SEQ,"sending video sink state to executing\n");
01200 err = OMX_SendCommand(appPriv->videosinkhandle, OMX_CommandStateSet, OMX_StateExecuting, NULL);
01201 if(err != OMX_ErrorNone) {
01202 DEBUG(DEB_LEV_ERR,"video sink state executing failed\n");
01203 exit(1);
01204 }
01205 DEBUG(DEB_LEV_SIMPLE_SEQ,"waiting for video sink state executing\n");
01206 tsem_down(appPriv->fbdevSinkEventSem);
01207 DEBUG(DEB_LEV_SIMPLE_SEQ, "video sink state executing successful\n");
01208
01209 err = OMX_SendCommand(appPriv->volumehandle, OMX_CommandStateSet, OMX_StateExecuting, NULL);
01210 if(err != OMX_ErrorNone) {
01211 DEBUG(DEB_LEV_ERR,"volume state executing failed\n");
01212 exit(1);
01213 }
01214 DEBUG(DEB_LEV_SIMPLE_SEQ,"waiting for volume state executing\n");
01215 tsem_down(appPriv->volumeEventSem);
01216
01217 DEBUG(DEB_LEV_SIMPLE_SEQ,"sending audio sink state executing\n");
01218 err = OMX_SendCommand(appPriv->audiosinkhandle, OMX_CommandStateSet, OMX_StateExecuting, NULL);
01219 if(err != OMX_ErrorNone) {
01220 DEBUG(DEB_LEV_ERR,"audio sink state executing failed\n");
01221 exit(1);
01222 }
01223 DEBUG(DEB_LEV_SIMPLE_SEQ,"waiting for audio sink state executing\n");
01224 tsem_down(appPriv->audioSinkEventSem);
01225 DEBUG(DEB_LEV_SIMPLE_SEQ, "audio sink state executing successful\n");
01226 }
01227
01228 DEBUG(DEB_LEV_SIMPLE_SEQ,"All Component state changed to Executing\n");
01229
01230 if (!flagSetupTunnel) {
01231 err = OMX_FillThisBuffer(appPriv->parser3gphandle, outBufferParseVideo[0]);
01232 if(err != OMX_ErrorNone) {
01233 DEBUG(DEB_LEV_ERR, "In %s Error %08x Calling FillThisBuffer Parser3gp \n", __func__,err);
01234 exit(1);
01235 }
01236 DEBUG(DEB_LEV_PARAMS, "Fill parser second buffer %x\n", (int)outBufferParseVideo[1]);
01237 err = OMX_FillThisBuffer(appPriv->parser3gphandle, outBufferParseVideo[1]);
01238 if(err != OMX_ErrorNone) {
01239 DEBUG(DEB_LEV_ERR, "In %s Error %08x Calling FillThisBuffer Parser3gp\n", __func__,err);
01240 exit(1);
01241 }
01242
01243 err = OMX_FillThisBuffer(appPriv->parser3gphandle, outBufferParseAudio[0]);
01244 if(err != OMX_ErrorNone) {
01245 DEBUG(DEB_LEV_ERR, "In %s Error %08x Calling FillThisBuffer Parser3gp \n", __func__,err);
01246 exit(1);
01247 }
01248 DEBUG(DEB_LEV_PARAMS, "Fill parser second buffer %x\n", (int)outBufferParseAudio[1]);
01249 err = OMX_FillThisBuffer(appPriv->parser3gphandle, outBufferParseAudio[1]);
01250 if(err != OMX_ErrorNone) {
01251 DEBUG(DEB_LEV_ERR, "In %s Error %08x Calling FillThisBuffer Parser3gp\n", __func__,err);
01252 exit(1);
01253 }
01254
01255 err = OMX_FillThisBuffer(appPriv->videodechandle, outBufferVideoDec[0]);
01256 if(err != OMX_ErrorNone) {
01257 DEBUG(DEB_LEV_ERR, "In %s Error %08x Calling FillThisBuffer Video Dec\n", __func__,err);
01258 exit(1);
01259 }
01260 DEBUG(DEB_LEV_PARAMS, "Fill decoder second buffer %x\n", (int)outBufferVideoDec[1]);
01261 err = OMX_FillThisBuffer(appPriv->videodechandle, outBufferVideoDec[1]);
01262 if(err != OMX_ErrorNone) {
01263 DEBUG(DEB_LEV_ERR, "In %s Error %08x Calling FillThisBuffer Video Dec\n", __func__,err);
01264 exit(1);
01265 }
01266
01267 err = OMX_FillThisBuffer(appPriv->audiodechandle, outBufferAudioDec[0]);
01268 if(err != OMX_ErrorNone) {
01269 DEBUG(DEB_LEV_ERR, "In %s Error %08x Calling FillThisBuffer Audio Dec\n", __func__,err);
01270 exit(1);
01271 }
01272 DEBUG(DEB_LEV_PARAMS, "Fill decoder second buffer %x\n", (int)outBufferAudioDec[1]);
01273 err = OMX_FillThisBuffer(appPriv->audiodechandle, outBufferAudioDec[1]);
01274 if(err != OMX_ErrorNone) {
01275 DEBUG(DEB_LEV_ERR, "In %s Error %08x Calling FillThisBuffer Audio Dec\n", __func__,err);
01276 exit(1);
01277 }
01278
01279 if (flagIsDisplayRequested) {
01280 err = OMX_FillThisBuffer(appPriv->colorconv_handle, outBufferColorconv[0]);
01281 if(err != OMX_ErrorNone) {
01282 DEBUG(DEB_LEV_ERR, "In %s Error %08x Calling FillThisBuffer Video Dec\n", __func__,err);
01283 exit(1);
01284 }
01285 DEBUG(DEB_LEV_PARAMS, "Fill decoder second buffer %x\n", (int)outBufferColorconv[1]);
01286 err = OMX_FillThisBuffer(appPriv->colorconv_handle, outBufferColorconv[1]);
01287 if(err != OMX_ErrorNone) {
01288 DEBUG(DEB_LEV_ERR, "In %s Error %08x Calling FillThisBuffer Video Dec\n", __func__,err);
01289 exit(1);
01290 }
01291
01292 err = OMX_FillThisBuffer(appPriv->volumehandle, outBufferVolume[0]);
01293 if(err != OMX_ErrorNone) {
01294 DEBUG(DEB_LEV_ERR, "In %s Error %08x Calling FillThisBuffer Audio Dec\n", __func__,err);
01295 exit(1);
01296 }
01297 DEBUG(DEB_LEV_PARAMS, "Fill decoder second buffer %x\n", (int)outBufferVolume[1]);
01298 err = OMX_FillThisBuffer(appPriv->volumehandle, outBufferVolume[1]);
01299 if(err != OMX_ErrorNone) {
01300 DEBUG(DEB_LEV_ERR, "In %s Error %08x Calling FillThisBuffer Audio Dec\n", __func__,err);
01301 exit(1);
01302 }
01303 }
01304 }
01305
01306 DEBUG(DEFAULT_MESSAGES,"Waiting for EOS = %d\n",appPriv->eofSem->semval);
01307
01308 tsem_down(appPriv->eofSem);
01309
01310 DEBUG(DEFAULT_MESSAGES,"Received EOS \n");
01311
01312 DEBUG(DEFAULT_MESSAGES, "The execution of the decoding process is terminated\n");
01313 err = OMX_SendCommand(appPriv->parser3gphandle, OMX_CommandStateSet, OMX_StateIdle, NULL);
01314 err = OMX_SendCommand(appPriv->videodechandle, OMX_CommandStateSet, OMX_StateIdle, NULL);
01315 err = OMX_SendCommand(appPriv->audiodechandle, OMX_CommandStateSet, OMX_StateIdle, NULL);
01316
01317 if (flagIsDisplayRequested) {
01318 err = OMX_SendCommand(appPriv->colorconv_handle, OMX_CommandStateSet, OMX_StateIdle, NULL);
01319 err = OMX_SendCommand(appPriv->videosinkhandle, OMX_CommandStateSet, OMX_StateIdle, NULL);
01320 err = OMX_SendCommand(appPriv->volumehandle, OMX_CommandStateSet, OMX_StateIdle, NULL);
01321 err = OMX_SendCommand(appPriv->audiosinkhandle, OMX_CommandStateSet, OMX_StateIdle, NULL);
01322 }
01323
01324 tsem_down(appPriv->parser3gpEventSem);
01325 DEBUG(DEFAULT_MESSAGES,"Parser3gp idle state \n");
01326 tsem_down(appPriv->videoDecoderEventSem);
01327 tsem_down(appPriv->audioDecoderEventSem);
01328
01329 if (flagIsDisplayRequested) {
01330 tsem_down(appPriv->colorconvEventSem);
01331 tsem_down(appPriv->fbdevSinkEventSem);
01332 tsem_down(appPriv->volumeEventSem);
01333 tsem_down(appPriv->audioSinkEventSem);
01334 }
01335
01336 DEBUG(DEFAULT_MESSAGES, "All component Transitioned to Idle\n");
01337
01338 err = OMX_SendCommand(appPriv->parser3gphandle, OMX_CommandStateSet, OMX_StateLoaded, NULL);
01339 err = OMX_SendCommand(appPriv->videodechandle, OMX_CommandStateSet, OMX_StateLoaded, NULL);
01340 err = OMX_SendCommand(appPriv->audiodechandle, OMX_CommandStateSet, OMX_StateLoaded, NULL);
01341
01342 if (flagIsDisplayRequested) {
01343 err = OMX_SendCommand(appPriv->colorconv_handle, OMX_CommandStateSet, OMX_StateLoaded, NULL);
01344 err = OMX_SendCommand(appPriv->videosinkhandle, OMX_CommandStateSet, OMX_StateLoaded, NULL);
01345 err = OMX_SendCommand(appPriv->volumehandle, OMX_CommandStateSet, OMX_StateLoaded, NULL);
01346 err = OMX_SendCommand(appPriv->audiosinkhandle, OMX_CommandStateSet, OMX_StateLoaded, NULL);
01347 }
01348
01349
01350 DEBUG(DEFAULT_MESSAGES, "Video dec to loaded\n");
01351
01352
01353 if (!flagSetupTunnel) {
01354 err = OMX_FreeBuffer(appPriv->videodechandle, 0, inBufferVideoDec[0]);
01355 err = OMX_FreeBuffer(appPriv->videodechandle, 0, inBufferVideoDec[1]);
01356 err = OMX_FreeBuffer(appPriv->audiodechandle, 0, inBufferAudioDec[0]);
01357 err = OMX_FreeBuffer(appPriv->audiodechandle, 0, inBufferAudioDec[1]);
01358
01359 DEBUG(DEB_LEV_PARAMS, "Freeing decoder output ports\n");
01360 err = OMX_FreeBuffer(appPriv->videodechandle, 1, outBufferVideoDec[0]);
01361 err = OMX_FreeBuffer(appPriv->videodechandle, 1, outBufferVideoDec[1]);
01362 err = OMX_FreeBuffer(appPriv->audiodechandle, 1, outBufferAudioDec[0]);
01363 err = OMX_FreeBuffer(appPriv->audiodechandle, 1, outBufferAudioDec[1]);
01364 err = OMX_FreeBuffer(appPriv->parser3gphandle, VIDEO_PORT_INDEX, outBufferParseVideo[0]);
01365 err = OMX_FreeBuffer(appPriv->parser3gphandle, VIDEO_PORT_INDEX, outBufferParseVideo[1]);
01366 err = OMX_FreeBuffer(appPriv->parser3gphandle, AUDIO_PORT_INDEX, outBufferParseAudio[0]);
01367 err = OMX_FreeBuffer(appPriv->parser3gphandle, AUDIO_PORT_INDEX, outBufferParseAudio[1]);
01368 }
01369
01370 if (flagIsDisplayRequested && (!flagSetupTunnel)) {
01371 err = OMX_FreeBuffer(appPriv->colorconv_handle, 0, inBufferColorconv[0]);
01372 err = OMX_FreeBuffer(appPriv->colorconv_handle, 0, inBufferColorconv[1]);
01373 err = OMX_FreeBuffer(appPriv->colorconv_handle, 1, outBufferColorconv[0]);
01374 err = OMX_FreeBuffer(appPriv->colorconv_handle, 1, outBufferColorconv[1]);
01375
01376 err = OMX_FreeBuffer(appPriv->volumehandle, 0, inBufferVolume[0]);
01377 err = OMX_FreeBuffer(appPriv->volumehandle, 0, inBufferVolume[1]);
01378 err = OMX_FreeBuffer(appPriv->volumehandle, 1, outBufferVolume[0]);
01379 err = OMX_FreeBuffer(appPriv->volumehandle, 1, outBufferVolume[1]);
01380
01381 err = OMX_FreeBuffer(appPriv->videosinkhandle, 0, inBufferSinkVideo[0]);
01382 err = OMX_FreeBuffer(appPriv->videosinkhandle, 0, inBufferSinkVideo[1]);
01383 err = OMX_FreeBuffer(appPriv->audiosinkhandle, 0, inBufferSinkAudio[0]);
01384 err = OMX_FreeBuffer(appPriv->audiosinkhandle, 0, inBufferSinkAudio[1]);
01385 }
01386
01387 tsem_down(appPriv->parser3gpEventSem);
01388 DEBUG(DEFAULT_MESSAGES,"Parser3gp loaded state \n");
01389 tsem_down(appPriv->videoDecoderEventSem);
01390 tsem_down(appPriv->audioDecoderEventSem);
01391
01392 if (flagIsDisplayRequested) {
01393 tsem_down(appPriv->colorconvEventSem);
01394 tsem_down(appPriv->fbdevSinkEventSem);
01395 tsem_down(appPriv->volumeEventSem);
01396 tsem_down(appPriv->audioSinkEventSem);
01397 }
01398
01399 DEBUG(DEFAULT_MESSAGES, "All components released\n");
01400
01402 OMX_FreeHandle(appPriv->videodechandle);
01403 DEBUG(DEB_LEV_SIMPLE_SEQ, "videodec freed\n");
01404 OMX_FreeHandle(appPriv->audiodechandle);
01405 DEBUG(DEB_LEV_SIMPLE_SEQ, "audiodec dec freed\n");
01406
01407 OMX_FreeHandle(appPriv->parser3gphandle);
01408 DEBUG(DEB_LEV_SIMPLE_SEQ, "parser3gp freed\n");
01409
01410 if (flagIsDisplayRequested) {
01411 OMX_FreeHandle(appPriv->colorconv_handle);
01412 DEBUG(DEB_LEV_SIMPLE_SEQ, "color converter component freed\n");
01413 OMX_FreeHandle(appPriv->videosinkhandle);
01414 DEBUG(DEB_LEV_SIMPLE_SEQ, "videosink freed\n");
01415 OMX_FreeHandle(appPriv->volumehandle);
01416 DEBUG(DEB_LEV_SIMPLE_SEQ, "volume component freed\n");
01417 OMX_FreeHandle(appPriv->audiosinkhandle);
01418 DEBUG(DEB_LEV_SIMPLE_SEQ, "audiosink freed\n");
01419
01420 }
01421
01422 OMX_Deinit();
01423
01424 DEBUG(DEB_LEV_SIMPLE_SEQ, "All components freed. Closing...\n");
01425
01426 free(appPriv->parser3gpEventSem);
01427 appPriv->parser3gpEventSem = NULL;
01428
01429 free(appPriv->videoDecoderEventSem);
01430 appPriv->videoDecoderEventSem = NULL;
01431 free(appPriv->audioDecoderEventSem);
01432 appPriv->audioDecoderEventSem = NULL;
01433
01434 if (flagIsDisplayRequested) {
01435 free(appPriv->colorconvEventSem);
01436 appPriv->colorconvEventSem = NULL;
01437
01438 free(appPriv->fbdevSinkEventSem);
01439 appPriv->fbdevSinkEventSem = NULL;
01440
01441 free(appPriv->volumeEventSem);
01442 appPriv->volumeEventSem = NULL;
01443
01444 free(appPriv->audioSinkEventSem);
01445 appPriv->audioSinkEventSem = NULL;
01446 }
01447
01448 free(appPriv->eofSem);
01449 appPriv->eofSem = NULL;
01450 free(appPriv);
01451 appPriv = NULL;
01452
01453 free(input_file);
01454 free(output_file_audio);
01455 free(output_file_video);
01456 free(temp);
01457
01458 return 0;
01459 }
01460
01461
01462 OMX_ERRORTYPE parser3gpEventHandler(
01463 OMX_OUT OMX_HANDLETYPE hComponent,
01464 OMX_OUT OMX_PTR pAppData,
01465 OMX_OUT OMX_EVENTTYPE eEvent,
01466 OMX_OUT OMX_U32 Data1,
01467 OMX_OUT OMX_U32 Data2,
01468 OMX_OUT OMX_PTR pEventData)
01469 {
01470 OMX_PTR pExtraData;
01471 OMX_INDEXTYPE eIndexExtraData;
01472 OMX_ERRORTYPE err;
01473 DEBUG(DEB_LEV_SIMPLE_SEQ, "Hi there, I am in the %s callback\n", __func__);
01474
01475 if(eEvent == OMX_EventCmdComplete) {
01476 if (Data1 == OMX_CommandStateSet) {
01477 DEBUG(DEB_LEV_SIMPLE_SEQ, "Parser 3gp State changed in ");
01478 switch ((int)Data2) {
01479 case OMX_StateInvalid:
01480 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateInvalid\n");
01481 break;
01482 case OMX_StateLoaded:
01483 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateLoaded\n");
01484 break;
01485 case OMX_StateIdle:
01486 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateIdle\n");
01487 break;
01488 case OMX_StateExecuting:
01489 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateExecuting\n");
01490 break;
01491 case OMX_StatePause:
01492 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StatePause\n");
01493 break;
01494 case OMX_StateWaitForResources:
01495 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateWaitForResources\n");
01496 break;
01497 }
01498 tsem_up(appPriv->parser3gpEventSem);
01499 } else if (Data1 == OMX_CommandPortEnable){
01500 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s Received Port Enable Event\n",__func__);
01501 tsem_up(appPriv->parser3gpEventSem);
01502 } else if (Data1 == OMX_CommandPortDisable){
01503 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s Received Port Disable Event\n",__func__);
01504 tsem_up(appPriv->parser3gpEventSem);
01505 } else {
01506 DEBUG(DEB_LEV_SIMPLE_SEQ,"In %s Received Event Event=%d Data1=%d,Data2=%d\n",__func__,eEvent,(int)Data1,(int)Data2);
01507 }
01508 }else if(eEvent == OMX_EventPortSettingsChanged) {
01509 DEBUG(DEB_LEV_SIMPLE_SEQ,"Parser3gp Port Setting Changed event\n");
01510
01511
01512 if(Data2==0) {
01513 err = OMX_GetExtensionIndex(appPriv->parser3gphandle,"OMX.ST.index.config.videoextradata",&eIndexExtraData);
01514 if(err != OMX_ErrorNone) {
01515 DEBUG(DEB_LEV_ERR,"\n 1 error in get extension index\n");
01516 exit(1);
01517 } else {
01518 pExtraData = malloc(extradata_size);
01519 err = OMX_GetConfig(appPriv->parser3gphandle, eIndexExtraData, pExtraData);
01520 if(err != OMX_ErrorNone) {
01521 DEBUG(DEB_LEV_ERR,"\n parser 3gp Get Param Failed error =%08x index=%08x\n",err,eIndexExtraData);
01522 exit(1);
01523 }
01524 DEBUG(DEB_LEV_SIMPLE_SEQ,"Setting ExtraData\n");
01525 err = OMX_SetConfig(appPriv->videodechandle, eIndexExtraData, pExtraData);
01526 if(err != OMX_ErrorNone) {
01527 DEBUG(DEB_LEV_ERR,"\n video decoder Set Config Failed error=%08x\n",err);
01528 exit(1);
01529 }
01530 free(pExtraData);
01531 }
01532 } else if (Data2==1) {
01533 err = OMX_GetExtensionIndex(appPriv->parser3gphandle,"OMX.ST.index.config.audioextradata",&eIndexExtraData);
01534 if(err != OMX_ErrorNone) {
01535 DEBUG(DEB_LEV_ERR,"\n 1 error in get extension index\n");
01536 exit(1);
01537 } else {
01538 pExtraData = malloc(extradata_size);
01539 err = OMX_GetConfig(appPriv->parser3gphandle, eIndexExtraData, pExtraData);
01540 if(err != OMX_ErrorNone) {
01541 DEBUG(DEB_LEV_ERR,"\n parser 3gp Get Param Failed error =%08x index=%08x\n",err,eIndexExtraData);
01542 exit(1);
01543 }
01544 DEBUG(DEB_LEV_SIMPLE_SEQ,"Setting ExtraData\n");
01545 err = OMX_SetConfig(appPriv->audiodechandle, eIndexExtraData, pExtraData);
01546 if(err != OMX_ErrorNone) {
01547 DEBUG(DEB_LEV_ERR,"\n video decoder Set Config Failed error=%08x\n",err);
01548 exit(1);
01549 }
01550 free(pExtraData);
01551 }
01552 }
01553
01554
01555 if (flagSetupTunnel) {
01556 if(Data2==0) {
01557 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s parser3gp Component Port Disabling\n", __func__);
01558
01559 err = OMX_SendCommand(appPriv->parser3gphandle, OMX_CommandPortDisable, VIDEO_PORT_INDEX, NULL);
01560 if(err != OMX_ErrorNone) {
01561 DEBUG(DEB_LEV_ERR,"parser3gp video port disable failed\n");
01562 exit(1);
01563 }
01564 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s Video decoder Component Port Disabling\n", __func__);
01565
01566 err = OMX_SendCommand(appPriv->videodechandle, OMX_CommandPortDisable, OMX_ALL, NULL);
01567 if(err != OMX_ErrorNone) {
01568 DEBUG(DEB_LEV_ERR,"Video decoder port disable failed err=%08x\n",err);
01569 exit(1);
01570 }
01571
01572 if(flagIsDisplayRequested){
01573 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s Color Converter Component Port Disabling\n", __func__);
01574 err = OMX_SendCommand(appPriv->colorconv_handle, OMX_CommandPortDisable, OMX_ALL, NULL);
01575 if(err != OMX_ErrorNone) {
01576 DEBUG(DEB_LEV_ERR,"Color Converter Component port disable failed\n");
01577 exit(1);
01578 }
01579
01580 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s Video Sink Port Disabling\n", __func__);
01581 err = OMX_SendCommand(appPriv->videosinkhandle, OMX_CommandPortDisable, 0, NULL);
01582 if(err != OMX_ErrorNone) {
01583 DEBUG(DEB_LEV_ERR,"video sink port disable failed\n");
01584 exit(1);
01585 }
01586 }
01587 }else if (Data2==1) {
01588
01589 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s parser3gp Component Port Disabling\n", __func__);
01590
01591 err = OMX_SendCommand(appPriv->parser3gphandle, OMX_CommandPortDisable, AUDIO_PORT_INDEX, NULL);
01592 if(err != OMX_ErrorNone) {
01593 DEBUG(DEB_LEV_ERR,"parser3gp audio port disable failed\n");
01594 exit(1);
01595 }
01596
01597 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s Audio decoder Component Port Disabling\n", __func__);
01598
01599 err = OMX_SendCommand(appPriv->audiodechandle, OMX_CommandPortDisable, OMX_ALL, NULL);
01600 if(err != OMX_ErrorNone) {
01601 DEBUG(DEB_LEV_ERR,"Audio decoder port disable failed\n");
01602 exit(1);
01603 }
01604
01605 if(flagIsDisplayRequested){
01606 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s Volume Component Port Disabling\n", __func__);
01607 err = OMX_SendCommand(appPriv->volumehandle, OMX_CommandPortDisable, OMX_ALL, NULL);
01608 if(err != OMX_ErrorNone) {
01609 DEBUG(DEB_LEV_ERR,"Volume Component port disable failed\n");
01610 exit(1);
01611 }
01612
01613 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s Audio Sink Port Disabling\n", __func__);
01614 err = OMX_SendCommand(appPriv->audiosinkhandle, OMX_CommandPortDisable, 0, NULL);
01615 if(err != OMX_ErrorNone) {
01616 DEBUG(DEB_LEV_ERR,"Audio sink port disable failed\n");
01617 exit(1);
01618 }
01619 }
01620 }
01621 }
01622
01623
01624 tsem_up(appPriv->parser3gpEventSem);
01625 }else if(eEvent == OMX_EventPortFormatDetected) {
01626 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s Port Format Detected %x\n", __func__,(int)Data1);
01627 }else if (eEvent ==OMX_EventError){
01628 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s Error in %x Detection for port %d\n",__func__,(int)Data1,(int)Data2);
01629 } else if(eEvent == OMX_EventBufferFlag) {
01630 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s OMX_BUFFERFLAG_EOS\n", __func__);
01631 if((int)Data2 == OMX_BUFFERFLAG_EOS) {
01632 tsem_up(appPriv->eofSem);
01633 }
01634 } else {
01635 DEBUG(DEB_LEV_SIMPLE_SEQ, "Param1 is %i\n", (int)Data1);
01636 DEBUG(DEB_LEV_SIMPLE_SEQ, "Param2 is %i\n", (int)Data2);
01637 }
01638 return OMX_ErrorNone;
01639 }
01640
01641 OMX_ERRORTYPE parser3gpFillBufferDone(
01642 OMX_OUT OMX_HANDLETYPE hComponent,
01643 OMX_OUT OMX_PTR pAppData,
01644 OMX_OUT OMX_BUFFERHEADERTYPE* pBuffer)
01645 {
01646 OMX_ERRORTYPE err;
01647
01648
01649 if(pBuffer != NULL){
01650 switch(pBuffer->nOutputPortIndex) {
01651 case VIDEO_PORT_INDEX:
01652 if(!bEOS) {
01653 if(inBufferVideoDec[0]->pBuffer == pBuffer->pBuffer) {
01654 inBufferVideoDec[0]->nFilledLen = pBuffer->nFilledLen;
01655 err = OMX_EmptyThisBuffer(appPriv->videodechandle, inBufferVideoDec[0]);
01656 } else {
01657 inBufferVideoDec[1]->nFilledLen = pBuffer->nFilledLen;
01658 err = OMX_EmptyThisBuffer(appPriv->videodechandle, inBufferVideoDec[1]);
01659 }
01660 if(err != OMX_ErrorNone) {
01661 DEBUG(DEB_LEV_ERR, "In %s Error %08x Calling FillThisBuffer\n", __func__,err);
01662 }
01663 if(pBuffer->nFlags==OMX_BUFFERFLAG_EOS) {
01664 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s: eos=%x Calling Empty This Buffer\n", __func__,(int)pBuffer->nFlags);
01665 bEOS=OMX_TRUE;
01666 }
01667 } else {
01668 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s: eos=%x Dropping Empty This Buffer\n", __func__,(int)pBuffer->nFlags);
01669 }
01670 break;
01671 case AUDIO_PORT_INDEX:
01672 if(!bEOS) {
01673 if(inBufferAudioDec[0]->pBuffer == pBuffer->pBuffer) {
01674 inBufferAudioDec[0]->nFilledLen = pBuffer->nFilledLen;
01675 err = OMX_EmptyThisBuffer(appPriv->audiodechandle, inBufferAudioDec[0]);
01676 } else {
01677 inBufferAudioDec[1]->nFilledLen = pBuffer->nFilledLen;
01678 err = OMX_EmptyThisBuffer(appPriv->audiodechandle, inBufferAudioDec[1]);
01679 }
01680 if(err != OMX_ErrorNone) {
01681 DEBUG(DEB_LEV_ERR, "In %s Error %08x Calling FillThisBuffer\n", __func__,err);
01682 }
01683 if(pBuffer->nFlags==OMX_BUFFERFLAG_EOS) {
01684 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s: eos=%x Calling Empty This Buffer\n", __func__,(int)pBuffer->nFlags);
01685 bEOS=OMX_TRUE;
01686 }
01687 } else {
01688 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s: eos=%x Dropping Empty This Buffer\n", __func__,(int)pBuffer->nFlags);
01689 }
01690 break;
01691 }
01692 } else {
01693 DEBUG(DEB_LEV_ERR, "Ouch! In %s: had NULL buffer to output...\n", __func__);
01694 }
01695 return OMX_ErrorNone;
01696 }
01697
01698 OMX_ERRORTYPE videodecEventHandler(
01699 OMX_OUT OMX_HANDLETYPE hComponent,
01700 OMX_OUT OMX_PTR pAppData,
01701 OMX_OUT OMX_EVENTTYPE eEvent,
01702 OMX_OUT OMX_U32 Data1,
01703 OMX_OUT OMX_U32 Data2,
01704 OMX_OUT OMX_PTR pEventData)
01705 {
01706 OMX_ERRORTYPE err;
01707 OMX_PARAM_PORTDEFINITIONTYPE param;
01708
01709 DEBUG(DEB_LEV_SIMPLE_SEQ, "Hi there, I am in the %s callback\n", __func__);
01710 if(eEvent == OMX_EventCmdComplete) {
01711 if (Data1 == OMX_CommandStateSet) {
01712 DEBUG(DEB_LEV_SIMPLE_SEQ, "Video Decoder State changed in ");
01713 switch ((int)Data2) {
01714 case OMX_StateInvalid:
01715 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateInvalid\n");
01716 break;
01717 case OMX_StateLoaded:
01718 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateLoaded\n");
01719 break;
01720 case OMX_StateIdle:
01721 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateIdle\n");
01722 break;
01723 case OMX_StateExecuting:
01724 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateExecuting\n");
01725 break;
01726 case OMX_StatePause:
01727 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StatePause\n");
01728 break;
01729 case OMX_StateWaitForResources:
01730 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateWaitForResources\n");
01731 break;
01732 }
01733 tsem_up(appPriv->videoDecoderEventSem);
01734 }
01735 else if (Data1 == OMX_CommandPortEnable){
01736 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s Received Port Enable Event\n",__func__);
01737 tsem_up(appPriv->videoDecoderEventSem);
01738 } else if (Data1 == OMX_CommandPortDisable){
01739 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s Received Port Disable Event\n",__func__);
01740 tsem_up(appPriv->videoDecoderEventSem);
01741 }
01742 } else if(eEvent == OMX_EventPortSettingsChanged) {
01743 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s Received Port Settings Changed Event\n", __func__);
01744 if (Data2 == 1) {
01745 param.nPortIndex = 1;
01746 setHeader(¶m, sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
01747 err = OMX_GetParameter(appPriv->videodechandle,OMX_IndexParamPortDefinition, ¶m);
01748
01749 } else if (Data2 == 0) {
01750
01751 param.nPortIndex = 0;
01752 setHeader(¶m, sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
01753 err = OMX_GetParameter(appPriv->videodechandle,OMX_IndexParamPortDefinition, ¶m);
01754 }
01755 } else if(eEvent == OMX_EventBufferFlag) {
01756 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s OMX_BUFFERFLAG_EOS\n", __func__);
01757 if((int)Data2 == OMX_BUFFERFLAG_EOS) {
01758 tsem_up(appPriv->eofSem);
01759 }
01760 } else {
01761 DEBUG(DEB_LEV_SIMPLE_SEQ, "Param1 is %i\n", (int)Data1);
01762 DEBUG(DEB_LEV_SIMPLE_SEQ, "Param2 is %i\n", (int)Data2);
01763 }
01764
01765 return OMX_ErrorNone;
01766 }
01767
01768 OMX_ERRORTYPE videodecEmptyBufferDone(
01769 OMX_OUT OMX_HANDLETYPE hComponent,
01770 OMX_OUT OMX_PTR pAppData,
01771 OMX_OUT OMX_BUFFERHEADERTYPE* pBuffer)
01772 {
01773 OMX_ERRORTYPE err;
01774 static int iBufferDropped=0;
01775 DEBUG(DEB_LEV_FULL_SEQ, "Hi there, I am in the %s callback.\n", __func__);
01776
01777 if(pBuffer != NULL){
01778 if(!bEOS) {
01779 if(outBufferParseVideo[0]->pBuffer == pBuffer->pBuffer) {
01780 outBufferParseVideo[0]->nFilledLen=0;
01781 err = OMX_FillThisBuffer(appPriv->parser3gphandle, outBufferParseVideo[0]);
01782 } else {
01783 outBufferParseVideo[1]->nFilledLen=0;
01784 err = OMX_FillThisBuffer(appPriv->parser3gphandle, outBufferParseVideo[1]);
01785 }
01786 if(err != OMX_ErrorNone) {
01787 DEBUG(DEB_LEV_ERR, "In %s Error %08x Calling FillThisBuffer\n", __func__,err);
01788 }
01789 }
01790 else {
01791 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s: eos=%x Dropping Fill This Buffer\n", __func__,(int)pBuffer->nFlags);
01792 iBufferDropped++;
01793 if(iBufferDropped==2) {
01794 tsem_up(appPriv->eofSem);
01795 }
01796 }
01797 } else {
01798 if(!bEOS) {
01799 DEBUG(DEB_LEV_SIMPLE_SEQ,"It is here EOS = %d\n",appPriv->eofSem->semval);
01800 tsem_up(appPriv->eofSem);
01801 }
01802 DEBUG(DEB_LEV_ERR, "Ouch! In %s: had NULL buffer to output...\n", __func__);
01803 }
01804 return OMX_ErrorNone;
01805 }
01806
01807 OMX_ERRORTYPE videodecFillBufferDone(
01808 OMX_OUT OMX_HANDLETYPE hComponent,
01809 OMX_OUT OMX_PTR pAppData,
01810 OMX_OUT OMX_BUFFERHEADERTYPE* pBuffer)
01811 {
01812 OMX_ERRORTYPE err;
01813 int i;
01814 DEBUG(DEB_LEV_FUNCTION_NAME, "In %s \n",__func__);
01815
01816 if(pBuffer != NULL){
01817 if(!bEOS) {
01818 if (pBuffer->nFilledLen == 0) {
01819 DEBUG(DEB_LEV_ERR, "Gadbadax! In %s: had 0 data size in output buffer...\n", __func__);
01820 return OMX_ErrorNone;
01821 }
01822 if ((!flagDecodedOutputReceived) && (!flagIsDisplayRequested) ) {
01823 for(i = 0; i<pBuffer->nFilledLen; i++){
01824 putchar(*(char*)(pBuffer->pBuffer + i));
01825 }
01826 pBuffer->nFilledLen = 0;
01827 err = OMX_FillThisBuffer(hComponent, pBuffer);
01828 if(err != OMX_ErrorNone) {
01829 DEBUG(DEB_LEV_ERR, "In %s Error %08x Calling FillThisBuffer\n", __func__,err);
01830 }
01831 } else if ((flagDecodedOutputReceived) && (!flagIsDisplayRequested)) {
01832 if(pBuffer->nFilledLen > 0) {
01833 fwrite(pBuffer->pBuffer, 1, pBuffer->nFilledLen, outfileVideo);
01834 }
01835 pBuffer->nFilledLen = 0;
01836 err = OMX_FillThisBuffer(hComponent, pBuffer);
01837 if(err != OMX_ErrorNone) {
01838 DEBUG(DEB_LEV_ERR, "In %s Error %08x Calling FillThisBuffer\n", __func__,err);
01839 }
01840 }
01841 else if ((!flagSetupTunnel) && (flagIsDisplayRequested)) {
01842 if(inBufferColorconv[0]->pBuffer == pBuffer->pBuffer) {
01843 inBufferColorconv[0]->nFilledLen = pBuffer->nFilledLen;
01844 err = OMX_EmptyThisBuffer(appPriv->colorconv_handle, inBufferColorconv[0]);
01845 } else {
01846 inBufferColorconv[1]->nFilledLen = pBuffer->nFilledLen;
01847 err = OMX_EmptyThisBuffer(appPriv->colorconv_handle, inBufferColorconv[1]);
01848 }
01849 if(err != OMX_ErrorNone) {
01850 DEBUG(DEB_LEV_ERR, "In %s Error %08x Calling EmptyThisBuffer\n", __func__,err);
01851 }
01852 }
01853 } else {
01854 DEBUG(DEB_LEV_ERR, " Buffer Dropping ...\n");
01855 }
01856 } else {
01857 DEBUG(DEB_LEV_ERR, "Ouch! In %s: had NULL buffer to output...\n", __func__);
01858 }
01859 return OMX_ErrorNone;
01860 }
01861
01862
01863 OMX_ERRORTYPE colorconvEventHandler(
01864 OMX_OUT OMX_HANDLETYPE hComponent,
01865 OMX_OUT OMX_PTR pAppData,
01866 OMX_OUT OMX_EVENTTYPE eEvent,
01867 OMX_OUT OMX_U32 Data1,
01868 OMX_OUT OMX_U32 Data2,
01869 OMX_OUT OMX_PTR pEventData) {
01870
01871 DEBUG(DEB_LEV_SIMPLE_SEQ, "\nHi there, I am in the %s callback\n", __func__);
01872 if(eEvent == OMX_EventCmdComplete) {
01873 if (Data1 == OMX_CommandStateSet) {
01874 DEBUG(DEB_LEV_SIMPLE_SEQ, "\nState changed in ");
01875 switch ((int)Data2) {
01876 case OMX_StateInvalid:
01877 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateInvalid\n");
01878 break;
01879 case OMX_StateLoaded:
01880 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateLoaded\n");
01881 break;
01882 case OMX_StateIdle:
01883 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateIdle\n");
01884 break;
01885 case OMX_StateExecuting:
01886 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateExecuting\n");
01887 break;
01888 case OMX_StatePause:
01889 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StatePause\n");
01890 break;
01891 case OMX_StateWaitForResources:
01892 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateWaitForResources\n");
01893 break;
01894 }
01895 tsem_up(appPriv->colorconvEventSem);
01896 }
01897 else if (OMX_CommandPortEnable || OMX_CommandPortDisable) {
01898 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s Received Port Enable/Disable Event\n",__func__);
01899 tsem_up(appPriv->colorconvEventSem);
01900 }
01901 } else if(eEvent == OMX_EventBufferFlag) {
01902 DEBUG(DEB_LEV_ERR, "In %s OMX_BUFFERFLAG_EOS\n", __func__);
01903 if((int)Data2 == OMX_BUFFERFLAG_EOS) {
01904 tsem_up(appPriv->eofSem);
01905 }
01906 } else {
01907 DEBUG(DEB_LEV_SIMPLE_SEQ, "Param1 is %i\n", (int)Data1);
01908 DEBUG(DEB_LEV_SIMPLE_SEQ, "Param2 is %i\n", (int)Data2);
01909 }
01910 return OMX_ErrorNone;
01911 }
01912
01913 OMX_ERRORTYPE colorconvEmptyBufferDone(
01914 OMX_OUT OMX_HANDLETYPE hComponent,
01915 OMX_OUT OMX_PTR pAppData,
01916 OMX_OUT OMX_BUFFERHEADERTYPE* pBuffer) {
01917
01918 OMX_ERRORTYPE err;
01919 static int iBufferDropped = 0;
01920
01921 if(pBuffer != NULL) {
01922 if(!bEOS) {
01923 if(outBufferVideoDec[0]->pBuffer == pBuffer->pBuffer) {
01924 outBufferVideoDec[0]->nFilledLen = pBuffer->nFilledLen;
01925 err = OMX_FillThisBuffer(appPriv->videodechandle, outBufferVideoDec[0]);
01926 } else {
01927 outBufferVideoDec[1]->nFilledLen = pBuffer->nFilledLen;
01928 err = OMX_FillThisBuffer(appPriv->videodechandle, outBufferVideoDec[1]);
01929 }
01930 if(err != OMX_ErrorNone) {
01931 DEBUG(DEB_LEV_ERR, "In %s Error %08x Calling FillThisBuffer\n", __func__,err);
01932 }
01933 } else {
01934 DEBUG(DEB_LEV_ERR, "In %s: eos=%x Dropping Fill This Buffer\n", __func__,(int)pBuffer->nFlags);
01935 iBufferDropped++;
01936 if(iBufferDropped == 2) {
01937 tsem_up(appPriv->eofSem);
01938 }
01939 }
01940 } else {
01941 if(!bEOS) {
01942 tsem_up(appPriv->eofSem);
01943 }
01944 DEBUG(DEB_LEV_ERR, "Ouch! In %s: had NULL buffer to output...\n", __func__);
01945 }
01946 return OMX_ErrorNone;
01947 }
01948
01949 OMX_ERRORTYPE colorconvFillBufferDone(
01950 OMX_OUT OMX_HANDLETYPE hComponent,
01951 OMX_OUT OMX_PTR pAppData,
01952 OMX_OUT OMX_BUFFERHEADERTYPE* pBuffer) {
01953
01954 OMX_ERRORTYPE err;
01955 if(pBuffer != NULL) {
01956 if(!bEOS) {
01960 if(flagIsDisplayRequested && (!flagSetupTunnel)) {
01961 if(inBufferSinkVideo[0]->pBuffer == pBuffer->pBuffer) {
01962 inBufferSinkVideo[0]->nFilledLen = pBuffer->nFilledLen;
01963 err = OMX_EmptyThisBuffer(appPriv->videosinkhandle, inBufferSinkVideo[0]);
01964 } else {
01965 inBufferSinkVideo[1]->nFilledLen = pBuffer->nFilledLen;
01966 err = OMX_EmptyThisBuffer(appPriv->videosinkhandle, inBufferSinkVideo[1]);
01967 }
01968 if(err != OMX_ErrorNone) {
01969 DEBUG(DEB_LEV_ERR, "In %s Error %08x Calling FillThisBuffer\n", __func__,err);
01970 }
01971 } else if((pBuffer->nFilledLen > 0) && (!flagSetupTunnel)) {
01972 fwrite(pBuffer->pBuffer, sizeof(char), pBuffer->nFilledLen, outfileVideo);
01973 pBuffer->nFilledLen = 0;
01974 }
01975 if(pBuffer->nFlags == OMX_BUFFERFLAG_EOS) {
01976 DEBUG(DEB_LEV_ERR, "In %s: eos=%x Calling Empty This Buffer\n", __func__, (int)pBuffer->nFlags);
01977 bEOS = OMX_TRUE;
01978 }
01979 if(!bEOS && !flagIsDisplayRequested && (!flagSetupTunnel)) {
01980 err = OMX_FillThisBuffer(hComponent, pBuffer);
01981 }
01982 } else {
01983 DEBUG(DEB_LEV_ERR, "In %s: eos=%x Dropping Empty This Buffer\n", __func__,(int)pBuffer->nFlags);
01984 }
01985 } else {
01986 DEBUG(DEB_LEV_ERR, "Ouch! In %s: had NULL buffer to output...\n", __func__);
01987 }
01988 return OMX_ErrorNone;
01989 }
01990
01992 OMX_ERRORTYPE fb_sinkEventHandler(
01993 OMX_OUT OMX_HANDLETYPE hComponent,
01994 OMX_OUT OMX_PTR pAppData,
01995 OMX_OUT OMX_EVENTTYPE eEvent,
01996 OMX_OUT OMX_U32 Data1,
01997 OMX_OUT OMX_U32 Data2,
01998 OMX_OUT OMX_PTR pEventData) {
01999
02000 DEBUG(DEB_LEV_SIMPLE_SEQ, "Hi there, I am in the %s callback\n", __func__);
02001 if(eEvent == OMX_EventCmdComplete) {
02002 if (Data1 == OMX_CommandStateSet) {
02003 DEBUG(DEB_LEV_SIMPLE_SEQ, "State changed in ");
02004 switch ((int)Data2) {
02005 case OMX_StateInvalid:
02006 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateInvalid\n");
02007 break;
02008 case OMX_StateLoaded:
02009 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateLoaded\n");
02010 break;
02011 case OMX_StateIdle:
02012 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateIdle ---- fbsink\n");
02013 break;
02014 case OMX_StateExecuting:
02015 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateExecuting\n");
02016 break;
02017 case OMX_StatePause:
02018 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StatePause\n");
02019 break;
02020 case OMX_StateWaitForResources:
02021 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateWaitForResources\n");
02022 break;
02023 }
02024 tsem_up(appPriv->fbdevSinkEventSem);
02025 }
02026 else if (OMX_CommandPortEnable || OMX_CommandPortDisable) {
02027 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s Received Port Enable/Disable Event\n",__func__);
02028 tsem_up(appPriv->fbdevSinkEventSem);
02029 }
02030 } else if(eEvent == OMX_EventBufferFlag) {
02031 DEBUG(DEB_LEV_ERR, "In %s OMX_BUFFERFLAG_EOS\n", __func__);
02032 if((int)Data2 == OMX_BUFFERFLAG_EOS) {
02033 tsem_up(appPriv->eofSem);
02034 }
02035 } else {
02036 DEBUG(DEB_LEV_SIMPLE_SEQ, "Param1 is %i\n", (int)Data1);
02037 DEBUG(DEB_LEV_SIMPLE_SEQ, "Param2 is %i\n", (int)Data2);
02038 }
02039 return OMX_ErrorNone;
02040 }
02041
02042 OMX_ERRORTYPE fb_sinkEmptyBufferDone(
02043 OMX_OUT OMX_HANDLETYPE hComponent,
02044 OMX_OUT OMX_PTR pAppData,
02045 OMX_OUT OMX_BUFFERHEADERTYPE* pBuffer) {
02046
02047 OMX_ERRORTYPE err;
02048 static int inputBufferDropped = 0;
02049 if(pBuffer != NULL) {
02050 if(!bEOS) {
02051 if(outBufferColorconv[0]->pBuffer == pBuffer->pBuffer) {
02052 outBufferColorconv[0]->nFilledLen = pBuffer->nFilledLen;
02053 err = OMX_FillThisBuffer(appPriv->colorconv_handle, outBufferColorconv[0]);
02054 } else {
02055 outBufferColorconv[1]->nFilledLen = pBuffer->nFilledLen;
02056 err = OMX_FillThisBuffer(appPriv->colorconv_handle, outBufferColorconv[1]);
02057 }
02058 if(err != OMX_ErrorNone) {
02059 DEBUG(DEB_LEV_ERR, "In %s Error %08x Calling FillThisBuffer\n", __func__,err);
02060 }
02061 } else {
02062 DEBUG(DEB_LEV_ERR, "In %s: eos=%x Dropping Fill This Buffer\n", __func__,(int)pBuffer->nFlags);
02063 inputBufferDropped++;
02064 if(inputBufferDropped == 2) {
02065 tsem_up(appPriv->eofSem);
02066 }
02067 }
02068 } else {
02069 if(!bEOS) {
02070 tsem_up(appPriv->eofSem);
02071 }
02072 DEBUG(DEB_LEV_ERR, "Ouch! In %s: had NULL buffer to output...\n", __func__);
02073 }
02074 return OMX_ErrorNone;
02075 }
02076
02077 OMX_ERRORTYPE audiodecEventHandler(
02078 OMX_OUT OMX_HANDLETYPE hComponent,
02079 OMX_OUT OMX_PTR pAppData,
02080 OMX_OUT OMX_EVENTTYPE eEvent,
02081 OMX_OUT OMX_U32 Data1,
02082 OMX_OUT OMX_U32 Data2,
02083 OMX_OUT OMX_PTR pEventData)
02084 {
02085 OMX_ERRORTYPE err;
02086 OMX_PARAM_PORTDEFINITIONTYPE param;
02087
02088
02089 DEBUG(DEB_LEV_SIMPLE_SEQ, "Hi there, I am in the %s callback\n", __func__);
02090 if(eEvent == OMX_EventCmdComplete) {
02091 if (Data1 == OMX_CommandStateSet) {
02092 DEBUG(DEB_LEV_SIMPLE_SEQ, "Audio Decoder State changed in ");
02093 switch ((int)Data2) {
02094 case OMX_StateInvalid:
02095 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateInvalid\n");
02096 break;
02097 case OMX_StateLoaded:
02098 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateLoaded\n");
02099 break;
02100 case OMX_StateIdle:
02101 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateIdle\n");
02102 break;
02103 case OMX_StateExecuting:
02104 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateExecuting\n");
02105 break;
02106 case OMX_StatePause:
02107 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StatePause\n");
02108 break;
02109 case OMX_StateWaitForResources:
02110 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateWaitForResources\n");
02111 break;
02112 }
02113 tsem_up(appPriv->audioDecoderEventSem);
02114 }
02115 else if (Data1 == OMX_CommandPortEnable){
02116 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s Received Port Enable Event\n",__func__);
02117 tsem_up(appPriv->audioDecoderEventSem);
02118 } else if (Data1 == OMX_CommandPortDisable){
02119 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s Received Port Disable Event\n",__func__);
02120 tsem_up(appPriv->audioDecoderEventSem);
02121 }
02122 } else if(eEvent == OMX_EventPortSettingsChanged) {
02123 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s Received Port Settings Changed Event\n", __func__);
02124 if (Data2 == 1) {
02125 param.nPortIndex = 1;
02126 setHeader(¶m, sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
02127 err = OMX_GetParameter(appPriv->audiodechandle,OMX_IndexParamPortDefinition, ¶m);
02128 } else if (Data2 == 0) {
02129
02130 param.nPortIndex = 0;
02131 setHeader(¶m, sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
02132 err = OMX_GetParameter(appPriv->audiodechandle,OMX_IndexParamPortDefinition, ¶m);
02133 }
02134 } else if(eEvent == OMX_EventBufferFlag) {
02135 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s OMX_BUFFERFLAG_EOS\n", __func__);
02136 if((int)Data2 == OMX_BUFFERFLAG_EOS) {
02137 tsem_up(appPriv->eofSem);
02138 }
02139 } else {
02140 DEBUG(DEB_LEV_SIMPLE_SEQ, "Param1 is %i\n", (int)Data1);
02141 DEBUG(DEB_LEV_SIMPLE_SEQ, "Param2 is %i\n", (int)Data2);
02142 }
02143
02144 return OMX_ErrorNone;
02145 }
02146
02147 OMX_ERRORTYPE audiodecEmptyBufferDone(
02148 OMX_OUT OMX_HANDLETYPE hComponent,
02149 OMX_OUT OMX_PTR pAppData,
02150 OMX_OUT OMX_BUFFERHEADERTYPE* pBuffer)
02151 {
02152 OMX_ERRORTYPE err;
02153 static int iBufferDropped=0;
02154 DEBUG(DEB_LEV_FULL_SEQ, "Hi there, I am in the %s callback.\n", __func__);
02155
02156 if(pBuffer != NULL){
02157 if(!bEOS) {
02158 if(outBufferParseAudio[0]->pBuffer == pBuffer->pBuffer) {
02159 outBufferParseAudio[0]->nFilledLen=0;
02160 err = OMX_FillThisBuffer(appPriv->parser3gphandle, outBufferParseAudio[0]);
02161 } else {
02162 outBufferParseAudio[1]->nFilledLen=0;
02163 err = OMX_FillThisBuffer(appPriv->parser3gphandle, outBufferParseAudio[1]);
02164 }
02165 if(err != OMX_ErrorNone) {
02166 DEBUG(DEB_LEV_ERR, "In %s Error %08x Calling FillThisBuffer\n", __func__,err);
02167 }
02168 }
02169 else {
02170 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s: eos=%x Dropping Fill This Buffer\n", __func__,(int)pBuffer->nFlags);
02171 iBufferDropped++;
02172 if(iBufferDropped==2) {
02173 tsem_up(appPriv->eofSem);
02174 }
02175 }
02176 } else {
02177 if(!bEOS) {
02178 DEBUG(DEB_LEV_SIMPLE_SEQ,"It is here EOS = %d\n",appPriv->eofSem->semval);
02179 tsem_up(appPriv->eofSem);
02180 }
02181 DEBUG(DEB_LEV_ERR, "Ouch! In %s: had NULL buffer to output...\n", __func__);
02182 }
02183 return OMX_ErrorNone;
02184 }
02185
02186 OMX_ERRORTYPE audiodecFillBufferDone(
02187 OMX_OUT OMX_HANDLETYPE hComponent,
02188 OMX_OUT OMX_PTR pAppData,
02189 OMX_OUT OMX_BUFFERHEADERTYPE* pBuffer)
02190 {
02191 OMX_ERRORTYPE err;
02192 int i;
02193 DEBUG(DEB_LEV_FUNCTION_NAME, "In %s \n",__func__);
02194
02195 if(pBuffer != NULL){
02196 if(!bEOS) {
02197 if (pBuffer->nFilledLen == 0) {
02198 DEBUG(DEB_LEV_ERR, "Ouch! In %s: had 0 data size in output buffer...\n", __func__);
02199 return OMX_ErrorNone;
02200 }
02201 if ((!flagDecodedOutputReceived) && (!flagIsDisplayRequested)) {
02202 for(i = 0; i<pBuffer->nFilledLen; i++){
02203 putchar(*(char*)(pBuffer->pBuffer + i));
02204 }
02205 pBuffer->nFilledLen = 0;
02206 err = OMX_FillThisBuffer(hComponent, pBuffer);
02207 if(err != OMX_ErrorNone) {
02208 DEBUG(DEB_LEV_ERR, "In %s Error %08x Calling FillThisBuffer\n", __func__,err);
02209 }
02210 } else if ((flagDecodedOutputReceived) && (!flagIsDisplayRequested)) {
02211 if(pBuffer->nFilledLen > 0) {
02212 fwrite(pBuffer->pBuffer, 1, pBuffer->nFilledLen, outfileAudio);
02213 }
02214 pBuffer->nFilledLen = 0;
02215 err = OMX_FillThisBuffer(hComponent, pBuffer);
02216 if(err != OMX_ErrorNone) {
02217 DEBUG(DEB_LEV_ERR, "In %s Error %08x Calling FillThisBuffer\n", __func__,err);
02218 }
02219 } else if ((!flagSetupTunnel) && (flagIsDisplayRequested)) {
02220 if(inBufferVolume[0]->pBuffer == pBuffer->pBuffer) {
02221 inBufferVolume[0]->nFilledLen = pBuffer->nFilledLen;
02222 err = OMX_EmptyThisBuffer(appPriv->volumehandle, inBufferVolume[0]);
02223 } else {
02224 inBufferVolume[1]->nFilledLen = pBuffer->nFilledLen;
02225 err = OMX_EmptyThisBuffer(appPriv->volumehandle, inBufferVolume[1]);
02226 }
02227 if(err != OMX_ErrorNone) {
02228 DEBUG(DEB_LEV_ERR, "In %s Error %08x Calling EmptyThisBuffer\n", __func__,err);
02229 }
02230 }
02231 } else {
02232 DEBUG(DEB_LEV_ERR, " Buffer Dropping ...\n");
02233 }
02234 } else {
02235 DEBUG(DEB_LEV_ERR, "Ouch! In %s: had NULL buffer to output...\n", __func__);
02236 }
02237 return OMX_ErrorNone;
02238 }
02239
02240 OMX_ERRORTYPE volumeEventHandler(
02241 OMX_OUT OMX_HANDLETYPE hComponent,
02242 OMX_OUT OMX_PTR pAppData,
02243 OMX_OUT OMX_EVENTTYPE eEvent,
02244 OMX_OUT OMX_U32 Data1,
02245 OMX_OUT OMX_U32 Data2,
02246 OMX_OUT OMX_PTR pEventData)
02247 {
02248
02249 DEBUG(DEB_LEV_SIMPLE_SEQ, "Hi there, I am in the %s callback\n", __func__);
02250 if(eEvent == OMX_EventCmdComplete) {
02251 if (Data1 == OMX_CommandStateSet) {
02252 DEBUG(DEB_LEV_SIMPLE_SEQ, "Audio Decoder State changed in ");
02253 switch ((int)Data2) {
02254 case OMX_StateInvalid:
02255 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateInvalid\n");
02256 break;
02257 case OMX_StateLoaded:
02258 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateLoaded\n");
02259 break;
02260 case OMX_StateIdle:
02261 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateIdle\n");
02262 break;
02263 case OMX_StateExecuting:
02264 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateExecuting\n");
02265 break;
02266 case OMX_StatePause:
02267 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StatePause\n");
02268 break;
02269 case OMX_StateWaitForResources:
02270 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateWaitForResources\n");
02271 break;
02272 }
02273 tsem_up(appPriv->volumeEventSem);
02274 } else if (Data1 == OMX_CommandPortEnable){
02275 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s Received Port Enable Event\n",__func__);
02276 tsem_up(appPriv->volumeEventSem);
02277 } else if (Data1 == OMX_CommandPortDisable){
02278 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s Received Port Disable Event\n",__func__);
02279 tsem_up(appPriv->volumeEventSem);
02280 }
02281 } else if(eEvent == OMX_EventBufferFlag) {
02282 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s OMX_BUFFERFLAG_EOS\n", __func__);
02283 if((int)Data2 == OMX_BUFFERFLAG_EOS) {
02284 tsem_up(appPriv->eofSem);
02285 }
02286 } else {
02287 DEBUG(DEB_LEV_SIMPLE_SEQ, "Param1 is %i\n", (int)Data1);
02288 DEBUG(DEB_LEV_SIMPLE_SEQ, "Param2 is %i\n", (int)Data2);
02289 }
02290
02291 return OMX_ErrorNone;
02292 }
02293 OMX_ERRORTYPE volumeEmptyBufferDone(
02294 OMX_OUT OMX_HANDLETYPE hComponent,
02295 OMX_OUT OMX_PTR pAppData,
02296 OMX_OUT OMX_BUFFERHEADERTYPE* pBuffer)
02297 {
02298 OMX_ERRORTYPE err;
02299 static int iBufferDropped=0;
02300 DEBUG(DEB_LEV_FULL_SEQ, "Hi there, I am in the %s callback.\n", __func__);
02301
02302 if(pBuffer != NULL){
02303 if(!bEOS) {
02304 if(outBufferAudioDec[0]->pBuffer == pBuffer->pBuffer) {
02305 outBufferAudioDec[0]->nFilledLen=0;
02306 err = OMX_FillThisBuffer(appPriv->audiodechandle, outBufferAudioDec[0]);
02307 } else {
02308 outBufferAudioDec[1]->nFilledLen=0;
02309 err = OMX_FillThisBuffer(appPriv->audiodechandle, outBufferAudioDec[1]);
02310 }
02311 if(err != OMX_ErrorNone) {
02312 DEBUG(DEB_LEV_ERR, "In %s Error %08x Calling FillThisBuffer\n", __func__,err);
02313 }
02314 }
02315 else {
02316 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s: eos=%x Dropping Fill This Buffer\n", __func__,(int)pBuffer->nFlags);
02317 iBufferDropped++;
02318 if(iBufferDropped==2) {
02319 tsem_up(appPriv->eofSem);
02320 }
02321 }
02322 } else {
02323 if(!bEOS) {
02324 DEBUG(DEFAULT_MESSAGES,"It is here EOS = %d\n",appPriv->eofSem->semval);
02325 tsem_up(appPriv->eofSem);
02326 }
02327 DEBUG(DEB_LEV_ERR, "Ouch! In %s: had NULL buffer to output...\n", __func__);
02328 }
02329 return OMX_ErrorNone;
02330 }
02331
02332 OMX_ERRORTYPE volumeFillBufferDone(
02333 OMX_OUT OMX_HANDLETYPE hComponent,
02334 OMX_OUT OMX_PTR pAppData,
02335 OMX_OUT OMX_BUFFERHEADERTYPE* pBuffer)
02336 {
02337 OMX_ERRORTYPE err;
02338 int i;
02339 static int volCompBufferDropped=0;
02340 DEBUG(DEB_LEV_FUNCTION_NAME, "In %s \n",__func__);
02341
02342 if(pBuffer != NULL){
02343 if (pBuffer->nFilledLen == 0) {
02344 DEBUG(DEB_LEV_ERR, "Ouch! In %s: had 0 data size in output buffer...\n", __func__);
02345 return OMX_ErrorNone;
02346 }
02347 if ((!flagDecodedOutputReceived) && (!flagIsDisplayRequested) ) {
02348 for(i = 0; i<pBuffer->nFilledLen; i++){
02349 putchar(*(char*)(pBuffer->pBuffer + i));
02350 }
02351 pBuffer->nFilledLen = 0;
02352 err = OMX_FillThisBuffer(hComponent, pBuffer);
02353 if(err != OMX_ErrorNone) {
02354 DEBUG(DEB_LEV_ERR, "In %s Error %08x Calling FillThisBuffer\n", __func__,err);
02355 }
02356 } else if (flagDecodedOutputReceived && (!flagIsDisplayRequested) ) {
02357 if(pBuffer->nFilledLen > 0) {
02358 fwrite(pBuffer->pBuffer, 1, pBuffer->nFilledLen, outfileAudio);
02359 }
02360 pBuffer->nFilledLen = 0;
02361 err = OMX_FillThisBuffer(hComponent, pBuffer);
02362 if(err != OMX_ErrorNone) {
02363 DEBUG(DEB_LEV_ERR, "In %s Error %08x Calling FillThisBuffer\n", __func__,err);
02364 }
02365 } else if ((!flagSetupTunnel) && (flagIsDisplayRequested )) {
02366 if(!bEOS) {
02367 if(inBufferSinkAudio[0]->pBuffer == pBuffer->pBuffer) {
02368 inBufferSinkAudio[0]->nFilledLen = pBuffer->nFilledLen;
02369 err = OMX_EmptyThisBuffer(appPriv->audiosinkhandle, inBufferSinkAudio[0]);
02370 } else {
02371 inBufferSinkAudio[1]->nFilledLen = pBuffer->nFilledLen;
02372 err = OMX_EmptyThisBuffer(appPriv->audiosinkhandle, inBufferSinkAudio[1]);
02373 }
02374 if(err != OMX_ErrorNone) {
02375 DEBUG(DEB_LEV_ERR, "In %s Error %08x Calling EmptyThisBuffer\n", __func__,err);
02376 }
02377 } else {
02378 DEBUG(DEFAULT_MESSAGES,"In %s EOS reached\n",__func__);
02379 volCompBufferDropped++;
02380 if(volCompBufferDropped==2) {
02381 tsem_up(appPriv->eofSem);
02382 }
02383 }
02384
02385 }
02386 } else {
02387 DEBUG(DEB_LEV_ERR, "Ouch! In %s: had NULL buffer to output...\n", __func__);
02388 }
02389 return OMX_ErrorNone;
02390 }
02391
02392 OMX_ERRORTYPE audiosinkEventHandler(
02393 OMX_OUT OMX_HANDLETYPE hComponent,
02394 OMX_OUT OMX_PTR pAppData,
02395 OMX_OUT OMX_EVENTTYPE eEvent,
02396 OMX_OUT OMX_U32 Data1,
02397 OMX_OUT OMX_U32 Data2,
02398 OMX_OUT OMX_PTR pEventData) {
02399 DEBUG(DEB_LEV_SIMPLE_SEQ, "Hi there, I am in the %s callback\n", __func__);
02400 if (Data1 == OMX_CommandStateSet) {
02401 DEBUG(DEB_LEV_SIMPLE_SEQ, "Audio Sink State changed in ");
02402 switch ((int)Data2) {
02403 case OMX_StateInvalid:
02404 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateInvalid\n");
02405 break;
02406 case OMX_StateLoaded:
02407 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateLoaded\n");
02408 break;
02409 case OMX_StateIdle:
02410 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateIdle\n");
02411 break;
02412 case OMX_StateExecuting:
02413 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateExecuting\n");
02414 break;
02415 case OMX_StatePause:
02416 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StatePause\n");
02417 break;
02418 case OMX_StateWaitForResources:
02419 DEBUG(DEB_LEV_SIMPLE_SEQ, "OMX_StateWaitForResources\n");
02420 break;
02421 }
02422 tsem_up(appPriv->audioSinkEventSem);
02423 } else if (Data1 == OMX_CommandPortEnable){
02424 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s Received Port Enable Event\n",__func__);
02425 tsem_up(appPriv->audioSinkEventSem);
02426 } else if (Data1 == OMX_CommandPortDisable){
02427 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s Received Port Disable Event\n",__func__);
02428 tsem_up(appPriv->audioSinkEventSem);
02429 } else {
02430 DEBUG(DEB_LEV_SIMPLE_SEQ, "Param1 is %i\n", (int)Data1);
02431 DEBUG(DEB_LEV_SIMPLE_SEQ, "Param2 is %i\n", (int)Data2);
02432 }
02433
02434 return OMX_ErrorNone;
02435 }
02436
02437 OMX_ERRORTYPE audiosinkEmptyBufferDone(
02438 OMX_OUT OMX_HANDLETYPE hComponent,
02439 OMX_OUT OMX_PTR pAppData,
02440 OMX_OUT OMX_BUFFERHEADERTYPE* pBuffer)
02441 {
02442 OMX_ERRORTYPE err;
02443 static int alsaSinkBufferDropped=0;
02444 DEBUG(DEB_LEV_FULL_SEQ, "Hi there, I am in the %s callback.\n", __func__);
02445
02446 DEBUG(DEB_LEV_PARAMS, "Empty buffer %x\n", (int)pBuffer);
02447 if(!bEOS) {
02448 if(outBufferVolume[0]->pBuffer == pBuffer->pBuffer) {
02449 outBufferVolume[0]->nFilledLen=0;
02450 err = OMX_FillThisBuffer(appPriv->volumehandle, outBufferVolume[0]);
02451 } else {
02452 outBufferVolume[1]->nFilledLen=0;
02453 err = OMX_FillThisBuffer(appPriv->volumehandle, outBufferVolume[1]);
02454 }
02455 if(err != OMX_ErrorNone) {
02456 DEBUG(DEB_LEV_ERR, "In %s Error %08x Calling FillThisBuffer\n", __func__,err);
02457 }
02458 } else {
02459 DEBUG(DEFAULT_MESSAGES,"In %s EOS reached\n",__func__);
02460 alsaSinkBufferDropped++;
02461 if(alsaSinkBufferDropped==2) {
02462 tsem_up(appPriv->eofSem);
02463 }
02464 }
02465
02466 return OMX_ErrorNone;
02467 }
02468
02469