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 <string.h>
21 #include <OMXAL/OpenMAXAL.h>
22 #include <OMXAL/OpenMAXAL_Android.h>
23 
main(int argc __unused,char ** argv __unused)24 int main(int argc __unused, char **argv __unused)
25 {
26     XAresult result;
27     XAObjectItf engineObject;
28     printf("xaCreateEngine\n");
29     result = xaCreateEngine(&engineObject, 0, NULL, 0, NULL, NULL);
30     printf("result = %d\n", result);
31     assert(XA_RESULT_SUCCESS == result);
32     printf("engineObject = %p\n", engineObject);
33     printf("realize\n");
34     result = (*engineObject)->Realize(engineObject, XA_BOOLEAN_FALSE);
35     printf("result = %d\n", result);
36     printf("GetInterface for ENGINE\n");
37     XAEngineItf engineEngine;
38     result = (*engineObject)->GetInterface(engineObject, XA_IID_ENGINE, &engineEngine);
39     printf("result = %d\n", result);
40     printf("engineEngine = %p\n", engineEngine);
41     assert(XA_RESULT_SUCCESS == result);
42 
43     XAObjectItf outputMixObject;
44     printf("CreateOutputMix");
45     result = (*engineEngine)->CreateOutputMix(engineEngine, &outputMixObject, 0, NULL, NULL);
46     printf("result = %d, outputMixObject=%p\n", result, outputMixObject);
47     result = (*outputMixObject)->Realize(outputMixObject, XA_BOOLEAN_FALSE);
48     printf("result = %d\n", result);
49 
50     XAObjectItf deviceObject;
51     printf("CreateCameraDevice\n");
52     result = (*engineEngine)->CreateCameraDevice(engineEngine, &deviceObject,
53             XA_DEFAULTDEVICEID_CAMERA, 0, NULL, NULL);
54     printf("result = %d, deviceObject=%p\n", result, deviceObject);
55 
56     printf("CreateRadioDevice\n");
57     result = (*engineEngine)->CreateRadioDevice(engineEngine, &deviceObject, 0, NULL, NULL);
58     printf("result = %d, deviceObject=%p\n", result, deviceObject);
59 
60     printf("CreateLEDDevice\n");
61     result = (*engineEngine)->CreateLEDDevice(engineEngine, &deviceObject, XA_DEFAULTDEVICEID_LED,
62             0, NULL, NULL);
63     printf("result = %d, deviceObject=%p\n", result, deviceObject);
64 
65     printf("CreateVibraDevice\n");
66     result = (*engineEngine)->CreateVibraDevice(engineEngine, &deviceObject,
67             XA_DEFAULTDEVICEID_VIBRA, 0, NULL, NULL);
68     printf("result = %d, deviceObject=%p\n", result, deviceObject);
69 
70     printf("CreateMediaPlayer\n");
71     XAObjectItf playerObject;
72 #if 1
73     XADataLocator_AndroidBufferQueue locABQ;
74     memset(&locABQ, 0, sizeof(locABQ));
75     locABQ.locatorType = XA_DATALOCATOR_ANDROIDBUFFERQUEUE;
76 #else
77     XADataLocator_URI locUri;
78     locUri.locatorType = XA_DATALOCATOR_URI;
79     locUri.URI = (XAchar *) "/sdcard/hello.wav";
80 #endif
81     XADataFormat_MIME fmtMime;
82     fmtMime.formatType = XA_DATAFORMAT_MIME;
83     fmtMime.mimeType = NULL;
84     fmtMime.containerType = XA_CONTAINERTYPE_UNSPECIFIED;
85     XADataSource dataSrc;
86 #if 1
87     dataSrc.pLocator = &locABQ;
88 #else
89     dataSrc.pLocator = &locUri;
90 #endif
91     dataSrc.pFormat = &fmtMime;
92     XADataSink audioSnk;
93     XADataLocator_OutputMix locOM;
94     locOM.locatorType = XA_DATALOCATOR_OUTPUTMIX;
95     locOM.outputMix = outputMixObject;
96     audioSnk.pLocator = &locOM;
97     audioSnk.pFormat = NULL;
98     XADataLocator_NativeDisplay locND;
99     locND.locatorType = XA_DATALOCATOR_NATIVEDISPLAY;
100     locND.hWindow = NULL;
101     locND.hDisplay = NULL;
102     XADataSink imageVideoSink;
103     imageVideoSink.pLocator = &locND;
104     imageVideoSink.pFormat = NULL;
105     result = (*engineEngine)->CreateMediaPlayer(engineEngine, &playerObject, &dataSrc, NULL,
106             &audioSnk, &imageVideoSink, NULL, NULL, 0, NULL, NULL);
107     printf("result = %d, playerObject=%p\n", result, playerObject);
108     result = (*playerObject)->Realize(playerObject, XA_BOOLEAN_FALSE);
109     printf("result = %d\n", result);
110 
111     printf("GetInterface for PLAY\n");
112     XAPlayItf playerPlay;
113     result = (*playerObject)->GetInterface(playerObject, XA_IID_PLAY, &playerPlay);
114     printf("result = %d\n", result);
115     printf("playerPlay = %p\n", playerPlay);
116     assert(XA_RESULT_SUCCESS == result);
117 
118     printf("SetPlayState to PLAYING\n");
119     result = (*playerPlay)->SetPlayState(playerPlay, XA_PLAYSTATE_PLAYING);
120     printf("result = %d\n", result);
121     assert(XA_RESULT_SUCCESS == result);
122 
123     printf("destroying media player\n");
124     (*playerObject)->Destroy(playerObject);
125 
126     printf("destroying output mix\n");
127     (*outputMixObject)->Destroy(outputMixObject);
128 
129     printf("destroying engine\n");
130     (*engineObject)->Destroy(engineObject);
131     printf("exit\n");
132 
133     return EXIT_SUCCESS;
134 }
135