|
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: Stream Information Interface Implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <assert.h> |
|
19 |
|
20 #include "xastreaminformationitf.h" |
|
21 |
|
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 { |
|
29 if (self) |
|
30 { |
|
31 XAStreamInformationItfImpl* impl = |
|
32 (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 XAresult XAStreamInformationItfImpl_QueryMediaContainerInformation( |
|
46 XAStreamInformationItf self, XAMediaContainerInformation * info) |
|
47 { |
|
48 XAresult ret = XA_RESULT_SUCCESS; |
|
49 XAStreamInformationItfImpl* impl = GetImpl(self); |
|
50 DEBUG_API("->XAStreamInformationItfImpl_QueryMediaContainerInformation"); |
|
51 if (!impl || !info || !impl->adapCtx) |
|
52 { |
|
53 /* invalid parameter */ |
|
54 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
|
55 DEBUG_API("-<XAStreamInformationItfImpl_QueryMediaContainerInformation"); |
|
56 return XA_RESULT_PARAMETER_INVALID; |
|
57 } |
|
58 |
|
59 if (impl->adapCtx->fwtype == FWMgrFWMMF) |
|
60 { |
|
61 ret = XAAdaptationBase_ThreadEntry(impl->adapCtx); |
|
62 if (ret == XA_RESULT_PARAMETER_INVALID) |
|
63 { |
|
64 DEBUG_API("<-XAStreamInformationItfImpl_QueryMediaContainerInformation"); |
|
65 return ret; |
|
66 } |
|
67 ret = XAStreamInformationItfAdaptMMF_QueryMediaContainerInformation( |
|
68 impl->adapCtx, &(info->containerType), |
|
69 &(info->mediaDuration), &(info->numStreams)); |
|
70 XAAdaptationBase_ThreadExit(impl->adapCtx); |
|
71 } |
|
72 |
|
73 DEBUG_API("-<XAStreamInformationItfImpl_QueryMediaContainerInformation"); |
|
74 return ret; |
|
75 } |
|
76 |
|
77 XAresult XAStreamInformationItfImpl_QueryStreamType( |
|
78 XAStreamInformationItf self, XAuint32 streamIndex, XAuint32 *domain) |
|
79 { |
|
80 XAresult ret = XA_RESULT_SUCCESS; |
|
81 XAStreamInformationItfImpl* impl = GetImpl(self); |
|
82 DEBUG_API("->XAStreamInformationItfImpl_QueryStreamType"); |
|
83 if (!impl || !domain || (streamIndex == 0) || !impl->adapCtx) |
|
84 { |
|
85 /* invalid parameter */ |
|
86 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
|
87 DEBUG_API("-<XAStreamInformationItfImpl_QueryStreamType"); |
|
88 return XA_RESULT_PARAMETER_INVALID; |
|
89 } |
|
90 if (impl->adapCtx->fwtype == FWMgrFWMMF) |
|
91 { |
|
92 ret = XAAdaptationBase_ThreadEntry(impl->adapCtx); |
|
93 if (ret == XA_RESULT_PARAMETER_INVALID) |
|
94 { |
|
95 DEBUG_API("<-XAStreamInformationItfImpl_QueryStreamType"); |
|
96 return ret; |
|
97 } |
|
98 |
|
99 ret = XAStreamInformationItfAdaptMMF_QueryStreamType(impl->adapCtx, |
|
100 streamIndex, domain); |
|
101 |
|
102 XAAdaptationBase_ThreadExit(impl->adapCtx); |
|
103 } |
|
104 DEBUG_API("-<XAStreamInformationItfImpl_QueryStreamType"); |
|
105 return ret; |
|
106 } |
|
107 |
|
108 XAresult XAStreamInformationItfImpl_QueryStreamInformation( |
|
109 XAStreamInformationItf self, XAuint32 streamIndex, void * info) |
|
110 { |
|
111 XAresult ret = XA_RESULT_SUCCESS; |
|
112 XAStreamInformationItfImpl* impl = GetImpl(self); |
|
113 DEBUG_API("->XAStreamInformationItfImpl_QueryStreamInformation"); |
|
114 if (!impl || !info || (streamIndex == 0) || !impl->adapCtx) |
|
115 { |
|
116 /* invalid parameter */ |
|
117 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
|
118 DEBUG_API("-<XAStreamInformationItfImpl_QueryStreamInformation"); |
|
119 return XA_RESULT_PARAMETER_INVALID; |
|
120 } |
|
121 |
|
122 if (impl->adapCtx->fwtype == FWMgrFWMMF) |
|
123 { |
|
124 ret = XAAdaptationBase_ThreadEntry(impl->adapCtx); |
|
125 if (ret == XA_RESULT_PARAMETER_INVALID) |
|
126 { |
|
127 DEBUG_API("<-XAStreamInformationItfImpl_QueryStreamInformation"); |
|
128 return ret; |
|
129 } |
|
130 |
|
131 ret = XAStreamInformationItfAdaptMMF_QueryStreamInformation( |
|
132 impl->adapCtx, streamIndex, info); |
|
133 |
|
134 XAAdaptationBase_ThreadExit(impl->adapCtx); |
|
135 } |
|
136 |
|
137 DEBUG_API("-<XAStreamInformationItfImpl_QueryStreamInformation"); |
|
138 return ret; |
|
139 } |
|
140 |
|
141 XAresult XAStreamInformationItfImpl_QueryStreamName( |
|
142 XAStreamInformationItf self, XAuint32 streamIndex, |
|
143 XAuint16 * pNameSize, XAchar * pName) |
|
144 { |
|
145 XAresult ret = XA_RESULT_SUCCESS; |
|
146 XAStreamInformationItfImpl* impl = GetImpl(self); |
|
147 DEBUG_API("->XAStreamInformationItfImpl_QueryStreamName"); |
|
148 if (!impl || (streamIndex == 0) || !pNameSize || !impl->adapCtx) |
|
149 { |
|
150 /* invalid parameter */ |
|
151 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
|
152 DEBUG_API("-<XAStreamInformationItfImpl_QueryStreamName"); |
|
153 return XA_RESULT_PARAMETER_INVALID; |
|
154 } |
|
155 |
|
156 if (impl->adapCtx->fwtype == FWMgrFWMMF) |
|
157 { |
|
158 ret = XAAdaptationBase_ThreadEntry(impl->adapCtx); |
|
159 if (ret == XA_RESULT_PARAMETER_INVALID) |
|
160 { |
|
161 DEBUG_API("<-XAStreamInformationItfImpl_QueryStreamName"); |
|
162 return ret; |
|
163 } |
|
164 |
|
165 ret = XAStreamInformationItfAdaptMMF_QueryStreamName(impl->adapCtx, |
|
166 streamIndex, pNameSize, pName); |
|
167 |
|
168 XAAdaptationBase_ThreadExit(impl->adapCtx); |
|
169 } |
|
170 DEBUG_API("-<XAStreamInformationItfImpl_QueryStreamName"); |
|
171 return ret; |
|
172 } |
|
173 |
|
174 XAresult XAStreamInformationItfImpl_RegisterStreamChangeCallback( |
|
175 XAStreamInformationItf self, xaStreamEventChangeCallback callback, |
|
176 void * pContext) |
|
177 { |
|
178 XAresult ret = XA_RESULT_SUCCESS; |
|
179 XAStreamInformationItfImpl* impl = GetImpl(self); |
|
180 DEBUG_API("->XAStreamInformationItfImpl_RegisterStreamChangeCallback"); |
|
181 if (!impl) |
|
182 { |
|
183 /* invalid parameter */ |
|
184 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
|
185 DEBUG_API("-<XAStreamInformationItfImpl_RegisterStreamChangeCallback"); |
|
186 return XA_RESULT_PARAMETER_INVALID; |
|
187 } |
|
188 |
|
189 /* callback may be NULL (to remove callback) */ |
|
190 impl->callback = callback; |
|
191 impl->cbcontext = pContext; |
|
192 impl->cbPtrToSelf = self; |
|
193 |
|
194 DEBUG_API("-<XAStreamInformationItfImpl_RegisterStreamChangeCallback"); |
|
195 return ret; |
|
196 } |
|
197 |
|
198 XAresult XAStreamInformationItfImpl_QueryActiveStreams( |
|
199 XAStreamInformationItf self, XAuint32 *numStreams, |
|
200 XAboolean *activeStreams) |
|
201 { |
|
202 XAresult ret = XA_RESULT_SUCCESS; |
|
203 XAStreamInformationItfImpl* impl = GetImpl(self); |
|
204 DEBUG_API("->XAStreamInformationItfImpl_QueryActiveStreams"); |
|
205 if (!impl || !numStreams || !impl->adapCtx) |
|
206 { |
|
207 /* invalid parameter */ |
|
208 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
|
209 DEBUG_API("-<XAStreamInformationItfImpl_QueryActiveStreams"); |
|
210 return XA_RESULT_PARAMETER_INVALID; |
|
211 } |
|
212 |
|
213 if (impl->adapCtx->fwtype == FWMgrFWGST) |
|
214 { |
|
215 ret = XAAdaptationBase_ThreadEntry(impl->adapCtx); |
|
216 if (ret == XA_RESULT_PARAMETER_INVALID) |
|
217 { |
|
218 DEBUG_API("<-XAStreamInformationItfImpl_QueryActiveStreams"); |
|
219 return ret; |
|
220 } |
|
221 |
|
222 ret = XAStreamInformationItfAdaptMMF_QueryActiveStreams( |
|
223 impl->adapCtx, numStreams, activeStreams); |
|
224 |
|
225 XAAdaptationBase_ThreadExit(impl->adapCtx); |
|
226 } |
|
227 |
|
228 DEBUG_API("-<XAStreamInformationItfImpl_QueryActiveStreams"); |
|
229 return ret; |
|
230 } |
|
231 |
|
232 XAresult XAStreamInformationItfImpl_SetActiveStream( |
|
233 XAStreamInformationItf self, XAuint32 streamNum, XAboolean active, |
|
234 XAboolean commitNow) |
|
235 { |
|
236 XAresult ret = XA_RESULT_SUCCESS; |
|
237 XAStreamInformationItfImpl* impl = GetImpl(self); |
|
238 DEBUG_API("->XAStreamInformationItfImpl_SetActiveStream"); |
|
239 if (!impl || !impl->adapCtx) |
|
240 { |
|
241 /* invalid parameter */ |
|
242 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
|
243 DEBUG_API("-<XAStreamInformationItfImpl_SetActiveStream"); |
|
244 return XA_RESULT_PARAMETER_INVALID; |
|
245 } |
|
246 |
|
247 if (impl->adapCtx->fwtype == FWMgrFWMMF) |
|
248 { |
|
249 ret = XAAdaptationBase_ThreadEntry(impl->adapCtx); |
|
250 if (ret == XA_RESULT_PARAMETER_INVALID) |
|
251 { |
|
252 DEBUG_API("<-XAStreamInformationItfImpl_SetActiveStream"); |
|
253 return ret; |
|
254 } |
|
255 |
|
256 ret = XAStreamInformationItfAdaptMMF_SetActiveStream(impl->adapCtx, |
|
257 streamNum, active, commitNow); |
|
258 |
|
259 XAAdaptationBase_ThreadExit(impl->adapCtx); |
|
260 } |
|
261 |
|
262 DEBUG_API("-<XAStreamInformationItfImpl_SetActiveStream"); |
|
263 return ret; |
|
264 } |
|
265 |
|
266 /** |
|
267 * XAStreamInformationItfImpl -specific methods |
|
268 **/ |
|
269 |
|
270 /** |
|
271 * XAStreamInformationItfImpl* XAStreamInformationItfImpl_Create() |
|
272 * Description: Allocate and initialize PlayItfImpl |
|
273 **/ |
|
274 XAStreamInformationItfImpl* XAStreamInformationItfImpl_Create( |
|
275 XAAdaptationBaseCtx *adapCtx) |
|
276 { |
|
277 XAStreamInformationItfImpl *self; |
|
278 |
|
279 DEBUG_API("->XAStreamInformationItfImpl_Create"); |
|
280 self = (XAStreamInformationItfImpl*) calloc(1, |
|
281 sizeof(XAStreamInformationItfImpl)); |
|
282 if (self) |
|
283 { |
|
284 /* init itf default implementation */ |
|
285 self->itf.QueryMediaContainerInformation |
|
286 = XAStreamInformationItfImpl_QueryMediaContainerInformation; |
|
287 self->itf.QueryStreamType |
|
288 = XAStreamInformationItfImpl_QueryStreamType; |
|
289 self->itf.QueryStreamInformation |
|
290 = XAStreamInformationItfImpl_QueryStreamInformation; |
|
291 self->itf.QueryStreamName |
|
292 = XAStreamInformationItfImpl_QueryStreamName; |
|
293 self->itf.RegisterStreamChangeCallback |
|
294 = XAStreamInformationItfImpl_RegisterStreamChangeCallback; |
|
295 self->itf.QueryActiveStreams |
|
296 = XAStreamInformationItfImpl_QueryActiveStreams; |
|
297 self->itf.SetActiveStream |
|
298 = XAStreamInformationItfImpl_SetActiveStream; |
|
299 |
|
300 /* init variables */ |
|
301 self->cbPtrToSelf = NULL; |
|
302 self->callback = NULL; |
|
303 self->cbcontext = NULL; |
|
304 self->adapCtx = adapCtx; |
|
305 |
|
306 self->self = self; |
|
307 } |
|
308 |
|
309 DEBUG_API("<-XAStreamInformationItfImpl_Create"); |
|
310 return self; |
|
311 } |
|
312 |
|
313 /* void XAStreamInformationItfImpl_Free(XAStreamInformationItfImpl* self) |
|
314 * Description: Free all resources reserved at XAStreamInformationItfImpl_Create |
|
315 */ |
|
316 void XAStreamInformationItfImpl_Free(XAStreamInformationItfImpl* self) |
|
317 { |
|
318 DEBUG_API("->XAStreamInformationItfImpl_Free"); |
|
319 if(self) |
|
320 { |
|
321 assert(self==self->self); |
|
322 free(self); |
|
323 } |
|
324 DEBUG_API("<-XAStreamInformationItfImpl_Free"); |
|
325 } |
|
326 |