1 /* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #include <assert.h> 18 #include <stdio.h> 19 #include <stdlib.h> 20 #include <OMXAL/OpenMAXAL.h> 21 #include <OMXAL/OpenMAXAL_Android.h> 22 23 int main(int argc, char **argv) 24 { 25 XAresult result; 26 XAObjectItf engineObject; 27 printf("xaCreateEngine\n"); 28 result = xaCreateEngine(&engineObject, 0, NULL, 0, NULL, NULL); 29 printf("result = %d\n", result); 30 assert(XA_RESULT_SUCCESS == result); 31 printf("engineObject = %p\n", engineObject); 32 printf("realize\n"); 33 result = (*engineObject)->Realize(engineObject, XA_BOOLEAN_FALSE); 34 printf("result = %d\n", result); 35 printf("GetInterface for ENGINE\n"); 36 XAEngineItf engineEngine; 37 result = (*engineObject)->GetInterface(engineObject, XA_IID_ENGINE, &engineEngine); 38 printf("result = %d\n", result); 39 printf("engineEngine = %p\n", engineEngine); 40 assert(XA_RESULT_SUCCESS == result); 41 42 XAObjectItf outputMixObject; 43 printf("CreateOutputMix"); 44 result = (*engineEngine)->CreateOutputMix(engineEngine, &outputMixObject, 0, NULL, NULL); 45 printf("result = %d, outputMixObject=%p\n", result, outputMixObject); 46 result = (*outputMixObject)->Realize(outputMixObject, XA_BOOLEAN_FALSE); 47 printf("result = %d\n", result); 48 49 XAObjectItf deviceObject; 50 printf("CreateCameraDevice\n"); 51 result = (*engineEngine)->CreateCameraDevice(engineEngine, &deviceObject, 52 XA_DEFAULTDEVICEID_CAMERA, 0, NULL, NULL); 53 printf("result = %d, deviceObject=%p\n", result, deviceObject); 54 55 printf("CreateRadioDevice\n"); 56 result = (*engineEngine)->CreateRadioDevice(engineEngine, &deviceObject, 0, NULL, NULL); 57 printf("result = %d, deviceObject=%p\n", result, deviceObject); 58 59 printf("CreateLEDDevice\n"); 60 result = (*engineEngine)->CreateLEDDevice(engineEngine, &deviceObject, XA_DEFAULTDEVICEID_LED, 61 0, NULL, NULL); 62 printf("result = %d, deviceObject=%p\n", result, deviceObject); 63 64 printf("CreateVibraDevice\n"); 65 result = (*engineEngine)->CreateVibraDevice(engineEngine, &deviceObject, 66 XA_DEFAULTDEVICEID_VIBRA, 0, NULL, NULL); 67 printf("result = %d, deviceObject=%p\n", result, deviceObject); 68 69 printf("CreateMediaPlayer\n"); 70 XAObjectItf playerObject; 71 #if 1 72 XADataLocator_AndroidBufferQueue locABQ; 73 memset(&locABQ, 0, sizeof(locABQ)); 74 locABQ.locatorType = XA_DATALOCATOR_ANDROIDBUFFERQUEUE; 75 #else 76 XADataLocator_URI locUri; 77 locUri.locatorType = XA_DATALOCATOR_URI; 78 locUri.URI = (XAchar *) "/sdcard/hello.wav"; 79 #endif 80 XADataFormat_MIME fmtMime; 81 fmtMime.formatType = XA_DATAFORMAT_MIME; 82 fmtMime.mimeType = NULL; 83 fmtMime.containerType = XA_CONTAINERTYPE_UNSPECIFIED; 84 XADataSource dataSrc; 85 #if 1 86 dataSrc.pLocator = &locABQ; 87 #else 88 dataSrc.pLocator = &locUri; 89 #endif 90 dataSrc.pFormat = &fmtMime; 91 XADataSink audioSnk; 92 XADataLocator_OutputMix locOM; 93 locOM.locatorType = XA_DATALOCATOR_OUTPUTMIX; 94 locOM.outputMix = outputMixObject; 95 audioSnk.pLocator = &locOM; 96 audioSnk.pFormat = NULL; 97 XADataLocator_NativeDisplay locND; 98 locND.locatorType = XA_DATALOCATOR_NATIVEDISPLAY; 99 locND.hWindow = NULL; 100 locND.hDisplay = NULL; 101 XADataSink imageVideoSink; 102 imageVideoSink.pLocator = &locND; 103 imageVideoSink.pFormat = NULL; 104 result = (*engineEngine)->CreateMediaPlayer(engineEngine, &playerObject, &dataSrc, NULL, 105 &audioSnk, &imageVideoSink, NULL, NULL, 0, NULL, NULL); 106 printf("result = %d, playerObject=%p\n", result, playerObject); 107 result = (*playerObject)->Realize(playerObject, XA_BOOLEAN_FALSE); 108 printf("result = %d\n", result); 109 110 printf("GetInterface for PLAY\n"); 111 XAPlayItf playerPlay; 112 result = (*playerObject)->GetInterface(playerObject, XA_IID_PLAY, &playerPlay); 113 printf("result = %d\n", result); 114 printf("playerPlay = %p\n", playerPlay); 115 assert(XA_RESULT_SUCCESS == result); 116 117 printf("SetPlayState to PLAYING\n"); 118 result = (*playerPlay)->SetPlayState(playerPlay, XA_PLAYSTATE_PLAYING); 119 printf("result = %d\n", result); 120 assert(XA_RESULT_SUCCESS == result); 121 122 printf("destroying media player\n"); 123 (*playerObject)->Destroy(playerObject); 124 125 printf("destroying output mix\n"); 126 (*outputMixObject)->Destroy(outputMixObject); 127 128 printf("destroying engine\n"); 129 (*engineObject)->Destroy(engineObject); 130 printf("exit\n"); 131 132 return EXIT_SUCCESS; 133 } 134