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