khronosfws/openmax_al/src/mmf_adaptation/xaplaybackrateitfadaptationmmf.c
author hgs
Fri, 25 Jun 2010 17:36:03 -0500
changeset 28 ebf79c79991a
permissions -rw-r--r--
201025
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
28
hgs
parents:
diff changeset
     1
/*
hgs
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
hgs
parents:
diff changeset
     3
* All rights reserved.
hgs
parents:
diff changeset
     4
* This component and the accompanying materials are made available
hgs
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
hgs
parents:
diff changeset
     6
* which accompanies this distribution, and is available
hgs
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
hgs
parents:
diff changeset
     8
*
hgs
parents:
diff changeset
     9
* Initial Contributors:
hgs
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
hgs
parents:
diff changeset
    11
*
hgs
parents:
diff changeset
    12
* Contributors:
hgs
parents:
diff changeset
    13
*
hgs
parents:
diff changeset
    14
* Description: 
hgs
parents:
diff changeset
    15
*
hgs
parents:
diff changeset
    16
*/
hgs
parents:
diff changeset
    17
hgs
parents:
diff changeset
    18
#include "xamediaplayeradaptctxmmf.h"
hgs
parents:
diff changeset
    19
#include "xaplaybackrateitfadaptationmmf.h"
hgs
parents:
diff changeset
    20
#include "xaplayitfadaptationmmf.h"
hgs
parents:
diff changeset
    21
#include "cmmfbackendengine.h"
hgs
parents:
diff changeset
    22
hgs
parents:
diff changeset
    23
/*XA_RATEPROP_STAGGEREDVIDEO,XA_RATEPROP_SMOOTHVIDEO,XA_RATEPROP_SILENTAUDIO,
hgs
parents:
diff changeset
    24
  XA_RATEPROP_STAGGEREDAUDIO,XA_RATEPROP_NOPITCHCORAUDIO,XA_RATEPROP_PITCHCORAUDIO*/
hgs
parents:
diff changeset
    25
#define SUPPORTEDPROPS (XA_RATEPROP_STAGGEREDVIDEO | XA_RATEPROP_SILENTAUDIO)
hgs
parents:
diff changeset
    26
/* NOTE: currently rewind rates do not seem to work */
hgs
parents:
diff changeset
    27
#define MINRATE (-1000)
hgs
parents:
diff changeset
    28
#define MAXRATE 4000
hgs
parents:
diff changeset
    29
/*
hgs
parents:
diff changeset
    30
 * XAresult XAPlaybackRateItfAdapt_SetRate(XAAdaptationGstCtx *bCtx, XApermille rate)
hgs
parents:
diff changeset
    31
 * @param XAAdaptationGstCtx *bCtx - Adaptation context, this will be casted to correct type regarding to contextID value
hgs
parents:
diff changeset
    32
 * @param XApermille rate - new playback rate in permilles of original speed
hgs
parents:
diff changeset
    33
 * @return XAresult ret - Success value
hgs
parents:
diff changeset
    34
 */
hgs
parents:
diff changeset
    35
XAresult XAPlaybackRateItfAdaptMMF_SetRate(XAAdaptationMMFCtx *bCtx, XApermille rate)
hgs
parents:
diff changeset
    36
{
hgs
parents:
diff changeset
    37
    XAresult ret = XA_RESULT_SUCCESS;
hgs
parents:
diff changeset
    38
    XAMediaPlayerAdaptationMMFCtx* mCtx = (XAMediaPlayerAdaptationMMFCtx*) bCtx;
hgs
parents:
diff changeset
    39
    DEBUG_API_A1("->XAPlaybackRateItfAdaptMMF_SetRate %d permilles", rate);
hgs
parents:
diff changeset
    40
hgs
parents:
diff changeset
    41
    if( !bCtx || bCtx->baseObj.ctxId != XAMediaPlayerAdaptation )
hgs
parents:
diff changeset
    42
    {
hgs
parents:
diff changeset
    43
        DEBUG_ERR("Invalid context!");
hgs
parents:
diff changeset
    44
        return XA_RESULT_PARAMETER_INVALID;
hgs
parents:
diff changeset
    45
    }
hgs
parents:
diff changeset
    46
    if( rate<MINRATE || rate>MAXRATE )
hgs
parents:
diff changeset
    47
    {
hgs
parents:
diff changeset
    48
        DEBUG_ERR("Invalid rate!");
hgs
parents:
diff changeset
    49
        return XA_RESULT_PARAMETER_INVALID;
hgs
parents:
diff changeset
    50
    }
hgs
parents:
diff changeset
    51
hgs
parents:
diff changeset
    52
    ret = mmf_playbackrateitf_set_playbackrate(mCtx->mmfContext, rate/10);
hgs
parents:
diff changeset
    53
    if(ret == XA_RESULT_SUCCESS)
hgs
parents:
diff changeset
    54
        {
hgs
parents:
diff changeset
    55
        mCtx->playrate = rate/10;
hgs
parents:
diff changeset
    56
        if(mCtx->playrate == 0 || mCtx->playrate == 100)
hgs
parents:
diff changeset
    57
            {
hgs
parents:
diff changeset
    58
            mCtx->rateprops = XA_RATEPROP_SMOOTHVIDEO | XA_RATEPROP_NOPITCHCORAUDIO;
hgs
parents:
diff changeset
    59
            }
hgs
parents:
diff changeset
    60
        else
hgs
parents:
diff changeset
    61
            {
hgs
parents:
diff changeset
    62
            mCtx->rateprops = SUPPORTEDPROPS; 
hgs
parents:
diff changeset
    63
            }
hgs
parents:
diff changeset
    64
        }
hgs
parents:
diff changeset
    65
hgs
parents:
diff changeset
    66
    DEBUG_API("<-XAPlaybackRateItfAdaptMMF_SetRate");
hgs
parents:
diff changeset
    67
    return ret;
hgs
parents:
diff changeset
    68
}
hgs
parents:
diff changeset
    69
hgs
parents:
diff changeset
    70
/*
hgs
parents:
diff changeset
    71
 * XAresult XAPlaybackRateItfAdaptMMF_SetPropertyConstraints(XAAdaptationMMFCtx *bCtx,
hgs
parents:
diff changeset
    72
 *                                                       XAuint32 constraints)
hgs
parents:
diff changeset
    73
 */
hgs
parents:
diff changeset
    74
XAresult XAPlaybackRateItfAdaptMMF_SetPropertyConstraints(XAAdaptationMMFCtx *bCtx,
hgs
parents:
diff changeset
    75
                                                       XAuint32 constraints)
hgs
parents:
diff changeset
    76
{
hgs
parents:
diff changeset
    77
    XAresult ret = XA_RESULT_SUCCESS;
hgs
parents:
diff changeset
    78
    XAuint32 capabilities;
hgs
parents:
diff changeset
    79
    XAMediaPlayerAdaptationMMFCtx* mCtx = NULL;
hgs
parents:
diff changeset
    80
    DEBUG_API("->XAPlaybackRateItfAdaptMMF_SetPropertyConstraints");
hgs
parents:
diff changeset
    81
hgs
parents:
diff changeset
    82
    if( !bCtx || bCtx->baseObj.ctxId != XAMediaPlayerAdaptation )
hgs
parents:
diff changeset
    83
    {
hgs
parents:
diff changeset
    84
        DEBUG_ERR("Invalid context!");
hgs
parents:
diff changeset
    85
        return XA_RESULT_PARAMETER_INVALID;
hgs
parents:
diff changeset
    86
    }
hgs
parents:
diff changeset
    87
    mCtx = (XAMediaPlayerAdaptationMMFCtx*) bCtx;
hgs
parents:
diff changeset
    88
    
hgs
parents:
diff changeset
    89
    ret = XAPlaybackRateItfAdaptMMF_GetCapabilitiesOfRate(bCtx,mCtx->playrate,&capabilities);
hgs
parents:
diff changeset
    90
    
hgs
parents:
diff changeset
    91
    if( (constraints & capabilities ) == 0 )
hgs
parents:
diff changeset
    92
    {
hgs
parents:
diff changeset
    93
        DEBUG_ERR("constraints cannot be satisfied!!");
hgs
parents:
diff changeset
    94
        ret = XA_RESULT_FEATURE_UNSUPPORTED;
hgs
parents:
diff changeset
    95
    }
hgs
parents:
diff changeset
    96
    else
hgs
parents:
diff changeset
    97
    {
hgs
parents:
diff changeset
    98
        mCtx->rateprops = capabilities & constraints;
hgs
parents:
diff changeset
    99
    }
hgs
parents:
diff changeset
   100
    DEBUG_API("<-XAPlaybackRateItfAdaptMMF_SetPropertyConstraints");
hgs
parents:
diff changeset
   101
    return ret;
hgs
parents:
diff changeset
   102
}
hgs
parents:
diff changeset
   103
hgs
parents:
diff changeset
   104
/*
hgs
parents:
diff changeset
   105
 * XAresult XAPlaybackRateItfAdaptMMF_GetProperties(XAAdaptationMMFCtx *bCtx,
hgs
parents:
diff changeset
   106
 *                                              XAuint32 *pProperties)
hgs
parents:
diff changeset
   107
 */
hgs
parents:
diff changeset
   108
XAresult XAPlaybackRateItfAdaptMMF_GetProperties(XAAdaptationMMFCtx *bCtx,
hgs
parents:
diff changeset
   109
                                               XAuint32 *pProperties)
hgs
parents:
diff changeset
   110
{
hgs
parents:
diff changeset
   111
    XAresult ret = XA_RESULT_SUCCESS;
hgs
parents:
diff changeset
   112
    XAMediaPlayerAdaptationMMFCtx* mCtx = NULL;
hgs
parents:
diff changeset
   113
    DEBUG_API("->XAPlaybackRateItfAdaptMMF_GetProperties");
hgs
parents:
diff changeset
   114
hgs
parents:
diff changeset
   115
    if( !bCtx || bCtx->baseObj.ctxId != XAMediaPlayerAdaptation )
hgs
parents:
diff changeset
   116
    {
hgs
parents:
diff changeset
   117
        DEBUG_ERR("Invalid context!");
hgs
parents:
diff changeset
   118
        return XA_RESULT_PARAMETER_INVALID;
hgs
parents:
diff changeset
   119
    }
hgs
parents:
diff changeset
   120
    mCtx = (XAMediaPlayerAdaptationMMFCtx*) bCtx;
hgs
parents:
diff changeset
   121
    *pProperties = mCtx->rateprops;
hgs
parents:
diff changeset
   122
hgs
parents:
diff changeset
   123
    DEBUG_API("<-XAPlaybackRateItfAdaptMMF_GetProperties");
hgs
parents:
diff changeset
   124
    return ret;
hgs
parents:
diff changeset
   125
}
hgs
parents:
diff changeset
   126
hgs
parents:
diff changeset
   127
hgs
parents:
diff changeset
   128
XAresult XAPlaybackRateItfAdaptMMF_GetCapabilitiesOfRate(XAAdaptationMMFCtx *bCtx,
hgs
parents:
diff changeset
   129
                                                       XApermille rate,
hgs
parents:
diff changeset
   130
                                                       XAuint32 *pCapabilities)
hgs
parents:
diff changeset
   131
{
hgs
parents:
diff changeset
   132
    XAresult ret = XA_RESULT_SUCCESS;
hgs
parents:
diff changeset
   133
    
hgs
parents:
diff changeset
   134
    DEBUG_API("->XAPlaybackRateItfAdaptMMF_GetCapabilitiesOfRate");
hgs
parents:
diff changeset
   135
    if( !bCtx || bCtx->baseObj.ctxId != XAMediaPlayerAdaptation || !pCapabilities)
hgs
parents:
diff changeset
   136
    {
hgs
parents:
diff changeset
   137
        DEBUG_ERR("Invalid context!");
hgs
parents:
diff changeset
   138
        return XA_RESULT_PARAMETER_INVALID;
hgs
parents:
diff changeset
   139
    }
hgs
parents:
diff changeset
   140
hgs
parents:
diff changeset
   141
    if( rate < MINRATE || rate > MAXRATE )
hgs
parents:
diff changeset
   142
    {
hgs
parents:
diff changeset
   143
        DEBUG_ERR("Invalid rate!");
hgs
parents:
diff changeset
   144
        *pCapabilities = 0;
hgs
parents:
diff changeset
   145
        ret = XA_RESULT_PARAMETER_INVALID;
hgs
parents:
diff changeset
   146
    }
hgs
parents:
diff changeset
   147
    else
hgs
parents:
diff changeset
   148
    {
hgs
parents:
diff changeset
   149
        if(rate == 0 || rate == 1000)
hgs
parents:
diff changeset
   150
            {
hgs
parents:
diff changeset
   151
            *pCapabilities = XA_RATEPROP_SMOOTHVIDEO | XA_RATEPROP_NOPITCHCORAUDIO;
hgs
parents:
diff changeset
   152
            }
hgs
parents:
diff changeset
   153
        else
hgs
parents:
diff changeset
   154
            {
hgs
parents:
diff changeset
   155
            *pCapabilities = XA_RATEPROP_STAGGEREDVIDEO | XA_RATEPROP_SILENTAUDIO;
hgs
parents:
diff changeset
   156
            }
hgs
parents:
diff changeset
   157
    }
hgs
parents:
diff changeset
   158
hgs
parents:
diff changeset
   159
    DEBUG_API("<-XAPlaybackRateItfAdaptMMF_GetCapabilitiesOfRate");
hgs
parents:
diff changeset
   160
    return ret;
hgs
parents:
diff changeset
   161
}
hgs
parents:
diff changeset
   162
hgs
parents:
diff changeset
   163
hgs
parents:
diff changeset
   164
XAresult XAPlaybackRateItfAdaptMMF_GetRateRange(XAAdaptationMMFCtx *bCtx,
hgs
parents:
diff changeset
   165
                                             XAuint8 index,
hgs
parents:
diff changeset
   166
                                             XApermille *pMinRate,
hgs
parents:
diff changeset
   167
                                             XApermille *pMaxRate,
hgs
parents:
diff changeset
   168
                                             XApermille *pStepSize,
hgs
parents:
diff changeset
   169
                                             XAuint32 *pCapabilities)
hgs
parents:
diff changeset
   170
{
hgs
parents:
diff changeset
   171
    XAresult ret = XA_RESULT_SUCCESS;
hgs
parents:
diff changeset
   172
    XAMediaPlayerAdaptationMMFCtx* mCtx;
hgs
parents:
diff changeset
   173
    XAboolean forward = XA_BOOLEAN_FALSE;
hgs
parents:
diff changeset
   174
    XAboolean backward = XA_BOOLEAN_FALSE;
hgs
parents:
diff changeset
   175
    XAuint8 allowedindex = 0;
hgs
parents:
diff changeset
   176
    
hgs
parents:
diff changeset
   177
    DEBUG_API("->XAPlaybackRateItfAdaptMMF_GetRateRange");
hgs
parents:
diff changeset
   178
hgs
parents:
diff changeset
   179
    if( !bCtx || bCtx->baseObj.ctxId != XAMediaPlayerAdaptation )
hgs
parents:
diff changeset
   180
    {
hgs
parents:
diff changeset
   181
        DEBUG_ERR("Invalid context!");
hgs
parents:
diff changeset
   182
        return XA_RESULT_PARAMETER_INVALID;
hgs
parents:
diff changeset
   183
    }
hgs
parents:
diff changeset
   184
    mCtx = (XAMediaPlayerAdaptationMMFCtx*) bCtx;
hgs
parents:
diff changeset
   185
    ret = mmf_playbackrateitf_get_playbackratecaps(mCtx->mmfContext, &forward, &backward);
hgs
parents:
diff changeset
   186
    if(ret == XA_RESULT_SUCCESS)
hgs
parents:
diff changeset
   187
        {
hgs
parents:
diff changeset
   188
        if(forward == XA_BOOLEAN_TRUE)
hgs
parents:
diff changeset
   189
            {
hgs
parents:
diff changeset
   190
            allowedindex++;
hgs
parents:
diff changeset
   191
            }
hgs
parents:
diff changeset
   192
        if(backward == XA_BOOLEAN_TRUE)
hgs
parents:
diff changeset
   193
            {
hgs
parents:
diff changeset
   194
            allowedindex++;
hgs
parents:
diff changeset
   195
            }
hgs
parents:
diff changeset
   196
    
hgs
parents:
diff changeset
   197
        if( index > allowedindex )
hgs
parents:
diff changeset
   198
            {
hgs
parents:
diff changeset
   199
            ret = XA_RESULT_PARAMETER_INVALID;
hgs
parents:
diff changeset
   200
            }
hgs
parents:
diff changeset
   201
        else
hgs
parents:
diff changeset
   202
            {
hgs
parents:
diff changeset
   203
            switch(index)
hgs
parents:
diff changeset
   204
                {
hgs
parents:
diff changeset
   205
                case 0:
hgs
parents:
diff changeset
   206
                    {
hgs
parents:
diff changeset
   207
                    *pMinRate = 0;
hgs
parents:
diff changeset
   208
                    *pMaxRate = 1000;
hgs
parents:
diff changeset
   209
                    *pStepSize = 0; /* continuous range */
hgs
parents:
diff changeset
   210
                    *pCapabilities = XA_RATEPROP_SMOOTHVIDEO | XA_RATEPROP_NOPITCHCORAUDIO;
hgs
parents:
diff changeset
   211
                    break;
hgs
parents:
diff changeset
   212
                    }
hgs
parents:
diff changeset
   213
                case 1:
hgs
parents:
diff changeset
   214
                    {
hgs
parents:
diff changeset
   215
                    *pMinRate = 2000;
hgs
parents:
diff changeset
   216
                    *pMaxRate = 4000;
hgs
parents:
diff changeset
   217
                    *pStepSize = 0; /* continuous range */
hgs
parents:
diff changeset
   218
                    *pCapabilities = SUPPORTEDPROPS;
hgs
parents:
diff changeset
   219
                    break;
hgs
parents:
diff changeset
   220
                    }
hgs
parents:
diff changeset
   221
                case 2:
hgs
parents:
diff changeset
   222
                    {
hgs
parents:
diff changeset
   223
                    *pMinRate = MINRATE;
hgs
parents:
diff changeset
   224
                    *pMaxRate = MINRATE;
hgs
parents:
diff changeset
   225
                    *pStepSize = 0; /* continuous range */
hgs
parents:
diff changeset
   226
                    *pCapabilities = SUPPORTEDPROPS;
hgs
parents:
diff changeset
   227
                    break;
hgs
parents:
diff changeset
   228
                    }
hgs
parents:
diff changeset
   229
                }
hgs
parents:
diff changeset
   230
            }
hgs
parents:
diff changeset
   231
        }
hgs
parents:
diff changeset
   232
hgs
parents:
diff changeset
   233
    DEBUG_API("<-XAPlaybackRateItfAdaptMMF_GetRateRange");
hgs
parents:
diff changeset
   234
    return ret;
hgs
parents:
diff changeset
   235
}
hgs
parents:
diff changeset
   236