videoplayback/videoplaybackview/viewsrc/mpxvideoplaybackdisplayhandler.cpp
author hgs
Fri, 06 Aug 2010 09:43:48 +0300
changeset 50 21fe8338c6bf
parent 44 518105d52e45
permissions -rw-r--r--
201031
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
44
hgs
parents:
diff changeset
     1
/*
hgs
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
hgs
parents:
diff changeset
     3
* All rights reserved.
hgs
parents:
diff changeset
     4
* This component and the accompanying materials are made available
hgs
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
hgs
parents:
diff changeset
     6
* which accompanies this distribution, and is available
hgs
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
hgs
parents:
diff changeset
     8
*
hgs
parents:
diff changeset
     9
* Initial Contributors:
hgs
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
hgs
parents:
diff changeset
    11
*
hgs
parents:
diff changeset
    12
* Contributors:
hgs
parents:
diff changeset
    13
*
hgs
parents:
diff changeset
    14
* Description:   Implementation of video playback display handler
hgs
parents:
diff changeset
    15
*
hgs
parents:
diff changeset
    16
*/
hgs
parents:
diff changeset
    17
50
hgs
parents: 44
diff changeset
    18
// Version : %version:  28 %
44
hgs
parents:
diff changeset
    19
hgs
parents:
diff changeset
    20
#include <sysutil.h>
hgs
parents:
diff changeset
    21
#include <s32file.h>
hgs
parents:
diff changeset
    22
#include <mpxcommand.h>
hgs
parents:
diff changeset
    23
#include <mpxcommandgeneraldefs.h>
hgs
parents:
diff changeset
    24
#include <mpxplaybackutility.h>
hgs
parents:
diff changeset
    25
#include <mpxvideoplaybackdefs.h>
hgs
parents:
diff changeset
    26
50
hgs
parents: 44
diff changeset
    27
#include "videocontainer.h"
44
hgs
parents:
diff changeset
    28
#include "mpxvideoviewwrapper.h"
hgs
parents:
diff changeset
    29
#include "mpxvideoplaybackdisplayhandler.h"
hgs
parents:
diff changeset
    30
#include "mpxvideoregion.h"
hgs
parents:
diff changeset
    31
#include "videoplaybackviewfiledetails.h"
hgs
parents:
diff changeset
    32
hgs
parents:
diff changeset
    33
const TInt KVIDEORESIZINGREPEATRATE = 50000;
hgs
parents:
diff changeset
    34
const TReal32 KTRANSITIONEFFECTCNT = 8;
hgs
parents:
diff changeset
    35
hgs
parents:
diff changeset
    36
_LIT( KAspectRatioFile, "c:\\private\\200159b2\\mpxvideoplayer_aspect_ratio.dat" );
hgs
parents:
diff changeset
    37
hgs
parents:
diff changeset
    38
hgs
parents:
diff changeset
    39
CMPXVideoPlaybackDisplayHandler::CMPXVideoPlaybackDisplayHandler( MMPXPlaybackUtility* aPlayUtil,
hgs
parents:
diff changeset
    40
                                                                  CMPXVideoViewWrapper* aViewWrapper )
hgs
parents:
diff changeset
    41
    : iPlaybackUtility( aPlayUtil )
hgs
parents:
diff changeset
    42
    , iTransitionEffectCnt( 0 )
hgs
parents:
diff changeset
    43
    , iViewWrapper( aViewWrapper )
hgs
parents:
diff changeset
    44
    , iScaleWidth( 100.0f )
hgs
parents:
diff changeset
    45
    , iScaleHeight( 100.0f )
hgs
parents:
diff changeset
    46
    , iHorizontalPosition( EHorizontalAlignCenter )
hgs
parents:
diff changeset
    47
    , iVerticalPosition( EVerticalAlignCenter )
hgs
parents:
diff changeset
    48
    , iRotation( EVideoRotationNone )
hgs
parents:
diff changeset
    49
    , iAutoScale( EAutoScaleBestFit )
hgs
parents:
diff changeset
    50
{
hgs
parents:
diff changeset
    51
}
hgs
parents:
diff changeset
    52
hgs
parents:
diff changeset
    53
CMPXVideoPlaybackDisplayHandler::~CMPXVideoPlaybackDisplayHandler()
hgs
parents:
diff changeset
    54
{
hgs
parents:
diff changeset
    55
    MPX_ENTER_EXIT(_L("CMPXVideoPlaybackDisplayHandler::~CMPXVideoPlaybackDisplayHandler()"));
hgs
parents:
diff changeset
    56
hgs
parents:
diff changeset
    57
    MPX_TRAPD( error, SaveAspectRatioL() );
hgs
parents:
diff changeset
    58
hgs
parents:
diff changeset
    59
    if ( iResizingTimer )
hgs
parents:
diff changeset
    60
    {
hgs
parents:
diff changeset
    61
        iResizingTimer->Cancel();
hgs
parents:
diff changeset
    62
        delete iResizingTimer;
hgs
parents:
diff changeset
    63
        iResizingTimer = NULL;
hgs
parents:
diff changeset
    64
    }
hgs
parents:
diff changeset
    65
hgs
parents:
diff changeset
    66
    iAspectRatioArray.Close();
hgs
parents:
diff changeset
    67
hgs
parents:
diff changeset
    68
    if ( iVideoDisplay )
hgs
parents:
diff changeset
    69
    {
hgs
parents:
diff changeset
    70
        SurfaceRemoved();
hgs
parents:
diff changeset
    71
hgs
parents:
diff changeset
    72
        delete iVideoDisplay;
hgs
parents:
diff changeset
    73
        iVideoDisplay = NULL;
hgs
parents:
diff changeset
    74
    }
hgs
parents:
diff changeset
    75
hgs
parents:
diff changeset
    76
	if ( iVideoContainer )
hgs
parents:
diff changeset
    77
    {
hgs
parents:
diff changeset
    78
        delete iVideoContainer;
hgs
parents:
diff changeset
    79
        iVideoContainer = NULL;
hgs
parents:
diff changeset
    80
    }
hgs
parents:
diff changeset
    81
}
hgs
parents:
diff changeset
    82
hgs
parents:
diff changeset
    83
CMPXVideoPlaybackDisplayHandler*
hgs
parents:
diff changeset
    84
CMPXVideoPlaybackDisplayHandler::NewL( MMPXPlaybackUtility* aPlayUtil,
hgs
parents:
diff changeset
    85
                                       CMPXVideoViewWrapper* aViewWrapper )
hgs
parents:
diff changeset
    86
{
hgs
parents:
diff changeset
    87
    MPX_ENTER_EXIT(_L("CMPXVideoPlaybackDisplayHandler::NewL()"));
hgs
parents:
diff changeset
    88
hgs
parents:
diff changeset
    89
    CMPXVideoPlaybackDisplayHandler* self =
hgs
parents:
diff changeset
    90
        new(ELeave) CMPXVideoPlaybackDisplayHandler( aPlayUtil, aViewWrapper );
hgs
parents:
diff changeset
    91
hgs
parents:
diff changeset
    92
    CleanupStack::PushL( self );
hgs
parents:
diff changeset
    93
    self->ConstructL();
hgs
parents:
diff changeset
    94
    CleanupStack::Pop();
hgs
parents:
diff changeset
    95
    return self;
hgs
parents:
diff changeset
    96
}
hgs
parents:
diff changeset
    97
hgs
parents:
diff changeset
    98
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
    99
//  CMPXVideoPlaybackDisplayHandler::ConstructL()
hgs
parents:
diff changeset
   100
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   101
//
hgs
parents:
diff changeset
   102
void CMPXVideoPlaybackDisplayHandler::ConstructL()
hgs
parents:
diff changeset
   103
{
hgs
parents:
diff changeset
   104
    iResizingTimer = CPeriodic::NewL( CActive::EPriorityStandard );
hgs
parents:
diff changeset
   105
    LoadAspectRatioL();
hgs
parents:
diff changeset
   106
}
hgs
parents:
diff changeset
   107
hgs
parents:
diff changeset
   108
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   109
//   CMPXVideoPlaybackDisplayHandler::CreateDisplayWindowL()
hgs
parents:
diff changeset
   110
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   111
//
hgs
parents:
diff changeset
   112
void CMPXVideoPlaybackDisplayHandler::CreateDisplayWindowL(
hgs
parents:
diff changeset
   113
                                          RWsSession& /*aWs*/,
hgs
parents:
diff changeset
   114
                                          CWsScreenDevice& aScreenDevice,
hgs
parents:
diff changeset
   115
                                          RWindow& aWin,
hgs
parents:
diff changeset
   116
                                          TRect aDisplayRect )
hgs
parents:
diff changeset
   117
{
hgs
parents:
diff changeset
   118
    MPX_ENTER_EXIT(_L("CMPXVideoPlaybackDisplayHandler::CreateDisplayWindowL()"));
hgs
parents:
diff changeset
   119
hgs
parents:
diff changeset
   120
    if ( ! iVideoContainer )
hgs
parents:
diff changeset
   121
    {
50
hgs
parents: 44
diff changeset
   122
        iVideoContainer = new ( ELeave ) CVideoContainer();
44
hgs
parents:
diff changeset
   123
        iVideoContainer->ConstructL();
hgs
parents:
diff changeset
   124
        iVideoContainer->SetRect( aDisplayRect );
hgs
parents:
diff changeset
   125
    }
hgs
parents:
diff changeset
   126
hgs
parents:
diff changeset
   127
    RWindowBase *videoWindow = iVideoContainer->DrawableWindow();
hgs
parents:
diff changeset
   128
    videoWindow->SetOrdinalPosition( -1 );
hgs
parents:
diff changeset
   129
    (&aWin)->SetOrdinalPosition( 0 );
hgs
parents:
diff changeset
   130
hgs
parents:
diff changeset
   131
    MPX_DEBUG(_L("VideoWindow ordinal position is: %d"), videoWindow->OrdinalPosition());
hgs
parents:
diff changeset
   132
    MPX_DEBUG(_L("UiWindow ordinal position is: %d"), (&aWin)->OrdinalPosition());
hgs
parents:
diff changeset
   133
hgs
parents:
diff changeset
   134
    AddDisplayWindowL( aScreenDevice, *videoWindow, (RWindow*)videoWindow );
hgs
parents:
diff changeset
   135
}
hgs
parents:
diff changeset
   136
hgs
parents:
diff changeset
   137
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   138
//   CMPXVideoPlaybackDisplayHandler::RemoveDisplayWindow()
hgs
parents:
diff changeset
   139
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   140
//
hgs
parents:
diff changeset
   141
void CMPXVideoPlaybackDisplayHandler::RemoveDisplayWindow()
hgs
parents:
diff changeset
   142
{
hgs
parents:
diff changeset
   143
    MPX_ENTER_EXIT(_L("CMPXVideoPlaybackDisplayHandler::RemoveDisplayWindow()"));
hgs
parents:
diff changeset
   144
hgs
parents:
diff changeset
   145
    if ( iVideoDisplay )
hgs
parents:
diff changeset
   146
    {
hgs
parents:
diff changeset
   147
        SurfaceRemoved();
hgs
parents:
diff changeset
   148
        delete iVideoDisplay;
hgs
parents:
diff changeset
   149
        iVideoDisplay = NULL;
hgs
parents:
diff changeset
   150
    }
hgs
parents:
diff changeset
   151
hgs
parents:
diff changeset
   152
    if ( iVideoContainer )
hgs
parents:
diff changeset
   153
    {
hgs
parents:
diff changeset
   154
        delete iVideoContainer;
hgs
parents:
diff changeset
   155
        iVideoContainer = NULL;
hgs
parents:
diff changeset
   156
    }
hgs
parents:
diff changeset
   157
hgs
parents:
diff changeset
   158
    iSurfaceId = TSurfaceId::CreateNullId();
hgs
parents:
diff changeset
   159
}
hgs
parents:
diff changeset
   160
hgs
parents:
diff changeset
   161
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   162
//   CMPXVideoPlaybackDisplayHandler::HandleVideoDisplayMessageL()
hgs
parents:
diff changeset
   163
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   164
//
hgs
parents:
diff changeset
   165
void CMPXVideoPlaybackDisplayHandler::HandleVideoDisplayMessageL( CMPXMessage* aMessage )
hgs
parents:
diff changeset
   166
{
hgs
parents:
diff changeset
   167
    MPX_ENTER_EXIT(_L("CMPXVideoPlaybackDisplayHandler::HandleVideoDisplayMessage()"));
hgs
parents:
diff changeset
   168
hgs
parents:
diff changeset
   169
    TMPXVideoDisplayCommand message =
hgs
parents:
diff changeset
   170
        ( *(aMessage->Value<TMPXVideoDisplayCommand>(KMPXMediaVideoDisplayCommand)) );
hgs
parents:
diff changeset
   171
hgs
parents:
diff changeset
   172
    MPX_DEBUG(
hgs
parents:
diff changeset
   173
      _L("CMPXVideoPlaybackDisplayHandler::HandleVideoDisplayMessageL() message = %d"), message );
hgs
parents:
diff changeset
   174
hgs
parents:
diff changeset
   175
    switch ( message )
hgs
parents:
diff changeset
   176
    {
hgs
parents:
diff changeset
   177
        case EPbMsgVideoSurfaceCreated:
hgs
parents:
diff changeset
   178
        {
hgs
parents:
diff changeset
   179
            SurfaceCreatedL( aMessage );
hgs
parents:
diff changeset
   180
            break;
hgs
parents:
diff changeset
   181
        }
hgs
parents:
diff changeset
   182
        case EPbMsgVideoSurfaceChanged:
hgs
parents:
diff changeset
   183
        {
hgs
parents:
diff changeset
   184
            SurfaceChangedL( aMessage );
hgs
parents:
diff changeset
   185
            break;
hgs
parents:
diff changeset
   186
        }
hgs
parents:
diff changeset
   187
        case EPbMsgVideoSurfaceRemoved:
hgs
parents:
diff changeset
   188
        {
hgs
parents:
diff changeset
   189
            SurfaceRemoved();
hgs
parents:
diff changeset
   190
            break;
hgs
parents:
diff changeset
   191
        }
hgs
parents:
diff changeset
   192
    }
hgs
parents:
diff changeset
   193
}
hgs
parents:
diff changeset
   194
hgs
parents:
diff changeset
   195
hgs
parents:
diff changeset
   196
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   197
//   CMPXVideoPlaybackDisplayHandler::SetAspectRatioL()
hgs
parents:
diff changeset
   198
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   199
//
hgs
parents:
diff changeset
   200
TInt CMPXVideoPlaybackDisplayHandler::SetAspectRatioL( TMPXVideoPlaybackCommand aCmd )
hgs
parents:
diff changeset
   201
{
hgs
parents:
diff changeset
   202
    MPX_DEBUG(_L("CMPXVideoPlaybackDisplayHandler::SetAspectRatioL()"));
hgs
parents:
diff changeset
   203
hgs
parents:
diff changeset
   204
    TInt aspectRatio;
hgs
parents:
diff changeset
   205
hgs
parents:
diff changeset
   206
    aspectRatio = SetNgaAspectRatioL( aCmd );
hgs
parents:
diff changeset
   207
hgs
parents:
diff changeset
   208
    //
hgs
parents:
diff changeset
   209
    //  Update the aspect ratio in the array
hgs
parents:
diff changeset
   210
    //
hgs
parents:
diff changeset
   211
    TInt count = iAspectRatioArray.Count();
hgs
parents:
diff changeset
   212
hgs
parents:
diff changeset
   213
    if ( count > 0 && count > iCurrentIndexForAspectRatio )
hgs
parents:
diff changeset
   214
    {
hgs
parents:
diff changeset
   215
        iAspectRatioArray[iCurrentIndexForAspectRatio].scalingType = (TMMFScalingType)aspectRatio;
hgs
parents:
diff changeset
   216
    }
hgs
parents:
diff changeset
   217
hgs
parents:
diff changeset
   218
    return aspectRatio;
hgs
parents:
diff changeset
   219
}
hgs
parents:
diff changeset
   220
hgs
parents:
diff changeset
   221
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   222
//   CMPXVideoPlaybackDisplayHandler::SetDefaultAspectRatioL
hgs
parents:
diff changeset
   223
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   224
//
hgs
parents:
diff changeset
   225
TInt CMPXVideoPlaybackDisplayHandler::SetDefaultAspectRatioL(
hgs
parents:
diff changeset
   226
        VideoPlaybackViewFileDetails* aFileDetails, TReal32 aDisplayAspectRatio )
hgs
parents:
diff changeset
   227
{
hgs
parents:
diff changeset
   228
    MPX_ENTER_EXIT(_L("CMPXVideoPlaybackDisplayHandler::SetDefaultAspectRatioL()"));
hgs
parents:
diff changeset
   229
hgs
parents:
diff changeset
   230
    TInt newAspectRatio = EMMFNatural;
hgs
parents:
diff changeset
   231
hgs
parents:
diff changeset
   232
    if ( aFileDetails->mVideoHeight > 0 && aFileDetails->mVideoWidth > 0 )
hgs
parents:
diff changeset
   233
    {
hgs
parents:
diff changeset
   234
        TMMFScalingType scalingType = EMMFNatural;
hgs
parents:
diff changeset
   235
hgs
parents:
diff changeset
   236
        TReal32 videoAspectRatio = (TReal32)aFileDetails->mVideoWidth /
hgs
parents:
diff changeset
   237
                                   (TReal32)aFileDetails->mVideoHeight;
hgs
parents:
diff changeset
   238
hgs
parents:
diff changeset
   239
        TInt cnt = iAspectRatioArray.Count();
hgs
parents:
diff changeset
   240
        TInt i = 0;
hgs
parents:
diff changeset
   241
hgs
parents:
diff changeset
   242
        //
hgs
parents:
diff changeset
   243
        //  check whether dat file has the information about (videoRatio + screenRatio)
hgs
parents:
diff changeset
   244
        //
hgs
parents:
diff changeset
   245
        for ( ; i < cnt ; i++ )
hgs
parents:
diff changeset
   246
        {
hgs
parents:
diff changeset
   247
            if ( iAspectRatioArray[i].videoRatio == videoAspectRatio &&
hgs
parents:
diff changeset
   248
                 iAspectRatioArray[i].screenRatio == aDisplayAspectRatio &&
hgs
parents:
diff changeset
   249
                 ( scalingType = iAspectRatioArray[i].scalingType ) > 0 )
hgs
parents:
diff changeset
   250
            {
hgs
parents:
diff changeset
   251
                break;
hgs
parents:
diff changeset
   252
            }
hgs
parents:
diff changeset
   253
        }
hgs
parents:
diff changeset
   254
hgs
parents:
diff changeset
   255
        //
hgs
parents:
diff changeset
   256
        //  if can't find out match aspect ratio in dat file,
hgs
parents:
diff changeset
   257
        //  choose the scaling type through the rule
hgs
parents:
diff changeset
   258
        //      aspectRatioDiff =  videoAspectRatio - aDisplayAspectRatio
hgs
parents:
diff changeset
   259
        //      aspectRatioDiff ==  0        ==> natural
hgs
parents:
diff changeset
   260
        //      aspectRatioDiff > 0.1        ==> zoom
hgs
parents:
diff changeset
   261
        //      aspectRatioDiff < - 0.3      ==> natural
hgs
parents:
diff changeset
   262
        //      aspectRatioDiff >= - 0.3 and <= 0.1   ==> stretch
hgs
parents:
diff changeset
   263
        //
hgs
parents:
diff changeset
   264
hgs
parents:
diff changeset
   265
        if ( i == cnt )
hgs
parents:
diff changeset
   266
        {
hgs
parents:
diff changeset
   267
            if ( videoAspectRatio - aDisplayAspectRatio > 0.1 )
hgs
parents:
diff changeset
   268
            {
hgs
parents:
diff changeset
   269
                scalingType = EMMFZoom;
hgs
parents:
diff changeset
   270
            }
hgs
parents:
diff changeset
   271
            else if ( ( videoAspectRatio != aDisplayAspectRatio ) &&
hgs
parents:
diff changeset
   272
                      ( videoAspectRatio - aDisplayAspectRatio > (- 0.3) ) )
hgs
parents:
diff changeset
   273
            {
hgs
parents:
diff changeset
   274
                scalingType = EMMFStretch;
hgs
parents:
diff changeset
   275
            }
hgs
parents:
diff changeset
   276
hgs
parents:
diff changeset
   277
            TMPXAspectRatio ratio;
hgs
parents:
diff changeset
   278
hgs
parents:
diff changeset
   279
            ratio.videoRatio = videoAspectRatio;
hgs
parents:
diff changeset
   280
            ratio.screenRatio = aDisplayAspectRatio;
hgs
parents:
diff changeset
   281
            ratio.scalingType = scalingType;
hgs
parents:
diff changeset
   282
hgs
parents:
diff changeset
   283
            iAspectRatioArray.Append( ratio );
hgs
parents:
diff changeset
   284
        }
hgs
parents:
diff changeset
   285
hgs
parents:
diff changeset
   286
        iCurrentIndexForAspectRatio = i;
hgs
parents:
diff changeset
   287
hgs
parents:
diff changeset
   288
        TMPXVideoPlaybackCommand aspectRatioCmd = EPbCmdNaturalAspectRatio;
hgs
parents:
diff changeset
   289
hgs
parents:
diff changeset
   290
        if ( scalingType == EMMFZoom )
hgs
parents:
diff changeset
   291
        {
hgs
parents:
diff changeset
   292
            aspectRatioCmd = EPbCmdZoomAspectRatio;
hgs
parents:
diff changeset
   293
        }
hgs
parents:
diff changeset
   294
        else if ( scalingType == EMMFStretch )
hgs
parents:
diff changeset
   295
        {
hgs
parents:
diff changeset
   296
            aspectRatioCmd = EPbCmdStretchAspectRatio;
hgs
parents:
diff changeset
   297
        }
hgs
parents:
diff changeset
   298
hgs
parents:
diff changeset
   299
        newAspectRatio = SetAspectRatioL( aspectRatioCmd );
hgs
parents:
diff changeset
   300
    }
hgs
parents:
diff changeset
   301
hgs
parents:
diff changeset
   302
    return newAspectRatio;
hgs
parents:
diff changeset
   303
}
hgs
parents:
diff changeset
   304
hgs
parents:
diff changeset
   305
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   306
//   CMPXVideoPlaybackDisplayHandler::SaveAspectRatioL
hgs
parents:
diff changeset
   307
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   308
//
hgs
parents:
diff changeset
   309
void CMPXVideoPlaybackDisplayHandler::SaveAspectRatioL()
hgs
parents:
diff changeset
   310
{
hgs
parents:
diff changeset
   311
    MPX_ENTER_EXIT(_L("CMPXVideoPlaybackDisplayHandler::SaveAspectRatioL"));
hgs
parents:
diff changeset
   312
hgs
parents:
diff changeset
   313
    RFs fs;
hgs
parents:
diff changeset
   314
    TInt err = fs.Connect();
hgs
parents:
diff changeset
   315
    CleanupClosePushL<RFs>( fs );
hgs
parents:
diff changeset
   316
hgs
parents:
diff changeset
   317
    TBool canSave = EFalse;
hgs
parents:
diff changeset
   318
hgs
parents:
diff changeset
   319
    TRAP_IGNORE( canSave = ! SysUtil::FFSSpaceBelowCriticalLevelL(
hgs
parents:
diff changeset
   320
                                 &fs, sizeof(TMPXAspectRatio) * iAspectRatioArray.Count()) );
hgs
parents:
diff changeset
   321
hgs
parents:
diff changeset
   322
    if ( canSave )
hgs
parents:
diff changeset
   323
    {
hgs
parents:
diff changeset
   324
        // save list to disk
hgs
parents:
diff changeset
   325
        RFileWriteStream out;
hgs
parents:
diff changeset
   326
hgs
parents:
diff changeset
   327
        TInt err( out.Replace( fs, KAspectRatioFile, EFileWrite ) );
hgs
parents:
diff changeset
   328
hgs
parents:
diff changeset
   329
        if ( err == KErrPathNotFound )
hgs
parents:
diff changeset
   330
        {
hgs
parents:
diff changeset
   331
            fs.MkDirAll( KAspectRatioFile );
hgs
parents:
diff changeset
   332
            err = out.Create( fs, KAspectRatioFile, EFileWrite );
hgs
parents:
diff changeset
   333
        }
hgs
parents:
diff changeset
   334
hgs
parents:
diff changeset
   335
        if ( ! err )
hgs
parents:
diff changeset
   336
        {
hgs
parents:
diff changeset
   337
            TInt cnt = iAspectRatioArray.Count();
hgs
parents:
diff changeset
   338
hgs
parents:
diff changeset
   339
            MPX_TRAP( err,
hgs
parents:
diff changeset
   340
            {
hgs
parents:
diff changeset
   341
                for ( TInt i = 0 ; i < cnt ; i++ )
hgs
parents:
diff changeset
   342
                {
hgs
parents:
diff changeset
   343
                    //Save (videoRatio + screenRatio + scalingType)
hgs
parents:
diff changeset
   344
                    out.WriteReal32L( iAspectRatioArray[i].videoRatio );
hgs
parents:
diff changeset
   345
                    out.WriteReal32L( iAspectRatioArray[i].screenRatio );
hgs
parents:
diff changeset
   346
                    out.WriteInt8L( iAspectRatioArray[i].scalingType );
hgs
parents:
diff changeset
   347
                }
hgs
parents:
diff changeset
   348
            } );
hgs
parents:
diff changeset
   349
hgs
parents:
diff changeset
   350
            out.Close();
hgs
parents:
diff changeset
   351
        }
hgs
parents:
diff changeset
   352
    }
hgs
parents:
diff changeset
   353
hgs
parents:
diff changeset
   354
    CleanupStack::PopAndDestroy();
hgs
parents:
diff changeset
   355
}
hgs
parents:
diff changeset
   356
hgs
parents:
diff changeset
   357
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   358
//   CMPXVideoPlaybackDisplayHandler::LoadAspectRatioL
hgs
parents:
diff changeset
   359
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   360
//
hgs
parents:
diff changeset
   361
void CMPXVideoPlaybackDisplayHandler::LoadAspectRatioL()
hgs
parents:
diff changeset
   362
{
hgs
parents:
diff changeset
   363
    MPX_ENTER_EXIT(_L("CMPXVideoPlaybackDisplayHandler::LoadAspectRatioL()"));
hgs
parents:
diff changeset
   364
hgs
parents:
diff changeset
   365
    RFs fs;
hgs
parents:
diff changeset
   366
    RFileReadStream in;
hgs
parents:
diff changeset
   367
hgs
parents:
diff changeset
   368
    TInt err = fs.Connect();
hgs
parents:
diff changeset
   369
    CleanupClosePushL<RFs>( fs );
hgs
parents:
diff changeset
   370
hgs
parents:
diff changeset
   371
    if ( ! err && in.Open( fs, KAspectRatioFile, EFileRead ) == KErrNone )
hgs
parents:
diff changeset
   372
    {
hgs
parents:
diff changeset
   373
        TMPXAspectRatio ratio;
hgs
parents:
diff changeset
   374
hgs
parents:
diff changeset
   375
        MPX_TRAP( err,
hgs
parents:
diff changeset
   376
        {
hgs
parents:
diff changeset
   377
            for ( err = KErrNone ; err == KErrNone ; )
hgs
parents:
diff changeset
   378
            {
hgs
parents:
diff changeset
   379
                //
hgs
parents:
diff changeset
   380
                //  Read (videoRatio + screenRatio + scalingType)
hgs
parents:
diff changeset
   381
                //
hgs
parents:
diff changeset
   382
                ratio.videoRatio = in.ReadReal32L();
hgs
parents:
diff changeset
   383
                ratio.screenRatio = in.ReadReal32L();
hgs
parents:
diff changeset
   384
                ratio.scalingType = (TMMFScalingType)in.ReadInt8L();
hgs
parents:
diff changeset
   385
hgs
parents:
diff changeset
   386
                iAspectRatioArray.Append( ratio );
hgs
parents:
diff changeset
   387
            }
hgs
parents:
diff changeset
   388
        } );
hgs
parents:
diff changeset
   389
hgs
parents:
diff changeset
   390
        in.Close();
hgs
parents:
diff changeset
   391
    }
hgs
parents:
diff changeset
   392
hgs
parents:
diff changeset
   393
    CleanupStack::PopAndDestroy();
hgs
parents:
diff changeset
   394
}
hgs
parents:
diff changeset
   395
hgs
parents:
diff changeset
   396
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   397
//   CMPXVideoPlaybackDisplayHandler::UpdateVideoRectL()
hgs
parents:
diff changeset
   398
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   399
//
hgs
parents:
diff changeset
   400
void CMPXVideoPlaybackDisplayHandler::UpdateVideoRectL( TRect aClipRect, TBool transitionEffect )
hgs
parents:
diff changeset
   401
{
hgs
parents:
diff changeset
   402
    MPX_ENTER_EXIT(_L("CMPXVideoPlaybackDisplayHandler::UpdateVideoRectL()"));
hgs
parents:
diff changeset
   403
hgs
parents:
diff changeset
   404
    if ( transitionEffect )
hgs
parents:
diff changeset
   405
    {
hgs
parents:
diff changeset
   406
        iTlXDiff = (TReal32)( iWindowRect.iTl.iX - aClipRect.iTl.iX ) / KTRANSITIONEFFECTCNT;
hgs
parents:
diff changeset
   407
        iTlYDiff = (TReal32)( iWindowRect.iTl.iY - aClipRect.iTl.iY ) / KTRANSITIONEFFECTCNT;
hgs
parents:
diff changeset
   408
        iBrXDiff = (TReal32)( iWindowRect.iBr.iX - aClipRect.iBr.iX ) / KTRANSITIONEFFECTCNT;
hgs
parents:
diff changeset
   409
        iBrYDiff = (TReal32)( iWindowRect.iBr.iY - aClipRect.iBr.iY ) / KTRANSITIONEFFECTCNT;
hgs
parents:
diff changeset
   410
hgs
parents:
diff changeset
   411
        if ( iResizingTimer->IsActive() )
hgs
parents:
diff changeset
   412
        {
hgs
parents:
diff changeset
   413
            iResizingTimer->Cancel();
hgs
parents:
diff changeset
   414
        }
hgs
parents:
diff changeset
   415
hgs
parents:
diff changeset
   416
        iResizingTimer->Start(
hgs
parents:
diff changeset
   417
                0,
hgs
parents:
diff changeset
   418
                KVIDEORESIZINGREPEATRATE,
hgs
parents:
diff changeset
   419
                TCallBack( CMPXVideoPlaybackDisplayHandler::UpdateVideoRectTimeOutL, this ) );
hgs
parents:
diff changeset
   420
    }
hgs
parents:
diff changeset
   421
    else
hgs
parents:
diff changeset
   422
    {
hgs
parents:
diff changeset
   423
        SetVideoRectL( aClipRect );
hgs
parents:
diff changeset
   424
hgs
parents:
diff changeset
   425
        iWindowRect = aClipRect;
hgs
parents:
diff changeset
   426
hgs
parents:
diff changeset
   427
        iViewWrapper->UpdateVideoRectDone();
hgs
parents:
diff changeset
   428
    }
hgs
parents:
diff changeset
   429
}
hgs
parents:
diff changeset
   430
hgs
parents:
diff changeset
   431
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   432
//   CMPXVideoPlaybackDisplayHandler::UpdateVideoRectTimeOutL()
hgs
parents:
diff changeset
   433
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   434
//
hgs
parents:
diff changeset
   435
TInt CMPXVideoPlaybackDisplayHandler::UpdateVideoRectTimeOutL( TAny* aPtr )
hgs
parents:
diff changeset
   436
{
hgs
parents:
diff changeset
   437
    MPX_DEBUG(_L("CMPXVideoPlaybackDisplayHandler::UpdateVideoRectTimeOutL()"));
hgs
parents:
diff changeset
   438
hgs
parents:
diff changeset
   439
    static_cast<CMPXVideoPlaybackDisplayHandler*>(aPtr)->CalculateVideoRectL();
hgs
parents:
diff changeset
   440
hgs
parents:
diff changeset
   441
    return KErrNone;
hgs
parents:
diff changeset
   442
}
hgs
parents:
diff changeset
   443
hgs
parents:
diff changeset
   444
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   445
//   CMPXVideoPlaybackDisplayHandler::CalculateVideoRectL()
hgs
parents:
diff changeset
   446
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   447
//
hgs
parents:
diff changeset
   448
void CMPXVideoPlaybackDisplayHandler::CalculateVideoRectL()
hgs
parents:
diff changeset
   449
{
hgs
parents:
diff changeset
   450
    iTransitionEffectCnt++;
hgs
parents:
diff changeset
   451
hgs
parents:
diff changeset
   452
    TRect windowRect( (TInt)( (TReal32)iWindowRect.iTl.iX - iTlXDiff * (TReal32)iTransitionEffectCnt ),
hgs
parents:
diff changeset
   453
                      (TInt)( (TReal32)iWindowRect.iTl.iY - iTlYDiff * (TReal32)iTransitionEffectCnt ),
hgs
parents:
diff changeset
   454
                      (TInt)( (TReal32)iWindowRect.iBr.iX - iBrXDiff * (TReal32)iTransitionEffectCnt ),
hgs
parents:
diff changeset
   455
                      (TInt)( (TReal32)iWindowRect.iBr.iY - iBrYDiff * (TReal32)iTransitionEffectCnt ) );
hgs
parents:
diff changeset
   456
hgs
parents:
diff changeset
   457
    MPX_DEBUG(_L("CMPXVideoPlaybackDisplayHandler::CalculateVideoRectL() %d %d %d %d"),
hgs
parents:
diff changeset
   458
            windowRect.iTl.iX, windowRect.iTl.iY, windowRect.iBr.iX, windowRect.iBr.iY );
hgs
parents:
diff changeset
   459
hgs
parents:
diff changeset
   460
    SetVideoRectL( windowRect );
hgs
parents:
diff changeset
   461
hgs
parents:
diff changeset
   462
    if ( iTransitionEffectCnt >= KTRANSITIONEFFECTCNT )
hgs
parents:
diff changeset
   463
    {
hgs
parents:
diff changeset
   464
        iTransitionEffectCnt = 0;
hgs
parents:
diff changeset
   465
        iWindowRect = windowRect;
hgs
parents:
diff changeset
   466
hgs
parents:
diff changeset
   467
        if ( iResizingTimer->IsActive() )
hgs
parents:
diff changeset
   468
        {
hgs
parents:
diff changeset
   469
            iResizingTimer->Cancel();
hgs
parents:
diff changeset
   470
        }
hgs
parents:
diff changeset
   471
hgs
parents:
diff changeset
   472
        MPX_DEBUG(_L("CMPXVideoPlaybackDisplayHandler::CalculateVideoRectL() Done"));
hgs
parents:
diff changeset
   473
hgs
parents:
diff changeset
   474
        iViewWrapper->UpdateVideoRectDone();
hgs
parents:
diff changeset
   475
    }
hgs
parents:
diff changeset
   476
}
hgs
parents:
diff changeset
   477
hgs
parents:
diff changeset
   478
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   479
//   CMPXVideoPlaybackDisplayHandler::SetVideoRectL()
hgs
parents:
diff changeset
   480
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   481
//
hgs
parents:
diff changeset
   482
void CMPXVideoPlaybackDisplayHandler::SetVideoRectL( TRect aRect )
hgs
parents:
diff changeset
   483
{
hgs
parents:
diff changeset
   484
    MPX_ENTER_EXIT(_L("CMPXVideoPlaybackDisplayHandler::SetVideoRectL()"));
hgs
parents:
diff changeset
   485
hgs
parents:
diff changeset
   486
    if ( iVideoDisplay )
hgs
parents:
diff changeset
   487
    {
hgs
parents:
diff changeset
   488
        iVideoDisplay->SetVideoExtentL( *iWindowBase, aRect, TRect( iWindowBase->Size() ) );
hgs
parents:
diff changeset
   489
    }
hgs
parents:
diff changeset
   490
}
hgs
parents:
diff changeset
   491
hgs
parents:
diff changeset
   492
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   493
//   CMPXVideoPlaybackDisplayHandler::AddDisplayWindowL()
hgs
parents:
diff changeset
   494
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   495
//
hgs
parents:
diff changeset
   496
void CMPXVideoPlaybackDisplayHandler::AddDisplayWindowL( CWsScreenDevice& aScreenDevice,
hgs
parents:
diff changeset
   497
                                                         RWindowBase& aWindowBase,
hgs
parents:
diff changeset
   498
                                                         RWindow* aWin )
hgs
parents:
diff changeset
   499
{
hgs
parents:
diff changeset
   500
    MPX_ENTER_EXIT(_L("CMPXVideoPlaybackDisplayHandler::AddDisplayWindowL()"));
hgs
parents:
diff changeset
   501
hgs
parents:
diff changeset
   502
    iWindowBase = &aWindowBase;
hgs
parents:
diff changeset
   503
hgs
parents:
diff changeset
   504
    TInt displayId = aScreenDevice.GetScreenNumber();
hgs
parents:
diff changeset
   505
hgs
parents:
diff changeset
   506
    MPX_DEBUG(_L("CMPXVideoPlaybackDisplayHandler::AddDisplayWindowL() displayId %d"), displayId);
hgs
parents:
diff changeset
   507
hgs
parents:
diff changeset
   508
    CMediaClientVideoDisplay* tempDisplay = iVideoDisplay;
hgs
parents:
diff changeset
   509
hgs
parents:
diff changeset
   510
    iVideoDisplay = CMediaClientVideoDisplay::NewL( displayId );
hgs
parents:
diff changeset
   511
hgs
parents:
diff changeset
   512
    delete tempDisplay;
hgs
parents:
diff changeset
   513
hgs
parents:
diff changeset
   514
    TRect cropRect = TRect( aWin->Size() );
hgs
parents:
diff changeset
   515
hgs
parents:
diff changeset
   516
    //
hgs
parents:
diff changeset
   517
    // If RWindow is still in potrait, rotate surface to play a video in landscape
hgs
parents:
diff changeset
   518
    //
hgs
parents:
diff changeset
   519
    if ( cropRect.Width() < cropRect.Height() )
hgs
parents:
diff changeset
   520
    {
hgs
parents:
diff changeset
   521
        iRotation = EVideoRotationClockwise90;
hgs
parents:
diff changeset
   522
    }
hgs
parents:
diff changeset
   523
hgs
parents:
diff changeset
   524
    iWindowRect = cropRect;
hgs
parents:
diff changeset
   525
hgs
parents:
diff changeset
   526
    MPX_DEBUG(_L("CMPXVideoPlaybackDisplayHandler::AddDisplayWindowL() cropRect (%d, %d), (%d, %d)"),
hgs
parents:
diff changeset
   527
        cropRect.iTl.iX, cropRect.iTl.iY, cropRect.iBr.iX, cropRect.iBr.iY);
hgs
parents:
diff changeset
   528
hgs
parents:
diff changeset
   529
    MPX_TRAPD( dispError,
hgs
parents:
diff changeset
   530
    iVideoDisplay->AddDisplayWindowL( iWindowBase,
hgs
parents:
diff changeset
   531
                                      cropRect,
hgs
parents:
diff changeset
   532
                                      cropRect,
hgs
parents:
diff changeset
   533
                                      cropRect,
hgs
parents:
diff changeset
   534
                                      iScaleWidth,
hgs
parents:
diff changeset
   535
                                      iScaleHeight,
hgs
parents:
diff changeset
   536
                                      iRotation,
hgs
parents:
diff changeset
   537
                                      iAutoScale,
hgs
parents:
diff changeset
   538
                                      iHorizontalPosition,
hgs
parents:
diff changeset
   539
                                      iVerticalPosition,
hgs
parents:
diff changeset
   540
                                      aWin );
hgs
parents:
diff changeset
   541
    );
hgs
parents:
diff changeset
   542
hgs
parents:
diff changeset
   543
    MPX_DEBUG(_L("CMPXVideoPlaybackDisplayHandler::AddDisplayWindowL() Display Added"));
hgs
parents:
diff changeset
   544
    //
hgs
parents:
diff changeset
   545
    //  Check if surface was created before window was ready
hgs
parents:
diff changeset
   546
    //
hgs
parents:
diff changeset
   547
    if ( iSurfaceCached )
hgs
parents:
diff changeset
   548
    {
hgs
parents:
diff changeset
   549
        iVideoDisplay->SurfaceCreated( iSurfaceId, iCropRect, iAspectRatio, iCropRect );
hgs
parents:
diff changeset
   550
hgs
parents:
diff changeset
   551
        iSurfaceCached = EFalse;
50
hgs
parents: 44
diff changeset
   552
hgs
parents: 44
diff changeset
   553
        //
hgs
parents: 44
diff changeset
   554
        // Let ControlsController know that we get the surface.
hgs
parents: 44
diff changeset
   555
        //
hgs
parents: 44
diff changeset
   556
        iViewWrapper->SurfacedAttached( true );
44
hgs
parents:
diff changeset
   557
    }
hgs
parents:
diff changeset
   558
}
hgs
parents:
diff changeset
   559
hgs
parents:
diff changeset
   560
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   561
//   CMPXVideoPlaybackDisplayHandler::SurfaceCreatedL()
hgs
parents:
diff changeset
   562
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   563
//
hgs
parents:
diff changeset
   564
void CMPXVideoPlaybackDisplayHandler::SurfaceCreatedL( CMPXMessage* aMessage )
hgs
parents:
diff changeset
   565
{
hgs
parents:
diff changeset
   566
    MPX_ENTER_EXIT(_L("CMPXVideoPlaybackDisplayHandler::SurfaceCreatedL()"));
hgs
parents:
diff changeset
   567
hgs
parents:
diff changeset
   568
    TSurfaceId oldSurfaceId = iSurfaceId;
hgs
parents:
diff changeset
   569
hgs
parents:
diff changeset
   570
    //
hgs
parents:
diff changeset
   571
    //  Extract the surface parameters from the message
hgs
parents:
diff changeset
   572
    //
hgs
parents:
diff changeset
   573
    iSurfaceId = aMessage->ValueTObjectL<TSurfaceId>( KMPXMediaVideoDisplayTSurfaceId );
hgs
parents:
diff changeset
   574
    iCropRect = aMessage->ValueTObjectL<TRect>( KMPXMediaVideoDisplayCropRect );
hgs
parents:
diff changeset
   575
    iAspectRatio = aMessage->ValueTObjectL<TVideoAspectRatio>( KMPXMediaVideoDisplayAspectRatio );
hgs
parents:
diff changeset
   576
hgs
parents:
diff changeset
   577
    if ( iVideoDisplay )
hgs
parents:
diff changeset
   578
    {
hgs
parents:
diff changeset
   579
        //
hgs
parents:
diff changeset
   580
        //  Remove old surface if one exists
hgs
parents:
diff changeset
   581
        //
hgs
parents:
diff changeset
   582
        if ( ! oldSurfaceId.IsNull() )
hgs
parents:
diff changeset
   583
        {
hgs
parents:
diff changeset
   584
            iVideoDisplay->RemoveSurface();
hgs
parents:
diff changeset
   585
        }
hgs
parents:
diff changeset
   586
hgs
parents:
diff changeset
   587
        //
hgs
parents:
diff changeset
   588
        //  Add new surface
hgs
parents:
diff changeset
   589
        //
hgs
parents:
diff changeset
   590
        iVideoDisplay->SurfaceCreated( iSurfaceId, iCropRect, iAspectRatio, iCropRect );
50
hgs
parents: 44
diff changeset
   591
hgs
parents: 44
diff changeset
   592
        //
hgs
parents: 44
diff changeset
   593
        // Let ControlsController know that we get the surface.
hgs
parents: 44
diff changeset
   594
        //
hgs
parents: 44
diff changeset
   595
        iViewWrapper->SurfacedAttached( true );
44
hgs
parents:
diff changeset
   596
    }
hgs
parents:
diff changeset
   597
    else
hgs
parents:
diff changeset
   598
    {
hgs
parents:
diff changeset
   599
        //
hgs
parents:
diff changeset
   600
        //  Video display has not been created yet, save surface information to create
hgs
parents:
diff changeset
   601
        //  the surface when the display is created
hgs
parents:
diff changeset
   602
        //
hgs
parents:
diff changeset
   603
        iSurfaceCached = ETrue;
hgs
parents:
diff changeset
   604
    }
hgs
parents:
diff changeset
   605
}
hgs
parents:
diff changeset
   606
hgs
parents:
diff changeset
   607
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   608
//   CMPXVideoPlaybackDisplayHandler::SurfaceChangedL()
hgs
parents:
diff changeset
   609
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   610
//
hgs
parents:
diff changeset
   611
void CMPXVideoPlaybackDisplayHandler::SurfaceChangedL( CMPXMessage* aMessage )
hgs
parents:
diff changeset
   612
{
hgs
parents:
diff changeset
   613
    MPX_ENTER_EXIT(_L("CMPXVideoPlaybackDisplayHandler::SurfaceChangedL()"));
hgs
parents:
diff changeset
   614
hgs
parents:
diff changeset
   615
    //
hgs
parents:
diff changeset
   616
    //  Extract the surface parameters from the message
hgs
parents:
diff changeset
   617
    //
hgs
parents:
diff changeset
   618
    iSurfaceId = aMessage->ValueTObjectL<TSurfaceId>( KMPXMediaVideoDisplayTSurfaceId );
hgs
parents:
diff changeset
   619
    iCropRect = aMessage->ValueTObjectL<TRect>( KMPXMediaVideoDisplayCropRect );
hgs
parents:
diff changeset
   620
    iAspectRatio = aMessage->ValueTObjectL<TVideoAspectRatio>( KMPXMediaVideoDisplayAspectRatio );
hgs
parents:
diff changeset
   621
hgs
parents:
diff changeset
   622
    if ( iVideoDisplay )
hgs
parents:
diff changeset
   623
    {
hgs
parents:
diff changeset
   624
        //
hgs
parents:
diff changeset
   625
        //  Add new surface
hgs
parents:
diff changeset
   626
        //
hgs
parents:
diff changeset
   627
        iVideoDisplay->SurfaceParametersChanged( iSurfaceId, iCropRect, iAspectRatio );
hgs
parents:
diff changeset
   628
hgs
parents:
diff changeset
   629
        iVideoDisplay->RedrawWindows( iCropRect );
hgs
parents:
diff changeset
   630
    }
hgs
parents:
diff changeset
   631
}
hgs
parents:
diff changeset
   632
hgs
parents:
diff changeset
   633
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   634
//   CMPXVideoPlaybackDisplayHandler::SurfaceRemoved()
hgs
parents:
diff changeset
   635
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   636
//
hgs
parents:
diff changeset
   637
void CMPXVideoPlaybackDisplayHandler::SurfaceRemoved()
hgs
parents:
diff changeset
   638
{
hgs
parents:
diff changeset
   639
    MPX_ENTER_EXIT(_L("CMPXVideoPlaybackDisplayHandler::SurfaceRemoved()"));
hgs
parents:
diff changeset
   640
50
hgs
parents: 44
diff changeset
   641
    //
hgs
parents: 44
diff changeset
   642
    // Let ControlsController know that we get the surface.
hgs
parents: 44
diff changeset
   643
    //
hgs
parents: 44
diff changeset
   644
    iViewWrapper->SurfacedAttached( false );
hgs
parents: 44
diff changeset
   645
44
hgs
parents:
diff changeset
   646
    if ( iVideoDisplay )
hgs
parents:
diff changeset
   647
    {
hgs
parents:
diff changeset
   648
        iVideoDisplay->RemoveSurface();
hgs
parents:
diff changeset
   649
    }
hgs
parents:
diff changeset
   650
hgs
parents:
diff changeset
   651
    iSurfaceId = TSurfaceId::CreateNullId();
hgs
parents:
diff changeset
   652
}
hgs
parents:
diff changeset
   653
hgs
parents:
diff changeset
   654
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   655
//   CMPXVideoPlaybackDisplayHandler::SetNgaAspectRatioL()
hgs
parents:
diff changeset
   656
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   657
//
hgs
parents:
diff changeset
   658
TInt CMPXVideoPlaybackDisplayHandler::SetNgaAspectRatioL( TMPXVideoPlaybackCommand aCmd )
hgs
parents:
diff changeset
   659
{
hgs
parents:
diff changeset
   660
    MPX_ENTER_EXIT(_L("CMPXVideoPlaybackDisplayHandler::SetNgaAspectRatioL()"));
hgs
parents:
diff changeset
   661
hgs
parents:
diff changeset
   662
    TInt aspectRatio = EMMFNatural;
hgs
parents:
diff changeset
   663
hgs
parents:
diff changeset
   664
    switch ( aCmd )
hgs
parents:
diff changeset
   665
    {
hgs
parents:
diff changeset
   666
        case EPbCmdNaturalAspectRatio:
hgs
parents:
diff changeset
   667
        {
hgs
parents:
diff changeset
   668
            iAutoScale = EAutoScaleBestFit;
hgs
parents:
diff changeset
   669
            aspectRatio = EMMFNatural;
hgs
parents:
diff changeset
   670
            break;
hgs
parents:
diff changeset
   671
        }
hgs
parents:
diff changeset
   672
        case EPbCmdZoomAspectRatio:
hgs
parents:
diff changeset
   673
        {
hgs
parents:
diff changeset
   674
            iAutoScale = EAutoScaleClip;
hgs
parents:
diff changeset
   675
            aspectRatio = EMMFZoom;
hgs
parents:
diff changeset
   676
            break;
hgs
parents:
diff changeset
   677
        }
hgs
parents:
diff changeset
   678
        case EPbCmdStretchAspectRatio:
hgs
parents:
diff changeset
   679
        {
hgs
parents:
diff changeset
   680
            iAutoScale = EAutoScaleStretch;
hgs
parents:
diff changeset
   681
            aspectRatio = EMMFStretch;
hgs
parents:
diff changeset
   682
            break;
hgs
parents:
diff changeset
   683
        }
hgs
parents:
diff changeset
   684
    }
hgs
parents:
diff changeset
   685
hgs
parents:
diff changeset
   686
    if ( iVideoDisplay && ! iSurfaceId.IsNull() )
hgs
parents:
diff changeset
   687
    {
hgs
parents:
diff changeset
   688
        iVideoDisplay->SetAutoScaleL( iAutoScale,
hgs
parents:
diff changeset
   689
                                      iHorizontalPosition,
hgs
parents:
diff changeset
   690
                                      iVerticalPosition,
hgs
parents:
diff changeset
   691
                                      iCropRect );
hgs
parents:
diff changeset
   692
    }
hgs
parents:
diff changeset
   693
hgs
parents:
diff changeset
   694
    return aspectRatio;
hgs
parents:
diff changeset
   695
}
hgs
parents:
diff changeset
   696
hgs
parents:
diff changeset
   697
// End of File