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 <gst.h> |
|
19 #include "XAAdaptation.h" |
|
20 #include "XAMediaPlayerAdaptCtx.h" |
|
21 #include "XAPlaybackRateItfAdaptation.h" |
|
22 #include "XAPlayItfAdaptation.h" |
|
23 |
|
24 /*XA_RATEPROP_STAGGEREDVIDEO,XA_RATEPROP_SMOOTHVIDEO,XA_RATEPROP_SILENTAUDIO, |
|
25 XA_RATEPROP_STAGGEREDAUDIO,XA_RATEPROP_NOPITCHCORAUDIO,XA_RATEPROP_PITCHCORAUDIO*/ |
|
26 #define SUPPORTEDPROPS (XA_RATEPROP_SMOOTHVIDEO | XA_RATEPROP_SILENTAUDIO) |
|
27 /* NOTE: currently rewind rates do not seem to work */ |
|
28 #define MINRATE (100) |
|
29 #define MAXRATE 8000 |
|
30 /* |
|
31 * XAresult XAPlaybackRateItfAdapt_SetRate(XAAdaptationBaseCtx *bCtx, XApermille rate) |
|
32 * @param XAAdaptationBaseCtx *bCtx - Adaptation context, this will be casted to correct type regarding to contextID value |
|
33 * @param XApermille rate - new playback rate in permilles of original speed |
|
34 * @return XAresult ret - Success value |
|
35 */ |
|
36 XAresult XAPlaybackRateItfAdapt_SetRate(XAAdaptationBaseCtx *bCtx, XApermille rate) |
|
37 { |
|
38 XAresult ret = XA_RESULT_SUCCESS; |
|
39 XAMediaPlayerAdaptationCtx* mCtx = (XAMediaPlayerAdaptationCtx*) bCtx; |
|
40 DEBUG_API_A1("->XAPlaybackRateItfAdapt_SetRate %d permilles", rate); |
|
41 |
|
42 if( !bCtx || bCtx->ctxId != XAMediaPlayerAdaptation ) |
|
43 { |
|
44 DEBUG_ERR("Invalid context!"); |
|
45 return XA_RESULT_PARAMETER_INVALID; |
|
46 } |
|
47 if( rate<MINRATE || rate>MAXRATE ) |
|
48 { |
|
49 DEBUG_ERR("Invalid rate!"); |
|
50 return XA_RESULT_PARAMETER_INVALID; |
|
51 } |
|
52 if(rate != 0) |
|
53 { |
|
54 mCtx->playrate = ((gdouble)rate)/1000; |
|
55 if( GST_STATE(bCtx->bin) < GST_STATE_PAUSED ) |
|
56 { /* This should not happen */ |
|
57 DEBUG_ERR("WARNING: Gst not prerolled yet!"); |
|
58 } |
|
59 else |
|
60 { |
|
61 /* apply immediately */ |
|
62 XAAdaptationBase_PrepareAsyncWait(bCtx); |
|
63 DEBUG_INFO_A1("Apply new playrate %f.", mCtx->playrate); |
|
64 if(!gst_element_seek( bCtx->bin, mCtx->playrate, GST_FORMAT_TIME, |
|
65 GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE, |
|
66 GST_SEEK_TYPE_NONE, 0, |
|
67 GST_SEEK_TYPE_NONE, -1)) |
|
68 { |
|
69 DEBUG_ERR("WARN: gst reports seek not handled"); |
|
70 } |
|
71 /* flushed seeks always asynchronous */ |
|
72 XAAdaptationBase_StartAsyncWait(bCtx); |
|
73 DEBUG_INFO("New playrate handled.") |
|
74 bCtx->waitingasyncop = XA_BOOLEAN_FALSE; |
|
75 } |
|
76 } |
|
77 else |
|
78 { /* Gst do not accept rate of 0, pause instead */ |
|
79 mCtx->playrate = 1.0; |
|
80 if( GST_STATE(bCtx->bin) > GST_STATE_PAUSED ) |
|
81 { |
|
82 DEBUG_ERR("Pause playback"); |
|
83 XAPlayItfAdapt_SetPlayState(bCtx, XA_PLAYSTATE_PAUSED); |
|
84 } |
|
85 |
|
86 } |
|
87 |
|
88 DEBUG_API("<-XAPlaybackRateItfAdapt_SetRate"); |
|
89 return ret; |
|
90 } |
|
91 |
|
92 /* |
|
93 * XAresult XAPlaybackRateItfAdapt_SetPropertyConstraints(XAAdaptationBaseCtx *bCtx, |
|
94 * XAuint32 constraints) |
|
95 */ |
|
96 XAresult XAPlaybackRateItfAdapt_SetPropertyConstraints(XAAdaptationBaseCtx *bCtx, |
|
97 XAuint32 constraints) |
|
98 { |
|
99 XAresult ret = XA_RESULT_SUCCESS; |
|
100 XAMediaPlayerAdaptationCtx* mCtx = NULL; |
|
101 DEBUG_API("->XAPlaybackRateItfAdapt_SetPropertyConstraints"); |
|
102 |
|
103 if( !bCtx || bCtx->ctxId != XAMediaPlayerAdaptation ) |
|
104 { |
|
105 DEBUG_ERR("Invalid context!"); |
|
106 return XA_RESULT_PARAMETER_INVALID; |
|
107 } |
|
108 mCtx = (XAMediaPlayerAdaptationCtx*) bCtx; |
|
109 if( (constraints & SUPPORTEDPROPS ) == 0 ) |
|
110 { |
|
111 DEBUG_ERR("constraints cannot be satisfied!!"); |
|
112 ret = XA_RESULT_FEATURE_UNSUPPORTED; |
|
113 } |
|
114 else |
|
115 { |
|
116 mCtx->rateprops = SUPPORTEDPROPS & constraints; |
|
117 } |
|
118 DEBUG_API("<-XAPlaybackRateItfAdapt_SetPropertyConstraints"); |
|
119 return ret; |
|
120 } |
|
121 |
|
122 /* |
|
123 * XAresult XAPlaybackRateItfAdapt_GetProperties(XAAdaptationBaseCtx *bCtx, |
|
124 * XAuint32 *pProperties) |
|
125 */ |
|
126 XAresult XAPlaybackRateItfAdapt_GetProperties(XAAdaptationBaseCtx *bCtx, |
|
127 XAuint32 *pProperties) |
|
128 { |
|
129 XAresult ret = XA_RESULT_SUCCESS; |
|
130 XAMediaPlayerAdaptationCtx* mCtx = NULL; |
|
131 DEBUG_API("->XAPlaybackRateItfAdapt_GetProperties"); |
|
132 |
|
133 if( !bCtx || bCtx->ctxId != XAMediaPlayerAdaptation ) |
|
134 { |
|
135 DEBUG_ERR("Invalid context!"); |
|
136 return XA_RESULT_PARAMETER_INVALID; |
|
137 } |
|
138 mCtx = (XAMediaPlayerAdaptationCtx*) bCtx; |
|
139 *pProperties = mCtx->rateprops; |
|
140 |
|
141 DEBUG_API("<-XAPlaybackRateItfAdapt_GetProperties"); |
|
142 return ret; |
|
143 } |
|
144 |
|
145 |
|
146 XAresult XAPlaybackRateItfAdapt_GetCapabilitiesOfRate(XAAdaptationBaseCtx *bCtx, |
|
147 XApermille rate, |
|
148 XAuint32 *pCapabilities) |
|
149 { |
|
150 XAresult ret = XA_RESULT_SUCCESS; |
|
151 XAMediaPlayerAdaptationCtx* mCtx = NULL; |
|
152 DEBUG_API("->XAPlaybackRateItfAdapt_GetCapabilitiesOfRate"); |
|
153 if( !bCtx || bCtx->ctxId != XAMediaPlayerAdaptation ) |
|
154 { |
|
155 DEBUG_ERR("Invalid context!"); |
|
156 return XA_RESULT_PARAMETER_INVALID; |
|
157 } |
|
158 mCtx = (XAMediaPlayerAdaptationCtx*) bCtx; |
|
159 if( rate<MINRATE || rate>MAXRATE ) |
|
160 { |
|
161 DEBUG_ERR("Invalid rate!"); |
|
162 *pCapabilities = 0; |
|
163 ret = XA_RESULT_PARAMETER_INVALID; |
|
164 } |
|
165 else |
|
166 { |
|
167 *pCapabilities = SUPPORTEDPROPS; |
|
168 } |
|
169 |
|
170 DEBUG_API("<-XAPlaybackRateItfAdapt_GetCapabilitiesOfRate"); |
|
171 return ret; |
|
172 } |
|
173 |
|
174 |
|
175 XAresult XAPlaybackRateItfAdapt_GetRateRange(XAAdaptationBaseCtx *bCtx, |
|
176 XAuint8 index, |
|
177 XApermille *pMinRate, |
|
178 XApermille *pMaxRate, |
|
179 XApermille *pStepSize, |
|
180 XAuint32 *pCapabilities) |
|
181 { |
|
182 XAresult ret = XA_RESULT_SUCCESS; |
|
183 XAMediaPlayerAdaptationCtx* mCtx = NULL; |
|
184 DEBUG_API("->XAPlaybackRateItfAdapt_GetRateRange"); |
|
185 |
|
186 if( !bCtx || bCtx->ctxId != XAMediaPlayerAdaptation ) |
|
187 { |
|
188 DEBUG_ERR("Invalid context!"); |
|
189 return XA_RESULT_PARAMETER_INVALID; |
|
190 } |
|
191 mCtx = (XAMediaPlayerAdaptationCtx*) bCtx; |
|
192 /* NOTE: hardcoded values, cannot be queried from gst */ |
|
193 /* only one range supported */ |
|
194 if( index>0 ) |
|
195 { |
|
196 ret = XA_RESULT_PARAMETER_INVALID; |
|
197 } |
|
198 else |
|
199 { |
|
200 *pMinRate = MINRATE; |
|
201 *pMaxRate = MAXRATE; |
|
202 *pStepSize = 0; /* continuous range */ |
|
203 *pCapabilities = SUPPORTEDPROPS; |
|
204 } |
|
205 |
|
206 DEBUG_API("<-XAPlaybackRateItfAdapt_GetRateRange"); |
|
207 return ret; |
|
208 } |
|
209 |
|