xa.c revision 94a37e8117fb72790882dfb815f99e2365754c74
1#include <assert.h> 2#include <stdio.h> 3#include <stdlib.h> 4#include "OMXAL/OpenMAXAL.h" 5 6int main(int argc, char **argv) 7{ 8 XAresult result; 9 XAObjectItf engineObject; 10 printf("xaCreateEngine\n"); 11 result = xaCreateEngine(&engineObject, 0, NULL, 0, NULL, NULL); 12 printf("result = %ld\n", result); 13 assert(XA_RESULT_SUCCESS == result); 14 printf("engineObject = %p\n", engineObject); 15 printf("realize\n"); 16 result = (*engineObject)->Realize(engineObject, XA_BOOLEAN_FALSE); 17 printf("result = %ld\n", result); 18 printf("GetInterface for ENGINE\n"); 19 XAEngineItf engineEngine; 20 result = (*engineObject)->GetInterface(engineObject, XA_IID_ENGINE, &engineEngine); 21 printf("result = %ld\n", result); 22 printf("engineEngine = %p\n", engineEngine); 23 assert(XA_RESULT_SUCCESS == result); 24 25 XAObjectItf outputMixObject; 26 printf("CreateOutputMix"); 27 result = (*engineEngine)->CreateOutputMix(engineEngine, &outputMixObject, 0, NULL, NULL); 28 printf("result = %ld, outputMixObject=%p\n", result, outputMixObject); 29 result = (*outputMixObject)->Realize(outputMixObject, XA_BOOLEAN_FALSE); 30 printf("result = %ld\n", result); 31 32 XAObjectItf deviceObject; 33 printf("CreateCameraDevice\n"); 34 result = (*engineEngine)->CreateCameraDevice(engineEngine, &deviceObject, 35 XA_DEFAULTDEVICEID_CAMERA, 0, NULL, NULL); 36 printf("result = %ld, deviceObject=%p\n", result, deviceObject); 37 38 printf("CreateRadioDevice\n"); 39 result = (*engineEngine)->CreateRadioDevice(engineEngine, &deviceObject, 0, NULL, NULL); 40 printf("result = %ld, deviceObject=%p\n", result, deviceObject); 41 42 printf("CreateLEDDevice\n"); 43 result = (*engineEngine)->CreateLEDDevice(engineEngine, &deviceObject, XA_DEFAULTDEVICEID_LED, 44 0, NULL, NULL); 45 printf("result = %ld, deviceObject=%p\n", result, deviceObject); 46 47 printf("CreateVibraDevice\n"); 48 result = (*engineEngine)->CreateVibraDevice(engineEngine, &deviceObject, 49 XA_DEFAULTDEVICEID_VIBRA, 0, NULL, NULL); 50 printf("result = %ld, deviceObject=%p\n", result, deviceObject); 51 52 printf("CreateMediaPlayer\n"); 53 XAObjectItf playerObject; 54 XADataLocator_URI locUri; 55 locUri.locatorType = XA_DATALOCATOR_URI; 56 locUri.URI = (XAchar *) "/sdcard/hello.wav"; 57 XADataFormat_MIME fmtMime; 58 fmtMime.formatType = XA_DATAFORMAT_MIME; 59 fmtMime.mimeType = NULL; 60 fmtMime.containerType = XA_CONTAINERTYPE_UNSPECIFIED; 61 XADataSource dataSrc; 62 dataSrc.pLocator = &locUri; 63 dataSrc.pFormat = &fmtMime; 64 XADataSink audioSnk; 65 XADataLocator_OutputMix locOM; 66 locOM.locatorType = XA_DATALOCATOR_OUTPUTMIX; 67 locOM.outputMix = outputMixObject; 68 audioSnk.pLocator = &locOM; 69 audioSnk.pFormat = NULL; 70 XADataLocator_NativeDisplay locND; 71 locND.locatorType = XA_DATALOCATOR_NATIVEDISPLAY; 72 locND.hWindow = NULL; 73 locND.hDisplay = NULL; 74 XADataSink imageVideoSink; 75 imageVideoSink.pLocator = &locND; 76 imageVideoSink.pFormat = NULL; 77 result = (*engineEngine)->CreateMediaPlayer(engineEngine, &playerObject, &dataSrc, NULL, 78 &audioSnk, &imageVideoSink, NULL, NULL, 0, NULL, NULL); 79 printf("result = %ld, playerObject=%p\n", result, playerObject); 80 result = (*playerObject)->Realize(playerObject, XA_BOOLEAN_FALSE); 81 printf("result = %ld\n", result); 82 83 printf("GetInterface for PLAY\n"); 84 XAPlayItf playerPlay; 85 result = (*playerObject)->GetInterface(playerObject, XA_IID_PLAY, &playerPlay); 86 printf("result = %ld\n", result); 87 printf("playerPlay = %p\n", playerPlay); 88 assert(XA_RESULT_SUCCESS == result); 89 90 printf("SetPlayState to PLAYING\n"); 91 result = (*playerPlay)->SetPlayState(playerPlay, XA_PLAYSTATE_PLAYING); 92 printf("result = %ld\n", result); 93 assert(XA_RESULT_SUCCESS == result); 94 95 printf("destroying media player\n"); 96 (*playerObject)->Destroy(playerObject); 97 98 printf("destroying output mix\n"); 99 (*outputMixObject)->Destroy(outputMixObject); 100 101 printf("destroying engine\n"); 102 (*engineObject)->Destroy(engineObject); 103 printf("exit\n"); 104 105 return EXIT_SUCCESS; 106} 107