|
1 /* |
|
2 * Copyright (c) 2006 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 the License "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: Controller class for handling browser requests to play video |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <mmf/common/mmferrors.h> |
|
21 #include <aknclearer.h> |
|
22 #include <AknUtils.h> |
|
23 |
|
24 #include "BavpPlugin.h" |
|
25 #include "BavpLogger.h" |
|
26 #include "BavpControllerVideo.h" |
|
27 #include "BavpView.h" |
|
28 #include "BavpViewFullScreen.h" |
|
29 #include <mmf/common/mmfcontrollerframework.h> |
|
30 #include <MMFScalingCustomCommandConstants.h> |
|
31 |
|
32 using namespace RT_GestureHelper; |
|
33 |
|
34 // CONSTANTS |
|
35 // One second represented in microseconds |
|
36 const TInt KBavpOneSecond = 1000000; |
|
37 |
|
38 // ============================ MEMBER FUNCTIONS =============================== |
|
39 |
|
40 // ----------------------------------------------------------------------------- |
|
41 // CBavpControllerVideo::NewL |
|
42 // Two-phased constructor. |
|
43 // ----------------------------------------------------------------------------- |
|
44 CBavpControllerVideo* CBavpControllerVideo::NewL( MBavpView* aView, |
|
45 TUint aAccessPtId, |
|
46 TBavpMediaType aMediaType, |
|
47 const TDesC& aFileName ) |
|
48 { |
|
49 CBavpControllerVideo* self = new( ELeave ) CBavpControllerVideo( aView, aAccessPtId ); |
|
50 |
|
51 Log( EFalse, _L("CBavpControllerVideo::NewL this="), (TInt)self ); |
|
52 |
|
53 CleanupStack::PushL( self ); |
|
54 self->ConstructL( aMediaType, aFileName ); |
|
55 CleanupStack::Pop( self ); |
|
56 return self; |
|
57 } |
|
58 |
|
59 // ----------------------------------------------------------------------------- |
|
60 // CBavpControllerVideo::~CBavpControllerVideo() |
|
61 // Destructor |
|
62 // ----------------------------------------------------------------------------- |
|
63 CBavpControllerVideo::~CBavpControllerVideo() |
|
64 { |
|
65 Log( EFalse, _L("CBavpControllerVideo::~CBavpControllerVideo this="), (TInt)this ); |
|
66 |
|
67 // If currently playing, call Stop before you close and delete |
|
68 if ( iCurrentState == EBavpPlaying && iVideoPlayer) |
|
69 { |
|
70 iVideoPlayer->Stop(); |
|
71 } |
|
72 |
|
73 // Close the video plugin, and delete it |
|
74 if ( iVideoPlayer ) |
|
75 { |
|
76 iVideoPlayer->Close(); |
|
77 #ifdef BRDO_VIDEOPLAYER2_ENABLED_FF |
|
78 iVideoPlayer->RemoveDisplayWindow(iBavpView->WindowInst()); |
|
79 #endif |
|
80 delete iVideoPlayer; |
|
81 } |
|
82 |
|
83 // CIdle AO used for display update |
|
84 if ( iDisplayUpdater ) |
|
85 { |
|
86 delete iDisplayUpdater; |
|
87 } |
|
88 |
|
89 if ( iBackLightUpdater ) |
|
90 { |
|
91 iBackLightUpdater->Cancel(); |
|
92 delete iBackLightUpdater; |
|
93 } |
|
94 // Used for displaying content in full screen |
|
95 if ( iBavpViewFullScreen ) |
|
96 { |
|
97 delete iBavpViewFullScreen; |
|
98 } |
|
99 } |
|
100 |
|
101 // ----------------------------------------------------------------------------- |
|
102 // CBavpControllerVideo::CBavpControllerVideo |
|
103 // C++ default constructor can NOT contain any code, that |
|
104 // might leave. |
|
105 // ----------------------------------------------------------------------------- |
|
106 CBavpControllerVideo::CBavpControllerVideo( MBavpView* aView, TUint aAccessPtId ) |
|
107 : CBavpController( aView, aAccessPtId ), iActiveWindow(NULL) |
|
108 { |
|
109 } |
|
110 |
|
111 // ----------------------------------------------------------------------------- |
|
112 // CBavpControllerVideo::ConstructL |
|
113 // Symbian 2nd phase constructor can leave. |
|
114 // ----------------------------------------------------------------------------- |
|
115 void CBavpControllerVideo::ConstructL( TBavpMediaType aMediaType, |
|
116 const TDesC& aFileName ) |
|
117 { |
|
118 // Construct the BavpController base class |
|
119 BaseConstructL( aMediaType, aFileName ); |
|
120 |
|
121 // Create CIdle (AO) to update the display |
|
122 iDisplayUpdater = CIdle::NewL( CActive::EPriorityIdle ); |
|
123 iBackLightUpdater=CHeartbeat::NewL(CActive::EPriorityStandard); |
|
124 } |
|
125 |
|
126 // ----------------------------------------------------------------------------- |
|
127 // CBavpControllerVideo::PrepareCompleteL |
|
128 // Handle the leaving methods needed by MvpuoPrepareComplete |
|
129 // ----------------------------------------------------------------------------- |
|
130 void CBavpControllerVideo::PrepareCompleteL() |
|
131 { |
|
132 // Resolution |
|
133 TSize size; |
|
134 iVideoPlayer->VideoFrameSizeL(size); |
|
135 iClipInfo->iResolutionHeight = size.iHeight; |
|
136 iClipInfo->iResolutionWidth = size.iWidth; |
|
137 |
|
138 // Bitrate |
|
139 iClipInfo->iBitrate = iVideoPlayer->VideoBitRateL() + |
|
140 iVideoPlayer->AudioBitRateL(); |
|
141 |
|
142 TInt iMetaCount = iVideoPlayer->NumberOfMetaDataEntriesL(); |
|
143 CMMFMetaDataEntry* metaData = NULL; |
|
144 |
|
145 for ( TInt i = 0; i < iMetaCount; i++ ) |
|
146 { |
|
147 metaData = iVideoPlayer->MetaDataEntryL( i ); |
|
148 |
|
149 Log( EFalse, _L("metaData index="), i ); |
|
150 Log( EFalse, metaData->Name() ); |
|
151 Log( EFalse, metaData->Value() ); |
|
152 |
|
153 // Check if seekable |
|
154 if ( !metaData->Name().CompareF( KBavpSeekable ) ) |
|
155 { |
|
156 if ( !metaData->Value().CompareF( KBavpFalse ) ) |
|
157 { |
|
158 iClipInfo->iSeekable = EFalse; |
|
159 } |
|
160 } |
|
161 |
|
162 // Check if live stream |
|
163 if ( !metaData->Name().CompareF( KBavpLiveStream ) ) |
|
164 { |
|
165 if ( !metaData->Value().CompareF( KBavpTrue ) ) |
|
166 { |
|
167 // Live stream is not seekable |
|
168 iClipInfo->iLiveStream = ETrue; |
|
169 iClipInfo->iSeekable = EFalse; |
|
170 } |
|
171 } |
|
172 |
|
173 delete metaData; |
|
174 } // end of for |
|
175 |
|
176 // Set up the max volume |
|
177 iClipInfo->iMaxVolume = iVideoPlayer->MaxVolume(); |
|
178 iPlayerMaxVolume = iClipInfo->iMaxVolume; |
|
179 |
|
180 // Duration |
|
181 iClipInfo->iDurationInSeconds = iVideoPlayer->DurationL(); |
|
182 |
|
183 // Audio track |
|
184 iClipInfo->iAudioTrack = iVideoPlayer->AudioEnabledL(); |
|
185 |
|
186 // Video track |
|
187 iClipInfo->iVideoTrack = iVideoPlayer->VideoBitRateL(); |
|
188 |
|
189 if ( IsClipSeekable() ) |
|
190 { |
|
191 iVideoPlayer->SetPositionL( iClipInfo->iPosition ); |
|
192 } |
|
193 #ifdef BRDO_VIDEOPLAYER2_ENABLED_FF |
|
194 TRect rect( iBavpView->CoeControl().Rect() ); |
|
195 CEikonEnv* eikon = CEikonEnv::Static(); |
|
196 RWsSession& ws = eikon->WsSession(); |
|
197 CWsScreenDevice* screenDevice = eikon->ScreenDevice(); |
|
198 // Clip rect manipulation. |
|
199 // Calculate the rect for display, including title and status pane |
|
200 TRect clipRect = GetClipRect( rect ); |
|
201 TRAPD(errAdd, iVideoPlayer->AddDisplayWindowL(CCoeEnv::Static()->WsSession(), |
|
202 *screenDevice, |
|
203 iBavpView->WindowInst(), |
|
204 rect, |
|
205 clipRect)); |
|
206 TRAPD(errScale, iVideoPlayer->SetAutoScaleL(iBavpView->WindowInst(), EAutoScaleBestFit)); |
|
207 if( ( errAdd != KErrNone ) && (iActiveWindow != &iBavpView->WindowInst()) ) |
|
208 { |
|
209 iActiveWindow = &iBavpView->WindowInst(); |
|
210 } |
|
211 Log( EFalse, _L("CBavpControllerVideo::InitVideoPlayerL() AddDisplayWindowL %d"), errAdd ); |
|
212 Log( EFalse, _L("CBavpControllerVideo::InitVideoPlayerL() SetAutoScaleL %d"), errScale ); |
|
213 #endif |
|
214 } |
|
215 |
|
216 // ----------------------------------------------------------------------------- |
|
217 // CBavpControllerVideo::InitVideoPlayer |
|
218 // The non-leaving version that calls the leaving version. Closes the current |
|
219 // player and prepares the MMF to play the video |
|
220 // ----------------------------------------------------------------------------- |
|
221 void CBavpControllerVideo::InitVideoPlayer() |
|
222 { |
|
223 TRAP_IGNORE( InitVideoPlayerL() ); |
|
224 } |
|
225 |
|
226 // ----------------------------------------------------------------------------- |
|
227 // CBavpControllerVideo::InitVideoPlayerL |
|
228 // Closes the current player and prepares the MMF to play the video |
|
229 // ----------------------------------------------------------------------------- |
|
230 void CBavpControllerVideo::InitVideoPlayerL() |
|
231 { |
|
232 Log( EFalse, _L("CBavpControllerVideo::InitVideoPlayerL()") ); |
|
233 |
|
234 // If videoplayer is already opened, close and delete it |
|
235 if ( iVideoPlayer ) |
|
236 { |
|
237 iVideoPlayer->Close(); |
|
238 #ifdef BRDO_VIDEOPLAYER2_ENABLED_FF |
|
239 iVideoPlayer->RemoveDisplayWindow(iBavpView->WindowInst()); |
|
240 #endif |
|
241 delete iVideoPlayer; |
|
242 iVideoPlayer = NULL; |
|
243 } |
|
244 |
|
245 // Get the rect to display |
|
246 TRect rect( iBavpView->CoeControl().Rect() ); |
|
247 TPoint pt = iBavpView->WindowInst().AbsPosition(); |
|
248 rect.Move( pt.iX, pt.iY ); |
|
249 |
|
250 CEikonEnv* eikon = CEikonEnv::Static(); |
|
251 RWsSession& ws = eikon->WsSession(); |
|
252 CWsScreenDevice* screenDevice = eikon->ScreenDevice(); |
|
253 |
|
254 // Clip rect manipulation. |
|
255 // Calculate the rect for display, including title and status pane |
|
256 TRect clipRect = GetClipRect( rect ); |
|
257 |
|
258 Log( EFalse, _L("InitVideoPlayerL() - calling CVideoPlayerUtility::NewL") ); |
|
259 |
|
260 // Initialize the videoplayer |
|
261 #ifdef BRDO_VIDEOPLAYER2_ENABLED_FF |
|
262 iVideoPlayer = CVideoPlayerUtility2::NewL( *this, EMdaPriorityNormal, |
|
263 EMdaPriorityPreferenceNone); |
|
264 #else |
|
265 iVideoPlayer = CVideoPlayerUtility::NewL( *this, EMdaPriorityNormal, |
|
266 EMdaPriorityPreferenceNone, |
|
267 ws, *screenDevice, |
|
268 iBavpView->WindowInst(), rect, |
|
269 clipRect); |
|
270 #endif |
|
271 |
|
272 // Register for loading notification |
|
273 iVideoPlayer->RegisterForVideoLoadingNotification( *this ); |
|
274 |
|
275 switch ( iClipInfo->iMediaType ) |
|
276 { |
|
277 case ELocalVideoFile: |
|
278 Log( EFalse, _L("InitVideoPlayerL() - calling OpenVideoFile") ); |
|
279 OpenVideoFileL(); |
|
280 break; |
|
281 |
|
282 case ELocalRamFile: |
|
283 case EUrl: |
|
284 case ELocalSdpFile: |
|
285 #if defined(BRDO_ASX_FILE) |
|
286 case ELocalAsxFile: |
|
287 #endif // BRDO_ASX_FILE |
|
288 Log( EFalse, _L("InitVideoPlayerL() - calling OpenVideoUrlL") ); |
|
289 OpenVideoUrlL(); |
|
290 break; |
|
291 |
|
292 // Not supported |
|
293 case ELocalAudioPlaylist: |
|
294 default: |
|
295 User::Leave( KErrNotSupported ); |
|
296 break; |
|
297 } |
|
298 } |
|
299 |
|
300 // ----------------------------------------------------------------------------- |
|
301 // CBavpControllerVideo::UnInitVideoPlayer |
|
302 // Closes the player and delete the instance |
|
303 // ----------------------------------------------------------------------------- |
|
304 void CBavpControllerVideo::UnInitVideoPlayer() |
|
305 { |
|
306 Log( EFalse, _L("CBavpControllerVideo::UnInitVideoPlayer()") ); |
|
307 |
|
308 if ( iVideoPlayer ) |
|
309 { |
|
310 iVideoPlayer->Close(); |
|
311 #ifdef BRDO_VIDEOPLAYER2_ENABLED_FF |
|
312 iVideoPlayer->RemoveDisplayWindow(iBavpView->WindowInst()); |
|
313 #endif |
|
314 delete iVideoPlayer; |
|
315 iVideoPlayer = NULL; |
|
316 } |
|
317 |
|
318 iCurrentState = EBavpNone; |
|
319 } |
|
320 |
|
321 // ----------------------------------------------------------------------------- |
|
322 // CBavpControllerVideo::RotateScreen90 |
|
323 // Rotate the screen if needed |
|
324 // ----------------------------------------------------------------------------- |
|
325 void CBavpControllerVideo::RotateScreen90() |
|
326 { |
|
327 Log( EFalse, _L("CBavpControllerVideo::RotateScreen90()") ); |
|
328 |
|
329 TRect screenRect; |
|
330 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, screenRect ); |
|
331 |
|
332 // Rotate only if screen rect height is greater than its width |
|
333 if ( screenRect.Height() > screenRect.Width() ) |
|
334 { |
|
335 #ifdef BRDO_VIDEOPLAYER2_ENABLED_FF |
|
336 TRAP_IGNORE( iVideoPlayer->SetRotationL(iBavpView->WindowInst(), EVideoRotationClockwise90 ) ); |
|
337 #else |
|
338 TRAP_IGNORE( iVideoPlayer->SetRotationL( EVideoRotationClockwise90 ) ); |
|
339 #endif |
|
340 |
|
341 } |
|
342 } |
|
343 |
|
344 // ----------------------------------------------------------------------------- |
|
345 // CBavpControllerVideo::RevertToFullScreenL |
|
346 // Set full screen display mode |
|
347 // ----------------------------------------------------------------------------- |
|
348 void CBavpControllerVideo::RevertToFullScreenL() |
|
349 { |
|
350 Log( EFalse, _L("CBavpControllerVideo::RevertToFullScreenL()")); |
|
351 CBavpPluginEcomMain* npm = (CBavpPluginEcomMain*)Dll::Tls(); |
|
352 bool fullscreen = true; |
|
353 |
|
354 //This method is not supported when using CVideoPlayerUtility2, and will |
|
355 //always leave with KErrNotSupported. instead of variating for new player |
|
356 //we are ignoring the Leave |
|
357 TRAP_IGNORE( iVideoPlayer->StopDirectScreenAccessL() ); |
|
358 |
|
359 |
|
360 iClipInfo->iInFullScreenMode = ETrue; |
|
361 |
|
362 npm->Funcs()->setvalue(iBavpView->bavPlugin()->getNPP(), |
|
363 NPPVpluginFullScreenBool, |
|
364 static_cast<void*>(&fullscreen)); |
|
365 iBavpView->ControllerStateChangedL(); |
|
366 |
|
367 CEikonEnv* eikon = CEikonEnv::Static(); |
|
368 RWsSession& ws = eikon->WsSession(); |
|
369 CWsScreenDevice* screenDevice = eikon->ScreenDevice(); |
|
370 |
|
371 iNormalScreenRect = iBavpView->CoeControl().Rect(); |
|
372 TPoint pt = iBavpView->WindowInst().AbsPosition(); |
|
373 iNormalScreenRect.Move(pt.iX, pt.iY); |
|
374 TRect screenRect = eikon->EikAppUi()->ApplicationRect(); |
|
375 |
|
376 CCoeControl* parentView = iBavpView->CoeControl().Parent(); |
|
377 parentView->SetRect(screenRect); |
|
378 iBavpView->CoeControl().SetExtent(TPoint(0,0), screenRect.Size()); |
|
379 |
|
380 #ifdef BRDO_VIDEOPLAYER2_ENABLED_FF |
|
381 |
|
382 iVideoPlayer->RemoveDisplayWindow(iBavpView->WindowInst()); |
|
383 TRAPD(errAdd, iVideoPlayer->AddDisplayWindowL(ws,*screenDevice,iBavpView->WindowInst(), screenRect, screenRect)); |
|
384 TRAPD(errScale, iVideoPlayer->SetAutoScaleL(iBavpView->WindowInst(), EAutoScaleBestFit)); |
|
385 Log( EFalse, _L("CBavpControllerVideo::RevertToFullScreenL() errAdd %d"), errAdd); |
|
386 Log( EFalse, _L("CBavpControllerVideo::RevertToFullScreenL() errScale %d"), errScale); |
|
387 #else |
|
388 iVideoPlayer->SetDisplayWindowL( ws, *screenDevice, |
|
389 iBavpView->WindowInst(), |
|
390 screenRect, screenRect ); |
|
391 |
|
392 RotateScreen90(); |
|
393 #endif |
|
394 } |
|
395 |
|
396 // ----------------------------------------------------------------------------- |
|
397 // CBavpControllerVideo::RevertToNormalScreenL |
|
398 // Set back to normal display mode |
|
399 // ----------------------------------------------------------------------------- |
|
400 void CBavpControllerVideo::RevertToNormalScreenL() |
|
401 { |
|
402 Log( EFalse, _L("CBavpControllerVideo::RevertToNormalScreenL()") ); |
|
403 CEikonEnv* eikon = CEikonEnv::Static(); |
|
404 RWsSession& ws = eikon->WsSession(); |
|
405 CWsScreenDevice* screenDevice = eikon->ScreenDevice(); |
|
406 CBavpPluginEcomMain* npm = (CBavpPluginEcomMain*)Dll::Tls(); |
|
407 bool fullscreen = false; |
|
408 |
|
409 //This method is not supported when using CVideoPlayerUtility2, and will |
|
410 //always leave with KErrNotSupported. instead of variating for new player |
|
411 //we are ignoring the Leave |
|
412 TRAP_IGNORE( iVideoPlayer->StopDirectScreenAccessL() ); |
|
413 |
|
414 npm->Funcs()->setvalue(iBavpView->bavPlugin()->getNPP(), |
|
415 NPPVpluginFullScreenBool, |
|
416 static_cast<void*>(&fullscreen)); |
|
417 |
|
418 CCoeControl* parentView = iBavpView->CoeControl().Parent(); |
|
419 parentView->SetRect(iNormalScreenRect); |
|
420 iBavpView->CoeControl().SetExtent(TPoint(0,0), iNormalScreenRect.Size()); |
|
421 |
|
422 iClipInfo->iInFullScreenMode = EFalse; |
|
423 RefreshRectCoordinatesL(); |
|
424 #ifdef BRDO_VIDEOPLAYER2_ENABLED_FF |
|
425 iVideoPlayer->SetRotationL(iBavpView->WindowInst(), EVideoRotationNone ); |
|
426 #else |
|
427 iVideoPlayer->SetRotationL( EVideoRotationNone ); |
|
428 #endif |
|
429 |
|
430 iBavpView->ControllerStateChangedL(); |
|
431 } |
|
432 |
|
433 // ----------------------------------------------------------------------------- |
|
434 // CBavpControllerVideo::ToggleScreen |
|
435 // Start a call back for the display screen switches (Full Screen to |
|
436 // Normal Screen) |
|
437 // ----------------------------------------------------------------------------- |
|
438 void CBavpControllerVideo::ToggleScreen() |
|
439 { |
|
440 if ( iDisplayUpdater->IsActive() ) |
|
441 { |
|
442 iDisplayUpdater->Cancel(); |
|
443 } |
|
444 |
|
445 iDisplayUpdater->Start( TCallBack( CBavpControllerVideo::WaitForScreenSwitch, |
|
446 this ) ); |
|
447 } |
|
448 |
|
449 // ----------------------------------------------------------------------------- |
|
450 // CBavpControllerVideo::RefreshRectCoordinatesL |
|
451 // Refresh the coordinates of rect for display |
|
452 // ----------------------------------------------------------------------------- |
|
453 void CBavpControllerVideo::RefreshRectCoordinatesL() |
|
454 { |
|
455 Log( EFalse, _L("CBavpControllerVideo::RefreshRectCoordinatesL()") ); |
|
456 |
|
457 if ( IsClipFullScreen() ) { |
|
458 return; |
|
459 } |
|
460 if ( iVideoPlayer ) |
|
461 { |
|
462 |
|
463 #ifdef BRDO_VIDEOPLAYER2_ENABLED_FF |
|
464 UpdateWindowSize(); |
|
465 #else |
|
466 TRect rect( iBavpView->CoeControl().Rect() ); |
|
467 |
|
468 TRect wr(iBavpView->WindowRect()); //can have negative coordinates |
|
469 //if video scrolled out of viewport |
|
470 CEikonEnv* eikon = CEikonEnv::Static(); |
|
471 RWsSession& ws = eikon->WsSession(); |
|
472 CWsScreenDevice* screenDevice = eikon->ScreenDevice(); |
|
473 |
|
474 // Windows' absolute position, relative to the current screen |
|
475 TPoint pt = iBavpView->WindowInst().AbsPosition(); |
|
476 rect.Move( pt.iX, pt.iY ); |
|
477 wr.Move( pt.iX, pt.iY ); |
|
478 |
|
479 // Reset clipRect |
|
480 TRect clipRect = rect; |
|
481 clipRect = GetClipRect( rect ); |
|
482 |
|
483 Log( EFalse, _L("\nPosition: == clipRect to DAS: ==\n") ); |
|
484 Log( EFalse, _L("\nPosition:: clipRect.x = \n"), clipRect.iTl.iX ); |
|
485 Log( EFalse, _L("\nPosition:: clipRect.y = \n"), clipRect.iTl.iY ); |
|
486 Log( EFalse, _L("\nPosition:2: clipRect.x = \n"), clipRect.iBr.iX ); |
|
487 Log( EFalse, _L("\nPosition:2: clipRect.y = \n"), clipRect.iBr.iY ); |
|
488 |
|
489 TRAP_IGNORE |
|
490 ( |
|
491 iVideoPlayer->SetDisplayWindowL( ws, *screenDevice, |
|
492 iBavpView->WindowInst(), |
|
493 wr, clipRect ); |
|
494 ); |
|
495 |
|
496 #endif |
|
497 if( iCurrentState == EBavpPaused || iCurrentState == EBavpStopped || iCurrentState == EBavpPlayComplete ) |
|
498 { |
|
499 iVideoPlayer->RefreshFrameL(); |
|
500 } |
|
501 |
|
502 } //end of iVideoPlayer |
|
503 } |
|
504 |
|
505 // ----------------------------------------------------------------------------- |
|
506 // CBavpControllerVideo::WaitForScreenSwitch |
|
507 // Switches between normal screen and full screen |
|
508 // ----------------------------------------------------------------------------- |
|
509 TInt CBavpControllerVideo::WaitForScreenSwitch( TAny* aThisData ) |
|
510 { |
|
511 TRAP_IGNORE( WaitForScreenSwitchL( aThisData ) ); |
|
512 return KErrNone; |
|
513 } |
|
514 |
|
515 // ----------------------------------------------------------------------------- |
|
516 // CBavpControllerVideo::WaitForScreenSwitch |
|
517 // Switches between normal screen and full screen |
|
518 // ----------------------------------------------------------------------------- |
|
519 void CBavpControllerVideo::WaitForScreenSwitchL( TAny* aThisData ) |
|
520 { |
|
521 Log( EFalse, _L("CBavpControllerVideo::WaitForScreenSwitchL()") ); |
|
522 |
|
523 // Use static cast |
|
524 CBavpControllerVideo* thisData = STATIC_CAST(CBavpControllerVideo*, aThisData); |
|
525 |
|
526 // Switch from Normal screen mode to Full Screen mode |
|
527 if ( !thisData->IsClipFullScreen() ) |
|
528 { |
|
529 thisData->RevertToFullScreenL(); |
|
530 |
|
531 } |
|
532 else if ( thisData->IsClipFullScreen() ) |
|
533 { |
|
534 // Switch from Full Screen mode to Normal Screen mode |
|
535 thisData->RevertToNormalScreenL(); |
|
536 |
|
537 } |
|
538 } |
|
539 |
|
540 // ----------------------------------------------------------------------------- |
|
541 // CBavpControllerVideo::DoFastForwardL |
|
542 // Fast forwards the video |
|
543 // ----------------------------------------------------------------------------- |
|
544 TInt CBavpControllerVideo::DoFastForwardL( TAny* aThisData ) |
|
545 { |
|
546 CBavpControllerVideo* thisData = STATIC_CAST( CBavpControllerVideo*, aThisData ); |
|
547 TTimeIntervalMicroSeconds skipPosition( 0 ); |
|
548 TTimeIntervalMicroSeconds currentPosition( thisData->iVideoPlayer->PositionL() ); |
|
549 |
|
550 Log( EFalse, _L("CBavpControllerVideo::DoFastForwardL() - currentPosition = "), |
|
551 currentPosition.Int64() ); |
|
552 |
|
553 // If we're not at the end of clip, skip forward a few positions |
|
554 if ( currentPosition < thisData->iClipInfo->iDurationInSeconds ) |
|
555 { |
|
556 skipPosition = currentPosition.Int64() + KSkipToPosition; |
|
557 |
|
558 // If skip pass end of clip, set to the end of clip |
|
559 if ( skipPosition > thisData->iClipInfo->iDurationInSeconds ) |
|
560 { |
|
561 skipPosition = thisData->iClipInfo->iDurationInSeconds; |
|
562 } |
|
563 |
|
564 Log( EFalse, _L("CBavpControllerVideo::DoFastForwardL() - skipPosition = "), |
|
565 skipPosition.Int64() ); |
|
566 |
|
567 // Set the position |
|
568 thisData->iVideoPlayer->SetPositionL( skipPosition ); |
|
569 |
|
570 // Refresh the frame |
|
571 thisData->iVideoPlayer->RefreshFrameL(); |
|
572 thisData->iClipInfo->iPosition = skipPosition; |
|
573 } |
|
574 else |
|
575 { |
|
576 // Fast Forward reached the end of the clip, cancel the fast forward |
|
577 thisData->iPositionUpdater->Cancel(); |
|
578 thisData->iClipInfo->iPosition = thisData->iClipInfo->iDurationInSeconds; |
|
579 // Set the state to complete since it reached the end of the clip |
|
580 thisData->iCurrentState = EBavpFastForwardComplete; |
|
581 Log( EFalse, _L("CBavpControllerVideo::DoFastForwardL() - End of clip") ); |
|
582 } |
|
583 |
|
584 return ETrue; |
|
585 } |
|
586 |
|
587 // ----------------------------------------------------------------------------- |
|
588 // CBavpControllerVideo::DoRewindL |
|
589 // Rewinds the video |
|
590 // ----------------------------------------------------------------------------- |
|
591 TInt CBavpControllerVideo::DoRewindL( TAny* aThisData ) |
|
592 { |
|
593 CBavpControllerVideo* thisData = STATIC_CAST( CBavpControllerVideo*, aThisData ); |
|
594 TTimeIntervalMicroSeconds skipPosition( 0 ); |
|
595 TTimeIntervalMicroSeconds currentPosition( thisData->iVideoPlayer->PositionL() ); |
|
596 |
|
597 Log( EFalse, _L("CBavpControllerVideo::DoFastForwardL() - currentPosition = "), |
|
598 currentPosition.Int64() ); |
|
599 |
|
600 // We're not at the beginning of the clip, rewind a few positions |
|
601 if ( currentPosition > 0 ) |
|
602 { |
|
603 skipPosition = currentPosition.Int64() - KSkipToPosition; |
|
604 |
|
605 // If skip pass beginning of clip, set to the beginning of clip |
|
606 if ( skipPosition < 0 ) |
|
607 { |
|
608 skipPosition = 0; |
|
609 } |
|
610 |
|
611 Log( EFalse, _L("CBavpControllerVideo::RewindL() - skipPosition = "), |
|
612 skipPosition.Int64() ); |
|
613 |
|
614 // Set the position |
|
615 thisData->iVideoPlayer->SetPositionL( skipPosition ); |
|
616 |
|
617 // Refresh the frame |
|
618 thisData->iVideoPlayer->RefreshFrameL(); |
|
619 thisData->iClipInfo->iPosition = skipPosition; |
|
620 } |
|
621 else |
|
622 { |
|
623 // Rewind reached the beginning of the clip, cancel the rewind |
|
624 thisData->iPositionUpdater->Cancel(); |
|
625 thisData->iClipInfo->iPosition = 0; |
|
626 // Set the state to complete since it reached beginning of clip |
|
627 thisData->iCurrentState = EBavpRewindComplete; |
|
628 Log( EFalse, _L("CBavpControllerVideo::RewindL() - beginning of clip") ); |
|
629 } |
|
630 |
|
631 return ETrue; |
|
632 } |
|
633 |
|
634 // -------------------------------------------------------------------------- |
|
635 // CBavpControllerVideo::HandleError |
|
636 // Handle error codes. We can receive errors from the MMF Video Player |
|
637 // and its MMF callbacks (mvpuoPlayComplete, etc). |
|
638 // The MMF errors are for handling content issues, such as decoding content |
|
639 // and network access. |
|
640 // NOTES: |
|
641 // MMF errors start at -12000, see /epoc32/include/mmf/common/MMFErrors.h |
|
642 // MMF also returns -1 (KErrNotFound) and few other system-wide errors |
|
643 // ----------------------------------------------------------------------------- |
|
644 void CBavpControllerVideo::HandleError( TInt aError ) |
|
645 { |
|
646 Log( EFalse, _L("In CBavpControllerVideo::HandleError(): err="), aError ); |
|
647 |
|
648 switch ( aError ) |
|
649 { |
|
650 case KErrSessionClosed: // When we stop live streaming |
|
651 if ( iCurrentState == EBavpBuffering || |
|
652 iCurrentState == EBavpStopped ) |
|
653 { |
|
654 Log( EFalse, _L("HandleError: iCurrentState=Buffering or Stopped and err=KErrSessionClosed") ); |
|
655 // Controller needs to be re-initialized, whenever |
|
656 // live streaming is "Stopped" |
|
657 // iCurrentState = EBavpNone, set by UnInitVideoPlayer |
|
658 UnInitVideoPlayer(); |
|
659 // Set state to stopped, because we "stop" live content |
|
660 iCurrentState = EBavpStopped; |
|
661 } |
|
662 else if ( iCurrentState == EBavpPlaying || |
|
663 iCurrentState == EBavpPaused ) |
|
664 { |
|
665 Log( EFalse, _L("HandleError:iCurrentState=Playing or Paused and err=KErrSessionClosed") ); |
|
666 // If the window is not on top, it might be a video or phone |
|
667 // call interrupt |
|
668 TRAP_IGNORE |
|
669 ( |
|
670 if ( !iBavpView->IsTopWindowL() ) |
|
671 { |
|
672 InitVideoPlayer(); |
|
673 } |
|
674 ) // end of TRAP_IGNORE |
|
675 } |
|
676 else |
|
677 { |
|
678 } |
|
679 break; |
|
680 |
|
681 case KErrDisconnected: |
|
682 // If the window is not on top, it might be a video or phone |
|
683 // call interrupt |
|
684 Log( EFalse, _L("HandleError: err=KErrDisconnected") ); |
|
685 TRAP_IGNORE |
|
686 ( |
|
687 if ( !iBavpView->IsTopWindowL() ) |
|
688 { |
|
689 InitVideoPlayer(); |
|
690 } |
|
691 ) // end of TRAP_IGNORE |
|
692 break; |
|
693 |
|
694 case KErrMMVideoDevice: |
|
695 case KErrMMAudioDevice: |
|
696 HandleMultiInstanceError(); |
|
697 break; |
|
698 |
|
699 // Errors from MMF (i.e. MvpuoPrepareComplete, MvpuoPlayComplete...) |
|
700 case KErrNotFound: |
|
701 case KErrNotSupported: |
|
702 case KErrCorrupt: |
|
703 case KErrInUse: |
|
704 case KErrNoMemory: |
|
705 case KErrAbort: |
|
706 case KErrArgument: |
|
707 case KErrCouldNotConnect: |
|
708 case KErrTimedOut: |
|
709 case KErrHardwareNotAvailable: |
|
710 case KErrOverflow: |
|
711 case KErrMMNotEnoughBandwidth: |
|
712 case KErrMMNetworkRead: |
|
713 case KErrMMNetworkWrite: |
|
714 case KErrMMServerNotSupported: |
|
715 case KErrMMUDPReceive: |
|
716 case KErrMMInvalidProtocol: |
|
717 case KErrMMInvalidURL: |
|
718 case KErrMMProxyServer: |
|
719 case KErrMMDecoder: |
|
720 case KErrMMPartialPlayback: |
|
721 // Close the player and delete player instance. |
|
722 // iCurrentState = EBavpNone, set by UnInitVideoPlayer. |
|
723 UnInitVideoPlayer(); |
|
724 |
|
725 // Display we have bad content |
|
726 Log( EFalse, _L("HandleError: state=BadContent") ); |
|
727 iCurrentState = EBavpBadContent; |
|
728 iBavpView->UpdateView(); |
|
729 break; |
|
730 |
|
731 default: |
|
732 // Do nothing |
|
733 break; |
|
734 |
|
735 } // end of switch |
|
736 |
|
737 Log( EFalse, _L("Out CBavpControllerVideo::HandleError()") ); |
|
738 } |
|
739 |
|
740 // ----------------------------------------------------------------------------- |
|
741 // CBavpControllerVideo::HandleKeysL |
|
742 // Handles user key presses when we're Activated (aka Top of CCoeControl stack) |
|
743 // ----------------------------------------------------------------------------- |
|
744 TKeyResponse CBavpControllerVideo::HandleKeysL( const TKeyEvent& aKeyEvent, |
|
745 TEventCode aType ) |
|
746 { |
|
747 TKeyResponse keyResponse( EKeyWasNotConsumed ); |
|
748 |
|
749 // If we're in full screen mode, and any key is pressed, toggle to normal |
|
750 // screen. Consume all key presses (down, key, up) when in full screen mode. |
|
751 if ( IsClipFullScreen() ) |
|
752 { |
|
753 if ( aType == EEventKeyDown ) |
|
754 { |
|
755 ToggleScreen(); |
|
756 } |
|
757 keyResponse = EKeyWasConsumed; |
|
758 } |
|
759 else |
|
760 { |
|
761 // Use the default HandleKeysL method |
|
762 keyResponse = CBavpController::HandleKeysL( aKeyEvent, aType ); |
|
763 } |
|
764 |
|
765 return keyResponse; |
|
766 } |
|
767 |
|
768 // ----------------------------------------------------------------------------- |
|
769 // CBavpControllerVideo::HandleCommandL |
|
770 // Default implementation, override as needed. |
|
771 // Handles the commands from the Option Menu defined in TBavpCommandIds |
|
772 // ----------------------------------------------------------------------------- |
|
773 void CBavpControllerVideo::HandleCommandL( TBavpCommandIds aCommand ) |
|
774 { |
|
775 Log( EFalse, _L("CBavpControllerVideo::HandleCommandL(): aCommand="), (TInt)aCommand ); |
|
776 |
|
777 switch ( aCommand ) |
|
778 { |
|
779 case EBavpCmdPlayFullScreen: |
|
780 ToggleScreen(); |
|
781 break; |
|
782 |
|
783 default: |
|
784 // Use the default HandleCommandL method |
|
785 CBavpController::HandleCommandL( aCommand ); |
|
786 break; |
|
787 } |
|
788 } |
|
789 |
|
790 // ----------------------------------------------------------------------------- |
|
791 // CBavpControllerVideo::PlayAudioVideoL |
|
792 // Handles request to open and play an audio or video content |
|
793 // ----------------------------------------------------------------------------- |
|
794 void CBavpControllerVideo::PlayAudioVideoL() |
|
795 { |
|
796 Log( EFalse, _L("CBavpControllerVideo::PlayAudioVideoL() ") ); |
|
797 |
|
798 if ( iClipInfo->iMediaType == ELocalRamFile ) |
|
799 { |
|
800 ParseRamFileL(); |
|
801 } |
|
802 #if defined(BRDO_ASX_FILE) |
|
803 else if ( iClipInfo->iMediaType == ELocalAsxFile ) |
|
804 { |
|
805 ParseAsxFileL(); |
|
806 } |
|
807 #endif // BRDO_ASX_FILE |
|
808 // Check for the mediatype and open the file |
|
809 InitVideoPlayerL(); |
|
810 } |
|
811 |
|
812 // ----------------------------------------------------------------------------- |
|
813 // CBavpControllerVideo::Stop |
|
814 // Stops video from playing, if playing. |
|
815 // ----------------------------------------------------------------------------- |
|
816 void CBavpControllerVideo::Stop() |
|
817 { |
|
818 Log( EFalse, _L("CBavpControllerVideo::Stop") ); |
|
819 |
|
820 // If we are fast forwarding or rewind, stop the position updater |
|
821 iPositionUpdater->Cancel(); |
|
822 |
|
823 if ( iVideoPlayer ) |
|
824 { |
|
825 // Stop video and set the state to stop |
|
826 iVideoPlayer->Stop(); |
|
827 iCurrentState = EBavpStopped; |
|
828 |
|
829 iClipInfo->iPosition = 0; |
|
830 TRAP_IGNORE |
|
831 ( |
|
832 iVideoPlayer->SetPositionL( iClipInfo->iPosition ); |
|
833 iVideoPlayer->RefreshFrameL(); |
|
834 ); |
|
835 } |
|
836 |
|
837 // The videoPlayer can play audio-only content, so we need to updateDisplay |
|
838 // to show the audio stop animation |
|
839 if ( !IsClipVideo() ) |
|
840 { |
|
841 iBavpView->UpdateView(); |
|
842 } |
|
843 } |
|
844 |
|
845 // ----------------------------------------------------------------------------- |
|
846 // CBavpControllerVideo::PlayL |
|
847 // Plays video |
|
848 // |
|
849 // NOTE: The MMF throws an error when interrupted by a telephone call, so |
|
850 // iCurrentState=EBavpBadContent and PlayL called after call is done. |
|
851 // ----------------------------------------------------------------------------- |
|
852 void CBavpControllerVideo::PlayL() |
|
853 { |
|
854 Log( EFalse, _L("CBavpControllerVideo::PlayL") ); |
|
855 |
|
856 if ( !iVideoPlayer || !iPlayerInitialized ) |
|
857 { |
|
858 // 1) Live-stream clip that was stopped will close the iVideoPlayer and |
|
859 // need buffering, because Play() will have to be reinitialized with |
|
860 // server. |
|
861 // 2) The initialization of multiple video instances and a single |
|
862 // playback hardware/software (ie Julie H/W) will cause the second plus |
|
863 // instances to return an error. HandleError() will display stop animation, |
|
864 // and if the user selects PlayL(), and the iVideoPlayer needs to be |
|
865 // reinitialized. |
|
866 // |
|
867 // The buffering animation will be stopped, when MvpuoPrepareComplete() |
|
868 // is called. |
|
869 iCurrentState = EBavpBuffering; |
|
870 iBavpView->UpdateView(); |
|
871 Log( EFalse, _L("PlayL - Calling InitVideoPlayerL()") ); |
|
872 |
|
873 // This calls OpenUrlL or OpenFileL, which will call iVideoPlayer->Play |
|
874 InitVideoPlayerL(); |
|
875 return; |
|
876 } |
|
877 |
|
878 if ( iCurrentState == EBavpPaused || |
|
879 iCurrentState == EBavpFastForwarding || |
|
880 iCurrentState == EBavpRewinding ) |
|
881 { |
|
882 // If we are fast forwarding or rewind, pause |
|
883 if ( iPositionUpdater->IsActive() ) |
|
884 { |
|
885 // PauseL stops the PositionUpdater |
|
886 PauseL(); |
|
887 } |
|
888 |
|
889 // We are resuming play and the clip is seekable, get the last |
|
890 // position and adjust the last position, if needed |
|
891 if ( iClipInfo->iPosition >= |
|
892 iClipInfo->iDurationInSeconds.Int64() - KBavpOneSecond ) |
|
893 { |
|
894 // Take back one second if too near end of clip |
|
895 TTimeIntervalMicroSeconds adjustPosition = |
|
896 iClipInfo->iPosition.Int64() - KBavpOneSecond; |
|
897 |
|
898 // Negative value is not allowed, use beginning of clip |
|
899 if ( adjustPosition.Int64() < 0 ) |
|
900 { |
|
901 adjustPosition = 0; |
|
902 } |
|
903 |
|
904 // Use the adjusted position |
|
905 iClipInfo->iPosition = adjustPosition; |
|
906 } |
|
907 } |
|
908 else |
|
909 { |
|
910 // Handle all other states, EBavpStopped, EBavpPlayComplete, |
|
911 // EBavpRewindComplete, EBavpFastForwardComplete, EBavpBadContent |
|
912 iClipInfo->iPosition = 0; |
|
913 } |
|
914 |
|
915 if ( IsClipOnDemand() && iCurrentState == EBavpStopped ) |
|
916 { |
|
917 // On-demand that was stopped will need buffering, |
|
918 // because Play() will have to be reinitialized with server. |
|
919 // The buffering animation is stopped, for on-demand when |
|
920 // MvloLoadingComplete() is called |
|
921 iCurrentState = EBavpBuffering; |
|
922 Log( EFalse, _L("PlayL - Set EBavpBuffering") ); |
|
923 } |
|
924 else |
|
925 { |
|
926 // Set state and update view to stop any animations running |
|
927 iCurrentState = EBavpPlaying; |
|
928 Log( EFalse, _L("PlayL - Set EBavpPlaying") ); |
|
929 } |
|
930 |
|
931 iBavpView->UpdateView(); |
|
932 |
|
933 iVideoPlayer->SetPositionL( iClipInfo->iPosition ); |
|
934 //Fix for "EABU-7ZW9YT" if the pause is initiated for foreground to background and also for plugin invisible and plugin playpause |
|
935 if(iCurrentState == EBavpPaused) |
|
936 iCurrentState = EBavpPlaying; |
|
937 |
|
938 iVideoPlayer->Play(); |
|
939 // ETwelveOClock: Timer tick is on the second - from Symbian |
|
940 if (!iBackLightUpdater->IsActive()) |
|
941 { |
|
942 iBackLightUpdater->Start( ETwelveOClock, this ); |
|
943 } |
|
944 } |
|
945 |
|
946 // ----------------------------------------------------------------------------- |
|
947 // CBavpControllerVideo::PauseL |
|
948 // Pauses video while playing. Saves the last position, if seekable content. |
|
949 // ----------------------------------------------------------------------------- |
|
950 void CBavpControllerVideo::PauseL() |
|
951 { |
|
952 Log( EFalse, _L("CBavpControllerVideo::PauseL") ); |
|
953 |
|
954 // If the position updater is running, stop it |
|
955 iPositionUpdater->Cancel(); |
|
956 |
|
957 if ( iVideoPlayer ) |
|
958 { |
|
959 //disable screensaver |
|
960 iBackLightUpdater->Cancel(); |
|
961 if ( IsClipSeekable() ) |
|
962 { |
|
963 // Seekable content, save position for possible resume |
|
964 iVideoPlayer->PauseL(); |
|
965 iClipInfo->iPosition = iVideoPlayer->PositionL(); |
|
966 iCurrentState = EBavpPaused; |
|
967 } |
|
968 else |
|
969 { |
|
970 // Not seekable content, i.e. Live stream |
|
971 iVideoPlayer->Stop(); |
|
972 iClipInfo->iPosition = 0; |
|
973 iVideoPlayer->SetPositionL( iClipInfo->iPosition ); |
|
974 iCurrentState = EBavpStopped; |
|
975 } |
|
976 } |
|
977 // The videoPlayer can play audio-only content, so we need to updateDisplay |
|
978 // to show the audio paused animation |
|
979 if ( !IsClipVideo() ) |
|
980 { |
|
981 iBavpView->UpdateView(); |
|
982 } |
|
983 } |
|
984 |
|
985 // ----------------------------------------------------------------------------- |
|
986 // CBavpControllerAudio::FastForwardL |
|
987 // Fast forwards the video. This is only called on seekable and local file |
|
988 // content. |
|
989 // ----------------------------------------------------------------------------- |
|
990 void CBavpControllerVideo::FastForwardL() |
|
991 { |
|
992 // Check that the content can be Fast Forwarded, this is used when media key |
|
993 // is pressed. We don't allow the user to select FF from Option Menu, if this |
|
994 // condition is not already meet. |
|
995 if ( !IsClipSeekable() && !IsClipLocalMedia() ) |
|
996 { |
|
997 return; |
|
998 } |
|
999 |
|
1000 // If playing, pause it (PauseL stops the PositionUpdater) |
|
1001 if ( iCurrentState == EBavpPlaying ) |
|
1002 { |
|
1003 PauseL(); |
|
1004 } |
|
1005 |
|
1006 iCurrentState = EBavpFastForwarding; |
|
1007 iPositionUpdater->Start( KInitialDelay, KUpdateFrequency, |
|
1008 TCallBack( &DoFastForwardL, this ) ); |
|
1009 if (!iBackLightUpdater->IsActive()) |
|
1010 { |
|
1011 iBackLightUpdater->Start( ETwelveOClock, this ); |
|
1012 } |
|
1013 } |
|
1014 |
|
1015 // ----------------------------------------------------------------------------- |
|
1016 // CBavpControllerAudio::RewindL |
|
1017 // Rewinds the video. This is only called on seekable and local file |
|
1018 // content. |
|
1019 // ----------------------------------------------------------------------------- |
|
1020 void CBavpControllerVideo::RewindL() |
|
1021 { |
|
1022 // Check that the content can be Rewound, this is used when media key |
|
1023 // is pressed. We don't allow the user to select FF from Option Menu, if this |
|
1024 // condition is not already meet. |
|
1025 if ( !IsClipSeekable() && !IsClipLocalMedia() ) |
|
1026 { |
|
1027 return; |
|
1028 } |
|
1029 |
|
1030 // If playing, pause it (PauseL stops the PositionUpdater) |
|
1031 if ( iCurrentState == EBavpPlaying ) |
|
1032 { |
|
1033 PauseL(); |
|
1034 } |
|
1035 |
|
1036 iCurrentState = EBavpRewinding; |
|
1037 iPositionUpdater->Start( KInitialDelay, KUpdateFrequency, |
|
1038 TCallBack( &DoRewindL, this ) ); |
|
1039 if (!iBackLightUpdater->IsActive()) |
|
1040 { |
|
1041 iBackLightUpdater->Start( ETwelveOClock, this ); |
|
1042 } |
|
1043 |
|
1044 } |
|
1045 // ----------------------------------------------------------------------------- |
|
1046 // CBavpControllerVideo::OpenVideoUrlL |
|
1047 // Handles request to open the url link |
|
1048 // ----------------------------------------------------------------------------- |
|
1049 void CBavpControllerVideo::OpenVideoUrlL() |
|
1050 { |
|
1051 Log( EFalse, _L("CBavpControllerVideo::OpenUrlL() entered") ); |
|
1052 |
|
1053 // Note: Play() is called from MvpuoPrepareComplete() |
|
1054 iVideoPlayer->OpenUrlL( *iClipInfo->iUrl, iAccessPtId, |
|
1055 KNullDesC8, KRopControllerUid ); |
|
1056 } |
|
1057 |
|
1058 // ----------------------------------------------------------------------------- |
|
1059 // CBavpControllerVideo::OpenVideoFileL |
|
1060 // Open a video file |
|
1061 // ----------------------------------------------------------------------------- |
|
1062 void CBavpControllerVideo::OpenVideoFileL() |
|
1063 { |
|
1064 Log( EFalse, _L("CBavpControllerVideo::OpenFileL() ") ); |
|
1065 |
|
1066 // Note: Play() is called from MvpuoPrepareComplete() |
|
1067 iVideoPlayer->OpenFileL( *iClipInfo->iFileName ); |
|
1068 } |
|
1069 |
|
1070 // ----------------------------------------------------------------------------- |
|
1071 // CBavpControllerVideo::SetPlayerVolume |
|
1072 // ----------------------------------------------------------------------------- |
|
1073 void CBavpControllerVideo::SetPlayerVolume( TInt aVolume ) |
|
1074 { |
|
1075 if ( iVideoPlayer && iPlayerInitialized ) |
|
1076 { |
|
1077 // The CR volume is 0-10, convert to Video player volume 0-100 |
|
1078 TInt playerVolume = ( aVolume * iPlayerMaxVolume ) / KCRVolumeMax; |
|
1079 |
|
1080 // Set Video player volume |
|
1081 TRAP_IGNORE( iVideoPlayer->SetVolumeL( playerVolume) ); |
|
1082 } |
|
1083 } |
|
1084 |
|
1085 // ----------------------------------------------------------------------------- |
|
1086 // CBavpControllerVideo::GetPlayerVolume |
|
1087 // ----------------------------------------------------------------------------- |
|
1088 TInt CBavpControllerVideo::GetPlayerVolume() |
|
1089 { |
|
1090 TInt playerVolume( 0 ); |
|
1091 TInt CRVolume( 0 ); |
|
1092 |
|
1093 if ( iVideoPlayer && iPlayerInitialized ) |
|
1094 { |
|
1095 // Video player returns 0-100 |
|
1096 playerVolume = iVideoPlayer->Volume(); |
|
1097 |
|
1098 // Convert to CR volume 0-10 |
|
1099 CRVolume = ( playerVolume * KCRVolumeMax ) / iPlayerMaxVolume; |
|
1100 } |
|
1101 |
|
1102 return CRVolume; |
|
1103 } |
|
1104 |
|
1105 // ----------------------------------------------------------------------------- |
|
1106 // CBavpControllerVideo::MvpuoOpenComplete |
|
1107 // Notification to the client that the opening of the video clip has completed, |
|
1108 // successfully, or otherwise. |
|
1109 // ----------------------------------------------------------------------------- |
|
1110 void CBavpControllerVideo::MvpuoOpenComplete( TInt aError ) |
|
1111 { |
|
1112 Log( EFalse, _L("MvpuoOpenComplete err="), aError ); |
|
1113 |
|
1114 if ( aError != KErrNone ) |
|
1115 { |
|
1116 // Got an error from the MMF callback |
|
1117 HandleError( aError ); |
|
1118 } |
|
1119 else |
|
1120 { |
|
1121 // No error opening player, proceed with preparing player |
|
1122 iVideoPlayer->Prepare(); |
|
1123 } |
|
1124 } |
|
1125 |
|
1126 // ----------------------------------------------------------------------------- |
|
1127 // CBavpControllerVideo::MvpuoPrepareComplete |
|
1128 // Notification to the client that the opening of the video clip has been prepared |
|
1129 // successfully, or otherwise. |
|
1130 // This callback is called in response to a call to CVideoPlayerUtility::Prepare(). |
|
1131 // ----------------------------------------------------------------------------- |
|
1132 void CBavpControllerVideo::MvpuoPrepareComplete( TInt aError ) |
|
1133 { |
|
1134 Log( EFalse, _L("MvpuoPrepareComplete err="), aError ); |
|
1135 |
|
1136 if ( aError != KErrNone ) |
|
1137 { |
|
1138 HandleError( aError ); |
|
1139 } |
|
1140 else |
|
1141 { |
|
1142 // Proceed with initialization and playing content |
|
1143 |
|
1144 // Video player initialized and ready for interaction, |
|
1145 // volume, option menus, etc... |
|
1146 iPlayerInitialized = ETrue; |
|
1147 |
|
1148 // Cleanup clip info |
|
1149 iClipInfo->ReInit(); |
|
1150 |
|
1151 // Handle all of the leaving methods of preparing the clip and |
|
1152 // controller. Reading meta data, max volume, ... |
|
1153 TRAP_IGNORE( PrepareCompleteL() ); |
|
1154 |
|
1155 // Full screen display mode, rotate if necessary |
|
1156 if ( IsClipFullScreen() ) |
|
1157 { |
|
1158 RotateScreen90(); |
|
1159 } |
|
1160 |
|
1161 // Use the iCurrrentVolume, everytime we "set" the volume in the |
|
1162 // BavpController we check for Profile setting, so we can use it here |
|
1163 SetPlayerVolume( iCurrentVolume ); |
|
1164 |
|
1165 // Start to play this media object |
|
1166 iVideoPlayer->Play(); |
|
1167 |
|
1168 // Stop the buffering animation now, to avoid screen flicker |
|
1169 iCurrentState = EBavpPlaying; |
|
1170 iBavpView->UpdateView(); |
|
1171 } |
|
1172 } |
|
1173 |
|
1174 // ----------------------------------------------------------------------------- |
|
1175 // CBavpControllerVideo::MvpuoPlayComplete |
|
1176 // Notification that video playback has completed. This is not called if playback |
|
1177 // is explicitly stopped by calling Stop. |
|
1178 // ----------------------------------------------------------------------------- |
|
1179 void CBavpControllerVideo::MvpuoPlayComplete( TInt aError ) |
|
1180 { |
|
1181 Log( EFalse, _L("MvpuoPlayComplete err="), aError ); |
|
1182 |
|
1183 if ( aError != KErrNone ) |
|
1184 { |
|
1185 // Got an error from the MMF callback |
|
1186 HandleError( aError ); |
|
1187 } |
|
1188 else |
|
1189 { |
|
1190 // No error, proceed with playing complete |
|
1191 iCurrentState = EBavpPlayComplete; |
|
1192 iClipInfo->iPosition = 0; |
|
1193 |
|
1194 // Set the previous call state to complete, this will ensure we |
|
1195 // don't try to replay the content if a call comes in |
|
1196 iPreCallState = EBavpPlayComplete; |
|
1197 |
|
1198 // Revert back to normal screen if it's full screen display |
|
1199 if ( IsClipFullScreen() ) |
|
1200 { |
|
1201 TRAP_IGNORE |
|
1202 ( |
|
1203 RevertToNormalScreenL(); |
|
1204 iBavpView->ControllerStateChangedL(); |
|
1205 ); |
|
1206 } |
|
1207 |
|
1208 iBavpView->UpdateView(); |
|
1209 } |
|
1210 } |
|
1211 |
|
1212 // ----------------------------------------------------------------------------- |
|
1213 // CBavpControllerVideo::MvpuoEvent |
|
1214 // General event notification from controller. These events are specified by the |
|
1215 // supplier of the controller. Take the user initiaiated event, like selecting |
|
1216 // "pause" from the menu item, or another MMF event and convert into a |
|
1217 // "video plugin error", so we can process in HandleError(). |
|
1218 // ----------------------------------------------------------------------------- |
|
1219 void CBavpControllerVideo::MvpuoEvent( const TMMFEvent& aEvent ) |
|
1220 { |
|
1221 Log( EFalse, _L("MvpuoEvent aEvent.iErrorCode="), aEvent.iErrorCode ); |
|
1222 |
|
1223 if ( aEvent.iEventType == KMMFEventCategoryVideoPlayerGeneralError ) |
|
1224 { |
|
1225 HandleError( aEvent.iErrorCode ); |
|
1226 } |
|
1227 } |
|
1228 |
|
1229 // ----------------------------------------------------------------------------- |
|
1230 // CBavpControllerVideo::MvloLoadingComplete |
|
1231 // Notification that video clip loading/rebuffering has started |
|
1232 // ----------------------------------------------------------------------------- |
|
1233 void CBavpControllerVideo::MvloLoadingStarted() |
|
1234 { |
|
1235 Log( EFalse, _L("MvloLoadingStarted") ); |
|
1236 |
|
1237 if ( iCurrentState != EBavpPlaying ) |
|
1238 { |
|
1239 // Start the buffering animation |
|
1240 iCurrentState = EBavpBuffering; |
|
1241 iBavpView->UpdateView(); |
|
1242 } |
|
1243 } |
|
1244 |
|
1245 // ----------------------------------------------------------------------------- |
|
1246 // CBavpControllerVideo::MvloLoadingComplete |
|
1247 // Notification that video clip loading/rebuffering has completed |
|
1248 // and starting to play |
|
1249 // ----------------------------------------------------------------------------- |
|
1250 void CBavpControllerVideo::MvloLoadingComplete() |
|
1251 { |
|
1252 Log( EFalse, _L("MvloLoadingComplete") ); |
|
1253 |
|
1254 if ( !iBackLightUpdater->IsActive() ) |
|
1255 { |
|
1256 iBackLightUpdater->Start( ETwelveOClock, this ); |
|
1257 } |
|
1258 // Stop the buffering animation |
|
1259 iCurrentState = EBavpPlaying; |
|
1260 iBavpView->UpdateView(); |
|
1261 } |
|
1262 |
|
1263 // ----------------------------------------------------------------------------- |
|
1264 // CBavpControllerVideo::getPositionL |
|
1265 // To get the current position of the clip |
|
1266 // ----------------------------------------------------------------------------- |
|
1267 |
|
1268 TTimeIntervalMicroSeconds CBavpControllerVideo::getPositionL() |
|
1269 { |
|
1270 if ( iVideoPlayer ) |
|
1271 { |
|
1272 return iVideoPlayer->PositionL(); |
|
1273 } |
|
1274 return NULL; |
|
1275 } |
|
1276 |
|
1277 // ----------------------------------------------------------------------------- |
|
1278 // CBavpControllerVideo::setPositionL |
|
1279 // To set the position of the clip |
|
1280 // ----------------------------------------------------------------------------- |
|
1281 |
|
1282 void CBavpControllerVideo::setPositionL(TTimeIntervalMicroSeconds val) |
|
1283 { |
|
1284 if ( iVideoPlayer ) |
|
1285 { |
|
1286 if ( !IsClipSeekable() && !IsClipLocalMedia() ) |
|
1287 { |
|
1288 return; |
|
1289 } |
|
1290 |
|
1291 TBool didWePause = EFalse; |
|
1292 // If playing, pause it (PauseL stops the PositionUpdater) |
|
1293 if ( iCurrentState == EBavpPlaying ) |
|
1294 { |
|
1295 PauseL(); |
|
1296 didWePause = ETrue; |
|
1297 } |
|
1298 |
|
1299 if ( (val > iClipInfo->iDurationInSeconds ) || (val < 0) ) |
|
1300 { |
|
1301 val = 0; |
|
1302 } |
|
1303 |
|
1304 iVideoPlayer->SetPositionL(val); |
|
1305 iVideoPlayer->RefreshFrameL(); |
|
1306 iClipInfo->iPosition = val; |
|
1307 if ( didWePause ) |
|
1308 { |
|
1309 PlayL(); |
|
1310 } |
|
1311 } |
|
1312 } |
|
1313 |
|
1314 // ----------------------------------------------------------------------------- |
|
1315 // CBavpControllerVideo::Beat |
|
1316 // Call HandleScreenSaver |
|
1317 // ----------------------------------------------------------------------------- |
|
1318 // |
|
1319 void CBavpControllerVideo::Beat() |
|
1320 { |
|
1321 HandleScreenSaver(); |
|
1322 } |
|
1323 |
|
1324 // ----------------------------------------------------------------------------- |
|
1325 // CBavpControllerVideo::Synchronize |
|
1326 // Call HandleScreenSaver |
|
1327 // ----------------------------------------------------------------------------- |
|
1328 // |
|
1329 void CBavpControllerVideo::Synchronize() |
|
1330 { |
|
1331 HandleScreenSaver(); |
|
1332 } |
|
1333 |
|
1334 // ----------------------------------------------------------------------------- |
|
1335 // CBavpControllerVideo::HandleScreenSaver |
|
1336 // To disable backlight for screensaver if needed |
|
1337 // ----------------------------------------------------------------------------- |
|
1338 // |
|
1339 void CBavpControllerVideo::HandleScreenSaver() |
|
1340 { |
|
1341 Log( EFalse, _L("CBavpControllerVideo::HandleScreenSaver() entered" )); |
|
1342 |
|
1343 //disable screensaver when it's in playing|forwarding|backwarding mode |
|
1344 if ( NoScreenSaverMode() && iVideoPlayer ) |
|
1345 { |
|
1346 User::ResetInactivityTime(); |
|
1347 } |
|
1348 } |
|
1349 |
|
1350 TBool CBavpControllerVideo::NoScreenSaverMode() |
|
1351 { |
|
1352 return (iCurrentState == EBavpPlaying || |
|
1353 iCurrentState == EBavpFastForwarding || |
|
1354 iCurrentState == EBavpRewinding); |
|
1355 } |
|
1356 |
|
1357 |
|
1358 // ----------------------------------------------------------------------------- |
|
1359 // CBavpControllerVideo::SetDefaultAspectRatioL |
|
1360 // Sets default aspect ratio (code is taken from mmplayer) |
|
1361 // ----------------------------------------------------------------------------- |
|
1362 /* |
|
1363 * This function was added for consistency with mmplayer. |
|
1364 * Not used is 5.0 (S60_50) since we want to preserve correct |
|
1365 * aspect ratio and this function will stretch the video to |
|
1366 * the full screen, which due to S60_50 screen size doesn't match |
|
1367 * to correct ratio. |
|
1368 * If needed it should be called in WaitForScreenSwitchL() after |
|
1369 * screen mode changed. |
|
1370 */ |
|
1371 void CBavpControllerVideo::SetDefaultAspectRatioL() |
|
1372 { |
|
1373 TSize frameSize; |
|
1374 TRect rect = iBavpView->CoeControl().Rect(); |
|
1375 |
|
1376 if ( iVideoPlayer ) { |
|
1377 |
|
1378 iVideoPlayer->VideoFrameSizeL( frameSize ); |
|
1379 } |
|
1380 |
|
1381 if ( frameSize.iWidth > 0 && frameSize.iHeight > 0) { |
|
1382 |
|
1383 TMMFScalingType scalingType = EMMFNatural; |
|
1384 |
|
1385 TReal32 videoAspectRatio = (TReal)frameSize.iWidth / |
|
1386 (TReal)frameSize.iHeight; |
|
1387 TReal32 dispAspectRatio = (TReal)rect.Width() / (TReal)rect.Height(); |
|
1388 |
|
1389 // Choose the scaling type through the rule: |
|
1390 // videoAspectRatio - iDisplayAspectRatio > 0.1 ==> zoom |
|
1391 // videoAspectRatio - iDisplayAspectRatio < 0.1 ==> stretch |
|
1392 // videoAspectRatio = iDisplayAspectRatio ==> natural |
|
1393 if ( videoAspectRatio - dispAspectRatio > 0.1 ) { |
|
1394 scalingType = EMMFZoom; |
|
1395 } |
|
1396 else if ( videoAspectRatio != dispAspectRatio ) { |
|
1397 scalingType = EMMFStretch; |
|
1398 } |
|
1399 |
|
1400 TMMFMessageDestinationPckg destinationPckg(KUidInterfaceMMFControllerScalingMsg ); |
|
1401 |
|
1402 TPckgBuf<TInt> scaleTypePckg( scalingType ); |
|
1403 |
|
1404 iVideoPlayer->CustomCommandSync( destinationPckg, |
|
1405 EMMFSetScalingType, |
|
1406 scaleTypePckg, |
|
1407 KNullDesC8 ); |
|
1408 iVideoPlayer->RefreshFrameL(); |
|
1409 |
|
1410 } |
|
1411 } |
|
1412 |
|
1413 void CBavpControllerVideo::HandleInComingCallL() |
|
1414 |
|
1415 { |
|
1416 if ( IsClipFullScreen() ) |
|
1417 { |
|
1418 RevertToNormalScreenL(); |
|
1419 iBavpView->ControllerStateChangedL(); |
|
1420 } |
|
1421 } |
|
1422 |
|
1423 // ----------------------------------------------------------------------------- |
|
1424 // CBavpControllerVideo::HandleGesture |
|
1425 // ----------------------------------------------------------------------------- |
|
1426 TBool CBavpControllerVideo::HandleGesture(TGestureEvent *gesture) |
|
1427 { |
|
1428 TBool ret = EFalse; |
|
1429 TGestureCode gtype = gesture->Code(EAxisBoth); |
|
1430 switch(gtype) |
|
1431 { |
|
1432 case EGestureTap: |
|
1433 { |
|
1434 if (IsClipFullScreen()) |
|
1435 { |
|
1436 ToggleScreen(); |
|
1437 ret = ETrue; |
|
1438 } |
|
1439 break; |
|
1440 } |
|
1441 } |
|
1442 return ret; |
|
1443 } |
|
1444 #ifdef BRDO_VIDEOPLAYER2_ENABLED_FF |
|
1445 // ----------------------------------------------------------------------------- |
|
1446 // CBavpControllerVideo::UpdateWindowSize |
|
1447 // Refreshing the window co-ordinates. |
|
1448 // ----------------------------------------------------------------------------- |
|
1449 /* |
|
1450 * MMF Client API has updated with new methods to control video display |
|
1451 * Windows and video picture positioning to produce a new version of the API, |
|
1452 * CVideoPlayerUtility2. The new API is the preferred way to play video on graphics |
|
1453 * surfaces, and will support new features such as more flexible window positioning. |
|
1454 * Updatewindow has made in separate method so that in future, timer can be |
|
1455 * implemented for redusing the call to update window. |
|
1456 */ |
|
1457 void CBavpControllerVideo::UpdateWindowSize() |
|
1458 { |
|
1459 TRect rect( iBavpView->CoeControl().Rect() ); |
|
1460 TRect wr(iBavpView->WindowRect()); //can have negative coordinates |
|
1461 //if video scrolled out of viewport |
|
1462 CEikonEnv* eikon = CEikonEnv::Static(); |
|
1463 RWsSession& ws = eikon->WsSession(); |
|
1464 CWsScreenDevice* screenDevice = eikon->ScreenDevice(); |
|
1465 // Reset clipRect |
|
1466 TRect clipRect = rect; |
|
1467 clipRect = GetClipRect( rect ); |
|
1468 if( ( iActiveWindow != &iBavpView->WindowInst() ) && ( iActiveWindow != NULL ) ) |
|
1469 { |
|
1470 //Remove the active window and add the new window |
|
1471 iVideoPlayer->RemoveDisplayWindow(iBavpView->WindowInst()); |
|
1472 TRAPD(errAdd, iVideoPlayer->AddDisplayWindowL(ws,*screenDevice,iBavpView->WindowInst(), wr, clipRect)); |
|
1473 TRAP_IGNORE(iVideoPlayer->SetAutoScaleL(iBavpView->WindowInst(), EAutoScaleBestFit)); |
|
1474 if( errAdd == KErrNone ) |
|
1475 iActiveWindow = &iBavpView->WindowInst(); |
|
1476 } |
|
1477 else |
|
1478 { |
|
1479 //window is already active, only needs the window size changed or position change |
|
1480 TRAPD(err1,iVideoPlayer->SetVideoExtentL(iBavpView->WindowInst(),wr)); |
|
1481 TRAPD(err2,iVideoPlayer->SetWindowClipRectL(iBavpView->WindowInst(),clipRect)); |
|
1482 Log( EFalse, _L("SetVideoExtent err1 = %d"), err1 ); |
|
1483 Log( EFalse, _L("SetVideoExtent err2 = %d"), err2 ); |
|
1484 } |
|
1485 } |
|
1486 #endif |
|
1487 // End of File |