khronosfws/openmax_al/src/mediaplayer/xaplayitf.c
changeset 25 6f7ceef7b1d1
parent 21 2ed61feeead6
child 33 5e8b14bae8c3
equal deleted inserted replaced
21:2ed61feeead6 25:6f7ceef7b1d1
     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     // No need to do anything else if radio:
   253     // No need to do anything else if radio:
   246 		if ( ((XAMediaPlayerAdaptationMMFCtx*)impl->pObjImpl->curAdaptCtx)->isForRadio == XA_BOOLEAN_TRUE)
   254     if (((XAMediaPlayerAdaptationMMFCtx*) impl->pObjImpl->curAdaptCtx)->isForRadio
   247 		{
   255             == XA_BOOLEAN_TRUE)
   248     	DEBUG_API("<-XAPlayItfImpl_RegisterCallback");
   256         {
   249     	return ret;			
   257         DEBUG_API("<-XAPlayItfImpl_RegisterCallback");
   250 		}
   258         return ret;
   251 
   259         }
   252     XA_IMPL_THREAD_SAFETY_ENTRY( XATSMediaPlayer );
   260 
   253 
   261     XA_IMPL_THREAD_SAFETY_ENTRY( XATSMediaPlayer );
   254     if(impl->pObjImpl->curAdaptCtx->fwtype == FWMgrFWMMF)
   262 
   255     {
   263     if (impl->pObjImpl->curAdaptCtx->fwtype == FWMgrFWMMF)
   256         ret = XAPlayItfAdaptMMF_RegisterCallback(impl->pObjImpl->curAdaptCtx, callback);
   264         {
   257     }
   265         ret = XAPlayItfAdaptMMF_RegisterCallback(impl->pObjImpl->curAdaptCtx,
       
   266                 callback);
       
   267         }
   258 
   268 
   259     XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer );
   269     XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer );
   260 
   270 
   261     DEBUG_API("<-XAPlayItfImpl_RegisterCallback");
   271     DEBUG_API("<-XAPlayItfImpl_RegisterCallback");
   262     return ret;
   272     return ret;
   263 }
   273     }
   264 
   274 
   265 /**
   275 /**
   266  * XAresult XAPlayItfImpl_SetCallbackEventsMask(XAPlayItf self, XAuint32 eventFlags)
   276  * XAresult XAPlayItfImpl_SetCallbackEventsMask(XAPlayItf self, XAuint32 eventFlags)
   267  * Description: Enables/disables notification of playback events.
   277  * Description: Enables/disables notification of playback events.
   268  **/
   278  **/
   269 XAresult XAPlayItfImpl_SetCallbackEventsMask(XAPlayItf self, XAuint32 eventFlags)
   279 XAresult XAPlayItfImpl_SetCallbackEventsMask(XAPlayItf self,
   270 {
   280         XAuint32 eventFlags)
       
   281     {
   271     XAresult ret = XA_RESULT_SUCCESS;
   282     XAresult ret = XA_RESULT_SUCCESS;
   272     XAPlayItfImpl* impl = GetImpl(self);
   283     XAPlayItfImpl* impl = GetImpl(self);
   273 
   284 
   274     DEBUG_API("->XAPlayItfImpl_SetCallbackEventsMask");
   285     DEBUG_API("->XAPlayItfImpl_SetCallbackEventsMask");
   275 
   286 
   276     if(!impl || ( eventFlags > (XA_PLAYEVENT_HEADATEND | XA_PLAYEVENT_HEADATMARKER |
   287     if (!impl || (eventFlags > (XA_PLAYEVENT_HEADATEND
   277                   XA_PLAYEVENT_HEADATNEWPOS | XA_PLAYEVENT_HEADMOVING | XA_PLAYEVENT_HEADSTALLED) ) )
   288             | XA_PLAYEVENT_HEADATMARKER | XA_PLAYEVENT_HEADATNEWPOS
   278     {
   289             | XA_PLAYEVENT_HEADMOVING | XA_PLAYEVENT_HEADSTALLED)))
   279         /* invalid parameter */
   290         {
   280         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 );
   281         DEBUG_API("<-XAPlayItfImpl_SetCallbackEventsMask");
   306         DEBUG_API("<-XAPlayItfImpl_SetCallbackEventsMask");
   282         return XA_RESULT_PARAMETER_INVALID;
   307         return ret;
   283     }
   308         }
   284 
       
   285     XA_IMPL_THREAD_SAFETY_ENTRY( XATSMediaPlayer );
       
   286 
       
   287     impl->eventFlags = eventFlags;
       
   288 
       
   289     if(impl->pObjImpl->curAdaptCtx->fwtype == FWMgrFWMMF)
       
   290     {
       
   291         ret = XAPlayItfAdaptMMF_SetCallbackEventsMask(impl->pObjImpl->curAdaptCtx, eventFlags);
       
   292 
       
   293 	    XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer );
       
   294 	    DEBUG_API("<-XAPlayItfImpl_SetCallbackEventsMask");
       
   295 	    return ret;
       
   296     }
       
   297 
   309 
   298     /* enable position tracking if client wants so */
   310     /* enable position tracking if client wants so */
   299     if( (eventFlags & (XA_PLAYEVENT_HEADATMARKER | XA_PLAYEVENT_HEADATNEWPOS))
   311     if ((eventFlags & (XA_PLAYEVENT_HEADATMARKER | XA_PLAYEVENT_HEADATNEWPOS))
   300         &&  impl->adapCtx && !impl->positionupdateOn)
   312             && impl->adapCtx && !impl->positionupdateOn)
   301         {
   313         {
   302         ret = XAPlayItfAdapt_EnablePositionTracking((XAAdaptationGstCtx*)impl->adapCtx, XA_BOOLEAN_TRUE);
   314         ret = XAPlayItfAdapt_EnablePositionTracking(
   303         if( ret == XA_RESULT_SUCCESS )
   315                 (XAAdaptationGstCtx*) impl->adapCtx, XA_BOOLEAN_TRUE);
   304         {
   316         if (ret == XA_RESULT_SUCCESS)
       
   317             {
   305             impl->positionupdateOn = XA_BOOLEAN_TRUE;
   318             impl->positionupdateOn = XA_BOOLEAN_TRUE;
   306         }
   319             }
   307     }
   320         }
   308     else if( !(eventFlags & (XA_PLAYEVENT_HEADATMARKER | XA_PLAYEVENT_HEADATNEWPOS))
   321     else if (!(eventFlags & (XA_PLAYEVENT_HEADATMARKER
   309             &&  impl->adapCtx && impl->positionupdateOn)
   322             | XA_PLAYEVENT_HEADATNEWPOS)) && impl->adapCtx
   310     {
   323             && impl->positionupdateOn)
   311         ret = XAPlayItfAdapt_EnablePositionTracking((XAAdaptationGstCtx*)impl->adapCtx, XA_BOOLEAN_FALSE);
   324         {
   312         if( ret == XA_RESULT_SUCCESS )
   325         ret = XAPlayItfAdapt_EnablePositionTracking(
   313         {
   326                 (XAAdaptationGstCtx*) impl->adapCtx, XA_BOOLEAN_FALSE);
       
   327         if (ret == XA_RESULT_SUCCESS)
       
   328             {
   314             impl->positionupdateOn = XA_BOOLEAN_FALSE;
   329             impl->positionupdateOn = XA_BOOLEAN_FALSE;
   315         }
   330             }
   316     }
   331         }
   317 
   332 
   318     XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer );
   333     XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer );
   319     DEBUG_API("<-XAPlayItfImpl_SetCallbackEventsMask");
   334     DEBUG_API("<-XAPlayItfImpl_SetCallbackEventsMask");
   320     return ret;
   335     return ret;
   321 }
   336     }
   322 
   337 
   323 /**
   338 /**
   324  * XAresult XAPlayItfImpl_GetCallbackEventsMask(XAPlayItf self, XAuint32 *pEventFlags)
   339  * XAresult XAPlayItfImpl_GetCallbackEventsMask(XAPlayItf self, XAuint32 *pEventFlags)
   325  * Description: Queries for the notification state (enabled/disabled) of playback events.
   340  * Description: Queries for the notification state (enabled/disabled) of playback events.
   326  **/
   341  **/
   327 XAresult XAPlayItfImpl_GetCallbackEventsMask(XAPlayItf self, XAuint32 *pEventFlags)
   342 XAresult XAPlayItfImpl_GetCallbackEventsMask(XAPlayItf self,
   328 {
   343         XAuint32 *pEventFlags)
       
   344     {
   329     XAresult ret = XA_RESULT_SUCCESS;
   345     XAresult ret = XA_RESULT_SUCCESS;
   330     XAPlayItfImpl* impl = GetImpl(self);
   346     XAPlayItfImpl* impl = GetImpl(self);
   331 
   347 
   332     DEBUG_API("->XAPlayItfImpl_GetCallbackEventsMask");
   348     DEBUG_API("->XAPlayItfImpl_GetCallbackEventsMask");
   333     if(!impl || !pEventFlags)
   349     if (!impl || !pEventFlags)
   334     {
   350         {
   335         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   351         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   336         DEBUG_API("<-XAPlayItfImpl_GetCallbackEventsMask");
   352         DEBUG_API("<-XAPlayItfImpl_GetCallbackEventsMask");
   337         /* invalid parameter */
   353         /* invalid parameter */
   338         return XA_RESULT_PARAMETER_INVALID;
   354         return XA_RESULT_PARAMETER_INVALID;
   339     }
   355         }
   340 
   356 
   341     *pEventFlags = impl->eventFlags;
   357     *pEventFlags = impl->eventFlags;
   342 
   358 
   343     DEBUG_API("<-XAPlayItfImpl_GetCallbackEventsMask");
   359     DEBUG_API("<-XAPlayItfImpl_GetCallbackEventsMask");
   344     return ret;
   360     return ret;
   345 }
   361     }
   346 
   362 
   347 /**
   363 /**
   348  * XAresult XAPlayItfImpl_SetMarkerPosition(XAPlayItf self, XAmillisecond mSec)
   364  * XAresult XAPlayItfImpl_SetMarkerPosition(XAPlayItf self, XAmillisecond mSec)
   349  * Description: Sets the position of the playback marker.
   365  * Description: Sets the position of the playback marker.
   350  **/
   366  **/
   351 XAresult XAPlayItfImpl_SetMarkerPosition(XAPlayItf self, XAmillisecond mSec)
   367 XAresult XAPlayItfImpl_SetMarkerPosition(XAPlayItf self, XAmillisecond mSec)
   352 {
   368     {
   353     XAresult ret = XA_RESULT_SUCCESS;
   369     XAresult ret = XA_RESULT_SUCCESS;
   354     XAmillisecond duration = 0;
   370     XAmillisecond duration = 0;
   355     XAPlayItfImpl* impl = GetImpl(self);
   371     XAPlayItfImpl* impl = GetImpl(self);
   356 
   372 
   357     DEBUG_API_A1("->XAPlayItfImpl_SetMarkerPosition: %lu ms", mSec);
   373     DEBUG_API_A1("->XAPlayItfImpl_SetMarkerPosition: %lu ms", mSec);
   358 
   374 
   359     /* Get duration of the content */
   375     /* Get duration of the content */
   360     if(XAPlayItfImpl_GetDuration(self, &duration) != XA_RESULT_SUCCESS)
   376     if (XAPlayItfImpl_GetDuration(self, &duration) != XA_RESULT_SUCCESS)
   361     {
   377         {
   362         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   378         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   363         DEBUG_API("<-XAPlayItfImpl_SetMarkerPosition");
   379         DEBUG_API("<-XAPlayItfImpl_SetMarkerPosition");
   364         /* invalid parameter */
   380         /* invalid parameter */
   365         return XA_RESULT_PARAMETER_INVALID;
   381         return XA_RESULT_PARAMETER_INVALID;
   366     }
   382         }
   367 
   383 
   368 
   384     if (!impl || mSec > duration)
   369     if(!impl || mSec > duration)
   385         {
   370     {
       
   371         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   386         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   372         DEBUG_API("<-XAPlayItfImpl_SetMarkerPosition");
   387         DEBUG_API("<-XAPlayItfImpl_SetMarkerPosition");
   373         /* invalid parameter */
   388         /* invalid parameter */
   374         return XA_RESULT_PARAMETER_INVALID;
   389         return XA_RESULT_PARAMETER_INVALID;
   375     }
   390         }
   376 
   391 
   377     impl->markerPosition = mSec;
   392     impl->markerPosition = mSec;
   378     impl->isMarkerPosCbSend = XA_BOOLEAN_FALSE;
   393     impl->isMarkerPosCbSend = XA_BOOLEAN_FALSE;
   379 
   394 
   380     XA_IMPL_THREAD_SAFETY_ENTRY( XATSMediaPlayer );
   395     XA_IMPL_THREAD_SAFETY_ENTRY( XATSMediaPlayer );
   381 
   396 
   382     if(impl->pObjImpl->curAdaptCtx->fwtype == FWMgrFWMMF)
   397     if (impl->pObjImpl->curAdaptCtx->fwtype == FWMgrFWMMF)
   383     {
   398         {
   384         ret = XAPlayItfAdaptMMF_SetMarkerPosition(impl->pObjImpl->curAdaptCtx, mSec);
   399         ret = XAPlayItfAdaptMMF_SetMarkerPosition(
   385     }
   400                 impl->pObjImpl->curAdaptCtx, mSec);
       
   401         }
   386 
   402 
   387     XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer );
   403     XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer );
   388 
   404 
   389     DEBUG_API("<-XAPlayItfImpl_SetMarkerPosition");
   405     DEBUG_API("<-XAPlayItfImpl_SetMarkerPosition");
   390     return ret;
   406     return ret;
   391 }
   407     }
   392 
   408 
   393 /**
   409 /**
   394  * XAresult XAPlayItfImpl_ClearMarkerPosition(XAPlayItf self)
   410  * XAresult XAPlayItfImpl_ClearMarkerPosition(XAPlayItf self)
   395  * Description: Clears marker.
   411  * Description: Clears marker.
   396  **/
   412  **/
   397 XAresult XAPlayItfImpl_ClearMarkerPosition(XAPlayItf self)
   413 XAresult XAPlayItfImpl_ClearMarkerPosition(XAPlayItf self)
   398 {
   414     {
   399     XAresult ret = XA_RESULT_SUCCESS;
   415     XAresult ret = XA_RESULT_SUCCESS;
   400     XAPlayItfImpl* impl = GetImpl(self);
   416     XAPlayItfImpl* impl = GetImpl(self);
   401 
   417 
   402     DEBUG_API("->XAPlayItfImpl_ClearMarkerPosition");
   418     DEBUG_API("->XAPlayItfImpl_ClearMarkerPosition");
   403     if(!impl)
   419     if (!impl)
   404     {
   420         {
   405         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   421         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   406         DEBUG_API("<-XAPlayItfImpl_ClearMarkerPosition");
   422         DEBUG_API("<-XAPlayItfImpl_ClearMarkerPosition");
   407         /* invalid parameter */
   423         /* invalid parameter */
   408         return XA_RESULT_PARAMETER_INVALID;
   424         return XA_RESULT_PARAMETER_INVALID;
   409     }
   425         }
   410 
   426 
   411     impl->isMarkerPosCbSend = XA_BOOLEAN_FALSE;
   427     impl->isMarkerPosCbSend = XA_BOOLEAN_FALSE;
   412     impl->markerPosition = NO_POSITION;
   428     impl->markerPosition = NO_POSITION;
   413 
   429 
   414     XA_IMPL_THREAD_SAFETY_ENTRY( XATSMediaPlayer );
   430     XA_IMPL_THREAD_SAFETY_ENTRY( XATSMediaPlayer );
   415 
   431 
   416     if(impl->pObjImpl->curAdaptCtx->fwtype == FWMgrFWMMF)
   432     if (impl->pObjImpl->curAdaptCtx->fwtype == FWMgrFWMMF)
   417     {
   433         {
   418         ret = XAPlayItfAdaptMMF_ClearMarkerPosition(impl->pObjImpl->curAdaptCtx);
   434         ret = XAPlayItfAdaptMMF_ClearMarkerPosition(
   419     }
   435                 impl->pObjImpl->curAdaptCtx);
       
   436         }
   420 
   437 
   421     XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer );
   438     XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer );
   422 
   439 
   423     DEBUG_API("<-XAPlayItfImpl_ClearMarkerPosition");
   440     DEBUG_API("<-XAPlayItfImpl_ClearMarkerPosition");
   424     return ret;
   441     return ret;
   425 }
   442     }
   426 
   443 
   427 /**
   444 /**
   428  * XAresult XAPlayItfImpl_GetMarkerPosition(XAPlayItf self, XAmillisecond *pMsec)
   445  * XAresult XAPlayItfImpl_GetMarkerPosition(XAPlayItf self, XAmillisecond *pMsec)
   429  * Description: Queries the position of playback marker.
   446  * Description: Queries the position of playback marker.
   430  **/
   447  **/
   431 XAresult XAPlayItfImpl_GetMarkerPosition(XAPlayItf self, XAmillisecond *pMsec)
   448 XAresult XAPlayItfImpl_GetMarkerPosition(XAPlayItf self, XAmillisecond *pMsec)
   432 {
   449     {
   433     XAresult ret = XA_RESULT_SUCCESS;
   450     XAresult ret = XA_RESULT_SUCCESS;
   434     XAPlayItfImpl* impl = GetImpl(self);
   451     XAPlayItfImpl* impl = GetImpl(self);
   435 
   452 
   436     DEBUG_API("->XAPlayItfImpl_GetMarkerPosition");
   453     DEBUG_API("->XAPlayItfImpl_GetMarkerPosition");
   437     if(!impl || !pMsec)
   454     if (!impl || !pMsec)
   438     {
   455         {
   439         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   456         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   440         DEBUG_API("<-XAPlayItfImpl_GetMarkerPosition");
   457         DEBUG_API("<-XAPlayItfImpl_GetMarkerPosition");
   441         /* invalid parameter */
   458         /* invalid parameter */
   442         return XA_RESULT_PARAMETER_INVALID;
   459         return XA_RESULT_PARAMETER_INVALID;
   443     }
   460         }
   444 
   461 
   445     if(impl->markerPosition == NO_POSITION)
   462     if (impl->markerPosition == NO_POSITION)
   446     {
   463         {
   447         DEBUG_ERR("XA_RESULT_PRECONDITIONS_VIOLATED");
   464         DEBUG_ERR("XA_RESULT_PRECONDITIONS_VIOLATED");
   448         DEBUG_API("<-XAPlayItfImpl_GetMarkerPosition");
   465         DEBUG_API("<-XAPlayItfImpl_GetMarkerPosition");
   449         /*marker is not set */
   466         /*marker is not set */
   450         return XA_RESULT_PRECONDITIONS_VIOLATED;
   467         return XA_RESULT_PRECONDITIONS_VIOLATED;
   451     }
   468         }
   452 
   469 
   453     *pMsec = impl->markerPosition;
   470     *pMsec = impl->markerPosition;
   454 
   471 
   455     DEBUG_API("<-XAPlayItfImpl_GetMarkerPosition");
   472     DEBUG_API("<-XAPlayItfImpl_GetMarkerPosition");
   456     return ret;
   473     return ret;
   457 }
   474     }
   458 
   475 
   459 /**
   476 /**
   460  * XAresult XAPlayItfImpl_SetPositionUpdatePeriod(XAPlayItf self, XAmillisecond mSec)
   477  * XAresult XAPlayItfImpl_SetPositionUpdatePeriod(XAPlayItf self, XAmillisecond mSec)
   461  * Description: Sets the interval between periodic position notifications.
   478  * Description: Sets the interval between periodic position notifications.
   462  **/
   479  **/
   463 XAresult XAPlayItfImpl_SetPositionUpdatePeriod(XAPlayItf self, XAmillisecond mSec)
   480 XAresult XAPlayItfImpl_SetPositionUpdatePeriod(XAPlayItf self,
   464 {
   481         XAmillisecond mSec)
       
   482     {
   465     XAresult ret = XA_RESULT_SUCCESS;
   483     XAresult ret = XA_RESULT_SUCCESS;
   466     XAPlayItfImpl* impl = GetImpl(self);
   484     XAPlayItfImpl* impl = GetImpl(self);
   467 
   485 
   468     DEBUG_API_A1("->XAPlayItfImpl_SetPositionUpdatePeriod, %lu mSec", mSec);
   486     DEBUG_API_A1("->XAPlayItfImpl_SetPositionUpdatePeriod, %lu mSec", mSec);
   469     if(!impl )
   487     if (!impl)
   470     {
   488         {
   471         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   489         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   472         DEBUG_API("<-XAPlayItfImpl_SetPositionUpdatePeriod");
   490         DEBUG_API("<-XAPlayItfImpl_SetPositionUpdatePeriod");
   473         /* invalid parameter */
   491         /* invalid parameter */
   474         return XA_RESULT_PARAMETER_INVALID;
   492         return XA_RESULT_PARAMETER_INVALID;
   475     }
   493         }
   476     impl->positionUpdatePeriod = mSec;
   494     impl->positionUpdatePeriod = mSec;
   477 
   495 
   478     XA_IMPL_THREAD_SAFETY_ENTRY( XATSMediaPlayer );
   496     XA_IMPL_THREAD_SAFETY_ENTRY( XATSMediaPlayer );
   479 
   497 
   480     if(impl->pObjImpl->curAdaptCtx->fwtype == FWMgrFWMMF)
   498     if (impl->pObjImpl->curAdaptCtx->fwtype == FWMgrFWMMF)
   481     {
   499         {
   482         ret = XAPlayItfAdaptMMF_SetPositionUpdatePeriod(impl->pObjImpl->curAdaptCtx, mSec);
   500         ret = XAPlayItfAdaptMMF_SetPositionUpdatePeriod(
   483     }
   501                 impl->pObjImpl->curAdaptCtx, mSec);
       
   502         }
   484 
   503 
   485     XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer );
   504     XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer );
   486 
   505 
   487     DEBUG_API("<-XAPlayItfImpl_SetPositionUpdatePeriod");
   506     DEBUG_API("<-XAPlayItfImpl_SetPositionUpdatePeriod");
   488     return ret;
   507     return ret;
   489 }
   508     }
   490 
   509 
   491 /**
   510 /**
   492  * XAresult XAPlayItfImpl_GetPositionUpdatePeriod(XAPlayItf self, XAmillisecond *pMsec)
   511  * XAresult XAPlayItfImpl_GetPositionUpdatePeriod(XAPlayItf self, XAmillisecond *pMsec)
   493  * Description: Queries the interval between periodic position notifications.
   512  * Description: Queries the interval between periodic position notifications.
   494  **/
   513  **/
   495 XAresult XAPlayItfImpl_GetPositionUpdatePeriod(XAPlayItf self, XAmillisecond *pMsec)
   514 XAresult XAPlayItfImpl_GetPositionUpdatePeriod(XAPlayItf self,
   496 {
   515         XAmillisecond *pMsec)
       
   516     {
   497     XAresult ret = XA_RESULT_SUCCESS;
   517     XAresult ret = XA_RESULT_SUCCESS;
   498     XAPlayItfImpl* impl = GetImpl(self);
   518     XAPlayItfImpl* impl = GetImpl(self);
   499 
   519 
   500     DEBUG_API("->XAPlayItfImpl_GetPositionUpdatePeriod");
   520     DEBUG_API("->XAPlayItfImpl_GetPositionUpdatePeriod");
   501     if(!impl || !pMsec)
   521     if (!impl || !pMsec)
   502     {
   522         {
   503         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   523         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   504         DEBUG_API("<-XAPlayItfImpl_GetPositionUpdatePeriod");
   524         DEBUG_API("<-XAPlayItfImpl_GetPositionUpdatePeriod");
   505         /* invalid parameter */
   525         /* invalid parameter */
   506         return XA_RESULT_PARAMETER_INVALID;
   526         return XA_RESULT_PARAMETER_INVALID;
   507     }
   527         }
   508 
   528 
   509     *pMsec = impl->positionUpdatePeriod;
   529     *pMsec = impl->positionUpdatePeriod;
   510 
   530 
   511     DEBUG_API("<-XAPlayItfImpl_GetPositionUpdatePeriod");
   531     DEBUG_API("<-XAPlayItfImpl_GetPositionUpdatePeriod");
   512     return ret;
   532     return ret;
   513 }
   533     }
   514 
       
   515 
   534 
   516 /**
   535 /**
   517  * XAPlayItfImpl -specific methods
   536  * XAPlayItfImpl -specific methods
   518  **/
   537  **/
   519 
   538 
   520 /**
   539 /**
   521  * XAPlayItfImpl* XAPlayItfImpl_Create()
   540  * XAPlayItfImpl* XAPlayItfImpl_Create()
   522  * Description: Allocate and initialize PlayItfImpl
   541  * Description: Allocate and initialize PlayItfImpl
   523  **/
   542  **/
   524 XAPlayItfImpl* XAPlayItfImpl_Create( XAMediaPlayerImpl *impl )
   543 XAPlayItfImpl* XAPlayItfImpl_Create(XAMediaPlayerImpl *impl)
   525 {
   544     {
   526     XAPlayItfImpl *self;
   545     XAPlayItfImpl *self;
   527 
   546 
   528     DEBUG_API("->XAPlayItfImpl_Create");
   547     DEBUG_API("->XAPlayItfImpl_Create");
   529     self = (XAPlayItfImpl*)calloc(1,sizeof(XAPlayItfImpl));
   548     self = (XAPlayItfImpl*) calloc(1, sizeof(XAPlayItfImpl));
   530     if(self)
   549     if (self)
   531     {
   550         {
   532         /* init itf default implementation */
   551         /* init itf default implementation */
   533         self->itf.ClearMarkerPosition = XAPlayItfImpl_ClearMarkerPosition;
   552         self->itf.ClearMarkerPosition = XAPlayItfImpl_ClearMarkerPosition;
   534         self->itf.GetCallbackEventsMask = XAPlayItfImpl_GetCallbackEventsMask;
   553         self->itf.GetCallbackEventsMask = XAPlayItfImpl_GetCallbackEventsMask;
   535         self->itf.GetDuration = XAPlayItfImpl_GetDuration;
   554         self->itf.GetDuration = XAPlayItfImpl_GetDuration;
   536         self->itf.GetMarkerPosition = XAPlayItfImpl_GetMarkerPosition;
   555         self->itf.GetMarkerPosition = XAPlayItfImpl_GetMarkerPosition;
   537         self->itf.GetPlayState = XAPlayItfImpl_GetPlayState;
   556         self->itf.GetPlayState = XAPlayItfImpl_GetPlayState;
   538         self->itf.GetPosition = XAPlayItfImpl_GetPosition;
   557         self->itf.GetPosition = XAPlayItfImpl_GetPosition;
   539         self->itf.GetPositionUpdatePeriod = XAPlayItfImpl_GetPositionUpdatePeriod;
   558         self->itf.GetPositionUpdatePeriod
       
   559                 = XAPlayItfImpl_GetPositionUpdatePeriod;
   540         self->itf.RegisterCallback = XAPlayItfImpl_RegisterCallback;
   560         self->itf.RegisterCallback = XAPlayItfImpl_RegisterCallback;
   541         self->itf.SetCallbackEventsMask = XAPlayItfImpl_SetCallbackEventsMask;
   561         self->itf.SetCallbackEventsMask = XAPlayItfImpl_SetCallbackEventsMask;
   542         self->itf.SetMarkerPosition = XAPlayItfImpl_SetMarkerPosition;
   562         self->itf.SetMarkerPosition = XAPlayItfImpl_SetMarkerPosition;
   543         self->itf.SetPlayState = XAPlayItfImpl_SetPlayState;
   563         self->itf.SetPlayState = XAPlayItfImpl_SetPlayState;
   544         self->itf.SetPositionUpdatePeriod = XAPlayItfImpl_SetPositionUpdatePeriod;
   564         self->itf.SetPositionUpdatePeriod
       
   565                 = XAPlayItfImpl_SetPositionUpdatePeriod;
   545 
   566 
   546         /* init variables */
   567         /* init variables */
   547         self->callback = NULL;
   568         self->callback = NULL;
   548         self->cbcontext = NULL;
   569         self->cbcontext = NULL;
   549         self->playbackState = XA_PLAYSTATE_STOPPED;
   570         self->playbackState = XA_PLAYSTATE_STOPPED;
   553         self->lastPosition = START_POSITION;
   574         self->lastPosition = START_POSITION;
   554         /*self->adapCtx = impl->curAdaptCtx;*/
   575         /*self->adapCtx = impl->curAdaptCtx;*/
   555         self->pObjImpl = impl;
   576         self->pObjImpl = impl;
   556         self->cbPtrToSelf = NULL;
   577         self->cbPtrToSelf = NULL;
   557         self->isMarkerPosCbSend = XA_BOOLEAN_FALSE;
   578         self->isMarkerPosCbSend = XA_BOOLEAN_FALSE;
   558         
   579 
   559 /*        XAAdaptationBase_AddEventHandler( self->adapCtx, &XAPlayItfImpl_AdaptCb, XA_PLAYITFEVENTS, self );*/
   580         /*        XAAdaptationBase_AddEventHandler( self->adapCtx, &XAPlayItfImpl_AdaptCb, XA_PLAYITFEVENTS, self );*/
   560         XAAdaptationBase_AddEventHandler( self->pObjImpl->curAdaptCtx, &XAPlayItfImpl_AdaptCb, XA_PLAYITFEVENTS, self );
   581         XAAdaptationBase_AddEventHandler(self->pObjImpl->curAdaptCtx,
       
   582                 &XAPlayItfImpl_AdaptCb, XA_PLAYITFEVENTS, self);
   561 
   583 
   562         self->self = self;
   584         self->self = self;
   563     }
   585         }
   564 
   586 
   565     DEBUG_API("<-XAPlayItfImpl_Create");
   587     DEBUG_API("<-XAPlayItfImpl_Create");
   566     return self;
   588     return self;
   567 }
   589     }
   568 
   590 
   569 /* void XAPlayItfImpl_Free(XAPlayItfImpl* self)
   591 /* void XAPlayItfImpl_Free(XAPlayItfImpl* self)
   570  * Description: Free all resources reserved at XAPlayItfImpl_Create
   592  * Description: Free all resources reserved at XAPlayItfImpl_Create
   571  */
   593  */
   572 void XAPlayItfImpl_Free(XAPlayItfImpl* self)
   594 void XAPlayItfImpl_Free(XAPlayItfImpl* self)
   573 {
   595     {
   574     DEBUG_API("->XAPlayItfImpl_Free");
   596     DEBUG_API("->XAPlayItfImpl_Free");
   575     assert(self==self->self);
   597     assert(self==self->self);
   576 /*    XAAdaptationBase_RemoveEventHandler( self->adapCtx, &XAPlayItfImpl_AdaptCb );*/
   598     /*    XAAdaptationBase_RemoveEventHandler( self->adapCtx, &XAPlayItfImpl_AdaptCb );*/
   577     XAAdaptationBase_RemoveEventHandler( self->pObjImpl->curAdaptCtx, &XAPlayItfImpl_AdaptCb );
   599     XAAdaptationBase_RemoveEventHandler(self->pObjImpl->curAdaptCtx,
       
   600             &XAPlayItfImpl_AdaptCb);
   578     free(self);
   601     free(self);
   579     DEBUG_API("<-XAPlayItfImpl_Free");
   602     DEBUG_API("<-XAPlayItfImpl_Free");
   580 }
   603     }
   581 
   604 
   582 /* void XAPlayItfImpl_AdaptCb
   605 /* void XAPlayItfImpl_AdaptCb
   583  * Description: Listen changes in adaptation
   606  * Description: Listen changes in adaptation
   584  */
   607  */
   585 void XAPlayItfImpl_AdaptCb( void *pHandlerCtx, XAAdaptEvent *event )
   608 void XAPlayItfImpl_AdaptCb(void *pHandlerCtx, XAAdaptEvent *event)
   586 {
   609     {
   587     XAPlayItfImpl* impl = (XAPlayItfImpl*)pHandlerCtx;
   610     XAPlayItfImpl* impl = (XAPlayItfImpl*) pHandlerCtx;
   588     XAuint32 newpos = 0;
   611     XAuint32 newpos = 0;
   589 
   612 
   590     DEBUG_API("->XAPlayItfImpl_AdaptCb");
   613     DEBUG_API("->XAPlayItfImpl_AdaptCb");
   591     XA_IMPL_THREAD_SAFETY_ENTRY_FOR_VOID_FUNCTIONS( XATSMediaPlayer );
   614     XA_IMPL_THREAD_SAFETY_ENTRY_FOR_VOID_FUNCTIONS( XATSMediaPlayer );
   592     if(!impl)
   615     if (!impl)
   593     {
   616         {
   594         DEBUG_ERR("XAPlayItfImpl_AdaptCb, invalid context pointer!");
   617         DEBUG_ERR("XAPlayItfImpl_AdaptCb, invalid context pointer!");
   595         DEBUG_API("<-XAPlayItfImpl_AdaptCb");
   618         DEBUG_API("<-XAPlayItfImpl_AdaptCb");
   596         XA_IMPL_THREAD_SAFETY_EXIT_FOR_VOID_FUNCTIONS( XATSMediaPlayer );
   619         XA_IMPL_THREAD_SAFETY_EXIT_FOR_VOID_FUNCTIONS( XATSMediaPlayer );
   597         return;
   620         return;
   598     }
   621         }
   599     assert(event);
   622     assert(event);
   600 
   623 
   601     if(impl->pObjImpl->curAdaptCtx->fwtype == FWMgrFWMMF)
   624     if (impl->pObjImpl->curAdaptCtx->fwtype == FWMgrFWMMF)
   602     {
   625         {
   603         impl->callback(impl->cbPtrToSelf, impl->cbcontext, event->eventid);
   626         impl->callback(impl->cbPtrToSelf, impl->cbcontext, event->eventid);
   604         DEBUG_API("<-XAPlayItfImpl_AdaptCb");
   627         DEBUG_API("<-XAPlayItfImpl_AdaptCb");
   605         XA_IMPL_THREAD_SAFETY_EXIT_FOR_VOID_FUNCTIONS( XATSMediaPlayer );
   628         XA_IMPL_THREAD_SAFETY_EXIT_FOR_VOID_FUNCTIONS( XATSMediaPlayer );
   606         return;
   629         return;
   607     }
   630         }
   608 
   631 
   609     /* check position update events */
   632     /* check position update events */
   610     if( event->eventid == XA_ADAPT_POSITION_UPDATE_EVT )
   633     if (event->eventid == XA_ADAPT_POSITION_UPDATE_EVT)
   611     {
   634         {
   612         assert(event->data);
   635         assert(event->data);
   613         newpos = *((XAuint32*)(event->data));
   636         newpos = *((XAuint32*) (event->data));
   614         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);
   615 
   638 
   616         /* Check is looping start file playing before marker position */
   639         /* Check is looping start file playing before marker position */
   617         if(newpos < impl->markerPosition || impl->lastPosition > newpos)
   640         if (newpos < impl->markerPosition || impl->lastPosition > newpos)
   618         {
   641             {
   619         	DEBUG_INFO("Restart looping, clear marker position callback flag.");
   642             DEBUG_INFO("Restart looping, clear marker position callback flag.");
   620             impl->isMarkerPosCbSend = XA_BOOLEAN_FALSE;
   643             impl->isMarkerPosCbSend = XA_BOOLEAN_FALSE;
   621         }
   644             }
   622 
   645 
   623         /* check if marker passed and callback needed */
   646         /* check if marker passed and callback needed */
   624         if( (impl->markerPosition != NO_POSITION) &&
   647         if ((impl->markerPosition != NO_POSITION) && (impl->eventFlags
   625             (impl->eventFlags & XA_PLAYEVENT_HEADATMARKER) )
   648                 & XA_PLAYEVENT_HEADATMARKER))
   626         {
   649             {
   627             if( impl->callback &&
   650             if (impl->callback && (((impl->lastPosition
   628                 (
   651                     < impl->markerPosition)
   629                   ((impl->lastPosition < impl->markerPosition) &&
   652                     && (newpos > impl->markerPosition)) || (newpos
   630                   (newpos > impl->markerPosition))
   653                     == impl->markerPosition)))
   631                   ||
   654                 {
   632                   (newpos == impl->markerPosition)
       
   633                 )
       
   634               )
       
   635             {
       
   636                 /* Check is callback already send */
   655                 /* Check is callback already send */
   637                 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)))
   638                 {
   671                 {
   639                     impl->callback(impl->cbPtrToSelf, impl->cbcontext, XA_PLAYEVENT_HEADATMARKER);
   672                 impl->callback(impl->cbPtrToSelf, impl->cbcontext,
   640                     impl->isMarkerPosCbSend = XA_BOOLEAN_TRUE;
   673                         XA_PLAYEVENT_HEADATNEWPOS);
   641                 }
   674                 }
   642             }
   675             }
   643         }
       
   644         /* check if update period passed and callback needed */
       
   645         if( (impl->positionUpdatePeriod > 0) &&
       
   646             (impl->eventFlags & XA_PLAYEVENT_HEADATNEWPOS) &&
       
   647             impl->callback )
       
   648         {
       
   649             if( (XAuint32)((impl->lastPosition)/(impl->positionUpdatePeriod )) <
       
   650                 (XAuint32)(newpos/(impl->positionUpdatePeriod )) )
       
   651             {
       
   652                 impl->callback(impl->cbPtrToSelf, impl->cbcontext, XA_PLAYEVENT_HEADATNEWPOS);
       
   653             }
       
   654         }
       
   655         /* store position */
   676         /* store position */
   656         impl->lastPosition = newpos;
   677         impl->lastPosition = newpos;
   657     }
   678         }
   658 
   679 
   659     /* check other events */
   680     /* check other events */
   660     else if( event->eventid == XA_PLAYEVENT_HEADATEND )
   681     else if (event->eventid == XA_PLAYEVENT_HEADATEND)
   661     {
   682         {
   662         impl->playbackState = XA_PLAYSTATE_STOPPED;
   683         impl->playbackState = XA_PLAYSTATE_STOPPED;
   663         impl->lastPosition=0;
   684         impl->lastPosition = 0;
   664         /* send callback if needed */
   685         /* send callback if needed */
   665         if( (XA_PLAYEVENT_HEADATEND & impl->eventFlags) && impl->callback )
   686         if ((XA_PLAYEVENT_HEADATEND & impl->eventFlags) && impl->callback)
   666         {
   687             {
   667             impl->callback(impl->cbPtrToSelf, impl->cbcontext, XA_PLAYEVENT_HEADATEND);
   688             impl->callback(impl->cbPtrToSelf, impl->cbcontext,
   668         }
   689                     XA_PLAYEVENT_HEADATEND);
   669     }
   690             }
   670     else if( event->eventid == XA_PLAYEVENT_HEADSTALLED )
   691         }
   671     {
   692     else if (event->eventid == XA_PLAYEVENT_HEADSTALLED)
       
   693         {
   672         impl->playbackState = XA_PLAYSTATE_PAUSED;
   694         impl->playbackState = XA_PLAYSTATE_PAUSED;
   673         if(impl->adapCtx->fwtype == FWMgrFWMMF)
   695         if (impl->adapCtx->fwtype == FWMgrFWMMF)
   674             {
   696             {
   675             //XAPlayItfAdaptMMF_GetPosition((XAAdaptationGstCtx*)impl->adapCtx, &(impl->lastPosition));
   697             //XAPlayItfAdaptMMF_GetPosition((XAAdaptationGstCtx*)impl->adapCtx, &(impl->lastPosition));
   676             }
   698             }
   677         else
   699         else
   678             {
   700             {
   679             XAPlayItfAdaptGST_GetPosition((XAAdaptationGstCtx*)impl->adapCtx, &(impl->lastPosition));
   701             XAPlayItfAdaptGST_GetPosition(
   680             }        
   702                     (XAAdaptationGstCtx*) impl->adapCtx,
       
   703                     &(impl->lastPosition));
       
   704             }
   681         /* send callback if needed */
   705         /* send callback if needed */
   682         if( (XA_PLAYEVENT_HEADSTALLED & impl->eventFlags) && impl->callback )
   706         if ((XA_PLAYEVENT_HEADSTALLED & impl->eventFlags) && impl->callback)
   683         {
   707             {
   684             impl->callback(impl->cbPtrToSelf, impl->cbcontext, XA_PLAYEVENT_HEADSTALLED);
   708             impl->callback(impl->cbPtrToSelf, impl->cbcontext,
   685         }
   709                     XA_PLAYEVENT_HEADSTALLED);
   686     }
   710             }
   687     else if( event->eventid == XA_PLAYEVENT_HEADMOVING )
   711         }
   688     {
   712     else if (event->eventid == XA_PLAYEVENT_HEADMOVING)
       
   713         {
   689         impl->playbackState = XA_PLAYSTATE_PLAYING;
   714         impl->playbackState = XA_PLAYSTATE_PLAYING;
   690         /* send callback if needed */
   715         /* send callback if needed */
   691         if( (XA_PLAYEVENT_HEADMOVING & impl->eventFlags) && impl->callback )
   716         if ((XA_PLAYEVENT_HEADMOVING & impl->eventFlags) && impl->callback)
   692         {
   717             {
   693             impl->callback(impl->cbPtrToSelf, impl->cbcontext, XA_PLAYEVENT_HEADMOVING);
   718             impl->callback(impl->cbPtrToSelf, impl->cbcontext,
   694         }
   719                     XA_PLAYEVENT_HEADMOVING);
   695     }
   720             }
       
   721         }
   696     else
   722     else
   697     {
   723         {
   698         /* do nothing */
   724         /* do nothing */
   699     }
   725         }
   700 
   726 
   701     DEBUG_API("<-XAPlayItfImpl_AdaptCb");
   727     DEBUG_API("<-XAPlayItfImpl_AdaptCb");
   702     XA_IMPL_THREAD_SAFETY_EXIT_FOR_VOID_FUNCTIONS( XATSMediaPlayer );
   728     XA_IMPL_THREAD_SAFETY_EXIT_FOR_VOID_FUNCTIONS( XATSMediaPlayer );
   703 }
   729     }
   704 
   730