videoplayback/videoplaybackcontrols/tsrc/videoplaybackcontrols_test/src/mpxvpbc_stub.cpp
changeset 0 96612d01cf9f
child 1 6711b85517b7
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 VideoPlaybackControls
       
    15 *
       
    16 */
       
    17 
       
    18 // Version : %version: ou1cpsw#11 %
       
    19 
       
    20 
       
    21 // INCLUDES
       
    22 #include <coeaui.h>
       
    23 #include <aknutils.h>
       
    24 #include <aknsutils.h> 
       
    25 #include <aknviewappui.h>
       
    26 #include <aknsdrawutils.h>
       
    27 #include <aknsbasicbackgroundcontrolcontext.h>
       
    28 
       
    29 #include "mpxvideoplaybackviewfiledetails.h"
       
    30 #include "videoplaybackcontrolstest.h"
       
    31 #include "mpxvpbc_stub.h"
       
    32 #include "mpxvideoplaybackcontrolscontroller.h"
       
    33 #include "mpxhelixplaybackplugindefs.h"
       
    34 #include "mpxvpbuih_stub.h"
       
    35 #include "mpxcommonvideoplaybackview.hrh"
       
    36 #include "mpxvideo_debug.h"
       
    37 
       
    38 // ============================ MEMBER FUNCTIONS ===================================================
       
    39 
       
    40 // -------------------------------------------------------------------------------------------------
       
    41 // CMPXVideoPlaybackContainer::CMPXVideoPlaybackContainer
       
    42 // C++ default constructor can NOT contain any code, that
       
    43 // might leave.
       
    44 // -------------------------------------------------------------------------------------------------
       
    45 //
       
    46 
       
    47 CMPXVideoPlaybackContainer::CMPXVideoPlaybackContainer()
       
    48 {
       
    49 }
       
    50 
       
    51 // -------------------------------------------------------------------------------------------------
       
    52 // CMPXVideoPlaybackContainer::ConstructL()
       
    53 // Symbian 2nd phase constructor can leave.
       
    54 // -------------------------------------------------------------------------------------------------
       
    55 //
       
    56 void CMPXVideoPlaybackContainer::ConstructL( const TDesC& aFileName )
       
    57 {
       
    58     MPX_DEBUG(_L("CMPXVideoPlaybackContainer::ConstructL()"));
       
    59 
       
    60     iFileDetails = CMPXVideoPlaybackViewFileDetails::NewL();    
       
    61     iFileDetails->iClipName = HBufC::NewL( aFileName.Length() );
       
    62     iFileDetails->iClipName->Des().Copy( aFileName );
       
    63 
       
    64     CreateWindowL();       
       
    65 
       
    66     iUserInputHandler = CMPXVideoPlaybackUserInputHandler::NewL( this );
       
    67     
       
    68     SetFocus( ETrue );
       
    69     
       
    70     MakeVisible( ETrue );
       
    71 
       
    72     ActivateL();
       
    73 }
       
    74 
       
    75 // -------------------------------------------------------------------------------------------------
       
    76 // CMPXVideoPlaybackContainer::NewL()
       
    77 // Two-phased constructor.
       
    78 // -------------------------------------------------------------------------------------------------
       
    79 //
       
    80 CMPXVideoPlaybackContainer* CMPXVideoPlaybackContainer::NewL( const TDesC& aFileName )
       
    81 {
       
    82     MPX_DEBUG(_L("CMPXVideoPlaybackContainer::NewL( %S )"),&aFileName);
       
    83 
       
    84     CMPXVideoPlaybackContainer* self = new (ELeave) CMPXVideoPlaybackContainer();
       
    85 
       
    86 
       
    87     CleanupStack::PushL( self );
       
    88     self->ConstructL( aFileName );
       
    89     CleanupStack::Pop();
       
    90 
       
    91     return self;
       
    92 }
       
    93 
       
    94 // 
       
    95 // -------------------------------------------------------------------------------------------------
       
    96 // CMPXVideoPlaybackContainer::~CMPXVideoPlaybackContainer()
       
    97 // Destructor.
       
    98 // -------------------------------------------------------------------------------------------------
       
    99 //
       
   100 CMPXVideoPlaybackContainer::~CMPXVideoPlaybackContainer()
       
   101 {
       
   102     MPX_DEBUG(_L("CMPXVideoPlaybackContainer::~CMPXVideoPlaybackContainer()"));
       
   103 
       
   104     if ( iFileDetails )
       
   105     {
       
   106         delete iFileDetails;
       
   107         iFileDetails = NULL;
       
   108     }   
       
   109     
       
   110     if ( iUserInputHandler )
       
   111     {
       
   112         delete iUserInputHandler;
       
   113         iUserInputHandler = NULL;
       
   114     } 
       
   115 
       
   116     CloseWindow();
       
   117 }
       
   118 
       
   119 // -------------------------------------------------------------------------------------------------
       
   120 // CMPXVideoPlaybackContainer::CountComponentControls
       
   121 // -------------------------------------------------------------------------------------------------
       
   122 //
       
   123 TInt CMPXVideoPlaybackContainer::CountComponentControls() const
       
   124 {
       
   125     return 0;
       
   126 }
       
   127 
       
   128 // -------------------------------------------------------------------------------------------------
       
   129 // CMPXVideoPlaybackContainer::Draw
       
   130 // -------------------------------------------------------------------------------------------------
       
   131 //
       
   132 void CMPXVideoPlaybackContainer::Draw(const TRect& aRect) const
       
   133 {
       
   134     CWindowGc& gc = SystemGc();
       
   135 
       
   136     gc.SetPenStyle( CGraphicsContext::ENullPen );
       
   137     gc.SetBrushColor( KRgbBlack );
       
   138     gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
       
   139     gc.DrawRect( aRect );
       
   140 }
       
   141 
       
   142 // 
       
   143 // -------------------------------------------------------------------------------------------------
       
   144 // CMPXVideoPlaybackContainer::HandleCommandL()
       
   145 // -------------------------------------------------------------------------------------------------
       
   146 //
       
   147 void CMPXVideoPlaybackContainer::HandleCommandL( TInt aCommand, TInt aValue )
       
   148 {
       
   149     MPX_DEBUG(_L("CMPXVideoPlaybackContainer::HandleCommandL(aCommand=%d,aValue=%d)"),aCommand,aValue);
       
   150 
       
   151     iCommand = aCommand;
       
   152     iValue = aValue;
       
   153 }
       
   154 
       
   155 // 
       
   156 // -------------------------------------------------------------------------------------------------
       
   157 // CMPXVideoPlaybackContainer::ExpectedResultL()
       
   158 // -------------------------------------------------------------------------------------------------
       
   159 //
       
   160 void CMPXVideoPlaybackContainer::ExpectedResultL( TInt aCommand, TInt aValue )
       
   161 {
       
   162     MPX_DEBUG(_L("CMPXVideoPlaybackContainer::ExpectedResultL(aCommand=%d,aValue=%d)"),aCommand,aValue);
       
   163 
       
   164     if ( iCommand != aCommand || iValue != aValue )
       
   165     {
       
   166         User::Leave( KErrGeneral );
       
   167     }
       
   168 }
       
   169 
       
   170 //
       
   171 // -------------------------------------------------------------------------------------------------
       
   172 // CMPXVideoPlaybackContainer::SetController()
       
   173 // -------------------------------------------------------------------------------------------------
       
   174 //
       
   175 void CMPXVideoPlaybackContainer::SetController(
       
   176     CMPXVideoPlaybackControlsController* aControlsController )
       
   177 {
       
   178     MPX_DEBUG(_L("CMPXVideoPlaybackContainer::SetController()"));
       
   179 
       
   180     iControlsController = aControlsController;
       
   181 }
       
   182 
       
   183 //
       
   184 // -------------------------------------------------------------------------------------------------
       
   185 // CMPXVideoPlaybackContainer::AddFileDetailsL()
       
   186 // -------------------------------------------------------------------------------------------------
       
   187 //
       
   188 void CMPXVideoPlaybackContainer::AddFileDetailsL( TBool aHasVideoTrack )
       
   189 {
       
   190     MPX_DEBUG(_L("CMPXVideoPlaybackContainer::AddFileDetailsL() "));
       
   191 
       
   192     iFileDetails->iAudioEnabled = ETrue;
       
   193     iFileDetails->iVideoEnabled = aHasVideoTrack;
       
   194     iFileDetails->iVideoEnabled = aHasVideoTrack;
       
   195     iFileDetails->iSeekable = ETrue;
       
   196     
       
   197     iFileDetails->iTitle    = _L("Test Title").Alloc();
       
   198 
       
   199     if ( iFileDetails->iVideoEnabled )
       
   200     {        
       
   201         iFileDetails->iVideoHeight = 176;
       
   202         iFileDetails->iVideoWidth = 144;
       
   203         
       
   204         iFileDetails->iBitRate = 8000;
       
   205         iFileDetails->iMimeType = _L("video/3gp").Alloc();        
       
   206     }
       
   207 
       
   208     if ( iFileDetails->iPlaybackMode == EMPXVideoLiveStreaming )
       
   209     {
       
   210         iFileDetails->iSeekable = EFalse;
       
   211     }
       
   212 
       
   213     iControlsController->AddFileDetailsL( iFileDetails );
       
   214 }
       
   215 
       
   216 //
       
   217 // -------------------------------------------------------------------------------------------------
       
   218 // CMPXVideoPlaybackContainer::AddFileDetailsL()
       
   219 // -------------------------------------------------------------------------------------------------
       
   220 //
       
   221 CMPXVideoPlaybackViewFileDetails*
       
   222 CMPXVideoPlaybackContainer::FileDetails( TInt aMode )
       
   223 {
       
   224     MPX_DEBUG(_L("CMPXVideoPlaybackContainer::AddFileDetailsL() "));
       
   225 
       
   226     iFileDetails->iPlaybackMode = (TMPXVideoMode)aMode;
       
   227 
       
   228     return iFileDetails;
       
   229 }
       
   230 
       
   231 // -------------------------------------------------------------------------------------------------
       
   232 // From CCoeControl
       
   233 // Handles key events.
       
   234 // -------------------------------------------------------------------------------------------------
       
   235 //
       
   236 TKeyResponse CMPXVideoPlaybackContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent,
       
   237                                                          TEventCode aType )
       
   238 {
       
   239     iKeyResponse = EKeyWasNotConsumed;
       
   240     
       
   241     iUserInputHandler->ProcessKeyEventL( aKeyEvent, aType );
       
   242     
       
   243     return iKeyResponse;
       
   244 }
       
   245 
       
   246 // -------------------------------------------------------------------------------------------------
       
   247 // CMPXVideoPlaybackContainer::DoHandleKeyEventL()
       
   248 // -------------------------------------------------------------------------------------------------
       
   249 //
       
   250 void CMPXVideoPlaybackContainer::DoHandleKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType )
       
   251 {
       
   252     MPX_DEBUG(_L("CMPXVideoPlaybackContainer::DoHandleKeyEventL()"));
       
   253     
       
   254     switch ( aKeyEvent.iScanCode )
       
   255     {
       
   256         case EStdKeyDevice3:        // rocker middle key
       
   257         case EStdKeyEnter:          // enter key on a qwerty key board
       
   258         {
       
   259             HandleCommandL(EMPXPbvCmdPlayPause);
       
   260             iKeyResponse = EKeyWasConsumed;
       
   261             break;
       
   262         }
       
   263         case EStdKeyUpArrow:        // rocker up key
       
   264         {
       
   265             HandleCommandL(EMPXPbvCmdIncreaseVolume);
       
   266             iKeyResponse = EKeyWasConsumed;
       
   267             break;
       
   268         }
       
   269         case EStdKeyDownArrow:      // rocker down key
       
   270         {
       
   271             HandleCommandL( EMPXPbvCmdDecreaseVolume );
       
   272             iKeyResponse = EKeyWasConsumed;
       
   273             break;
       
   274         }
       
   275         case EStdKeyLeftArrow:      // rocker left key
       
   276         {
       
   277             if (aType == EEventKeyDown)
       
   278             {
       
   279                 HandleCommandL(EMPXPbvCmdSeekBackward);
       
   280             }
       
   281             else if (aType == EEventKeyUp)
       
   282             {
       
   283                 HandleCommandL(EMPXPbvCmdEndSeek);
       
   284             }
       
   285             
       
   286             iKeyResponse = EKeyWasConsumed;
       
   287             break;
       
   288         }
       
   289         case EStdKeyRightArrow:     // rocker right key
       
   290         {
       
   291             if (aType == EEventKeyDown)
       
   292             {
       
   293                 HandleCommandL(EMPXPbvCmdSeekForward);
       
   294             }
       
   295             else if (aType == EEventKeyUp)
       
   296             {
       
   297                 HandleCommandL(EMPXPbvCmdEndSeek);
       
   298             }
       
   299             
       
   300             iKeyResponse = EKeyWasConsumed;
       
   301             break;
       
   302         }
       
   303         case EStdKeyYes:            // green/send key
       
   304         {
       
   305             // in playback view we dont want to take any action
       
   306             // just consume the key
       
   307             iKeyResponse = EKeyWasConsumed;
       
   308             break;
       
   309         }
       
   310         default:
       
   311         {
       
   312             break;
       
   313         }
       
   314     }    
       
   315 }
       
   316 
       
   317 // -------------------------------------------------------------------------------------------------
       
   318 // CMPXVideoPlaybackContainer::UserInputHandler()
       
   319 // -------------------------------------------------------------------------------------------------
       
   320 //
       
   321 CMPXVideoPlaybackUserInputHandler* CMPXVideoPlaybackContainer::UserInputHandler()
       
   322 {
       
   323     return iUserInputHandler;
       
   324 }
       
   325 
       
   326 
       
   327 //  End of File