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