32 * Sets play state to GStreamer. |
33 * Sets play state to GStreamer. |
33 * @param XAAdaptationBaseCtx *bCtx - Adaptation context, this will be casted to correct type regarding to contextID |
34 * @param XAAdaptationBaseCtx *bCtx - Adaptation context, this will be casted to correct type regarding to contextID |
34 * XAuint32 state - Play state to be set |
35 * XAuint32 state - Play state to be set |
35 * @return XAresult ret - Success value |
36 * @return XAresult ret - Success value |
36 */ |
37 */ |
37 XAresult XAPlayItfAdaptMMF_SetPlayState(XAAdaptationBaseCtx *bCtx, XAuint32 state) |
38 XAresult XAPlayItfAdaptMMF_SetPlayState(XAAdaptationBaseCtx *bCtx, |
38 { |
39 XAuint32 state) |
39 XAresult ret = XA_RESULT_SUCCESS; |
40 { |
40 XAMediaPlayerAdaptationMMFCtx* mCtx = (XAMediaPlayerAdaptationMMFCtx*) bCtx; |
41 XAresult ret = XA_RESULT_SUCCESS; |
|
42 XAMediaPlayerAdaptationMMFCtx* mCtx; |
|
43 if (!bCtx) |
|
44 { |
|
45 ret = XA_RESULT_PARAMETER_INVALID; |
|
46 return ret; |
|
47 } |
|
48 |
|
49 mCtx = (XAMediaPlayerAdaptationMMFCtx*) bCtx; |
|
50 |
41 |
51 |
42 DEBUG_API_A1("->XAPlayItfAdaptMMF_SetPlayState %s",PLAYSTATENAME(state)); |
52 DEBUG_API_A1("->XAPlayItfAdaptMMF_SetPlayState %s",PLAYSTATENAME(state)); |
43 |
53 |
44 /* bCtx and parameter pointer validation happens in the calling function. |
54 /* bCtx and parameter pointer validation happens in the calling function. |
45 * We don't need to repeat it here*/ |
55 * We don't need to repeat it here*/ |
46 switch ( state ) |
56 switch (state) |
47 { |
57 { |
48 case XA_PLAYSTATE_STOPPED: |
58 case XA_PLAYSTATE_STOPPED: |
49 { |
59 { |
50 ret = mmf_playitf_stop_playback(mCtx->mmfContext); |
60 if (bCtx->ctxId == XARadioAdaptation) |
|
61 { |
|
62 mmf_set_player_adapt_context(cmmfradiobackendengine_init(), |
|
63 bCtx); |
|
64 stop_radio(cmmfradiobackendengine_init()); |
|
65 } |
|
66 else |
|
67 { |
|
68 ret = mmf_playitf_stop_playback(mCtx->mmfContext); |
|
69 } |
51 break; |
70 break; |
52 } |
71 } |
53 case XA_PLAYSTATE_PAUSED: |
72 case XA_PLAYSTATE_PAUSED: |
54 ret = mmf_playitf_pause_playback(mCtx->mmfContext); |
73 ret = mmf_playitf_pause_playback(mCtx->mmfContext); |
55 break; |
74 break; |
56 case XA_PLAYSTATE_PLAYING: |
75 case XA_PLAYSTATE_PLAYING: |
57 { |
76 { |
58 ret = mmf_playitf_resume_playback(mCtx->mmfContext); |
77 if (bCtx->ctxId == XARadioAdaptation) |
|
78 { |
|
79 mmf_set_player_adapt_context(cmmfradiobackendengine_init(), |
|
80 bCtx); |
|
81 play_radio(cmmfradiobackendengine_init()); |
|
82 } |
|
83 else |
|
84 { |
|
85 ret = mmf_playitf_resume_playback(mCtx->mmfContext); |
|
86 } |
59 break; |
87 break; |
60 } |
88 } |
61 default: |
89 default: |
62 ret = XA_RESULT_PARAMETER_INVALID; |
90 ret = XA_RESULT_PARAMETER_INVALID; |
63 break; |
91 break; |
64 } |
92 } |
65 |
93 |
66 DEBUG_API("<-XAPlayItfAdaptMMF_SetPlayState"); |
94 DEBUG_API("<-XAPlayItfAdaptMMF_SetPlayState"); |
67 return ret; |
95 return ret; |
68 } |
96 } |
69 |
97 |
70 /* |
98 /* |
71 * XAresult XAPlayItfAdaptMMF_GetPlayState(XAAdaptationBaseCtx *bCtx, XAuint32 *pState) |
99 * XAresult XAPlayItfAdaptMMF_GetPlayState(XAAdaptationBaseCtx *bCtx, XAuint32 *pState) |
72 * @param XAAdaptationBaseCtx *bCtx - Adaptation context, this will be casted to correct type regarding to contextID |
100 * @param XAAdaptationBaseCtx *bCtx - Adaptation context, this will be casted to correct type regarding to contextID |
73 * XAuint32 *state - XAmillisecond *pMsec - Pointer where to store play state |
101 * XAuint32 *state - XAmillisecond *pMsec - Pointer where to store play state |
74 * @return XAresult ret - Success value |
102 * @return XAresult ret - Success value |
75 */ |
103 */ |
76 XAresult XAPlayItfAdaptMMF_GetPlayState(XAAdaptationBaseCtx *bCtx, XAuint32 *pState) |
104 XAresult XAPlayItfAdaptMMF_GetPlayState(XAAdaptationBaseCtx *bCtx, |
77 { |
105 XAuint32 *pState) |
78 XAresult ret = XA_RESULT_SUCCESS; |
106 { |
79 XAMediaPlayerAdaptationMMFCtx* mCtx = (XAMediaPlayerAdaptationMMFCtx*) bCtx; |
107 XAresult ret = XA_RESULT_SUCCESS; |
|
108 XAMediaPlayerAdaptationMMFCtx* pSelf; |
|
109 if (!bCtx || !pState) |
|
110 { |
|
111 ret = XA_RESULT_PARAMETER_INVALID; |
|
112 return ret; |
|
113 } |
|
114 |
|
115 pSelf = (XAMediaPlayerAdaptationMMFCtx*) bCtx; |
80 |
116 |
81 DEBUG_API("->XAPlayItfAdaptMMF_GetPlayState"); |
117 DEBUG_API("->XAPlayItfAdaptMMF_GetPlayState"); |
82 |
118 |
83 /* If playhead reaches eof, state will transition to paused. |
119 /* If playhead reaches eof, state will transition to paused. |
84 * This object does not have visibility to callback*/ |
120 * This object does not have visibility to callback*/ |
85 ret = mmf_playitf_get_play_state(mCtx->mmfContext, pState); |
121 ret = mmf_playitf_get_play_state(pSelf->mmfContext, pState); |
86 |
122 |
87 DEBUG_API("<-XAPlayItfAdaptMMF_GetPlayState"); |
123 DEBUG_API("<-XAPlayItfAdaptMMF_GetPlayState"); |
88 return ret; |
124 return ret; |
89 |
125 |
90 } |
126 } |
93 * XAresult XAPlayItfAdaptMMF_GetDuration(XAAdaptationBaseCtx *bCtx, XAmillisecond *pMsec) |
129 * XAresult XAPlayItfAdaptMMF_GetDuration(XAAdaptationBaseCtx *bCtx, XAmillisecond *pMsec) |
94 * @param XAAdaptationBaseCtx *bCtx - Adaptation context, this will be casted to correct type regarding to contextID |
130 * @param XAAdaptationBaseCtx *bCtx - Adaptation context, this will be casted to correct type regarding to contextID |
95 * XAmillisecond *pMsec - Pointer where to store duration of stream. |
131 * XAmillisecond *pMsec - Pointer where to store duration of stream. |
96 * @return XAresult ret - Success value |
132 * @return XAresult ret - Success value |
97 */ |
133 */ |
98 XAresult XAPlayItfAdaptMMF_GetDuration(XAAdaptationBaseCtx *bCtx, XAmillisecond *pMsec) |
134 XAresult XAPlayItfAdaptMMF_GetDuration(XAAdaptationBaseCtx *bCtx, |
99 { |
135 XAmillisecond *pMsec) |
100 XAresult ret = XA_RESULT_SUCCESS; |
136 { |
101 XAMediaPlayerAdaptationMMFCtx* mCtx = (XAMediaPlayerAdaptationMMFCtx*) bCtx; |
137 XAresult ret = XA_RESULT_SUCCESS; |
|
138 XAMediaPlayerAdaptationMMFCtx* pSelf; |
|
139 if (!bCtx || !pMsec) |
|
140 { |
|
141 ret = XA_RESULT_PARAMETER_INVALID; |
|
142 return ret; |
|
143 } |
|
144 |
|
145 pSelf = (XAMediaPlayerAdaptationMMFCtx*) bCtx; |
102 |
146 |
103 DEBUG_API("->XAPlayItfAdaptMMF_GetDuration"); |
147 DEBUG_API("->XAPlayItfAdaptMMF_GetDuration"); |
104 |
148 |
105 ret = mmf_playitf_get_duration(mCtx->mmfContext, pMsec); |
149 ret = mmf_playitf_get_duration(pSelf->mmfContext, pMsec); |
106 |
150 |
107 DEBUG_API("<-XAPlayItfAdaptMMF_GetDuration"); |
151 DEBUG_API("<-XAPlayItfAdaptMMF_GetDuration"); |
108 return ret; |
152 return ret; |
109 } |
153 } |
110 |
154 |
111 /* |
155 /* |
112 * XAresult XAPlayItfAdaptMMF_GetPosition(XAAdaptationBaseCtx *bCtx, XAmillisecond *pMsec) |
156 * XAresult XAPlayItfAdaptMMF_GetPosition(XAAdaptationBaseCtx *bCtx, XAmillisecond *pMsec) |
113 * @param XAAdaptationBaseCtx *bCtx - Adaptation context, this will be casted to correct type regarding to contextID value |
157 * @param XAAdaptationBaseCtx *bCtx - Adaptation context, this will be casted to correct type regarding to contextID value |
114 * XAmillisecond *pMsec - Pointer where to store current position in stream. |
158 * XAmillisecond *pMsec - Pointer where to store current position in stream. |
115 * @return XAresult ret - Success value |
159 * @return XAresult ret - Success value |
116 */ |
160 */ |
117 XAresult XAPlayItfAdaptMMF_GetPosition(XAAdaptationBaseCtx *bCtx, XAmillisecond *pMsec) |
161 XAresult XAPlayItfAdaptMMF_GetPosition(XAAdaptationBaseCtx *bCtx, |
118 { |
162 XAmillisecond *pMsec) |
119 XAresult ret = XA_RESULT_SUCCESS; |
163 { |
120 XAMediaPlayerAdaptationMMFCtx* mCtx = (XAMediaPlayerAdaptationMMFCtx*) bCtx; |
164 XAresult ret = XA_RESULT_SUCCESS; |
|
165 XAMediaPlayerAdaptationMMFCtx* pSelf; |
|
166 if (!bCtx || !pMsec) |
|
167 { |
|
168 ret = XA_RESULT_PARAMETER_INVALID; |
|
169 return ret; |
|
170 } |
|
171 |
|
172 pSelf = (XAMediaPlayerAdaptationMMFCtx*) bCtx; |
121 |
173 |
122 DEBUG_API("->XAPlayItfAdaptMMF_GetPosition"); |
174 DEBUG_API("->XAPlayItfAdaptMMF_GetPosition"); |
123 |
175 |
124 ret = mmf_playitf_get_position(mCtx->mmfContext, pMsec); |
176 ret = mmf_playitf_get_position(pSelf->mmfContext, pMsec); |
125 |
177 |
126 DEBUG_API("<-XAPlayItfAdaptMMF_GetPosition"); |
178 DEBUG_API("<-XAPlayItfAdaptMMF_GetPosition"); |
127 return ret; |
179 return ret; |
128 } |
180 } |
129 |
181 |
130 /* |
182 /* |
131 * XAresult XAPlayItfAdaptMMF_RegisterCallback(XAAdaptationBaseCtx *bCtx, xaPlayCallback callback) |
183 * XAresult XAPlayItfAdaptMMF_RegisterCallback(XAAdaptationBaseCtx *bCtx, xaPlayCallback callback) |
132 * Description: Sets the playback callback function. |
184 * Description: Sets the playback callback function. |
133 */ |
185 */ |
134 XAresult XAPlayItfAdaptMMF_RegisterCallback(XAAdaptationBaseCtx *bCtx, xaPlayCallback callback) |
186 XAresult XAPlayItfAdaptMMF_RegisterCallback(XAAdaptationBaseCtx *bCtx, |
135 { |
187 xaPlayCallback callback) |
136 XAresult ret = XA_RESULT_SUCCESS; |
188 { |
137 XAMediaPlayerAdaptationMMFCtx* mCtx = (XAMediaPlayerAdaptationMMFCtx*) bCtx; |
189 XAresult ret = XA_RESULT_SUCCESS; |
|
190 XAMediaPlayerAdaptationMMFCtx* pSelf; |
|
191 if (!bCtx) |
|
192 { |
|
193 ret = XA_RESULT_PARAMETER_INVALID; |
|
194 return ret; |
|
195 } |
|
196 |
|
197 pSelf = (XAMediaPlayerAdaptationMMFCtx*) bCtx; |
138 |
198 |
139 DEBUG_API("->XAPlayItfAdaptMMF_RegisterCallback"); |
199 DEBUG_API("->XAPlayItfAdaptMMF_RegisterCallback"); |
140 |
200 |
141 ret = mmf_playitf_register_callback(mCtx->mmfContext, callback); |
201 ret = mmf_playitf_register_callback(pSelf->mmfContext, callback); |
142 |
202 |
143 DEBUG_API("<-XAPlayItfAdaptMMF_RegisterCallback"); |
203 DEBUG_API("<-XAPlayItfAdaptMMF_RegisterCallback"); |
144 return ret; |
204 return ret; |
145 } |
205 } |
146 |
206 |
147 /** |
207 /** |
148 * XAresult XAPlayItfAdaptMMF_SetCallbackEventsMask(XAAdaptationBaseCtx *bCtx, XAuint32 eventFlags) |
208 * XAresult XAPlayItfAdaptMMF_SetCallbackEventsMask(XAAdaptationBaseCtx *bCtx, XAuint32 eventFlags) |
149 * Description: Enables/disables notification of playback events. |
209 * Description: Enables/disables notification of playback events. |
150 **/ |
210 **/ |
151 XAresult XAPlayItfAdaptMMF_SetCallbackEventsMask(XAAdaptationBaseCtx *bCtx, XAuint32 eventFlags) |
211 XAresult XAPlayItfAdaptMMF_SetCallbackEventsMask(XAAdaptationBaseCtx *bCtx, |
152 { |
212 XAuint32 eventFlags) |
153 XAresult ret = XA_RESULT_SUCCESS; |
213 { |
154 XAMediaPlayerAdaptationMMFCtx* mCtx = (XAMediaPlayerAdaptationMMFCtx*) bCtx; |
214 XAresult ret = XA_RESULT_SUCCESS; |
|
215 XAMediaPlayerAdaptationMMFCtx* pSelf; |
|
216 if (!bCtx) |
|
217 { |
|
218 ret = XA_RESULT_PARAMETER_INVALID; |
|
219 return ret; |
|
220 } |
|
221 |
|
222 pSelf = (XAMediaPlayerAdaptationMMFCtx*) bCtx; |
155 |
223 |
156 DEBUG_API("->XAPlayItfAdaptMMF_SetCallbackEventsMask"); |
224 DEBUG_API("->XAPlayItfAdaptMMF_SetCallbackEventsMask"); |
157 |
225 |
158 ret = mmf_playitf_set_callback_events_mask(mCtx->mmfContext, eventFlags); |
226 ret = mmf_playitf_set_callback_events_mask(pSelf->mmfContext, eventFlags); |
159 |
227 |
160 DEBUG_API("<-XAPlayItfAdaptMMF_SetCallbackEventsMask"); |
228 DEBUG_API("<-XAPlayItfAdaptMMF_SetCallbackEventsMask"); |
161 return ret; |
229 return ret; |
162 } |
230 } |
163 |
231 |
164 /** |
232 /** |
165 * XAresult XAPlayItfAdaptMMF_SetMarkerPosition(XAAdaptationBaseCtx *bCtx, XAmillisecond mSec) |
233 * XAresult XAPlayItfAdaptMMF_SetMarkerPosition(XAAdaptationBaseCtx *bCtx, XAmillisecond mSec) |
166 * Description: Sets marker position. |
234 * Description: Sets marker position. |
167 **/ |
235 **/ |
168 XAresult XAPlayItfAdaptMMF_SetMarkerPosition(XAAdaptationBaseCtx *bCtx, XAmillisecond mSec) |
236 XAresult XAPlayItfAdaptMMF_SetMarkerPosition(XAAdaptationBaseCtx *bCtx, |
169 { |
237 XAmillisecond mSec) |
170 XAresult ret = XA_RESULT_SUCCESS; |
238 { |
171 XAMediaPlayerAdaptationMMFCtx* mCtx = (XAMediaPlayerAdaptationMMFCtx*) bCtx; |
239 XAresult ret = XA_RESULT_SUCCESS; |
|
240 XAMediaPlayerAdaptationMMFCtx* pSelf; |
|
241 if (!bCtx) |
|
242 { |
|
243 ret = XA_RESULT_PARAMETER_INVALID; |
|
244 return ret; |
|
245 } |
|
246 |
|
247 pSelf = (XAMediaPlayerAdaptationMMFCtx*) bCtx; |
172 |
248 |
173 DEBUG_API("->XAPlayItfAdaptMMF_SetMarkerPosition"); |
249 DEBUG_API("->XAPlayItfAdaptMMF_SetMarkerPosition"); |
174 |
250 |
175 ret = mmf_playitf_set_marker_position(mCtx->mmfContext, mSec); |
251 ret = mmf_playitf_set_marker_position(pSelf->mmfContext, mSec); |
176 |
252 |
177 DEBUG_API("<-XAPlayItfAdaptMMF_SetMarkerPosition"); |
253 DEBUG_API("<-XAPlayItfAdaptMMF_SetMarkerPosition"); |
178 return ret; |
254 return ret; |
179 } |
255 } |
180 |
256 |
181 /** |
257 /** |
182 * XAresult XAPlayItfAdaptMMF_SetCallbackEventsMask(XAAdaptationBaseCtx *bCtx, XAuint32 eventFlags) |
258 * XAresult XAPlayItfAdaptMMF_SetCallbackEventsMask(XAAdaptationBaseCtx *bCtx, XAuint32 eventFlags) |
183 * Description: Clears marker position. |
259 * Description: Clears marker position. |
184 **/ |
260 **/ |
185 XAresult XAPlayItfAdaptMMF_ClearMarkerPosition(XAAdaptationBaseCtx *bCtx) |
261 XAresult XAPlayItfAdaptMMF_ClearMarkerPosition(XAAdaptationBaseCtx *bCtx) |
186 { |
262 { |
187 XAresult ret = XA_RESULT_SUCCESS; |
263 XAresult ret = XA_RESULT_SUCCESS; |
188 XAMediaPlayerAdaptationMMFCtx* mCtx = (XAMediaPlayerAdaptationMMFCtx*) bCtx; |
264 XAMediaPlayerAdaptationMMFCtx* pSelf; |
|
265 if (!bCtx) |
|
266 { |
|
267 ret = XA_RESULT_PARAMETER_INVALID; |
|
268 return ret; |
|
269 } |
|
270 |
|
271 pSelf = (XAMediaPlayerAdaptationMMFCtx*) bCtx; |
189 |
272 |
190 DEBUG_API("->XAPlayItfAdaptMMF_ClearMarkerPosition"); |
273 DEBUG_API("->XAPlayItfAdaptMMF_ClearMarkerPosition"); |
191 |
274 |
192 ret = mmf_playitf_clear_marker_position(mCtx->mmfContext); |
275 ret = mmf_playitf_clear_marker_position(pSelf->mmfContext); |
193 |
276 |
194 DEBUG_API("<-XAPlayItfAdaptMMF_ClearMarkerPosition"); |
277 DEBUG_API("<-XAPlayItfAdaptMMF_ClearMarkerPosition"); |
195 return ret; |
278 return ret; |
196 } |
279 } |
197 |
280 |
198 /** |
281 /** |
199 * XAPlayItfAdaptMMF_SetPositionUpdatePeriod(XAAdaptationBaseCtx *bCtx, XAmillisecond mSec) |
282 * XAPlayItfAdaptMMF_SetPositionUpdatePeriod(XAAdaptationBaseCtx *bCtx, XAmillisecond mSec) |
200 * Description: Sets position update period. |
283 * Description: Sets position update period. |
201 **/ |
284 **/ |
202 XAresult XAPlayItfAdaptMMF_SetPositionUpdatePeriod(XAAdaptationBaseCtx *bCtx, XAmillisecond mSec) |
285 XAresult XAPlayItfAdaptMMF_SetPositionUpdatePeriod(XAAdaptationBaseCtx *bCtx, |
203 { |
286 XAmillisecond mSec) |
204 XAresult ret = XA_RESULT_SUCCESS; |
287 { |
205 XAMediaPlayerAdaptationMMFCtx* mCtx = (XAMediaPlayerAdaptationMMFCtx*) bCtx; |
288 XAresult ret = XA_RESULT_SUCCESS; |
|
289 XAMediaPlayerAdaptationMMFCtx* pSelf; |
|
290 if (!bCtx) |
|
291 { |
|
292 ret = XA_RESULT_PARAMETER_INVALID; |
|
293 return ret; |
|
294 } |
|
295 |
|
296 pSelf = (XAMediaPlayerAdaptationMMFCtx*) bCtx; |
206 |
297 |
207 DEBUG_API("->XAPlayItfAdaptMMF_SetPositionUpdatePeriod"); |
298 DEBUG_API("->XAPlayItfAdaptMMF_SetPositionUpdatePeriod"); |
208 |
299 |
209 ret = mmf_playitf_set_position_update_period(mCtx->mmfContext, mSec); |
300 ret = mmf_playitf_set_position_update_period(pSelf->mmfContext, mSec); |
210 |
301 |
211 DEBUG_API("<-XAPlayItfAdaptMMF_SetPositionUpdatePeriod"); |
302 DEBUG_API("<-XAPlayItfAdaptMMF_SetPositionUpdatePeriod"); |
212 return ret; |
303 return ret; |
213 } |
304 } |
|
305 /* |
|
306 * XAresult XAPlayItfAdapt_StateChange |
|
307 * Handle callback from Radio utility |
|
308 */ |
|
309 void XAPlayItfAdaptMMF_StateChange(XAAdaptationBaseCtx *bCtx, |
|
310 XAboolean playing) |
|
311 { |
|
312 if (playing) |
|
313 { |
|
314 XAAdaptEvent event = |
|
315 { |
|
316 XA_PLAYITFEVENTS, XA_PLAYEVENT_HEADMOVING, 1, 0 |
|
317 }; |
|
318 XAAdaptationBase_SendAdaptEvents(bCtx, &event); |
|
319 } |
|
320 else |
|
321 { |
|
322 XAAdaptEvent event = |
|
323 { |
|
324 XA_PLAYITFEVENTS, XA_PLAYEVENT_HEADSTALLED, 1, 0 |
|
325 }; |
|
326 XAAdaptationBase_SendAdaptEvents(bCtx, &event); |
|
327 } |
|
328 |
|
329 } |