khronosfws/openmax_al/src/mediaplayer/xaseekitf.c
changeset 33 5e8b14bae8c3
parent 25 6f7ceef7b1d1
child 43 9894ed580e4a
equal deleted inserted replaced
28:ebf79c79991a 33:5e8b14bae8c3
    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 
    22 #include "xaseekitf.h"
    22 #include "xaseekitf.h"
    23 
       
    24 #include "xaseekitfadaptation.h"
       
    25 #include "xaplayitfadaptation.h"
       
    26 #include "xathreadsafety.h"
    23 #include "xathreadsafety.h"
    27 #include "xaplayitfadaptationmmf.h"
    24 #include "xaplayitfadaptationmmf.h"
    28 #include "xaseekitfadaptationmmf.h"
    25 #include "xaseekitfadaptationmmf.h"
    29 /**
    26 /**
    30  * XASeekItfImpl* GetImpl(XASeekItf self)
    27  * XASeekItfImpl* GetImpl(XASeekItf self)
   106             {
   103             {
   107             impl->playbackPosition = pos;
   104             impl->playbackPosition = pos;
   108             impl->seekMode = seekMode;
   105             impl->seekMode = seekMode;
   109             }
   106             }
   110         }
   107         }
   111     else
       
   112         {
       
   113         /* Get duration of the content */
       
   114         if (XAPlayItfAdaptGST_GetDuration(
       
   115                 (XAAdaptationGstCtx*) impl->adapCtx, &duration)
       
   116                 != XA_RESULT_SUCCESS)
       
   117             {
       
   118             /* invalid parameter */
       
   119             XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer );
       
   120             DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
       
   121             DEBUG_API("<-XASeekItfImpl_SetPosition");
       
   122             return XA_RESULT_PARAMETER_INVALID;
       
   123             }
       
   124         if (pos > duration)
       
   125             {
       
   126             /* invalid parameter */
       
   127             XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer );
       
   128             DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
       
   129             DEBUG_API("<-XASeekItfImpl_SetPosition");
       
   130             return XA_RESULT_PARAMETER_INVALID;
       
   131             }
       
   132 
       
   133         if (seekMode != XA_SEEKMODE_FAST && seekMode != XA_SEEKMODE_ACCURATE)
       
   134             {
       
   135             /* seek mode unsupported */
       
   136             XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer );
       
   137             DEBUG_ERR("XA_RESULT_FEATURE_UNSUPPORTED");
       
   138             DEBUG_API("<-XASeekItfImpl_SetPosition");
       
   139             return XA_RESULT_FEATURE_UNSUPPORTED;
       
   140             }
       
   141 
       
   142         ret = XASeekItfAdapt_SetPosition((XAAdaptationGstCtx*) impl->adapCtx,
       
   143                 pos, seekMode);
       
   144         if (ret == XA_RESULT_SUCCESS)
       
   145             {
       
   146             impl->playbackPosition = pos;
       
   147             impl->seekMode = seekMode;
       
   148             }
       
   149 
       
   150         }
       
   151 
   108 
   152     XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer );
   109     XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer );
   153     DEBUG_API("<-XASeekItfImpl_SetPosition");
   110     DEBUG_API("<-XASeekItfImpl_SetPosition");
   154     return ret;
   111     return ret;
   155     }
   112     }
   205             {
   162             {
   206             impl->loopEnable = loopEnable;
   163             impl->loopEnable = loopEnable;
   207             impl->startPos = startPos;
   164             impl->startPos = startPos;
   208             impl->endPos = endPos;
   165             impl->endPos = endPos;
   209             }
   166             }
   210         }
       
   211     else
       
   212         {
       
   213         /* Get duration of the content */
       
   214         if (XAPlayItfAdaptGST_GetDuration(
       
   215                 (XAAdaptationGstCtx*) impl->adapCtx, &duration)
       
   216                 != XA_RESULT_SUCCESS)
       
   217             {
       
   218             /* invalid parameter */
       
   219             XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer );
       
   220             DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
       
   221             DEBUG_API("<-XASeekItfImpl_SetLoop");
       
   222             return XA_RESULT_PARAMETER_INVALID;
       
   223             }
       
   224         if (endPos > duration && endPos != XA_TIME_UNKNOWN)
       
   225             {
       
   226             /* invalid parameter */
       
   227             XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer );
       
   228             DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
       
   229             DEBUG_API("<-XASeekItfImpl_SetLoop");
       
   230             return XA_RESULT_PARAMETER_INVALID;
       
   231             }
       
   232 
       
   233         ret = XASeekItfAdapt_SetLoop((XAAdaptationGstCtx*) impl->adapCtx,
       
   234                 loopEnable, startPos, endPos);
       
   235         if (ret == XA_RESULT_SUCCESS)
       
   236             {
       
   237             impl->loopEnable = loopEnable;
       
   238             impl->startPos = startPos;
       
   239             impl->endPos = endPos;
       
   240             }
       
   241 
       
   242         }
   167         }
   243 
   168 
   244     XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer );
   169     XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer );
   245     DEBUG_API("<-XASeekItfImpl_SetLoop");
   170     DEBUG_API("<-XASeekItfImpl_SetLoop");
   246     return ret;
   171     return ret;
   303         self->endPos = 0;
   228         self->endPos = 0;
   304 
   229 
   305         self->adapCtx = impl->curAdaptCtx;
   230         self->adapCtx = impl->curAdaptCtx;
   306 
   231 
   307         self->self = self;
   232         self->self = self;
   308         }DEBUG_API("<-XASeekItfImpl_Create");
   233         }
       
   234     DEBUG_API("<-XASeekItfImpl_Create");
   309     return self;
   235     return self;
   310     }
   236     }
   311 
   237 
   312 /**
   238 /**
   313  * void XASeekItfImpl_Free(XASeekItfImpl* self)
   239  * void XASeekItfImpl_Free(XASeekItfImpl* self)