|
1 /* |
|
2 * Copyright (c) 2002-2005 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: Video ringing tone player |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "CPhoneVideoPlayer.h" |
|
21 |
|
22 #include "PhoneUI.pan" |
|
23 #include "MPhoneVideoPlayerObserver.h" |
|
24 #include "CPhoneRingingTone.h" |
|
25 #include "PhoneConstants.h" |
|
26 #include "PhoneLogger.h" |
|
27 |
|
28 #include <eikenv.h> // CEikEnv |
|
29 #include <coemain.h> // CCoeEnv |
|
30 #include <VideoPlayer.h> // CVideoPlayerUtility |
|
31 |
|
32 // EXTERNAL DATA STRUCTURES |
|
33 |
|
34 // EXTERNAL FUNCTION PROTOTYPES |
|
35 |
|
36 // CONSTANTS |
|
37 |
|
38 // MACROS |
|
39 |
|
40 // LOCAL CONSTANTS AND MACROS |
|
41 |
|
42 // MODULE DATA STRUCTURES |
|
43 |
|
44 // LOCAL FUNCTION PROTOTYPES |
|
45 |
|
46 // FORWARD DECLARATIONS |
|
47 |
|
48 |
|
49 // ============================ MEMBER FUNCTIONS =============================== |
|
50 |
|
51 // ----------------------------------------------------------------------------- |
|
52 // CPhoneVideoPlayer::CPhoneVideoPlayer |
|
53 // C++ default constructor can NOT contain any code, that |
|
54 // might leave. |
|
55 // ----------------------------------------------------------------------------- |
|
56 // |
|
57 CPhoneVideoPlayer::CPhoneVideoPlayer( |
|
58 MPhoneVideoPlayerObserver& aObserver ) |
|
59 : |
|
60 iObserver( aObserver ), |
|
61 iVideoPlayer( NULL ), |
|
62 iPlayerState( EVideoClosed ), |
|
63 iVolume( 0 ) |
|
64 { |
|
65 } |
|
66 |
|
67 // ----------------------------------------------------------------------------- |
|
68 // CPhoneVideoPlayer::ConstructL |
|
69 // Symbian 2nd phase constructor can leave. |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 void CPhoneVideoPlayer::ConstructL( |
|
73 const TDesC& aFileName, |
|
74 TInt aPriority, |
|
75 TUint aPreference, |
|
76 RWindow& aVideoTarget ) |
|
77 { |
|
78 // Screen and clip rectangles to window dimensions |
|
79 TPoint wndPosition( aVideoTarget.AbsPosition() ); |
|
80 TSize wndSize( aVideoTarget.Size() ); |
|
81 TRect wndRect( wndPosition, wndSize ); |
|
82 |
|
83 // Create video player instance |
|
84 iVideoPlayer = CVideoPlayerUtility::NewL( |
|
85 *this, |
|
86 aPriority, |
|
87 static_cast<TMdaPriorityPreference>( aPreference ), |
|
88 CCoeEnv::Static()->WsSession(), |
|
89 *CCoeEnv::Static()->ScreenDevice(), |
|
90 aVideoTarget, |
|
91 wndRect, |
|
92 wndRect ); |
|
93 |
|
94 RFs fs = CEikonEnv::Static()->FsSession(); |
|
95 User::LeaveIfError( iFileHandle.Open( fs, |
|
96 aFileName, |
|
97 EFileShareReadersOnly | |
|
98 EFileStream | |
|
99 EFileRead ) ); |
|
100 |
|
101 iVideoPlayer->OpenFileL( iFileHandle ); // async |
|
102 |
|
103 iPlayerState = EVideoOpening; |
|
104 } |
|
105 |
|
106 // ----------------------------------------------------------------------------- |
|
107 // CPhoneVideoPlayer::NewL |
|
108 // Two-phased constructor. |
|
109 // ----------------------------------------------------------------------------- |
|
110 // |
|
111 CPhoneVideoPlayer* CPhoneVideoPlayer::NewL( |
|
112 const CPhoneRingingTone& aRingingTone, |
|
113 TInt aPriority, |
|
114 TUint aPreference, |
|
115 MPhoneVideoPlayerObserver& aObserver, |
|
116 RWindow& aVideoTarget, |
|
117 TBool aExtSecNeeded ) |
|
118 { |
|
119 // Check the file DRM property if extend secure is needed. |
|
120 if ( aExtSecNeeded ) |
|
121 { |
|
122 __PHONELOG( EBasic, EPhoneUIView, "CPhoneVideoPlayer::NewL - check DRM extend security" ); |
|
123 if ( !aRingingTone.IsFileInRom() && |
|
124 !aRingingTone.IsFileDrmProtected() ) |
|
125 { |
|
126 __PHONELOG( EBasic, EPhoneUIView, "CPhoneVideoPlayer::NewL - DRM extend security permission denied" ); |
|
127 User::Leave( KErrPermissionDenied ); |
|
128 } |
|
129 __PHONELOG( EBasic, EPhoneUIView, "CPhoneVideoPlayer::NewL - check DRM extend security - ok" ); |
|
130 } |
|
131 |
|
132 CPhoneVideoPlayer* self = new(ELeave) CPhoneVideoPlayer( aObserver ); |
|
133 |
|
134 CleanupStack::PushL( self ); |
|
135 self->ConstructL( |
|
136 aRingingTone.FileName(), |
|
137 aPriority, |
|
138 aPreference, |
|
139 aVideoTarget ); |
|
140 CleanupStack::Pop( self ); |
|
141 |
|
142 return self; |
|
143 } |
|
144 |
|
145 // ----------------------------------------------------------------------------- |
|
146 // CPhoneVideoPlayer::New |
|
147 // Two-phased constructor (non-leaving) |
|
148 // ----------------------------------------------------------------------------- |
|
149 // |
|
150 CPhoneVideoPlayer* CPhoneVideoPlayer::New( |
|
151 const CPhoneRingingTone& aRingingTone, |
|
152 TInt aPriority, |
|
153 TUint aPreference, |
|
154 MPhoneVideoPlayerObserver& aObserver, |
|
155 RWindow& aVideoTarget, |
|
156 TBool aExtSecNeeded ) |
|
157 { |
|
158 CPhoneVideoPlayer* self = NULL; |
|
159 |
|
160 TRAP_IGNORE( self = CPhoneVideoPlayer::NewL( |
|
161 aRingingTone, |
|
162 aPriority, |
|
163 aPreference, |
|
164 aObserver, |
|
165 aVideoTarget, |
|
166 aExtSecNeeded ) ); |
|
167 |
|
168 return self; // this is NULL if NewL leaves |
|
169 } |
|
170 |
|
171 // Destructor |
|
172 CPhoneVideoPlayer::~CPhoneVideoPlayer() |
|
173 { |
|
174 if ( iVolumeRampTimer ) |
|
175 { |
|
176 iVolumeRampTimer->Cancel(); |
|
177 delete iVolumeRampTimer; |
|
178 } |
|
179 |
|
180 if ( iVideoPlayer ) |
|
181 { |
|
182 iVideoPlayer->Close(); |
|
183 delete iVideoPlayer; |
|
184 } |
|
185 |
|
186 iFileHandle.Close(); |
|
187 |
|
188 } |
|
189 |
|
190 // ----------------------------------------------------------------------------- |
|
191 // CPhoneVideoPlayer::Play |
|
192 // (other items were commented in a header). |
|
193 // ----------------------------------------------------------------------------- |
|
194 // |
|
195 void CPhoneVideoPlayer::Play( |
|
196 TRingingType aRingType, |
|
197 TInt aVolume ) |
|
198 { |
|
199 __PHONELOG2( |
|
200 EBasic, |
|
201 EPhoneUIView, |
|
202 "CPhoneVideoPlayer::Play - aRingType(%d), aVolume(%d)", |
|
203 aRingType, |
|
204 aVolume ); |
|
205 |
|
206 __ASSERT_DEBUG( iVideoPlayer, Panic( EPhoneViewGeneralError ) ); |
|
207 |
|
208 iRingingType = aRingType; |
|
209 iVolume = aVolume; |
|
210 |
|
211 switch( iPlayerState ) |
|
212 { |
|
213 case EVideoOpening: |
|
214 case EVideoPreparing: |
|
215 case EVideoOpen: |
|
216 // see MvpuoPrepareComplete() |
|
217 iToBePlayed = ETrue; |
|
218 break; |
|
219 |
|
220 case EVideoReady: |
|
221 iVideoPlayer->Play(); |
|
222 iPlayerState = EVideoPlaying; |
|
223 break; |
|
224 |
|
225 case EVideoPlaying: |
|
226 case EVideoClosed: |
|
227 case EVideoError: |
|
228 default: |
|
229 // NOP |
|
230 break; |
|
231 } |
|
232 |
|
233 return; |
|
234 } |
|
235 |
|
236 // ----------------------------------------------------------------------------- |
|
237 // CPhoneVideoPlayer::StopPlaying |
|
238 // (other items were commented in a header). |
|
239 // ----------------------------------------------------------------------------- |
|
240 // |
|
241 void CPhoneVideoPlayer::StopPlaying() |
|
242 { |
|
243 __PHONELOG( EBasic, EPhoneUIView, "CPhoneVideoPlayer::StopPlaying" ); |
|
244 |
|
245 iToBePlayed = EFalse; |
|
246 |
|
247 if ( iVolumeRampTimer ) |
|
248 { |
|
249 iVolumeRampTimer->Cancel(); |
|
250 } |
|
251 |
|
252 if ( iPlayerState == EVideoPlaying ) |
|
253 { |
|
254 iVideoPlayer->Stop(); |
|
255 iPlayerState = EVideoReady; |
|
256 } |
|
257 } |
|
258 |
|
259 // ----------------------------------------------------------------------------- |
|
260 // CPhoneVideoPlayer::PausePlaying |
|
261 // (other items were commented in a header). |
|
262 // ----------------------------------------------------------------------------- |
|
263 // |
|
264 TInt CPhoneVideoPlayer::PausePlaying() |
|
265 { |
|
266 __LOGMETHODSTARTEND(EPhoneUIView, "CPhoneVideoPlayer::StopPlaying "); |
|
267 TInt err = KErrNone; |
|
268 |
|
269 if ( iPlayerState == EVideoPlaying ) |
|
270 { |
|
271 TRAP( err, iVideoPlayer->PauseL() ); |
|
272 if ( err == KErrNone ) |
|
273 { |
|
274 iPlayerState = EVideoPaused; |
|
275 } |
|
276 } |
|
277 else |
|
278 { |
|
279 err = KErrNotReady; |
|
280 } |
|
281 |
|
282 return err; |
|
283 } |
|
284 |
|
285 // ----------------------------------------------------------------------------- |
|
286 // CPhoneVideoPlayer::ResumePlaying |
|
287 // (other items were commented in a header). |
|
288 // ----------------------------------------------------------------------------- |
|
289 // |
|
290 void CPhoneVideoPlayer::ResumePlaying() |
|
291 { |
|
292 __LOGMETHODSTARTEND(EPhoneUIView, "CPhoneVideoPlayer::ResumePlaying "); |
|
293 |
|
294 if ( iPlayerState == EVideoPaused ) |
|
295 { |
|
296 iVideoPlayer->Play(); |
|
297 iPlayerState = EVideoPlaying; |
|
298 } |
|
299 } |
|
300 |
|
301 // ----------------------------------------------------------------------------- |
|
302 // CPhoneVideoPlayer::MuteAudio |
|
303 // (other items were commented in a header). |
|
304 // ----------------------------------------------------------------------------- |
|
305 // |
|
306 void CPhoneVideoPlayer::MuteAudio() |
|
307 { |
|
308 __PHONELOG( EBasic, EPhoneUIView, "CPhoneVideoPlayer::MuteAudio" ); |
|
309 |
|
310 if ( iVolumeRampTimer ) |
|
311 { |
|
312 iVolumeRampTimer->Cancel(); |
|
313 } |
|
314 |
|
315 iVolume = 0; |
|
316 SetVolume( 0 ); |
|
317 } |
|
318 |
|
319 // ----------------------------------------------------------------------------- |
|
320 // CPhoneVideoPlayer::SetVolume |
|
321 // (other items were commented in a header). |
|
322 // ----------------------------------------------------------------------------- |
|
323 // |
|
324 void CPhoneVideoPlayer::SetVolume( TInt aVolume ) |
|
325 { |
|
326 __PHONELOG1( |
|
327 EBasic, |
|
328 EPhoneUIView, |
|
329 "CPhoneVideoPlayer::SetVolume - aVolume(%d)", |
|
330 aVolume ); |
|
331 |
|
332 TInt maxVolume( iVideoPlayer->MaxVolume() ); |
|
333 maxVolume = ( maxVolume > 0 ) ? maxVolume : KPhoneVideoMaxVolumeLevel; |
|
334 |
|
335 TInt scaledVolume = ( aVolume * maxVolume ) / KPhoneVideoMaxVolumeLevel; |
|
336 |
|
337 TRAP_IGNORE( iVideoPlayer->SetVolumeL( scaledVolume ) ); |
|
338 } |
|
339 |
|
340 // ----------------------------------------------------------------------------- |
|
341 // CPhoneVideoPlayer::SetRingingType |
|
342 // (other items were commented in a header). |
|
343 // ----------------------------------------------------------------------------- |
|
344 // |
|
345 void CPhoneVideoPlayer::SetRingingType( TRingingType aRingingType ) |
|
346 { |
|
347 __PHONELOG1( |
|
348 EBasic, |
|
349 EPhoneUIView, |
|
350 "CPhoneVideoPlayer::SetRingingType - aRingingType(%d)", |
|
351 aRingingType ); |
|
352 |
|
353 if ( aRingingType == ETypeAscending ) |
|
354 { |
|
355 if ( !iVolumeRampTimer ) |
|
356 { |
|
357 iVolumeRampTimer = CPeriodic::New( CActive::EPriorityStandard ); |
|
358 } |
|
359 |
|
360 if ( iVolumeRampTimer && !iVolumeRampTimer->IsActive() ) |
|
361 { |
|
362 TCallBack cb( VolumeRampTimerCallback, this ); |
|
363 |
|
364 SetVolume( KPhoneVideoMinVolumeLevel ); |
|
365 iRampedVolume = KPhoneVideoMinVolumeLevel; |
|
366 iVolumeRampTimer->Start( |
|
367 KPhoneVideoVolumeRampInterval, |
|
368 KPhoneVideoVolumeRampInterval, |
|
369 cb ); |
|
370 } |
|
371 } |
|
372 } |
|
373 |
|
374 // ----------------------------------------------------------------------------- |
|
375 // CPhoneVideoPlayer::VolumeRampTimerCallback |
|
376 // (other items were commented in a header). |
|
377 // ----------------------------------------------------------------------------- |
|
378 // |
|
379 TInt CPhoneVideoPlayer::VolumeRampTimerCallback( TAny* aObj ) |
|
380 { |
|
381 return static_cast<CPhoneVideoPlayer*>( aObj )->DoVolumeRamp(); |
|
382 } |
|
383 |
|
384 // ----------------------------------------------------------------------------- |
|
385 // CPhoneVideoPlayer::DoVolumeRamp |
|
386 // (other items were commented in a header). |
|
387 // ----------------------------------------------------------------------------- |
|
388 // |
|
389 TInt CPhoneVideoPlayer::DoVolumeRamp() |
|
390 { |
|
391 if ( iRampedVolume < iVolume ) |
|
392 { |
|
393 iRampedVolume = iRampedVolume + KPhoneVideoVolumeRampStep; |
|
394 if ( iRampedVolume >= iVolume ) |
|
395 { |
|
396 // target volume level reached |
|
397 iRampedVolume = iVolume; |
|
398 iVolumeRampTimer->Cancel(); |
|
399 } |
|
400 |
|
401 SetVolume( iRampedVolume ); |
|
402 } |
|
403 |
|
404 return KErrNone; |
|
405 } |
|
406 |
|
407 // ----------------------------------------------------------------------------- |
|
408 // CPhoneVideoPlayer::State |
|
409 // (other items were commented in a header). |
|
410 // ----------------------------------------------------------------------------- |
|
411 // |
|
412 CPhoneVideoPlayer::TVideoPlayerState CPhoneVideoPlayer::State() const |
|
413 { |
|
414 return iPlayerState; |
|
415 } |
|
416 |
|
417 // ----------------------------------------------------------------------------- |
|
418 // CPhoneVideoPlayer::VideoResolution |
|
419 // (other items were commented in a header). |
|
420 // ----------------------------------------------------------------------------- |
|
421 // |
|
422 CPhoneVideoPlayer::TVideoResolution CPhoneVideoPlayer::VideoResolution() const |
|
423 { |
|
424 TSize frameSize( VideoFrameSize() ); |
|
425 |
|
426 // SubQCCIF video resolution is 128x96 pixels |
|
427 if ( frameSize.iWidth == KPhoneVideoSubQCCIFWidth && |
|
428 frameSize.iHeight == KPhoneVideoSubQCCIFHeight ) |
|
429 { |
|
430 return EVideoSubQCIF; |
|
431 } |
|
432 |
|
433 return EVideoQCIF; |
|
434 } |
|
435 |
|
436 // ----------------------------------------------------------------------------- |
|
437 // CPhoneVideoPlayer::VideoResolution |
|
438 // (other items were commented in a header). |
|
439 // ----------------------------------------------------------------------------- |
|
440 // |
|
441 TSize CPhoneVideoPlayer::VideoFrameSize() const |
|
442 { |
|
443 TSize frameSize( 0,0 ); |
|
444 |
|
445 TRAPD( err, iVideoPlayer->VideoFrameSizeL( frameSize ) ); |
|
446 |
|
447 if ( err != KErrNone ) |
|
448 { |
|
449 return TSize(0,0); |
|
450 } |
|
451 |
|
452 return frameSize; |
|
453 } |
|
454 |
|
455 // ----------------------------------------------------------------------------- |
|
456 // CPhoneVideoPlayer::AdjustToWindow |
|
457 // (other items were commented in a header). |
|
458 // ----------------------------------------------------------------------------- |
|
459 // |
|
460 void CPhoneVideoPlayer::AdjustToWindow( RWindow& aDisplayWindow, |
|
461 const TRect& aUncropPane ) |
|
462 { |
|
463 __ASSERT_DEBUG( iPlayerState == EVideoReady, Panic( EPhoneViewGeneralError ) ); |
|
464 |
|
465 // Get video frame dimensions |
|
466 TSize frameSize( VideoFrameSize() ); |
|
467 |
|
468 if ( frameSize.iWidth == 0 || frameSize.iHeight == 0 ) |
|
469 { |
|
470 return; |
|
471 } |
|
472 |
|
473 // Uncrop pane dimensions |
|
474 TSize uncropPaneSize( aUncropPane.Size() ); |
|
475 |
|
476 // To cover display window: |
|
477 // The video is scaled to match to dimensions of uncrop pane defined |
|
478 // in Call Handling LAF. Video is centered to uncrop pane if exact |
|
479 // match is not possible. |
|
480 // Assumption is that video can be scaled to 50,150 or 200 |
|
481 // percent from its original size (can't be scaled freely). |
|
482 |
|
483 ///////////////////////////// |
|
484 // Calculate scaling factor |
|
485 ///////////////////////////// |
|
486 TInt dScaleFactor( KBaseScaleFactor ); // use integer arithmetic |
|
487 |
|
488 TInt xDelta( uncropPaneSize.iWidth - frameSize.iWidth ); |
|
489 TInt yDelta( uncropPaneSize.iHeight - frameSize.iHeight ); |
|
490 |
|
491 if ( xDelta == 0 && yDelta == 0 ) |
|
492 { |
|
493 // correct size, scaling not needed |
|
494 } |
|
495 else if ( xDelta < 0 && yDelta == 0 ) |
|
496 { |
|
497 // wide, but cannot downscale -> just crop |
|
498 } |
|
499 else if ( yDelta < 0 && xDelta == 0 ) |
|
500 { |
|
501 // tall, but cannot downscale -> just crop |
|
502 } |
|
503 else if ( xDelta > 0 && yDelta > 0 ) |
|
504 { |
|
505 // small, narrow and flat -> enlarge |
|
506 TInt xProp( ( KBaseScaleFactor * uncropPaneSize.iWidth ) / frameSize.iWidth ); |
|
507 TInt yProp( ( KBaseScaleFactor * uncropPaneSize.iHeight ) / frameSize.iHeight ); |
|
508 |
|
509 dScaleFactor = xProp > yProp ? xProp : yProp; |
|
510 } |
|
511 else if ( xDelta < 0 && yDelta < 0 ) |
|
512 { |
|
513 // large, wide and tall -> downscale |
|
514 TInt xProp( ( KBaseScaleFactor * uncropPaneSize.iWidth ) / frameSize.iWidth ); |
|
515 TInt yProp( ( KBaseScaleFactor * uncropPaneSize.iHeight ) / frameSize.iHeight ); |
|
516 |
|
517 dScaleFactor = xProp > yProp ? xProp : yProp; |
|
518 } |
|
519 else if ( xDelta > 0 && yDelta <= 0 ) |
|
520 { |
|
521 // narrow -> enlarge |
|
522 dScaleFactor = ( KBaseScaleFactor * uncropPaneSize.iWidth ) / frameSize.iWidth; |
|
523 } |
|
524 else if ( yDelta > 0 && xDelta <= 0 ) |
|
525 { |
|
526 // flat -> enlarge |
|
527 dScaleFactor = ( KBaseScaleFactor * uncropPaneSize.iHeight ) / frameSize.iHeight; |
|
528 } |
|
529 else |
|
530 { |
|
531 // do nothing |
|
532 } |
|
533 |
|
534 // Convert to float: 0.5, 1.5, 2.0 .. |
|
535 TInt scaleFactor( dScaleFactor / KBaseScaleFactor ); |
|
536 TInt remainder( dScaleFactor % KBaseScaleFactor ); |
|
537 TReal32 fScaleFactor = (TReal) scaleFactor ; |
|
538 |
|
539 if ( scaleFactor > 0 ) // upscale |
|
540 { |
|
541 if ( remainder > KHalfBaseScale ) |
|
542 { |
|
543 fScaleFactor = fScaleFactor + KFullScaleFactor; |
|
544 } |
|
545 else if ( remainder > 0 ) |
|
546 { |
|
547 fScaleFactor = fScaleFactor + KHalfScaleFactor; |
|
548 } |
|
549 else // 0 |
|
550 { |
|
551 } |
|
552 } |
|
553 else // downscale |
|
554 { |
|
555 if ( remainder > KHalfBaseScale ) |
|
556 { |
|
557 fScaleFactor = KFullScaleFactor; |
|
558 } |
|
559 else |
|
560 { |
|
561 fScaleFactor = KHalfScaleFactor; |
|
562 } |
|
563 } |
|
564 |
|
565 //////////////////////////////////////////////// |
|
566 // Calculate scaled frame size (virtual canvas) |
|
567 //////////////////////////////////////////////// |
|
568 TReal32 canvasWidth = fScaleFactor * (TReal32)frameSize.iWidth; |
|
569 TReal32 canvasHeight = fScaleFactor * (TReal32)frameSize.iHeight; |
|
570 TSize canvasSize( (TInt)canvasWidth, (TInt)canvasHeight ); |
|
571 |
|
572 //////////////////////////////////////////////// |
|
573 // Crop by centering displayRect to canvasRect |
|
574 //////////////////////////////////////////////// |
|
575 TRect canvasRect( aUncropPane.iTl, canvasSize ); |
|
576 TInt offsetX = (uncropPaneSize.iWidth - canvasSize.iWidth) / KCentering; |
|
577 TInt offsetY = (uncropPaneSize.iHeight - canvasSize.iHeight) / KCentering; |
|
578 canvasRect.Move( offsetX, offsetY ); |
|
579 |
|
580 // Video is autoscaled by video player |
|
581 // iVideoPlayer->SetScaleFactorL(...); |
|
582 |
|
583 TRect clipRect( aDisplayWindow.AbsPosition(), aDisplayWindow.Size() ); |
|
584 |
|
585 //////////////////////////////////////////////// |
|
586 // Update settings to player |
|
587 //////////////////////////////////////////////// |
|
588 TRAP_IGNORE( |
|
589 iVideoPlayer->SetDisplayWindowL( |
|
590 CCoeEnv::Static()->WsSession(), |
|
591 *CCoeEnv::Static()->ScreenDevice(), |
|
592 aDisplayWindow, |
|
593 canvasRect, |
|
594 clipRect ) ); |
|
595 |
|
596 } |
|
597 |
|
598 |
|
599 // ========================================================= |
|
600 // Callbacks from VideoPlayerutility |
|
601 // ========================================================= |
|
602 |
|
603 // --------------------------------------------------------- |
|
604 // see MVideoPlayerUtilityObserver::MvpuoOpenComplete |
|
605 // --------------------------------------------------------- |
|
606 void CPhoneVideoPlayer::MvpuoOpenComplete( TInt aError ) |
|
607 { |
|
608 __PHONELOG1( |
|
609 EBasic, |
|
610 EPhoneUIView, |
|
611 "CPhoneVideoPlayer::MvpuoOpenComplete - aError(%d)", |
|
612 aError ); |
|
613 |
|
614 if ( aError == KErrNone ) |
|
615 { |
|
616 // Prepare clip for playing |
|
617 iPlayerState = EVideoPreparing; |
|
618 iVideoPlayer->Prepare(); |
|
619 } |
|
620 else // Report error |
|
621 { |
|
622 iPlayerState = EVideoError; |
|
623 iObserver.HandleVideoPlayerError( |
|
624 MPhoneVideoPlayerObserver::EVideoPlayerInitializingFailure, |
|
625 aError ); |
|
626 } |
|
627 } |
|
628 |
|
629 // --------------------------------------------------------- |
|
630 // see MVideoPlayerUtilityObserver::MvpuoPrepareComplete |
|
631 // --------------------------------------------------------- |
|
632 void CPhoneVideoPlayer::MvpuoPrepareComplete( TInt aError ) |
|
633 { |
|
634 __PHONELOG1( |
|
635 EBasic, |
|
636 EPhoneUIView, |
|
637 "CPhoneVideoPlayer::MvpuoPrepareComplete - aError(%d)", |
|
638 aError ); |
|
639 |
|
640 if ( aError == KErrNone ) |
|
641 { |
|
642 iPlayerState = EVideoReady; |
|
643 iObserver.HandleVideoPlayerInitComplete(); |
|
644 |
|
645 SetVolume( iVolume ); |
|
646 SetRingingType( iRingingType ); |
|
647 |
|
648 if ( iToBePlayed ) |
|
649 { |
|
650 iVideoPlayer->Play(); |
|
651 } |
|
652 } |
|
653 else // Report error |
|
654 { |
|
655 iPlayerState = EVideoError; |
|
656 iObserver.HandleVideoPlayerError( |
|
657 MPhoneVideoPlayerObserver::EVideoPlayerInitializingFailure, |
|
658 aError ); |
|
659 } |
|
660 } |
|
661 |
|
662 // --------------------------------------------------------- |
|
663 // see MVideoPlayerUtilityObserver::MvpuoFrameReady |
|
664 // --------------------------------------------------------- |
|
665 void CPhoneVideoPlayer::MvpuoFrameReady( CFbsBitmap& /*aFrame*/, |
|
666 TInt /*aError*/ ) |
|
667 { |
|
668 // NOP |
|
669 } |
|
670 |
|
671 // --------------------------------------------------------- |
|
672 // see MVideoPlayerUtilityObserver::MvpuoPlayComplete |
|
673 // Trapping callback as leaving not allowed. |
|
674 // --------------------------------------------------------- |
|
675 void CPhoneVideoPlayer::MvpuoPlayComplete( TInt aError ) |
|
676 { |
|
677 __PHONELOG1( |
|
678 EBasic, |
|
679 EPhoneUIView, |
|
680 "CPhoneVideoPlayer::MvpuoPlayComplete - aError(%d)", |
|
681 aError ); |
|
682 |
|
683 if ( aError == KErrNone ) |
|
684 { |
|
685 iPlayerState = EVideoReady; |
|
686 |
|
687 if ( iRingingType == ETypeRingingOnce ) |
|
688 { |
|
689 iObserver.HandleVideoPlayerPlayingComplete(); |
|
690 } |
|
691 else // continue playing |
|
692 { |
|
693 iVideoPlayer->Play(); |
|
694 iPlayerState = EVideoPlaying; |
|
695 } |
|
696 } |
|
697 else // report error |
|
698 { |
|
699 iPlayerState = EVideoError; |
|
700 iObserver.HandleVideoPlayerError( |
|
701 MPhoneVideoPlayerObserver::EVideoPlayerPlayingFailure, |
|
702 aError ); |
|
703 } |
|
704 } |
|
705 |
|
706 // --------------------------------------------------------- |
|
707 // see MVideoPlayerUtilityObserver::MvpuoEvent |
|
708 // Trapping callback as leaving not allowed. |
|
709 // --------------------------------------------------------- |
|
710 void CPhoneVideoPlayer::MvpuoEvent( const TMMFEvent& /*aEvent*/ ) |
|
711 { |
|
712 // NOP |
|
713 } |
|
714 |
|
715 // End of File |