|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Engine Interface Implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <stdio.h> |
|
19 #include <stdlib.h> |
|
20 #include <assert.h> |
|
21 #include "xaengineitf.h" |
|
22 #include "xaobjects.h" |
|
23 #include "xacapabilitiesmgr.h" |
|
24 /*static XAchar implementationText[] = "Implementation does not conform to AL Spec";*/ |
|
25 |
|
26 /** |
|
27 * XAEngineItfImpl* GetImpl(XAEngineItf self) |
|
28 * Description: Validate interface pointer and cast it to implementation pointer. |
|
29 **/ |
|
30 static XAEngineItfImpl* GetImpl(XAEngineItf self) |
|
31 { |
|
32 if (self) |
|
33 { |
|
34 XAEngineItfImpl* impl = (XAEngineItfImpl*) (*self); |
|
35 if (impl && (impl == impl->self)) |
|
36 { |
|
37 return impl; |
|
38 } |
|
39 } |
|
40 return NULL; |
|
41 } |
|
42 /** |
|
43 * Base interface XAEngineItf implementation |
|
44 */ |
|
45 XAresult XAEngineItfImpl_CreateCameraDevice(XAEngineItf self, |
|
46 XAObjectItf *pDevice, XAuint32 deviceID, XAuint32 numInterfaces, |
|
47 const XAInterfaceID *pInterfaceIds, |
|
48 const XAboolean *pInterfaceRequired) |
|
49 { |
|
50 #ifdef OMAX_CAMERABIN |
|
51 XAEngineItfImpl* impl = GetImpl(self); |
|
52 return XACameraDeviceImpl_CreateCameraDevice( impl->mapper,impl->capabilities, |
|
53 pDevice, deviceID,numInterfaces, |
|
54 pInterfaceIds, pInterfaceRequired ); |
|
55 #else |
|
56 return XA_RESULT_FEATURE_UNSUPPORTED; |
|
57 #endif |
|
58 } |
|
59 |
|
60 XAresult XAEngineItfImpl_CreateRadioDevice(XAEngineItf self, |
|
61 XAObjectItf *pDevice, XAuint32 numInterfaces, |
|
62 const XAInterfaceID *pInterfaceIds, |
|
63 const XAboolean *pInterfaceRequired) |
|
64 { |
|
65 return XARadioDeviceImpl_CreateRadioDevice( /*((XAEngineItfImpl*)self)->mapper,*/ |
|
66 pDevice, numInterfaces, pInterfaceIds, pInterfaceRequired); |
|
67 } |
|
68 |
|
69 XAresult XAEngineItfImpl_CreateLEDDevice(XAEngineItf self, |
|
70 XAObjectItf *pDevice, XAuint32 deviceID, XAuint32 numInterfaces, |
|
71 const XAInterfaceID *pInterfaceIds, |
|
72 const XAboolean *pInterfaceRequired) |
|
73 { |
|
74 return XA_RESULT_FEATURE_UNSUPPORTED; |
|
75 } |
|
76 |
|
77 XAresult XAEngineItfImpl_CreateVibraDevice(XAEngineItf self, |
|
78 XAObjectItf *pDevice, XAuint32 deviceID, XAuint32 numInterfaces, |
|
79 const XAInterfaceID *pInterfaceIds, |
|
80 const XAboolean *pInterfaceRequired) |
|
81 { |
|
82 return XA_RESULT_FEATURE_UNSUPPORTED; |
|
83 } |
|
84 |
|
85 XAresult XAEngineItfImpl_CreateMediaPlayer(XAEngineItf self, |
|
86 XAObjectItf *pPlayer, XADataSource *pDataSrc, XADataSource *pBankSrc, |
|
87 XADataSink *pAudioSnk, XADataSink *pImageVideoSnk, |
|
88 XADataSink *pVibra, XADataSink *pLEDArray, XAuint32 numInterfaces, |
|
89 const XAInterfaceID *pInterfaceIds, |
|
90 const XAboolean *pInterfaceRequired) |
|
91 { |
|
92 XAEngineItfImpl* impl = GetImpl(self); |
|
93 return XAMediaPlayerImpl_CreateMediaPlayer(impl->mapper, |
|
94 impl->capabilities, pPlayer, pDataSrc, pBankSrc, pAudioSnk, |
|
95 pImageVideoSnk, pVibra, pLEDArray, numInterfaces, pInterfaceIds, |
|
96 pInterfaceRequired); |
|
97 } |
|
98 |
|
99 XAresult XAEngineItfImpl_CreateMediaRecorder(XAEngineItf self, |
|
100 XAObjectItf * pRecorder, XADataSource * pAudioSrc, |
|
101 XADataSource * pImageVideoSrc, XADataSink * pDataSnk, |
|
102 XAuint32 numInterfaces, const XAInterfaceID * pInterfaceIds, |
|
103 const XAboolean * pInterfaceRequired) |
|
104 { |
|
105 XAEngineItfImpl* impl = GetImpl(self); |
|
106 return XAMediaRecorderImpl_CreateMediaRecorder(impl->mapper, |
|
107 impl->capabilities, pRecorder, pAudioSrc, pImageVideoSrc, |
|
108 pDataSnk, numInterfaces, pInterfaceIds, pInterfaceRequired); |
|
109 } |
|
110 |
|
111 XAresult XAEngineItfImpl_CreateOutputMix(XAEngineItf self, XAObjectItf *pMix, |
|
112 XAuint32 numInterfaces, const XAInterfaceID *pInterfaceIds, |
|
113 const XAboolean *pInterfaceRequired) |
|
114 { |
|
115 return XA_RESULT_FEATURE_UNSUPPORTED; |
|
116 } |
|
117 |
|
118 XAresult XAEngineItfImpl_CreateMetadataExtractor(XAEngineItf self, |
|
119 XAObjectItf *pMetadataExtractor, XADataSource *pDataSource, |
|
120 XAuint32 numInterfaces, const XAInterfaceID *pInterfaceIds, |
|
121 const XAboolean *pInterfaceRequired) |
|
122 { |
|
123 XAEngineItfImpl* impl = GetImpl(self); |
|
124 return XAMetadataExtractorImpl_Create(impl->mapper, impl->capabilities, |
|
125 pMetadataExtractor, pDataSource, numInterfaces, pInterfaceIds, |
|
126 pInterfaceRequired); |
|
127 } |
|
128 |
|
129 XAresult XAEngineItfImpl_CreateExtensionObject(XAEngineItf self, |
|
130 XAObjectItf *pObject, void *pParameters, XAuint32 objectID, |
|
131 XAuint32 numInterfaces, const XAInterfaceID *pInterfaceIds, |
|
132 const XAboolean *pInterfaceRequired) |
|
133 { |
|
134 DEBUG_API("->XAEngineItfImpl_CreateExtensionObject"); |
|
135 /* no supported extensions */ |
|
136 DEBUG_API("<-XAEngineItfImpl_CreateExtensionObject - XA_RESULT_FEATURE_UNSUPPORTED"); |
|
137 return XA_RESULT_FEATURE_UNSUPPORTED; |
|
138 } |
|
139 |
|
140 XAresult XAEngineItfImpl_GetImplementationInfo(XAEngineItf self, |
|
141 XAuint32 *pMajor, XAuint32 *pMinor, XAuint32 *pStep, |
|
142 const XAchar *pImplementationText) |
|
143 { |
|
144 DEBUG_API("->XAEngineItfImpl_GetImplementationInfo"); |
|
145 |
|
146 if (!pMajor || !pMinor || !pStep) |
|
147 { |
|
148 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
|
149 DEBUG_API("<-XAEngineItfImpl_GetImplementationInfo"); |
|
150 return XA_RESULT_PARAMETER_INVALID; |
|
151 } |
|
152 /* OpenMAX AL API ver 1.0.1 */ |
|
153 *pMajor = 1; |
|
154 *pMinor = 0; |
|
155 *pStep = 1; |
|
156 /*pImplementationText = (XAchar *) implementationText;*/ |
|
157 |
|
158 DEBUG_API("<-XAEngineItfImpl_GetImplementationInfo"); |
|
159 return XA_RESULT_SUCCESS; |
|
160 } |
|
161 |
|
162 XAresult XAEngineItfImpl_QuerySupportedProfiles(XAEngineItf self, |
|
163 XAint16 *pProfilesSupported) |
|
164 { |
|
165 DEBUG_API("->XAEngineItfImpl_QuerySupportedProfiles"); |
|
166 |
|
167 if (!pProfilesSupported) |
|
168 { |
|
169 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
|
170 DEBUG_API("<-XAEngineItfImpl_QuerySupportedProfiles"); |
|
171 return XA_RESULT_PARAMETER_INVALID; |
|
172 } |
|
173 /* NOTE: enable +MIDI when/if XMF issues solved |
|
174 * XA_PROFILES_MEDIA_PLAYER | |
|
175 * XA_PROFILES_MEDIA_PLAYER_RECORDER | |
|
176 * XA_PROFILES_PLUS_MIDI; |
|
177 */ |
|
178 *pProfilesSupported = XA_PROFILES_MEDIA_PLAYER |
|
179 | XA_PROFILES_MEDIA_PLAYER_RECORDER; |
|
180 |
|
181 DEBUG_API("<-XAEngineItfImpl_QuerySupportedProfiles"); |
|
182 return XA_RESULT_SUCCESS; |
|
183 } |
|
184 |
|
185 XAresult XAEngineItfImpl_QueryNumSupportedInterfaces(XAEngineItf self, |
|
186 XAuint32 objectID, XAuint32 *pNumSupportedInterfaces) |
|
187 { |
|
188 XAresult res = XA_RESULT_SUCCESS; |
|
189 DEBUG_API("->XAEngineItfImpl_QueryNumSupportedInterfaces"); |
|
190 |
|
191 if (!pNumSupportedInterfaces) |
|
192 { |
|
193 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
|
194 DEBUG_API("<-XAEngineItfImpl_QueryNumSupportedInterfaces"); |
|
195 return XA_RESULT_PARAMETER_INVALID; |
|
196 } |
|
197 *pNumSupportedInterfaces = 0; |
|
198 switch (objectID) |
|
199 { |
|
200 case XA_OBJECTID_ENGINE: |
|
201 res = XAEngineImpl_QueryNumSupportedInterfaces( |
|
202 pNumSupportedInterfaces); |
|
203 break; |
|
204 case XA_OBJECTID_MEDIAPLAYER: |
|
205 res = XAMediaPlayerImpl_QueryNumSupportedInterfaces( |
|
206 pNumSupportedInterfaces); |
|
207 break; |
|
208 case XA_OBJECTID_MEDIARECORDER: |
|
209 res = XAMediaRecorderImpl_QueryNumSupportedInterfaces( |
|
210 pNumSupportedInterfaces); |
|
211 break; |
|
212 case XA_OBJECTID_RADIODEVICE: |
|
213 res = XARadioDeviceImpl_QueryNumSupportedInterfaces( |
|
214 pNumSupportedInterfaces); |
|
215 break; |
|
216 case XA_OBJECTID_METADATAEXTRACTOR: |
|
217 res = XAMetadataExtractorImpl_QueryNumSupportedInterfaces( |
|
218 pNumSupportedInterfaces); |
|
219 break; |
|
220 default: |
|
221 res = XA_RESULT_FEATURE_UNSUPPORTED; |
|
222 break; |
|
223 } |
|
224 |
|
225 DEBUG_API_A1("<-XAEngineItfImpl_QueryNumSupportedInterfaces %lu",res); |
|
226 return res; |
|
227 } |
|
228 |
|
229 XAresult XAEngineItfImpl_QuerySupportedInterfaces(XAEngineItf self, |
|
230 XAuint32 objectID, XAuint32 index, XAInterfaceID *pInterfaceId) |
|
231 { |
|
232 XAresult res = XA_RESULT_SUCCESS; |
|
233 DEBUG_API("->XAEngineItfImpl_QuerySupportedInterfaces"); |
|
234 |
|
235 if (!pInterfaceId) |
|
236 { |
|
237 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
|
238 DEBUG_API("<-XAEngineItfImpl_QuerySupportedInterfaces"); |
|
239 return XA_RESULT_PARAMETER_INVALID; |
|
240 } |
|
241 *pInterfaceId = XA_IID_NULL; |
|
242 switch (objectID) |
|
243 { |
|
244 case XA_OBJECTID_ENGINE: |
|
245 res = XAEngineImpl_QuerySupportedInterfaces(index, pInterfaceId); |
|
246 break; |
|
247 case XA_OBJECTID_MEDIAPLAYER: |
|
248 res = XAMediaPlayerImpl_QuerySupportedInterfaces(index, |
|
249 pInterfaceId); |
|
250 break; |
|
251 case XA_OBJECTID_MEDIARECORDER: |
|
252 res = XAMediaRecorderImpl_QuerySupportedInterfaces(index, |
|
253 pInterfaceId); |
|
254 break; |
|
255 case XA_OBJECTID_RADIODEVICE: |
|
256 res = XARadioDeviceImpl_QuerySupportedInterfaces(index, |
|
257 pInterfaceId); |
|
258 break; |
|
259 case XA_OBJECTID_METADATAEXTRACTOR: |
|
260 res = XAMetadataExtractorImpl_QuerySupportedInterfaces(index, |
|
261 pInterfaceId); |
|
262 break; |
|
263 default: |
|
264 res = XA_RESULT_FEATURE_UNSUPPORTED; |
|
265 } |
|
266 |
|
267 DEBUG_API_A1("<-XAEngineItfImpl_QuerySupportedInterfaces %lu", res); |
|
268 return res; |
|
269 } |
|
270 |
|
271 XAresult XAEngineItfImpl_QueryLEDCapabilities(XAEngineItf self, |
|
272 XAuint32 *pIndex, XAuint32 *pLEDDeviceID, |
|
273 XALEDDescriptor *pDescriptor) |
|
274 { |
|
275 XAresult res = XA_RESULT_SUCCESS; |
|
276 DEBUG_API("->XAEngineItfImpl_QueryLEDCapabilities"); |
|
277 |
|
278 if (!pDescriptor) |
|
279 { /*query number of devices*/ |
|
280 if (!pIndex) |
|
281 { |
|
282 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
|
283 DEBUG_API("<-XAEngineItfImpl_QueryLEDCapabilities"); |
|
284 return XA_RESULT_PARAMETER_INVALID; |
|
285 } |
|
286 else |
|
287 { |
|
288 /* Number of devices */ |
|
289 *pIndex = 0; |
|
290 } |
|
291 } |
|
292 else |
|
293 { |
|
294 // return NotSupported below |
|
295 res = XA_RESULT_FEATURE_UNSUPPORTED; |
|
296 } |
|
297 DEBUG_API("<-XAEngineItfImpl_QueryLEDCapabilities"); |
|
298 return res; |
|
299 } |
|
300 |
|
301 XAresult XAEngineItfImpl_QueryVibraCapabilities(XAEngineItf self, |
|
302 XAuint32 *pIndex, XAuint32 *pVibraDeviceID, |
|
303 XAVibraDescriptor *pDescriptor) |
|
304 { |
|
305 XAresult res = XA_RESULT_SUCCESS; |
|
306 DEBUG_API("->XAEngineItfImpl_QueryVibraCapabilities"); |
|
307 |
|
308 if (!pDescriptor) |
|
309 { /*query number of devices*/ |
|
310 if (!pIndex) |
|
311 { |
|
312 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
|
313 DEBUG_API("<-XAEngineItfImpl_QueryVibraCapabilities"); |
|
314 res = XA_RESULT_PARAMETER_INVALID; |
|
315 } |
|
316 else |
|
317 { |
|
318 /* Number of devices */ |
|
319 *pIndex = 0; |
|
320 } |
|
321 } |
|
322 else |
|
323 { |
|
324 // return NotSupported below |
|
325 res = XA_RESULT_FEATURE_UNSUPPORTED; |
|
326 } |
|
327 |
|
328 DEBUG_API("<-XAEngineItfImpl_QueryVibraCapabilities"); |
|
329 return res; |
|
330 } |
|
331 |
|
332 XAresult XAEngineItfImpl_QueryNumSupportedExtensions(XAEngineItf self, |
|
333 XAuint32 *pNumExtensions) |
|
334 { |
|
335 DEBUG_API("->XAEngineItfImpl_QuerySupportedExtension"); |
|
336 if (pNumExtensions == NULL) |
|
337 { |
|
338 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
|
339 DEBUG_API("<-XAEngineItfImpl_QuerySupportedExtension"); |
|
340 return XA_RESULT_PARAMETER_INVALID; |
|
341 } |
|
342 /* no supported extensions */ |
|
343 *pNumExtensions = 0; |
|
344 DEBUG_API("<-XAEngineItfImpl_QuerySupportedExtension"); |
|
345 return XA_RESULT_SUCCESS; |
|
346 } |
|
347 |
|
348 XAresult XAEngineItfImpl_QuerySupportedExtension(XAEngineItf self, |
|
349 XAuint32 index, XAchar *pExtensionName, XAint16 *pNameLength) |
|
350 { |
|
351 DEBUG_API("->XAEngineItfImpl_QuerySupportedExtension"); |
|
352 /* no supported extensions => index is always wrong */ |
|
353 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
|
354 DEBUG_API("<-XAEngineItfImpl_QuerySupportedExtension"); |
|
355 return XA_RESULT_PARAMETER_INVALID; |
|
356 } |
|
357 |
|
358 XAresult XAEngineItfImpl_IsExtensionSupported(XAEngineItf self, |
|
359 const XAchar *pExtensionName, XAboolean *pSupported) |
|
360 { |
|
361 DEBUG_API("->XAEngineItfImpl_IsExtensionSupported"); |
|
362 if (pSupported == NULL) |
|
363 { |
|
364 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
|
365 DEBUG_API("<-XAEngineItfImpl_IsExtensionSupported"); |
|
366 return XA_RESULT_PARAMETER_INVALID; |
|
367 } |
|
368 /* no supported extensions */ |
|
369 *pSupported = XA_BOOLEAN_FALSE; |
|
370 DEBUG_API("<-XAEngineItfImpl_IsExtensionSupported"); |
|
371 return XA_RESULT_SUCCESS; |
|
372 } |
|
373 |
|
374 /** |
|
375 * XAEngineItfImpl -specific methods |
|
376 **/ |
|
377 XAEngineItfImpl* XAEngineItfImpl_Create(FrameworkMap* fwkmapper, |
|
378 XACapabilities* capabilities) |
|
379 { |
|
380 XAEngineItfImpl* self = (XAEngineItfImpl*) calloc(1, |
|
381 sizeof(XAEngineItfImpl)); |
|
382 DEBUG_API("->XAEngineItfImpl_Create"); |
|
383 |
|
384 if (self) |
|
385 { |
|
386 /* init itf default implementation */ |
|
387 self->itf.CreateCameraDevice = XAEngineItfImpl_CreateCameraDevice; |
|
388 self->itf.CreateRadioDevice = XAEngineItfImpl_CreateRadioDevice; |
|
389 self->itf.CreateLEDDevice = XAEngineItfImpl_CreateLEDDevice; |
|
390 self->itf.CreateVibraDevice = XAEngineItfImpl_CreateVibraDevice; |
|
391 self->itf.CreateMediaPlayer = XAEngineItfImpl_CreateMediaPlayer; |
|
392 self->itf.CreateMediaRecorder = XAEngineItfImpl_CreateMediaRecorder; |
|
393 self->itf.CreateOutputMix = XAEngineItfImpl_CreateOutputMix; |
|
394 self->itf.CreateMetadataExtractor |
|
395 = XAEngineItfImpl_CreateMetadataExtractor; |
|
396 self->itf.CreateExtensionObject |
|
397 = XAEngineItfImpl_CreateExtensionObject; |
|
398 self->itf.GetImplementationInfo |
|
399 = XAEngineItfImpl_GetImplementationInfo; |
|
400 self->itf.QuerySupportedProfiles |
|
401 = XAEngineItfImpl_QuerySupportedProfiles; |
|
402 self->itf.QueryNumSupportedInterfaces |
|
403 = XAEngineItfImpl_QueryNumSupportedInterfaces; |
|
404 self->itf.QuerySupportedInterfaces |
|
405 = XAEngineItfImpl_QuerySupportedInterfaces; |
|
406 self->itf.QueryLEDCapabilities = XAEngineItfImpl_QueryLEDCapabilities; |
|
407 self->itf.QueryVibraCapabilities |
|
408 = XAEngineItfImpl_QueryVibraCapabilities; |
|
409 self->itf.QueryNumSupportedExtensions |
|
410 = XAEngineItfImpl_QueryNumSupportedExtensions; |
|
411 self->itf.QuerySupportedExtension |
|
412 = XAEngineItfImpl_QuerySupportedExtension; |
|
413 self->itf.IsExtensionSupported = XAEngineItfImpl_IsExtensionSupported; |
|
414 self->mapper = fwkmapper; |
|
415 self->capabilities = capabilities; |
|
416 self->xyz = 50; |
|
417 self->self = self; |
|
418 } |
|
419 DEBUG_API("<-XAEngineItfImpl_Create"); |
|
420 return self; |
|
421 } |
|
422 |
|
423 void XAEngineItfImpl_Free(XAEngineItfImpl* self) |
|
424 { |
|
425 DEBUG_API("->XAEngineItfImpl_Free"); |
|
426 if(self) |
|
427 { |
|
428 assert(self==self->self); |
|
429 free(self); |
|
430 } |
|
431 DEBUG_API("<-XAEngineItfImpl_Free"); |
|
432 } |