khronosfws/openmax_al/src/mediarecorder/xarecorditf.c
changeset 25 6f7ceef7b1d1
parent 19 4a629bc82c5e
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: Record Itf Impl
    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 #include "xarecorditf.h"
    21 #include "xarecorditf.h"
    28 /**
    28 /**
    29  * XARecordItfImpl* GetImpl(XARecordItf self)
    29  * XARecordItfImpl* GetImpl(XARecordItf self)
    30  * Description: Validate interface pointer and cast it to implementation pointer.
    30  * Description: Validate interface pointer and cast it to implementation pointer.
    31  **/
    31  **/
    32 static XARecordItfImpl* GetImpl(XARecordItf self)
    32 static XARecordItfImpl* GetImpl(XARecordItf self)
    33 {
    33     {
    34     if( self )
    34     if (self)
    35     {
    35         {
    36         XARecordItfImpl* impl = (XARecordItfImpl*)(*self);
    36         XARecordItfImpl* impl = (XARecordItfImpl*) (*self);
    37         if( impl && (impl == impl->self) )
    37         if (impl && (impl == impl->self))
    38         {
    38             {
    39             return impl;
    39             return impl;
    40         }
    40             }
    41     }
    41         }
    42     return NULL;
    42     return NULL;
    43 }
    43     }
    44 
    44 
    45 /*****************************************************************************
    45 /*****************************************************************************
    46  * Base interface XARecordItf implementation
    46  * Base interface XARecordItf implementation
    47  *****************************************************************************/
    47  *****************************************************************************/
    48 
    48 
    49 /**
    49 /**
    50  * XAresult XARecordItfImpl_SetRecordState(XARecordItf self,
    50  * XAresult XARecordItfImpl_SetRecordState(XARecordItf self,
    51  *                                         XAuint32 state)
    51  *                                         XAuint32 state)
    52  * Description: Transitions recorder into the given record state.
    52  * Description: Transitions recorder into the given record state.
    53  **/
    53  **/
    54 XAresult XARecordItfImpl_SetRecordState(XARecordItf self,
    54 XAresult XARecordItfImpl_SetRecordState(XARecordItf self, XAuint32 state)
    55                                         XAuint32 state)
    55     {
    56 {
       
    57     XAresult ret = XA_RESULT_SUCCESS;
    56     XAresult ret = XA_RESULT_SUCCESS;
    58     XARecordItfImpl *impl = GetImpl(self);
    57     XARecordItfImpl *impl = GetImpl(self);
    59     DEBUG_API("->XARecordItfImpl_SetRecordState");
    58     DEBUG_API("->XARecordItfImpl_SetRecordState");
    60 
    59 
    61     if( !impl || state < XA_RECORDSTATE_STOPPED || state > XA_RECORDSTATE_RECORDING )
    60     if (!impl || state < XA_RECORDSTATE_STOPPED || state
    62     {
    61             > XA_RECORDSTATE_RECORDING)
       
    62         {
    63         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
    63         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
    64         DEBUG_API("<-XARecordItfImpl_SetRecordState");
    64         DEBUG_API("<-XARecordItfImpl_SetRecordState");
    65         /* invalid parameter */
    65         /* invalid parameter */
    66         return XA_RESULT_PARAMETER_INVALID;
    66         return XA_RESULT_PARAMETER_INVALID;
    67     }
    67         }
    68 
    68 
    69     /* check is play state changed, if not do nothing */
    69     /* check is play state changed, if not do nothing */
    70     if(state != impl->recordState)
    70     if (state != impl->recordState)
    71     {
    71         {
    72         if(impl->adapCtx->fwtype == FWMgrFWMMF)
    72         if (impl->adapCtx->fwtype == FWMgrFWMMF)
    73         {
    73             {
    74            ret = XARecordItfAdaptMMF_SetRecordState((XAAdaptationMMFCtx*)impl->adapCtx, state);
    74             ret = XARecordItfAdaptMMF_SetRecordState(
    75         }
    75                     (XAAdaptationMMFCtx*) impl->adapCtx, state);
       
    76             }
    76         else
    77         else
    77         {
    78             {
    78            ret = XARecordItfAdapt_SetRecordState((XAAdaptationGstCtx*)impl->adapCtx, state);
    79             ret = XARecordItfAdapt_SetRecordState(
    79         }
    80                     (XAAdaptationGstCtx*) impl->adapCtx, state);
    80 
    81             }
    81         if(ret == XA_RESULT_SUCCESS)
    82 
    82         {
    83         if (ret == XA_RESULT_SUCCESS)
       
    84             {
    83             impl->recordState = state;
    85             impl->recordState = state;
    84         }
    86             }
    85     }
    87         }
    86 
    88 
    87     DEBUG_API("<-XARecordItfImpl_SetRecordState");
    89     DEBUG_API("<-XARecordItfImpl_SetRecordState");
    88     return ret;
    90     return ret;
    89 }
    91     }
    90 
    92 
    91 /**
    93 /**
    92  * XAresult XARecordItfImpl_GetRecordState(XARecordItf self,
    94  * XAresult XARecordItfImpl_GetRecordState(XARecordItf self,
    93  *                                         XAuint32 *pState)
    95  *                                         XAuint32 *pState)
    94  * Description: Gets the recorder’s current record state.
    96  * Description: Gets the recorder’s current record state.
    95  **/
    97  **/
    96 XAresult XARecordItfImpl_GetRecordState(XARecordItf self,
    98 XAresult XARecordItfImpl_GetRecordState(XARecordItf self, XAuint32 *pState)
    97                                         XAuint32 *pState)
    99     {
    98 {
       
    99     XARecordItfImpl *impl = GetImpl(self);
   100     XARecordItfImpl *impl = GetImpl(self);
   100     DEBUG_API("->XARecordItfImpl_GetRecordState");
   101     DEBUG_API("->XARecordItfImpl_GetRecordState");
   101 
   102 
   102     if( !impl || !pState )
   103     if (!impl || !pState)
   103     {
   104         {
   104         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   105         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   105         DEBUG_API("<-XARecordItfImpl_GetRecordState");
   106         DEBUG_API("<-XARecordItfImpl_GetRecordState");
   106         /* invalid parameter */
   107         /* invalid parameter */
   107         return XA_RESULT_PARAMETER_INVALID;
   108         return XA_RESULT_PARAMETER_INVALID;
   108     }
   109         }
   109 
   110 
   110     *pState = impl->recordState;
   111     *pState = impl->recordState;
   111 
   112 
   112     DEBUG_API("<-XARecordItfImpl_GetRecordState");
   113     DEBUG_API("<-XARecordItfImpl_GetRecordState");
   113 
   114 
   114     return XA_RESULT_SUCCESS;
   115     return XA_RESULT_SUCCESS;
   115 }
   116     }
   116 
   117 
   117 /**
   118 /**
   118  * XAresult XARecordItfImpl_SetDurationLimit(XARecordItf self,
   119  * XAresult XARecordItfImpl_SetDurationLimit(XARecordItf self,
   119  *                                           XAmillisecond msec)
   120  *                                           XAmillisecond msec)
   120  * Description: Sets the duration of current content in milliseconds.
   121  * Description: Sets the duration of current content in milliseconds.
   121  **/
   122  **/
   122 XAresult XARecordItfImpl_SetDurationLimit(XARecordItf self,
   123 XAresult XARecordItfImpl_SetDurationLimit(XARecordItf self,
   123                                           XAmillisecond msec)
   124         XAmillisecond msec)
   124 {
   125     {
   125     XAresult ret = XA_RESULT_SUCCESS;
   126     XAresult ret = XA_RESULT_SUCCESS;
   126     XARecordItfImpl *impl = GetImpl(self);
   127     XARecordItfImpl *impl = GetImpl(self);
   127     DEBUG_API("->XARecordItfImpl_SetDurationLimit");
   128     DEBUG_API("->XARecordItfImpl_SetDurationLimit");
   128     XA_IMPL_THREAD_SAFETY_ENTRY(XATSMediaRecorder);
   129     XA_IMPL_THREAD_SAFETY_ENTRY(XATSMediaRecorder);
   129     if( !impl || msec <= 0 )
   130     if (!impl || msec <= 0)
   130     {
   131         {
   131         /* invalid parameter */
   132         /* invalid parameter */
   132         XA_IMPL_THREAD_SAFETY_EXIT(XATSMediaRecorder);
   133         XA_IMPL_THREAD_SAFETY_EXIT(XATSMediaRecorder);
   133         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   134         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   134         DEBUG_API("<-XARecordItfImpl_SetDurationLimit");
   135         DEBUG_API("<-XARecordItfImpl_SetDurationLimit");
   135         return XA_RESULT_PARAMETER_INVALID;
   136         return XA_RESULT_PARAMETER_INVALID;
   136     }
   137         }
   137 
   138 
   138     impl->durationLimitSetted = 1;
   139     impl->durationLimitSetted = 1;
   139     impl->durationLimit = msec;
   140     impl->durationLimit = msec;
   140     if(impl->adapCtx->fwtype == FWMgrFWGST)
   141     if (impl->adapCtx->fwtype == FWMgrFWGST)
   141     {
   142         {
   142        ret = XARecordItfAdapt_EnablePositionTracking( (XAAdaptationGstCtx*)impl->adapCtx, 1 );
   143         ret = XARecordItfAdapt_EnablePositionTracking(
   143     }
   144                 (XAAdaptationGstCtx*) impl->adapCtx, 1);
       
   145         }
   144     else
   146     else
   145     {
   147         {
   146     ret = XARecordItfAdaptMMF_EnablePositionTracking( (XAAdaptationMMFCtx*)impl->adapCtx, 1 );
   148         ret = XARecordItfAdaptMMF_EnablePositionTracking(
   147     }
   149                 (XAAdaptationMMFCtx*) impl->adapCtx, 1);
   148 
   150         }
   149 
   151 
   150     XA_IMPL_THREAD_SAFETY_EXIT(XATSMediaRecorder);
   152     XA_IMPL_THREAD_SAFETY_EXIT(XATSMediaRecorder);
   151     DEBUG_API("<-XARecordItfImpl_SetDurationLimit");
   153     DEBUG_API("<-XARecordItfImpl_SetDurationLimit");
   152     return ret;
   154     return ret;
   153 }
   155     }
   154 
   156 
   155 /**
   157 /**
   156  * XAresult XARecordItfImpl_GetPosition(XARecordItf self,
   158  * XAresult XARecordItfImpl_GetPosition(XARecordItf self,
   157  *                                      XAmillisecond *pMsec)
   159  *                                      XAmillisecond *pMsec)
   158  * Description: Returns the current position of the recording head relative
   160  * Description: Returns the current position of the recording head relative
   159  *              to the beginning of content.
   161  *              to the beginning of content.
   160  **/
   162  **/
   161 XAresult XARecordItfImpl_GetPosition(XARecordItf self,
   163 XAresult XARecordItfImpl_GetPosition(XARecordItf self, XAmillisecond *pMsec)
   162                                      XAmillisecond *pMsec)
   164     {
   163 {
       
   164     XAresult ret = XA_RESULT_SUCCESS;
   165     XAresult ret = XA_RESULT_SUCCESS;
   165     XARecordItfImpl *impl = GetImpl(self);
   166     XARecordItfImpl *impl = GetImpl(self);
   166     DEBUG_API("->XARecordItfImpl_GetPosition");
   167     DEBUG_API("->XARecordItfImpl_GetPosition");
   167     XA_IMPL_THREAD_SAFETY_ENTRY(XATSMediaRecorder);
   168     XA_IMPL_THREAD_SAFETY_ENTRY(XATSMediaRecorder);
   168     if( !impl || !pMsec )
   169     if (!impl || !pMsec)
   169     {
   170         {
   170         /* invalid parameter */
   171         /* invalid parameter */
   171         XA_IMPL_THREAD_SAFETY_EXIT(XATSMediaRecorder);
   172         XA_IMPL_THREAD_SAFETY_EXIT(XATSMediaRecorder);
   172         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   173         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   173         DEBUG_API("<-XARecordItfImpl_GetPosition");
   174         DEBUG_API("<-XARecordItfImpl_GetPosition");
   174         return XA_RESULT_PARAMETER_INVALID;
   175         return XA_RESULT_PARAMETER_INVALID;
   175     }
   176         }
   176 
   177 
   177     
   178     if (impl->adapCtx->fwtype == FWMgrFWGST)
   178     if(impl->adapCtx->fwtype == FWMgrFWGST)
   179         {
   179     {
   180         ret = XARecordItfAdapt_GetPosition(
   180     ret = XARecordItfAdapt_GetPosition((XAAdaptationGstCtx*)impl->adapCtx, pMsec);
   181                 (XAAdaptationGstCtx*) impl->adapCtx, pMsec);
   181     }
   182         }
   182     else
   183     else
   183     {
   184         {
   184     ret = XARecordItfAdaptMMF_GetPosition((XAAdaptationMMFCtx*)impl->adapCtx, pMsec);
   185         ret = XARecordItfAdaptMMF_GetPosition(
   185     }
   186                 (XAAdaptationMMFCtx*) impl->adapCtx, pMsec);
       
   187         }
   186 
   188 
   187     XA_IMPL_THREAD_SAFETY_EXIT(XATSMediaRecorder);
   189     XA_IMPL_THREAD_SAFETY_EXIT(XATSMediaRecorder);
   188     DEBUG_API("<-XARecordItfImpl_GetPosition");
   190     DEBUG_API("<-XARecordItfImpl_GetPosition");
   189     return ret;
   191     return ret;
   190 }
   192     }
   191 
   193 
   192 /**
   194 /**
   193  * XAresult XARecordItfImpl_RegisterCallback(XARecordItf self,
   195  * XAresult XARecordItfImpl_RegisterCallback(XARecordItf self,
   194  *                                           xaRecordCallback callback,
   196  *                                           xaRecordCallback callback,
   195  *                                           void *pContext)
   197  *                                           void *pContext)
   196  * Description: Registers the record callback function.
   198  * Description: Registers the record callback function.
   197  **/
   199  **/
   198 XAresult XARecordItfImpl_RegisterCallback(XARecordItf self,
   200 XAresult XARecordItfImpl_RegisterCallback(XARecordItf self,
   199                                           xaRecordCallback callback,
   201         xaRecordCallback callback, void *pContext)
   200                                           void *pContext)
   202     {
   201 {
       
   202     XAresult ret = XA_RESULT_SUCCESS;
   203     XAresult ret = XA_RESULT_SUCCESS;
   203     XARecordItfImpl *impl = GetImpl(self);
   204     XARecordItfImpl *impl = GetImpl(self);
   204     DEBUG_API("->XARecordItfImpl_RegisterCallback");
   205     DEBUG_API("->XARecordItfImpl_RegisterCallback");
   205 
   206 
   206     if( !impl )
   207     if (!impl)
   207     {
   208         {
   208         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   209         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   209         DEBUG_API("<-XARecordItfImpl_RegisterCallback");
   210         DEBUG_API("<-XARecordItfImpl_RegisterCallback");
   210         /* invalid parameter */
   211         /* invalid parameter */
   211         return XA_RESULT_PARAMETER_INVALID;
   212         return XA_RESULT_PARAMETER_INVALID;
   212     }
   213         }
   213 
   214 
   214     if( callback )
   215     if (callback)
   215     {
   216         {
   216         impl->callback = callback;
   217         impl->callback = callback;
   217         impl->cbcontext  = pContext;
   218         impl->cbcontext = pContext;
   218         impl->cbPtrToSelf = self;
   219         impl->cbPtrToSelf = self;
   219     }
   220         }
   220     else
   221     else
   221     {
   222         {
   222         /* There is no callback */
   223         /* There is no callback */
   223     }
   224         }
   224 
   225 
   225     DEBUG_API("<-XARecordItfImpl_RegisterCallback");
   226     DEBUG_API("<-XARecordItfImpl_RegisterCallback");
   226     return ret;
   227     return ret;
   227 }
   228     }
   228 
   229 
   229 /**
   230 /**
   230  * XAresult XARecordItfImpl_SetCallbackEventsMask(XARecordItf self,
   231  * XAresult XARecordItfImpl_SetCallbackEventsMask(XARecordItf self,
   231  *                                                XAuint32 eventFlags)
   232  *                                                XAuint32 eventFlags)
   232  * Description: Sets the notification state of record events.
   233  * Description: Sets the notification state of record events.
   233  **/
   234  **/
   234 XAresult XARecordItfImpl_SetCallbackEventsMask(XARecordItf self,
   235 XAresult XARecordItfImpl_SetCallbackEventsMask(XARecordItf self,
   235                                                XAuint32 eventFlags)
   236         XAuint32 eventFlags)
   236 {
   237     {
   237     XAresult ret = XA_RESULT_SUCCESS;
   238     XAresult ret = XA_RESULT_SUCCESS;
   238     XARecordItfImpl* impl = GetImpl(self);
   239     XARecordItfImpl* impl = GetImpl(self);
   239     DEBUG_API_A1("->XARecordItfImpl_SetCallbackEventsMask- %lu", eventFlags);
   240     DEBUG_API_A1("->XARecordItfImpl_SetCallbackEventsMask- %lu", eventFlags);
   240     XA_IMPL_THREAD_SAFETY_ENTRY(XATSMediaRecorder);
   241     XA_IMPL_THREAD_SAFETY_ENTRY(XATSMediaRecorder);
   241 
   242 
   242     if(!impl || (eventFlags > (XA_RECORDEVENT_HEADATLIMIT | XA_RECORDEVENT_HEADATMARKER |
   243     if (!impl || (eventFlags > (XA_RECORDEVENT_HEADATLIMIT
   243                  XA_RECORDEVENT_HEADATNEWPOS | XA_RECORDEVENT_HEADMOVING |
   244             | XA_RECORDEVENT_HEADATMARKER | XA_RECORDEVENT_HEADATNEWPOS
   244                  XA_RECORDEVENT_HEADSTALLED | XA_RECORDEVENT_BUFFER_FULL)) )
   245             | XA_RECORDEVENT_HEADMOVING | XA_RECORDEVENT_HEADSTALLED
   245     {
   246             | XA_RECORDEVENT_BUFFER_FULL)))
       
   247         {
   246         /* invalid parameter */
   248         /* invalid parameter */
   247         XA_IMPL_THREAD_SAFETY_EXIT(XATSMediaRecorder);
   249         XA_IMPL_THREAD_SAFETY_EXIT(XATSMediaRecorder);
   248         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   250         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   249         DEBUG_API("<-XARecordItfImpl_SetCallbackEventsMask");
   251         DEBUG_API("<-XARecordItfImpl_SetCallbackEventsMask");
   250         return XA_RESULT_PARAMETER_INVALID;
   252         return XA_RESULT_PARAMETER_INVALID;
   251     }
   253         }
   252 
   254 
   253     impl->eventFlags = eventFlags;
   255     impl->eventFlags = eventFlags;
   254     
   256 
   255     if(impl->adapCtx->fwtype == FWMgrFWGST)
   257     if (impl->adapCtx->fwtype == FWMgrFWGST)
   256         {
   258         {
   257             /* enable position tracking if client wants so */
   259         /* enable position tracking if client wants so */
   258             if( (eventFlags & (XA_RECORDEVENT_HEADATMARKER | XA_RECORDEVENT_HEADATNEWPOS))
   260         if ((eventFlags & (XA_RECORDEVENT_HEADATMARKER
   259                 &&  impl->adapCtx && !impl->positionupdateOn)
   261                 | XA_RECORDEVENT_HEADATNEWPOS)) && impl->adapCtx
   260             {
   262                 && !impl->positionupdateOn)
   261                 ret = XARecordItfAdapt_EnablePositionTracking((XAAdaptationGstCtx*)impl->adapCtx, XA_BOOLEAN_TRUE);
   263             {
   262                 if( ret == XA_RESULT_SUCCESS )
   264             ret = XARecordItfAdapt_EnablePositionTracking(
       
   265                     (XAAdaptationGstCtx*) impl->adapCtx, XA_BOOLEAN_TRUE);
       
   266             if (ret == XA_RESULT_SUCCESS)
   263                 {
   267                 {
   264                     impl->positionupdateOn = XA_BOOLEAN_TRUE;
   268                 impl->positionupdateOn = XA_BOOLEAN_TRUE;
   265                 }
   269                 }
   266             }
   270             }
   267             else if( !(eventFlags & (XA_RECORDEVENT_HEADATMARKER | XA_RECORDEVENT_HEADATNEWPOS))
   271         else if (!(eventFlags & (XA_RECORDEVENT_HEADATMARKER
   268                     &&  impl->adapCtx && impl->positionupdateOn)
   272                 | XA_RECORDEVENT_HEADATNEWPOS)) && impl->adapCtx
   269             {
   273                 && impl->positionupdateOn)
   270                 ret = XARecordItfAdapt_EnablePositionTracking((XAAdaptationGstCtx*)impl->adapCtx, XA_BOOLEAN_FALSE);
   274             {
   271                 if( ret == XA_RESULT_SUCCESS )
   275             ret = XARecordItfAdapt_EnablePositionTracking(
       
   276                     (XAAdaptationGstCtx*) impl->adapCtx, XA_BOOLEAN_FALSE);
       
   277             if (ret == XA_RESULT_SUCCESS)
   272                 {
   278                 {
   273                     impl->positionupdateOn = XA_BOOLEAN_FALSE;
   279                 impl->positionupdateOn = XA_BOOLEAN_FALSE;
   274                 }
   280                 }
   275             }
   281             }
   276         }
   282         }
   277     else
   283     else
   278         {
   284         {
   279             /* enable position tracking if client wants so */
   285         /* enable position tracking if client wants so */
   280             if( (eventFlags & (XA_RECORDEVENT_HEADATMARKER | XA_RECORDEVENT_HEADATNEWPOS))
   286         if ((eventFlags & (XA_RECORDEVENT_HEADATMARKER
   281                 &&  impl->adapCtx && !impl->positionupdateOn)
   287                 | XA_RECORDEVENT_HEADATNEWPOS)) && impl->adapCtx
   282             {
   288                 && !impl->positionupdateOn)
   283                 ret = XARecordItfAdaptMMF_EnablePositionTracking((XAAdaptationMMFCtx*)impl->adapCtx, XA_BOOLEAN_TRUE);
   289             {
   284                 if( ret == XA_RESULT_SUCCESS )
   290             ret = XARecordItfAdaptMMF_EnablePositionTracking(
       
   291                     (XAAdaptationMMFCtx*) impl->adapCtx, XA_BOOLEAN_TRUE);
       
   292             if (ret == XA_RESULT_SUCCESS)
   285                 {
   293                 {
   286                     impl->positionupdateOn = XA_BOOLEAN_TRUE;
   294                 impl->positionupdateOn = XA_BOOLEAN_TRUE;
   287                 }
   295                 }
   288             }
   296             }
   289             else if( !(eventFlags & (XA_RECORDEVENT_HEADATMARKER | XA_RECORDEVENT_HEADATNEWPOS))
   297         else if (!(eventFlags & (XA_RECORDEVENT_HEADATMARKER
   290                     &&  impl->adapCtx && impl->positionupdateOn)
   298                 | XA_RECORDEVENT_HEADATNEWPOS)) && impl->adapCtx
   291             {
   299                 && impl->positionupdateOn)
   292                 ret = XARecordItfAdaptMMF_EnablePositionTracking((XAAdaptationMMFCtx*)impl->adapCtx, XA_BOOLEAN_FALSE);
   300             {
   293                 if( ret == XA_RESULT_SUCCESS )
   301             ret = XARecordItfAdaptMMF_EnablePositionTracking(
       
   302                     (XAAdaptationMMFCtx*) impl->adapCtx, XA_BOOLEAN_FALSE);
       
   303             if (ret == XA_RESULT_SUCCESS)
   294                 {
   304                 {
   295                     impl->positionupdateOn = XA_BOOLEAN_FALSE;
   305                 impl->positionupdateOn = XA_BOOLEAN_FALSE;
   296                 }
   306                 }
   297     }
   307             }
   298         }
   308         }
   299     XA_IMPL_THREAD_SAFETY_EXIT(XATSMediaRecorder);
   309     XA_IMPL_THREAD_SAFETY_EXIT(XATSMediaRecorder);
   300     DEBUG_API("<-XARecordItfImpl_SetCallbackEventsMask");
   310     DEBUG_API("<-XARecordItfImpl_SetCallbackEventsMask");
   301     return ret;
   311     return ret;
   302 }
   312     }
   303 
   313 
   304 /**
   314 /**
   305  * XAresult XARecordItfImpl_GetCallbackEventsMask(XARecordItf self,
   315  * XAresult XARecordItfImpl_GetCallbackEventsMask(XARecordItf self,
   306  *                                                XAuint32 *pEventFlags)
   316  *                                                XAuint32 *pEventFlags)
   307  * Description: Queries the notification state of record events.
   317  * Description: Queries the notification state of record events.
   308  **/
   318  **/
   309 XAresult XARecordItfImpl_GetCallbackEventsMask(XARecordItf self,
   319 XAresult XARecordItfImpl_GetCallbackEventsMask(XARecordItf self,
   310                                                XAuint32 *pEventFlags)
   320         XAuint32 *pEventFlags)
   311 {
   321     {
   312     XAresult ret = XA_RESULT_SUCCESS;
   322     XAresult ret = XA_RESULT_SUCCESS;
   313     XARecordItfImpl *impl = GetImpl(self);
   323     XARecordItfImpl *impl = GetImpl(self);
   314     DEBUG_API("->XARecordItfImpl_GetCallbackEventsMask");
   324     DEBUG_API("->XARecordItfImpl_GetCallbackEventsMask");
   315 
   325 
   316     DEBUG_INFO_A1("pEventFlags - %u", pEventFlags);
   326     DEBUG_INFO_A1("pEventFlags - %u", pEventFlags);
   317 
   327 
   318 
   328     if (!impl || !pEventFlags)
   319     if( !impl || !pEventFlags )
   329         {
   320     {
       
   321         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   330         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   322         DEBUG_API("<-XARecordItfImpl_GetCallbackEventsMask");
   331         DEBUG_API("<-XARecordItfImpl_GetCallbackEventsMask");
   323         /* invalid parameter */
   332         /* invalid parameter */
   324         return XA_RESULT_PARAMETER_INVALID;
   333         return XA_RESULT_PARAMETER_INVALID;
   325     }
   334         }
   326 
   335 
   327     *pEventFlags = impl->eventFlags;
   336     *pEventFlags = impl->eventFlags;
   328     DEBUG_API("<-XARecordItfImpl_GetCallbackEventsMask");
   337     DEBUG_API("<-XARecordItfImpl_GetCallbackEventsMask");
   329     return ret;
   338     return ret;
   330 }
   339     }
   331 
   340 
   332 /**
   341 /**
   333  * XAresult XARecordItfImpl_SetMarkerPosition(XARecordItf self,
   342  * XAresult XARecordItfImpl_SetMarkerPosition(XARecordItf self,
   334  *                                            XAmillisecond mSec)
   343  *                                            XAmillisecond mSec)
   335  * Description: Sets the position of the recording marker.
   344  * Description: Sets the position of the recording marker.
   336  **/
   345  **/
   337 XAresult XARecordItfImpl_SetMarkerPosition(XARecordItf self,
   346 XAresult XARecordItfImpl_SetMarkerPosition(XARecordItf self,
   338                                            XAmillisecond mSec)
   347         XAmillisecond mSec)
   339 {
   348     {
   340     XAresult ret = XA_RESULT_SUCCESS;
   349     XAresult ret = XA_RESULT_SUCCESS;
   341     XARecordItfImpl *impl = GetImpl(self);
   350     XARecordItfImpl *impl = GetImpl(self);
   342     DEBUG_API_A1("->XARecordItfImpl_SetMarkerPosition, mSec-%lu",mSec);
   351     DEBUG_API_A1("->XARecordItfImpl_SetMarkerPosition, mSec-%lu",mSec);
   343 
   352 
   344     if( !impl || (( impl->durationLimitSetted) && (mSec > impl->durationLimit) ) )
   353     if (!impl
   345     {
   354             || ((impl->durationLimitSetted) && (mSec > impl->durationLimit)))
       
   355         {
   346         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   356         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   347         DEBUG_API("<-XARecordItfImpl_SetMarkerPosition");
   357         DEBUG_API("<-XARecordItfImpl_SetMarkerPosition");
   348         /* invalid parameter */
   358         /* invalid parameter */
   349         return XA_RESULT_PARAMETER_INVALID;
   359         return XA_RESULT_PARAMETER_INVALID;
   350     }
   360         }
   351 
   361 
   352     impl->markerPosition = mSec;
   362     impl->markerPosition = mSec;
   353 
   363 
   354     DEBUG_API("<-XARecordItfImpl_SetMarkerPosition");
   364     DEBUG_API("<-XARecordItfImpl_SetMarkerPosition");
   355     return ret;
   365     return ret;
   356 }
   366     }
   357 
   367 
   358 /**
   368 /**
   359  * XAresult XARecordItfImpl_ClearMarkerPosition(XARecordItf self)
   369  * XAresult XARecordItfImpl_ClearMarkerPosition(XARecordItf self)
   360  * Description: Clears marker.
   370  * Description: Clears marker.
   361  **/
   371  **/
   362 XAresult XARecordItfImpl_ClearMarkerPosition(XARecordItf self)
   372 XAresult XARecordItfImpl_ClearMarkerPosition(XARecordItf self)
   363 {
   373     {
   364     XAresult ret = XA_RESULT_SUCCESS;
   374     XAresult ret = XA_RESULT_SUCCESS;
   365     XARecordItfImpl *impl = GetImpl(self);
   375     XARecordItfImpl *impl = GetImpl(self);
   366     DEBUG_API("->XARecordItfImpl_ClearMarkerPosition");
   376     DEBUG_API("->XARecordItfImpl_ClearMarkerPosition");
   367 
   377 
   368     if( !impl )
   378     if (!impl)
   369     {
   379         {
   370         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   380         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   371         DEBUG_API("<-XARecordItfImpl_ClearMarkerPosition");
   381         DEBUG_API("<-XARecordItfImpl_ClearMarkerPosition");
   372         /* invalid parameter */
   382         /* invalid parameter */
   373         return XA_RESULT_PARAMETER_INVALID;
   383         return XA_RESULT_PARAMETER_INVALID;
   374     }
   384         }
   375 
   385 
   376     impl->markerPosition = NO_POSITION;
   386     impl->markerPosition = NO_POSITION;
   377 
   387 
   378     DEBUG_API("<-XARecordItfImpl_ClearMarkerPosition");
   388     DEBUG_API("<-XARecordItfImpl_ClearMarkerPosition");
   379     return ret;
   389     return ret;
   380 }
   390     }
   381 
   391 
   382 /**
   392 /**
   383  * XAresult XARecordItfImpl_GetMarkerPosition(XARecordItf self,
   393  * XAresult XARecordItfImpl_GetMarkerPosition(XARecordItf self,
   384  *                                            XAmillisecond *pMsec)
   394  *                                            XAmillisecond *pMsec)
   385  * Description: Queries the position of the recording marker.
   395  * Description: Queries the position of the recording marker.
   386  **/
   396  **/
   387 XAresult XARecordItfImpl_GetMarkerPosition(XARecordItf self,
   397 XAresult XARecordItfImpl_GetMarkerPosition(XARecordItf self,
   388                                            XAmillisecond *pMsec)
   398         XAmillisecond *pMsec)
   389 {
   399     {
   390     XARecordItfImpl *impl = GetImpl(self);
   400     XARecordItfImpl *impl = GetImpl(self);
   391     DEBUG_API("->XARecordItfImpl_GetMarkerPosition");
   401     DEBUG_API("->XARecordItfImpl_GetMarkerPosition");
   392 
   402 
   393     if( !impl || !pMsec )
   403     if (!impl || !pMsec)
   394     {
   404         {
   395         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   405         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   396         DEBUG_API("<-XARecordItfImpl_GetMarkerPosition");
   406         DEBUG_API("<-XARecordItfImpl_GetMarkerPosition");
   397         /* invalid parameter */
   407         /* invalid parameter */
   398         return XA_RESULT_PARAMETER_INVALID;
   408         return XA_RESULT_PARAMETER_INVALID;
   399     }
   409         }
   400     if ( impl->markerPosition == NO_POSITION )
   410     if (impl->markerPosition == NO_POSITION)
   401     {
   411         {
   402         DEBUG_ERR("No marker position set.");
   412         DEBUG_ERR("No marker position set.");
   403         return XA_RESULT_PRECONDITIONS_VIOLATED;
   413         return XA_RESULT_PRECONDITIONS_VIOLATED;
   404     }
   414         }
   405 
   415 
   406     *pMsec = impl->markerPosition;
   416     *pMsec = impl->markerPosition;
   407 
   417 
   408     DEBUG_API("<-XARecordItfImpl_GetMarkerPosition");
   418     DEBUG_API("<-XARecordItfImpl_GetMarkerPosition");
   409     return XA_RESULT_SUCCESS;
   419     return XA_RESULT_SUCCESS;
   410 }
   420     }
   411 
   421 
   412 /**
   422 /**
   413  * XAresult XARecordItfImpl_SetPositionUpdatePeriod(XARecordItf self,
   423  * XAresult XARecordItfImpl_SetPositionUpdatePeriod(XARecordItf self,
   414  *                                                  XAmillisecond mSec)
   424  *                                                  XAmillisecond mSec)
   415  * Description: Sets the interval between periodic position notifications.
   425  * Description: Sets the interval between periodic position notifications.
   416  **/
   426  **/
   417 XAresult XARecordItfImpl_SetPositionUpdatePeriod(XARecordItf self,
   427 XAresult XARecordItfImpl_SetPositionUpdatePeriod(XARecordItf self,
   418                                                  XAmillisecond mSec)
   428         XAmillisecond mSec)
   419 {
   429     {
   420     XAresult ret = XA_RESULT_SUCCESS;
   430     XAresult ret = XA_RESULT_SUCCESS;
   421     XARecordItfImpl *impl = GetImpl(self);
   431     XARecordItfImpl *impl = GetImpl(self);
   422     DEBUG_API_A1("->XARecordItfImpl_SetPositionUpdatePeriod, mSec-%lu",mSec);
   432     DEBUG_API_A1("->XARecordItfImpl_SetPositionUpdatePeriod, mSec-%lu",mSec);
   423 
   433 
   424     if( !impl || (( impl->durationLimitSetted) && (mSec > impl->durationLimit) ) )
   434     if (!impl
   425     {
   435             || ((impl->durationLimitSetted) && (mSec > impl->durationLimit)))
       
   436         {
   426         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   437         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   427         DEBUG_API("<-XARecordItfImpl_SetPositionUpdatePeriod");
   438         DEBUG_API("<-XARecordItfImpl_SetPositionUpdatePeriod");
   428         /* invalid parameter */
   439         /* invalid parameter */
   429         return XA_RESULT_PARAMETER_INVALID;
   440         return XA_RESULT_PARAMETER_INVALID;
   430     }
   441         }
   431 
   442 
   432     impl->positionUpdatePeriod = mSec;
   443     impl->positionUpdatePeriod = mSec;
   433 
   444 
   434     DEBUG_API("<-XARecordItfImpl_SetPositionUpdatePeriod");
   445     DEBUG_API("<-XARecordItfImpl_SetPositionUpdatePeriod");
   435     return ret;
   446     return ret;
   436 }
   447     }
   437 
   448 
   438 /**
   449 /**
   439  * XAresult XARecordItfImpl_GetPositionUpdatePeriod(XARecordItf self,
   450  * XAresult XARecordItfImpl_GetPositionUpdatePeriod(XARecordItf self,
   440  *                                                  XAmillisecond *pMsec)
   451  *                                                  XAmillisecond *pMsec)
   441  * Description: Queries the interval between periodic position notifications.
   452  * Description: Queries the interval between periodic position notifications.
   442  **/
   453  **/
   443 XAresult XARecordItfImpl_GetPositionUpdatePeriod(XARecordItf self,
   454 XAresult XARecordItfImpl_GetPositionUpdatePeriod(XARecordItf self,
   444                                                  XAmillisecond *pMsec)
   455         XAmillisecond *pMsec)
   445 {
   456     {
   446     XARecordItfImpl *impl = GetImpl(self);
   457     XARecordItfImpl *impl = GetImpl(self);
   447     DEBUG_API("->XARecordItfImpl_GetPositionUpdatePeriod");
   458     DEBUG_API("->XARecordItfImpl_GetPositionUpdatePeriod");
   448 
   459 
   449     if( !impl || !pMsec )
   460     if (!impl || !pMsec)
   450     {
   461         {
   451         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   462         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   452         DEBUG_API("<-XARecordItfImpl_GetPositionUpdatePeriod");
   463         DEBUG_API("<-XARecordItfImpl_GetPositionUpdatePeriod");
   453         /* invalid parameter */
   464         /* invalid parameter */
   454         return XA_RESULT_PARAMETER_INVALID;
   465         return XA_RESULT_PARAMETER_INVALID;
   455     }
   466         }
   456 
   467 
   457     *pMsec = impl->positionUpdatePeriod;
   468     *pMsec = impl->positionUpdatePeriod;
   458 
   469 
   459     DEBUG_API("<-XARecordItfImpl_GetPositionUpdatePeriod");
   470     DEBUG_API("<-XARecordItfImpl_GetPositionUpdatePeriod");
   460     return XA_RESULT_SUCCESS;
   471     return XA_RESULT_SUCCESS;
   461 }
   472     }
   462 
   473 
   463 /*****************************************************************************
   474 /*****************************************************************************
   464  * XARecordItfImpl -specific methods
   475  * XARecordItfImpl -specific methods
   465  *****************************************************************************/
   476  *****************************************************************************/
   466 
   477 
   467 
       
   468 /**
   478 /**
   469  * XARecordItfImpl* XARecordItfImpl_Create()
   479  * XARecordItfImpl* XARecordItfImpl_Create()
   470  * Description: Allocate and initialize XARecordItfImpl
   480  * Description: Allocate and initialize XARecordItfImpl
   471  **/
   481  **/
   472 XARecordItfImpl* XARecordItfImpl_Create( XAMediaRecorderImpl* impl )
   482 XARecordItfImpl* XARecordItfImpl_Create(XAMediaRecorderImpl* impl)
   473 {
   483     {
   474     XARecordItfImpl* self = (XARecordItfImpl*)
   484     XARecordItfImpl* self = (XARecordItfImpl*) calloc(1,
   475         calloc(1,sizeof(XARecordItfImpl));
   485             sizeof(XARecordItfImpl));
   476     
   486 
   477     
       
   478     DEBUG_API("->XARecordItfImpl_Create");
   487     DEBUG_API("->XARecordItfImpl_Create");
   479     if( self )
   488     if (self)
   480     {
   489         {
   481         /* init itf default implementation */
   490         /* init itf default implementation */
   482         self->itf.ClearMarkerPosition = XARecordItfImpl_ClearMarkerPosition;
   491         self->itf.ClearMarkerPosition = XARecordItfImpl_ClearMarkerPosition;
   483         self->itf.GetCallbackEventsMask = XARecordItfImpl_GetCallbackEventsMask;
   492         self->itf.GetCallbackEventsMask
       
   493                 = XARecordItfImpl_GetCallbackEventsMask;
   484         self->itf.GetMarkerPosition = XARecordItfImpl_GetMarkerPosition;
   494         self->itf.GetMarkerPosition = XARecordItfImpl_GetMarkerPosition;
   485         self->itf.GetPosition = XARecordItfImpl_GetPosition;
   495         self->itf.GetPosition = XARecordItfImpl_GetPosition;
   486         self->itf.GetPositionUpdatePeriod = XARecordItfImpl_GetPositionUpdatePeriod;
   496         self->itf.GetPositionUpdatePeriod
       
   497                 = XARecordItfImpl_GetPositionUpdatePeriod;
   487         self->itf.GetRecordState = XARecordItfImpl_GetRecordState;
   498         self->itf.GetRecordState = XARecordItfImpl_GetRecordState;
   488         self->itf.RegisterCallback = XARecordItfImpl_RegisterCallback;
   499         self->itf.RegisterCallback = XARecordItfImpl_RegisterCallback;
   489         self->itf.SetCallbackEventsMask = XARecordItfImpl_SetCallbackEventsMask;
   500         self->itf.SetCallbackEventsMask
       
   501                 = XARecordItfImpl_SetCallbackEventsMask;
   490         self->itf.SetDurationLimit = XARecordItfImpl_SetDurationLimit;
   502         self->itf.SetDurationLimit = XARecordItfImpl_SetDurationLimit;
   491         self->itf.SetMarkerPosition = XARecordItfImpl_SetMarkerPosition;
   503         self->itf.SetMarkerPosition = XARecordItfImpl_SetMarkerPosition;
   492         self->itf.SetPositionUpdatePeriod = XARecordItfImpl_SetPositionUpdatePeriod;
   504         self->itf.SetPositionUpdatePeriod
       
   505                 = XARecordItfImpl_SetPositionUpdatePeriod;
   493         self->itf.SetRecordState = XARecordItfImpl_SetRecordState;
   506         self->itf.SetRecordState = XARecordItfImpl_SetRecordState;
   494 
   507 
   495         /* init variables */
   508         /* init variables */
   496         self->recordState = XA_RECORDSTATE_STOPPED;
   509         self->recordState = XA_RECORDSTATE_STOPPED;
   497         self->markerPosition = NO_POSITION;
   510         self->markerPosition = NO_POSITION;
   503         self->cbcontext = NULL;
   516         self->cbcontext = NULL;
   504         self->eventFlags = 0;
   517         self->eventFlags = 0;
   505         self->cbPtrToSelf = NULL;
   518         self->cbPtrToSelf = NULL;
   506         self->pObjImpl = impl;
   519         self->pObjImpl = impl;
   507         self->adapCtx = impl->adaptationCtx;
   520         self->adapCtx = impl->adaptationCtx;
   508         XAAdaptationBase_AddEventHandler( impl->adaptationCtx, &XARecordItfImpl_AdaptCb, XA_RECORDITFEVENTS, self );
   521         XAAdaptationBase_AddEventHandler(impl->adaptationCtx,
       
   522                 &XARecordItfImpl_AdaptCb, XA_RECORDITFEVENTS, self);
   509         self->self = self;
   523         self->self = self;
   510     }
   524         }DEBUG_API("<-XARecordItfImpl_Create");
   511     DEBUG_API("<-XARecordItfImpl_Create");
       
   512     return self;
   525     return self;
   513 }
   526     }
   514 
   527 
   515 /**
   528 /**
   516  * void XARecordItfImpl_Free(XARecordItfImpl* self)
   529  * void XARecordItfImpl_Free(XARecordItfImpl* self)
   517  * Description: Free all resources reserved at XARecordItfImpl_Create
   530  * Description: Free all resources reserved at XARecordItfImpl_Create
   518  **/
   531  **/
   519 void XARecordItfImpl_Free(XARecordItfImpl* self)
   532 void XARecordItfImpl_Free(XARecordItfImpl* self)
   520 {
   533     {
   521     DEBUG_API("->XARecordItfImpl_Free");
   534     DEBUG_API("->XARecordItfImpl_Free");
   522     assert( self==self->self );
   535     assert( self==self->self );
   523     XAAdaptationBase_RemoveEventHandler( self->adapCtx, &XARecordItfImpl_AdaptCb );
   536     XAAdaptationBase_RemoveEventHandler(self->adapCtx,
   524     free( self );
   537             &XARecordItfImpl_AdaptCb);
       
   538     free(self);
   525     DEBUG_API("<-XARecordItfImpl_Free");
   539     DEBUG_API("<-XARecordItfImpl_Free");
   526 }
   540     }
   527 
   541 
   528 /* void XARecordItfImpl_AdaptCb
   542 /* void XARecordItfImpl_AdaptCb
   529  * Description: Listen changes in adaptation
   543  * Description: Listen changes in adaptation
   530  */
   544  */
   531 void XARecordItfImpl_AdaptCb( void *pHandlerCtx, XAAdaptEvent *event )
   545 void XARecordItfImpl_AdaptCb(void *pHandlerCtx, XAAdaptEvent *event)
   532 {
   546     {
   533     XARecordItfImpl* impl = (XARecordItfImpl*)pHandlerCtx;
   547     XARecordItfImpl* impl = (XARecordItfImpl*) pHandlerCtx;
   534     DEBUG_API("->XARecordItfImpl_AdaptCb");
   548     DEBUG_API("->XARecordItfImpl_AdaptCb");
   535 
   549 
   536     if(!impl)
   550     if (!impl)
   537     {
   551         {
   538         DEBUG_ERR("XARecordItfImpl_AdaptCb, invalid context pointer!");
   552         DEBUG_ERR("XARecordItfImpl_AdaptCb, invalid context pointer!");
   539         DEBUG_API("<-XARecordItfImpl_AdaptCb");
   553         DEBUG_API("<-XARecordItfImpl_AdaptCb");
   540         return;
   554         return;
   541     }
   555         }
   542     assert(event);
   556     assert(event);
   543     /* check position update events */
   557     /* check position update events */
   544     if( event->eventid == XA_ADAPT_POSITION_UPDATE_EVT )
   558     if (event->eventid == XA_ADAPT_POSITION_UPDATE_EVT)
   545     {
   559         {
   546         XAuint32 newpos = 0;
   560         XAuint32 newpos = 0;
   547         assert(event->data);
   561         assert(event->data);
   548         newpos = *((XAuint32*)(event->data));
   562         newpos = *((XAuint32*) (event->data));
   549         DEBUG_INFO_A1("new position %u",newpos);
   563         DEBUG_INFO_A1("new position %u",newpos);
   550         /* check if marker passed and callback needed */
   564         /* check if marker passed and callback needed */
   551         if( (impl->markerPosition != NO_POSITION) &&
   565         if ((impl->markerPosition != NO_POSITION) && (impl->eventFlags
   552             (impl->eventFlags & XA_RECORDEVENT_HEADATMARKER) )
   566                 & XA_RECORDEVENT_HEADATMARKER))
   553         {
   567             {
   554             if( (impl->lastPosition < impl->markerPosition) &&
   568             if ((impl->lastPosition < impl->markerPosition) && (newpos
   555                 (newpos >= impl->markerPosition) &&
   569                     >= impl->markerPosition) && impl->callback)
   556                 impl->callback )
   570                 {
   557             {
   571                 impl->callback(impl->cbPtrToSelf, impl->cbcontext,
   558                 impl->callback(impl->cbPtrToSelf, impl->cbcontext, XA_RECORDEVENT_HEADATMARKER);
   572                         XA_RECORDEVENT_HEADATMARKER);
   559             }
   573                 }
   560         }
   574             }
   561         /* check if update period passed and callback needed */
   575         /* check if update period passed and callback needed */
   562         if( (impl->positionUpdatePeriod > 0) &&
   576         if ((impl->positionUpdatePeriod > 0) && (impl->eventFlags
   563             (impl->eventFlags & XA_RECORDEVENT_HEADATNEWPOS) &&
   577                 & XA_RECORDEVENT_HEADATNEWPOS) && impl->callback)
   564             impl->callback )
   578             {
   565         {
   579             if ((XAuint32) ((impl->lastPosition)
   566             if( (XAuint32)((impl->lastPosition)/(impl->positionUpdatePeriod )) <
   580                     / (impl->positionUpdatePeriod)) < (XAuint32) (newpos
   567                 (XAuint32)(newpos/(impl->positionUpdatePeriod )) )
   581                     / (impl->positionUpdatePeriod)))
   568             {
   582                 {
   569                 impl->callback(impl->cbPtrToSelf, impl->cbcontext, XA_RECORDEVENT_HEADATNEWPOS);
   583                 impl->callback(impl->cbPtrToSelf, impl->cbcontext,
   570             }
   584                         XA_RECORDEVENT_HEADATNEWPOS);
   571         }
   585                 }
       
   586             }
   572         /* store position */
   587         /* store position */
   573         impl->lastPosition = newpos;
   588         impl->lastPosition = newpos;
   574 
   589 
   575         /* Check have we reached record duration limit */
   590         /* Check have we reached record duration limit */
   576         if ( impl->durationLimitSetted)
   591         if (impl->durationLimitSetted)
   577         {
   592             {
   578             if ( impl->callback && (impl->lastPosition >= impl->durationLimit ))
   593             if (impl->callback && (impl->lastPosition >= impl->durationLimit))
   579             {
   594                 {
   580                 impl->itf.SetRecordState(impl->cbPtrToSelf,XA_RECORDSTATE_STOPPED);
   595                 impl->itf.SetRecordState(impl->cbPtrToSelf,
   581                 impl->callback(impl->cbPtrToSelf, impl->cbcontext, XA_RECORDEVENT_HEADATLIMIT);
   596                         XA_RECORDSTATE_STOPPED);
   582             }
   597                 impl->callback(impl->cbPtrToSelf, impl->cbcontext,
   583         }
   598                         XA_RECORDEVENT_HEADATLIMIT);
   584     }
   599                 }
   585     else if( event->eventid == XA_RECORDEVENT_HEADSTALLED )
   600             }
   586     {
   601         }
       
   602     else if (event->eventid == XA_RECORDEVENT_HEADSTALLED)
       
   603         {
   587         impl->recordState = XA_RECORDSTATE_PAUSED;
   604         impl->recordState = XA_RECORDSTATE_PAUSED;
   588         /* send callback if needed */
   605         /* send callback if needed */
   589         if( (XA_RECORDEVENT_HEADSTALLED & impl->eventFlags) && impl->callback )
   606         if ((XA_RECORDEVENT_HEADSTALLED & impl->eventFlags) && impl->callback)
   590         {
   607             {
   591             impl->callback(impl->cbPtrToSelf, impl->cbcontext, XA_RECORDEVENT_HEADSTALLED);
   608             impl->callback(impl->cbPtrToSelf, impl->cbcontext,
   592         }
   609                     XA_RECORDEVENT_HEADSTALLED);
   593     }
   610             }
   594     else if( event->eventid == XA_RECORDEVENT_BUFFER_FULL )
   611         }
   595     {
   612     else if (event->eventid == XA_RECORDEVENT_BUFFER_FULL)
       
   613         {
   596         /* Adaptation is set to pause, need to sync state with AL-layer*/
   614         /* Adaptation is set to pause, need to sync state with AL-layer*/
   597         impl->recordState = XA_RECORDSTATE_STOPPED;
   615         impl->recordState = XA_RECORDSTATE_STOPPED;
   598         /* send callback if needed */
   616         /* send callback if needed */
   599         if( (XA_RECORDEVENT_BUFFER_FULL & impl->eventFlags) && impl->callback )
   617         if ((XA_RECORDEVENT_BUFFER_FULL & impl->eventFlags) && impl->callback)
   600         {
   618             {
   601             impl->callback(impl->cbPtrToSelf, impl->cbcontext, XA_RECORDEVENT_BUFFER_FULL);
   619             impl->callback(impl->cbPtrToSelf, impl->cbcontext,
   602         }
   620                     XA_RECORDEVENT_BUFFER_FULL);
   603     }
   621             }
   604     else if( event->eventid == XA_RECORDEVENT_HEADMOVING )
   622         }
   605     {
   623     else if (event->eventid == XA_RECORDEVENT_HEADMOVING)
       
   624         {
   606         /* send callback if needed */
   625         /* send callback if needed */
   607         if( (XA_RECORDEVENT_HEADMOVING & impl->eventFlags) && impl->callback )
   626         if ((XA_RECORDEVENT_HEADMOVING & impl->eventFlags) && impl->callback)
   608         {
   627             {
   609             impl->callback(impl->cbPtrToSelf, impl->cbcontext, XA_RECORDEVENT_HEADMOVING);
   628             impl->callback(impl->cbPtrToSelf, impl->cbcontext,
   610         }
   629                     XA_RECORDEVENT_HEADMOVING);
   611     }
   630             }
       
   631         }
   612     else
   632     else
   613     {
   633         {
   614         /* do nothing */
   634         /* do nothing */
   615     }
   635         }
   616 
   636 
   617     DEBUG_API("<-XARecordItfImpl_AdaptCb");
   637     DEBUG_API("<-XARecordItfImpl_AdaptCb");
   618 }
   638     }
   619 
   639