| 60 |      1 | /*
 | 
|  |      2 | * Copyright (c) 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:  
 | 
|  |     15 | *       MsgEditor video media control - a Message Editor Base control.
 | 
|  |     16 | *
 | 
|  |     17 | */
 | 
|  |     18 | 
 | 
|  |     19 | 
 | 
|  |     20 | 
 | 
|  |     21 | // INCLUDE FILES
 | 
|  |     22 | #include "MsgVideoControl.h"
 | 
|  |     23 | 
 | 
|  |     24 | #include <AudioPreference.h>
 | 
|  |     25 | #include <AknsDrawUtils.h>
 | 
|  |     26 | #include <DRMCommon.h>
 | 
|  |     27 | #include <mmf/common/mmferrors.h>              // KErrMMPartialPlayback
 | 
|  |     28 | 
 | 
|  |     29 | #include <MsgEditorCommon.h>
 | 
|  |     30 | 
 | 
|  |     31 | #include "MsgFrameControl.h"
 | 
|  |     32 | #include "MsgIconControl.h"
 | 
|  |     33 | #include "MsgVideoAreaControl.h"
 | 
|  |     34 | 
 | 
|  |     35 | #include "MsgMediaControlLogging.h"
 | 
|  |     36 | 
 | 
|  |     37 | // ==========================================================
 | 
|  |     38 | 
 | 
|  |     39 | // EXTERNAL DATA STRUCTURES
 | 
|  |     40 | 
 | 
|  |     41 | // EXTERNAL FUNCTION PROTOTYPES
 | 
|  |     42 | 
 | 
|  |     43 | // CONSTANTS
 | 
|  |     44 | 
 | 
|  |     45 | // MACROS
 | 
|  |     46 | 
 | 
|  |     47 | // LOCAL CONSTANTS AND MACROS
 | 
|  |     48 | 
 | 
|  |     49 | //used to reset inactivity timer after one sec so that backlight will not
 | 
|  |     50 | // be turned on during video playback.
 | 
|  |     51 | const TInt KResetInactivityAfterOneSecond = 2000000;   // 2s
 | 
|  |     52 | 
 | 
|  |     53 | // MODULE DATA STRUCTURES
 | 
|  |     54 | 
 | 
|  |     55 | // LOCAL FUNCTION PROTOTYPES
 | 
|  |     56 | 
 | 
|  |     57 | // ================= MEMBER FUNCTIONS =======================
 | 
|  |     58 | 
 | 
|  |     59 | // ---------------------------------------------------------
 | 
|  |     60 | // CMsgVideoControl::CMsgVideoControl
 | 
|  |     61 | //
 | 
|  |     62 | // Constructor. Maximum video area is calculated so that height comes from 
 | 
|  |     63 | // mainpane height and width comes from data pane height. This video will
 | 
|  |     64 | // use whole application area excluding scrollbar area.
 | 
|  |     65 | // ---------------------------------------------------------
 | 
|  |     66 | //
 | 
|  |     67 | CMsgVideoControl::CMsgVideoControl( MMsgBaseControlObserver& aBaseControlObserver,
 | 
|  |     68 |                                     TMdaPriority aPriority,
 | 
|  |     69 |                                     TMdaPriorityPreference  aPreference,
 | 
|  |     70 |                                     TInt aFlags ) :
 | 
|  |     71 |     CMsgMediaControl( aBaseControlObserver, EMsgComponentIdVideo, EMsgVideoControl ),
 | 
|  |     72 |     iMaxVideoArea( MsgEditorCommons::MsgMainPane() ),
 | 
|  |     73 |     iMaxVolume( 1 ),
 | 
|  |     74 |     iFlags( aFlags ),
 | 
|  |     75 |     iHasVideo( ETrue ),
 | 
|  |     76 |     iPriority( aPriority ),
 | 
|  |     77 |     iPreference( aPreference )
 | 
|  |     78 |     {
 | 
|  |     79 |     if ( iFlags & ENoPlayback )
 | 
|  |     80 |         {
 | 
|  |     81 |         iControlType = EMsgImageControl;
 | 
|  |     82 |         }
 | 
|  |     83 |         
 | 
|  |     84 |     iMaxVideoArea.SetWidth( MsgEditorCommons::MsgDataPane().Width() );
 | 
|  |     85 |     }
 | 
|  |     86 | 
 | 
|  |     87 | // ---------------------------------------------------------
 | 
|  |     88 | // CMsgVideoControl::ConstructL
 | 
|  |     89 | // ---------------------------------------------------------
 | 
|  |     90 | //
 | 
|  |     91 | void CMsgVideoControl::ConstructL( CMsgEditorView& aParent, MMsgAsyncControlObserver* aObserver )
 | 
|  |     92 |     {
 | 
|  |     93 |     BaseConstructL( aParent, aObserver );
 | 
|  |     94 |         
 | 
|  |     95 |     SetRect( iMaxVideoArea );
 | 
|  |     96 |     
 | 
|  |     97 |     iTimer = CPeriodic::NewL( EPriorityLow );
 | 
|  |     98 |     }
 | 
|  |     99 | 
 | 
|  |    100 | // ---------------------------------------------------------
 | 
|  |    101 | // CMsgVideoControl::NewL
 | 
|  |    102 | //
 | 
|  |    103 | // Two-phased constructor.
 | 
|  |    104 | // ---------------------------------------------------------
 | 
|  |    105 | //
 | 
|  |    106 | EXPORT_C CMsgVideoControl* CMsgVideoControl::NewL( CMsgEditorView& aParent,
 | 
|  |    107 |                                                    MMsgAsyncControlObserver* aObserver,
 | 
|  |    108 |                                                    TMdaPriority aPriority,
 | 
|  |    109 |                                                    TMdaPriorityPreference  aPreference,
 | 
|  |    110 |                                                    TInt aFlags )
 | 
|  |    111 |     {
 | 
|  |    112 |     CMsgVideoControl* self = new( ELeave ) CMsgVideoControl( aParent, aPriority, aPreference, aFlags );
 | 
|  |    113 |     
 | 
|  |    114 |     CleanupStack::PushL( self );
 | 
|  |    115 |     self->ConstructL( aParent, aObserver );
 | 
|  |    116 |     CleanupStack::Pop( self );
 | 
|  |    117 |     
 | 
|  |    118 |     return self;
 | 
|  |    119 |     }
 | 
|  |    120 | 
 | 
|  |    121 | // ---------------------------------------------------------
 | 
|  |    122 | // CMsgVideoControl::~CMsgVideoControl
 | 
|  |    123 | //
 | 
|  |    124 | // Destructor
 | 
|  |    125 | // ---------------------------------------------------------
 | 
|  |    126 | //
 | 
|  |    127 | CMsgVideoControl::~CMsgVideoControl()
 | 
|  |    128 |     {
 | 
|  |    129 |     delete iVideoPlayer;
 | 
|  |    130 |     delete iIdle;
 | 
|  |    131 |     
 | 
|  |    132 |     iVideoFile.Close();
 | 
|  |    133 |     
 | 
|  |    134 |     delete iTimer;
 | 
|  |    135 |     delete iVideoAreaControl;
 | 
|  |    136 |     }
 | 
|  |    137 | 
 | 
|  |    138 | 
 | 
|  |    139 | // ---------------------------------------------------------
 | 
|  |    140 | // CMsgVideoControl::HasAudio
 | 
|  |    141 | //
 | 
|  |    142 | // Check if video clip has audio in.
 | 
|  |    143 | // ---------------------------------------------------------
 | 
|  |    144 | //
 | 
|  |    145 | EXPORT_C TBool CMsgVideoControl::HasAudioL( void ) const
 | 
|  |    146 |     {
 | 
|  |    147 |     if ( iVideoPlayer && Error() == KErrNone )
 | 
|  |    148 |         {
 | 
|  |    149 |         return iVideoPlayer->AudioEnabledL();
 | 
|  |    150 |         }
 | 
|  |    151 |     return EFalse;
 | 
|  |    152 |     }
 | 
|  |    153 | 
 | 
|  |    154 | // ---------------------------------------------------------
 | 
|  |    155 | // CMsgVideoControl::SetVolume
 | 
|  |    156 | //
 | 
|  |    157 | // Set volume level.
 | 
|  |    158 | // ---------------------------------------------------------
 | 
|  |    159 | //
 | 
|  |    160 | EXPORT_C void CMsgVideoControl::SetVolumeL( TInt aVolume )
 | 
|  |    161 |     {
 | 
|  |    162 |     MSGMEDIACONTROLLOGGER_WRITEF( _L("MsgVideoControl::SetVolumeL(): HasAudioL(): %d, iMaxVolume: %d, aVolume: %d"),  HasAudioL(), iMaxVolume, aVolume);
 | 
|  |    163 |     if ( HasAudioL() )
 | 
|  |    164 |         {
 | 
|  |    165 |         iVideoPlayer->SetVolumeL( aVolume );
 | 
|  |    166 |         iVolume = iVideoPlayer->Volume();
 | 
|  |    167 |         }
 | 
|  |    168 |     }
 | 
|  |    169 |     
 | 
|  |    170 | // ---------------------------------------------------------
 | 
|  |    171 | // CMsgVideoControl::FocusChanged
 | 
|  |    172 | //
 | 
|  |    173 | // Called when focus is changing. Playing is paused or stopped
 | 
|  |    174 | // depending on iContinueOnFocus flag when focus moves out of video control. 
 | 
|  |    175 | // When focus moved back to control playing is started automatically
 | 
|  |    176 | // if iContinueOnFocus flag is set.
 | 
|  |    177 | // ---------------------------------------------------------
 | 
|  |    178 | //
 | 
|  |    179 | void CMsgVideoControl::FocusChanged( TDrawNow aDrawNow )
 | 
|  |    180 |     {
 | 
|  |    181 |     MSGMEDIACONTROLLOGGER_WRITEF( _L("MsgVideoControl : FocusChanged: IsFocused(): %d" ), IsFocused() );
 | 
|  |    182 |     if ( IsFocused() )
 | 
|  |    183 |         {
 | 
|  |    184 |         if ( iState == EMsgAsyncControlStatePaused &&
 | 
|  |    185 |              iContinueOnFocus )
 | 
|  |    186 |             {
 | 
|  |    187 |             MSGMEDIACONTROLLOGGER_WRITE( "MsgVideoControl : FocusChanged - Delayed start **" );
 | 
|  |    188 |             // We must use CIdle to perform Play since
 | 
|  |    189 |             // "SizeChanged" event comes only after "FocusChanged"
 | 
|  |    190 |             // and thus the coordinates of the video control might
 | 
|  |    191 |             // be false at this stage.
 | 
|  |    192 |             delete iIdle;
 | 
|  |    193 |             iIdle = NULL;
 | 
|  |    194 |             TRAP_IGNORE( iIdle = CIdle::NewL( CActive::EPriorityIdle ) );
 | 
|  |    195 |             if ( iIdle ) 
 | 
|  |    196 |                 {
 | 
|  |    197 |                 iIdle->Start( TCallBack( DelayedPlay, this ) );
 | 
|  |    198 |                 }
 | 
|  |    199 |             else
 | 
|  |    200 |                 {
 | 
|  |    201 |                 MSGMEDIACONTROLLOGGER_WRITE( "MsgVideoControl : FocusChanged - Error in creating iIdle **" );
 | 
|  |    202 |                 Stop();
 | 
|  |    203 |                 }
 | 
|  |    204 |             
 | 
|  |    205 |             }
 | 
|  |    206 |         }
 | 
|  |    207 |     else
 | 
|  |    208 |         {
 | 
|  |    209 |         if ( iContinueOnFocus && 
 | 
|  |    210 |              iState == EMsgAsyncControlStatePlaying )
 | 
|  |    211 |             {
 | 
|  |    212 |             MSGMEDIACONTROLLOGGER_WRITE( "MsgVideoControl : FocusChanged - Pausing video ..." );
 | 
|  |    213 |             TRAPD( err, PauseL() );
 | 
|  |    214 |             if ( err )
 | 
|  |    215 |                 {
 | 
|  |    216 |                 MSGMEDIACONTROLLOGGER_WRITE( "MsgVideoControl : FocusChanged - Error in pausing -> Stop it **" );
 | 
|  |    217 |                 Stop();
 | 
|  |    218 |                 }
 | 
|  |    219 |             }
 | 
|  |    220 |         else
 | 
|  |    221 |             {
 | 
|  |    222 |             MSGMEDIACONTROLLOGGER_WRITE( "MsgVideoControl : FocusChanged - Stopping video **" );
 | 
|  |    223 |             Stop();
 | 
|  |    224 |             }
 | 
|  |    225 |         }
 | 
|  |    226 |         
 | 
|  |    227 |     CMsgMediaControl::FocusChanged( aDrawNow );
 | 
|  |    228 |     }
 | 
|  |    229 | 
 | 
|  |    230 | // ---------------------------------------------------------
 | 
|  |    231 | // CMsgVideoControl::SetAndGetSizeL
 | 
|  |    232 | //
 | 
|  |    233 | // Calculates and sets the size of the control and returns new size as
 | 
|  |    234 | // reference aSize. Video control uses the whole application area excluding
 | 
|  |    235 | // area that has been reserved for scrollbar when it is used for playback.
 | 
|  |    236 | // Otherwise it uses the same width but height is calculated so that
 | 
|  |    237 | // it will icon height + one line height and rounded up to the next whole line.
 | 
|  |    238 | // ---------------------------------------------------------
 | 
|  |    239 | //
 | 
|  |    240 | void CMsgVideoControl::SetAndGetSizeL( TSize& aSize )
 | 
|  |    241 |     {
 | 
|  |    242 |     MSGMEDIACONTROLLOGGER_WRITEF( _L("MsgVideoControl:: SetAndGetSizeL(): Size: %dx%d"),  aSize.iWidth, aSize.iHeight);
 | 
|  |    243 |     
 | 
|  |    244 |     aSize.iWidth = iMaxVideoArea.Width();
 | 
|  |    245 |     
 | 
|  |    246 |     if ( iFlags & ENoPlayback )
 | 
|  |    247 |         {
 | 
|  |    248 |         aSize.iHeight = iFrame->FrameSize().iHeight;
 | 
|  |    249 |         
 | 
|  |    250 |         if ( aSize.iHeight % iLineHeight != 0 )
 | 
|  |    251 |             {
 | 
|  |    252 |             aSize.iHeight += iLineHeight - ( aSize.iHeight % iLineHeight );
 | 
|  |    253 |             }
 | 
|  |    254 |             
 | 
|  |    255 |         aSize.iHeight += iLineHeight;
 | 
|  |    256 |         }
 | 
|  |    257 |     else
 | 
|  |    258 |         {
 | 
|  |    259 |         aSize.iHeight = iMaxVideoArea.Height();
 | 
|  |    260 |         }
 | 
|  |    261 |     
 | 
|  |    262 |     MSGMEDIACONTROLLOGGER_WRITEF( _L("MsgVideoControl:: SetAndGetSizeL(): New size: %dx%d"),  aSize.iWidth, aSize.iHeight);
 | 
|  |    263 |     SetSize( aSize );
 | 
|  |    264 |     }
 | 
|  |    265 | 
 | 
|  |    266 | // ---------------------------------------------------------
 | 
|  |    267 | // CMsgVideoControl::Reset
 | 
|  |    268 | //
 | 
|  |    269 | // Empties the control and sets icon visible.
 | 
|  |    270 | // ---------------------------------------------------------
 | 
|  |    271 | //
 | 
|  |    272 | void CMsgVideoControl::Reset()
 | 
|  |    273 |     {
 | 
|  |    274 |     if( iVideoPlayer )
 | 
|  |    275 |         {
 | 
|  |    276 |         iVideoPlayer->Stop();
 | 
|  |    277 |         iVideoPlayer->Close();
 | 
|  |    278 |         
 | 
|  |    279 |         iTimer->Cancel();
 | 
|  |    280 |         
 | 
|  |    281 |         delete iVideoPlayer;
 | 
|  |    282 |         iVideoPlayer = NULL;
 | 
|  |    283 |         }
 | 
|  |    284 |         
 | 
|  |    285 |     iVideoFile.Close();
 | 
|  |    286 |     
 | 
|  |    287 |     iVolume = 0;
 | 
|  |    288 |     iMaxVolume = 1;
 | 
|  |    289 | 
 | 
|  |    290 |     SetIconVisible( ETrue );
 | 
|  |    291 |     
 | 
|  |    292 |     if ( iVideoAreaControl )
 | 
|  |    293 |     	{
 | 
|  |    294 |         iVideoAreaControl->MakeVisible( EFalse );
 | 
|  |    295 |     	}
 | 
|  |    296 |     
 | 
|  |    297 |     iControlModeFlags |= EMsgControlModeModified;
 | 
|  |    298 |     SetState( EMsgAsyncControlStateIdle );
 | 
|  |    299 |     }
 | 
|  |    300 | 
 | 
|  |    301 | // ---------------------------------------------------------
 | 
|  |    302 | // CMsgVideoControl::Draw
 | 
|  |    303 | // Draw the skin background when appriate. Normal icon drawing
 | 
|  |    304 | // is performed when icon is visible. Otherwise when video frame
 | 
|  |    305 | // is visible we just draw the control area around the video frame.
 | 
|  |    306 | // Video controller is responsible of drawing the video frame area.
 | 
|  |    307 | // ---------------------------------------------------------
 | 
|  |    308 | //
 | 
|  |    309 | void CMsgVideoControl::Draw( const TRect& aRect ) const
 | 
|  |    310 |     {
 | 
|  |    311 |     MSGMEDIACONTROLLOGGER_ENTERFN( "MsgVideoControl : Draw()" );
 | 
|  |    312 |     if ( VisiblePlaceholder() )
 | 
|  |    313 |         {    
 | 
|  |    314 |         // Basic icon drawing from base class when icon is visible.
 | 
|  |    315 |         CMsgMediaControl::Draw( aRect );    
 | 
|  |    316 |         }
 | 
|  |    317 |     else 
 | 
|  |    318 |         {
 | 
|  |    319 |         if ( !AknsDrawUtils::BackgroundBetweenRects( AknsUtils::SkinInstance(), 
 | 
|  |    320 |                                                       AknsDrawUtils::ControlContext( this ), 
 | 
|  |    321 |                                                       this, 
 | 
|  |    322 |                                                       SystemGc(), 
 | 
|  |    323 |                                                       aRect,
 | 
|  |    324 |                                                       iVideoFrameArea ) )
 | 
|  |    325 |             {
 | 
|  |    326 |             SystemGc().SetBrushColor( AKN_LAF_COLOR( 0 ) );
 | 
|  |    327 |             SystemGc().SetBrushStyle( CGraphicsContext::ESolidBrush );
 | 
|  |    328 |             SystemGc().SetPenStyle( CGraphicsContext::ENullPen );
 | 
|  |    329 |             SystemGc().DrawRect( aRect );
 | 
|  |    330 |             }
 | 
|  |    331 |             
 | 
|  |    332 |         if ( !Window().IsFaded() )
 | 
|  |    333 |             {
 | 
|  |    334 |             // Should prevent race conditions between DSP ans window server.
 | 
|  |    335 |             iCoeEnv->WsSession().Flush();
 | 
|  |    336 |             TRAP_IGNORE( iVideoPlayer->RefreshFrameL() ) ;
 | 
|  |    337 |             }
 | 
|  |    338 |         }        
 | 
|  |    339 |     }
 | 
|  |    340 | 
 | 
|  |    341 | // ---------------------------------------------------------
 | 
|  |    342 | // CMsgVideoControl::HandleResourceChange
 | 
|  |    343 | // ---------------------------------------------------------
 | 
|  |    344 | //
 | 
|  |    345 | void CMsgVideoControl::HandleResourceChange( TInt aType )
 | 
|  |    346 |     {
 | 
|  |    347 |     CMsgMediaControl::HandleResourceChange( aType ); 
 | 
|  |    348 |     
 | 
|  |    349 |     if ( aType == KEikDynamicLayoutVariantSwitch )
 | 
|  |    350 |         {
 | 
|  |    351 |         Stop();
 | 
|  |    352 |         TRAP_IGNORE( UpdateScaleFactorL() );
 | 
|  |    353 |         
 | 
|  |    354 |         iMaxVideoArea = MsgEditorCommons::MsgMainPane();
 | 
|  |    355 |         iMaxVideoArea.SetWidth( MsgEditorCommons::MsgDataPane().Width() );
 | 
|  |    356 |         }
 | 
|  |    357 |     }
 | 
|  |    358 | 
 | 
|  |    359 | // ---------------------------------------------------------
 | 
|  |    360 | // CMsgVideoControl::SizeChanged
 | 
|  |    361 | //
 | 
|  |    362 | // Called when size is changed.
 | 
|  |    363 | // ---------------------------------------------------------
 | 
|  |    364 | //
 | 
|  |    365 | void CMsgVideoControl::SizeChanged()
 | 
|  |    366 |     {
 | 
|  |    367 |     MSGMEDIACONTROLLOGGER_WRITEF( _L("MsgVideoControl:: SizeChanged(): New size: %dx%d"),  Size().iWidth, Size().iHeight);
 | 
|  |    368 |     
 | 
|  |    369 |     CMsgMediaControl::SizeChanged();
 | 
|  |    370 |     
 | 
|  |    371 |     SetPosition( Rect().iTl );
 | 
|  |    372 |     MSGMEDIACONTROLLOGGER_WRITEF( _L("MsgVideoControl:: SizeChanged(): Rect().iTl %dx%d"),  Rect().iTl.iX, Rect().iTl.iY);
 | 
|  |    373 |     if ( iVideoPlayer && Error() == KErrNone )
 | 
|  |    374 |         { 
 | 
|  |    375 |         TRAP_IGNORE( SetVideoFrameSizeL() );
 | 
|  |    376 |         }
 | 
|  |    377 |     }
 | 
|  |    378 | 
 | 
|  |    379 | // ---------------------------------------------------------
 | 
|  |    380 | // CMsgVideoControl::LoadL
 | 
|  |    381 | // ---------------------------------------------------------
 | 
|  |    382 | //
 | 
|  |    383 | void CMsgVideoControl::LoadL( RFile& aFileHandle )
 | 
|  |    384 |     {
 | 
|  |    385 |     MSGMEDIACONTROLLOGGER_ENTERFN( "MsgVideoControl : LoadL()" );
 | 
|  |    386 | 
 | 
|  |    387 |     iVideoFile.Close();
 | 
|  |    388 |     User::LeaveIfError( iVideoFile.Duplicate( aFileHandle ) );
 | 
|  |    389 |     
 | 
|  |    390 |     if ( !iVideoAreaControl )
 | 
|  |    391 |     	{
 | 
|  |    392 |         iVideoAreaControl = CMsgVideoAreaControl::NewL( this );
 | 
|  |    393 |     	}
 | 
|  |    394 |     
 | 
|  |    395 |     if ( !iVideoPlayer )
 | 
|  |    396 |         {
 | 
|  |    397 |         // Disable frame display as video is not yet visible
 | 
|  |    398 |         TRect rect;
 | 
|  |    399 |         TRect clipRect;
 | 
|  |    400 | 
 | 
|  |    401 |         // Create VideoPlayerUtility instance
 | 
|  |    402 |         iVideoPlayer = CVideoPlayerUtility::NewL(
 | 
|  |    403 |                         *this,
 | 
|  |    404 |                         iPriority,
 | 
|  |    405 |                         iPreference,
 | 
|  |    406 |                         ControlEnv()->WsSession(),
 | 
|  |    407 |                         *ControlEnv()->ScreenDevice(),    
 | 
|  |    408 |                         *iVideoAreaControl->DrawableWindow(),
 | 
|  |    409 |                         rect, 
 | 
|  |    410 |                         clipRect );
 | 
|  |    411 |         // Register for Loading/rebuffering notices
 | 
|  |    412 |         iVideoPlayer->RegisterForVideoLoadingNotification( *this );
 | 
|  |    413 |         }
 | 
|  |    414 |     else
 | 
|  |    415 |         {
 | 
|  |    416 |         iVideoPlayer->Close();
 | 
|  |    417 |         }
 | 
|  |    418 | 
 | 
|  |    419 |     TMMFileHandleSource mmSource( iVideoFile, iUniqueContentId );
 | 
|  |    420 |     iVideoPlayer->OpenFileL( mmSource );        
 | 
|  |    421 | 
 | 
|  |    422 |     SetState( EMsgAsyncControlStateOpening );
 | 
|  |    423 |     
 | 
|  |    424 |     MSGMEDIACONTROLLOGGER_LEAVEFN( "MsgVideoControl : LoadL()" );
 | 
|  |    425 |     }
 | 
|  |    426 | 
 | 
|  |    427 | // ---------------------------------------------------------
 | 
|  |    428 | // CMsgVideoControl::Cancel
 | 
|  |    429 | // ---------------------------------------------------------
 | 
|  |    430 | //
 | 
|  |    431 | void CMsgVideoControl::Cancel()
 | 
|  |    432 |     {
 | 
|  |    433 |     if ( iState == EMsgAsyncControlStateOpening )
 | 
|  |    434 |         {
 | 
|  |    435 |         iVideoPlayer->Close();
 | 
|  |    436 |         
 | 
|  |    437 |         SetState( EMsgAsyncControlStateIdle );
 | 
|  |    438 |         }
 | 
|  |    439 |     }
 | 
|  |    440 | 
 | 
|  |    441 | // ---------------------------------------------------------
 | 
|  |    442 | // CMsgVideoControl::VideoResolution
 | 
|  |    443 | //
 | 
|  |    444 | // Gives the resolution of the video in display (Symbian OS bitmap)
 | 
|  |    445 | // ---------------------------------------------------------
 | 
|  |    446 | //
 | 
|  |    447 | EXPORT_C TSize CMsgVideoControl::VideoResolutionL() const
 | 
|  |    448 |     {
 | 
|  |    449 |     TSize retVal( 0, 0 );
 | 
|  |    450 |     if ( iVideoPlayer && Error() == KErrNone )
 | 
|  |    451 |         {
 | 
|  |    452 |         iVideoPlayer->VideoFrameSizeL( retVal );
 | 
|  |    453 |         }
 | 
|  |    454 |     return retVal;
 | 
|  |    455 |     }
 | 
|  |    456 | 
 | 
|  |    457 | // ---------------------------------------------------------
 | 
|  |    458 | // DelayedExit
 | 
|  |    459 | // ---------------------------------------------------------
 | 
|  |    460 | //
 | 
|  |    461 | TInt CMsgVideoControl::DelayedPlay( TAny* aThis )
 | 
|  |    462 |     {
 | 
|  |    463 |     TRAPD( error, static_cast<CMsgVideoControl*>( aThis )->PlayL() );
 | 
|  |    464 |     return error;
 | 
|  |    465 |     }
 | 
|  |    466 | 
 | 
|  |    467 | // ---------------------------------------------------------
 | 
|  |    468 | // CMsgVideoControl::PlayL
 | 
|  |    469 | //
 | 
|  |    470 | // Starts video playback.
 | 
|  |    471 | // ---------------------------------------------------------
 | 
|  |    472 | //
 | 
|  |    473 | void CMsgVideoControl::PlayL()
 | 
|  |    474 |     {
 | 
|  |    475 |     MSGMEDIACONTROLLOGGER_ENTERFN( "MsgVideoControl : PlayL()" );
 | 
|  |    476 | 
 | 
|  |    477 |     // When DSP is used for audio/video playing, dsp resources are not always available.
 | 
|  |    478 |     // It is handled by setting normal 'ready' icon. No error notes occur.
 | 
|  |    479 |     if ( iVideoPlayer && 
 | 
|  |    480 |          (  Error() == KErrNone ||
 | 
|  |    481 |             (   iState == EMsgAsyncControlStateCorrupt
 | 
|  |    482 |             &&  (   Error() == KErrAccessDenied
 | 
|  |    483 |                 ||  Error() == KErrSessionClosed ) ) ) && 
 | 
|  |    484 |          !( iFlags & ENoPlayback ) )
 | 
|  |    485 |         {
 | 
|  |    486 |         if ( iHasVideo )
 | 
|  |    487 |             {
 | 
|  |    488 |             // Only hide icon if video file has video stream.
 | 
|  |    489 |             if ( iIconControl->IsVisible() )
 | 
|  |    490 |                 {
 | 
|  |    491 |                 UpdateScaleFactorL();
 | 
|  |    492 |                 
 | 
|  |    493 |                 SetIconVisible( EFalse );
 | 
|  |    494 |                 iVideoAreaControl->MakeVisible( ETrue );
 | 
|  |    495 |                 
 | 
|  |    496 |                 // Enable frame display        	
 | 
|  |    497 |                 SetVideoFrameSizeL();
 | 
|  |    498 |                 }
 | 
|  |    499 |             
 | 
|  |    500 |             iTimer->Cancel(); //just in case
 | 
|  |    501 |             
 | 
|  |    502 |             // Disable backlight turn off during video playback when video contains
 | 
|  |    503 |             // video stream.
 | 
|  |    504 |             iTimer->Start( KResetInactivityAfterOneSecond,
 | 
|  |    505 |                            KResetInactivityAfterOneSecond,
 | 
|  |    506 |                            TCallBack( DoResetInactivityTimer, NULL ) );
 | 
|  |    507 |             }
 | 
|  |    508 |         	
 | 
|  |    509 |         iVideoPlayer->Play();
 | 
|  |    510 |         
 | 
|  |    511 |         if ( iState == EMsgAsyncControlStatePaused )
 | 
|  |    512 |             {
 | 
|  |    513 |             SetState( EMsgAsyncControlStatePlaying );
 | 
|  |    514 |             }
 | 
|  |    515 |         else
 | 
|  |    516 |             {
 | 
|  |    517 |             if (iState == EMsgAsyncControlStateReady )
 | 
|  |    518 |                 {
 | 
|  |    519 |                 // First time
 | 
|  |    520 |                 SetState( EMsgAsyncControlStateAboutToPlay );
 | 
|  |    521 |                 }
 | 
|  |    522 |             else
 | 
|  |    523 |                 {
 | 
|  |    524 |                 // State must be stop. Video has earlier played
 | 
|  |    525 |                 SetState( EMsgAsyncControlStatePlaying );
 | 
|  |    526 |                 }
 | 
|  |    527 |             }
 | 
|  |    528 |         }
 | 
|  |    529 |     MSGMEDIACONTROLLOGGER_LEAVEFN( "MsgVideoControl : PlayL()" );
 | 
|  |    530 |     }
 | 
|  |    531 | 
 | 
|  |    532 | // ---------------------------------------------------------
 | 
|  |    533 | // CMsgVideoControl::Stop
 | 
|  |    534 | //
 | 
|  |    535 | // Stops video.
 | 
|  |    536 | // ---------------------------------------------------------
 | 
|  |    537 | //
 | 
|  |    538 | void CMsgVideoControl::Stop()
 | 
|  |    539 |     {
 | 
|  |    540 |     MSGMEDIACONTROLLOGGER_ENTERFN( "MsgVideoControl : Stop()" );
 | 
|  |    541 | 
 | 
|  |    542 |     if ( iState == EMsgAsyncControlStatePlaying ||
 | 
|  |    543 |          iState == EMsgAsyncControlStatePaused )
 | 
|  |    544 |         {
 | 
|  |    545 |         iVideoPlayer->Stop();
 | 
|  |    546 |         
 | 
|  |    547 |         // Enable backlight to turn on after video playback has been stopped.
 | 
|  |    548 |         iTimer->Cancel();
 | 
|  |    549 |         
 | 
|  |    550 |         SetState( EMsgAsyncControlStateStopped );
 | 
|  |    551 |         }
 | 
|  |    552 |     }
 | 
|  |    553 | 
 | 
|  |    554 | // ---------------------------------------------------------
 | 
|  |    555 | // CMsgVideoControl::PauseL
 | 
|  |    556 | //
 | 
|  |    557 | // Pauses video.
 | 
|  |    558 | // ---------------------------------------------------------
 | 
|  |    559 | //
 | 
|  |    560 | void CMsgVideoControl::PauseL()
 | 
|  |    561 |     {
 | 
|  |    562 |     MSGMEDIACONTROLLOGGER_ENTERFN( "MsgVideoControl : PauseL()" );
 | 
|  |    563 |     if ( iState == EMsgAsyncControlStatePlaying )
 | 
|  |    564 |         {
 | 
|  |    565 |         iVideoPlayer->PauseL();
 | 
|  |    566 |         
 | 
|  |    567 |         // Enable backlight to turn on after video playback has been paused.
 | 
|  |    568 |         iTimer->Cancel();
 | 
|  |    569 |         
 | 
|  |    570 |         SetState( EMsgAsyncControlStatePaused );
 | 
|  |    571 |         }
 | 
|  |    572 |     }
 | 
|  |    573 | 
 | 
|  |    574 | // ---------------------------------------------------------
 | 
|  |    575 | // CMsgVideoControl::IsOffScreen
 | 
|  |    576 | //
 | 
|  |    577 | // Returns ETrue if control is off screen.
 | 
|  |    578 | // ---------------------------------------------------------
 | 
|  |    579 | //
 | 
|  |    580 | EXPORT_C TBool CMsgVideoControl::IsOffScreen() const
 | 
|  |    581 |     {
 | 
|  |    582 |     TRect rect( Rect() );
 | 
|  |    583 |     if ( rect.iTl.iY < 0 || rect.iBr.iY > iMaxVideoArea.Height() )
 | 
|  |    584 |         {
 | 
|  |    585 |         return ETrue;
 | 
|  |    586 |         }
 | 
|  |    587 |     else
 | 
|  |    588 |         {
 | 
|  |    589 |         return EFalse;
 | 
|  |    590 |         }
 | 
|  |    591 |     }
 | 
|  |    592 | 
 | 
|  |    593 | 
 | 
|  |    594 | // ---------------------------------------------------------
 | 
|  |    595 | // CMsgVideoControl::SetVideoFrameSizeL
 | 
|  |    596 | //
 | 
|  |    597 | // ---------------------------------------------------------
 | 
|  |    598 | //
 | 
|  |    599 | void CMsgVideoControl::SetVideoFrameSizeL()
 | 
|  |    600 |     {
 | 
|  |    601 |     MSGMEDIACONTROLLOGGER_ENTERFN( "MsgVideoControl : DoSizeChangedL()" );
 | 
|  |    602 |     
 | 
|  |    603 |     TRect rect;
 | 
|  |    604 |     TRect clipRect;
 | 
|  |    605 |     
 | 
|  |    606 | 	if ( VisiblePlaceholder() )
 | 
|  |    607 | 		{
 | 
|  |    608 | 		// Disable frame display if icon is visible
 | 
|  |    609 | 		iVideoFrameArea = TRect();
 | 
|  |    610 | 		}
 | 
|  |    611 | 	else
 | 
|  |    612 | 	    {
 | 
|  |    613 | 	    TSize videoSize( iOriginalSize.iWidth * iScaleFactor,
 | 
|  |    614 |                          iOriginalSize.iHeight * iScaleFactor );
 | 
|  |    615 |         
 | 
|  |    616 |         TPoint videoPosition( Rect().Center() );
 | 
|  |    617 |         
 | 
|  |    618 |         videoPosition.iX -= videoSize.iWidth / 2;
 | 
|  |    619 |         videoPosition.iY -= videoSize.iHeight / 2;
 | 
|  |    620 |         
 | 
|  |    621 |         // Rect & clipRect are relative to screen coordinates.
 | 
|  |    622 |         rect =  TRect( videoPosition, videoSize );
 | 
|  |    623 |         rect.Move( 0, iMaxVideoArea.iTl.iY );
 | 
|  |    624 | 
 | 
|  |    625 |         clipRect = rect;
 | 
|  |    626 |         clipRect.iTl.iY = Max( clipRect.iTl.iY, iMaxVideoArea.iTl.iY );
 | 
|  |    627 |         clipRect.iTl.iY = Min( clipRect.iTl.iY, iMaxVideoArea.iBr.iY );
 | 
|  |    628 |         clipRect.iBr.iY = Min( clipRect.iBr.iY, iMaxVideoArea.iBr.iY );
 | 
|  |    629 |         clipRect.iBr.iY = Max( clipRect.iBr.iY, iMaxVideoArea.iTl.iY );
 | 
|  |    630 | 
 | 
|  |    631 |         // iVideoFrameArea is relative to window coordinates.
 | 
|  |    632 |         iVideoFrameArea = clipRect;
 | 
|  |    633 |         iVideoFrameArea.Move( 0, -iBaseControlObserver->ViewRect().iTl.iY );
 | 
|  |    634 | 
 | 
|  |    635 |         MSGMEDIACONTROLLOGGER_WRITE( "MsgVideoControl : DoSizeChangedL() - Calling  SetDisplayWindowL" );
 | 
|  |    636 |         MSGMEDIACONTROLLOGGER_WRITEF( _L("MsgVideoControl:: SizeChanged(): rect (%d,%d),( %d,%d)"),  rect.iTl.iX, rect.iTl.iY, rect.iBr.iX, rect.iBr.iY);
 | 
|  |    637 |         MSGMEDIACONTROLLOGGER_WRITEF( _L("MsgVideoControl:: SizeChanged(): cliRect (%d,%d),( %d,%d)"),  clipRect.iTl.iX, clipRect.iTl.iY, clipRect.iBr.iX, clipRect.iBr.iY);
 | 
|  |    638 | 	    }
 | 
|  |    639 | 	
 | 
|  |    640 |     iVideoAreaControl->SetRect( iVideoFrameArea );
 | 
|  |    641 | 
 | 
|  |    642 | 	// iVideoAreaControl is relative to screen coordinates.
 | 
|  |    643 |     iVideoPlayer->SetDisplayWindowL(
 | 
|  |    644 |         ControlEnv()->WsSession(),
 | 
|  |    645 |         *ControlEnv()->ScreenDevice(),
 | 
|  |    646 |         *iVideoAreaControl->DrawableWindow(),
 | 
|  |    647 |         rect,
 | 
|  |    648 |         clipRect );
 | 
|  |    649 |     
 | 
|  |    650 |     MSGMEDIACONTROLLOGGER_LEAVEFN( "MsgVideoControl : DoSizeChangedL()" );
 | 
|  |    651 |     }
 | 
|  |    652 | 
 | 
|  |    653 | 
 | 
|  |    654 | // =========================================================
 | 
|  |    655 | // Callbacks from VideoPlayerutility
 | 
|  |    656 | // =========================================================
 | 
|  |    657 | 
 | 
|  |    658 | // ---------------------------------------------------------
 | 
|  |    659 | // see MVideoPlayerUtilityObserver::MvpuoOpenComplete
 | 
|  |    660 | // ---------------------------------------------------------
 | 
|  |    661 | //
 | 
|  |    662 | void CMsgVideoControl::MvpuoOpenComplete( TInt aError )
 | 
|  |    663 |     {
 | 
|  |    664 |     MSGMEDIACONTROLLOGGER_ENTERFN( "MsgVideoControl : MvpuoOpenComplete()" );
 | 
|  |    665 |     
 | 
|  |    666 |     // Close the handle now
 | 
|  |    667 |     iVideoFile.Close();
 | 
|  |    668 |     
 | 
|  |    669 |     iMaxVolume = iVideoPlayer->MaxVolume();
 | 
|  |    670 |     iVolume = iVideoPlayer->Volume();
 | 
|  |    671 | 
 | 
|  |    672 |     // Needed so that video controller won't consume DRM rights automatically.    
 | 
|  |    673 |     MMMFDRMCustomCommand* customCommand = iVideoPlayer->GetDRMCustomCommand();
 | 
|  |    674 |     if ( customCommand )
 | 
|  |    675 |         {
 | 
|  |    676 |         customCommand->DisableAutomaticIntent( ETrue );            
 | 
|  |    677 |         }
 | 
|  |    678 |     
 | 
|  |    679 |     HandleCallback( aError, iState );
 | 
|  |    680 |     // Remember that MvpuoPrepareComplete() follows
 | 
|  |    681 |     
 | 
|  |    682 |     MSGMEDIACONTROLLOGGER_LEAVEFN( "MsgVideoControl : MvpuoOpenComplete()" );
 | 
|  |    683 |     }
 | 
|  |    684 | 
 | 
|  |    685 | // ---------------------------------------------------------
 | 
|  |    686 | // see MVideoPlayerUtilityObserver::MvpuoPrepareComplete
 | 
|  |    687 | // ---------------------------------------------------------
 | 
|  |    688 | //
 | 
|  |    689 | void CMsgVideoControl::MvpuoPrepareComplete( TInt aError )
 | 
|  |    690 |     {
 | 
|  |    691 |     MSGMEDIACONTROLLOGGER_ENTERFN( "MsgVideoControl : MvpuoPrepareComplete()" );
 | 
|  |    692 |     
 | 
|  |    693 |     // Determine whether video file contains video stream (i.e. it has something
 | 
|  |    694 |     // to show on the screen).
 | 
|  |    695 | 	TRAP_IGNORE( 
 | 
|  |    696 | 	    {
 | 
|  |    697 |         if ( iVideoPlayer->VideoFrameRateL() == 0 && iVideoPlayer->VideoBitRateL() == 0 )
 | 
|  |    698 |             {
 | 
|  |    699 |             MSGMEDIACONTROLLOGGER_WRITE( "MsgVideoControl : no video stream" );
 | 
|  |    700 |             
 | 
|  |    701 |             // If both video frame rate and bit rate are zeros then we can be pretty
 | 
|  |    702 |             // sure that there is no video stream on the file.
 | 
|  |    703 |             iHasVideo = EFalse;
 | 
|  |    704 |             }
 | 
|  |    705 |                                                  
 | 
|  |    706 |         iVideoPlayer->VideoFrameSizeL( iOriginalSize );
 | 
|  |    707 |         } );
 | 
|  |    708 |     
 | 
|  |    709 |     HandleCallback( aError, EMsgAsyncControlStateReady );    
 | 
|  |    710 |     
 | 
|  |    711 |     MSGMEDIACONTROLLOGGER_LEAVEFN( "MsgVideoControl : MvpuoPrepareComplete()" );
 | 
|  |    712 |     }
 | 
|  |    713 | 
 | 
|  |    714 | // ---------------------------------------------------------
 | 
|  |    715 | // see MVideoPlayerUtilityObserver::MvpuoFrameReady
 | 
|  |    716 | // ---------------------------------------------------------
 | 
|  |    717 | //
 | 
|  |    718 | void CMsgVideoControl::MvpuoFrameReady( CFbsBitmap& /*aFrame*/,TInt /*aError*/ )
 | 
|  |    719 |     {
 | 
|  |    720 |     MSGMEDIACONTROLLOGGER_ENTERFN( "MsgVideoControl : MvpuoFrameReady()" );
 | 
|  |    721 |     MSGMEDIACONTROLLOGGER_LEAVEFN( "MsgVideoControl : MvpuoFrameReady()" );
 | 
|  |    722 |     }
 | 
|  |    723 | 
 | 
|  |    724 | // ---------------------------------------------------------
 | 
|  |    725 | // see MVideoPlayerUtilityObserver::MvpuoPlayComplete
 | 
|  |    726 | // Trapping callback as leaving not allowed.
 | 
|  |    727 | // ---------------------------------------------------------
 | 
|  |    728 | //
 | 
|  |    729 | void CMsgVideoControl::MvpuoPlayComplete( TInt aError )
 | 
|  |    730 |     {
 | 
|  |    731 |     MSGMEDIACONTROLLOGGER_ENTERFN( "MsgVideoControl : MvpuoPlayComplete()" );
 | 
|  |    732 |     
 | 
|  |    733 |     // Enable backlight to turn on after video playback has ended.
 | 
|  |    734 |     iTimer->Cancel();
 | 
|  |    735 |     
 | 
|  |    736 |     HandleCallback( aError, EMsgAsyncControlStateStopped );
 | 
|  |    737 |     
 | 
|  |    738 |     MSGMEDIACONTROLLOGGER_LEAVEFN( "MsgVideoControl : MvpuoPlayComplete()" );
 | 
|  |    739 |     }
 | 
|  |    740 |         
 | 
|  |    741 | // ---------------------------------------------------------
 | 
|  |    742 | // see MVideoPlayerUtilityObserver::MvpuoEvent
 | 
|  |    743 | // Trapping callback as leaving not allowed.
 | 
|  |    744 | // ---------------------------------------------------------
 | 
|  |    745 | //
 | 
|  |    746 | void CMsgVideoControl::MvpuoEvent( const TMMFEvent& /*aEvent*/ )
 | 
|  |    747 |     {
 | 
|  |    748 |     MSGMEDIACONTROLLOGGER_ENTERFN( "MsgVideoControl : MvpuoEvent()" );
 | 
|  |    749 |     MSGMEDIACONTROLLOGGER_LEAVEFN( "MsgVideoControl : MvpuoEvent()" );
 | 
|  |    750 |     }
 | 
|  |    751 |     
 | 
|  |    752 | // ---------------------------------------------------------
 | 
|  |    753 | // see MVideoLoadingObserver::MvloLoadingStarted
 | 
|  |    754 | // Trapping callback as leaving not allowed.
 | 
|  |    755 | // ---------------------------------------------------------
 | 
|  |    756 | //
 | 
|  |    757 | void CMsgVideoControl::MvloLoadingStarted()
 | 
|  |    758 |     {
 | 
|  |    759 |     MSGMEDIACONTROLLOGGER_ENTERFN( "MsgVideoControl : MvloLoadingStarted()" );
 | 
|  |    760 | 
 | 
|  |    761 |     SetState( EMsgAsyncControlStateBuffering );
 | 
|  |    762 |     
 | 
|  |    763 |     MSGMEDIACONTROLLOGGER_LEAVEFN( "MsgVideoControl : MvloLoadingStarted()" );
 | 
|  |    764 |     }
 | 
|  |    765 |     
 | 
|  |    766 | // ---------------------------------------------------------
 | 
|  |    767 | // see MVideoLoadingObserver::MvloLoadingComplete
 | 
|  |    768 | // Trapping callback as leaving not allowed.
 | 
|  |    769 | // ---------------------------------------------------------
 | 
|  |    770 | //
 | 
|  |    771 | void CMsgVideoControl::MvloLoadingComplete()
 | 
|  |    772 |     {
 | 
|  |    773 |     MSGMEDIACONTROLLOGGER_ENTERFN( "MsgVideoControl : MvloLoadingComplete()" );
 | 
|  |    774 |     
 | 
|  |    775 |     SetState( EMsgAsyncControlStatePlaying );
 | 
|  |    776 |     
 | 
|  |    777 |     MSGMEDIACONTROLLOGGER_LEAVEFN( "MsgVideoControl : MvloLoadingComplete()" );
 | 
|  |    778 |     }
 | 
|  |    779 | 
 | 
|  |    780 | // ---------------------------------------------------------
 | 
|  |    781 | // CMsgVideoControl::HandleCallback
 | 
|  |    782 | // ---------------------------------------------------------
 | 
|  |    783 | //
 | 
|  |    784 | void CMsgVideoControl::HandleCallback( TInt aError,
 | 
|  |    785 |                                        TMsgAsyncControlState aNewState )
 | 
|  |    786 |     {
 | 
|  |    787 |     MSGMEDIACONTROLLOGGER_ENTERFN( "MsgVideoControl : HandleCallback()" );
 | 
|  |    788 |     MSGMEDIACONTROLLOGGER_WRITEF_ERROR_STATE( _L("CMsgVideoControl::HandleCallback: **aError: %d, CurrentState: %S"), aError, iState);
 | 
|  |    789 |     MSGMEDIACONTROLLOGGER_WRITEF_ERROR_STATE( _L("CMsgVideoControl::HandleCallback: **aError: %d, aNewState: %S"), aError, aNewState);
 | 
|  |    790 |     
 | 
|  |    791 |     if ( aError == KErrMMPartialPlayback )
 | 
|  |    792 |         {
 | 
|  |    793 |         aError = KErrNone;
 | 
|  |    794 |         }
 | 
|  |    795 |     
 | 
|  |    796 |     iError = aError;
 | 
|  |    797 |     switch ( aError )
 | 
|  |    798 |         {
 | 
|  |    799 |         case KErrNone:    
 | 
|  |    800 |             {
 | 
|  |    801 |             SetState( aNewState );
 | 
|  |    802 |             
 | 
|  |    803 |             if ( iState == EMsgAsyncControlStateOpening )
 | 
|  |    804 |                 {
 | 
|  |    805 |                 if ( iVideoPlayer )
 | 
|  |    806 |                     {
 | 
|  |    807 |                     iVideoPlayer->Prepare();
 | 
|  |    808 |                     }
 | 
|  |    809 |                 }
 | 
|  |    810 |             
 | 
|  |    811 |             break;
 | 
|  |    812 |             }
 | 
|  |    813 |         case DRMCommon::EGeneralError:
 | 
|  |    814 |         case DRMCommon::EUnknownMIME:
 | 
|  |    815 |         case DRMCommon::EVersionNotSupported:
 | 
|  |    816 |         case DRMCommon::ESessionError:
 | 
|  |    817 |         case DRMCommon::ENoRights:
 | 
|  |    818 |         case DRMCommon::ERightsDBCorrupted:
 | 
|  |    819 |         case DRMCommon::EUnsupported:
 | 
|  |    820 |         case DRMCommon::ERightsExpired:
 | 
|  |    821 |         case DRMCommon::EInvalidRights:
 | 
|  |    822 |             {
 | 
|  |    823 |             SetState( EMsgAsyncControlStateNoRights );
 | 
|  |    824 |             break;
 | 
|  |    825 |             }
 | 
|  |    826 |         case KErrNoMemory:
 | 
|  |    827 |         default:
 | 
|  |    828 |             {
 | 
|  |    829 |             SetState( EMsgAsyncControlStateCorrupt );
 | 
|  |    830 |             }
 | 
|  |    831 |         } 
 | 
|  |    832 |     
 | 
|  |    833 |     MSGMEDIACONTROLLOGGER_LEAVEFN( "MsgVideoControl : HandleCallback()" );   
 | 
|  |    834 |     }
 | 
|  |    835 | 
 | 
|  |    836 | // ---------------------------------------------------------
 | 
|  |    837 | // CMsgVideoControl::Reset
 | 
|  |    838 | //
 | 
|  |    839 | // Empties the control.
 | 
|  |    840 | // ---------------------------------------------------------
 | 
|  |    841 | //
 | 
|  |    842 | void CMsgVideoControl::Close()
 | 
|  |    843 |     {
 | 
|  |    844 |     MSGMEDIACONTROLLOGGER_ENTERFN( "MsgVideoControl : Close()" );
 | 
|  |    845 |     
 | 
|  |    846 |     Reset();
 | 
|  |    847 |     
 | 
|  |    848 |     MSGMEDIACONTROLLOGGER_LEAVEFN( "MsgVideoControl : Close()" );   
 | 
|  |    849 |     }
 | 
|  |    850 | 
 | 
|  |    851 | 
 | 
|  |    852 | // ---------------------------------------------------------
 | 
|  |    853 | // CMsgImageControl::HitRegionContains
 | 
|  |    854 | // 
 | 
|  |    855 | // Note! CONE will do final verification if control is really hit so
 | 
|  |    856 | //       not need to do it here.
 | 
|  |    857 | // ---------------------------------------------------------
 | 
|  |    858 | //
 | 
|  |    859 | #ifdef RD_SCALABLE_UI_V2
 | 
|  |    860 | TBool CMsgVideoControl::HitRegionContains( const TPoint& aPoint, 
 | 
|  |    861 |                                            const CCoeControl& /*aControl*/ ) const
 | 
|  |    862 |     {
 | 
|  |    863 |     TBool result( EFalse );
 | 
|  |    864 |     
 | 
|  |    865 |     CCoeControl* visiblePlaceholder = VisiblePlaceholder();
 | 
|  |    866 |     
 | 
|  |    867 |     if ( visiblePlaceholder )
 | 
|  |    868 |         {
 | 
|  |    869 |         result = visiblePlaceholder->Rect().Contains( aPoint );
 | 
|  |    870 |         }
 | 
|  |    871 |     else
 | 
|  |    872 |         {
 | 
|  |    873 |         result = iVideoFrameArea.Contains( aPoint );;
 | 
|  |    874 |         }
 | 
|  |    875 |         
 | 
|  |    876 |     return result;
 | 
|  |    877 |     }
 | 
|  |    878 | #else
 | 
|  |    879 | TBool CMsgVideoControl::HitRegionContains( const TPoint& /*aPoint*/, 
 | 
|  |    880 |                                            const CCoeControl& /*aControl*/ ) const
 | 
|  |    881 |     {
 | 
|  |    882 |     return EFalse;
 | 
|  |    883 |     }
 | 
|  |    884 | 
 | 
|  |    885 | #endif // RD_SCALABLE_UI_V2
 | 
|  |    886 | 
 | 
|  |    887 | // ---------------------------------------------------------
 | 
|  |    888 | // CMsgVideoControl::HandleResourceChange
 | 
|  |    889 | //
 | 
|  |    890 | // Resets inactivity timer and prevents backlight from turning
 | 
|  |    891 | // off during video playback.
 | 
|  |    892 | // ---------------------------------------------------------
 | 
|  |    893 | //
 | 
|  |    894 | TInt CMsgVideoControl::DoResetInactivityTimer( TAny* /*aObject*/ )
 | 
|  |    895 |     {
 | 
|  |    896 |     User::ResetInactivityTime();
 | 
|  |    897 |     return KErrNone;
 | 
|  |    898 |     }
 | 
|  |    899 | 
 | 
|  |    900 | // ---------------------------------------------------------
 | 
|  |    901 | // CMsgVideoControl::UpdateScaleFactorL
 | 
|  |    902 | // ---------------------------------------------------------
 | 
|  |    903 | //
 | 
|  |    904 | void CMsgVideoControl::UpdateScaleFactorL()
 | 
|  |    905 |     {
 | 
|  |    906 |     if ( iVideoPlayer )
 | 
|  |    907 |         {
 | 
|  |    908 |         TReal widthRatio = static_cast<TReal>( iSize.iWidth ) / 
 | 
|  |    909 |                            static_cast<TReal>( iOriginalSize.iWidth );
 | 
|  |    910 |         TReal heightRatio = static_cast<TReal>( iSize.iHeight ) / 
 | 
|  |    911 |                             static_cast<TReal>( iOriginalSize.iHeight );
 | 
|  |    912 |                         
 | 
|  |    913 |         iScaleFactor = widthRatio < heightRatio ? widthRatio : 
 | 
|  |    914 |                                                   heightRatio;
 | 
|  |    915 |         }
 | 
|  |    916 |     }
 | 
|  |    917 | 
 | 
|  |    918 | //  End of File
 |