71 |
69 |
72 if (impl->pObjImpl->curAdaptCtx->fwtype == FWMgrFWMMF) |
70 if (impl->pObjImpl->curAdaptCtx->fwtype == FWMgrFWMMF) |
73 { |
71 { |
74 ret = XAPlayItfAdaptMMF_SetPlayState(impl->pObjImpl->curAdaptCtx, |
72 ret = XAPlayItfAdaptMMF_SetPlayState(impl->pObjImpl->curAdaptCtx, |
75 state); |
73 state); |
76 XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer ); |
|
77 DEBUG_API("<-XAPlayItfImpl_SetPlayState"); |
|
78 return ret; |
|
79 } |
|
80 |
|
81 /* check is play state changed, if not do nothing */ |
|
82 if (state != impl->playbackState) |
|
83 { |
|
84 if (state == XA_PLAYSTATE_PLAYING) |
|
85 { |
|
86 XAPlayItfAdaptGST_GetPosition( |
|
87 (XAAdaptationGstCtx*) impl->adapCtx, |
|
88 &(impl->lastPosition)); |
|
89 } |
|
90 ret = XAPlayItfAdaptGST_SetPlayState(impl->adapCtx, state); |
|
91 |
|
92 if (ret == XA_RESULT_SUCCESS) |
|
93 { |
|
94 impl->playbackState = state; |
|
95 if (state == XA_PLAYSTATE_STOPPED || state == XA_PLAYSTATE_PAUSED) |
|
96 { |
|
97 impl->isMarkerPosCbSend = XA_BOOLEAN_FALSE; |
|
98 impl->lastPosition = 0; |
|
99 } |
|
100 } |
|
101 } |
74 } |
102 |
75 |
103 XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer ); |
76 XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer ); |
104 DEBUG_API("<-XAPlayItfImpl_SetPlayState"); |
77 DEBUG_API("<-XAPlayItfImpl_SetPlayState"); |
105 return ret; |
78 return ret; |
203 |
167 |
204 if (impl->pObjImpl->curAdaptCtx->fwtype == FWMgrFWMMF) |
168 if (impl->pObjImpl->curAdaptCtx->fwtype == FWMgrFWMMF) |
205 { |
169 { |
206 ret = XAPlayItfAdaptMMF_GetPosition(impl->pObjImpl->curAdaptCtx, |
170 ret = XAPlayItfAdaptMMF_GetPosition(impl->pObjImpl->curAdaptCtx, |
207 pMsec); |
171 pMsec); |
208 } |
|
209 else |
|
210 { |
|
211 |
|
212 if (impl->playbackState == XA_PLAYSTATE_STOPPED) |
|
213 { |
|
214 *pMsec = 0; |
|
215 DEBUG_API("<-XAPlayItfImpl_GetPosition"); |
|
216 XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer ); |
|
217 return XA_RESULT_SUCCESS; |
|
218 } |
|
219 ret = XAPlayItfAdaptGST_GetPosition( |
|
220 (XAAdaptationGstCtx*) impl->adapCtx, pMsec); |
|
221 } |
172 } |
222 |
173 |
223 XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer ); |
174 XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer ); |
224 DEBUG_API("<-XAPlayItfImpl_GetPosition"); |
175 DEBUG_API("<-XAPlayItfImpl_GetPosition"); |
225 return ret; |
176 return ret; |
287 if (!impl || (eventFlags > (XA_PLAYEVENT_HEADATEND |
238 if (!impl || (eventFlags > (XA_PLAYEVENT_HEADATEND |
288 | XA_PLAYEVENT_HEADATMARKER | XA_PLAYEVENT_HEADATNEWPOS |
239 | XA_PLAYEVENT_HEADATMARKER | XA_PLAYEVENT_HEADATNEWPOS |
289 | XA_PLAYEVENT_HEADMOVING | XA_PLAYEVENT_HEADSTALLED))) |
240 | XA_PLAYEVENT_HEADMOVING | XA_PLAYEVENT_HEADSTALLED))) |
290 { |
241 { |
291 /* invalid parameter */ |
242 /* invalid parameter */ |
292 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");DEBUG_API("<-XAPlayItfImpl_SetCallbackEventsMask"); |
243 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
|
244 DEBUG_API("<-XAPlayItfImpl_SetCallbackEventsMask"); |
293 return XA_RESULT_PARAMETER_INVALID; |
245 return XA_RESULT_PARAMETER_INVALID; |
294 } |
246 } |
295 |
247 |
296 XA_IMPL_THREAD_SAFETY_ENTRY( XATSMediaPlayer ); |
248 XA_IMPL_THREAD_SAFETY_ENTRY( XATSMediaPlayer ); |
297 |
249 |
303 impl->pObjImpl->curAdaptCtx, eventFlags); |
255 impl->pObjImpl->curAdaptCtx, eventFlags); |
304 |
256 |
305 XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer ); |
257 XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer ); |
306 DEBUG_API("<-XAPlayItfImpl_SetCallbackEventsMask"); |
258 DEBUG_API("<-XAPlayItfImpl_SetCallbackEventsMask"); |
307 return ret; |
259 return ret; |
308 } |
|
309 |
|
310 /* enable position tracking if client wants so */ |
|
311 if ((eventFlags & (XA_PLAYEVENT_HEADATMARKER | XA_PLAYEVENT_HEADATNEWPOS)) |
|
312 && impl->adapCtx && !impl->positionupdateOn) |
|
313 { |
|
314 ret = XAPlayItfAdapt_EnablePositionTracking( |
|
315 (XAAdaptationGstCtx*) impl->adapCtx, XA_BOOLEAN_TRUE); |
|
316 if (ret == XA_RESULT_SUCCESS) |
|
317 { |
|
318 impl->positionupdateOn = XA_BOOLEAN_TRUE; |
|
319 } |
|
320 } |
|
321 else if (!(eventFlags & (XA_PLAYEVENT_HEADATMARKER |
|
322 | XA_PLAYEVENT_HEADATNEWPOS)) && impl->adapCtx |
|
323 && impl->positionupdateOn) |
|
324 { |
|
325 ret = XAPlayItfAdapt_EnablePositionTracking( |
|
326 (XAAdaptationGstCtx*) impl->adapCtx, XA_BOOLEAN_FALSE); |
|
327 if (ret == XA_RESULT_SUCCESS) |
|
328 { |
|
329 impl->positionupdateOn = XA_BOOLEAN_FALSE; |
|
330 } |
|
331 } |
260 } |
332 |
261 |
333 XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer ); |
262 XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer ); |
334 DEBUG_API("<-XAPlayItfImpl_SetCallbackEventsMask"); |
263 DEBUG_API("<-XAPlayItfImpl_SetCallbackEventsMask"); |
335 return ret; |
264 return ret; |
627 DEBUG_API("<-XAPlayItfImpl_AdaptCb"); |
555 DEBUG_API("<-XAPlayItfImpl_AdaptCb"); |
628 XA_IMPL_THREAD_SAFETY_EXIT_FOR_VOID_FUNCTIONS( XATSMediaPlayer ); |
556 XA_IMPL_THREAD_SAFETY_EXIT_FOR_VOID_FUNCTIONS( XATSMediaPlayer ); |
629 return; |
557 return; |
630 } |
558 } |
631 |
559 |
632 /* check position update events */ |
|
633 if (event->eventid == XA_ADAPT_POSITION_UPDATE_EVT) |
|
634 { |
|
635 assert(event->data); |
|
636 newpos = *((XAuint32*) (event->data)); |
|
637 DEBUG_API_A1("Position update from adaptation: new position %lu ms",newpos); |
|
638 |
|
639 /* Check is looping start file playing before marker position */ |
|
640 if (newpos < impl->markerPosition || impl->lastPosition > newpos) |
|
641 { |
|
642 DEBUG_INFO("Restart looping, clear marker position callback flag."); |
|
643 impl->isMarkerPosCbSend = XA_BOOLEAN_FALSE; |
|
644 } |
|
645 |
|
646 /* check if marker passed and callback needed */ |
|
647 if ((impl->markerPosition != NO_POSITION) && (impl->eventFlags |
|
648 & XA_PLAYEVENT_HEADATMARKER)) |
|
649 { |
|
650 if (impl->callback && (((impl->lastPosition |
|
651 < impl->markerPosition) |
|
652 && (newpos > impl->markerPosition)) || (newpos |
|
653 == impl->markerPosition))) |
|
654 { |
|
655 /* Check is callback already send */ |
|
656 if (impl->isMarkerPosCbSend != XA_BOOLEAN_TRUE) |
|
657 { |
|
658 impl->callback(impl->cbPtrToSelf, impl->cbcontext, |
|
659 XA_PLAYEVENT_HEADATMARKER); |
|
660 impl->isMarkerPosCbSend = XA_BOOLEAN_TRUE; |
|
661 } |
|
662 } |
|
663 } |
|
664 /* check if update period passed and callback needed */ |
|
665 if ((impl->positionUpdatePeriod > 0) && (impl->eventFlags |
|
666 & XA_PLAYEVENT_HEADATNEWPOS) && impl->callback) |
|
667 { |
|
668 if ((XAuint32) ((impl->lastPosition) |
|
669 / (impl->positionUpdatePeriod)) < (XAuint32) (newpos |
|
670 / (impl->positionUpdatePeriod))) |
|
671 { |
|
672 impl->callback(impl->cbPtrToSelf, impl->cbcontext, |
|
673 XA_PLAYEVENT_HEADATNEWPOS); |
|
674 } |
|
675 } |
|
676 /* store position */ |
|
677 impl->lastPosition = newpos; |
|
678 } |
|
679 |
|
680 /* check other events */ |
|
681 else if (event->eventid == XA_PLAYEVENT_HEADATEND) |
|
682 { |
|
683 impl->playbackState = XA_PLAYSTATE_STOPPED; |
|
684 impl->lastPosition = 0; |
|
685 /* send callback if needed */ |
|
686 if ((XA_PLAYEVENT_HEADATEND & impl->eventFlags) && impl->callback) |
|
687 { |
|
688 impl->callback(impl->cbPtrToSelf, impl->cbcontext, |
|
689 XA_PLAYEVENT_HEADATEND); |
|
690 } |
|
691 } |
|
692 else if (event->eventid == XA_PLAYEVENT_HEADSTALLED) |
|
693 { |
|
694 impl->playbackState = XA_PLAYSTATE_PAUSED; |
|
695 if (impl->adapCtx->fwtype == FWMgrFWMMF) |
|
696 { |
|
697 //XAPlayItfAdaptMMF_GetPosition((XAAdaptationGstCtx*)impl->adapCtx, &(impl->lastPosition)); |
|
698 } |
|
699 else |
|
700 { |
|
701 XAPlayItfAdaptGST_GetPosition( |
|
702 (XAAdaptationGstCtx*) impl->adapCtx, |
|
703 &(impl->lastPosition)); |
|
704 } |
|
705 /* send callback if needed */ |
|
706 if ((XA_PLAYEVENT_HEADSTALLED & impl->eventFlags) && impl->callback) |
|
707 { |
|
708 impl->callback(impl->cbPtrToSelf, impl->cbcontext, |
|
709 XA_PLAYEVENT_HEADSTALLED); |
|
710 } |
|
711 } |
|
712 else if (event->eventid == XA_PLAYEVENT_HEADMOVING) |
|
713 { |
|
714 impl->playbackState = XA_PLAYSTATE_PLAYING; |
|
715 /* send callback if needed */ |
|
716 if ((XA_PLAYEVENT_HEADMOVING & impl->eventFlags) && impl->callback) |
|
717 { |
|
718 impl->callback(impl->cbPtrToSelf, impl->cbcontext, |
|
719 XA_PLAYEVENT_HEADMOVING); |
|
720 } |
|
721 } |
|
722 else |
|
723 { |
|
724 /* do nothing */ |
|
725 } |
|
726 |
|
727 DEBUG_API("<-XAPlayItfImpl_AdaptCb"); |
560 DEBUG_API("<-XAPlayItfImpl_AdaptCb"); |
728 XA_IMPL_THREAD_SAFETY_EXIT_FOR_VOID_FUNCTIONS( XATSMediaPlayer ); |
561 XA_IMPL_THREAD_SAFETY_EXIT_FOR_VOID_FUNCTIONS( XATSMediaPlayer ); |
729 } |
562 } |
730 |
563 |