|
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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <assert.h> |
|
20 |
|
21 #include "xastreaminformationitf.h" |
|
22 #include "xastreaminformationitfadaptation.h" |
|
23 #include "xastreaminformationitfadaptationmmf.h" |
|
24 |
|
25 /* XAStreamInformationItfImpl* GetImpl |
|
26 * Description: Validate interface pointer and cast it to implementation pointer. |
|
27 */ |
|
28 static XAStreamInformationItfImpl* GetImpl(XAStreamInformationItf self) |
|
29 { |
|
30 if(self) |
|
31 { |
|
32 XAStreamInformationItfImpl* impl = (XAStreamInformationItfImpl*)(*self); |
|
33 if(impl && impl == impl->self) |
|
34 { |
|
35 return impl; |
|
36 } |
|
37 } |
|
38 return NULL; |
|
39 } |
|
40 |
|
41 /** |
|
42 * Base interface XAPlayItf implementation |
|
43 */ |
|
44 |
|
45 |
|
46 XAresult XAStreamInformationItfImpl_QueryMediaContainerInformation( |
|
47 XAStreamInformationItf self, |
|
48 XAMediaContainerInformation * info) |
|
49 { |
|
50 XAresult ret = XA_RESULT_SUCCESS; |
|
51 XAStreamInformationItfImpl* impl = GetImpl(self); |
|
52 DEBUG_API("->XAStreamInformationItfImpl_QueryMediaContainerInformation"); |
|
53 if(!impl || !info) |
|
54 { |
|
55 /* invalid parameter */ |
|
56 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
|
57 DEBUG_API("-<XAStreamInformationItfImpl_QueryMediaContainerInformation"); |
|
58 return XA_RESULT_PARAMETER_INVALID; |
|
59 } |
|
60 |
|
61 |
|
62 if(impl->adapCtx->fwtype == FWMgrFWGST) |
|
63 { |
|
64 ret = XAAdaptationBase_ThreadEntry(impl->adapCtx); |
|
65 if( ret == XA_RESULT_PARAMETER_INVALID ) |
|
66 { |
|
67 DEBUG_API("<-XAStreamInformationItfImpl_QueryMediaContainerInformation"); |
|
68 return ret; |
|
69 } |
|
70 ret = XAStreamInformationItfAdapt_QueryMediaContainerInformation( |
|
71 impl->adapCtx, |
|
72 &(info->containerType), |
|
73 &(info->mediaDuration), |
|
74 &(info->numStreams)); |
|
75 XAAdaptationBase_ThreadExit(impl->adapCtx); |
|
76 } |
|
77 else |
|
78 { |
|
79 ret = XAAdaptationBase_ThreadEntry(impl->adapCtx); |
|
80 if( ret == XA_RESULT_PARAMETER_INVALID ) |
|
81 { |
|
82 DEBUG_API("<-XAStreamInformationItfImpl_QueryMediaContainerInformation"); |
|
83 return ret; |
|
84 } |
|
85 ret = XAStreamInformationItfAdaptMMF_QueryMediaContainerInformation( |
|
86 impl->adapCtx, |
|
87 &(info->containerType), |
|
88 &(info->mediaDuration), |
|
89 &(info->numStreams)); |
|
90 XAAdaptationBase_ThreadExit(impl->adapCtx);; |
|
91 } |
|
92 |
|
93 DEBUG_API("-<XAStreamInformationItfImpl_QueryMediaContainerInformation"); |
|
94 return ret; |
|
95 } |
|
96 |
|
97 XAresult XAStreamInformationItfImpl_QueryStreamType( |
|
98 XAStreamInformationItf self, |
|
99 XAuint32 streamIndex, |
|
100 XAuint32 *domain) |
|
101 { |
|
102 XAresult ret = XA_RESULT_SUCCESS; |
|
103 XAStreamInformationItfImpl* impl = GetImpl(self); |
|
104 DEBUG_API("->XAStreamInformationItfImpl_QueryStreamType"); |
|
105 if(!impl || !domain || (streamIndex == 0)) |
|
106 { |
|
107 /* invalid parameter */ |
|
108 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
|
109 DEBUG_API("-<XAStreamInformationItfImpl_QueryStreamType"); |
|
110 return XA_RESULT_PARAMETER_INVALID; |
|
111 } |
|
112 if(impl->adapCtx->fwtype == FWMgrFWGST) |
|
113 { |
|
114 ret = XAAdaptationBase_ThreadEntry(impl->adapCtx); |
|
115 if( ret == XA_RESULT_PARAMETER_INVALID ) |
|
116 { |
|
117 DEBUG_API("<-XAStreamInformationItfImpl_QueryStreamType"); |
|
118 return ret; |
|
119 } |
|
120 |
|
121 ret = XAStreamInformationItfAdapt_QueryStreamType( |
|
122 impl->adapCtx, |
|
123 streamIndex, |
|
124 domain); |
|
125 |
|
126 XAAdaptationBase_ThreadExit(impl->adapCtx); |
|
127 } |
|
128 else |
|
129 { |
|
130 ret = XAAdaptationBase_ThreadEntry(impl->adapCtx); |
|
131 if( ret == XA_RESULT_PARAMETER_INVALID ) |
|
132 { |
|
133 DEBUG_API("<-XAStreamInformationItfImpl_QueryStreamType"); |
|
134 return ret; |
|
135 } |
|
136 |
|
137 ret = XAStreamInformationItfAdaptMMF_QueryStreamType( |
|
138 impl->adapCtx, |
|
139 streamIndex, |
|
140 domain); |
|
141 |
|
142 XAAdaptationBase_ThreadExit(impl->adapCtx);; |
|
143 } |
|
144 DEBUG_API("-<XAStreamInformationItfImpl_QueryStreamType"); |
|
145 return ret; |
|
146 } |
|
147 |
|
148 XAresult XAStreamInformationItfImpl_QueryStreamInformation( |
|
149 XAStreamInformationItf self, |
|
150 XAuint32 streamIndex, |
|
151 void * info) |
|
152 { |
|
153 XAresult ret = XA_RESULT_SUCCESS; |
|
154 XAStreamInformationItfImpl* impl = GetImpl(self); |
|
155 DEBUG_API("->XAStreamInformationItfImpl_QueryStreamInformation"); |
|
156 if(!impl || !info || (streamIndex == 0)) |
|
157 { |
|
158 /* invalid parameter */ |
|
159 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
|
160 DEBUG_API("-<XAStreamInformationItfImpl_QueryStreamInformation"); |
|
161 return XA_RESULT_PARAMETER_INVALID; |
|
162 } |
|
163 |
|
164 if(impl->adapCtx->fwtype == FWMgrFWGST) |
|
165 { |
|
166 ret = XAAdaptationBase_ThreadEntry(impl->adapCtx); |
|
167 if( ret == XA_RESULT_PARAMETER_INVALID ) |
|
168 { |
|
169 DEBUG_API("<-XAStreamInformationItfImpl_QueryStreamInformation"); |
|
170 return ret; |
|
171 } |
|
172 |
|
173 ret = XAStreamInformationItfAdapt_QueryStreamInformation( |
|
174 impl->adapCtx, |
|
175 streamIndex, |
|
176 info); |
|
177 |
|
178 XAAdaptationBase_ThreadExit(impl->adapCtx); |
|
179 } |
|
180 else |
|
181 { |
|
182 ret = XAAdaptationBase_ThreadEntry(impl->adapCtx); |
|
183 if( ret == XA_RESULT_PARAMETER_INVALID ) |
|
184 { |
|
185 DEBUG_API("<-XAStreamInformationItfImpl_QueryStreamInformation"); |
|
186 return ret; |
|
187 } |
|
188 |
|
189 ret = XAStreamInformationItfAdaptMMF_QueryStreamInformation( |
|
190 impl->adapCtx, |
|
191 streamIndex, |
|
192 info); |
|
193 |
|
194 XAAdaptationBase_ThreadExit(impl->adapCtx);; |
|
195 } |
|
196 |
|
197 DEBUG_API("-<XAStreamInformationItfImpl_QueryStreamInformation"); |
|
198 return ret; |
|
199 } |
|
200 |
|
201 XAresult XAStreamInformationItfImpl_QueryStreamName( |
|
202 XAStreamInformationItf self, |
|
203 XAuint32 streamIndex, |
|
204 XAuint16 * pNameSize, |
|
205 XAchar * pName) |
|
206 { |
|
207 XAresult ret = XA_RESULT_SUCCESS; |
|
208 XAStreamInformationItfImpl* impl = GetImpl(self); |
|
209 DEBUG_API("->XAStreamInformationItfImpl_QueryStreamName"); |
|
210 if(!impl || (streamIndex == 0) || !pNameSize) |
|
211 { |
|
212 /* invalid parameter */ |
|
213 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
|
214 DEBUG_API("-<XAStreamInformationItfImpl_QueryStreamName"); |
|
215 return XA_RESULT_PARAMETER_INVALID; |
|
216 } |
|
217 |
|
218 if(impl->adapCtx->fwtype == FWMgrFWGST) |
|
219 { |
|
220 ret = XAAdaptationBase_ThreadEntry(impl->adapCtx); |
|
221 if( ret == XA_RESULT_PARAMETER_INVALID ) |
|
222 { |
|
223 DEBUG_API("<-XAStreamInformationItfImpl_QueryStreamName"); |
|
224 return ret; |
|
225 } |
|
226 |
|
227 ret = XAStreamInformationItfAdapt_QueryStreamName( |
|
228 impl->adapCtx, |
|
229 streamIndex, |
|
230 pNameSize, |
|
231 pName); |
|
232 |
|
233 XAAdaptationBase_ThreadExit(impl->adapCtx); |
|
234 } |
|
235 else |
|
236 { |
|
237 ret = XAAdaptationBase_ThreadEntry(impl->adapCtx); |
|
238 if( ret == XA_RESULT_PARAMETER_INVALID ) |
|
239 { |
|
240 DEBUG_API("<-XAStreamInformationItfImpl_QueryStreamName"); |
|
241 return ret; |
|
242 } |
|
243 |
|
244 ret = XAStreamInformationItfAdaptMMF_QueryStreamName( |
|
245 impl->adapCtx, |
|
246 streamIndex, |
|
247 pNameSize, |
|
248 pName); |
|
249 |
|
250 XAAdaptationBase_ThreadExit(impl->adapCtx);; |
|
251 } |
|
252 DEBUG_API("-<XAStreamInformationItfImpl_QueryStreamName"); |
|
253 return ret; |
|
254 } |
|
255 |
|
256 XAresult XAStreamInformationItfImpl_RegisterStreamChangeCallback( |
|
257 XAStreamInformationItf self, |
|
258 xaStreamEventChangeCallback callback, |
|
259 void * pContext) |
|
260 { |
|
261 XAresult ret = XA_RESULT_SUCCESS; |
|
262 XAStreamInformationItfImpl* impl = GetImpl(self); |
|
263 DEBUG_API("->XAStreamInformationItfImpl_RegisterStreamChangeCallback"); |
|
264 if(!impl) |
|
265 { |
|
266 /* invalid parameter */ |
|
267 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
|
268 DEBUG_API("-<XAStreamInformationItfImpl_RegisterStreamChangeCallback"); |
|
269 return XA_RESULT_PARAMETER_INVALID; |
|
270 } |
|
271 |
|
272 /* callback may be NULL (to remove callback) */ |
|
273 impl->callback = callback; |
|
274 impl->cbcontext = pContext; |
|
275 impl->cbPtrToSelf = self; |
|
276 |
|
277 DEBUG_API("-<XAStreamInformationItfImpl_RegisterStreamChangeCallback"); |
|
278 return ret; |
|
279 } |
|
280 |
|
281 XAresult XAStreamInformationItfImpl_QueryActiveStreams( |
|
282 XAStreamInformationItf self, |
|
283 XAuint32 *numStreams, |
|
284 XAboolean *activeStreams) |
|
285 { |
|
286 XAresult ret = XA_RESULT_SUCCESS; |
|
287 XAStreamInformationItfImpl* impl = GetImpl(self); |
|
288 DEBUG_API("->XAStreamInformationItfImpl_QueryActiveStreams"); |
|
289 if(!impl || !numStreams) |
|
290 { |
|
291 /* invalid parameter */ |
|
292 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
|
293 DEBUG_API("-<XAStreamInformationItfImpl_QueryActiveStreams"); |
|
294 return XA_RESULT_PARAMETER_INVALID; |
|
295 } |
|
296 |
|
297 if(impl->adapCtx->fwtype == FWMgrFWGST) |
|
298 { |
|
299 ret = XAAdaptationBase_ThreadEntry(impl->adapCtx); |
|
300 if( ret == XA_RESULT_PARAMETER_INVALID ) |
|
301 { |
|
302 DEBUG_API("<-XAStreamInformationItfImpl_QueryActiveStreams"); |
|
303 return ret; |
|
304 } |
|
305 |
|
306 ret = XAStreamInformationItfAdapt_QueryActiveStreams( |
|
307 impl->adapCtx, |
|
308 numStreams, |
|
309 activeStreams); |
|
310 |
|
311 XAAdaptationBase_ThreadExit(impl->adapCtx); |
|
312 } |
|
313 else |
|
314 { |
|
315 ret = XAAdaptationBase_ThreadEntry(impl->adapCtx); |
|
316 if( ret == XA_RESULT_PARAMETER_INVALID ) |
|
317 { |
|
318 DEBUG_API("<-XAStreamInformationItfImpl_QueryActiveStreams"); |
|
319 return ret; |
|
320 } |
|
321 |
|
322 ret = XAStreamInformationItfAdaptMMF_QueryActiveStreams( |
|
323 impl->adapCtx, |
|
324 numStreams, |
|
325 activeStreams); |
|
326 |
|
327 XAAdaptationBase_ThreadExit(impl->adapCtx);; |
|
328 } |
|
329 |
|
330 DEBUG_API("-<XAStreamInformationItfImpl_QueryActiveStreams"); |
|
331 return ret; |
|
332 } |
|
333 |
|
334 XAresult XAStreamInformationItfImpl_SetActiveStream( |
|
335 XAStreamInformationItf self, |
|
336 XAuint32 streamNum, |
|
337 XAboolean active, |
|
338 XAboolean commitNow) |
|
339 { |
|
340 XAresult ret = XA_RESULT_SUCCESS; |
|
341 XAStreamInformationItfImpl* impl = GetImpl(self); |
|
342 DEBUG_API("->XAStreamInformationItfImpl_SetActiveStream"); |
|
343 if(!impl) |
|
344 { |
|
345 /* invalid parameter */ |
|
346 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
|
347 DEBUG_API("-<XAStreamInformationItfImpl_SetActiveStream"); |
|
348 return XA_RESULT_PARAMETER_INVALID; |
|
349 } |
|
350 |
|
351 if(impl->adapCtx->fwtype == FWMgrFWGST) |
|
352 { |
|
353 ret = XAAdaptationBase_ThreadEntry(impl->adapCtx); |
|
354 if( ret == XA_RESULT_PARAMETER_INVALID ) |
|
355 { |
|
356 DEBUG_API("<-XAStreamInformationItfImpl_SetActiveStream"); |
|
357 return ret; |
|
358 } |
|
359 |
|
360 ret = XAStreamInformationItfAdapt_SetActiveStream( |
|
361 impl->adapCtx, |
|
362 streamNum, |
|
363 active, |
|
364 commitNow); |
|
365 |
|
366 XAAdaptationBase_ThreadExit(impl->adapCtx); |
|
367 } |
|
368 else |
|
369 { |
|
370 ret = XAAdaptationBase_ThreadEntry(impl->adapCtx); |
|
371 if( ret == XA_RESULT_PARAMETER_INVALID ) |
|
372 { |
|
373 DEBUG_API("<-XAStreamInformationItfImpl_SetActiveStream"); |
|
374 return ret; |
|
375 } |
|
376 |
|
377 ret = XAStreamInformationItfAdaptMMF_SetActiveStream( |
|
378 impl->adapCtx, |
|
379 streamNum, |
|
380 active, |
|
381 commitNow); |
|
382 |
|
383 XAAdaptationBase_ThreadExit(impl->adapCtx);; |
|
384 } |
|
385 |
|
386 DEBUG_API("-<XAStreamInformationItfImpl_SetActiveStream"); |
|
387 return ret; |
|
388 } |
|
389 |
|
390 /** |
|
391 * XAStreamInformationItfImpl -specific methods |
|
392 **/ |
|
393 |
|
394 /** |
|
395 * XAStreamInformationItfImpl* XAStreamInformationItfImpl_Create() |
|
396 * Description: Allocate and initialize PlayItfImpl |
|
397 **/ |
|
398 XAStreamInformationItfImpl* XAStreamInformationItfImpl_Create( XAAdaptationBaseCtx *adapCtx ) |
|
399 { |
|
400 XAStreamInformationItfImpl *self; |
|
401 |
|
402 DEBUG_API("->XAStreamInformationItfImpl_Create"); |
|
403 self = (XAStreamInformationItfImpl*)calloc(1,sizeof(XAStreamInformationItfImpl)); |
|
404 if(self) |
|
405 { |
|
406 /* init itf default implementation */ |
|
407 self->itf.QueryMediaContainerInformation = XAStreamInformationItfImpl_QueryMediaContainerInformation; |
|
408 self->itf.QueryStreamType = XAStreamInformationItfImpl_QueryStreamType; |
|
409 self->itf.QueryStreamInformation = XAStreamInformationItfImpl_QueryStreamInformation; |
|
410 self->itf.QueryStreamName = XAStreamInformationItfImpl_QueryStreamName; |
|
411 self->itf.RegisterStreamChangeCallback = XAStreamInformationItfImpl_RegisterStreamChangeCallback; |
|
412 self->itf.QueryActiveStreams = XAStreamInformationItfImpl_QueryActiveStreams; |
|
413 self->itf.SetActiveStream = XAStreamInformationItfImpl_SetActiveStream; |
|
414 |
|
415 /* init variables */ |
|
416 self->cbPtrToSelf = NULL; |
|
417 self->callback = NULL; |
|
418 self->cbcontext = NULL; |
|
419 self->adapCtx = adapCtx; |
|
420 |
|
421 self->self = self; |
|
422 } |
|
423 |
|
424 DEBUG_API("<-XAStreamInformationItfImpl_Create"); |
|
425 return self; |
|
426 } |
|
427 |
|
428 /* void XAStreamInformationItfImpl_Free(XAStreamInformationItfImpl* self) |
|
429 * Description: Free all resources reserved at XAStreamInformationItfImpl_Create |
|
430 */ |
|
431 void XAStreamInformationItfImpl_Free(XAStreamInformationItfImpl* self) |
|
432 { |
|
433 DEBUG_API("->XAStreamInformationItfImpl_Free"); |
|
434 assert(self==self->self); |
|
435 free(self); |
|
436 DEBUG_API("<-XAStreamInformationItfImpl_Free"); |
|
437 } |
|
438 |
|
439 |