|
1 /* |
|
2 * Copyright (c) 2002-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 "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 * SMIL Player media renderer for playing video files |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include "SmilVideoRenderer.h" |
|
23 |
|
24 #include <AknUtils.h> |
|
25 #include <aknlayout.cdl.h> |
|
26 #include <applayout.cdl.h> // LAF |
|
27 #include <aknlayoutscalable_apps.cdl.h> |
|
28 #include <aknlayoutscalable_avkon.cdl.h> |
|
29 #include <AknStatuspaneUtils.h> |
|
30 #include <mmf/common/mmcaf.h> |
|
31 #include <mmferrors.h> |
|
32 #include <AudioPreference.h> |
|
33 |
|
34 #include <smilpresentation.h> |
|
35 |
|
36 #ifdef VIDEO_DEBUG |
|
37 #include "SmilMediaLogging.h" |
|
38 #endif |
|
39 |
|
40 // EXTERNAL DATA STRUCTURES |
|
41 |
|
42 // EXTERNAL FUNCTION PROTOTYPES |
|
43 |
|
44 // CONSTANTS |
|
45 const TInt KProcessingDelayOffset = 1 * 1000 * 1000; // 1s |
|
46 |
|
47 // MACROS |
|
48 |
|
49 // LOCAL CONSTANTS AND MACROS |
|
50 |
|
51 // MODULE DATA STRUCTURES |
|
52 |
|
53 // LOCAL FUNCTION PROTOTYPES |
|
54 |
|
55 // FORWARD DECLARATIONS |
|
56 |
|
57 // ============================= LOCAL FUNCTIONS =============================== |
|
58 |
|
59 // ============================ MEMBER FUNCTIONS =============================== |
|
60 |
|
61 // ---------------------------------------------------------------------------- |
|
62 // CSmilVideoRenderer::CSmilVideoRenderer |
|
63 // ---------------------------------------------------------------------------- |
|
64 // |
|
65 CSmilVideoRenderer::CSmilVideoRenderer( MSmilMedia* aMedia, |
|
66 DRMCommon& aDrmCommon, |
|
67 CDRMHelper& aDrmHelper ) : |
|
68 CSmilMediaRendererBase( EMsgMediaVideo, aMedia, aDrmCommon, aDrmHelper ), |
|
69 iState( ENotReady ), |
|
70 iError( KErrNone ), |
|
71 iStartTime( TInt64( 0 ) ), |
|
72 iParent( aMedia->Presentation()->GetPlayer()->GetControl( aMedia->Presentation() ) ) |
|
73 { |
|
74 } |
|
75 |
|
76 // ---------------------------------------------------------------------------- |
|
77 // CSmilVideoRenderer::ConstructL |
|
78 // ---------------------------------------------------------------------------- |
|
79 // |
|
80 void CSmilVideoRenderer::ConstructL( RFile& aFileHandle ) |
|
81 { |
|
82 #ifdef VIDEO_DEBUG |
|
83 SMILUILOGGER_ENTERFN( "Video, ConstructL" ); |
|
84 #endif |
|
85 |
|
86 BaseConstructL( aFileHandle ); |
|
87 User::LeaveIfError( CheckDRMRights() ); |
|
88 |
|
89 User::LeaveIfError( iMediaFile.Duplicate( aFileHandle ) ); |
|
90 |
|
91 CreateWindowL( iParent ); |
|
92 Window().SetBackgroundColor( KRgbBlack ); |
|
93 Window().SetNonFading( ETrue ); |
|
94 |
|
95 SetRect( ControlRect() ); |
|
96 |
|
97 #ifdef VIDEO_DEBUG |
|
98 SMILUILOGGER_WRITEF( _L("SMILUI: Video, control rect: ( %d, %d) ( %d, %d)"), |
|
99 Rect().iTl.iX, Rect().iTl.iY, Rect().iBr.iX, Rect().iBr.iY ); |
|
100 |
|
101 TPoint winPos = Window().Position(); |
|
102 SMILUILOGGER_WRITEF( _L("SMILUI: Video, window position: ( %d, %d)"), |
|
103 winPos.iX, winPos.iY ); |
|
104 #endif |
|
105 |
|
106 //Lets set the video mode according to the platform |
|
107 LoadVideoL(); |
|
108 |
|
109 TInt volume( iMedia->Presentation()->Volume() ); |
|
110 TRAP_IGNORE( DoSetVolumeL( volume ) ); |
|
111 |
|
112 MakeVisible( EFalse ); |
|
113 ActivateL(); |
|
114 |
|
115 #ifdef VIDEO_DEBUG |
|
116 SMILUILOGGER_LEAVEFN( "Video: ConstructL" ); |
|
117 SMILUILOGGER_WRITEF( _L("")); |
|
118 #endif |
|
119 } |
|
120 |
|
121 // ---------------------------------------------------------------------------- |
|
122 // CSmilVideoRenderer::NewL |
|
123 // ---------------------------------------------------------------------------- |
|
124 // |
|
125 CSmilVideoRenderer* CSmilVideoRenderer::NewL( RFile& aFileHandle, |
|
126 MSmilMedia* aMedia, |
|
127 DRMCommon& aDrmCommon, |
|
128 CDRMHelper& aDrmHelper ) |
|
129 { |
|
130 CSmilVideoRenderer* renderer = new(ELeave) CSmilVideoRenderer( aMedia, |
|
131 aDrmCommon, |
|
132 aDrmHelper ); |
|
133 CleanupStack::PushL( renderer ); |
|
134 renderer->ConstructL( aFileHandle ); |
|
135 CleanupStack::Pop( renderer ); |
|
136 return renderer; |
|
137 } |
|
138 |
|
139 // ---------------------------------------------------------------------------- |
|
140 // CSmilVideoRenderer::~CSmilVideoRenderer |
|
141 // ---------------------------------------------------------------------------- |
|
142 // |
|
143 CSmilVideoRenderer::~CSmilVideoRenderer() |
|
144 { |
|
145 #ifdef VIDEO_DEBUG |
|
146 SMILUILOGGER_ENTERFN( "Video, ~CSmilVideoRenderer" ); |
|
147 #endif |
|
148 |
|
149 if ( iVideoPlayer ) |
|
150 { |
|
151 #ifdef VIDEO_DEBUG |
|
152 SMILUILOGGER_WRITE( "Video: iVideoPlayer->Close()" ); |
|
153 #endif |
|
154 iVideoPlayer->Close(); |
|
155 delete iVideoPlayer; |
|
156 } |
|
157 |
|
158 iMediaFile.Close(); |
|
159 iMedia = NULL; // For LINT |
|
160 |
|
161 #ifdef VIDEO_DEBUG |
|
162 SMILUILOGGER_LEAVEFN( "Video: ~CSmilVideoRenderer" ); |
|
163 SMILUILOGGER_WRITEF( _L("")); |
|
164 #endif |
|
165 } |
|
166 |
|
167 // ---------------------------------------------------------------------------- |
|
168 // CSmilVideoRenderer::LoadVideoL |
|
169 // ---------------------------------------------------------------------------- |
|
170 // |
|
171 void CSmilVideoRenderer::LoadVideoL() |
|
172 { |
|
173 #ifdef VIDEO_DEBUG |
|
174 SMILUILOGGER_ENTERFN( "Video: LoadVideoL" ); |
|
175 SMILUILOGGER_WRITEF( _L("SMILUI: Video, State = %d"), iState ); |
|
176 #endif |
|
177 |
|
178 // Clipping rect and rect are always relative to screen coordinates!! |
|
179 TRect rect( VideoRect() ); |
|
180 TRect clipRect( rect ); |
|
181 |
|
182 #ifdef VIDEO_DEBUG |
|
183 SMILUILOGGER_WRITEF( _L("Video: LoadVideo rect before adjusting: (%d, %d) (%d, %d)"), |
|
184 rect.iTl.iX, rect.iTl.iY, rect.iBr.iX, rect.iBr.iY ); |
|
185 #endif |
|
186 |
|
187 AdjustRects( rect, clipRect ); |
|
188 |
|
189 if ( !iVideoPlayer ) |
|
190 { |
|
191 #ifdef VIDEO_DEBUG |
|
192 SMILUILOGGER_WRITEF( _L("SMILUI: Video, rect: ( %d, %d) ( %d, %d), clipRect: ( %d, %d) ( %d, %d)"), |
|
193 rect.iTl.iX, rect.iTl.iY, rect.iBr.iX, rect.iBr.iY, |
|
194 clipRect.iTl.iX, clipRect.iTl.iY, clipRect.iBr.iX, clipRect.iBr.iY ); |
|
195 #endif |
|
196 |
|
197 // Create VideoPlayerUtility instance |
|
198 iVideoPlayer = CVideoPlayerUtility::NewL( *this, |
|
199 TMdaPriority( KAudioPrioritySmilPlayer ), |
|
200 TMdaPriorityPreference( KAudioPrefSmilPlayer ), |
|
201 ControlEnv()->WsSession(), |
|
202 *ControlEnv()->ScreenDevice(), |
|
203 Window(), |
|
204 rect, |
|
205 clipRect ); |
|
206 |
|
207 iCurrentClipRect = clipRect; |
|
208 |
|
209 // Register for Loading/rebuffering notices |
|
210 iVideoPlayer->RegisterForVideoLoadingNotification( *this ); |
|
211 } |
|
212 else |
|
213 { |
|
214 #ifdef VIDEO_DEBUG |
|
215 SMILUILOGGER_WRITE( "Video: iVideoPlayer->Close()" ); |
|
216 #endif |
|
217 iVideoPlayer->Close(); |
|
218 |
|
219 if ( clipRect != iCurrentClipRect ) |
|
220 { |
|
221 iVideoPlayer->SetDisplayWindowL( ControlEnv()->WsSession(), |
|
222 *ControlEnv()->ScreenDevice(), |
|
223 Window(), |
|
224 rect, |
|
225 clipRect ); |
|
226 iCurrentClipRect = clipRect; |
|
227 } |
|
228 } |
|
229 |
|
230 #ifdef VIDEO_DEBUG |
|
231 SMILUILOGGER_WRITE( "Video: iVideoPlayer->OpenFileL()" ); |
|
232 #endif |
|
233 |
|
234 TMMFileHandleSource fileHandleSource( iMediaFile, KDefaultContentObject, ContentAccess::EPeek ); |
|
235 iVideoPlayer->OpenFileL( fileHandleSource ); |
|
236 |
|
237 BeginActiveWait(); |
|
238 |
|
239 MMMFDRMCustomCommand* customCommand = iVideoPlayer->GetDRMCustomCommand(); |
|
240 if ( customCommand ) |
|
241 { |
|
242 customCommand->DisableAutomaticIntent( ETrue ); |
|
243 } |
|
244 |
|
245 #ifdef VIDEO_DEBUG |
|
246 SMILUILOGGER_WRITEF( _L("SMILUI: Video, iError = %d"), iError ); |
|
247 #endif |
|
248 |
|
249 if ( iError != KErrNone ) |
|
250 { |
|
251 User::Leave( iError ); |
|
252 } |
|
253 |
|
254 #ifdef VIDEO_DEBUG |
|
255 SMILUILOGGER_WRITEF( _L("SMILUI: Video, State = %d"), iState ); |
|
256 SMILUILOGGER_LEAVEFN( "Video: LoadVideoL" ); |
|
257 #endif |
|
258 } |
|
259 |
|
260 // ---------------------------------------------------------------------------- |
|
261 // CSmilVideoRenderer::DoSetVolumeL |
|
262 // ---------------------------------------------------------------------------- |
|
263 // |
|
264 void CSmilVideoRenderer::DoSetVolumeL( TInt aVolume ) |
|
265 { |
|
266 #ifdef VIDEO_DEBUG |
|
267 SMILUILOGGER_ENTERFN( "Video: DoSetVolumeL" ); |
|
268 SMILUILOGGER_WRITEF( _L("SMILUI: Video, aVolume = %d"), aVolume ); |
|
269 #endif |
|
270 |
|
271 if ( iVideoPlayer->AudioEnabledL() ) |
|
272 { |
|
273 #ifdef VIDEO_DEBUG |
|
274 SMILUILOGGER_WRITE( "Video: iVideoPlayer->SetVolumeL()" ); |
|
275 #endif |
|
276 iVideoPlayer->SetVolumeL( iVideoPlayer->MaxVolume() * aVolume / 100 ); |
|
277 } |
|
278 |
|
279 #ifdef VIDEO_DEBUG |
|
280 SMILUILOGGER_LEAVEFN( "Video: DoSetVolumeL" ); |
|
281 SMILUILOGGER_WRITEF( _L("")); |
|
282 #endif |
|
283 |
|
284 } |
|
285 |
|
286 // ---------------------------------------------------------------------------- |
|
287 // CSmilVideoRenderer::IsVisual |
|
288 // ---------------------------------------------------------------------------- |
|
289 // |
|
290 TBool CSmilVideoRenderer::IsVisual() const |
|
291 { |
|
292 return ETrue; |
|
293 } |
|
294 |
|
295 // ---------------------------------------------------------------------------- |
|
296 // CSmilVideoRenderer::IsOpaque |
|
297 // ---------------------------------------------------------------------------- |
|
298 // |
|
299 TBool CSmilVideoRenderer::IsOpaque() const |
|
300 { |
|
301 return ETrue; |
|
302 } |
|
303 |
|
304 // ---------------------------------------------------------------------------- |
|
305 // CSmilVideoRenderer::IntrinsicWidth |
|
306 // ---------------------------------------------------------------------------- |
|
307 // |
|
308 TInt CSmilVideoRenderer::IntrinsicWidth() const |
|
309 { |
|
310 #ifdef VIDEO_DEBUG |
|
311 SMILUILOGGER_WRITEF( _L("SMILUI: Video, IntrinsicWidth = %d"), |
|
312 iMedia->GetRectangle().Width() ); |
|
313 SMILUILOGGER_WRITEF( _L("")); |
|
314 #endif |
|
315 return iMedia->GetRectangle().Width(); |
|
316 } |
|
317 |
|
318 // ---------------------------------------------------------------------------- |
|
319 // CSmilVideoRenderer::IntrinsicHeight |
|
320 // ---------------------------------------------------------------------------- |
|
321 // |
|
322 TInt CSmilVideoRenderer::IntrinsicHeight() const |
|
323 { |
|
324 #ifdef VIDEO_DEBUG |
|
325 SMILUILOGGER_WRITEF( _L("SMILUI: Video, IntrinsicHeight = %d"), |
|
326 iMedia->GetRectangle().Height() ); |
|
327 SMILUILOGGER_WRITEF( _L("")); |
|
328 #endif |
|
329 return iMedia->GetRectangle().Height(); |
|
330 } |
|
331 |
|
332 // ---------------------------------------------------------------------------- |
|
333 // CSmilVideoRenderer::IntrinsicDuration |
|
334 // ---------------------------------------------------------------------------- |
|
335 // |
|
336 TSmilTime CSmilVideoRenderer::IntrinsicDuration() const |
|
337 { |
|
338 #ifdef VIDEO_DEBUG |
|
339 SMILUILOGGER_ENTERFN( "Video: IntrinsicDuration" ); |
|
340 SMILUILOGGER_WRITEF( _L("SMILUI: Video, State = %d"), iState ); |
|
341 #endif |
|
342 |
|
343 TTimeIntervalMicroSeconds duration( TInt64( 0 ) ); |
|
344 |
|
345 TRAPD( error, duration = iVideoPlayer->DurationL() ); |
|
346 if ( error == KErrNone ) |
|
347 { |
|
348 duration = duration.Int64() + iProcessingDelay.Int64() + KProcessingDelayOffset; |
|
349 } |
|
350 |
|
351 #ifdef VIDEO_DEBUG |
|
352 SMILUILOGGER_WRITEF( _L("SMILUI: Video, State = %d"), iState ); |
|
353 SMILUILOGGER_WRITEF( _L("SMILUI: Video, IntrinsicDuration = %d"), I64INT( duration.Int64() ) ); |
|
354 SMILUILOGGER_LEAVEFN( "Video: IntrinsicDuration" ); |
|
355 SMILUILOGGER_WRITEF( _L("")); |
|
356 #endif |
|
357 |
|
358 return TSmilTime::FromMicroSeconds( duration ); |
|
359 } |
|
360 |
|
361 // ---------------------------------------------------------------------------- |
|
362 // CSmilVideoRenderer::PrepareMediaL |
|
363 // ---------------------------------------------------------------------------- |
|
364 // |
|
365 void CSmilVideoRenderer::PrepareMediaL() |
|
366 { |
|
367 #ifdef VIDEO_DEBUG |
|
368 SMILUILOGGER_ENTERFN( "Video: PrepareMediaL" ); |
|
369 SMILUILOGGER_WRITEF( _L("SMILUI: Video, State = %d"), iState ); |
|
370 #endif |
|
371 |
|
372 if ( iState == EReady ) |
|
373 { |
|
374 // Parent control position might have changed so we need to |
|
375 // update our position & size. |
|
376 SetRect( ControlRect() ); |
|
377 } |
|
378 |
|
379 // Reset processing delay. |
|
380 iProcessingDelay = TInt64( 0 ); |
|
381 |
|
382 // Reset pause position. |
|
383 iPausePosition = TInt64( 0 ); |
|
384 |
|
385 if ( iLatePreparation ) |
|
386 { |
|
387 #ifdef VIDEO_DEBUG |
|
388 SMILUILOGGER_WRITEF( _L("SMILUI: Using late preparation") ); |
|
389 #endif |
|
390 DoLatePreparationL(); |
|
391 |
|
392 if ( iError != KErrNone ) |
|
393 { |
|
394 iState = EError; |
|
395 } |
|
396 } |
|
397 |
|
398 if ( iState == EReady ) |
|
399 { |
|
400 iState = EHidden; |
|
401 } |
|
402 |
|
403 #ifdef VIDEO_DEBUG |
|
404 SMILUILOGGER_WRITEF( _L("SMILUI: Video, State = %d"), iState ); |
|
405 SMILUILOGGER_LEAVEFN( "Video: PrepareMediaL" ); |
|
406 SMILUILOGGER_WRITEF( _L("")); |
|
407 #endif |
|
408 } |
|
409 |
|
410 // ---------------------------------------------------------------------------- |
|
411 // CSmilVideoRenderer::SeekMediaL |
|
412 // ---------------------------------------------------------------------------- |
|
413 // |
|
414 void CSmilVideoRenderer::SeekMediaL( const TSmilTime& aTime ) |
|
415 { |
|
416 #ifdef VIDEO_DEBUG |
|
417 SMILUILOGGER_ENTERFN( "Video: SeekMediaL" ); |
|
418 SMILUILOGGER_WRITEF( _L("SMILUI: Video: SeekMediaL, time=%d"), aTime.Value() ); |
|
419 SMILUILOGGER_WRITEF( _L("SMILUI: Video, State = %d"), iState ); |
|
420 #endif |
|
421 |
|
422 TTimeIntervalMicroSeconds position = iVideoPlayer->PositionL(); |
|
423 if ( position != aTime.ToMicroSeconds() ) |
|
424 { |
|
425 if ( iState == EPlaying ) |
|
426 { |
|
427 #ifdef VIDEO_DEBUG |
|
428 SMILUILOGGER_WRITEF( _L("Video: iVideoPlayer->Stop()") ); |
|
429 #endif |
|
430 iVideoPlayer->Stop(); |
|
431 |
|
432 #ifdef VIDEO_DEBUG |
|
433 SMILUILOGGER_WRITEF( _L("Video: iVideoPlayer->SetPositionL()" )); |
|
434 #endif |
|
435 iVideoPlayer->SetPositionL( aTime.ToMicroSeconds() ); |
|
436 |
|
437 #ifdef VIDEO_DEBUG |
|
438 SMILUILOGGER_WRITEF( _L("Video: iVideoPlayer->Play()") ); |
|
439 #endif |
|
440 iVideoPlayer->Play(); |
|
441 } |
|
442 else if( iState == EHidden ) |
|
443 { |
|
444 #ifdef VIDEO_DEBUG |
|
445 SMILUILOGGER_WRITEF( _L("Video: iVideoPlayer->SetPositionL()") ); |
|
446 #endif |
|
447 |
|
448 iVideoPlayer->SetPositionL( aTime.ToMicroSeconds() ); |
|
449 } |
|
450 } |
|
451 |
|
452 if( aTime == 0 && |
|
453 iState == EPaused && |
|
454 PresentationPlaying() ) |
|
455 { |
|
456 #ifdef VIDEO_DEBUG |
|
457 SMILUILOGGER_WRITE( "SMILUI: Video, Auto play on SeekMediaL" ); |
|
458 #endif |
|
459 iState = EHidden; |
|
460 ShowMediaL(); |
|
461 } |
|
462 |
|
463 #ifdef VIDEO_DEBUG |
|
464 SMILUILOGGER_WRITEF( _L("SMILUI: Video, State = %d"), iState ); |
|
465 SMILUILOGGER_LEAVEFN( "Video: SeekMediaL" ); |
|
466 SMILUILOGGER_WRITEF( _L("")); |
|
467 #endif |
|
468 } |
|
469 |
|
470 // ---------------------------------------------------------------------------- |
|
471 // CSmilVideoRenderer::ShowMediaL |
|
472 // ---------------------------------------------------------------------------- |
|
473 // |
|
474 void CSmilVideoRenderer::ShowMediaL() |
|
475 { |
|
476 #ifdef VIDEO_DEBUG |
|
477 SMILUILOGGER_ENTERFN( "Video: ShowMediaL" ); |
|
478 SMILUILOGGER_WRITEF( _L("SMILUI: Video, State = %d"), iState ); |
|
479 #endif |
|
480 |
|
481 if ( iState == EHidden ) |
|
482 { |
|
483 iState = ELoading; |
|
484 UpdateDrawingArea(); |
|
485 MakeVisible( ETrue ); |
|
486 |
|
487 #ifdef VIDEO_DEBUG |
|
488 SMILUILOGGER_WRITEF( _L("Video: iCurrentClipRect: (%d, %d) (%d, %d)"), |
|
489 iCurrentClipRect.iTl.iX, iCurrentClipRect.iTl.iY, iCurrentClipRect.iBr.iX, iCurrentClipRect.iBr.iY ); |
|
490 SMILUILOGGER_WRITE( "Video: iVideoPlayer->Play()" ); |
|
491 #endif |
|
492 iCoeEnv->WsSession().Flush(); |
|
493 |
|
494 iStartTime.HomeTime(); |
|
495 |
|
496 if ( iMedia->Presentation()->State() != CSmilPresentation::EPlaying ) |
|
497 { |
|
498 iOldVolume = iVideoPlayer->Volume(); |
|
499 SetVolume( 0 ); |
|
500 } |
|
501 |
|
502 iVideoPlayer->Play(); |
|
503 |
|
504 // To make sure we don't Pause before clip has been loaded. |
|
505 BeginActiveWait(); |
|
506 |
|
507 if ( iState == ELoading ) |
|
508 { |
|
509 iState = EPlaying; |
|
510 |
|
511 TTime stopTime( TInt64( 0 ) ); |
|
512 stopTime.HomeTime(); |
|
513 |
|
514 iProcessingDelay = iProcessingDelay.Int64() + stopTime.MicroSecondsFrom( iStartTime ).Int64(); |
|
515 |
|
516 ConsumeDRMRightsL(); |
|
517 } |
|
518 } |
|
519 |
|
520 #ifdef VIDEO_DEBUG |
|
521 SMILUILOGGER_WRITEF( _L("SMILUI: Video, State = %d"), iState ); |
|
522 SMILUILOGGER_LEAVEFN( "Video: ShowMediaL" ); |
|
523 SMILUILOGGER_WRITEF( _L("")); |
|
524 #endif |
|
525 } |
|
526 |
|
527 // ---------------------------------------------------------------------------- |
|
528 // CSmilVideoRenderer::HideMedia |
|
529 // ---------------------------------------------------------------------------- |
|
530 // |
|
531 void CSmilVideoRenderer::HideMedia() |
|
532 { |
|
533 #ifdef VIDEO_DEBUG |
|
534 SMILUILOGGER_ENTERFN( "Video: HideMedia" ); |
|
535 SMILUILOGGER_WRITEF( _L("SMILUI: Video, State = %d"), iState ); |
|
536 #endif |
|
537 |
|
538 if ( iState == EPlaying || iState == EPaused ) |
|
539 { |
|
540 #ifdef VIDEO_DEBUG |
|
541 SMILUILOGGER_WRITEF( _L("Video: iVideoPlayer->Stop()") ); |
|
542 #endif |
|
543 iVideoPlayer->Stop(); |
|
544 iState = EHidden; |
|
545 |
|
546 // Do not call MakeVisible if presentation has ended and |
|
547 // video is played from begin of the presentation until the |
|
548 // end of presentation and current time is within one second |
|
549 // from the end. |
|
550 // This optimization is to keep the last frame visible. |
|
551 if ( !PresentationPlaying() || |
|
552 !PlayedForWholePresentation() || |
|
553 ( iMedia->Presentation()->CurrentTime() < |
|
554 ( iMedia->MediaEnd() - TSmilTime::FromMicroSeconds( KProcessingDelayOffset ) ) ) ) |
|
555 { |
|
556 MakeVisible( EFalse ); |
|
557 UpdateDrawingArea(); |
|
558 } |
|
559 } |
|
560 |
|
561 #ifdef VIDEO_DEBUG |
|
562 SMILUILOGGER_WRITEF( _L("SMILUI: Video, State = %d"), iState ); |
|
563 SMILUILOGGER_LEAVEFN( "Video: HideMedia" ); |
|
564 SMILUILOGGER_WRITEF( _L("")); |
|
565 #endif |
|
566 } |
|
567 |
|
568 // ---------------------------------------------------------------------------- |
|
569 // CSmilVideoRenderer::FreezeMedia |
|
570 // ---------------------------------------------------------------------------- |
|
571 // |
|
572 void CSmilVideoRenderer::FreezeMedia() |
|
573 { |
|
574 #ifdef VIDEO_DEBUG |
|
575 SMILUILOGGER_ENTERFN( "Video: FreezeMedia" ); |
|
576 SMILUILOGGER_WRITEF( _L("SMILUI: Video, State = %d"), iState ); |
|
577 #endif |
|
578 |
|
579 if ( iState == EPlaying ) |
|
580 { |
|
581 #ifdef VIDEO_DEBUG |
|
582 SMILUILOGGER_WRITE( "Video: iVideoPlayer->PauseL()" ); |
|
583 #endif |
|
584 // Do the waiting only if presentation is ending. Otherwise performs "normal" |
|
585 // pausing |
|
586 if ( PresentationPlaying() && |
|
587 iMedia->Presentation()->CurrentTime() >= iMedia->Presentation()->Duration() ) |
|
588 { |
|
589 // Clip is not paused if |
|
590 // clip end is < 1 second. In this case we wait |
|
591 // until clip ends. |
|
592 TBool clipEnding( EFalse ); |
|
593 |
|
594 TRAP_IGNORE( clipEnding = IsClipEndingL() ); |
|
595 |
|
596 if ( iState != EPaused ) |
|
597 { |
|
598 if ( clipEnding ) |
|
599 { |
|
600 BeginActiveWait(); |
|
601 } |
|
602 else |
|
603 { |
|
604 DoPause(); |
|
605 } |
|
606 } |
|
607 } |
|
608 else |
|
609 { |
|
610 DoPause(); |
|
611 } |
|
612 } |
|
613 #ifdef VIDEO_DEBUG |
|
614 SMILUILOGGER_WRITEF( _L("SMILUI: Video, State = %d"), iState ); |
|
615 SMILUILOGGER_LEAVEFN( "Video: FreezeMedia" ); |
|
616 SMILUILOGGER_WRITEF( _L("")); |
|
617 #endif |
|
618 } |
|
619 |
|
620 // ---------------------------------------------------------------------------- |
|
621 // CSmilVideoRenderer::Draw |
|
622 // ---------------------------------------------------------------------------- |
|
623 // |
|
624 void CSmilVideoRenderer::Draw( CGraphicsContext& /*aGc*/, |
|
625 const TRect& /*aRect*/, |
|
626 CSmilTransitionFilter* /*aTransitionFilter*/, |
|
627 const MSmilFocus* /*aFocus*/ ) |
|
628 { |
|
629 #ifdef VIDEO_DEBUG |
|
630 SMILUILOGGER_ENTERFN( "Video: Draw" ); |
|
631 SMILUILOGGER_WRITEF( _L("SMILUI: Video, State = %d"), iState ); |
|
632 SMILUILOGGER_LEAVEFN( "Video: Draw" ); |
|
633 SMILUILOGGER_WRITEF( _L("")); |
|
634 #endif |
|
635 } |
|
636 |
|
637 // ---------------------------------------------------------------------------- |
|
638 // CSmilVideoRenderer::Draw |
|
639 // ---------------------------------------------------------------------------- |
|
640 void CSmilVideoRenderer::Draw( const TRect& aRect ) const |
|
641 { |
|
642 #ifdef VIDEO_DEBUG |
|
643 SMILUILOGGER_ENTERFN( "Video: Draw" ); |
|
644 SMILUILOGGER_WRITEF( _L("SMILUI: Video, State = %d"), iState ); |
|
645 #endif |
|
646 |
|
647 if ( iError != KErrNone || |
|
648 ( iState != EPlaying && |
|
649 iState != EPaused && |
|
650 iState != ELoading ) ) |
|
651 { |
|
652 #ifdef VIDEO_DEBUG |
|
653 SMILUILOGGER_ENTERFN( "Video: Drawn with black" ); |
|
654 #endif |
|
655 |
|
656 CWindowGc& gc = SystemGc(); |
|
657 gc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
658 gc.SetPenStyle( CGraphicsContext::ENullPen ); |
|
659 gc.SetBrushColor( KRgbBlack ); |
|
660 gc.DrawRect( aRect ); |
|
661 } |
|
662 else if ( Window().DisplayMode() == EColor16MA ) |
|
663 { |
|
664 CWindowGc& gc = SystemGc(); |
|
665 gc.SetDrawMode( CGraphicsContext::EDrawModeWriteAlpha ); |
|
666 gc.SetBrushColor( TRgb( 0, 0 ) ); |
|
667 gc.Clear(); |
|
668 } |
|
669 |
|
670 #ifdef VIDEO_DEBUG |
|
671 SMILUILOGGER_LEAVEFN( "Video: Draw" ); |
|
672 SMILUILOGGER_WRITEF( _L("")); |
|
673 #endif |
|
674 } |
|
675 |
|
676 // ---------------------------------------------------------------------------- |
|
677 // CSmilVideoRenderer::ResumeMedia |
|
678 // ---------------------------------------------------------------------------- |
|
679 // |
|
680 void CSmilVideoRenderer::ResumeMedia() |
|
681 { |
|
682 #ifdef VIDEO_DEBUG |
|
683 SMILUILOGGER_ENTERFN( "Video: ResumeMedia" ); |
|
684 SMILUILOGGER_WRITEF( _L("SMILUI: Video, State = %d"), iState ); |
|
685 #endif |
|
686 |
|
687 TRAPD( error, DoResumeL() ); |
|
688 if ( error != KErrNone ) |
|
689 { |
|
690 iError = error; |
|
691 } |
|
692 |
|
693 #ifdef VIDEO_DEBUG |
|
694 SMILUILOGGER_WRITEF( _L("SMILUI: Video, State = %d, iError = %d"), iState, iError ); |
|
695 SMILUILOGGER_LEAVEFN( "Video: ResumeMedia" ); |
|
696 SMILUILOGGER_WRITEF( _L("")); |
|
697 #endif |
|
698 } |
|
699 |
|
700 // ---------------------------------------------------------------------------- |
|
701 // CSmilVideoRenderer::DoResumeL |
|
702 // ---------------------------------------------------------------------------- |
|
703 // |
|
704 void CSmilVideoRenderer::DoResumeL() |
|
705 { |
|
706 if ( iState == EPaused ) |
|
707 { |
|
708 #ifdef VIDEO_DEBUG |
|
709 SMILUILOGGER_WRITE( "Video: iVideoPlayer->Play() in ResumeMedia()" ); |
|
710 #endif |
|
711 if ( iLatePreparation ) |
|
712 { |
|
713 #ifdef VIDEO_DEBUG |
|
714 SMILUILOGGER_WRITE( "Video: late preparation in ResumeMedia()" ); |
|
715 #endif |
|
716 |
|
717 DoLatePreparationL(); |
|
718 |
|
719 if ( iError == KErrNone ) |
|
720 { |
|
721 #ifdef VIDEO_DEBUG |
|
722 SMILUILOGGER_WRITE( "Video: late preparation succeeded" ); |
|
723 #endif |
|
724 |
|
725 iState = EPlaying; |
|
726 |
|
727 UpdateDrawingArea(); |
|
728 iVideoPlayer->Play( iPausePosition, iVideoPlayer->DurationL() ); |
|
729 |
|
730 iPausePosition = 0; |
|
731 } |
|
732 } |
|
733 else |
|
734 { |
|
735 iState = EPlaying; |
|
736 iPausePosition = 0; |
|
737 |
|
738 UpdateDrawingArea(); |
|
739 iVideoPlayer->Play(); |
|
740 } |
|
741 |
|
742 } |
|
743 } |
|
744 |
|
745 // ---------------------------------------------------------------------------- |
|
746 // CSmilVideoRenderer::SetVolume |
|
747 // ---------------------------------------------------------------------------- |
|
748 // |
|
749 void CSmilVideoRenderer::SetVolume( TInt aVolume ) |
|
750 { |
|
751 TRAP_IGNORE( DoSetVolumeL( aVolume ) ); |
|
752 } |
|
753 |
|
754 // ---------------------------------------------------------------------------- |
|
755 // CSmilVideoRenderer::MvpuoFrameReady |
|
756 // ---------------------------------------------------------------------------- |
|
757 // |
|
758 void CSmilVideoRenderer::MvpuoFrameReady( CFbsBitmap& /*aFrame*/, |
|
759 TInt /*aError*/ ) |
|
760 { |
|
761 #ifdef VIDEO_DEBUG |
|
762 SMILUILOGGER_WRITEF( _L("Frame ready") ); |
|
763 #endif |
|
764 return; |
|
765 } |
|
766 |
|
767 // ---------------------------------------------------------------------------- |
|
768 // CSmilVideoRenderer::MvpuoPlayComplete |
|
769 // ---------------------------------------------------------------------------- |
|
770 // |
|
771 void CSmilVideoRenderer::MvpuoPlayComplete( TInt aError ) |
|
772 { |
|
773 #ifdef VIDEO_DEBUG |
|
774 SMILUILOGGER_ENTERFN( "Video: PlayComplete" ); |
|
775 SMILUILOGGER_WRITEF( _L("SMILUI: Video, State = %d"), iState ); |
|
776 SMILUILOGGER_WRITEF( _L("SMILUI: Video, aError = %d"), aError ); |
|
777 #endif |
|
778 |
|
779 if ( aError != KErrNone ) |
|
780 { |
|
781 iError = aError; |
|
782 iLatePreparation = ETrue; |
|
783 |
|
784 if ( iState != ENotReady && |
|
785 iState != EReady && |
|
786 iState != EHidden ) |
|
787 { |
|
788 if ( iState == EPaused && |
|
789 ( iError == KErrSessionClosed || |
|
790 iError == KErrDied ) ) |
|
791 { |
|
792 #ifdef VIDEO_DEBUG |
|
793 SMILUILOGGER_WRITEF( _L("SMILUI: Video, pause position: %d"), I64INT( iPausePosition.Int64() ) ); |
|
794 #endif |
|
795 if ( iPausePosition == 0 ) |
|
796 { |
|
797 // No pause position. Cannot show continue on menu. Notifying UI that presentation |
|
798 // should go to end state. |
|
799 iState = EError; |
|
800 #ifdef VIDEO_DEBUG |
|
801 SMILUILOGGER_WRITE( "SMILUI: Video, Critical error. Notified UI about presentation end" ); |
|
802 #endif |
|
803 iMedia->Presentation()->GetPlayer()->PresentationEvent( MSmilPlayer::EEndReached, |
|
804 iMedia->Presentation(), |
|
805 KNullDesC() ); |
|
806 } |
|
807 // Otherwise try to do late preparation on ResumeMedia and continue from the current position. |
|
808 } |
|
809 else |
|
810 { |
|
811 iState = EError; |
|
812 |
|
813 TRAP_IGNORE( iMedia->RendererAtEndL() ); |
|
814 } |
|
815 } |
|
816 |
|
817 EndActiveWait(); |
|
818 } |
|
819 else if ( iState == EPlaying ) |
|
820 { |
|
821 TRAP_IGNORE( iMedia->RendererAtEndL() ); |
|
822 iState = EPaused; |
|
823 |
|
824 EndActiveWait(); |
|
825 } |
|
826 |
|
827 #ifdef VIDEO_DEBUG |
|
828 SMILUILOGGER_WRITEF( _L("SMILUI: Video, State = %d"), iState ); |
|
829 SMILUILOGGER_LEAVEFN( "Video: PlayComplete" ); |
|
830 SMILUILOGGER_WRITEF( _L("")); |
|
831 #endif |
|
832 } |
|
833 |
|
834 // ---------------------------------------------------------------------------- |
|
835 // CSmilVideoRenderer::MvpuoOpenComplete |
|
836 // ---------------------------------------------------------------------------- |
|
837 // |
|
838 void CSmilVideoRenderer::MvpuoOpenComplete( TInt aError ) |
|
839 { |
|
840 #ifdef VIDEO_DEBUG |
|
841 SMILUILOGGER_ENTERFN( "Video: OpenComplete" ); |
|
842 SMILUILOGGER_WRITEF( _L("SMILUI: Video, State = %d"), iState ); |
|
843 SMILUILOGGER_WRITEF( _L("SMILUI: Video, aError = %d"), aError ); |
|
844 #endif |
|
845 if ( aError != KErrNone ) |
|
846 { |
|
847 iError = aError; |
|
848 |
|
849 EndActiveWait(); |
|
850 } |
|
851 else |
|
852 { |
|
853 // Prepare clip for playing and data queries |
|
854 #ifdef VIDEO_DEBUG |
|
855 SMILUILOGGER_WRITE( "Video: iVideoPlayer->Prepare()" ); |
|
856 #endif |
|
857 iVideoPlayer->Prepare(); |
|
858 } |
|
859 #ifdef VIDEO_DEBUG |
|
860 SMILUILOGGER_WRITEF( _L("SMILUI: Video, State = %d"), iState ); |
|
861 SMILUILOGGER_LEAVEFN( "Video: OpenComplete" ); |
|
862 SMILUILOGGER_WRITEF( _L("")); |
|
863 #endif |
|
864 } |
|
865 |
|
866 // ---------------------------------------------------------------------------- |
|
867 // CSmilVideoRenderer::MvpuoPrepareComplete |
|
868 // ---------------------------------------------------------------------------- |
|
869 // |
|
870 void CSmilVideoRenderer::MvpuoPrepareComplete( TInt aError ) |
|
871 { |
|
872 #ifdef VIDEO_DEBUG |
|
873 SMILUILOGGER_ENTERFN( "Video: PrepareComplete" ); |
|
874 SMILUILOGGER_WRITEF( _L("SMILUI: Video, State = %d"), iState ); |
|
875 SMILUILOGGER_WRITEF( _L("SMILUI: Video, aError = %d"), aError ); |
|
876 #endif |
|
877 |
|
878 if ( aError != KErrNone && |
|
879 aError != KErrMMPartialPlayback ) |
|
880 { |
|
881 iError = aError; |
|
882 iLatePreparation = ETrue; |
|
883 } |
|
884 else |
|
885 { |
|
886 if ( iLatePreparation ) |
|
887 { |
|
888 // Calculate processing delay taken by the late preparation. |
|
889 TTime stopTime( TInt64( 0 ) ); |
|
890 stopTime.HomeTime(); |
|
891 |
|
892 TTimeIntervalMicroSeconds duration( TInt64( 0 ) ); |
|
893 duration = stopTime.MicroSecondsFrom( iStartTime ).Int64(); |
|
894 iProcessingDelay = duration.Int64() + KProcessingDelayOffset; |
|
895 } |
|
896 |
|
897 iState = EReady; |
|
898 iLatePreparation = EFalse; |
|
899 } |
|
900 |
|
901 #ifdef VIDEO_DEBUG |
|
902 SMILUILOGGER_WRITEF( _L("SMILUI: Video, Processing delay = %d"), |
|
903 I64INT( iProcessingDelay.Int64() ) ); |
|
904 #endif |
|
905 |
|
906 EndActiveWait(); |
|
907 |
|
908 #ifdef VIDEO_DEBUG |
|
909 SMILUILOGGER_WRITEF( _L("SMILUI: Video, State = %d"), iState ); |
|
910 SMILUILOGGER_LEAVEFN( "Video: PrepareComplete" ); |
|
911 SMILUILOGGER_WRITEF( _L("")); |
|
912 #endif |
|
913 } |
|
914 |
|
915 // ---------------------------------------------------------------------------- |
|
916 // CSmilVideoRenderer::MvpuoEvent |
|
917 // ---------------------------------------------------------------------------- |
|
918 // |
|
919 void CSmilVideoRenderer::MvpuoEvent( const TMMFEvent& /*aEvent*/ ) |
|
920 { |
|
921 #ifdef VIDEO_DEBUG |
|
922 SMILUILOGGER_ENTERFN( "Video: MvpuoEvent" ); |
|
923 SMILUILOGGER_WRITEF( _L("SMILUI: Video, State = %d"), iState ); |
|
924 #endif |
|
925 |
|
926 #ifdef VIDEO_DEBUG |
|
927 SMILUILOGGER_WRITEF( _L("SMILUI: Video, State = %d"), iState ); |
|
928 SMILUILOGGER_LEAVEFN( "Video: MvpuoEvent" ); |
|
929 SMILUILOGGER_WRITEF( _L("")); |
|
930 #endif |
|
931 } |
|
932 |
|
933 // ---------------------------------------------------------------------------- |
|
934 // CSmilVideoRenderer::MvloLoadingStarted |
|
935 // ---------------------------------------------------------------------------- |
|
936 // |
|
937 void CSmilVideoRenderer::MvloLoadingStarted() |
|
938 { |
|
939 #ifdef VIDEO_DEBUG |
|
940 SMILUILOGGER_ENTERFN( "Video: MvloLoadingStarted" ); |
|
941 SMILUILOGGER_WRITEF( _L("SMILUI: Video, State = %d"), iState ); |
|
942 #endif |
|
943 |
|
944 #ifdef VIDEO_DEBUG |
|
945 SMILUILOGGER_WRITEF( _L("SMILUI: Video, State = %d"), iState ); |
|
946 SMILUILOGGER_LEAVEFN( "Video: MvloLoadingStarted" ); |
|
947 SMILUILOGGER_WRITEF( _L("")); |
|
948 #endif |
|
949 } |
|
950 |
|
951 // ---------------------------------------------------------------------------- |
|
952 // CSmilVideoRenderer::MvloLoadingComplete |
|
953 // ---------------------------------------------------------------------------- |
|
954 // |
|
955 void CSmilVideoRenderer::MvloLoadingComplete() |
|
956 { |
|
957 #ifdef VIDEO_DEBUG |
|
958 SMILUILOGGER_ENTERFN( "Video: MvloLoadingComplete" ); |
|
959 SMILUILOGGER_WRITEF( _L("SMILUI: Video, State = %d"), iState ); |
|
960 #endif |
|
961 |
|
962 // To make sure we don't Pause before clip loading completed. |
|
963 EndActiveWait(); |
|
964 |
|
965 #ifdef VIDEO_DEBUG |
|
966 SMILUILOGGER_WRITEF( _L("SMILUI: Video, State = %d"), iState ); |
|
967 SMILUILOGGER_LEAVEFN( "Video: MvloLoadingComplete" ); |
|
968 SMILUILOGGER_WRITEF( _L("")); |
|
969 #endif |
|
970 } |
|
971 |
|
972 // ---------------------------------------------------------------------------- |
|
973 // CSmilVideoRenderer::AdjustRects |
|
974 // ---------------------------------------------------------------------------- |
|
975 // |
|
976 void CSmilVideoRenderer::AdjustRects( TRect& aRect, TRect& aClipRect ) const |
|
977 { |
|
978 #ifdef VIDEO_DEBUG |
|
979 SMILUILOGGER_WRITEF( _L("SMILUI: Video, aRect: ( %d, %d) ( %d, %d), aClipRect: ( %d, %d) ( %d, %d)"), |
|
980 aRect.iTl.iX, aRect.iTl.iY, aRect.iBr.iX, aRect.iBr.iY, |
|
981 aClipRect.iTl.iX, aClipRect.iTl.iY, aClipRect.iBr.iX, aClipRect.iBr.iY ); |
|
982 SMILUILOGGER_ENTERFN( "Video: AdjustRects" ); |
|
983 #endif |
|
984 |
|
985 TRect appWindowRect; |
|
986 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EApplicationWindow, appWindowRect ); |
|
987 |
|
988 TAknLayoutRect mainPane; |
|
989 |
|
990 if ( AknStatuspaneUtils::StaconPaneActive() ) |
|
991 { |
|
992 mainPane.LayoutRect( appWindowRect, AknLayoutScalable_Avkon::main_pane( 4 ) ); |
|
993 } |
|
994 else |
|
995 { |
|
996 mainPane.LayoutRect( appWindowRect, AknLayoutScalable_Avkon::main_pane( 0 ) ); |
|
997 } |
|
998 |
|
999 TAknLayoutRect mainSmilPane; |
|
1000 mainSmilPane.LayoutRect( mainPane.Rect(), AknLayoutScalable_Apps::main_smil_pane() ); |
|
1001 |
|
1002 TRect mainSmilPaneRect; |
|
1003 mainSmilPaneRect = mainSmilPane.Rect(); |
|
1004 |
|
1005 TRect controlPaneRect; |
|
1006 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EControlPane, controlPaneRect ); |
|
1007 |
|
1008 // region to height of screen |
|
1009 if ( aRect.iBr.iY > mainSmilPaneRect.iBr.iY ) |
|
1010 { |
|
1011 #ifdef VIDEO_DEBUG |
|
1012 SMILUILOGGER_WRITEF( _L("SMILUI: Video, region to height of screen ") ); |
|
1013 #endif |
|
1014 aClipRect.iBr.iY = mainSmilPaneRect.iBr.iY; |
|
1015 } |
|
1016 |
|
1017 // region to width of screen |
|
1018 if ( aRect.iBr.iX > mainSmilPaneRect.iBr.iX ) |
|
1019 { |
|
1020 #ifdef VIDEO_DEBUG |
|
1021 SMILUILOGGER_WRITEF( _L("SMILUI: Video, region to width of screen ") ); |
|
1022 #endif |
|
1023 aClipRect.iBr.iX = mainSmilPaneRect.iBr.iX; |
|
1024 } |
|
1025 |
|
1026 // softkeys in pause/end state |
|
1027 if ( iState != ENotReady && |
|
1028 iState != EHidden && |
|
1029 iState != ELoading && |
|
1030 iState != EPlaying ) |
|
1031 { |
|
1032 if ( !AknStatuspaneUtils::StaconPaneActive() && |
|
1033 aRect.iBr.iY > controlPaneRect.iTl.iY ) |
|
1034 { |
|
1035 #ifdef VIDEO_DEBUG |
|
1036 SMILUILOGGER_WRITEF( _L("SMILUI: Video, region to above control pane ") ); |
|
1037 #endif |
|
1038 aClipRect.iBr.iY = controlPaneRect.iTl.iY; |
|
1039 } |
|
1040 } |
|
1041 |
|
1042 if ( aRect.iTl.iX < 0 ) |
|
1043 { |
|
1044 #ifdef VIDEO_DEBUG |
|
1045 SMILUILOGGER_WRITEF( _L("SMILUI: Video, region iTl horizontally out of screen ") ); |
|
1046 #endif |
|
1047 aRect.iTl.iX = 0; |
|
1048 } |
|
1049 |
|
1050 if ( aRect.iTl.iY < 0 ) |
|
1051 { |
|
1052 #ifdef VIDEO_DEBUG |
|
1053 SMILUILOGGER_WRITEF( _L("SMILUI: Video, region iTl vertically out of screen ") ); |
|
1054 #endif |
|
1055 aRect.iTl.iY = 0; |
|
1056 } |
|
1057 |
|
1058 if ( aClipRect.iTl.iX < 0 ) |
|
1059 { |
|
1060 #ifdef VIDEO_DEBUG |
|
1061 SMILUILOGGER_WRITEF( _L("SMILUI: Video, clip region iTl horizontally out of screen ") ); |
|
1062 #endif |
|
1063 aClipRect.iTl.iX = 0; |
|
1064 } |
|
1065 |
|
1066 if ( aClipRect.iTl.iY < 0 ) |
|
1067 { |
|
1068 #ifdef VIDEO_DEBUG |
|
1069 SMILUILOGGER_WRITEF( _L("SMILUI: Video, clip region iTl vertically out of screen ") ); |
|
1070 #endif |
|
1071 aClipRect.iTl.iY = 0; |
|
1072 } |
|
1073 |
|
1074 // Disable rendering if video region is still hidden. |
|
1075 if ( iState == ENotReady || |
|
1076 iState == EReady || |
|
1077 iState == EHidden ) |
|
1078 { |
|
1079 aRect = TRect(); |
|
1080 aClipRect = TRect(); |
|
1081 } |
|
1082 |
|
1083 #ifdef VIDEO_DEBUG |
|
1084 SMILUILOGGER_WRITEF( _L("SMILUI: Video, aRect: ( %d, %d) ( %d, %d), aClipRect: ( %d, %d) ( %d, %d)"), |
|
1085 aRect.iTl.iX, aRect.iTl.iY, aRect.iBr.iX, aRect.iBr.iY, |
|
1086 aClipRect.iTl.iX, aClipRect.iTl.iY, aClipRect.iBr.iX, aClipRect.iBr.iY ); |
|
1087 SMILUILOGGER_LEAVEFN( "Video: AdjustRects" ); |
|
1088 #endif |
|
1089 } |
|
1090 |
|
1091 // ---------------------------------------------------------------------------- |
|
1092 // CSmilVideoRenderer::UpdateDrawingArea |
|
1093 // ---------------------------------------------------------------------------- |
|
1094 // |
|
1095 void CSmilVideoRenderer::UpdateDrawingArea() |
|
1096 { |
|
1097 #ifdef VIDEO_DEBUG |
|
1098 SMILUILOGGER_ENTERFN( "Video: UpdateDrawingArea" ); |
|
1099 #endif |
|
1100 |
|
1101 // Clipping rect and rect are always relative to screen coordinates!! |
|
1102 TRect rect( VideoRect() ); |
|
1103 |
|
1104 #ifdef VIDEO_DEBUG |
|
1105 SMILUILOGGER_WRITEF( _L("Video: UpdateDrawingArea rect before moving rect: (%d, %d) (%d, %d)"), |
|
1106 rect.iTl.iX, rect.iTl.iY, rect.iBr.iX, rect.iBr.iY ); |
|
1107 |
|
1108 TPoint winPos = Window().Position(); |
|
1109 SMILUILOGGER_WRITEF( _L("SMILUI: Video, window position: ( %d, %d)"), |
|
1110 winPos.iX, winPos.iY ); |
|
1111 #endif |
|
1112 |
|
1113 TRect mediaRect( iMedia->GetRectangle() ); |
|
1114 mediaRect.Move( iParent->PositionRelativeToScreen() ); |
|
1115 |
|
1116 rect.iBr.iY = mediaRect.iBr.iY; |
|
1117 |
|
1118 TRect clipRect( rect ); |
|
1119 |
|
1120 AdjustRects( rect, clipRect ); |
|
1121 |
|
1122 #ifdef VIDEO_DEBUG |
|
1123 SMILUILOGGER_WRITEF( _L("SMILUI: Video, iCurrentClipRect: ( %d, %d) ( %d, %d), clipRect: ( %d, %d) ( %d, %d)"), |
|
1124 iCurrentClipRect.iTl.iX, iCurrentClipRect.iTl.iY, iCurrentClipRect.iBr.iX, iCurrentClipRect.iBr.iY, |
|
1125 clipRect.iTl.iX, clipRect.iTl.iY, clipRect.iBr.iX, clipRect.iBr.iY ); |
|
1126 #endif |
|
1127 |
|
1128 if ( iCurrentClipRect != clipRect ) |
|
1129 { |
|
1130 iCurrentClipRect = clipRect; |
|
1131 |
|
1132 #ifdef VIDEO_DEBUG |
|
1133 SMILUILOGGER_WRITEF( _L("SMILUI: Video, iCurrentClipRect: ( %d, %d) ( %d, %d), clipRect: ( %d, %d) ( %d, %d)"), |
|
1134 iCurrentClipRect.iTl.iX, iCurrentClipRect.iTl.iY, iCurrentClipRect.iBr.iX, iCurrentClipRect.iBr.iY, |
|
1135 clipRect.iTl.iX, clipRect.iTl.iY, clipRect.iBr.iX, clipRect.iBr.iY ); |
|
1136 SMILUILOGGER_WRITE( "Video: iVideoPlayer->SetDisplayWindowL()" ); |
|
1137 #endif |
|
1138 TRAP_IGNORE( iVideoPlayer->SetDisplayWindowL( ControlEnv()->WsSession(), |
|
1139 *ControlEnv()->ScreenDevice(), |
|
1140 Window(), |
|
1141 rect, |
|
1142 clipRect ) ); |
|
1143 } |
|
1144 |
|
1145 UpdateSoftKeyVisibility(); |
|
1146 |
|
1147 #ifdef VIDEO_DEBUG |
|
1148 SMILUILOGGER_LEAVEFN( "Video: UpdateDrawingArea" ); |
|
1149 #endif |
|
1150 } |
|
1151 |
|
1152 // ---------------------------------------------------------------------------- |
|
1153 // CSmilVideoRenderer::IsClipEndingL |
|
1154 // Determines if clip is ending < 1 second. |
|
1155 // ---------------------------------------------------------------------------- |
|
1156 // |
|
1157 TBool CSmilVideoRenderer::IsClipEndingL() const |
|
1158 { |
|
1159 #ifdef VIDEO_DEBUG |
|
1160 SMILUILOGGER_ENTERFN( "Video: IsClipEndingL" ); |
|
1161 #endif |
|
1162 |
|
1163 TBool result( EFalse ); |
|
1164 TTimeIntervalMicroSeconds position( iVideoPlayer->PositionL() ); |
|
1165 TTimeIntervalMicroSeconds duration( iVideoPlayer->DurationL() ); |
|
1166 |
|
1167 #ifdef VIDEO_DEBUG |
|
1168 SMILUILOGGER_WRITEF( _L("SMILUI: Video, position: %d"), I64INT( position.Int64() ) ); |
|
1169 SMILUILOGGER_WRITEF( _L("SMILUI: Video, duration: %d"), I64INT( duration.Int64() ) ); |
|
1170 SMILUILOGGER_WRITEF( _L("SMILUI: Video, iProcessingDelay: %d"), I64INT( iProcessingDelay.Int64() ) ); |
|
1171 #endif |
|
1172 |
|
1173 // Sanity check. |
|
1174 if ( position <= duration ) |
|
1175 { |
|
1176 position = position.Int64() + iProcessingDelay.Int64() + KProcessingDelayOffset; |
|
1177 |
|
1178 if ( duration < position ) |
|
1179 { |
|
1180 result = ETrue; |
|
1181 } |
|
1182 } |
|
1183 |
|
1184 #ifdef VIDEO_DEBUG |
|
1185 SMILUILOGGER_WRITEF( _L("SMILUI: Video, result: %d"), result ); |
|
1186 SMILUILOGGER_LEAVEFN( "Video: IsClipEndingL" ); |
|
1187 #endif |
|
1188 |
|
1189 return result; |
|
1190 } |
|
1191 |
|
1192 // ---------------------------------------------------------------------------- |
|
1193 // CSmilVideoRenderer::UpdateSoftKeyVisibility |
|
1194 // Sets softkeys visible or invisible depending if video window is blocking soft |
|
1195 // keys and what the current state of the presentation is. |
|
1196 // ---------------------------------------------------------------------------- |
|
1197 // |
|
1198 void CSmilVideoRenderer::UpdateSoftKeyVisibility() |
|
1199 { |
|
1200 TRect rect( VideoRect() ); |
|
1201 |
|
1202 if ( !AknStatuspaneUtils::StaconPaneActive() && |
|
1203 ( iState == EReady || |
|
1204 iState == EPaused || |
|
1205 iState == EHidden ) ) |
|
1206 { |
|
1207 // Evaluate need to move change the control size because of control pane if |
|
1208 // stacon is not active and we are at EReady, EPaused or EHidden state. |
|
1209 |
|
1210 TRect controlPaneRect; |
|
1211 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EControlPane, controlPaneRect ); |
|
1212 |
|
1213 if ( rect.iBr.iY > controlPaneRect.iTl.iY ) |
|
1214 { |
|
1215 // Sofkeys as visible and video window is shown on control pane area |
|
1216 // => adjust video window so that it is not blocking softkeys |
|
1217 rect.iBr.iY = controlPaneRect.iTl.iY; |
|
1218 } |
|
1219 } |
|
1220 |
|
1221 // Use SetSize instead of SetRect as SetRect causes |
|
1222 // window to be cleared. |
|
1223 if ( rect.Size() != Size() ) |
|
1224 { |
|
1225 SetSize( rect.Size() ); |
|
1226 } |
|
1227 |
|
1228 #ifdef VIDEO_DEBUG |
|
1229 SMILUILOGGER_WRITEF( _L("SMILUI: Video, UpdateSoftKeyVisibility rect: ( %d, %d) ( %d, %d)"), |
|
1230 rect.iTl.iX, rect.iTl.iY, rect.iBr.iX, rect.iBr.iY ); |
|
1231 #endif |
|
1232 } |
|
1233 |
|
1234 // ---------------------------------------------------------------------------- |
|
1235 // CSmilVideoRenderer::DoPause |
|
1236 // Performs the pausing |
|
1237 // ---------------------------------------------------------------------------- |
|
1238 // |
|
1239 void CSmilVideoRenderer::DoPause() |
|
1240 { |
|
1241 #ifdef VIDEO_DEBUG |
|
1242 SMILUILOGGER_ENTERFN( "Video: DoPause" ); |
|
1243 #endif |
|
1244 |
|
1245 TRAPD( error, { |
|
1246 iVideoPlayer->PauseL(); |
|
1247 iPausePosition = iVideoPlayer->PositionL(); |
|
1248 } ); |
|
1249 |
|
1250 if ( error == KErrNone ) |
|
1251 { |
|
1252 #ifdef VIDEO_DEBUG |
|
1253 SMILUILOGGER_WRITEF( _L("SMILUI: Video, pause position: %d"), I64INT( iPausePosition.Int64() ) ); |
|
1254 SMILUILOGGER_WRITE( "Video: Pausing succeeded!" ); |
|
1255 #endif |
|
1256 iState = EPaused; |
|
1257 UpdateDrawingArea(); |
|
1258 } |
|
1259 else |
|
1260 { |
|
1261 #ifdef VIDEO_DEBUG |
|
1262 SMILUILOGGER_WRITEF( _L("SMILUI: Video, pausing failed = %d"), error ); |
|
1263 #endif |
|
1264 // Reset the pause position if error was received. |
|
1265 iPausePosition = 0; |
|
1266 } |
|
1267 |
|
1268 // Reset volume to previous setting |
|
1269 if ( iOldVolume ) |
|
1270 { |
|
1271 SetVolume( iOldVolume ); |
|
1272 iOldVolume = 0; |
|
1273 } |
|
1274 |
|
1275 #ifdef VIDEO_DEBUG |
|
1276 SMILUILOGGER_LEAVEFN( "Video: DoPause" ); |
|
1277 #endif |
|
1278 } |
|
1279 |
|
1280 // ---------------------------------------------------------------------------- |
|
1281 // CSmilVideoRenderer::ControlRect |
|
1282 // Returns media rectangle relative to parent control's rectangle. This is |
|
1283 // basically rectangle for video control. |
|
1284 // ---------------------------------------------------------------------------- |
|
1285 // |
|
1286 TRect CSmilVideoRenderer::ControlRect() const |
|
1287 { |
|
1288 TRect rect( iMedia->GetRectangle() ); |
|
1289 |
|
1290 if ( iParent ) |
|
1291 { |
|
1292 rect.Move( iParent->Position() ); |
|
1293 } |
|
1294 |
|
1295 return rect; |
|
1296 } |
|
1297 |
|
1298 // ---------------------------------------------------------------------------- |
|
1299 // CSmilVideoRenderer::VideoRect |
|
1300 // Returns video rectangle relative to screen. This is |
|
1301 // basically rectangle given to the video controller. |
|
1302 // ---------------------------------------------------------------------------- |
|
1303 // |
|
1304 TRect CSmilVideoRenderer::VideoRect() const |
|
1305 { |
|
1306 return TRect( PositionRelativeToScreen(), iMedia->GetRectangle().Size() ); ; |
|
1307 } |
|
1308 |
|
1309 // ---------------------------------------------------------------------------- |
|
1310 // CSmilVideoRenderer::PresentationPlaying |
|
1311 // ---------------------------------------------------------------------------- |
|
1312 // |
|
1313 TBool CSmilVideoRenderer::PresentationPlaying() const |
|
1314 { |
|
1315 return iMedia->Presentation()->State() == CSmilPresentation::EPlaying; |
|
1316 } |
|
1317 |
|
1318 // ---------------------------------------------------------------------------- |
|
1319 // CSmilVideoRenderer::PlayedForWholePresentation |
|
1320 // ---------------------------------------------------------------------------- |
|
1321 // |
|
1322 TBool CSmilVideoRenderer::PlayedForWholePresentation() const |
|
1323 { |
|
1324 return iMedia->MediaEnd() >= iMedia->Presentation()->Duration() && |
|
1325 iMedia->MediaBegin() <= 0; |
|
1326 } |
|
1327 |
|
1328 // ---------------------------------------------------------------------------- |
|
1329 // CSmilVideoRenderer::DoLatePreparationL |
|
1330 // ---------------------------------------------------------------------------- |
|
1331 // |
|
1332 void CSmilVideoRenderer::DoLatePreparationL() |
|
1333 { |
|
1334 #ifdef VIDEO_DEBUG |
|
1335 SMILUILOGGER_ENTERFN( "Video: DoLatePreparationL" ); |
|
1336 #endif |
|
1337 |
|
1338 iError = KErrNone; |
|
1339 |
|
1340 iVideoPlayer->OpenFileL( iMediaFile ); |
|
1341 |
|
1342 iStartTime.HomeTime(); |
|
1343 BeginActiveWait(); |
|
1344 |
|
1345 if ( iError == KErrNone ) |
|
1346 { |
|
1347 DoSetVolumeL( iMedia->Presentation()->Volume() ); |
|
1348 |
|
1349 iMedia->RendererDurationChangedL(); |
|
1350 } |
|
1351 |
|
1352 #ifdef VIDEO_DEBUG |
|
1353 SMILUILOGGER_WRITEF( _L("SMILUI: iError: %d"), iError ); |
|
1354 SMILUILOGGER_LEAVEFN( "Video: DoLatePreparationL" ); |
|
1355 #endif |
|
1356 } |
|
1357 |
|
1358 // End of file |