33
|
1 |
#include "opmaxplayerwindow.h"
|
|
2 |
#include "openmaxplayerutility.h"
|
|
3 |
|
|
4 |
|
|
5 |
/**
|
|
6 |
Balance values from mmfstandardcustomcommands.h
|
|
7 |
*/
|
|
8 |
#if 0
|
|
9 |
const TInt KMMFBalanceCenter = 0;
|
|
10 |
const TInt KMMFBalanceMaxLeft = -100;
|
|
11 |
const TInt KMMFBalanceMaxRight = 100;
|
|
12 |
#endif
|
|
13 |
|
|
14 |
COpMaxPlayerWindow* COpMaxPlayerWindow::NewL( RFs& aFs,
|
|
15 |
RWsSession& aWs,
|
|
16 |
CWsScreenDevice& aScreenDevice,
|
|
17 |
const RWindowTreeNode &aParentWindow,
|
|
18 |
TPoint aTopRight,
|
|
19 |
TSize aSize,
|
|
20 |
bool aTransparent,
|
|
21 |
TRgb aBackgroundColor,
|
|
22 |
bool aSuppressGraphicsContext)
|
|
23 |
{
|
|
24 |
COpMaxPlayerWindow* self = new(ELeave) COpMaxPlayerWindow( aFs, aWs, aScreenDevice, aSuppressGraphicsContext);
|
|
25 |
CleanupStack::PushL( self );
|
|
26 |
self->ConstructL( aParentWindow, aTopRight, aSize, aTransparent, aBackgroundColor );
|
|
27 |
CleanupStack::Pop();
|
|
28 |
return self;
|
|
29 |
}
|
|
30 |
|
|
31 |
COpMaxPlayerWindow::COpMaxPlayerWindow( RFs& aFs, RWsSession& aWs, CWsScreenDevice& aScreenDevice, bool aSuppressGraphicsContext ) :
|
|
32 |
CPlayerWindow( aFs, aWs, aScreenDevice, aSuppressGraphicsContext )
|
|
33 |
{
|
|
34 |
}
|
|
35 |
|
|
36 |
COpMaxPlayerWindow::~COpMaxPlayerWindow()
|
|
37 |
{
|
|
38 |
delete iVideoPlayer;
|
|
39 |
}
|
|
40 |
|
|
41 |
void COpMaxPlayerWindow::ConstructL( const RWindowTreeNode &aParentWindow, TPoint aTopRight, TSize aSize, bool aTransparent, TRgb aBackgroundColor )
|
|
42 |
{
|
|
43 |
BaseConstructL( aParentWindow, aTopRight, aSize, aTransparent, aBackgroundColor );
|
|
44 |
|
|
45 |
iVideoPlayer = new (ELeave) COpenMaxPlayerUtility;
|
|
46 |
iVideoPlayer->AddDisplayWindow( iWs, iScreenDevice, iWindow );
|
|
47 |
}
|
|
48 |
|
|
49 |
|
|
50 |
void COpMaxPlayerWindow::InitializeParameters( TSize& aVideoSize,
|
|
51 |
TTimeIntervalMicroSeconds& aDuration,
|
|
52 |
TInt& aMaxVolume,
|
|
53 |
TInt& aCurrentVolume,
|
|
54 |
TInt& aBalanceCenter,
|
|
55 |
TInt& aBalanceMaxLeft,
|
|
56 |
TInt& aBalanceMaxRight,
|
|
57 |
TInt& aDefaultBalance,
|
|
58 |
TInt& aCurrentBalance )
|
|
59 |
{
|
|
60 |
iVideoPlayer->VideoFrameSize(aVideoSize);
|
|
61 |
aDuration = iVideoPlayer->Duration();
|
|
62 |
aMaxVolume = iVideoPlayer->MaxVolume();
|
|
63 |
aCurrentVolume = iVideoPlayer->Volume();
|
|
64 |
aBalanceCenter = KMMFBalanceCenter;
|
|
65 |
aBalanceMaxLeft = KMMFBalanceMaxLeft;
|
|
66 |
aBalanceMaxRight = KMMFBalanceMaxRight;
|
|
67 |
aDefaultBalance = iVideoPlayer->Balance();
|
|
68 |
aCurrentBalance = aDefaultBalance;
|
|
69 |
}
|
|
70 |
|
|
71 |
void COpMaxPlayerWindow::SetDefaultAutoscaleMode( TAutoscaleMode aDefaultAutoscale )
|
|
72 |
{
|
|
73 |
switch( aDefaultAutoscale )
|
|
74 |
{
|
|
75 |
case EDoNotAutoscale:
|
|
76 |
iAutoScale = EAutoScaleNone;
|
|
77 |
break;
|
|
78 |
case EBestFit:
|
|
79 |
iAutoScale = EAutoScaleBestFit;
|
|
80 |
break;
|
|
81 |
case EStretch:
|
|
82 |
iAutoScale = EAutoScaleStretch;
|
|
83 |
break;
|
|
84 |
}
|
|
85 |
iDefaultAutoScale = iAutoScale;
|
|
86 |
iVideoPlayer->SetAutoScale(iWindow, iAutoScale);
|
|
87 |
}
|
|
88 |
|
|
89 |
void COpMaxPlayerWindow::PreparePlayerWithFile( RFile& aFile )
|
|
90 |
{
|
|
91 |
TFileName fileName;
|
|
92 |
aFile.FullName(fileName);
|
|
93 |
iVideoPlayer->OpenFile(fileName);
|
|
94 |
|
|
95 |
// Now wait for MvpuoOpenComplete callback.
|
|
96 |
PlayInitiated();
|
|
97 |
}
|
|
98 |
|
|
99 |
void COpMaxPlayerWindow::PreparePlayerWithUrl( const TDesC& aUrl )
|
|
100 |
{
|
|
101 |
iVideoPlayer->OpenFile(aUrl);
|
|
102 |
|
|
103 |
// Now wait for MvpuoOpenComplete callback.
|
|
104 |
}
|
|
105 |
|
|
106 |
TInt COpMaxPlayerWindow::DoExecuteOperation( TInt /*aOperation*/ )
|
|
107 |
{
|
|
108 |
// Currently there are no MMF-specific commands.
|
|
109 |
return KErrNotSupported;
|
|
110 |
}
|
|
111 |
|
|
112 |
TTimeIntervalMicroSeconds COpMaxPlayerWindow::Position()
|
|
113 |
{
|
|
114 |
TTimeIntervalMicroSeconds position = iVideoPlayer->Position();
|
|
115 |
return position;
|
|
116 |
}
|
|
117 |
|
|
118 |
TInt COpMaxPlayerWindow::SetVolume( TInt aVolume )
|
|
119 |
{
|
|
120 |
iVideoPlayer->SetVolume( aVolume );
|
|
121 |
return 0;
|
|
122 |
}
|
|
123 |
|
|
124 |
TInt COpMaxPlayerWindow::SetBalance( TInt aBalance )
|
|
125 |
{
|
|
126 |
iVideoPlayer->SetBalance( aBalance );
|
|
127 |
return 0;
|
|
128 |
}
|
|
129 |
|
|
130 |
TInt COpMaxPlayerWindow::RotationAngle()
|
|
131 |
{
|
|
132 |
TInt rotAngle = 0;
|
|
133 |
switch( iRotation )
|
|
134 |
{
|
|
135 |
case EVideoRotationClockwise90:
|
|
136 |
rotAngle = 90;
|
|
137 |
case EVideoRotationClockwise180:
|
|
138 |
rotAngle = 180;
|
|
139 |
case EVideoRotationClockwise270:
|
|
140 |
rotAngle = 270;
|
|
141 |
default:
|
|
142 |
rotAngle = 0;
|
|
143 |
}
|
|
144 |
return rotAngle;
|
|
145 |
}
|
|
146 |
|
|
147 |
TInt COpMaxPlayerWindow::NextRotationAngle()
|
|
148 |
{
|
|
149 |
switch( iRotation )
|
|
150 |
{
|
|
151 |
case EVideoRotationNone:
|
|
152 |
iRotation = EVideoRotationClockwise90;
|
|
153 |
break;
|
|
154 |
case EVideoRotationClockwise90:
|
|
155 |
iRotation = EVideoRotationClockwise180;
|
|
156 |
break;
|
|
157 |
case EVideoRotationClockwise180:
|
|
158 |
iRotation = EVideoRotationClockwise270;
|
|
159 |
break;
|
|
160 |
case EVideoRotationClockwise270:
|
|
161 |
iRotation = EVideoRotationNone;
|
|
162 |
break;
|
|
163 |
}
|
|
164 |
iVideoPlayer->SetRotation(iWindow, iRotation);
|
|
165 |
return 0;
|
|
166 |
}
|
|
167 |
|
|
168 |
TInt COpMaxPlayerWindow::ResetRotation()
|
|
169 |
{
|
|
170 |
iRotation = EVideoRotationNone;
|
|
171 |
iVideoPlayer->SetRotation(iWindow, iRotation);
|
|
172 |
return 0;
|
|
173 |
}
|
|
174 |
|
|
175 |
TInt COpMaxPlayerWindow::NextAutoscaleMode()
|
|
176 |
{
|
|
177 |
switch( iAutoScale )
|
|
178 |
{
|
|
179 |
case EAutoScaleNone:
|
|
180 |
iAutoScale = EAutoScaleBestFit;
|
|
181 |
break;
|
|
182 |
case EAutoScaleBestFit:
|
|
183 |
iAutoScale = EAutoScaleClip;
|
|
184 |
break;
|
|
185 |
case EAutoScaleClip:
|
|
186 |
iAutoScale = EAutoScaleStretch;
|
|
187 |
break;
|
|
188 |
case EAutoScaleStretch:
|
|
189 |
iAutoScale = EAutoScaleNone;
|
|
190 |
break;
|
|
191 |
}
|
|
192 |
iVideoPlayer->SetAutoScale(iWindow, iAutoScale);
|
|
193 |
return 0;
|
|
194 |
}
|
|
195 |
|
|
196 |
TInt COpMaxPlayerWindow::ResetAutoscale()
|
|
197 |
{
|
|
198 |
iAutoScale = iDefaultAutoScale;
|
|
199 |
iVideoPlayer->SetAutoScale(iWindow, iAutoScale);
|
|
200 |
return 0;
|
|
201 |
}
|
|
202 |
|
|
203 |
void COpMaxPlayerWindow::AppendAutoscaleModeText( TDes& aString )
|
|
204 |
{
|
|
205 |
switch( iAutoScale )
|
|
206 |
{
|
|
207 |
case EAutoScaleNone:
|
|
208 |
aString.Append(_L("None"));
|
|
209 |
break;
|
|
210 |
case EAutoScaleBestFit:
|
|
211 |
aString.Append(_L("Best Fit"));
|
|
212 |
break;
|
|
213 |
case EAutoScaleClip:
|
|
214 |
aString.Append(_L("Clip"));
|
|
215 |
break;
|
|
216 |
case EAutoScaleStretch:
|
|
217 |
aString.Append(_L("Stretch"));
|
|
218 |
break;
|
|
219 |
}
|
|
220 |
}
|
|
221 |
|
|
222 |
TInt COpMaxPlayerWindow::SetClipRectangle( TRect aRect )
|
|
223 |
{
|
|
224 |
iVideoPlayer->SetWindowClipRect(iWindow, aRect);
|
|
225 |
return 0;
|
|
226 |
}
|
|
227 |
|
|
228 |
TInt COpMaxPlayerWindow::SetVideoExtent( TRect aExtent )
|
|
229 |
{
|
|
230 |
iVideoPlayer->SetVideoExtent(iWindow, aExtent);
|
|
231 |
return 0;
|
|
232 |
}
|
|
233 |
|
|
234 |
TInt COpMaxPlayerWindow::SetScaleFactor( TReal aWidthScaleFactor, TReal aHeightScaleFactor )
|
|
235 |
{
|
|
236 |
iVideoPlayer->SetScaleFactor(iWindow, aWidthScaleFactor, aHeightScaleFactor);
|
|
237 |
return 0;
|
|
238 |
}
|
|
239 |
|
|
240 |
TInt COpMaxPlayerWindow::Play()
|
|
241 |
{
|
|
242 |
iVideoPlayer->Play();
|
|
243 |
return KErrNone;
|
|
244 |
}
|
|
245 |
|
|
246 |
TInt COpMaxPlayerWindow::Pause()
|
|
247 |
{
|
|
248 |
iVideoPlayer->Pause();
|
|
249 |
return 0;
|
|
250 |
}
|
|
251 |
|
|
252 |
TInt COpMaxPlayerWindow::Stop()
|
|
253 |
{
|
|
254 |
return iVideoPlayer->Stop();
|
|
255 |
}
|
|
256 |
|
|
257 |
TInt COpMaxPlayerWindow::SetPosition( TTimeIntervalMicroSeconds aPositionInMs )
|
|
258 |
{
|
|
259 |
iVideoPlayer->SetPosition( aPositionInMs );
|
|
260 |
return 0;
|
|
261 |
}
|
|
262 |
|
|
263 |
TInt COpMaxPlayerWindow::StepForward()
|
|
264 |
{
|
|
265 |
iVideoPlayer->StepFrame(1);
|
|
266 |
return 0;
|
|
267 |
}
|
|
268 |
|
|
269 |
TInt COpMaxPlayerWindow::StepBackward()
|
|
270 |
{
|
|
271 |
iVideoPlayer->StepFrame(-1);
|
|
272 |
return 0;
|
|
273 |
}
|
|
274 |
|
|
275 |
TInt COpMaxPlayerWindow::SetPlayVelocity( TInt aVelocity )
|
|
276 |
{
|
|
277 |
TRAPD( err, iVideoPlayer->SetPlayVelocity(aVelocity) );
|
|
278 |
return err;
|
|
279 |
}
|
|
280 |
|
|
281 |
// inherited from MVideoPlayerUtilityObserver
|
|
282 |
void COpMaxPlayerWindow::MvpuoOpenComplete(TInt aError)
|
|
283 |
{
|
|
284 |
RDebug::Printf( "CONSOLEPLAYER MvpuoOpenComplete(%i)", aError );
|
|
285 |
|
|
286 |
if( aError == KErrNone )
|
|
287 |
{
|
|
288 |
iVideoPlayer->Prepare();
|
|
289 |
|
|
290 |
// Now wait for MvpuoPrepareComplete callback.
|
|
291 |
}
|
|
292 |
else
|
|
293 |
{
|
|
294 |
Error( aError );
|
|
295 |
}
|
|
296 |
}
|
|
297 |
|
|
298 |
void COpMaxPlayerWindow::MvpuoPrepareComplete(TInt aError)
|
|
299 |
{
|
|
300 |
RDebug::Printf( "CONSOLEPLAYER MvpuoPrepareComplete(%i)", aError );
|
|
301 |
|
|
302 |
if( aError == KErrNone )
|
|
303 |
{
|
|
304 |
iVideoPlayer->AddDisplayWindow( iWs, iScreenDevice, iWindow );
|
|
305 |
Play();
|
|
306 |
ResetAutoscale();
|
|
307 |
PlayInitiated();
|
|
308 |
}
|
|
309 |
else
|
|
310 |
{
|
|
311 |
Error( aError );
|
|
312 |
}
|
|
313 |
}
|
|
314 |
|
|
315 |
void COpMaxPlayerWindow::MvpuoFrameReady(CFbsBitmap& /*aFrame*/,TInt aError)
|
|
316 |
{
|
|
317 |
RDebug::Printf( "CONSOLEPLAYER MvpuoFrameReady(%i)", aError );
|
|
318 |
|
|
319 |
if( aError != KErrNone )
|
|
320 |
{
|
|
321 |
Error( aError );
|
|
322 |
}
|
|
323 |
}
|
|
324 |
|
|
325 |
void COpMaxPlayerWindow::MvpuoPlayComplete(TInt aError)
|
|
326 |
{
|
|
327 |
RDebug::Printf( "CONSOLEPLAYER MvpuoPlayComplete(%i)", aError );
|
|
328 |
|
|
329 |
if( aError == KErrNone )
|
|
330 |
{
|
|
331 |
PlayComplete();
|
|
332 |
}
|
|
333 |
else
|
|
334 |
{
|
|
335 |
Error( aError );
|
|
336 |
}
|
|
337 |
}
|
|
338 |
|
|
339 |
void COpMaxPlayerWindow::MvpuoEvent(const TMMFEvent& aEvent)
|
|
340 |
{
|
|
341 |
RDebug::Printf( "CONSOLEPLAYER MvpuoEvent event=%x error=%i", aEvent.iEventType.iUid, aEvent.iErrorCode );
|
|
342 |
|
|
343 |
if( aEvent.iErrorCode != KErrNone )
|
|
344 |
{
|
|
345 |
Error( aEvent.iErrorCode );
|
|
346 |
}
|
|
347 |
}
|