|
1 /* |
|
2 * Copyright (c) 2010 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 * Source file for the main class of the ConsolePlayer test app. |
|
16 * |
|
17 */ |
|
18 |
1 #include "opmaxplayerwindow.h" |
19 #include "opmaxplayerwindow.h" |
2 #include "openmaxplayerutility.h" |
20 #include "openmaxplayerutility.h" |
3 |
21 |
4 |
22 |
5 /** |
23 /** |
9 const TInt KMMFBalanceCenter = 0; |
27 const TInt KMMFBalanceCenter = 0; |
10 const TInt KMMFBalanceMaxLeft = -100; |
28 const TInt KMMFBalanceMaxLeft = -100; |
11 const TInt KMMFBalanceMaxRight = 100; |
29 const TInt KMMFBalanceMaxRight = 100; |
12 #endif |
30 #endif |
13 |
31 |
14 COpMaxPlayerWindow* COpMaxPlayerWindow::NewL( RFs& aFs, |
32 COpMaxPlayerWindow* COpMaxPlayerWindow::NewL( RFs& aFs, |
15 RWsSession& aWs, |
33 RWsSession& aWs, |
16 CWsScreenDevice& aScreenDevice, |
34 CWsScreenDevice& aScreenDevice, |
17 const RWindowTreeNode &aParentWindow, |
35 const RWindowTreeNode &aParentWindow, |
18 TPoint aTopRight, |
36 TPoint aTopRight, |
19 TSize aSize, |
37 TSize aSize, |
23 { |
41 { |
24 COpMaxPlayerWindow* self = new(ELeave) COpMaxPlayerWindow( aFs, aWs, aScreenDevice, aSuppressGraphicsContext); |
42 COpMaxPlayerWindow* self = new(ELeave) COpMaxPlayerWindow( aFs, aWs, aScreenDevice, aSuppressGraphicsContext); |
25 CleanupStack::PushL( self ); |
43 CleanupStack::PushL( self ); |
26 self->ConstructL( aParentWindow, aTopRight, aSize, aTransparent, aBackgroundColor ); |
44 self->ConstructL( aParentWindow, aTopRight, aSize, aTransparent, aBackgroundColor ); |
27 CleanupStack::Pop(); |
45 CleanupStack::Pop(); |
28 return self; |
46 return self; |
29 } |
47 } |
30 |
48 |
31 COpMaxPlayerWindow::COpMaxPlayerWindow( RFs& aFs, RWsSession& aWs, CWsScreenDevice& aScreenDevice, bool aSuppressGraphicsContext ) : |
49 COpMaxPlayerWindow::COpMaxPlayerWindow( RFs& aFs, RWsSession& aWs, CWsScreenDevice& aScreenDevice, bool aSuppressGraphicsContext ) : |
32 CPlayerWindow( aFs, aWs, aScreenDevice, aSuppressGraphicsContext ) |
50 CPlayerWindow( aFs, aWs, aScreenDevice, aSuppressGraphicsContext ) |
33 { |
51 { |
34 } |
52 } |
35 |
53 |
36 COpMaxPlayerWindow::~COpMaxPlayerWindow() |
54 COpMaxPlayerWindow::~COpMaxPlayerWindow() |
37 { |
55 { |
38 delete iVideoPlayer; |
56 delete iVideoPlayer; |
39 } |
57 } |
40 |
58 |
41 void COpMaxPlayerWindow::ConstructL( const RWindowTreeNode &aParentWindow, TPoint aTopRight, TSize aSize, bool aTransparent, TRgb aBackgroundColor ) |
59 void COpMaxPlayerWindow::ConstructL( const RWindowTreeNode &aParentWindow, TPoint aTopRight, TSize aSize, bool aTransparent, TRgb aBackgroundColor ) |
42 { |
60 { |
45 iVideoPlayer = new (ELeave) COpenMaxPlayerUtility; |
63 iVideoPlayer = new (ELeave) COpenMaxPlayerUtility; |
46 iVideoPlayer->AddDisplayWindow( iWs, iScreenDevice, iWindow ); |
64 iVideoPlayer->AddDisplayWindow( iWs, iScreenDevice, iWindow ); |
47 } |
65 } |
48 |
66 |
49 |
67 |
50 void COpMaxPlayerWindow::InitializeParameters( TSize& aVideoSize, |
68 void COpMaxPlayerWindow::InitializeParameters( TSize& aVideoSize, |
51 TTimeIntervalMicroSeconds& aDuration, |
69 TTimeIntervalMicroSeconds& aDuration, |
52 TInt& aMaxVolume, |
70 TInt& aMaxVolume, |
53 TInt& aCurrentVolume, |
71 TInt& aCurrentVolume, |
54 TInt& aBalanceCenter, |
72 TInt& aBalanceCenter, |
55 TInt& aBalanceMaxLeft, |
73 TInt& aBalanceMaxLeft, |
56 TInt& aBalanceMaxRight, |
74 TInt& aBalanceMaxRight, |
57 TInt& aDefaultBalance, |
75 TInt& aDefaultBalance, |
58 TInt& aCurrentBalance ) |
76 TInt& aCurrentBalance ) |
59 { |
77 { |
60 iVideoPlayer->VideoFrameSize(aVideoSize); |
78 iVideoPlayer->VideoFrameSize(aVideoSize); |
61 aDuration = iVideoPlayer->Duration(); |
79 aDuration = iVideoPlayer->Duration(); |
62 aMaxVolume = iVideoPlayer->MaxVolume(); |
80 aMaxVolume = iVideoPlayer->MaxVolume(); |
63 aCurrentVolume = iVideoPlayer->Volume(); |
81 aCurrentVolume = iVideoPlayer->Volume(); |
64 aBalanceCenter = KMMFBalanceCenter; |
82 aBalanceCenter = KMMFBalanceCenter; |
65 aBalanceMaxLeft = KMMFBalanceMaxLeft; |
83 aBalanceMaxLeft = KMMFBalanceMaxLeft; |
81 case EStretch: |
99 case EStretch: |
82 iAutoScale = EAutoScaleStretch; |
100 iAutoScale = EAutoScaleStretch; |
83 break; |
101 break; |
84 } |
102 } |
85 iDefaultAutoScale = iAutoScale; |
103 iDefaultAutoScale = iAutoScale; |
86 iVideoPlayer->SetAutoScale(iWindow, iAutoScale); |
104 iVideoPlayer->SetAutoScale(iWindow, iAutoScale); |
87 } |
105 } |
88 |
106 |
89 void COpMaxPlayerWindow::PreparePlayerWithFile( RFile& aFile ) |
107 void COpMaxPlayerWindow::PreparePlayerWithFile( RFile& aFile ) |
90 { |
108 { |
91 TFileName fileName; |
109 TFileName fileName; |
92 aFile.FullName(fileName); |
110 aFile.FullName(fileName); |
93 iVideoPlayer->OpenFile(fileName); |
111 iVideoPlayer->OpenFile(fileName); |
94 |
112 |
95 // Now wait for MvpuoOpenComplete callback. |
113 // Now wait for MvpuoOpenComplete callback. |
96 PlayInitiated(); |
114 PlayInitiated(); |
97 } |
115 } |
98 |
116 |
99 void COpMaxPlayerWindow::PreparePlayerWithUrl( const TDesC& aUrl ) |
117 void COpMaxPlayerWindow::PreparePlayerWithUrl( const TDesC& aUrl ) |
100 { |
118 { |
101 iVideoPlayer->OpenFile(aUrl); |
119 iVideoPlayer->OpenFile(aUrl); |
102 |
120 |
103 // Now wait for MvpuoOpenComplete callback. |
121 // Now wait for MvpuoOpenComplete callback. |
104 } |
122 } |
105 |
123 |
106 TInt COpMaxPlayerWindow::DoExecuteOperation( TInt /*aOperation*/ ) |
124 TInt COpMaxPlayerWindow::DoExecuteOperation( TInt /*aOperation*/ ) |
107 { |
125 { |
108 // Currently there are no MMF-specific commands. |
126 // Currently there are no MMF-specific commands. |
186 iAutoScale = EAutoScaleStretch; |
204 iAutoScale = EAutoScaleStretch; |
187 break; |
205 break; |
188 case EAutoScaleStretch: |
206 case EAutoScaleStretch: |
189 iAutoScale = EAutoScaleNone; |
207 iAutoScale = EAutoScaleNone; |
190 break; |
208 break; |
191 } |
209 } |
192 iVideoPlayer->SetAutoScale(iWindow, iAutoScale); |
210 iVideoPlayer->SetAutoScale(iWindow, iAutoScale); |
193 return 0; |
211 return 0; |
194 } |
212 } |
195 |
213 |
196 TInt COpMaxPlayerWindow::ResetAutoscale() |
214 TInt COpMaxPlayerWindow::ResetAutoscale() |
280 |
298 |
281 // inherited from MVideoPlayerUtilityObserver |
299 // inherited from MVideoPlayerUtilityObserver |
282 void COpMaxPlayerWindow::MvpuoOpenComplete(TInt aError) |
300 void COpMaxPlayerWindow::MvpuoOpenComplete(TInt aError) |
283 { |
301 { |
284 RDebug::Printf( "CONSOLEPLAYER MvpuoOpenComplete(%i)", aError ); |
302 RDebug::Printf( "CONSOLEPLAYER MvpuoOpenComplete(%i)", aError ); |
285 |
303 |
286 if( aError == KErrNone ) |
304 if( aError == KErrNone ) |
287 { |
305 { |
288 iVideoPlayer->Prepare(); |
306 iVideoPlayer->Prepare(); |
289 |
307 |
290 // Now wait for MvpuoPrepareComplete callback. |
308 // Now wait for MvpuoPrepareComplete callback. |
291 } |
309 } |
292 else |
310 else |
293 { |
311 { |
294 Error( aError ); |
312 Error( aError ); |
296 } |
314 } |
297 |
315 |
298 void COpMaxPlayerWindow::MvpuoPrepareComplete(TInt aError) |
316 void COpMaxPlayerWindow::MvpuoPrepareComplete(TInt aError) |
299 { |
317 { |
300 RDebug::Printf( "CONSOLEPLAYER MvpuoPrepareComplete(%i)", aError ); |
318 RDebug::Printf( "CONSOLEPLAYER MvpuoPrepareComplete(%i)", aError ); |
301 |
319 |
302 if( aError == KErrNone ) |
320 if( aError == KErrNone ) |
303 { |
321 { |
304 iVideoPlayer->AddDisplayWindow( iWs, iScreenDevice, iWindow ); |
322 iVideoPlayer->AddDisplayWindow( iWs, iScreenDevice, iWindow ); |
305 Play(); |
323 Play(); |
306 ResetAutoscale(); |
324 ResetAutoscale(); |
313 } |
331 } |
314 |
332 |
315 void COpMaxPlayerWindow::MvpuoFrameReady(CFbsBitmap& /*aFrame*/,TInt aError) |
333 void COpMaxPlayerWindow::MvpuoFrameReady(CFbsBitmap& /*aFrame*/,TInt aError) |
316 { |
334 { |
317 RDebug::Printf( "CONSOLEPLAYER MvpuoFrameReady(%i)", aError ); |
335 RDebug::Printf( "CONSOLEPLAYER MvpuoFrameReady(%i)", aError ); |
318 |
336 |
319 if( aError != KErrNone ) |
337 if( aError != KErrNone ) |
320 { |
338 { |
321 Error( aError ); |
339 Error( aError ); |
322 } |
340 } |
323 } |
341 } |
324 |
342 |
325 void COpMaxPlayerWindow::MvpuoPlayComplete(TInt aError) |
343 void COpMaxPlayerWindow::MvpuoPlayComplete(TInt aError) |
326 { |
344 { |
327 RDebug::Printf( "CONSOLEPLAYER MvpuoPlayComplete(%i)", aError ); |
345 RDebug::Printf( "CONSOLEPLAYER MvpuoPlayComplete(%i)", aError ); |
328 |
346 |
329 if( aError == KErrNone ) |
347 if( aError == KErrNone ) |
330 { |
348 { |
331 PlayComplete(); |
349 PlayComplete(); |
332 } |
350 } |
333 else |
351 else |
335 Error( aError ); |
353 Error( aError ); |
336 } |
354 } |
337 } |
355 } |
338 |
356 |
339 void COpMaxPlayerWindow::MvpuoEvent(const TMMFEvent& aEvent) |
357 void COpMaxPlayerWindow::MvpuoEvent(const TMMFEvent& aEvent) |
340 { |
358 { |
341 RDebug::Printf( "CONSOLEPLAYER MvpuoEvent event=%x error=%i", aEvent.iEventType.iUid, aEvent.iErrorCode ); |
359 RDebug::Printf( "CONSOLEPLAYER MvpuoEvent event=%x error=%i", aEvent.iEventType.iUid, aEvent.iErrorCode ); |
342 |
360 |
343 if( aEvent.iErrorCode != KErrNone ) |
361 if( aEvent.iErrorCode != KErrNone ) |
344 { |
362 { |
345 Error( aEvent.iErrorCode ); |
363 Error( aEvent.iErrorCode ); |
346 } |
364 } |