videoplayback/videohelix/tsrc/ut_videohelixtest/src/videohelixtestbody.cpp
changeset 0 96612d01cf9f
child 2 dec420019252
equal deleted inserted replaced
-1:000000000000 0:96612d01cf9f
       
     1 /*
       
     2 * Copyright (c) 2008 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:  Test Harness for VideoHelixPlaybackPlugin
       
    15 *
       
    16 */
       
    17 
       
    18 // Version : %version: 15 %
       
    19 
       
    20 
       
    21 // [INCLUDE FILES] - do not remove
       
    22 #include <e32svr.h>
       
    23 #include <stifparser.h>
       
    24 #include <stiftestinterface.h>
       
    25 
       
    26 #include <mpxmediageneraldefs.h>
       
    27 #include <mpxcommandgeneraldefs.h>
       
    28 #include <mmf/common/mmferrors.h>
       
    29 #include <mpxplaybackpluginversion2.h>
       
    30 #include <mpxmessagegeneraldefs.h>
       
    31 
       
    32 #include <accpolnamevaluerecord.h>
       
    33 #include <accconfigfileparser.h>
       
    34 #include <acccongenericid.h>
       
    35 #include <accpolnamevaluerecord.h>
       
    36 
       
    37 #include "dlmgr_stub.h"
       
    38 #include "mpxvideoregion.h"
       
    39 #include "videohelixtest.h"
       
    40 #include "mpxvideoaccessoryobserver_stub.h"
       
    41 #include <mpxvideoplaybackdefs.h>
       
    42 #include "mpxmediavideodefs.h"
       
    43 #include "mpxvideo_debug.h"
       
    44 #include "mpxvideoplayerutility_stub.h"
       
    45 
       
    46 #ifdef __WINSCW__
       
    47     _LIT( KVideoTestPath, "c:\\data\\Videos\\" );
       
    48 #else
       
    49     _LIT( KVideoTestPath, "f:\\testing\\data\\" );
       
    50 #endif
       
    51 
       
    52 _LIT( KOpenControllerFilename, "c:\\vhpp_openerror.txt" );
       
    53 _LIT( KPrepareControllerFilename, "c:\\vhpp_prepareerror.txt" );
       
    54 _LIT( KPlaybackCompleteFilename, "c:\\vhpp_playerror.txt" );
       
    55 _LIT( KDlMgrFile, "c:\\vhpp_dlmgr.txt" );
       
    56 _LIT( KDrmRightsFile, "c:\\vhpp_drmrights.txt" );
       
    57 
       
    58 #define ELightsNotBlinking 1
       
    59 #define ELightsBlinking 2
       
    60 // ============================ MEMBER FUNCTIONS ===============================
       
    61 
       
    62 // -----------------------------------------------------------------------------
       
    63 //  CVHPPTestClass::RunMethodL
       
    64 //  Run specified method. Contains also table of test mothods and their names.
       
    65 // -----------------------------------------------------------------------------
       
    66 //
       
    67 TInt CVHPPTestClass::RunMethodL( CStifItemParser& aItem )
       
    68 {
       
    69     static TStifFunctionInfo const KFunctions[] =
       
    70     {
       
    71         //
       
    72         //  Copy this line for every implemented function.
       
    73         //  First string is the function name used in TestScripter script file.
       
    74         //  Second is the actual implementation member function.
       
    75         //
       
    76         ENTRY( "Initialize", CVHPPTestClass::InitializeL ),
       
    77         ENTRY( "InitializeHandle", CVHPPTestClass::InitializeHandleL ),
       
    78         ENTRY( "InitializeLink", CVHPPTestClass::InitializeLinkL ),
       
    79         ENTRY( "InitializeSdp", CVHPPTestClass::InitializeSdpL ),
       
    80         ENTRY( "IssueGeneralCommand", CVHPPTestClass::IssueGeneralCommandL),
       
    81         ENTRY( "IssuePlaybackCommand", CVHPPTestClass::IssuePlaybackCommandL),
       
    82         ENTRY( "IssueVideoCommand", CVHPPTestClass::IssueVideoCommandL),
       
    83         ENTRY( "IssueSeekingCommand", CVHPPTestClass::IssueSeekingCommandL),
       
    84         ENTRY( "SetProperty", CVHPPTestClass::SetPropertyL),
       
    85         ENTRY( "GetProperty", CVHPPTestClass::GetPropertyL),
       
    86         ENTRY( "GetSubPlayerNames", CVHPPTestClass::GetSubPlayerNamesL),
       
    87         ENTRY( "SelectSubPlayer", CVHPPTestClass::SelectSubPlayerL),
       
    88         ENTRY( "SubPlayerName", CVHPPTestClass::SubPlayerName),
       
    89         ENTRY( "SubPlayerIndex", CVHPPTestClass::SubPlayerIndex),
       
    90         ENTRY( "CancelRequest", CVHPPTestClass::CancelRequest),
       
    91         ENTRY( "GetMedia", CVHPPTestClass::GetMediaL),
       
    92         ENTRY( "SetPlaybackComplete", CVHPPTestClass::SetPlaybackCompleteL),
       
    93         ENTRY( "SetUnexpectedMmfEvent", CVHPPTestClass::SetUnexpectedMmfEventL),
       
    94         ENTRY( "ConnectToDownload", CVHPPTestClass::ConnectToDownloadL),
       
    95         ENTRY( "PauseDownload", CVHPPTestClass::PauseDownloadL),
       
    96         ENTRY( "ResumeDownload", CVHPPTestClass::ResumeDownloadL),
       
    97         ENTRY( "CancelDownload", CVHPPTestClass::CancelDownloadL),
       
    98         ENTRY( "RetrievePdlStatus", CVHPPTestClass::RetrievePdlStatusL),
       
    99         ENTRY( "ChangeAspectRatioL", CVHPPTestClass::ChangeAspectRatioL),
       
   100 
       
   101         ENTRY( "AlarmOn", CVHPPTestClass::AlarmOn),
       
   102         ENTRY( "AlarmAutoResume", CVHPPTestClass::AlarmAutoResume),
       
   103         ENTRY( "PhoneCallRejected", CVHPPTestClass::PhoneCallRejected),
       
   104         ENTRY( "VoiceCallAccepted", CVHPPTestClass::VoiceCallAccepted),
       
   105         ENTRY( "VideoCallAccepted", CVHPPTestClass::VideoCallAccepted),
       
   106         ENTRY( "PlayduringVideoCall", CVHPPTestClass::PlayduringVideoCall),
       
   107         ENTRY( "PlayduringVoiceCall", CVHPPTestClass::PlayduringVoiceCall),
       
   108 
       
   109         ENTRY( "EndPhoneCall", CVHPPTestClass::EndPhoneCall),
       
   110 
       
   111         ENTRY( "SetTvOutConnected", CVHPPTestClass::SetTvOutConnectedL ),
       
   112         ENTRY( "SetTvOutDisconnected", CVHPPTestClass::SetTvOutDisconnectedL ),
       
   113         ENTRY( "ConnectTvOut", CVHPPTestClass::ConnectTvOutL ),
       
   114         ENTRY( "DisconnectTvOut", CVHPPTestClass::DisconnectTvOutL ),
       
   115 
       
   116         ENTRY( "SetDrmProtected", CVHPPTestClass::SetDrmProtectedL ),
       
   117         ENTRY( "IssueSeekedToEndCommand", CVHPPTestClass::IssueSeekedToEndCommandL),
       
   118         ENTRY( "HandleVolume", CVHPPTestClass::HandleVolumeL )  
       
   119 
       
   120 
       
   121         //
       
   122         //  ADD NEW ENTRIES HERE
       
   123         //
       
   124         // ENTRY( "SendPlayCommandToServer",
       
   125         //        CVHPPTestClass::SendPlayCommandToServer ),
       
   126         // [test cases entries] - Do not remove
       
   127     };
       
   128 
       
   129     const TInt count = sizeof( KFunctions ) / sizeof( TStifFunctionInfo );
       
   130 
       
   131     return RunInternalL( KFunctions, count, aItem );
       
   132 }
       
   133 
       
   134 void
       
   135 CVHPPTestClass::WriteControllerError( const TDesC& aFilename, TInt aData )
       
   136 {
       
   137     MPX_ENTER_EXIT(_L("CVHPPTestClass::WriteControllerError()"),
       
   138                    _L("file = %S, data = %d"), &aFilename, aData );
       
   139 
       
   140     //
       
   141     //  Write to test file so the controller open fails
       
   142     //
       
   143     RFile file;
       
   144 
       
   145     RFs fs;
       
   146     TInt error = fs.Connect();
       
   147 
       
   148     TBuf8<16> tgt;
       
   149     tgt.Num( aData );
       
   150 
       
   151     file.Replace( fs, aFilename, EFileWrite );
       
   152 
       
   153     file.Write( tgt );
       
   154 
       
   155     file.Close();
       
   156     fs.Close();
       
   157 }
       
   158 
       
   159 void
       
   160 CVHPPTestClass::CreateGeneralPlaybackCommandL( TMPXPlaybackCommand aCmd )
       
   161 {
       
   162     MPX_ENTER_EXIT(_L("CVHPPTestClass::CreateGeneralPlaybackCommandL()"),
       
   163                    _L("aCmd = %d"), aCmd );
       
   164 
       
   165     CMPXCommand* cmd = CMPXCommand::NewL();
       
   166     CleanupStack::PushL( cmd );
       
   167 
       
   168     cmd->SetTObjectValueL<TBool>( KMPXCommandGeneralDoSync, ETrue );
       
   169 
       
   170     cmd->SetTObjectValueL<TInt>( KMPXCommandGeneralId,
       
   171                                  KMPXCommandIdPlaybackGeneral );
       
   172 
       
   173     cmd->SetTObjectValueL<TInt>( KMPXCommandPlaybackGeneralType, aCmd );
       
   174 
       
   175     iPlaybackPlugin->CommandL( *cmd );
       
   176 
       
   177     CleanupStack::PopAndDestroy( cmd );
       
   178 }
       
   179 
       
   180 void
       
   181 CVHPPTestClass::PreparePluginL()
       
   182 {
       
   183     MPX_ENTER_EXIT(_L("CVHPPTestClass::PreparePluginL()"));
       
   184 
       
   185     //
       
   186     //  Set this class as the observer for the Plugin events
       
   187     //
       
   188     iLog->Log(_L("    SetObserver on Plugin"));
       
   189     iPlaybackPlugin->SetObserver( *this );
       
   190 
       
   191     //
       
   192     //  Create Playback Message
       
   193     //
       
   194     iLog->Log(_L("    Close the Plugin"));
       
   195     CreateGeneralPlaybackCommandL( EPbCmdClose );
       
   196 }
       
   197 
       
   198 TInt
       
   199 CVHPPTestClass::ReadFileInitializationParameters( CStifItemParser& aItem, TDes& aFilename )
       
   200 {
       
   201     MPX_ENTER_EXIT(_L("CVHPPTestClass::ReadFileInitializationParameters()"));
       
   202 
       
   203     TPtrC filename;
       
   204 
       
   205     //
       
   206     //  Read in the filename from the config file
       
   207     //
       
   208     TInt err = aItem.GetNextString( filename );
       
   209 
       
   210     if ( err == KErrNone )
       
   211     {
       
   212         //
       
   213         //  Build the full path to the file
       
   214         //
       
   215         aFilename.Append( KVideoTestPath );
       
   216         aFilename.Append( filename );
       
   217 
       
   218         err = ReadInitializationErrors( aItem );
       
   219     }
       
   220 
       
   221     return err;
       
   222 }
       
   223 
       
   224 TInt
       
   225 CVHPPTestClass::ReadInitializationErrors( CStifItemParser& aItem )
       
   226 {
       
   227     TInt err;
       
   228     TInt initError;
       
   229     TInt openError;
       
   230     TInt prepError;
       
   231 
       
   232     //
       
   233     //  Read in the expected init error code
       
   234     //
       
   235     err = aItem.GetNextInt( initError );
       
   236 
       
   237     if ( err == KErrNone && initError != KErrNone )
       
   238     {
       
   239         AddErrorEvent( initError );
       
   240     }
       
   241     else
       
   242     {
       
   243         //
       
   244         //  Read in the expected open complete error code
       
   245         //
       
   246         err = aItem.GetNextInt( openError );
       
   247 
       
   248         WriteControllerError( KOpenControllerFilename, openError );
       
   249 
       
   250         if ( err == KErrNone && openError != KErrNone )
       
   251         {
       
   252             AddErrorEvent( openError );
       
   253         }
       
   254         else
       
   255         {
       
   256             //
       
   257             //  Open Complete does not return error
       
   258             //  Read in the expected prepare complete error code
       
   259             //
       
   260             err = aItem.GetNextInt( prepError );
       
   261 
       
   262             WriteControllerError( KPrepareControllerFilename, prepError );
       
   263 
       
   264             if ( err == KErrNone && prepError != KErrNone )
       
   265             {
       
   266                 AddErrorEvent( prepError );
       
   267             }
       
   268         }
       
   269     }
       
   270 
       
   271     return err;
       
   272 }
       
   273 
       
   274 // -----------------------------------------------------------------------------
       
   275 //  CVHPPTestClass::InitializeL
       
   276 //  Test creation of a general playback command.
       
   277 // -----------------------------------------------------------------------------
       
   278 //
       
   279 TInt
       
   280 CVHPPTestClass::InitializeL( CStifItemParser& aItem )
       
   281 {
       
   282     MPX_ENTER_EXIT(_L("CVHPPTestClass::InitializeL()"));
       
   283     iLog->Log(_L("CVHPPTestClass::InitializeL()"));
       
   284 
       
   285     TInt duration;
       
   286     TInt volumeSteps;
       
   287     
       
   288     TInt err = aItem.GetNextInt( duration );
       
   289 
       
   290     if ( err == KErrNone )
       
   291     {
       
   292         //
       
   293         //  We will always get an Init Complete message out
       
   294         //
       
   295         TCallbackEvent* event = new TCallbackEvent;
       
   296 
       
   297         event->iEvent = EPInitialised;
       
   298         event->iData  = duration;
       
   299         event->iError = KErrNone;
       
   300 
       
   301         AddExpectedEvent( event );
       
   302 
       
   303         // 
       
   304         // read number of volume steps
       
   305         //
       
   306         err = aItem.GetNextInt( volumeSteps );
       
   307         
       
   308         if ( err == KErrNone )
       
   309         {        
       
   310             //
       
   311             // set volume steps
       
   312             //
       
   313             SetVolumeSteps( volumeSteps );
       
   314             
       
   315             TBuf<120> fullPath;    
       
   316 
       
   317             err = ReadFileInitializationParameters( aItem, fullPath );
       
   318     
       
   319             if ( err == KErrNone )
       
   320             {
       
   321                 PreparePluginL();
       
   322     
       
   323                 //
       
   324                 //  Initalize the Plugin with a file name
       
   325                 //
       
   326                 MPX_DEBUG(_L("Initialize the Plugin:  filename = %S"), &fullPath);
       
   327                 iLog->Log(_L("Initialize the Plugin:  filename = %S"), &fullPath);
       
   328     
       
   329                 iPlaybackPlugin->InitialiseL( fullPath );
       
   330             }
       
   331         }
       
   332     }
       
   333 
       
   334     return err;
       
   335 }
       
   336 
       
   337 // -----------------------------------------------------------------------------
       
   338 //  CVHPPTestClass::InitializeLinkL
       
   339 //  Test creation of a general playback command.
       
   340 // -----------------------------------------------------------------------------
       
   341 //
       
   342 TInt
       
   343 CVHPPTestClass::InitializeLinkL( CStifItemParser& aItem )
       
   344 {
       
   345     MPX_ENTER_EXIT(_L("CVHPPTestClass::InitializeLinkL()"));
       
   346     iLog->Log(_L("CVHPPTestClass::InitializeLinkL()"));
       
   347 
       
   348     TInt duration;
       
   349     TInt volumeSteps;
       
   350     TInt err = aItem.GetNextInt( duration );
       
   351 
       
   352     if ( err == KErrNone )
       
   353     {
       
   354         //
       
   355         //  We will always get an Init Complete message out
       
   356         //
       
   357         TCallbackEvent* event = new TCallbackEvent;
       
   358 
       
   359         event->iEvent = EPInitialised;
       
   360         event->iData  = duration;
       
   361         event->iError = KErrNone;
       
   362 
       
   363         AddExpectedEvent( event );
       
   364 
       
   365         // 
       
   366         // read number of volume steps
       
   367         //
       
   368         err = aItem.GetNextInt( volumeSteps );
       
   369         
       
   370         if ( err == KErrNone )
       
   371         {        
       
   372             //
       
   373             // set volume steps
       
   374             //
       
   375             SetVolumeSteps( volumeSteps );
       
   376         
       
   377             TPtrC  link;
       
   378     
       
   379             //
       
   380             //  Read in the link from the config file
       
   381             //
       
   382             TInt err = aItem.GetNextString( link );
       
   383     
       
   384             if ( err == KErrNone )
       
   385             {
       
   386                 TInt err = ReadInitializationErrors( aItem );
       
   387     
       
   388                 if ( err == KErrNone )
       
   389                 {
       
   390                     PreparePluginL();
       
   391     
       
   392                     //
       
   393                     //  Extract the streaming link from the ram file and
       
   394                     //  Initalize the Plugin with the link and an access point
       
   395                     //
       
   396                     MPX_DEBUG(_L("Initialize the Plugin:  link = %S"), &link);
       
   397                     iLog->Log(_L("Initialize the Plugin:  link = %S"), &link);
       
   398     
       
   399                     iPlaybackPlugin->InitStreamingL( link, KNullDesC8, 11 );
       
   400                 }
       
   401             }
       
   402         }
       
   403     }
       
   404 
       
   405     return err;
       
   406 }
       
   407 
       
   408 // -----------------------------------------------------------------------------
       
   409 //  CVHPPTestClass::InitializeSdpL
       
   410 //  Test creation of a general playback command.
       
   411 // -----------------------------------------------------------------------------
       
   412 //
       
   413 TInt
       
   414 CVHPPTestClass::InitializeSdpL( CStifItemParser& /*aItem*/ )
       
   415 {
       
   416     MPX_ENTER_EXIT(_L("CVHPPTestClass::InitializeSdpL()"));
       
   417     iLog->Log(_L("CVHPPTestClass::InitializeSdpL()"));
       
   418 
       
   419     TBuf<120> fullPath;
       
   420     TInt      initError = KErrNone;
       
   421 
       
   422     TInt err = KErrNone;// = ReadInitializationParameters( aItem, fullPath, initError );
       
   423 
       
   424     if ( err == KErrNone )
       
   425     {
       
   426         PreparePluginL();
       
   427 
       
   428         MPX_DEBUG(_L("Initialize the Plugin:  filename = %S"), &fullPath);
       
   429         iLog->Log(_L("Initialize the Plugin:  filename = %S"), &fullPath);
       
   430 
       
   431 
       
   432         TRAPD( err,
       
   433                static_cast<CMPXPlaybackPluginVersion2*>(iPlaybackPlugin)->InitStreamingL
       
   434                                      ( fullPath, KNullDesC8, 11 );
       
   435               );
       
   436 
       
   437         MPX_DEBUG(_L("CVHPPTestClass::InitialisePluginL(%d)"), err);
       
   438 
       
   439         if ( err == initError )
       
   440         {
       
   441             MPX_DEBUG(_L("InitialiseL() returned proper error %d"), err);
       
   442             iLog->Log(_L("InitialiseL() returned proper error %d"), err);
       
   443             err = KErrNone;
       
   444         }
       
   445     }
       
   446 
       
   447     return err;
       
   448 }
       
   449 
       
   450 
       
   451 TInt
       
   452 CVHPPTestClass::InitializeHandleL( CStifItemParser& aItem  )
       
   453 {
       
   454     MPX_ENTER_EXIT(_L("CVHPPTestClass::InitializeHandleL()"));
       
   455     iLog->Log(_L("CVHPPTestClass::InitializeHandleL()"));
       
   456 
       
   457     TInt duration;
       
   458     TInt volumeSteps;
       
   459     TInt fileHandle32;
       
   460     
       
   461     TInt err = aItem.GetNextInt( fileHandle32 );
       
   462     
       
   463     if ( err == KErrNone )
       
   464     {        
       
   465     
       
   466 #ifndef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
       
   467         //
       
   468         // set RFile as default if the 64-bit flag is not defined
       
   469         //
       
   470         fileHandle32 = ETrue;
       
   471 #endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
       
   472         
       
   473         err = aItem.GetNextInt( duration );
       
   474     
       
   475         if ( err == KErrNone )
       
   476         {
       
   477             //
       
   478             //  We will always get an Init Complete message out
       
   479             //
       
   480             TCallbackEvent* event = new TCallbackEvent;
       
   481     
       
   482             event->iEvent = EPInitialised;
       
   483             event->iData  = duration;
       
   484             event->iError = KErrNone;
       
   485     
       
   486             AddExpectedEvent( event );
       
   487     
       
   488             // 
       
   489             // read number of volume steps
       
   490             //
       
   491             err = aItem.GetNextInt( volumeSteps );
       
   492             
       
   493             if ( err == KErrNone )
       
   494             {        
       
   495                 //
       
   496                 // set volume steps
       
   497                 //
       
   498                 SetVolumeSteps( volumeSteps );
       
   499             
       
   500                 TBuf<120> fullPath;
       
   501         
       
   502                 err = ReadFileInitializationParameters( aItem, fullPath );
       
   503         
       
   504                 if ( err == KErrNone )
       
   505                 {
       
   506                     PreparePluginL();
       
   507         
       
   508                     RFs fs;
       
   509                     TInt error = fs.Connect();
       
   510                     
       
   511                     //
       
   512                     //  Open a file handle to the clip
       
   513                     //
       
   514                     if ( fileHandle32 )
       
   515                     {
       
   516                         RFile file;
       
   517                         User::LeaveIfError( file.Open( fs, fullPath, EFileRead ) );
       
   518                         iPlaybackPlugin->InitialiseL( file );
       
   519                         file.Close();
       
   520                     }
       
   521 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
       
   522                     else
       
   523                     {
       
   524                         RFile64 file64;
       
   525                         User::LeaveIfError( file64.Open( fs, fullPath, EFileRead ) );
       
   526                         iPlaybackPlugin->Initialise64L( file64 );
       
   527                         file64.Close();
       
   528                     }
       
   529 #endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
       
   530                             
       
   531                     //
       
   532                     //  Initalize the Plugin with a file name
       
   533                     //
       
   534                     MPX_DEBUG(_L("Initialize the Plugin with File Handle:  filename = %S"), &fullPath);
       
   535                     iLog->Log(_L("Initialize the Plugin with File Handle:  filename = %S"), &fullPath);
       
   536             
       
   537                     fs.Close();
       
   538                 }
       
   539             } 
       
   540         } 
       
   541     } 
       
   542 
       
   543     return err;
       
   544 }
       
   545 
       
   546 TRect
       
   547 CVHPPTestClass::ReadRect( CStifItemParser& aItem )
       
   548 {
       
   549     MPX_ENTER_EXIT(_L("CVHPPTestClass::ReadRect()"));
       
   550 
       
   551     TRect rect;
       
   552 
       
   553     TInt value;
       
   554 
       
   555     if ( ! aItem.GetNextInt( value ) )
       
   556     {
       
   557         rect.iTl.iX = value;
       
   558 
       
   559         if ( ! aItem.GetNextInt( value ) )
       
   560         {
       
   561             rect.iTl.iY = value;
       
   562 
       
   563             if ( ! aItem.GetNextInt( value ) )
       
   564             {
       
   565                 rect.iBr.iX = value;
       
   566 
       
   567                 if ( ! aItem.GetNextInt( value ) )
       
   568                 {
       
   569                     rect.iBr.iY = value;
       
   570                 }
       
   571             }
       
   572         }
       
   573     }
       
   574 
       
   575     return rect;
       
   576 }
       
   577 
       
   578 void
       
   579 CVHPPTestClass::CreateVideoPlaybackCommandL( CStifItemParser& aItem,
       
   580                                              TMPXVideoPlaybackCommand aCmd )
       
   581 {
       
   582     MPX_ENTER_EXIT(_L("CVHPPTestClass::CreateVideoPlaybackCommandL()"),
       
   583                    _L("aCmd = %d"), aCmd );
       
   584 
       
   585     //
       
   586     //  create command to pass to playback plugin
       
   587     //
       
   588     CMPXCommand* cmd = CMPXCommand::NewL();
       
   589     CleanupStack::PushL( cmd );
       
   590 
       
   591     cmd->SetTObjectValueL<TBool>( KMPXCommandGeneralDoSync, ETrue );
       
   592 
       
   593     cmd->SetTObjectValueL<TInt>( KMPXCommandGeneralId,
       
   594                                  KMPXMediaIdVideoPlayback );
       
   595 
       
   596     cmd->SetTObjectValueL<TInt>( KMPXMediaVideoPlaybackCommand, aCmd );
       
   597 
       
   598     switch ( aCmd )
       
   599     {
       
   600         case EPbCmdRestartDSA:
       
   601         {
       
   602             TRect rect = ReadRect( aItem );
       
   603             RRegion region( rect );
       
   604 
       
   605             CMPXVideoRegion* vidReg = CMPXVideoRegion::NewL();
       
   606             CleanupStack::PushL( vidReg );
       
   607 
       
   608             vidReg->SetRegion( region );
       
   609 
       
   610             vidReg->Print();
       
   611 
       
   612             cmd->SetCObjectValueL<CMPXVideoRegion>( KMPXMediaVideoPlaybackDSARegion, vidReg );
       
   613 
       
   614             CleanupStack::PopAndDestroy( vidReg );
       
   615 
       
   616             break;
       
   617         }
       
   618         case EPbCmdSetDisplayWindow:
       
   619         {
       
   620             TRect rect = ReadRect( aItem );
       
   621             RRegion region( rect );
       
   622 
       
   623             CMPXVideoRegion* vidReg = CMPXVideoRegion::NewL();
       
   624             CleanupStack::PushL( vidReg );
       
   625 
       
   626             vidReg->SetRegion( region);
       
   627 
       
   628             vidReg->Print();
       
   629 
       
   630             cmd->SetTObjectValueL<TRect>( KMPXMediaVideoPlaybackTRect, rect );
       
   631 
       
   632             cmd->SetCObjectValueL<CMPXVideoRegion>( KMPXMediaVideoPlaybackDSARegion, vidReg );
       
   633 
       
   634             CleanupStack::PopAndDestroy( vidReg );
       
   635 
       
   636             break;
       
   637         }
       
   638     }
       
   639 
       
   640     iPlaybackPlugin->CommandL( *cmd );
       
   641 
       
   642     CleanupStack::PopAndDestroy( cmd );
       
   643 }
       
   644 
       
   645 // -----------------------------------------------------------------------------
       
   646 //  CVHPPTestClass::IssueVideoCommandL
       
   647 //  Test creation of a general playback command.
       
   648 // -----------------------------------------------------------------------------
       
   649 //
       
   650 TInt
       
   651 CVHPPTestClass::IssueVideoCommandL( CStifItemParser& aItem )
       
   652 {
       
   653     MPX_ENTER_EXIT(_L("CVHPPTestClass::IssueVideoCommandL()"));
       
   654     iLog->Log(_L("CVHPPTestClass::IssueVideoCommandL()"));
       
   655 
       
   656     TInt vidCmd;
       
   657     TInt err = aItem.GetNextInt( vidCmd );
       
   658 
       
   659     if ( err == KErrNone )
       
   660     {
       
   661         TCallbackEvent* event = new TCallbackEvent;
       
   662 
       
   663         event->iEvent = vidCmd;
       
   664         event->iData  = 0;
       
   665         event->iError = KErrNone;
       
   666 
       
   667         AddExpectedEvent( event );
       
   668 
       
   669         CreateVideoPlaybackCommandL( aItem, (TMPXVideoPlaybackCommand)vidCmd );
       
   670     }
       
   671 
       
   672     return KErrNone;
       
   673 }
       
   674 
       
   675 TInt
       
   676 CVHPPTestClass::IssueSeekingCommandL( CStifItemParser& aItem )
       
   677 {
       
   678     MPX_ENTER_EXIT(_L("CVHPPTestClass::IssueSeekingCommandL()"));
       
   679     iLog->Log(_L("CVHPPTestClass::IssueSeekingCommandL()"));
       
   680 
       
   681     TInt vidCmd;
       
   682     TInt err = aItem.GetNextInt( vidCmd );
       
   683 
       
   684     //
       
   685     //  Seeking is starting, allow posiiton callbacks
       
   686     //
       
   687     iAllowPositionCallback = ETrue;
       
   688 
       
   689     if ( err == KErrNone )
       
   690     {
       
   691         TCallbackEvent* event = new TCallbackEvent;
       
   692 
       
   693         if ( vidCmd == EPbCmdStartVideoSeekingForward || vidCmd == EPbCmdStartVideoSeekingBackward )
       
   694         {
       
   695             TBool addEvent = ETrue;
       
   696 
       
   697             aItem.GetNextInt( addEvent );
       
   698 
       
   699             if ( addEvent )
       
   700             {
       
   701                 event->iEvent = EPPluginSeeking;
       
   702                 event->iData  = 0;
       
   703                 event->iError = KErrNone;
       
   704                 AddExpectedEvent( event );
       
   705             }
       
   706         }
       
   707         else if ( vidCmd == EPbCmdStopVideoSeeking )
       
   708         {
       
   709             TInt callbackEvent;
       
   710             aItem.GetNextInt( callbackEvent );
       
   711 
       
   712             if ( callbackEvent )
       
   713             {
       
   714                 event->iEvent = callbackEvent;
       
   715                 event->iData  = 0;
       
   716                 event->iError = KErrNone;
       
   717                 AddExpectedEvent( event );
       
   718 
       
   719                 iAllowPositionCallback = EFalse;
       
   720             }
       
   721         }
       
   722 
       
   723         CreateVideoPlaybackCommandL( aItem, (TMPXVideoPlaybackCommand)vidCmd );
       
   724     }
       
   725 
       
   726     return KErrNone;
       
   727 }
       
   728 
       
   729 // -----------------------------------------------------------------------------
       
   730 //  CVHPPTestClass::IssueSeekedToEndCommandL
       
   731 //  Test creation of a End of Clip command.
       
   732 // -----------------------------------------------------------------------------
       
   733 //
       
   734 TInt
       
   735 CVHPPTestClass::IssueSeekedToEndCommandL( CStifItemParser& aItem )
       
   736 {
       
   737     MPX_ENTER_EXIT(_L("CVHPPTestClass::IssueSeekedToEndCommandL()"));
       
   738     iLog->Log(_L("CVHPPTestClass::IssueSeekedToEndCommandL()"));
       
   739 
       
   740     TCallbackEvent* event = new TCallbackEvent;
       
   741 
       
   742     event->iEvent = EPPlayComplete;
       
   743     event->iData  = 0;
       
   744     event->iError = KErrNone;
       
   745 
       
   746     AddExpectedEvent( event );
       
   747 
       
   748     CreateVideoPlaybackCommandL( aItem, EPbCmdEndofClipReached);
       
   749 
       
   750     return KErrNone;
       
   751 }
       
   752 
       
   753 TInt
       
   754 CVHPPTestClass::ParsePlaybackCommand( CStifItemParser& aItem, TInt& aCmd )
       
   755 {
       
   756     MPX_ENTER_EXIT(_L("CVHPPTestClass::ParsePlaybackCommand()"));
       
   757 
       
   758     TInt err = aItem.GetNextInt( aCmd );
       
   759 
       
   760     if ( err == KErrNone )
       
   761     {
       
   762         TCallbackEvent* event = new TCallbackEvent;
       
   763         event->iData  = 0;
       
   764 
       
   765         err = aItem.GetNextInt( event->iError );
       
   766 
       
   767         if ( err == KErrNone )
       
   768         {
       
   769             if ( event->iError == KErrNotSupported )
       
   770             {
       
   771                 delete event;
       
   772             }
       
   773             else
       
   774             {
       
   775                 err = aItem.GetNextInt( event->iEvent );
       
   776 
       
   777                 if ( err == KErrNone )
       
   778                 {
       
   779                     if ( event->iEvent == EPBufferingStarted )
       
   780                     {
       
   781                         //
       
   782                         //  A playing command will be added also
       
   783                         //
       
   784                         AddExpectedEvent( event );
       
   785 
       
   786                         event = new TCallbackEvent;
       
   787                         event->iEvent = EPPlaying;
       
   788                         event->iData  = 0;
       
   789                         event->iError = KErrNone;
       
   790                     }
       
   791 
       
   792                     AddExpectedEvent( event );
       
   793                 }
       
   794             }
       
   795         }
       
   796     }
       
   797 
       
   798     return err;
       
   799 }
       
   800 
       
   801 // -----------------------------------------------------------------------------
       
   802 //  CVHPPTestClass::IssueGeneralCommandL
       
   803 //  Test creation of a general playback command.
       
   804 // -----------------------------------------------------------------------------
       
   805 //
       
   806 TInt
       
   807 CVHPPTestClass::IssueGeneralCommandL( CStifItemParser& aItem )
       
   808 {
       
   809     MPX_ENTER_EXIT(_L("CVHPPTestClass::IssueGeneralCommandL()"));
       
   810     iLog->Log(_L("CVHPPTestClass::IssueGeneralCommandL()"));
       
   811 
       
   812     TInt genCmd = 0;
       
   813 
       
   814     TInt error = ParsePlaybackCommand( aItem, genCmd );
       
   815 
       
   816     if ( error == KErrNone )
       
   817     {
       
   818         CreateGeneralPlaybackCommandL( (TMPXPlaybackCommand)genCmd );
       
   819     }
       
   820 
       
   821     return error;
       
   822 }
       
   823 
       
   824 TInt
       
   825 CVHPPTestClass::IssuePlaybackCommandL( CStifItemParser& aItem )
       
   826 {
       
   827     MPX_ENTER_EXIT(_L("CVHPPTestClass::IssuePlaybackCommandL()"));
       
   828     iLog->Log(_L("CVHPPTestClass::IssuePlaybackCommandL()"));
       
   829 
       
   830     TInt genCmd;
       
   831 
       
   832     TInt error = ParsePlaybackCommand( aItem, genCmd );
       
   833 
       
   834     if ( error == KErrNone )
       
   835     {
       
   836         iPlaybackPlugin->CommandL( (TMPXPlaybackCommand)genCmd, 0 );
       
   837     }
       
   838 
       
   839     return error;
       
   840 }
       
   841 
       
   842 TInt
       
   843 CVHPPTestClass::SetPropertyL( CStifItemParser& aItem )
       
   844 {
       
   845     MPX_ENTER_EXIT(_L("CVHPPTestClass::SetPropertyL()"));
       
   846     iLog->Log(_L("CVHPPTestClass::SetPropertyL()"));
       
   847 
       
   848     TInt property;
       
   849     TInt value;
       
   850 
       
   851     TInt trapErr = KErrNone;
       
   852     TInt err = aItem.GetNextInt( property );
       
   853 
       
   854     if ( err == KErrNone )
       
   855     {
       
   856         err = aItem.GetNextInt( value );
       
   857 
       
   858         if ( err == KErrNone )
       
   859         {
       
   860             if ( property >= EPbPropertyNum )
       
   861             {
       
   862                 trapErr = KErrNotSupported;
       
   863             }
       
   864             else
       
   865             {
       
   866                 TCallbackEvent* event = new TCallbackEvent;
       
   867 
       
   868                 if ( property == EPbPropertyVolume )
       
   869                 {
       
   870                     TInt addEvent;
       
   871                     err = aItem.GetNextInt( addEvent );
       
   872 
       
   873                     if ( err == KErrNone && addEvent )
       
   874                     {
       
   875                         event->iEvent = EPVolumeChanged;
       
   876                         event->iData  = value;
       
   877                         event->iError = KErrNone;
       
   878                         AddExpectedEvent( event );
       
   879                     }
       
   880                 }
       
   881                 else if ( property == EPbPropertyMute )
       
   882                 {
       
   883                     event->iEvent = EPMuteChanged;
       
   884                     event->iData  = value;
       
   885                     event->iError = KErrNone;
       
   886                     AddExpectedEvent( event );
       
   887                 }
       
   888 				else
       
   889 				{
       
   890 					event->iEvent = EPSetComplete;
       
   891 					event->iData  = property;
       
   892 					event->iError = KErrNone;
       
   893 					AddExpectedEvent( event );
       
   894 				}
       
   895 				
       
   896             }
       
   897 
       
   898             TRAP( err, iPlaybackPlugin->SetL( (TMPXPlaybackProperty)property, value ) );
       
   899         }
       
   900     }
       
   901 
       
   902     if ( err == trapErr )
       
   903     {
       
   904         MPX_DEBUG(_L("CVHPPTestClass::SetPropertyL() leaves with proper error"));
       
   905         err = KErrNone;
       
   906     }
       
   907 
       
   908     return err;
       
   909 }
       
   910 
       
   911 TInt
       
   912 CVHPPTestClass::GetPropertyL( CStifItemParser& aItem )
       
   913 {
       
   914     MPX_ENTER_EXIT(_L("CVHPPTestClass::GetPropertyL()"));
       
   915     iLog->Log(_L("CVHPPTestClass::GetPropertyL()"));
       
   916 
       
   917     TInt property;
       
   918     TInt value;
       
   919 
       
   920     TInt trapErr = KErrNone;
       
   921 
       
   922     TInt err = aItem.GetNextInt( property );
       
   923 
       
   924     if ( err == KErrNone )
       
   925     {
       
   926         err = aItem.GetNextInt( value );
       
   927 
       
   928         if ( err == KErrNone )
       
   929         {
       
   930             if ( property >= EPbPropertyNum )
       
   931             {
       
   932                 trapErr = KErrNotSupported;
       
   933             }
       
   934             else
       
   935             {
       
   936                 TCallbackEvent* event = new TCallbackEvent;
       
   937 
       
   938                 event->iEvent = property;
       
   939                 event->iData  = value;
       
   940                 event->iError = KErrNone;
       
   941 
       
   942                 AddExpectedEvent( event );
       
   943             }
       
   944 
       
   945             TRAP( err, iPlaybackPlugin->PropertyL( (TMPXPlaybackProperty)property ) );
       
   946         }
       
   947     }
       
   948 
       
   949     if ( err == trapErr )
       
   950     {
       
   951         MPX_DEBUG(_L("CVHPPTestClass::GetPropertyL() leaves with proper error"));
       
   952         err = KErrNone;
       
   953     }
       
   954 
       
   955     return err;
       
   956 }
       
   957 
       
   958 TInt
       
   959 CVHPPTestClass::GetSubPlayerNamesL( CStifItemParser& /*aItem*/ )
       
   960 {
       
   961     MPX_ENTER_EXIT(_L("CVHPPTestClass::GetSubPlayerNamesL()"));
       
   962     iLog->Log(_L("CVHPPTestClass::GetSubPlayerNmaesL()"));
       
   963 
       
   964     iPlaybackPlugin->SubPlayerNamesL();
       
   965 
       
   966     return KErrNone;
       
   967 }
       
   968 
       
   969 TInt
       
   970 CVHPPTestClass::SelectSubPlayerL( CStifItemParser& /*aItem*/ )
       
   971 {
       
   972     MPX_ENTER_EXIT(_L("CVHPPTestClass::SelectSubPlayerL()"));
       
   973     iLog->Log(_L("CVHPPTestClass::SelectSubPlayerL()"));
       
   974 
       
   975     TRAPD( err, iPlaybackPlugin->SelectSubPlayerL( 1 ); );
       
   976 
       
   977     if ( err == KErrNotSupported )
       
   978     {
       
   979         err = KErrNone;
       
   980     }
       
   981 
       
   982     return err;
       
   983 }
       
   984 
       
   985 TInt
       
   986 CVHPPTestClass::SubPlayerName( CStifItemParser& /*aItem*/ )
       
   987 {
       
   988     MPX_ENTER_EXIT(_L("CVHPPTestClass::SubPlayerName()"));
       
   989     iLog->Log(_L("CVHPPTestClass::SubPlayerName()"));
       
   990 
       
   991     TInt err = KErrNone;
       
   992 
       
   993     TDesC name = iPlaybackPlugin->SubPlayerName();
       
   994 
       
   995     if ( name != KNullDesC )
       
   996     {
       
   997         err = KErrNotFound;
       
   998     }
       
   999 
       
  1000     return err;
       
  1001 }
       
  1002 
       
  1003 TInt
       
  1004 CVHPPTestClass::SubPlayerIndex( CStifItemParser& /*aItem*/ )
       
  1005 {
       
  1006     MPX_ENTER_EXIT(_L("CVHPPTestClass::SubPlayerIndex()"));
       
  1007     iLog->Log(_L("CVHPPTestClass::SubPlayerIndex()"));
       
  1008 
       
  1009     TInt err = iPlaybackPlugin->SubPlayerIndex();
       
  1010 
       
  1011     if ( err == KErrNotFound )
       
  1012     {
       
  1013         err = KErrNone;
       
  1014     }
       
  1015 
       
  1016     return err;
       
  1017 }
       
  1018 
       
  1019 TInt
       
  1020 CVHPPTestClass::GetMediaL( CStifItemParser& /*aItem*/ )
       
  1021 {
       
  1022     MPX_ENTER_EXIT(_L("CVHPPTestClass::GetMediaL()"));
       
  1023     iLog->Log(_L("CVHPPTestClass::GetMediaL()"));
       
  1024 
       
  1025     RArray<TMPXAttribute> attrs;
       
  1026     CleanupClosePushL(attrs);
       
  1027 
       
  1028     // TMPXAttribute attr( KMPXMediaGeneralAll );
       
  1029 
       
  1030     attrs.Append( KMPXMediaGeneralAll );
       
  1031     attrs.Append( KMPXMediaVideoAll );
       
  1032 
       
  1033     iPlaybackPlugin->MediaL( attrs.Array() );
       
  1034 
       
  1035     CleanupStack::PopAndDestroy( &attrs );
       
  1036 
       
  1037     return KErrNone;
       
  1038 }
       
  1039 
       
  1040 TInt
       
  1041 CVHPPTestClass::CancelRequest( CStifItemParser& /*aItem*/ )
       
  1042 {
       
  1043     MPX_ENTER_EXIT(_L("CVHPPTestClass::CancelRequest()"));
       
  1044     iLog->Log(_L("CVHPPTestClass::CancelRequest()"));
       
  1045 
       
  1046     iPlaybackPlugin->CancelRequest();
       
  1047 
       
  1048     return KErrNone;
       
  1049 }
       
  1050 
       
  1051 TInt
       
  1052 CVHPPTestClass::SetPlaybackCompleteL( CStifItemParser& aItem )
       
  1053 {
       
  1054     MPX_ENTER_EXIT(_L("CVHPPTestClass::SetPlaybackCompleteL()"));
       
  1055     iLog->Log(_L("CVHPPTestClass::SetPlaybackCompleteL()"));
       
  1056 
       
  1057     TInt playError = KErrNone;
       
  1058 
       
  1059     TInt err = aItem.GetNextInt( playError );
       
  1060 
       
  1061     if ( err == KErrNone )
       
  1062     {
       
  1063         TInt duration;
       
  1064 
       
  1065         err = aItem.GetNextInt( duration );
       
  1066 
       
  1067         if ( err == KErrNone )
       
  1068         {
       
  1069             WriteControllerError( KPlaybackCompleteFilename, playError );
       
  1070 
       
  1071             TCallbackEvent* event = new TCallbackEvent;
       
  1072             event->iEvent = EPSetComplete;
       
  1073             event->iData  = EPbPropertyPosition;
       
  1074             event->iError = KErrNone;
       
  1075             AddExpectedEvent( event );
       
  1076 
       
  1077             //
       
  1078             //  Trigger a playback complete by setting time to duration
       
  1079             //
       
  1080             iPlaybackPlugin->SetL( EPbPropertyPosition, duration );
       
  1081 
       
  1082             if ( playError )
       
  1083             {
       
  1084                 AddErrorEvent( playError );
       
  1085             }
       
  1086             else
       
  1087             {
       
  1088                 TCallbackEvent* event = new TCallbackEvent;
       
  1089 
       
  1090                 event->iEvent = EPPlayComplete;
       
  1091                 event->iData  = 0;
       
  1092                 event->iError = playError;
       
  1093 
       
  1094                 AddExpectedEvent( event );
       
  1095             }
       
  1096         }
       
  1097     }
       
  1098 
       
  1099     return KErrNone;
       
  1100 }
       
  1101 
       
  1102 TInt
       
  1103 CVHPPTestClass::SetUnexpectedMmfEventL( CStifItemParser& aItem )
       
  1104 {
       
  1105     MPX_ENTER_EXIT(_L("CVHPPTestClass::SetUnexpectedMmfEventL()"));
       
  1106     iLog->Log(_L("CVHPPTestClass::SetUnexpectedMmfEventL()"));
       
  1107 
       
  1108     TInt playError = KErrNone;
       
  1109 
       
  1110     TInt err = aItem.GetNextInt( playError );
       
  1111 
       
  1112     if ( err == KErrNone )
       
  1113     {
       
  1114         WriteControllerError( KPlaybackCompleteFilename, playError );
       
  1115 
       
  1116         //
       
  1117         //  Trigger an unexpected event by setting time to a negative value
       
  1118         //
       
  1119         iPlaybackPlugin->SetL( EPbPropertyPosition, -1 );
       
  1120 
       
  1121         TCallbackEvent* event = new TCallbackEvent;
       
  1122 
       
  1123         event->iEvent = EPClosed;
       
  1124         event->iData  = 0;
       
  1125         event->iError = playError;
       
  1126 
       
  1127         AddExpectedEvent( event );
       
  1128     }
       
  1129 
       
  1130     return KErrNone;
       
  1131 }
       
  1132 
       
  1133 // -----------------------------------------------------------------------------
       
  1134 //  CVHPPTestClass::ConnectToDownload
       
  1135 // -----------------------------------------------------------------------------
       
  1136 //
       
  1137 TInt
       
  1138 CVHPPTestClass::ConnectToDownloadL( CStifItemParser& aItem )
       
  1139 {
       
  1140     MPX_ENTER_EXIT(_L("CVHPPTestClass::ConnectToDownloadL()"));
       
  1141     iLog->Log(_L("CVHPPTestClass::ConnectToDownloadL()"));
       
  1142 
       
  1143     iDlMgrTester = CDlMgrTestClass::NewL();
       
  1144     iDlMgrTester->AddStifObserver( this );
       
  1145 
       
  1146     TInt dlId;
       
  1147     TPtrC filename;
       
  1148     TBuf<120> fullPath;
       
  1149 
       
  1150     //
       
  1151     //   Read in the download id and filename
       
  1152     //
       
  1153     TInt err = aItem.GetNextInt( dlId );
       
  1154 
       
  1155     if ( err == KErrNone )
       
  1156     {
       
  1157         err = aItem.GetNextString( filename );
       
  1158 
       
  1159         if ( err == KErrNone )
       
  1160         {
       
  1161             TCallbackEvent* event = new TCallbackEvent;
       
  1162             event->iEvent = EConnectedToDownload;
       
  1163             event->iData  = dlId;
       
  1164             event->iError = KErrNone;
       
  1165 
       
  1166             AddExpectedEvent( event );
       
  1167 
       
  1168             //
       
  1169             //  Build the full path to the file
       
  1170             //
       
  1171             fullPath.Append( KVideoTestPath );
       
  1172             fullPath.Append( filename );
       
  1173 
       
  1174             CMPXCommand* cmd = CMPXCommand::NewL();
       
  1175             CleanupStack::PushL( cmd );
       
  1176 
       
  1177             cmd->SetTObjectValueL<TBool>( KMPXCommandGeneralDoSync, ETrue );
       
  1178             cmd->SetTObjectValueL<TInt>( KMPXCommandGeneralId, KMPXCommandIdPlaybackPD );
       
  1179             cmd->SetTObjectValueL<TMPXPlaybackPdCommand>( KMPXCommandPlaybackGeneralType, EPbCmdStartPd );
       
  1180             cmd->SetTObjectValueL<TInt>( KMPXCommandPlaybackPDTransactionID, dlId );
       
  1181             cmd->SetTextValueL( KMPXMediaVideoPlaybackFileName, fullPath );
       
  1182             cmd->SetTObjectValueL<TInt>( KMPXMediaVideoMovePdlFile, ETrue );
       
  1183 
       
  1184             iPlaybackPlugin->CommandL( *cmd );
       
  1185 
       
  1186             CleanupStack::PopAndDestroy( cmd );
       
  1187         }
       
  1188     }
       
  1189 
       
  1190     return err;
       
  1191 }
       
  1192 
       
  1193 // -------------------------------------------------------------------------------------------------
       
  1194 //   CVHPPTestClass::SendPdlCustomCommandL()
       
  1195 // -------------------------------------------------------------------------------------------------
       
  1196 //
       
  1197 void
       
  1198 CVHPPTestClass::SendPdlCustomCommandL( TMPXPlaybackPdCommand aCustomCmd )
       
  1199 {
       
  1200     MPX_ENTER_EXIT(_L("CVHPPTestClass::SendPdlCustomCommandL"),
       
  1201                    _L("aCustomCmd = %d"), aCustomCmd );
       
  1202 
       
  1203     CMPXCommand* cmd = CMPXCommand::NewL();
       
  1204     CleanupStack::PushL( cmd );
       
  1205 
       
  1206     cmd->SetTObjectValueL<TBool>( KMPXCommandGeneralDoSync, ETrue );
       
  1207     cmd->SetTObjectValueL<TInt>( KMPXCommandGeneralId, KMPXCommandIdPlaybackPD );
       
  1208     cmd->SetTObjectValueL<TMPXPlaybackPdCommand>( KMPXCommandPlaybackGeneralType, aCustomCmd );
       
  1209 
       
  1210     iPlaybackPlugin->CommandL( *cmd );
       
  1211 
       
  1212     CleanupStack::PopAndDestroy( cmd );
       
  1213 }
       
  1214 
       
  1215 // -----------------------------------------------------------------------------
       
  1216 //  CVHPPTestClass::PauseDownloadL
       
  1217 // -----------------------------------------------------------------------------
       
  1218 //
       
  1219 TInt
       
  1220 CVHPPTestClass::PauseDownloadL( CStifItemParser& /*aItem*/ )
       
  1221 {
       
  1222     MPX_ENTER_EXIT(_L("CVHPPTestClass::PauseDownloadL()"));
       
  1223     iLog->Log(_L("CVHPPTestClass::PauseDownloadL()"));
       
  1224 
       
  1225     TCallbackEvent* event = new TCallbackEvent;
       
  1226 
       
  1227     event->iEvent = EPDownloadStateChanged;
       
  1228     event->iData  = EPbDlStateDownloadPaused;
       
  1229     event->iError = KErrNone;
       
  1230 
       
  1231     AddExpectedEvent( event );
       
  1232 
       
  1233     iDlMgrTester->PauseDownload();
       
  1234 
       
  1235     return KErrNone;
       
  1236 }
       
  1237 
       
  1238 // -----------------------------------------------------------------------------
       
  1239 //  CVHPPTestClass::ResumeDownloadL
       
  1240 // -----------------------------------------------------------------------------
       
  1241 //
       
  1242 TInt
       
  1243 CVHPPTestClass::ResumeDownloadL( CStifItemParser& aItem )
       
  1244 {
       
  1245     MPX_ENTER_EXIT(_L("CVHPPTestClass::ResumeDownloadL()"));
       
  1246     iLog->Log(_L("CVHPPTestClass::ResumeDownloadL()"));
       
  1247 
       
  1248     TInt dlSize;
       
  1249 
       
  1250     TInt err = aItem.GetNextInt( dlSize );
       
  1251 
       
  1252     if ( err == KErrNone )
       
  1253     {
       
  1254         WriteControllerError( KDlMgrFile, dlSize );
       
  1255 
       
  1256         TCallbackEvent* event = new TCallbackEvent;
       
  1257 
       
  1258         event->iEvent = EPDownloadStateChanged;
       
  1259         event->iError = KErrNone;
       
  1260 
       
  1261         if ( dlSize >= 100 )
       
  1262         {
       
  1263             event->iData = EPbDlStateDownloadCompleted;
       
  1264         }
       
  1265         else
       
  1266         {
       
  1267             event->iData  = EPbDlStateDownloading;
       
  1268         }
       
  1269 
       
  1270         AddExpectedEvent( event );
       
  1271 
       
  1272         iDlMgrTester->ResumeDownload();
       
  1273     }
       
  1274 
       
  1275     return err;
       
  1276 }
       
  1277 
       
  1278 // -----------------------------------------------------------------------------
       
  1279 //  CVHPPTestClass::CancelDownloadL
       
  1280 // -----------------------------------------------------------------------------
       
  1281 //
       
  1282 TInt
       
  1283 CVHPPTestClass::CancelDownloadL( CStifItemParser& /*aItem*/ )
       
  1284 {
       
  1285     MPX_ENTER_EXIT(_L("CVHPPTestClass::CancelDownloadL()"));
       
  1286     iLog->Log(_L("CVHPPTestClass::CancelDownloadL()"));
       
  1287 
       
  1288     TCallbackEvent* event = new TCallbackEvent;
       
  1289 
       
  1290     event->iEvent = EPDownloadStateChanged;
       
  1291     event->iData  = EPbDlStateDownloadCanceled;
       
  1292     event->iError = KErrNone;
       
  1293 
       
  1294     AddExpectedEvent( event );
       
  1295 
       
  1296     iDlMgrTester->CancelDownload();
       
  1297 
       
  1298     return KErrNone;
       
  1299 }
       
  1300 
       
  1301 // -----------------------------------------------------------------------------
       
  1302 //  CVHPPTestClass::RetrievePdlStatusL
       
  1303 // -----------------------------------------------------------------------------
       
  1304 //
       
  1305 TInt
       
  1306 CVHPPTestClass::RetrievePdlStatusL( CStifItemParser& aItem )
       
  1307 {
       
  1308     MPX_ENTER_EXIT(_L("CVHPPTestClass::RetrievePdlStatusL()"));
       
  1309     iLog->Log(_L("CVHPPTestClass::RetrievePdlStatusL()"));
       
  1310 
       
  1311     TInt pdlState;
       
  1312     TInt expectedPdlState;
       
  1313     TInt downloadedBytes;
       
  1314     TInt expectedDownloadedBytes;
       
  1315     TInt downloadSize;
       
  1316     TInt expectedDownloadSize;
       
  1317 
       
  1318     //
       
  1319     //   Read in the expected download data
       
  1320     //
       
  1321     TInt err = aItem.GetNextInt( expectedPdlState );
       
  1322 
       
  1323     if ( err == KErrNone )
       
  1324     {
       
  1325         err = aItem.GetNextInt( expectedDownloadedBytes );
       
  1326 
       
  1327         if ( err == KErrNone )
       
  1328         {
       
  1329             err = aItem.GetNextInt( expectedDownloadSize );
       
  1330         }
       
  1331     }
       
  1332 
       
  1333     if ( err == KErrNone )
       
  1334     {
       
  1335         CMPXCommand* cmd( CMPXCommand::NewL() );
       
  1336         CleanupStack::PushL( cmd );
       
  1337 
       
  1338         cmd->SetTObjectValueL<TBool>( KMPXCommandGeneralDoSync, ETrue );
       
  1339         cmd->SetTObjectValueL<TInt>( KMPXCommandGeneralId, KMPXCommandIdPlaybackPD );
       
  1340         cmd->SetTObjectValueL<TMPXPlaybackPdCommand>( KMPXCommandPlaybackGeneralType,
       
  1341                                                       EPbCmdGetPdStatus );
       
  1342 
       
  1343         iPlaybackPlugin->CommandL( *cmd );
       
  1344 
       
  1345         //
       
  1346         //  Parse the PDL information
       
  1347         //
       
  1348 
       
  1349         pdlState = cmd->ValueTObjectL<TMPXPlaybackPdDownloadState>( KMPXCommandPlaybackPDState );
       
  1350         downloadedBytes = cmd->ValueTObjectL<TInt>( KMPXCommandPlaybackPDDownloadedBytes );
       
  1351         downloadSize = cmd->ValueTObjectL<TInt>( KMPXCommandPlaybackPDTotalBytes );
       
  1352 
       
  1353         MPX_DEBUG(_L("    Expected Data:  PDL State = %d, current size = %d, total size = %d"),
       
  1354             expectedPdlState, expectedDownloadedBytes, expectedDownloadSize );
       
  1355 
       
  1356         MPX_DEBUG(_L("    Received PDL State = %d, current size = %d, total size = %d"),
       
  1357             pdlState, downloadedBytes, downloadSize );
       
  1358 
       
  1359         if ( ( expectedPdlState != pdlState ) ||
       
  1360              ( expectedDownloadedBytes != downloadedBytes ) ||
       
  1361              ( expectedDownloadSize != downloadSize ) )
       
  1362         {
       
  1363             err = KErrGeneral;
       
  1364         }
       
  1365 
       
  1366         CleanupStack::PopAndDestroy( cmd );
       
  1367     }
       
  1368 
       
  1369     return err;
       
  1370 }
       
  1371 
       
  1372 void
       
  1373 CVHPPTestClass::HandlePluginEvent( TEvent aEvent, TInt aData, TInt aError )
       
  1374 {
       
  1375     MPX_ENTER_EXIT(_L("CVHPPTestClass::HandlePluginEvent"),
       
  1376                    _L("(%d, %d, %d)"), aEvent, aData, aError );
       
  1377 
       
  1378     iLog->Log(_L("CVHPPTestClass::HandlePluginEvent(%d, %d, %d)"),
       
  1379         aEvent, aData, aError);
       
  1380 
       
  1381     TCallbackEvent* callback = new TCallbackEvent;
       
  1382 
       
  1383     callback->iEvent = aEvent;
       
  1384     callback->iData  = aData;
       
  1385     callback->iError = aError;
       
  1386 
       
  1387     ProcessEvent( callback );
       
  1388 }
       
  1389 
       
  1390 void
       
  1391 CVHPPTestClass::HandlePlaybackMessage( CMPXMessage* aMsg, TInt /*aErr*/ )
       
  1392 {
       
  1393     MPX_ENTER_EXIT(_L("CVHPPTestClass::HandlePlaybackMessage()"));
       
  1394     iLog->Log(_L("CVHPPTestClass::HandlePlaybackMessage"));
       
  1395 
       
  1396     TMPXMessageId id( *(aMsg->Value<TMPXMessageId>(KMPXMessageGeneralId)) );
       
  1397 
       
  1398     if ( KMPXMediaIdVideoPlayback == id )
       
  1399     {
       
  1400         TMPXVideoPlaybackCommand message =
       
  1401             ( *(aMsg->Value<TMPXVideoPlaybackCommand>(KMPXMediaVideoPlaybackCommand)) );
       
  1402 
       
  1403         switch ( message )
       
  1404         {
       
  1405             case EPbCmdPluginError:
       
  1406             {
       
  1407                 TInt error( *aMsg->Value<TInt>( KMPXMediaVideoError ) );
       
  1408 
       
  1409                 ProcessErrorEvent( error );
       
  1410                 break;
       
  1411             }
       
  1412             case EPbCmdTvOutEvent:
       
  1413             {
       
  1414                 TCallbackEvent* callback = new TCallbackEvent;
       
  1415 
       
  1416                 callback->iEvent = EPbCmdTvOutEvent;
       
  1417                 callback->iData  = *aMsg->Value<TInt>( KMPXMediaVideoTvOutConnected );
       
  1418                 callback->iError = *aMsg->Value<TInt>( KMPXMediaVideoTvOutPlayAllowed );
       
  1419 
       
  1420                 ProcessEvent( callback );
       
  1421 
       
  1422                 break;
       
  1423             }
       
  1424         }
       
  1425     }
       
  1426 }
       
  1427 
       
  1428 void
       
  1429 CVHPPTestClass::HandleProperty( TMPXPlaybackProperty aProperty,
       
  1430                                 TInt aValue,
       
  1431                                 TInt aError )
       
  1432 {
       
  1433     MPX_ENTER_EXIT(_L("CVHPPTestClass::HandleProperty()"));
       
  1434     iLog->Log(_L("CVHPPTestClass::HandleProperty"));
       
  1435 
       
  1436     TCallbackEvent* callback = new TCallbackEvent;
       
  1437 
       
  1438     callback->iEvent = aProperty;
       
  1439     callback->iData  = aValue;
       
  1440     callback->iError = aError;
       
  1441 
       
  1442     ProcessEvent( callback );
       
  1443 }
       
  1444 
       
  1445 void
       
  1446 CVHPPTestClass::HandleSubPlayerNames( TUid /*aPlayer*/,
       
  1447                                       const MDesCArray* /*aSubPlayers*/,
       
  1448                                       TBool /*aComplete*/,
       
  1449                                       TInt /*aError*/ )
       
  1450 {
       
  1451     MPX_ENTER_EXIT(_L("CVHPPTestClass::HandleSubPlayerNames()"));
       
  1452     iLog->Log(_L("CVHPPTestClass::HandleSubPlayerNames"));
       
  1453 
       
  1454     Signal();
       
  1455 }
       
  1456 
       
  1457 void
       
  1458 CVHPPTestClass::HandleMedia( CMPXMedia* aMedia, TInt /*aError*/ )
       
  1459 {
       
  1460     MPX_ENTER_EXIT(_L("CVHPPTestClass::HandleMedia()"));
       
  1461     iLog->Log(_L("CVHPPTestClass::HandleMedia"));
       
  1462 
       
  1463     //
       
  1464     //  Check for an error condition
       
  1465     //
       
  1466     if ( aMedia->IsSupported( KMPXMediaVideoError ) )
       
  1467     {
       
  1468         MPX_DEBUG(_L("CVHPPTestClass::HandleMedia() Plugin has error"));
       
  1469 
       
  1470         TInt error = aMedia->ValueTObjectL<TInt>( KMPXMediaVideoError );
       
  1471 
       
  1472         ProcessErrorEvent( error );
       
  1473     }
       
  1474     else
       
  1475     {
       
  1476         TBool partialPlaybackError = EFalse;
       
  1477 
       
  1478         if ( aMedia->IsSupported( KMPXMediaVideoPartialPlayback ) )
       
  1479         {
       
  1480             partialPlaybackError = aMedia->ValueTObjectL<TInt>( KMPXMediaVideoPartialPlayback );
       
  1481         }
       
  1482 
       
  1483         if ( partialPlaybackError )
       
  1484         {
       
  1485             ProcessErrorEvent( KErrMMPartialPlayback );
       
  1486         }
       
  1487         else
       
  1488         {
       
  1489             Signal();
       
  1490         }
       
  1491     }
       
  1492 }
       
  1493 
       
  1494 void
       
  1495 CVHPPTestClass::HandlePlaybackCommandComplete( CMPXCommand* /*aCommandResult*/,
       
  1496                                                TInt /*aError*/ )
       
  1497 {
       
  1498     MPX_DEBUG(_L("CVHPPTestClass::HandlePlaybackCommandComplete"));
       
  1499 }
       
  1500 
       
  1501 void
       
  1502 CVHPPTestClass::AddExpectedEvent( TCallbackEvent* aEvent )
       
  1503 {
       
  1504     MPX_ENTER_EXIT(_L("CVHPPTestClass::AddExpectedEvent()"));
       
  1505 
       
  1506     iExpectedCallbackArray->AppendL( aEvent );
       
  1507 
       
  1508     if ( iTimeoutController && ! iTimeoutController->IsActive() )
       
  1509     {
       
  1510         iTimeoutController->Start( TTimeIntervalMicroSeconds(15000000) );
       
  1511     }
       
  1512 }
       
  1513 
       
  1514 void
       
  1515 CVHPPTestClass::AddErrorEvent( TInt aError )
       
  1516 {
       
  1517     MPX_ENTER_EXIT(_L("CVHPPTestClass::AddErrorEvent"),
       
  1518                    _L("(%d)"), aError );
       
  1519 
       
  1520     iExpectedError = aError;
       
  1521 
       
  1522     if ( iTimeoutController && ! iTimeoutController->IsActive() )
       
  1523     {
       
  1524         iTimeoutController->Start( TTimeIntervalMicroSeconds(15000000) );
       
  1525     }
       
  1526 }
       
  1527 
       
  1528 void
       
  1529 CVHPPTestClass::HandleTimeout( TInt aError )
       
  1530 {
       
  1531     MPX_ENTER_EXIT(_L("CVHPPTestClass::HandleTimeout"),
       
  1532                    _L("(%d)"), aError );
       
  1533 
       
  1534     if ( aError == KErrNone )
       
  1535     {
       
  1536         iLog->Log(_L("    Callback timed out"));
       
  1537         Signal( KErrTimedOut );
       
  1538     }
       
  1539     else
       
  1540     {
       
  1541         iLog->Log(_L("    Callback timeout error %d"), aError);
       
  1542         Signal( aError );
       
  1543     }
       
  1544 }
       
  1545 
       
  1546 void
       
  1547 CVHPPTestClass::ProcessEvent( TCallbackEvent* aCallback )
       
  1548 {
       
  1549     if ( iExpectedCallbackArray->Count() > 0 )
       
  1550     {
       
  1551         TCallbackEvent* expectedCallback = (*iExpectedCallbackArray)[0];
       
  1552 
       
  1553         MPX_DEBUG(_L("CVHPPTestClass::ProcessEvent(%d,%d,%d) Expected(%d,%d,%d)"),
       
  1554             aCallback->iEvent, aCallback->iData, aCallback->iError,
       
  1555             expectedCallback->iEvent, expectedCallback->iData, expectedCallback->iError);
       
  1556 
       
  1557         if ( expectedCallback->iEvent == aCallback->iEvent )
       
  1558         {
       
  1559             if ( expectedCallback->iData == aCallback->iData &&
       
  1560                  expectedCallback->iError == aCallback->iError )
       
  1561             {
       
  1562                 MPX_DEBUG(_L("Callback received with proper error code"));
       
  1563                 iLog->Log(_L("Callback received with proper error code"));
       
  1564 
       
  1565                 //
       
  1566                 //  Pop the event from the array
       
  1567                 //
       
  1568                 iExpectedCallbackArray->Delete( 0 );
       
  1569 
       
  1570                 if ( iExpectedCallbackArray->Count() == 0 )
       
  1571                 {
       
  1572                     iTimeoutController->Cancel();
       
  1573                 }
       
  1574 
       
  1575                 Signal();
       
  1576             }
       
  1577             else
       
  1578             {
       
  1579                 iTimeoutController->Cancel();
       
  1580                 MPX_DEBUG(_L("Callback received with wrong error code"));
       
  1581                 iLog->Log(_L("Callback received with wrong error code"));
       
  1582                 Signal( KErrGeneral );
       
  1583             }
       
  1584         }
       
  1585     }
       
  1586     else
       
  1587     {
       
  1588         if ( ! ( iAllowPositionCallback && aCallback->iEvent == EPPositionChanged ) )
       
  1589         {
       
  1590             //
       
  1591             //  Unexpected event
       
  1592             //
       
  1593             _LIT( KPanic, "Unexpected Event" );
       
  1594             User::Panic( KPanic, -33 );
       
  1595         }
       
  1596     }
       
  1597 
       
  1598     delete aCallback;
       
  1599 }
       
  1600 
       
  1601 void
       
  1602 CVHPPTestClass::ProcessErrorEvent( TInt aError )
       
  1603 {
       
  1604     MPX_DEBUG(_L("CVHPPTestClass::ProcessErrorEvent(%d) ExpectedError(%d)"),
       
  1605         aError, iExpectedError );
       
  1606 
       
  1607     iLog->Log(_L("    Error received (%d)"), aError );
       
  1608 
       
  1609     if ( iExpectedError == aError )
       
  1610     {
       
  1611         iTimeoutController->Cancel();
       
  1612 
       
  1613         MPX_DEBUG(_L("Error received with proper error code"));
       
  1614         iLog->Log(_L("Error received with proper error code"));
       
  1615         Signal();
       
  1616 
       
  1617         iExpectedError = KErrNone;
       
  1618     }
       
  1619     else
       
  1620     {
       
  1621         iTimeoutController->Cancel();
       
  1622 
       
  1623         MPX_DEBUG(_L("Unexpected error received"));
       
  1624         iLog->Log(_L("Unexpected error received"));
       
  1625         Signal( KErrAbort );
       
  1626 
       
  1627         iExpectedError = KErrNone;
       
  1628     }
       
  1629 }
       
  1630 
       
  1631 // -----------------------------------------------------------------------------
       
  1632 //  CVHPPTestClass::ChangeAspectRatioL
       
  1633 // -----------------------------------------------------------------------------
       
  1634 //
       
  1635 TInt
       
  1636 CVHPPTestClass::ChangeAspectRatioL( CStifItemParser& aItem )
       
  1637 {
       
  1638     MPX_ENTER_EXIT(_L("CVHPPTestClass::ChangeAspectRatioL()"));
       
  1639     iLog->Log(_L("CVHPPTestClass::ChangeAspectRatioL()"));
       
  1640 
       
  1641     TInt aspectRatioCmd = 0;
       
  1642     TInt expectedResult = 0;
       
  1643     TInt err = aItem.GetNextInt( aspectRatioCmd );
       
  1644 
       
  1645     if ( err == KErrNone )
       
  1646     {
       
  1647         err = aItem.GetNextInt( expectedResult );
       
  1648 
       
  1649         if ( err == KErrNone )
       
  1650         {
       
  1651             //
       
  1652             //  create command to pass to playback plugin
       
  1653             //
       
  1654             CMPXCommand* cmd = CMPXCommand::NewL();
       
  1655             CleanupStack::PushL( cmd );
       
  1656 
       
  1657             cmd->SetTObjectValueL<TBool>( KMPXCommandGeneralDoSync, ETrue );
       
  1658             cmd->SetTObjectValueL<TInt>( KMPXCommandGeneralId, KMPXMediaIdVideoPlayback );
       
  1659 
       
  1660             cmd->SetTObjectValueL<TInt>( KMPXMediaVideoPlaybackCommand,
       
  1661                                          (TMPXVideoPlaybackCommand)aspectRatioCmd );
       
  1662 
       
  1663             iPlaybackPlugin->CommandL( *cmd );
       
  1664 
       
  1665             TInt result = cmd->ValueTObjectL<TInt>( KMPXMediaVideoAspectRatio );
       
  1666 
       
  1667             if ( expectedResult != result )
       
  1668             {
       
  1669                 err = KErrGeneral;
       
  1670             }
       
  1671 
       
  1672             CleanupStack::PopAndDestroy( cmd );
       
  1673         }
       
  1674     }
       
  1675 
       
  1676     return err;
       
  1677 }
       
  1678 
       
  1679 // -----------------------------------------------------------------------------
       
  1680 //  CVHPPTestClass::AlarmOn
       
  1681 // -----------------------------------------------------------------------------
       
  1682 //
       
  1683 TInt
       
  1684 CVHPPTestClass::AlarmOn( CStifItemParser& aItem )
       
  1685 {
       
  1686     MPX_ENTER_EXIT(_L("CVHPPTestClass::AlarmOn()"));
       
  1687     iLog->Log(_L("CVHPPTestClass::AlarmOn()"));
       
  1688 
       
  1689     TInt backgroundCmd = 0;
       
  1690     TInt err = aItem.GetNextInt( backgroundCmd );
       
  1691 
       
  1692     if ( err == KErrNone )
       
  1693     {
       
  1694         //callback event
       
  1695         TCallbackEvent* event = new TCallbackEvent;
       
  1696         event->iError = 0;
       
  1697         event->iData  = 0;
       
  1698         event->iEvent = EPPaused;
       
  1699         AddExpectedEvent( event );
       
  1700 
       
  1701         // set alarm status
       
  1702         RProperty::Set( KPSUidCoreApplicationUIs, KLightsAlarmLightActive, ELightsBlinking );
       
  1703 
       
  1704         //
       
  1705         //  create background Cmd to pass to playback plugin
       
  1706         //
       
  1707         CMPXCommand* cmdPause = CMPXCommand::NewL();
       
  1708         CleanupStack::PushL( cmdPause );
       
  1709         cmdPause->SetTObjectValueL<TBool>( KMPXCommandGeneralDoSync, ETrue );
       
  1710         cmdPause->SetTObjectValueL<TInt>( KMPXCommandGeneralId, KMPXMediaIdVideoPlayback );
       
  1711         cmdPause->SetTObjectValueL<TInt>( KMPXMediaVideoPlaybackCommand, backgroundCmd );
       
  1712         cmdPause->SetTObjectValueL<TBool>( KMPXMediaVideoAppForeground, ETrue );
       
  1713         iPlaybackPlugin->CommandL( *cmdPause );
       
  1714         CleanupStack::PopAndDestroy( cmdPause );
       
  1715 
       
  1716         //reset alarm
       
  1717         RProperty::Set( KPSUidCoreApplicationUIs, KLightsAlarmLightActive, ELightsNotBlinking );
       
  1718     }
       
  1719 
       
  1720     return err;
       
  1721 }
       
  1722 
       
  1723 // -----------------------------------------------------------------------------
       
  1724 //  CVHPPTestClass::AlarmOnAndOff
       
  1725 // -----------------------------------------------------------------------------
       
  1726 //
       
  1727 TInt
       
  1728 CVHPPTestClass::AlarmAutoResume( CStifItemParser& aItem )
       
  1729 {
       
  1730     MPX_ENTER_EXIT(_L("CVHPPTestClass::AlarmOnAndOff()"));
       
  1731     iLog->Log(_L("CVHPPTestClass::AlarmOnAndOff()"));
       
  1732 
       
  1733     TInt backgroundCmd = 0;
       
  1734     TInt err = 0;//aItem.GetNextInt( backgroundCmd );
       
  1735 
       
  1736     err = AlarmOn(aItem);
       
  1737 
       
  1738     if ( err == KErrNone )
       
  1739     {
       
  1740         err = aItem.GetNextInt( backgroundCmd );
       
  1741 
       
  1742         //reset alarm
       
  1743         RProperty::Set( KPSUidCoreApplicationUIs, KLightsAlarmLightActive, ELightsNotBlinking );
       
  1744 
       
  1745         if ( err == KErrNone )
       
  1746         {
       
  1747             TCallbackEvent* event = new TCallbackEvent;
       
  1748             event->iError = 0;
       
  1749             event->iData  = 0;
       
  1750             event->iEvent = EPPlaying;
       
  1751             AddExpectedEvent( event );
       
  1752 
       
  1753             //auto resume if alarm off
       
  1754             CMPXCommand* cmdPlay = CMPXCommand::NewL();
       
  1755             CleanupStack::PushL( cmdPlay );
       
  1756             cmdPlay->SetTObjectValueL<TBool>( KMPXCommandGeneralDoSync, ETrue );
       
  1757             cmdPlay->SetTObjectValueL<TInt>( KMPXCommandGeneralId, KMPXMediaIdVideoPlayback );
       
  1758             cmdPlay->SetTObjectValueL<TInt>( KMPXMediaVideoPlaybackCommand, backgroundCmd );
       
  1759             cmdPlay->SetTObjectValueL<TBool>( KMPXMediaVideoAppForeground, ETrue );
       
  1760             iPlaybackPlugin->CommandL( *cmdPlay );
       
  1761             CleanupStack::PopAndDestroy( cmdPlay );
       
  1762         }
       
  1763     }
       
  1764 
       
  1765     return err;
       
  1766 }
       
  1767 
       
  1768 // -----------------------------------------------------------------------------
       
  1769 //  CVHPPTestClass::PhoneCallRejected
       
  1770 // -----------------------------------------------------------------------------
       
  1771 //
       
  1772 TInt
       
  1773 CVHPPTestClass::PhoneCallRejected( CStifItemParser& aItem )
       
  1774 {
       
  1775     MPX_ENTER_EXIT(_L("CVHPPTestClass::PhoneCallRejected()"));
       
  1776     iLog->Log(_L("CVHPPTestClass::PhoneCallRejected()"));
       
  1777 
       
  1778     TInt background = 0;
       
  1779     TInt err = aItem.GetNextInt( background );
       
  1780     TCallbackEvent* event = new TCallbackEvent;
       
  1781 
       
  1782     if ( err == KErrNone )
       
  1783     {
       
  1784         //callback event
       
  1785         TCallbackEvent* event = new TCallbackEvent;
       
  1786         event->iError = 0;
       
  1787         event->iData  = 0;
       
  1788         event->iEvent = EPPaused;
       
  1789         AddExpectedEvent( event );
       
  1790 
       
  1791         //set phone call as ringing
       
  1792         RProperty::Set(KPSUidCtsyCallInformation, KCTsyCallState, EPSCTsyCallStateRinging);
       
  1793 
       
  1794         //pause
       
  1795         CreateBackgroundCommand(background);
       
  1796 
       
  1797         err = aItem.GetNextInt( background );
       
  1798 
       
  1799         if ( err == KErrNone )
       
  1800         {
       
  1801             //
       
  1802             //  Clear ringing
       
  1803             //
       
  1804             RProperty::Set(KPSUidCtsyCallInformation, KCTsyCallState, EPSCTsyCallStateNone);
       
  1805 
       
  1806             CreateBackgroundCommand(background);
       
  1807         }
       
  1808     }
       
  1809 
       
  1810     return err;
       
  1811 }
       
  1812 
       
  1813 // -----------------------------------------------------------------------------
       
  1814 //  CVHPPTestClass::VoiceCallAccepted
       
  1815 // -----------------------------------------------------------------------------
       
  1816 //
       
  1817 TInt
       
  1818 CVHPPTestClass::VoiceCallAccepted( CStifItemParser& aItem )
       
  1819 {
       
  1820     MPX_ENTER_EXIT(_L("CVHPPTestClass::VoiceCallAccepted()"));
       
  1821     iLog->Log(_L("CVHPPTestClass::VoiceCallAccepted()"));
       
  1822 
       
  1823     TInt background = 0;
       
  1824     TInt err = aItem.GetNextInt( background );
       
  1825 
       
  1826     if ( err == KErrNone )
       
  1827     {
       
  1828         //callback event
       
  1829         TCallbackEvent* event = new TCallbackEvent;
       
  1830         event->iError = 0;
       
  1831         event->iData  = 0;
       
  1832         event->iEvent = EPPaused;
       
  1833         AddExpectedEvent( event );
       
  1834 
       
  1835         //set phone call as ringing
       
  1836         RProperty::Set(KPSUidCtsyCallInformation, KCTsyCallState, EPSCTsyCallStateRinging);
       
  1837 
       
  1838         //pause
       
  1839         CreateBackgroundCommand(background);
       
  1840 
       
  1841         err = aItem.GetNextInt( background );
       
  1842 
       
  1843         if ( err == KErrNone )
       
  1844         {
       
  1845             //set phone call as Connected
       
  1846             RProperty::Set(KPSUidCtsyCallInformation, KCTsyCallState, EPSCTsyCallStateConnected);
       
  1847 
       
  1848             CreateBackgroundCommand(background);
       
  1849          }
       
  1850     }
       
  1851 
       
  1852     return err;
       
  1853 }
       
  1854 
       
  1855 // -----------------------------------------------------------------------------
       
  1856 //  CVHPPTestClass::VideoCallAccepted
       
  1857 // -----------------------------------------------------------------------------
       
  1858 //
       
  1859 TInt
       
  1860 CVHPPTestClass::VideoCallAccepted( CStifItemParser& aItem )
       
  1861 {
       
  1862     MPX_ENTER_EXIT(_L("CVHPPTestClass::VideoCallAccepted()"));
       
  1863     iLog->Log(_L("CVHPPTestClass::VideoCallAccepted()"));
       
  1864 
       
  1865     TInt background = 0;
       
  1866     TInt err = aItem.GetNextInt( background );
       
  1867 
       
  1868     if ( err == KErrNone )
       
  1869     {
       
  1870         //callback event
       
  1871         TCallbackEvent* event = new TCallbackEvent;
       
  1872         event->iError = 0;
       
  1873         event->iData  = 0;
       
  1874         event->iEvent = EPPaused;
       
  1875         AddExpectedEvent( event );
       
  1876 
       
  1877         //set phone call as ringing
       
  1878         RProperty::Set(KPSUidCtsyCallInformation, KCTsyCallState, EPSCTsyCallStateRinging);
       
  1879 
       
  1880         //pause
       
  1881         CreateBackgroundCommand(background);
       
  1882 
       
  1883         err = aItem.GetNextInt( background );
       
  1884 
       
  1885         if ( err == KErrNone )
       
  1886         {
       
  1887             //set phone call as Connected
       
  1888             RProperty::Set(KPSUidCtsyCallInformation, KCTsyCallType, EPSCTsyCallTypeH324Multimedia);
       
  1889 
       
  1890            CreateBackgroundCommand(background);
       
  1891         }
       
  1892     }
       
  1893 
       
  1894     return err;
       
  1895 }
       
  1896 
       
  1897 // -----------------------------------------------------------------------------
       
  1898 //  CVHPPTestClass::PlayduringVideoCall
       
  1899 // -----------------------------------------------------------------------------
       
  1900 //
       
  1901 TInt
       
  1902 CVHPPTestClass::PlayduringVideoCall( CStifItemParser& /*aItem*/ )
       
  1903 {
       
  1904     MPX_ENTER_EXIT(_L("CVHPPTestClass::PlayduringVideoCall()"));
       
  1905     iLog->Log(_L("CVHPPTestClass::PlayduringVideoCall()"));
       
  1906 
       
  1907     TInt err = 0;
       
  1908 
       
  1909     //set phone call as Connected
       
  1910     err = RProperty::Set(KPSUidCtsyCallInformation, KCTsyCallType, EPSCTsyCallTypeH324Multimedia);
       
  1911 
       
  1912     AddErrorEvent(KMPXVideoCallOngoingError);
       
  1913 
       
  1914     return err;
       
  1915 }
       
  1916 
       
  1917 // -----------------------------------------------------------------------------
       
  1918 //  CVHPPTestClass::PlayduringVoiceCall
       
  1919 // -----------------------------------------------------------------------------
       
  1920 //
       
  1921 TInt
       
  1922 CVHPPTestClass::PlayduringVoiceCall( CStifItemParser& /*aItem*/ )
       
  1923 {
       
  1924     MPX_ENTER_EXIT(_L("CVHPPTestClass::PlayduringVoiceCall()"));
       
  1925     iLog->Log(_L("CVHPPTestClass::PlayduringVoiceCall()"));
       
  1926 
       
  1927     TInt err = 0;
       
  1928 
       
  1929     //set phone call as Connected
       
  1930     err = RProperty::Set(KPSUidCtsyCallInformation, KCTsyCallState, EPSCTsyCallStateConnected);
       
  1931 
       
  1932     AddErrorEvent(KMPXVideoPlayOver2GDuringVoiceCallError);
       
  1933 
       
  1934     return err;
       
  1935 }
       
  1936 
       
  1937 TInt
       
  1938 CVHPPTestClass::EndPhoneCall()
       
  1939 {
       
  1940     MPX_ENTER_EXIT(_L("CVHPPTestClass::EndPhoneCall()"));
       
  1941     iLog->Log(_L("CVHPPTestClass::EndPhoneCall()"));
       
  1942 
       
  1943     //Disconnect phone call
       
  1944     RProperty::Set(KPSUidCtsyCallInformation, KCTsyCallState, EPSCTsyCallStateNone);
       
  1945     RProperty::Set(KPSUidCtsyCallInformation, KCTsyCallType, EPSCTsyCallTypeNone);
       
  1946 
       
  1947     return KErrNone;
       
  1948 }
       
  1949 
       
  1950 TInt
       
  1951 CVHPPTestClass::ConnectTvOutL( CStifItemParser& aItem )
       
  1952 {
       
  1953     MPX_ENTER_EXIT(_L("CVHPPTestClass::ConnectTvOutL()"));
       
  1954     iLog->Log(_L("CVHPPTestClass::ConnectTvOutL()"));
       
  1955 
       
  1956     TBool playable = EFalse;
       
  1957 
       
  1958     TInt err = aItem.GetNextInt( playable );
       
  1959 
       
  1960     if ( err == KErrNone )
       
  1961     {
       
  1962         if ( ! playable )
       
  1963         {
       
  1964             TCallbackEvent* event = new TCallbackEvent;
       
  1965 
       
  1966             event->iEvent = EPPaused;
       
  1967             event->iData  = 0;
       
  1968             event->iError = 0;
       
  1969 
       
  1970             AddExpectedEvent( event );
       
  1971 
       
  1972             iExpectedError = KMPXVideoTvOutPlaybackNotAllowed;
       
  1973         }
       
  1974 
       
  1975         //
       
  1976         //  Add event for callback
       
  1977         //
       
  1978         TCallbackEvent* event = new TCallbackEvent;
       
  1979 
       
  1980         event->iEvent = EPbCmdTvOutEvent;
       
  1981         event->iData  = ETrue;
       
  1982         event->iError = playable;
       
  1983 
       
  1984         AddExpectedEvent( event );
       
  1985     }
       
  1986 
       
  1987     iAccObserver->UpdateTvOutStatusL( ETrue );
       
  1988 
       
  1989     return err;
       
  1990 }
       
  1991 
       
  1992 TInt
       
  1993 CVHPPTestClass::DisconnectTvOutL()
       
  1994 {
       
  1995     MPX_ENTER_EXIT(_L("CVHPPTestClass::DisconnectTvOutL()"));
       
  1996     iLog->Log(_L("CVHPPTestClass::DisconnectTvOutL()"));
       
  1997 
       
  1998     //
       
  1999     //  Add event for callback
       
  2000     //
       
  2001     TCallbackEvent* event = new TCallbackEvent;
       
  2002 
       
  2003     event->iEvent = EPbCmdTvOutEvent;
       
  2004     event->iData  = EFalse;
       
  2005     event->iError = ETrue;
       
  2006 
       
  2007     AddExpectedEvent( event );
       
  2008 
       
  2009     iAccObserver->UpdateTvOutStatusL( EFalse );
       
  2010 
       
  2011     return KErrNone;
       
  2012 }
       
  2013 
       
  2014 void
       
  2015 CVHPPTestClass::CreateBackgroundCommand( TBool aBackground )
       
  2016 {
       
  2017     MPX_ENTER_EXIT(_L("CVHPPTestClass::CreateBackgroundCommand()"),
       
  2018                    _L("aBackground = %d"), aBackground );
       
  2019 
       
  2020     CMPXCommand* cmd = CMPXCommand::NewL();
       
  2021     CleanupStack::PushL( cmd );
       
  2022     cmd->SetTObjectValueL<TBool>( KMPXCommandGeneralDoSync, ETrue );
       
  2023     cmd->SetTObjectValueL<TInt>( KMPXCommandGeneralId, KMPXMediaIdVideoPlayback );
       
  2024     cmd->SetTObjectValueL<TInt>( KMPXMediaVideoPlaybackCommand, aBackground );
       
  2025     cmd->SetTObjectValueL<TBool>( KMPXMediaVideoAppForeground, ETrue );
       
  2026     iPlaybackPlugin->CommandL( *cmd );
       
  2027     CleanupStack::PopAndDestroy( cmd );
       
  2028 }
       
  2029 
       
  2030 TInt
       
  2031 CVHPPTestClass::SetTvOutConnectedL( CStifItemParser& aItem )
       
  2032 {
       
  2033     MPX_ENTER_EXIT(_L("CVHPPTestClass::SetTvOutConnectedL()"));
       
  2034     iLog->Log(_L("CVHPPTestClass::SetTvOutConnectedL()"));
       
  2035 
       
  2036     TInt allowed = ETrue;
       
  2037 
       
  2038     TInt err = aItem.GetNextInt( allowed );
       
  2039 
       
  2040     if ( err == KErrNone )
       
  2041     {
       
  2042         iAccObserver->SetTvOutConnected( ETrue );
       
  2043         iAccObserver->SetTvOutPlaybackAllowed( allowed );
       
  2044     }
       
  2045 
       
  2046     return err;
       
  2047 }
       
  2048 
       
  2049 TInt
       
  2050 CVHPPTestClass::SetTvOutDisconnectedL()
       
  2051 {
       
  2052     MPX_ENTER_EXIT(_L("CVHPPTestClass::SetTvOutDisconnectedL()"));
       
  2053     iLog->Log(_L("CVHPPTestClass::SetTvOutDisconnectedL()"));
       
  2054 
       
  2055     iAccObserver->SetTvOutConnected( EFalse );
       
  2056     iAccObserver->SetTvOutPlaybackAllowed( ETrue );
       
  2057 
       
  2058     return KErrNone;
       
  2059 }
       
  2060 
       
  2061 void
       
  2062 CVHPPTestClass::HandleUtilityEvent( TCallbackEvent* aEvent )
       
  2063 {
       
  2064     MPX_ENTER_EXIT(_L("CVHPPTestClass::HandleUtilityEvent"),
       
  2065                    _L("(%d, %d, %d)"), aEvent->iEvent, aEvent->iData, aEvent->iError );
       
  2066 
       
  2067     ProcessEvent( aEvent );
       
  2068 }
       
  2069 
       
  2070 void
       
  2071 CVHPPTestClass::CleanupTempFiles()
       
  2072 {
       
  2073     RFs fs;
       
  2074     TInt error = fs.Connect();
       
  2075 
       
  2076     error = fs.Delete( KOpenControllerFilename );
       
  2077     error = fs.Delete( KPrepareControllerFilename );
       
  2078     error = fs.Delete( KPlaybackCompleteFilename );
       
  2079     error = fs.Delete( KDlMgrFile );
       
  2080     error = fs.Delete( KDrmRightsFile );
       
  2081 
       
  2082     fs.Close();
       
  2083 }
       
  2084 
       
  2085 TInt
       
  2086 CVHPPTestClass::SetDrmProtectedL( CStifItemParser& aItem )
       
  2087 {
       
  2088     MPX_ENTER_EXIT(_L("CVHPPTestClass::SetDrmProtectedL()"));
       
  2089 
       
  2090     TBool drmError = EFalse;
       
  2091 
       
  2092     TInt err = aItem.GetNextInt( drmError );
       
  2093 
       
  2094     if ( err == KErrNone )
       
  2095     {
       
  2096         WriteControllerError( KDrmRightsFile, drmError );
       
  2097     }
       
  2098 
       
  2099     return err;
       
  2100 }
       
  2101 
       
  2102 // ----------------------------------------------------------------------------- 
       
  2103 //  CVHPPTestClass::SetVolumeSteps 
       
  2104 // ----------------------------------------------------------------------------- 
       
  2105 // 
       
  2106 TInt 
       
  2107 CVHPPTestClass::SetVolumeSteps( TInt aVolumeSteps ) 
       
  2108 { 
       
  2109     MPX_ENTER_EXIT(_L("CVHPPTestClass::SetVolumeSteps()")); 
       
  2110     iLog->Log(_L("CVHPPTestClass::SetVolumeSteps()")); 
       
  2111     
       
  2112     iPlayerUtility->SetVolumeSteps( aVolumeSteps );
       
  2113     
       
  2114     return KErrNone; 
       
  2115 } 
       
  2116 
       
  2117 // ----------------------------------------------------------------------------- 
       
  2118 //  CVHPPTestClass::HandleVolumeL 
       
  2119 // ----------------------------------------------------------------------------- 
       
  2120 // 
       
  2121 TInt 
       
  2122 CVHPPTestClass::HandleVolumeL( CStifItemParser& aItem ) 
       
  2123 { 
       
  2124     MPX_ENTER_EXIT(_L("CVHPPTestClass::HandleVolumeL()")); 
       
  2125     iLog->Log(_L("CVHPPTestClass::HandleVolumeL()")); 
       
  2126       
       
  2127     TInt command; 
       
  2128     TInt value; 
       
  2129     
       
  2130     TInt err = aItem.GetNextInt( command );
       
  2131 
       
  2132     if ( err == KErrNone )
       
  2133     {
       
  2134         err = aItem.GetNextInt( value );
       
  2135 
       
  2136         if ( err == KErrNone ) 
       
  2137         {         
       
  2138             // 
       
  2139             // assign callback event values 
       
  2140             // 
       
  2141             TCallbackEvent* event = new TCallbackEvent; 
       
  2142             event->iEvent = EPVolumeChanged; 
       
  2143             event->iData  = value; 
       
  2144             event->iError = KErrNone; 
       
  2145                   
       
  2146             // 
       
  2147             // save expected result to be compared later 
       
  2148             // 
       
  2149             AddExpectedEvent( event ); 
       
  2150     
       
  2151             //
       
  2152             // send command to playback plugin
       
  2153             //
       
  2154             CreateVideoPlaybackCommandL( aItem, (TMPXVideoPlaybackCommand)command ); 
       
  2155         } 
       
  2156     }
       
  2157     
       
  2158     if ( err == KErrNone )
       
  2159     {
       
  2160         MPX_DEBUG(_L("CVHPPTestClass::HandleVolumeL() leaves with proper error"));
       
  2161     }
       
  2162     
       
  2163     return err; 
       
  2164 } 
       
  2165 
       
  2166 //  EOF