xa.c revision 8b8875067dd02b79361abb00c5d65b02a8ae72b0
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
30    XAObjectItf deviceObject;
31    printf("CreateCameraDevice\n");
32    result = (*engineEngine)->CreateCameraDevice(engineEngine, &deviceObject,
33            XA_DEFAULTDEVICEID_CAMERA, 0, NULL, NULL);
34    printf("result = %ld, deviceObject=%p\n", result, deviceObject);
35
36    printf("CreateRadioDevice\n");
37    result = (*engineEngine)->CreateRadioDevice(engineEngine, &deviceObject, 0, NULL, NULL);
38    printf("result = %ld, deviceObject=%p\n", result, deviceObject);
39
40    printf("CreateLEDDevice\n");
41    result = (*engineEngine)->CreateLEDDevice(engineEngine, &deviceObject, XA_DEFAULTDEVICEID_LED,
42            0, NULL, NULL);
43    printf("result = %ld, deviceObject=%p\n", result, deviceObject);
44
45    printf("CreateVibraDevice\n");
46    result = (*engineEngine)->CreateVibraDevice(engineEngine, &deviceObject,
47            XA_DEFAULTDEVICEID_VIBRA, 0, NULL, NULL);
48    printf("result = %ld, deviceObject=%p\n", result, deviceObject);
49
50    printf("CreateMediaPlayer\n");
51    XAObjectItf playerObject;
52    XADataLocator_URI locUri;
53    locUri.locatorType = XA_DATALOCATOR_URI;
54    locUri.URI = (XAchar *) "/sdcard/hello.wav";
55    XADataFormat_MIME fmtMime;
56    fmtMime.formatType = XA_DATAFORMAT_MIME;
57    fmtMime.mimeType = NULL;
58    fmtMime.containerType = XA_CONTAINERTYPE_UNSPECIFIED;
59    XADataSource dataSrc;
60    dataSrc.pLocator = &locUri;
61    dataSrc.pFormat = &fmtMime;
62    XADataSink audioSnk;
63    XADataLocator_OutputMix locOM;
64    locOM.locatorType = XA_DATALOCATOR_OUTPUTMIX;
65    locOM.outputMix = outputMixObject;
66    audioSnk.pLocator = &locOM;
67    audioSnk.pFormat = NULL;
68    XADataLocator_NativeDisplay locND;
69    locND.locatorType = XA_DATALOCATOR_NATIVEDISPLAY;
70    locND.hWindow = NULL;
71    locND.hDisplay = NULL;
72    XADataSink imageVideoSink;
73    imageVideoSink.pLocator = &locND;
74    imageVideoSink.pFormat = NULL;
75    result = (*engineEngine)->CreateMediaPlayer(engineEngine, &playerObject, &dataSrc, NULL,
76            &audioSnk, &imageVideoSink, NULL, NULL, 0, NULL, NULL);
77    printf("result = %ld, playerObject=%p\n", result, playerObject);
78
79    printf("destroying output mix\n");
80    (*outputMixObject)->Destroy(outputMixObject);
81
82    printf("destroying engine\n");
83    (*engineObject)->Destroy(engineObject);
84    printf("exit\n");
85
86    return EXIT_SUCCESS;
87}
88