khronosfws/openmax_al/src/mediaplayer/xaplayitf.c
changeset 31 8dfd592727cb
parent 16 43d09473c595
child 42 1fa3fb47b1e3
equal deleted inserted replaced
22:128eb6a32b84 31:8dfd592727cb
     1 /*
     1 /*
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     2  * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3  * All rights reserved.
     4 * This component and the accompanying materials are made available
     4  * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5  * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6  * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     8  *
     9 * Initial Contributors:
     9  * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10  * Nokia Corporation - initial contribution.
    11 *
    11  *
    12 * Contributors:
    12  * Contributors:
    13 *
    13  *
    14 * Description: 
    14  * Description: Play Itf Implementation
    15 *
    15  *
    16 */
    16  */
    17 
    17 
    18 #include <stdio.h>
    18 #include <stdio.h>
    19 #include <stdlib.h>
    19 #include <stdlib.h>
    20 #include <assert.h>
    20 #include <assert.h>
    21 
    21 
    31 
    31 
    32 /* XAPlayItfImpl* GetImpl
    32 /* XAPlayItfImpl* GetImpl
    33  * Description: Validate interface pointer and cast it to implementation pointer.
    33  * Description: Validate interface pointer and cast it to implementation pointer.
    34  */
    34  */
    35 static XAPlayItfImpl* GetImpl(XAPlayItf self)
    35 static XAPlayItfImpl* GetImpl(XAPlayItf self)
    36 {
    36     {
    37     if(self)
    37     if (self)
    38     {
    38         {
    39         XAPlayItfImpl* impl = (XAPlayItfImpl*)(*self);
    39         XAPlayItfImpl* impl = (XAPlayItfImpl*) (*self);
    40         if(impl && impl == impl->self)
    40         if (impl && impl == impl->self)
    41         {
    41             {
    42             return impl;
    42             return impl;
    43         }
    43             }
    44     }
    44         }
    45     return NULL;
    45     return NULL;
    46 }
    46     }
    47 
    47 
    48 /**
    48 /**
    49  * Base interface XAPlayItf implementation
    49  * Base interface XAPlayItf implementation
    50  */
    50  */
    51 
    51 
    52 /**
    52 /**
    53  * XAresult XAPlayItfImpl_SetPlayState(XAPlayItf self, XAuint32 state)
    53  * XAresult XAPlayItfImpl_SetPlayState(XAPlayItf self, XAuint32 state)
    54  * Description: Requests a transition of the player into the given play state.
    54  * Description: Requests a transition of the player into the given play state.
    55  **/
    55  **/
    56 XAresult XAPlayItfImpl_SetPlayState(XAPlayItf self, XAuint32 state)
    56 XAresult XAPlayItfImpl_SetPlayState(XAPlayItf self, XAuint32 state)
    57 {
    57     {
    58     XAresult ret = XA_RESULT_SUCCESS;
    58     XAresult ret = XA_RESULT_SUCCESS;
    59     XAPlayItfImpl* impl = GetImpl(self);
    59     XAPlayItfImpl* impl = GetImpl(self);
    60     DEBUG_API_A1("->XAPlayItfImpl_SetPlayState %s",PLAYSTATENAME(state));
    60     DEBUG_API_A1("->XAPlayItfImpl_SetPlayState %s",PLAYSTATENAME(state));
    61 
    61 
    62     if( !impl || state < XA_PLAYSTATE_STOPPED || state > XA_PLAYSTATE_PLAYING )
    62     if (!impl || state < XA_PLAYSTATE_STOPPED || state > XA_PLAYSTATE_PLAYING)
    63     {
    63         {
    64         /* invalid parameter */
    64         /* invalid parameter */
    65         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
    65         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
    66         DEBUG_API("<-XAPlayItfImpl_SetPlayState");
    66         DEBUG_API("<-XAPlayItfImpl_SetPlayState");
    67         return XA_RESULT_PARAMETER_INVALID;
    67         return XA_RESULT_PARAMETER_INVALID;
    68     }
    68         }
    69 
    69 
    70     XA_IMPL_THREAD_SAFETY_ENTRY( XATSMediaPlayer );
    70     XA_IMPL_THREAD_SAFETY_ENTRY( XATSMediaPlayer );
    71 
    71 
    72     if(impl->pObjImpl->curAdaptCtx->fwtype == FWMgrFWMMF)
    72     if (impl->pObjImpl->curAdaptCtx->fwtype == FWMgrFWMMF)
    73     {
    73         {
    74         ret = XAPlayItfAdaptMMF_SetPlayState(impl->pObjImpl->curAdaptCtx, state);
    74         ret = XAPlayItfAdaptMMF_SetPlayState(impl->pObjImpl->curAdaptCtx,
       
    75                 state);
    75         XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer );
    76         XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer );
    76         DEBUG_API("<-XAPlayItfImpl_SetPlayState");
    77         DEBUG_API("<-XAPlayItfImpl_SetPlayState");
    77         return ret;		    
    78         return ret;
    78     }
    79         }
    79 
    80 
    80 	/* check is play state changed, if not do nothing */
    81     /* check is play state changed, if not do nothing */
    81     if(state != impl->playbackState)
    82     if (state != impl->playbackState)
    82 	{
    83         {
    83     	if(state == XA_PLAYSTATE_PLAYING)
    84         if (state == XA_PLAYSTATE_PLAYING)
    84     	{
    85             {
    85         	XAPlayItfAdaptGST_GetPosition((XAAdaptationGstCtx*)impl->adapCtx, &(impl->lastPosition));
    86             XAPlayItfAdaptGST_GetPosition(
    86     	}
    87                     (XAAdaptationGstCtx*) impl->adapCtx,
    87 		ret = XAPlayItfAdaptGST_SetPlayState(impl->adapCtx, state);
    88                     &(impl->lastPosition));
    88 
    89             }
    89 		if(ret == XA_RESULT_SUCCESS)
    90         ret = XAPlayItfAdaptGST_SetPlayState(impl->adapCtx, state);
    90 		    {
    91 
    91 		    impl->playbackState = state;
    92         if (ret == XA_RESULT_SUCCESS)
    92 		    if(state == XA_PLAYSTATE_STOPPED || state == XA_PLAYSTATE_PAUSED)
    93             {
    93 		        {
    94             impl->playbackState = state;
    94 		        impl->isMarkerPosCbSend = XA_BOOLEAN_FALSE;
    95             if (state == XA_PLAYSTATE_STOPPED || state == XA_PLAYSTATE_PAUSED)
    95 		        impl->lastPosition = 0;
    96                 {
    96 		        }
    97                 impl->isMarkerPosCbSend = XA_BOOLEAN_FALSE;
    97 		    }
    98                 impl->lastPosition = 0;
    98     }
    99                 }
       
   100             }
       
   101         }
    99 
   102 
   100     XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer );
   103     XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer );
   101     DEBUG_API("<-XAPlayItfImpl_SetPlayState");
   104     DEBUG_API("<-XAPlayItfImpl_SetPlayState");
   102     return ret;
   105     return ret;
   103 }
   106     }
   104 
   107 
   105 /**
   108 /**
   106  * XAresult XAPlayItfImpl_GetPlayState(XAPlayItf self, XAuint32 *pState)
   109  * XAresult XAPlayItfImpl_GetPlayState(XAPlayItf self, XAuint32 *pState)
   107  * Description: Gets the player's current play state.
   110  * Description: Gets the player's current play state.
   108  **/
   111  **/
   109 XAresult XAPlayItfImpl_GetPlayState(XAPlayItf self, XAuint32 *pState)
   112 XAresult XAPlayItfImpl_GetPlayState(XAPlayItf self, XAuint32 *pState)
   110 {
   113     {
   111     XAresult ret = XA_RESULT_SUCCESS;
   114     XAresult ret = XA_RESULT_SUCCESS;
   112     XAPlayItfImpl* impl = GetImpl(self);
   115     XAPlayItfImpl* impl = GetImpl(self);
   113 
   116 
   114     DEBUG_API("->XAPlayItfImpl_GetPlayState");
   117     DEBUG_API("->XAPlayItfImpl_GetPlayState");
   115 
   118 
   116     if(!impl || !pState)
   119     if (!impl || !pState)
   117     {
   120         {
   118         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   121         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   119         DEBUG_API("<-XAPlayItfImpl_GetPlayState");
   122         DEBUG_API("<-XAPlayItfImpl_GetPlayState");
   120         /* invalid parameter */
   123         /* invalid parameter */
   121         return XA_RESULT_PARAMETER_INVALID;
   124         return XA_RESULT_PARAMETER_INVALID;
   122     }
   125         }
   123 
   126 
   124     XA_IMPL_THREAD_SAFETY_ENTRY( XATSMediaPlayer );
   127     XA_IMPL_THREAD_SAFETY_ENTRY( XATSMediaPlayer );
   125 
   128 
   126     if(impl->pObjImpl->curAdaptCtx->fwtype == FWMgrFWMMF)
   129     if (impl->pObjImpl->curAdaptCtx->fwtype == FWMgrFWMMF)
   127     {
   130         {
   128         ret = XAPlayItfAdaptMMF_GetPlayState(impl->pObjImpl->curAdaptCtx, pState);    
   131         ret = XAPlayItfAdaptMMF_GetPlayState(impl->pObjImpl->curAdaptCtx,
   129     }
   132                 pState);
       
   133         }
   130     else
   134     else
   131     {
   135         {
   132         *pState = impl->playbackState;
   136         *pState = impl->playbackState;
   133     }
   137         }
   134 
   138 
   135     XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer );
   139     XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer );
   136 
   140 
   137     DEBUG_API_A1("<-XAPlayItfImpl_GetPlayState: %s",PLAYSTATENAME(impl->playbackState));
   141     DEBUG_API_A1("<-XAPlayItfImpl_GetPlayState: %s",PLAYSTATENAME(impl->playbackState));
   138     return ret;
   142     return ret;
   139 }
   143     }
   140 
   144 
   141 /**
   145 /**
   142  * XAresult XAPlayItfImpl_GetDuration(XAPlayItf self, XAmillisecond *pMsec)
   146  * XAresult XAPlayItfImpl_GetDuration(XAPlayItf self, XAmillisecond *pMsec)
   143  * Description: Gets the duration of the current content, in milliseconds.
   147  * Description: Gets the duration of the current content, in milliseconds.
   144  **/
   148  **/
   145 XAresult XAPlayItfImpl_GetDuration(XAPlayItf self, XAmillisecond *pMsec)
   149 XAresult XAPlayItfImpl_GetDuration(XAPlayItf self, XAmillisecond *pMsec)
   146 {
   150     {
   147     XAresult ret = XA_RESULT_SUCCESS;
   151     XAresult ret = XA_RESULT_SUCCESS;
   148     XAPlayItfImpl* impl = GetImpl(self);
   152     XAPlayItfImpl* impl = GetImpl(self);
   149     DEBUG_API("->XAPlayItfImpl_GetDuration");
   153     DEBUG_API("->XAPlayItfImpl_GetDuration");
   150 
   154 
   151     if(!impl || !pMsec)
   155     if (!impl || !pMsec)
   152     {
   156         {
   153         /* invalid parameter */
   157         /* invalid parameter */
   154         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   158         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   155         DEBUG_API("<-XAPlayItfImpl_GetDuration");
   159         DEBUG_API("<-XAPlayItfImpl_GetDuration");
   156         return XA_RESULT_PARAMETER_INVALID;
   160         return XA_RESULT_PARAMETER_INVALID;
   157     }
   161         }
   158 
   162 
   159     XA_IMPL_THREAD_SAFETY_ENTRY( XATSMediaPlayer );
   163     XA_IMPL_THREAD_SAFETY_ENTRY( XATSMediaPlayer );
   160 
   164 
   161     if(impl->pObjImpl->curAdaptCtx->fwtype == FWMgrFWMMF)
   165     if (impl->pObjImpl->curAdaptCtx->fwtype == FWMgrFWMMF)
   162     {
   166         {
   163         ret = XAPlayItfAdaptMMF_GetDuration(impl->pObjImpl->curAdaptCtx, pMsec);
   167         ret = XAPlayItfAdaptMMF_GetDuration(impl->pObjImpl->curAdaptCtx,
   164     }
   168                 pMsec);
       
   169         }
   165     else
   170     else
   166     {
   171         {
   167         ret = XAPlayItfAdaptGST_GetDuration((XAAdaptationGstCtx*)impl->adapCtx, pMsec);
   172         ret = XAPlayItfAdaptGST_GetDuration(
   168     }
   173                 (XAAdaptationGstCtx*) impl->adapCtx, pMsec);
   169     
   174         }
       
   175 
   170     XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer );
   176     XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer );
   171 
   177 
   172     DEBUG_API("<-XAPlayItfImpl_GetDuration");
   178     DEBUG_API("<-XAPlayItfImpl_GetDuration");
   173     return ret;
   179     return ret;
   174 }
   180     }
   175 
   181 
   176 /**
   182 /**
   177  * XAresult XAPlayItfImpl_GetPosition(XAPlayItf self, XAmillisecond *pMsec)
   183  * XAresult XAPlayItfImpl_GetPosition(XAPlayItf self, XAmillisecond *pMsec)
   178  * Description: Returns the current position of the playback head relative
   184  * Description: Returns the current position of the playback head relative
   179  * to the beginning of the content.
   185  * to the beginning of the content.
   180  **/
   186  **/
   181 XAresult XAPlayItfImpl_GetPosition(XAPlayItf self, XAmillisecond *pMsec)
   187 XAresult XAPlayItfImpl_GetPosition(XAPlayItf self, XAmillisecond *pMsec)
   182 {
   188     {
   183     XAresult ret = XA_RESULT_SUCCESS;
   189     XAresult ret = XA_RESULT_SUCCESS;
   184     XAPlayItfImpl* impl = GetImpl(self);
   190     XAPlayItfImpl* impl = GetImpl(self);
   185  
   191 
   186     DEBUG_API("->XAPlayItfImpl_GetPosition");
   192     DEBUG_API("->XAPlayItfImpl_GetPosition");
   187 
   193 
   188     if(!impl || !pMsec)
   194     if (!impl || !pMsec)
   189     {
   195         {
   190         /* invalid parameter */
   196         /* invalid parameter */
   191         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   197         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   192         DEBUG_API("<-XAPlayItfImpl_GetPosition");
   198         DEBUG_API("<-XAPlayItfImpl_GetPosition");
   193         return XA_RESULT_PARAMETER_INVALID;
   199         return XA_RESULT_PARAMETER_INVALID;
   194     }
   200         }
   195 
   201 
   196     XA_IMPL_THREAD_SAFETY_ENTRY( XATSMediaPlayer );
   202     XA_IMPL_THREAD_SAFETY_ENTRY( XATSMediaPlayer );
   197 
   203 
   198     if(impl->pObjImpl->curAdaptCtx->fwtype == FWMgrFWMMF)
   204     if (impl->pObjImpl->curAdaptCtx->fwtype == FWMgrFWMMF)
   199     {
   205         {
   200         ret = XAPlayItfAdaptMMF_GetPosition(impl->pObjImpl->curAdaptCtx, pMsec);
   206         ret = XAPlayItfAdaptMMF_GetPosition(impl->pObjImpl->curAdaptCtx,
   201     }
   207                 pMsec);
       
   208         }
   202     else
   209     else
   203     {
   210         {
   204 
   211 
   205         if ( impl->playbackState == XA_PLAYSTATE_STOPPED )
   212         if (impl->playbackState == XA_PLAYSTATE_STOPPED)
   206         {
   213             {
   207     	    *pMsec = 0;
   214             *pMsec = 0;
   208     	    DEBUG_API("<-XAPlayItfImpl_GetPosition");
   215             DEBUG_API("<-XAPlayItfImpl_GetPosition");
   209             XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer );    	
   216             XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer );
   210     	    return XA_RESULT_SUCCESS;
   217             return XA_RESULT_SUCCESS;
   211         }
   218             }
   212         ret = XAPlayItfAdaptGST_GetPosition((XAAdaptationGstCtx*)impl->adapCtx, pMsec);
   219         ret = XAPlayItfAdaptGST_GetPosition(
   213 	}
   220                 (XAAdaptationGstCtx*) impl->adapCtx, pMsec);
       
   221         }
   214 
   222 
   215     XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer );
   223     XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer );
   216     DEBUG_API("<-XAPlayItfImpl_GetPosition");
   224     DEBUG_API("<-XAPlayItfImpl_GetPosition");
   217     return ret;
   225     return ret;
   218 }
   226     }
   219 
   227 
   220 /**
   228 /**
   221  * XAresult XAPlayItfImpl_RegisterCallback(XAPlayItf self, xaPlayCallback callback,
   229  * XAresult XAPlayItfImpl_RegisterCallback(XAPlayItf self, xaPlayCallback callback,
   222  *                                         void *pContext)
   230  *                                         void *pContext)
   223  * Description: Sets the playback callback function.
   231  * Description: Sets the playback callback function.
   224  **/
   232  **/
   225 XAresult XAPlayItfImpl_RegisterCallback(XAPlayItf self, xaPlayCallback callback,
   233 XAresult XAPlayItfImpl_RegisterCallback(XAPlayItf self,
   226                                         void *pContext)
   234         xaPlayCallback callback, void *pContext)
   227 {
   235     {
   228     XAresult ret = XA_RESULT_SUCCESS;
   236     XAresult ret = XA_RESULT_SUCCESS;
   229     XAPlayItfImpl* impl = GetImpl(self);
   237     XAPlayItfImpl* impl = GetImpl(self);
   230 
   238 
   231     DEBUG_API("->XAPlayItfImpl_RegisterCallback");
   239     DEBUG_API("->XAPlayItfImpl_RegisterCallback");
   232     if(!impl)
   240     if (!impl)
   233     {
   241         {
   234         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   242         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   235         DEBUG_API("<-XAPlayItfImpl_RegisterCallback");
   243         DEBUG_API("<-XAPlayItfImpl_RegisterCallback");
   236         /* invalid parameter */
   244         /* invalid parameter */
   237         return XA_RESULT_PARAMETER_INVALID;
   245         return XA_RESULT_PARAMETER_INVALID;
   238     }
   246         }
   239 
   247 
   240     /* callback may be NULL (to remove callback) */
   248     /* callback may be NULL (to remove callback) */
   241     impl->callback = callback;
   249     impl->callback = callback;
   242     impl->cbcontext = pContext;
   250     impl->cbcontext = pContext;
   243     impl->cbPtrToSelf = self;
   251     impl->cbPtrToSelf = self;
   244 
   252 
   245     XA_IMPL_THREAD_SAFETY_ENTRY( XATSMediaPlayer );
   253     // No need to do anything else if radio:
   246 
   254     if (((XAMediaPlayerAdaptationMMFCtx*) impl->pObjImpl->curAdaptCtx)->isForRadio
   247     if(impl->pObjImpl->curAdaptCtx->fwtype == FWMgrFWMMF)
   255             == XA_BOOLEAN_TRUE)
   248     {
   256         {
   249         ret = XAPlayItfAdaptMMF_RegisterCallback(impl->pObjImpl->curAdaptCtx, callback);
   257         DEBUG_API("<-XAPlayItfImpl_RegisterCallback");
   250     }
   258         return ret;
       
   259         }
       
   260 
       
   261     XA_IMPL_THREAD_SAFETY_ENTRY( XATSMediaPlayer );
       
   262 
       
   263     if (impl->pObjImpl->curAdaptCtx->fwtype == FWMgrFWMMF)
       
   264         {
       
   265         ret = XAPlayItfAdaptMMF_RegisterCallback(impl->pObjImpl->curAdaptCtx,
       
   266                 callback);
       
   267         }
   251 
   268 
   252     XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer );
   269     XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer );
   253 
   270 
   254     DEBUG_API("<-XAPlayItfImpl_RegisterCallback");
   271     DEBUG_API("<-XAPlayItfImpl_RegisterCallback");
   255     return ret;
   272     return ret;
   256 }
   273     }
   257 
   274 
   258 /**
   275 /**
   259  * XAresult XAPlayItfImpl_SetCallbackEventsMask(XAPlayItf self, XAuint32 eventFlags)
   276  * XAresult XAPlayItfImpl_SetCallbackEventsMask(XAPlayItf self, XAuint32 eventFlags)
   260  * Description: Enables/disables notification of playback events.
   277  * Description: Enables/disables notification of playback events.
   261  **/
   278  **/
   262 XAresult XAPlayItfImpl_SetCallbackEventsMask(XAPlayItf self, XAuint32 eventFlags)
   279 XAresult XAPlayItfImpl_SetCallbackEventsMask(XAPlayItf self,
   263 {
   280         XAuint32 eventFlags)
       
   281     {
   264     XAresult ret = XA_RESULT_SUCCESS;
   282     XAresult ret = XA_RESULT_SUCCESS;
   265     XAPlayItfImpl* impl = GetImpl(self);
   283     XAPlayItfImpl* impl = GetImpl(self);
   266 
   284 
   267     DEBUG_API("->XAPlayItfImpl_SetCallbackEventsMask");
   285     DEBUG_API("->XAPlayItfImpl_SetCallbackEventsMask");
   268 
   286 
   269     if(!impl || ( eventFlags > (XA_PLAYEVENT_HEADATEND | XA_PLAYEVENT_HEADATMARKER |
   287     if (!impl || (eventFlags > (XA_PLAYEVENT_HEADATEND
   270                   XA_PLAYEVENT_HEADATNEWPOS | XA_PLAYEVENT_HEADMOVING | XA_PLAYEVENT_HEADSTALLED) ) )
   288             | XA_PLAYEVENT_HEADATMARKER | XA_PLAYEVENT_HEADATNEWPOS
   271     {
   289             | XA_PLAYEVENT_HEADMOVING | XA_PLAYEVENT_HEADSTALLED)))
   272         /* invalid parameter */
   290         {
   273         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   291         /* invalid parameter */
       
   292         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");DEBUG_API("<-XAPlayItfImpl_SetCallbackEventsMask");
       
   293         return XA_RESULT_PARAMETER_INVALID;
       
   294         }
       
   295 
       
   296     XA_IMPL_THREAD_SAFETY_ENTRY( XATSMediaPlayer );
       
   297 
       
   298     impl->eventFlags = eventFlags;
       
   299 
       
   300     if (impl->pObjImpl->curAdaptCtx->fwtype == FWMgrFWMMF)
       
   301         {
       
   302         ret = XAPlayItfAdaptMMF_SetCallbackEventsMask(
       
   303                 impl->pObjImpl->curAdaptCtx, eventFlags);
       
   304 
       
   305         XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer );
   274         DEBUG_API("<-XAPlayItfImpl_SetCallbackEventsMask");
   306         DEBUG_API("<-XAPlayItfImpl_SetCallbackEventsMask");
   275         return XA_RESULT_PARAMETER_INVALID;
   307         return ret;
   276     }
   308         }
   277 
       
   278     XA_IMPL_THREAD_SAFETY_ENTRY( XATSMediaPlayer );
       
   279 
       
   280     impl->eventFlags = eventFlags;
       
   281 
       
   282     if(impl->pObjImpl->curAdaptCtx->fwtype == FWMgrFWMMF)
       
   283     {
       
   284         ret = XAPlayItfAdaptMMF_SetCallbackEventsMask(impl->pObjImpl->curAdaptCtx, eventFlags);
       
   285 
       
   286 	    XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer );
       
   287 	    DEBUG_API("<-XAPlayItfImpl_SetCallbackEventsMask");
       
   288 	    return ret;
       
   289     }
       
   290 
   309 
   291     /* enable position tracking if client wants so */
   310     /* enable position tracking if client wants so */
   292     if( (eventFlags & (XA_PLAYEVENT_HEADATMARKER | XA_PLAYEVENT_HEADATNEWPOS))
   311     if ((eventFlags & (XA_PLAYEVENT_HEADATMARKER | XA_PLAYEVENT_HEADATNEWPOS))
   293         &&  impl->adapCtx && !impl->positionupdateOn)
   312             && impl->adapCtx && !impl->positionupdateOn)
   294         {
   313         {
   295         ret = XAPlayItfAdapt_EnablePositionTracking((XAAdaptationGstCtx*)impl->adapCtx, XA_BOOLEAN_TRUE);
   314         ret = XAPlayItfAdapt_EnablePositionTracking(
   296         if( ret == XA_RESULT_SUCCESS )
   315                 (XAAdaptationGstCtx*) impl->adapCtx, XA_BOOLEAN_TRUE);
   297         {
   316         if (ret == XA_RESULT_SUCCESS)
       
   317             {
   298             impl->positionupdateOn = XA_BOOLEAN_TRUE;
   318             impl->positionupdateOn = XA_BOOLEAN_TRUE;
   299         }
   319             }
   300     }
   320         }
   301     else if( !(eventFlags & (XA_PLAYEVENT_HEADATMARKER | XA_PLAYEVENT_HEADATNEWPOS))
   321     else if (!(eventFlags & (XA_PLAYEVENT_HEADATMARKER
   302             &&  impl->adapCtx && impl->positionupdateOn)
   322             | XA_PLAYEVENT_HEADATNEWPOS)) && impl->adapCtx
   303     {
   323             && impl->positionupdateOn)
   304         ret = XAPlayItfAdapt_EnablePositionTracking((XAAdaptationGstCtx*)impl->adapCtx, XA_BOOLEAN_FALSE);
   324         {
   305         if( ret == XA_RESULT_SUCCESS )
   325         ret = XAPlayItfAdapt_EnablePositionTracking(
   306         {
   326                 (XAAdaptationGstCtx*) impl->adapCtx, XA_BOOLEAN_FALSE);
       
   327         if (ret == XA_RESULT_SUCCESS)
       
   328             {
   307             impl->positionupdateOn = XA_BOOLEAN_FALSE;
   329             impl->positionupdateOn = XA_BOOLEAN_FALSE;
   308         }
   330             }
   309     }
   331         }
   310 
   332 
   311     XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer );
   333     XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer );
   312     DEBUG_API("<-XAPlayItfImpl_SetCallbackEventsMask");
   334     DEBUG_API("<-XAPlayItfImpl_SetCallbackEventsMask");
   313     return ret;
   335     return ret;
   314 }
   336     }
   315 
   337 
   316 /**
   338 /**
   317  * XAresult XAPlayItfImpl_GetCallbackEventsMask(XAPlayItf self, XAuint32 *pEventFlags)
   339  * XAresult XAPlayItfImpl_GetCallbackEventsMask(XAPlayItf self, XAuint32 *pEventFlags)
   318  * Description: Queries for the notification state (enabled/disabled) of playback events.
   340  * Description: Queries for the notification state (enabled/disabled) of playback events.
   319  **/
   341  **/
   320 XAresult XAPlayItfImpl_GetCallbackEventsMask(XAPlayItf self, XAuint32 *pEventFlags)
   342 XAresult XAPlayItfImpl_GetCallbackEventsMask(XAPlayItf self,
   321 {
   343         XAuint32 *pEventFlags)
       
   344     {
   322     XAresult ret = XA_RESULT_SUCCESS;
   345     XAresult ret = XA_RESULT_SUCCESS;
   323     XAPlayItfImpl* impl = GetImpl(self);
   346     XAPlayItfImpl* impl = GetImpl(self);
   324 
   347 
   325     DEBUG_API("->XAPlayItfImpl_GetCallbackEventsMask");
   348     DEBUG_API("->XAPlayItfImpl_GetCallbackEventsMask");
   326     if(!impl || !pEventFlags)
   349     if (!impl || !pEventFlags)
   327     {
   350         {
   328         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   351         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   329         DEBUG_API("<-XAPlayItfImpl_GetCallbackEventsMask");
   352         DEBUG_API("<-XAPlayItfImpl_GetCallbackEventsMask");
   330         /* invalid parameter */
   353         /* invalid parameter */
   331         return XA_RESULT_PARAMETER_INVALID;
   354         return XA_RESULT_PARAMETER_INVALID;
   332     }
   355         }
   333 
   356 
   334     *pEventFlags = impl->eventFlags;
   357     *pEventFlags = impl->eventFlags;
   335 
   358 
   336     DEBUG_API("<-XAPlayItfImpl_GetCallbackEventsMask");
   359     DEBUG_API("<-XAPlayItfImpl_GetCallbackEventsMask");
   337     return ret;
   360     return ret;
   338 }
   361     }
   339 
   362 
   340 /**
   363 /**
   341  * XAresult XAPlayItfImpl_SetMarkerPosition(XAPlayItf self, XAmillisecond mSec)
   364  * XAresult XAPlayItfImpl_SetMarkerPosition(XAPlayItf self, XAmillisecond mSec)
   342  * Description: Sets the position of the playback marker.
   365  * Description: Sets the position of the playback marker.
   343  **/
   366  **/
   344 XAresult XAPlayItfImpl_SetMarkerPosition(XAPlayItf self, XAmillisecond mSec)
   367 XAresult XAPlayItfImpl_SetMarkerPosition(XAPlayItf self, XAmillisecond mSec)
   345 {
   368     {
   346     XAresult ret = XA_RESULT_SUCCESS;
   369     XAresult ret = XA_RESULT_SUCCESS;
   347     XAmillisecond duration = 0;
   370     XAmillisecond duration = 0;
   348     XAPlayItfImpl* impl = GetImpl(self);
   371     XAPlayItfImpl* impl = GetImpl(self);
   349 
   372 
   350     DEBUG_API_A1("->XAPlayItfImpl_SetMarkerPosition: %lu ms", mSec);
   373     DEBUG_API_A1("->XAPlayItfImpl_SetMarkerPosition: %lu ms", mSec);
   351 
   374 
   352     /* Get duration of the content */
   375     /* Get duration of the content */
   353     if(XAPlayItfImpl_GetDuration(self, &duration) != XA_RESULT_SUCCESS)
   376     if (XAPlayItfImpl_GetDuration(self, &duration) != XA_RESULT_SUCCESS)
   354     {
   377         {
   355         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   378         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   356         DEBUG_API("<-XAPlayItfImpl_SetMarkerPosition");
   379         DEBUG_API("<-XAPlayItfImpl_SetMarkerPosition");
   357         /* invalid parameter */
   380         /* invalid parameter */
   358         return XA_RESULT_PARAMETER_INVALID;
   381         return XA_RESULT_PARAMETER_INVALID;
   359     }
   382         }
   360 
   383 
   361 
   384     if (!impl || mSec > duration)
   362     if(!impl || mSec > duration)
   385         {
   363     {
       
   364         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   386         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   365         DEBUG_API("<-XAPlayItfImpl_SetMarkerPosition");
   387         DEBUG_API("<-XAPlayItfImpl_SetMarkerPosition");
   366         /* invalid parameter */
   388         /* invalid parameter */
   367         return XA_RESULT_PARAMETER_INVALID;
   389         return XA_RESULT_PARAMETER_INVALID;
   368     }
   390         }
   369 
   391 
   370     impl->markerPosition = mSec;
   392     impl->markerPosition = mSec;
   371     impl->isMarkerPosCbSend = XA_BOOLEAN_FALSE;
   393     impl->isMarkerPosCbSend = XA_BOOLEAN_FALSE;
   372 
   394 
   373     XA_IMPL_THREAD_SAFETY_ENTRY( XATSMediaPlayer );
   395     XA_IMPL_THREAD_SAFETY_ENTRY( XATSMediaPlayer );
   374 
   396 
   375     if(impl->pObjImpl->curAdaptCtx->fwtype == FWMgrFWMMF)
   397     if (impl->pObjImpl->curAdaptCtx->fwtype == FWMgrFWMMF)
   376     {
   398         {
   377         ret = XAPlayItfAdaptMMF_SetMarkerPosition(impl->pObjImpl->curAdaptCtx, mSec);
   399         ret = XAPlayItfAdaptMMF_SetMarkerPosition(
   378     }
   400                 impl->pObjImpl->curAdaptCtx, mSec);
       
   401         }
   379 
   402 
   380     XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer );
   403     XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer );
   381 
   404 
   382     DEBUG_API("<-XAPlayItfImpl_SetMarkerPosition");
   405     DEBUG_API("<-XAPlayItfImpl_SetMarkerPosition");
   383     return ret;
   406     return ret;
   384 }
   407     }
   385 
   408 
   386 /**
   409 /**
   387  * XAresult XAPlayItfImpl_ClearMarkerPosition(XAPlayItf self)
   410  * XAresult XAPlayItfImpl_ClearMarkerPosition(XAPlayItf self)
   388  * Description: Clears marker.
   411  * Description: Clears marker.
   389  **/
   412  **/
   390 XAresult XAPlayItfImpl_ClearMarkerPosition(XAPlayItf self)
   413 XAresult XAPlayItfImpl_ClearMarkerPosition(XAPlayItf self)
   391 {
   414     {
   392     XAresult ret = XA_RESULT_SUCCESS;
   415     XAresult ret = XA_RESULT_SUCCESS;
   393     XAPlayItfImpl* impl = GetImpl(self);
   416     XAPlayItfImpl* impl = GetImpl(self);
   394 
   417 
   395     DEBUG_API("->XAPlayItfImpl_ClearMarkerPosition");
   418     DEBUG_API("->XAPlayItfImpl_ClearMarkerPosition");
   396     if(!impl)
   419     if (!impl)
   397     {
   420         {
   398         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   421         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   399         DEBUG_API("<-XAPlayItfImpl_ClearMarkerPosition");
   422         DEBUG_API("<-XAPlayItfImpl_ClearMarkerPosition");
   400         /* invalid parameter */
   423         /* invalid parameter */
   401         return XA_RESULT_PARAMETER_INVALID;
   424         return XA_RESULT_PARAMETER_INVALID;
   402     }
   425         }
   403 
   426 
   404     impl->isMarkerPosCbSend = XA_BOOLEAN_FALSE;
   427     impl->isMarkerPosCbSend = XA_BOOLEAN_FALSE;
   405     impl->markerPosition = NO_POSITION;
   428     impl->markerPosition = NO_POSITION;
   406 
   429 
   407     XA_IMPL_THREAD_SAFETY_ENTRY( XATSMediaPlayer );
   430     XA_IMPL_THREAD_SAFETY_ENTRY( XATSMediaPlayer );
   408 
   431 
   409     if(impl->pObjImpl->curAdaptCtx->fwtype == FWMgrFWMMF)
   432     if (impl->pObjImpl->curAdaptCtx->fwtype == FWMgrFWMMF)
   410     {
   433         {
   411         ret = XAPlayItfAdaptMMF_ClearMarkerPosition(impl->pObjImpl->curAdaptCtx);
   434         ret = XAPlayItfAdaptMMF_ClearMarkerPosition(
   412     }
   435                 impl->pObjImpl->curAdaptCtx);
       
   436         }
   413 
   437 
   414     XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer );
   438     XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer );
   415 
   439 
   416     DEBUG_API("<-XAPlayItfImpl_ClearMarkerPosition");
   440     DEBUG_API("<-XAPlayItfImpl_ClearMarkerPosition");
   417     return ret;
   441     return ret;
   418 }
   442     }
   419 
   443 
   420 /**
   444 /**
   421  * XAresult XAPlayItfImpl_GetMarkerPosition(XAPlayItf self, XAmillisecond *pMsec)
   445  * XAresult XAPlayItfImpl_GetMarkerPosition(XAPlayItf self, XAmillisecond *pMsec)
   422  * Description: Queries the position of playback marker.
   446  * Description: Queries the position of playback marker.
   423  **/
   447  **/
   424 XAresult XAPlayItfImpl_GetMarkerPosition(XAPlayItf self, XAmillisecond *pMsec)
   448 XAresult XAPlayItfImpl_GetMarkerPosition(XAPlayItf self, XAmillisecond *pMsec)
   425 {
   449     {
   426     XAresult ret = XA_RESULT_SUCCESS;
   450     XAresult ret = XA_RESULT_SUCCESS;
   427     XAPlayItfImpl* impl = GetImpl(self);
   451     XAPlayItfImpl* impl = GetImpl(self);
   428 
   452 
   429     DEBUG_API("->XAPlayItfImpl_GetMarkerPosition");
   453     DEBUG_API("->XAPlayItfImpl_GetMarkerPosition");
   430     if(!impl || !pMsec)
   454     if (!impl || !pMsec)
   431     {
   455         {
   432         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   456         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   433         DEBUG_API("<-XAPlayItfImpl_GetMarkerPosition");
   457         DEBUG_API("<-XAPlayItfImpl_GetMarkerPosition");
   434         /* invalid parameter */
   458         /* invalid parameter */
   435         return XA_RESULT_PARAMETER_INVALID;
   459         return XA_RESULT_PARAMETER_INVALID;
   436     }
   460         }
   437 
   461 
   438     if(impl->markerPosition == NO_POSITION)
   462     if (impl->markerPosition == NO_POSITION)
   439     {
   463         {
   440         DEBUG_ERR("XA_RESULT_PRECONDITIONS_VIOLATED");
   464         DEBUG_ERR("XA_RESULT_PRECONDITIONS_VIOLATED");
   441         DEBUG_API("<-XAPlayItfImpl_GetMarkerPosition");
   465         DEBUG_API("<-XAPlayItfImpl_GetMarkerPosition");
   442         /*marker is not set */
   466         /*marker is not set */
   443         return XA_RESULT_PRECONDITIONS_VIOLATED;
   467         return XA_RESULT_PRECONDITIONS_VIOLATED;
   444     }
   468         }
   445 
   469 
   446     *pMsec = impl->markerPosition;
   470     *pMsec = impl->markerPosition;
   447 
   471 
   448     DEBUG_API("<-XAPlayItfImpl_GetMarkerPosition");
   472     DEBUG_API("<-XAPlayItfImpl_GetMarkerPosition");
   449     return ret;
   473     return ret;
   450 }
   474     }
   451 
   475 
   452 /**
   476 /**
   453  * XAresult XAPlayItfImpl_SetPositionUpdatePeriod(XAPlayItf self, XAmillisecond mSec)
   477  * XAresult XAPlayItfImpl_SetPositionUpdatePeriod(XAPlayItf self, XAmillisecond mSec)
   454  * Description: Sets the interval between periodic position notifications.
   478  * Description: Sets the interval between periodic position notifications.
   455  **/
   479  **/
   456 XAresult XAPlayItfImpl_SetPositionUpdatePeriod(XAPlayItf self, XAmillisecond mSec)
   480 XAresult XAPlayItfImpl_SetPositionUpdatePeriod(XAPlayItf self,
   457 {
   481         XAmillisecond mSec)
       
   482     {
   458     XAresult ret = XA_RESULT_SUCCESS;
   483     XAresult ret = XA_RESULT_SUCCESS;
   459     XAPlayItfImpl* impl = GetImpl(self);
   484     XAPlayItfImpl* impl = GetImpl(self);
   460 
   485 
   461     DEBUG_API_A1("->XAPlayItfImpl_SetPositionUpdatePeriod, %lu mSec", mSec);
   486     DEBUG_API_A1("->XAPlayItfImpl_SetPositionUpdatePeriod, %lu mSec", mSec);
   462     if(!impl )
   487     if (!impl)
   463     {
   488         {
   464         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   489         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   465         DEBUG_API("<-XAPlayItfImpl_SetPositionUpdatePeriod");
   490         DEBUG_API("<-XAPlayItfImpl_SetPositionUpdatePeriod");
   466         /* invalid parameter */
   491         /* invalid parameter */
   467         return XA_RESULT_PARAMETER_INVALID;
   492         return XA_RESULT_PARAMETER_INVALID;
   468     }
   493         }
   469     impl->positionUpdatePeriod = mSec;
   494     impl->positionUpdatePeriod = mSec;
   470 
   495 
   471     XA_IMPL_THREAD_SAFETY_ENTRY( XATSMediaPlayer );
   496     XA_IMPL_THREAD_SAFETY_ENTRY( XATSMediaPlayer );
   472 
   497 
   473     if(impl->pObjImpl->curAdaptCtx->fwtype == FWMgrFWMMF)
   498     if (impl->pObjImpl->curAdaptCtx->fwtype == FWMgrFWMMF)
   474     {
   499         {
   475         ret = XAPlayItfAdaptMMF_SetPositionUpdatePeriod(impl->pObjImpl->curAdaptCtx, mSec);
   500         ret = XAPlayItfAdaptMMF_SetPositionUpdatePeriod(
   476     }
   501                 impl->pObjImpl->curAdaptCtx, mSec);
       
   502         }
   477 
   503 
   478     XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer );
   504     XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer );
   479 
   505 
   480     DEBUG_API("<-XAPlayItfImpl_SetPositionUpdatePeriod");
   506     DEBUG_API("<-XAPlayItfImpl_SetPositionUpdatePeriod");
   481     return ret;
   507     return ret;
   482 }
   508     }
   483 
   509 
   484 /**
   510 /**
   485  * XAresult XAPlayItfImpl_GetPositionUpdatePeriod(XAPlayItf self, XAmillisecond *pMsec)
   511  * XAresult XAPlayItfImpl_GetPositionUpdatePeriod(XAPlayItf self, XAmillisecond *pMsec)
   486  * Description: Queries the interval between periodic position notifications.
   512  * Description: Queries the interval between periodic position notifications.
   487  **/
   513  **/
   488 XAresult XAPlayItfImpl_GetPositionUpdatePeriod(XAPlayItf self, XAmillisecond *pMsec)
   514 XAresult XAPlayItfImpl_GetPositionUpdatePeriod(XAPlayItf self,
   489 {
   515         XAmillisecond *pMsec)
       
   516     {
   490     XAresult ret = XA_RESULT_SUCCESS;
   517     XAresult ret = XA_RESULT_SUCCESS;
   491     XAPlayItfImpl* impl = GetImpl(self);
   518     XAPlayItfImpl* impl = GetImpl(self);
   492 
   519 
   493     DEBUG_API("->XAPlayItfImpl_GetPositionUpdatePeriod");
   520     DEBUG_API("->XAPlayItfImpl_GetPositionUpdatePeriod");
   494     if(!impl || !pMsec)
   521     if (!impl || !pMsec)
   495     {
   522         {
   496         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   523         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   497         DEBUG_API("<-XAPlayItfImpl_GetPositionUpdatePeriod");
   524         DEBUG_API("<-XAPlayItfImpl_GetPositionUpdatePeriod");
   498         /* invalid parameter */
   525         /* invalid parameter */
   499         return XA_RESULT_PARAMETER_INVALID;
   526         return XA_RESULT_PARAMETER_INVALID;
   500     }
   527         }
   501 
   528 
   502     *pMsec = impl->positionUpdatePeriod;
   529     *pMsec = impl->positionUpdatePeriod;
   503 
   530 
   504     DEBUG_API("<-XAPlayItfImpl_GetPositionUpdatePeriod");
   531     DEBUG_API("<-XAPlayItfImpl_GetPositionUpdatePeriod");
   505     return ret;
   532     return ret;
   506 }
   533     }
   507 
       
   508 
   534 
   509 /**
   535 /**
   510  * XAPlayItfImpl -specific methods
   536  * XAPlayItfImpl -specific methods
   511  **/
   537  **/
   512 
   538 
   513 /**
   539 /**
   514  * XAPlayItfImpl* XAPlayItfImpl_Create()
   540  * XAPlayItfImpl* XAPlayItfImpl_Create()
   515  * Description: Allocate and initialize PlayItfImpl
   541  * Description: Allocate and initialize PlayItfImpl
   516  **/
   542  **/
   517 XAPlayItfImpl* XAPlayItfImpl_Create( XAMediaPlayerImpl *impl )
   543 XAPlayItfImpl* XAPlayItfImpl_Create(XAMediaPlayerImpl *impl)
   518 {
   544     {
   519     XAPlayItfImpl *self;
   545     XAPlayItfImpl *self;
   520 
   546 
   521     DEBUG_API("->XAPlayItfImpl_Create");
   547     DEBUG_API("->XAPlayItfImpl_Create");
   522     self = (XAPlayItfImpl*)calloc(1,sizeof(XAPlayItfImpl));
   548     self = (XAPlayItfImpl*) calloc(1, sizeof(XAPlayItfImpl));
   523     if(self)
   549     if (self)
   524     {
   550         {
   525         /* init itf default implementation */
   551         /* init itf default implementation */
   526         self->itf.ClearMarkerPosition = XAPlayItfImpl_ClearMarkerPosition;
   552         self->itf.ClearMarkerPosition = XAPlayItfImpl_ClearMarkerPosition;
   527         self->itf.GetCallbackEventsMask = XAPlayItfImpl_GetCallbackEventsMask;
   553         self->itf.GetCallbackEventsMask = XAPlayItfImpl_GetCallbackEventsMask;
   528         self->itf.GetDuration = XAPlayItfImpl_GetDuration;
   554         self->itf.GetDuration = XAPlayItfImpl_GetDuration;
   529         self->itf.GetMarkerPosition = XAPlayItfImpl_GetMarkerPosition;
   555         self->itf.GetMarkerPosition = XAPlayItfImpl_GetMarkerPosition;
   530         self->itf.GetPlayState = XAPlayItfImpl_GetPlayState;
   556         self->itf.GetPlayState = XAPlayItfImpl_GetPlayState;
   531         self->itf.GetPosition = XAPlayItfImpl_GetPosition;
   557         self->itf.GetPosition = XAPlayItfImpl_GetPosition;
   532         self->itf.GetPositionUpdatePeriod = XAPlayItfImpl_GetPositionUpdatePeriod;
   558         self->itf.GetPositionUpdatePeriod
       
   559                 = XAPlayItfImpl_GetPositionUpdatePeriod;
   533         self->itf.RegisterCallback = XAPlayItfImpl_RegisterCallback;
   560         self->itf.RegisterCallback = XAPlayItfImpl_RegisterCallback;
   534         self->itf.SetCallbackEventsMask = XAPlayItfImpl_SetCallbackEventsMask;
   561         self->itf.SetCallbackEventsMask = XAPlayItfImpl_SetCallbackEventsMask;
   535         self->itf.SetMarkerPosition = XAPlayItfImpl_SetMarkerPosition;
   562         self->itf.SetMarkerPosition = XAPlayItfImpl_SetMarkerPosition;
   536         self->itf.SetPlayState = XAPlayItfImpl_SetPlayState;
   563         self->itf.SetPlayState = XAPlayItfImpl_SetPlayState;
   537         self->itf.SetPositionUpdatePeriod = XAPlayItfImpl_SetPositionUpdatePeriod;
   564         self->itf.SetPositionUpdatePeriod
       
   565                 = XAPlayItfImpl_SetPositionUpdatePeriod;
   538 
   566 
   539         /* init variables */
   567         /* init variables */
   540         self->callback = NULL;
   568         self->callback = NULL;
   541         self->cbcontext = NULL;
   569         self->cbcontext = NULL;
   542         self->playbackState = XA_PLAYSTATE_STOPPED;
   570         self->playbackState = XA_PLAYSTATE_STOPPED;
   546         self->lastPosition = START_POSITION;
   574         self->lastPosition = START_POSITION;
   547         /*self->adapCtx = impl->curAdaptCtx;*/
   575         /*self->adapCtx = impl->curAdaptCtx;*/
   548         self->pObjImpl = impl;
   576         self->pObjImpl = impl;
   549         self->cbPtrToSelf = NULL;
   577         self->cbPtrToSelf = NULL;
   550         self->isMarkerPosCbSend = XA_BOOLEAN_FALSE;
   578         self->isMarkerPosCbSend = XA_BOOLEAN_FALSE;
   551         
   579 
   552 /*        XAAdaptationBase_AddEventHandler( self->adapCtx, &XAPlayItfImpl_AdaptCb, XA_PLAYITFEVENTS, self );*/
   580         /*        XAAdaptationBase_AddEventHandler( self->adapCtx, &XAPlayItfImpl_AdaptCb, XA_PLAYITFEVENTS, self );*/
   553         XAAdaptationBase_AddEventHandler( self->pObjImpl->curAdaptCtx, &XAPlayItfImpl_AdaptCb, XA_PLAYITFEVENTS, self );
   581         XAAdaptationBase_AddEventHandler(self->pObjImpl->curAdaptCtx,
       
   582                 &XAPlayItfImpl_AdaptCb, XA_PLAYITFEVENTS, self);
   554 
   583 
   555         self->self = self;
   584         self->self = self;
   556     }
   585         }
   557 
   586 
   558     DEBUG_API("<-XAPlayItfImpl_Create");
   587     DEBUG_API("<-XAPlayItfImpl_Create");
   559     return self;
   588     return self;
   560 }
   589     }
   561 
   590 
   562 /* void XAPlayItfImpl_Free(XAPlayItfImpl* self)
   591 /* void XAPlayItfImpl_Free(XAPlayItfImpl* self)
   563  * Description: Free all resources reserved at XAPlayItfImpl_Create
   592  * Description: Free all resources reserved at XAPlayItfImpl_Create
   564  */
   593  */
   565 void XAPlayItfImpl_Free(XAPlayItfImpl* self)
   594 void XAPlayItfImpl_Free(XAPlayItfImpl* self)
   566 {
   595     {
   567     DEBUG_API("->XAPlayItfImpl_Free");
   596     DEBUG_API("->XAPlayItfImpl_Free");
   568     assert(self==self->self);
   597     assert(self==self->self);
   569 /*    XAAdaptationBase_RemoveEventHandler( self->adapCtx, &XAPlayItfImpl_AdaptCb );*/
   598     /*    XAAdaptationBase_RemoveEventHandler( self->adapCtx, &XAPlayItfImpl_AdaptCb );*/
   570     XAAdaptationBase_RemoveEventHandler( self->pObjImpl->curAdaptCtx, &XAPlayItfImpl_AdaptCb );
   599     XAAdaptationBase_RemoveEventHandler(self->pObjImpl->curAdaptCtx,
       
   600             &XAPlayItfImpl_AdaptCb);
   571     free(self);
   601     free(self);
   572     DEBUG_API("<-XAPlayItfImpl_Free");
   602     DEBUG_API("<-XAPlayItfImpl_Free");
   573 }
   603     }
   574 
   604 
   575 /* void XAPlayItfImpl_AdaptCb
   605 /* void XAPlayItfImpl_AdaptCb
   576  * Description: Listen changes in adaptation
   606  * Description: Listen changes in adaptation
   577  */
   607  */
   578 void XAPlayItfImpl_AdaptCb( void *pHandlerCtx, XAAdaptEvent *event )
   608 void XAPlayItfImpl_AdaptCb(void *pHandlerCtx, XAAdaptEvent *event)
   579 {
   609     {
   580     XAPlayItfImpl* impl = (XAPlayItfImpl*)pHandlerCtx;
   610     XAPlayItfImpl* impl = (XAPlayItfImpl*) pHandlerCtx;
   581     XAuint32 newpos = 0;
   611     XAuint32 newpos = 0;
   582 
   612 
   583     DEBUG_API("->XAPlayItfImpl_AdaptCb");
   613     DEBUG_API("->XAPlayItfImpl_AdaptCb");
   584     XA_IMPL_THREAD_SAFETY_ENTRY_FOR_VOID_FUNCTIONS( XATSMediaPlayer );
   614     XA_IMPL_THREAD_SAFETY_ENTRY_FOR_VOID_FUNCTIONS( XATSMediaPlayer );
   585     if(!impl)
   615     if (!impl)
   586     {
   616         {
   587         DEBUG_ERR("XAPlayItfImpl_AdaptCb, invalid context pointer!");
   617         DEBUG_ERR("XAPlayItfImpl_AdaptCb, invalid context pointer!");
   588         DEBUG_API("<-XAPlayItfImpl_AdaptCb");
   618         DEBUG_API("<-XAPlayItfImpl_AdaptCb");
   589         XA_IMPL_THREAD_SAFETY_EXIT_FOR_VOID_FUNCTIONS( XATSMediaPlayer );
   619         XA_IMPL_THREAD_SAFETY_EXIT_FOR_VOID_FUNCTIONS( XATSMediaPlayer );
   590         return;
   620         return;
   591     }
   621         }
   592     assert(event);
   622     assert(event);
   593 
   623 
   594     if(impl->pObjImpl->curAdaptCtx->fwtype == FWMgrFWMMF)
   624     if (impl->pObjImpl->curAdaptCtx->fwtype == FWMgrFWMMF)
   595     {
   625         {
   596         impl->callback(impl->cbPtrToSelf, impl->cbcontext, event->eventid);
   626         impl->callback(impl->cbPtrToSelf, impl->cbcontext, event->eventid);
   597         DEBUG_API("<-XAPlayItfImpl_AdaptCb");
   627         DEBUG_API("<-XAPlayItfImpl_AdaptCb");
   598         XA_IMPL_THREAD_SAFETY_EXIT_FOR_VOID_FUNCTIONS( XATSMediaPlayer );
   628         XA_IMPL_THREAD_SAFETY_EXIT_FOR_VOID_FUNCTIONS( XATSMediaPlayer );
   599         return;
   629         return;
   600     }
   630         }
   601 
   631 
   602     /* check position update events */
   632     /* check position update events */
   603     if( event->eventid == XA_ADAPT_POSITION_UPDATE_EVT )
   633     if (event->eventid == XA_ADAPT_POSITION_UPDATE_EVT)
   604     {
   634         {
   605         assert(event->data);
   635         assert(event->data);
   606         newpos = *((XAuint32*)(event->data));
   636         newpos = *((XAuint32*) (event->data));
   607         DEBUG_API_A1("Position update from adaptation: new position %lu ms",newpos);
   637         DEBUG_API_A1("Position update from adaptation: new position %lu ms",newpos);
   608 
   638 
   609         /* Check is looping start file playing before marker position */
   639         /* Check is looping start file playing before marker position */
   610         if(newpos < impl->markerPosition || impl->lastPosition > newpos)
   640         if (newpos < impl->markerPosition || impl->lastPosition > newpos)
   611         {
   641             {
   612         	DEBUG_INFO("Restart looping, clear marker position callback flag.");
   642             DEBUG_INFO("Restart looping, clear marker position callback flag.");
   613             impl->isMarkerPosCbSend = XA_BOOLEAN_FALSE;
   643             impl->isMarkerPosCbSend = XA_BOOLEAN_FALSE;
   614         }
   644             }
   615 
   645 
   616         /* check if marker passed and callback needed */
   646         /* check if marker passed and callback needed */
   617         if( (impl->markerPosition != NO_POSITION) &&
   647         if ((impl->markerPosition != NO_POSITION) && (impl->eventFlags
   618             (impl->eventFlags & XA_PLAYEVENT_HEADATMARKER) )
   648                 & XA_PLAYEVENT_HEADATMARKER))
   619         {
   649             {
   620             if( impl->callback &&
   650             if (impl->callback && (((impl->lastPosition
   621                 (
   651                     < impl->markerPosition)
   622                   ((impl->lastPosition < impl->markerPosition) &&
   652                     && (newpos > impl->markerPosition)) || (newpos
   623                   (newpos > impl->markerPosition))
   653                     == impl->markerPosition)))
   624                   ||
   654                 {
   625                   (newpos == impl->markerPosition)
       
   626                 )
       
   627               )
       
   628             {
       
   629                 /* Check is callback already send */
   655                 /* Check is callback already send */
   630                 if( impl->isMarkerPosCbSend != XA_BOOLEAN_TRUE )
   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)))
   631                 {
   671                 {
   632                     impl->callback(impl->cbPtrToSelf, impl->cbcontext, XA_PLAYEVENT_HEADATMARKER);
   672                 impl->callback(impl->cbPtrToSelf, impl->cbcontext,
   633                     impl->isMarkerPosCbSend = XA_BOOLEAN_TRUE;
   673                         XA_PLAYEVENT_HEADATNEWPOS);
   634                 }
   674                 }
   635             }
   675             }
   636         }
       
   637         /* check if update period passed and callback needed */
       
   638         if( (impl->positionUpdatePeriod > 0) &&
       
   639             (impl->eventFlags & XA_PLAYEVENT_HEADATNEWPOS) &&
       
   640             impl->callback )
       
   641         {
       
   642             if( (XAuint32)((impl->lastPosition)/(impl->positionUpdatePeriod )) <
       
   643                 (XAuint32)(newpos/(impl->positionUpdatePeriod )) )
       
   644             {
       
   645                 impl->callback(impl->cbPtrToSelf, impl->cbcontext, XA_PLAYEVENT_HEADATNEWPOS);
       
   646             }
       
   647         }
       
   648         /* store position */
   676         /* store position */
   649         impl->lastPosition = newpos;
   677         impl->lastPosition = newpos;
   650     }
   678         }
   651 
   679 
   652     /* check other events */
   680     /* check other events */
   653     else if( event->eventid == XA_PLAYEVENT_HEADATEND )
   681     else if (event->eventid == XA_PLAYEVENT_HEADATEND)
   654     {
   682         {
   655         impl->playbackState = XA_PLAYSTATE_STOPPED;
   683         impl->playbackState = XA_PLAYSTATE_STOPPED;
   656         impl->lastPosition=0;
   684         impl->lastPosition = 0;
   657         /* send callback if needed */
   685         /* send callback if needed */
   658         if( (XA_PLAYEVENT_HEADATEND & impl->eventFlags) && impl->callback )
   686         if ((XA_PLAYEVENT_HEADATEND & impl->eventFlags) && impl->callback)
   659         {
   687             {
   660             impl->callback(impl->cbPtrToSelf, impl->cbcontext, XA_PLAYEVENT_HEADATEND);
   688             impl->callback(impl->cbPtrToSelf, impl->cbcontext,
   661         }
   689                     XA_PLAYEVENT_HEADATEND);
   662     }
   690             }
   663     else if( event->eventid == XA_PLAYEVENT_HEADSTALLED )
   691         }
   664     {
   692     else if (event->eventid == XA_PLAYEVENT_HEADSTALLED)
       
   693         {
   665         impl->playbackState = XA_PLAYSTATE_PAUSED;
   694         impl->playbackState = XA_PLAYSTATE_PAUSED;
   666         if(impl->adapCtx->fwtype == FWMgrFWMMF)
   695         if (impl->adapCtx->fwtype == FWMgrFWMMF)
   667             {
   696             {
   668             //XAPlayItfAdaptMMF_GetPosition((XAAdaptationGstCtx*)impl->adapCtx, &(impl->lastPosition));
   697             //XAPlayItfAdaptMMF_GetPosition((XAAdaptationGstCtx*)impl->adapCtx, &(impl->lastPosition));
   669             }
   698             }
   670         else
   699         else
   671             {
   700             {
   672             XAPlayItfAdaptGST_GetPosition((XAAdaptationGstCtx*)impl->adapCtx, &(impl->lastPosition));
   701             XAPlayItfAdaptGST_GetPosition(
   673             }        
   702                     (XAAdaptationGstCtx*) impl->adapCtx,
       
   703                     &(impl->lastPosition));
       
   704             }
   674         /* send callback if needed */
   705         /* send callback if needed */
   675         if( (XA_PLAYEVENT_HEADSTALLED & impl->eventFlags) && impl->callback )
   706         if ((XA_PLAYEVENT_HEADSTALLED & impl->eventFlags) && impl->callback)
   676         {
   707             {
   677             impl->callback(impl->cbPtrToSelf, impl->cbcontext, XA_PLAYEVENT_HEADSTALLED);
   708             impl->callback(impl->cbPtrToSelf, impl->cbcontext,
   678         }
   709                     XA_PLAYEVENT_HEADSTALLED);
   679     }
   710             }
   680     else if( event->eventid == XA_PLAYEVENT_HEADMOVING )
   711         }
   681     {
   712     else if (event->eventid == XA_PLAYEVENT_HEADMOVING)
       
   713         {
   682         impl->playbackState = XA_PLAYSTATE_PLAYING;
   714         impl->playbackState = XA_PLAYSTATE_PLAYING;
   683         /* send callback if needed */
   715         /* send callback if needed */
   684         if( (XA_PLAYEVENT_HEADMOVING & impl->eventFlags) && impl->callback )
   716         if ((XA_PLAYEVENT_HEADMOVING & impl->eventFlags) && impl->callback)
   685         {
   717             {
   686             impl->callback(impl->cbPtrToSelf, impl->cbcontext, XA_PLAYEVENT_HEADMOVING);
   718             impl->callback(impl->cbPtrToSelf, impl->cbcontext,
   687         }
   719                     XA_PLAYEVENT_HEADMOVING);
   688     }
   720             }
       
   721         }
   689     else
   722     else
   690     {
   723         {
   691         /* do nothing */
   724         /* do nothing */
   692     }
   725         }
   693 
   726 
   694     DEBUG_API("<-XAPlayItfImpl_AdaptCb");
   727     DEBUG_API("<-XAPlayItfImpl_AdaptCb");
   695     XA_IMPL_THREAD_SAFETY_EXIT_FOR_VOID_FUNCTIONS( XATSMediaPlayer );
   728     XA_IMPL_THREAD_SAFETY_EXIT_FOR_VOID_FUNCTIONS( XATSMediaPlayer );
   696 }
   729     }
   697 
   730