201035
authorhgs
Fri, 03 Sep 2010 19:37:02 -0500
changeset 33 e1b6d78dfe6a
parent 29 b818131c88a3
child 36 20d2741ccdad
201035
group/bld.inf
helix_ren/group/bld.inf
package_definition.xml
tsrc/consoleplayer/common/testappbase.cpp
tsrc/consoleplayer/common/testappbase.h
tsrc/consoleplayer/common/timercallback.cpp
tsrc/consoleplayer/common/timercallback.h
tsrc/consoleplayer/group/bld.inf
tsrc/consoleplayer/player/group/bld.inf
tsrc/consoleplayer/player/group/consoleplayer.mmp
tsrc/consoleplayer/player/group/consoleplayer.pkg
tsrc/consoleplayer/player/group/consoleplayer_reg.rss
tsrc/consoleplayer/player/group/create_sis.bat
tsrc/consoleplayer/player/group/externalplayer.mmp
tsrc/consoleplayer/player/group/externalplayer2.mmp
tsrc/consoleplayer/player/inc/consoleplayer.h
tsrc/consoleplayer/player/inc/externalplayer.h
tsrc/consoleplayer/player/inc/playerwindow.h
tsrc/consoleplayer/player/src/consoleplayer.cpp
tsrc/consoleplayer/player/src/externalplayer.cpp
tsrc/consoleplayer/player/src/mmf/mmfplayerwindow.cpp
tsrc/consoleplayer/player/src/mmf/mmfplayerwindow.h
tsrc/consoleplayer/player/src/openmax_al/openmaxplayerutility.cpp
tsrc/consoleplayer/player/src/openmax_al/openmaxplayerutility.h
tsrc/consoleplayer/player/src/openmax_al/opmaxplayerwindow.cpp
tsrc/consoleplayer/player/src/openmax_al/opmaxplayerwindow.h
tsrc/consoleplayer/player/src/playerwindow.cpp
tsrc/consoleplayer/thumbnail/group/bld.inf
tsrc/consoleplayer/thumbnail/group/create_sis.bat
tsrc/consoleplayer/thumbnail/group/thumbnailtester.mmp
tsrc/consoleplayer/thumbnail/group/thumbnailtester.pkg
tsrc/consoleplayer/thumbnail/group/thumbnailtester_reg.rss
tsrc/consoleplayer/thumbnail/src/brightnesscontrast.h
tsrc/consoleplayer/thumbnail/src/thumbnailtester.cpp
tsrc/consoleplayer/thumbnail/src/thumbnailtester.h
tsrc/consoleplayer/thumbnail/src/yuv2rgb24.cpp
tsrc/consoleplayer/thumbnail/src/yuv2rgb24.h
--- a/group/bld.inf	Wed Aug 25 00:54:11 2010 -0500
+++ b/group/bld.inf	Fri Sep 03 19:37:02 2010 -0500
@@ -1,20 +1,18 @@
 /*
-* ==============================================================================
-*  Name        : bld.inf
-*  Part of     : 
-*  Description : 
-*  Version     : 
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
 *
-*  Copyright © 2006 Nokia. All rights reserved.
-*  This material, including documentation and any related
-*  computer programs, is protected by copyright controlled by
-*  Nokia Corporation. All rights are reserved. Copying,
-*  including reproducing, storing, adapting or translating, any
-*  or all of this material requires the prior written consent of
-*  Nokia. This material also contains confidential
-*  information which may not be disclosed to others without the
-*  prior written consent of Nokia.
-* ==============================================================================
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Build information file for helix
+*
 */
 
 #include <platform_paths.hrh>
--- a/helix_ren/group/bld.inf	Wed Aug 25 00:54:11 2010 -0500
+++ b/helix_ren/group/bld.inf	Fri Sep 03 19:37:02 2010 -0500
@@ -1,20 +1,18 @@
 /*
-* ==============================================================================
-*  Name        : bld.inf
-*  Part of     : HELIXENGINE	
-*  Description : This main bld.inf file for HELIX_MDF 
-*  Version     : 
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
 *
-*  Copyright © 2006 Nokia Corporation.
-*  This material, including documentation and any related 
-*  computer programs, is protected by copyright controlled by 
-*  Nokia Corporation. All rights are reserved. Copying, 
-*  including reproducing, storing, adapting or translating, any 
-*  or all of this material requires the prior written consent of 
-*  Nokia Corporation. This material also contains confidential 
-*  information which may not be disclosed to others without the 
-*  prior written consent of Nokia Corporation.
-* ==============================================================================
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Build information file for helix
+*
 */
 
 #include <platform_paths.hrh>
--- a/package_definition.xml	Wed Aug 25 00:54:11 2010 -0500
+++ b/package_definition.xml	Fri Sep 03 19:37:02 2010 -0500
@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <SystemDefinition schema="3.0.0">
-  <package id="sf:helix" name="Helix" levels="plugin framework server generic specific">
-    <collection id="sf:helix_ren" name="Helix Engine" level="framework">
-      <component id="sf:helix_ren_build" filter="s60" name="Helix Engine Build" introduced="^2">
+  <package id="helix" name="Helix" levels="plugin framework server generic specific">
+    <collection id="helix_ren" name="Helix Engine" level="framework">
+      <component id="helix_ren_build" filter="s60" name="Helix Engine Build" introduced="^2">
        <unit bldFile="helix_ren/group"/>
       </component>
       <component id="helix_stub" filter="sf_build" name="Helix Stub" class="api" introduced="^2">
@@ -11,6 +11,11 @@
       <component id="helixrfsplugin" filter="s60" name="Helix RFS Plugin" class="plugin" introduced="^2">
         <unit bldFile="helix_ren/helixrfsplugin/group"/>
       </component>
-    </collection>
+    </collection>    
+    <collection id="helix_test" name="Helix test" level="specific">
+      <component id="helix_tsrc" filter="s60,test,pref_test,module_test" name="console player" introduced="^2">
+       <unit bldFile="tsrc/consoleplayer/group"/>
+      </component>      
+    </collection>    
   </package>
 </SystemDefinition>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/consoleplayer/common/testappbase.cpp	Fri Sep 03 19:37:02 2010 -0500
@@ -0,0 +1,1330 @@
+/*
+ * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ * Source file containing common test app functionality.
+ * 
+ */
+
+#include <f32file.h>
+#include <remconcoreapitarget.h>
+#include <remconinterfaceselector.h>
+
+#include "testappbase.h"
+
+const TInt KLeftSoftKeyCode  = EKeyDevice0;
+const TInt KRightSoftKeyCode = EKeyDevice1;
+
+const TInt KHelpWindowBorderPixels = 20;
+const TInt KHelpWindowSpaceBetweenColumns = 25;
+const TInt KHelpWindowSpaceBetweenRows = 2;
+
+struct TKeyListEntry
+    {
+    TInt         keyCode;
+    const TText* keyName;
+    };
+
+const TKeyListEntry KSupportedKeys[KSupportedKeysCount] =
+        {
+            {EKeyEnter,      STR("Enter")},      
+            {EKeyUpArrow,    STR("Up")},
+            {EKeyDownArrow,  STR("Down")}, 
+            {EKeyLeftArrow,  STR("Left")},
+            {EKeyRightArrow, STR("Right")},
+            {'0',            STR("0")},
+            {'1',            STR("1")},  
+            {'2',            STR("2")}, 
+            {'3',            STR("3")},
+            {'4',            STR("4")},
+            {'5',            STR("5")},
+            {'6',            STR("6")},
+            {'7',            STR("7")},
+            {'8',            STR("8")},
+            {'9',            STR("9")},
+            {'*',            STR("*")},
+            {'#',            STR("#")}
+        };
+        
+static TPtrC KeyName( TInt aIndex )
+    {
+    return TPtrC(KSupportedKeys[aIndex].keyName);
+    }
+
+// Portable app implementation
+
+CTestAppBase::CTestAppBase( TInt aFontSize ) : 
+    CActive( EPriorityStandard ),
+    iFontSize( aFontSize ),
+    iHelpSemitransparentBackgroundActive( true )
+    {    
+    CActiveScheduler::Add(this);
+    }
+
+CTestAppBase::~CTestAppBase()
+    {
+    delete iInterfaceSelector;
+    delete iHelpWindow;
+    delete iSelectionWindow;
+    delete iGc;
+    delete iWindowGroup;
+    delete iScreenDevice;
+    delete iTypefaceStore;
+    iWs.Close();
+    iFs.Close();
+    iFileHistory.ResetAndDestroy();
+    }
+
+void CTestAppBase::BaseConstructL( const TOperationsPage* aKeyMap, TInt aPageCount )
+    {
+    iKeyMap = aKeyMap;
+    iPageCount = aPageCount;
+    
+    User::LeaveIfError( iFs.Connect() );        
+    
+    User::LeaveIfError( iWs.Connect() );    
+
+    iScreenDevice = new(ELeave) CWsScreenDevice( iWs );
+    User::LeaveIfError( iScreenDevice->Construct() );
+    iDisplaySize = iScreenDevice->SizeInPixels();
+    
+    User::LeaveIfError( iScreenDevice->CreateContext(iGc) );
+
+    iWindowGroup = new(ELeave) RWindowGroup( iWs );
+    User::LeaveIfError( iWindowGroup->Construct( KNullWsHandle ) );
+
+    iSelectionWindow = new(ELeave) RWindow( iWs );
+    User::LeaveIfError( iSelectionWindow->Construct( *iWindowGroup, KNullWsHandle ) );    
+    iSelectionWindow->SetVisible(false);
+    iSelectionWindow->Activate();    
+            
+    // Load the font to be used for all text operations.
+    TFontSpec fontSpec;
+    fontSpec.iHeight = iFontSize;
+    iTypefaceStore = CFbsTypefaceStore::NewL(NULL);
+    
+    User::LeaveIfError( iTypefaceStore->GetNearestFontToDesignHeightInPixels(iFont, fontSpec) );
+
+    CalculateHelpWindowSize();
+
+    iHelpWindowTopRight = TPoint(iDisplaySize.iWidth/2 - iHelpWindowSize.iWidth/2, 
+                                 iDisplaySize.iHeight/2 - iHelpWindowSize.iHeight/2);
+
+    iHelpWindow = new(ELeave) RWindow( iWs );
+    User::LeaveIfError( iHelpWindow->Construct( *iWindowGroup, KNullWsHandle ) );
+    iHelpWindow->SetExtent( iHelpWindowTopRight, iHelpWindowSize );
+    iHelpWindow->SetTransparencyAlphaChannel();
+    iHelpWindow->SetBackgroundColor(KRgbTransparent);
+    iHelpWindow->SetVisible(false);
+    iHelpWindow->Activate();
+    iHelpWindow->PointerFilter(EPointerFilterDrag, 0);
+
+    // Initialize soft key indices
+    for( TInt i = 0; i < aPageCount; i++ )
+        {
+        iSoftkeyIndices[i] = iKeyMap[i].defaultSoftkeyIndex;
+        }
+    
+    // Only need to draw the help text when the options page is changed.  Window is displayed later by
+    // toggling the visibility of the window.
+    DrawHelpText();
+    
+    // THE FOLLOWING CODE IS COMMENTED OUT BECAUSE IT CAUSES A CRASH IN NCP BUILDS.
+    // THIS CAN BE ENABLED IN DFS BUILDS, TO ALLOW FOR TWO BUTTON OPERATION USING THE VOLUME KEYS.
+    //
+    // Since some phone have no keyboard or soft keys, treat the volume keys like the soft keys.
+    // SetupVolumeKeysL();    
+    }
+
+void CTestAppBase::SetupVolumeKeysL()
+    {
+    iInterfaceSelector = CRemConInterfaceSelector::NewL();
+    iCoreTarget = CRemConCoreApiTarget::NewL(*iInterfaceSelector, *this);
+    iInterfaceSelector->OpenTargetL();
+    }
+
+void CTestAppBase::StartMonitoringWindowEvents()
+    {
+    // Request notification for windows server events, to detect key presses.    
+    SetActive();
+    iWs.EventReady( &iStatus );
+    }
+
+TInt CTestAppBase::CurrentPageNumber()
+    {
+    return iCurrentPage+1;
+    }
+
+TPtrC CTestAppBase::CurrentPageName()
+    {
+    return TPtrC(iKeyMap[iCurrentPage].pageName);
+    }
+
+TPtrC CTestAppBase::CurrentSoftkeyName()
+    {
+    return TPtrC(iKeyMap[iCurrentPage].mapping[iSoftkeyIndices[iCurrentPage]].text);    
+    }
+    
+TPtrC CTestAppBase::KeyMapText( TInt aIndex, TInt aPage )
+    {
+    return TPtrC(iKeyMap[aPage].mapping[aIndex].text);
+    }
+
+TInt CTestAppBase::KeyMapOperation(TInt aIndex, TInt aPage )
+    {
+    return iKeyMap[aPage].mapping[aIndex].operation;
+    }
+
+void CTestAppBase::IncrementKeymapIndex( TInt& aIndex, TInt aPage )
+    {
+    aIndex = (aIndex + 1) % KSupportedKeysCount;
+    while( iKeyMap[aPage].mapping[aIndex].operation == KOperation_None )
+        {
+        aIndex = (aIndex + 1) % KSupportedKeysCount;
+        }
+    }
+
+void CTestAppBase::DecrementKeymapIndex( TInt& aIndex, TInt aPage )
+    {
+    aIndex = (aIndex + KSupportedKeysCount - 1) % KSupportedKeysCount;
+    while( iKeyMap[aPage].mapping[aIndex].operation == KOperation_None )
+        {
+        aIndex = (aIndex + KSupportedKeysCount - 1) % KSupportedKeysCount;
+        }
+    }
+
+void CTestAppBase::CalculateHelpWindowSize()
+    {
+    iHelpWindowColumn1Width = 0;
+    iHelpWindowColumn2Width = 0;
+    
+    // Find the widest strings for each column to determine the width of the window.
+    for( TInt index = 0; index < KSupportedKeysCount; index++ )
+        {
+        TInt width = iFont->TextWidthInPixels(KeyName(index));
+        if( width > iHelpWindowColumn1Width )
+            {
+            iHelpWindowColumn1Width = width;
+            }
+        
+        for( TInt index2 = 0; index2 < iPageCount; index2++ )
+            {
+            width = iFont->TextWidthInPixels(KeyMapText(index,index2));
+            if( width > iHelpWindowColumn2Width )
+                {
+                iHelpWindowColumn2Width = width;
+                }                    
+            }
+        }    
+    
+    iHelpWindowSize.iWidth = 2*KHelpWindowBorderPixels + iHelpWindowColumn1Width + 
+                             KHelpWindowSpaceBetweenColumns + iHelpWindowColumn2Width;
+    
+    iHelpWindowSize.iHeight = 2*KHelpWindowBorderPixels + iFontSize*KSupportedKeysCount + 
+                              KHelpWindowSpaceBetweenRows*(KSupportedKeysCount-1);
+    }
+
+void CTestAppBase::StartReceivingPointerEvents()
+    {
+    iRoutePointerEventsToApp = true;
+    }
+
+void CTestAppBase::StopReceivingPointerEvents()
+    {
+    iRoutePointerEventsToApp = false;
+    }
+
+//virtual void HandlePointerEvent( const TPointerEvent& aEvent ) {}
+
+CTestAppBase::TTestAppPointerEvent CTestAppBase::CharacterizePointerEvent( const TAdvancedPointerEvent& event )
+    {
+    TTestAppPointerEvent returnValue = EPointerEvent_None;
+    
+    RDebug::Printf( "POINTER EVENT:" );        
+    RDebug::Printf( "iType=%i", event.iType );
+    RDebug::Printf( "iModifiers=%x", event.iModifiers );
+    RDebug::Printf( "iPosition=%i,%i", event.iPosition.iX, event.iPosition.iY );
+    RDebug::Printf( "iParentPosition=%i,%i", event.iParentPosition.iX, event.iParentPosition.iY );
+    RDebug::Printf( "PointerNumber=%i", event.PointerNumber() );
+    RDebug::Printf( "Proximity=%i", event.Proximity() );
+    RDebug::Printf( "Pressure=%i", event.Pressure() );
+    RDebug::Printf( "ProximityAndPressure=%i", event.ProximityAndPressure() );
+    RDebug::Printf( "Position3D=%i,%i,%i", event.Position3D().iX, event.Position3D().iY, event.Position3D().iZ );
+    RDebug::Printf( "Pressure3D=%i,%i,%i", event.Pressure3D().iX, event.Pressure3D().iY, event.Pressure3D().iZ );
+    RDebug::Printf( "PositionAndPressure3D=%i,%i,%i", event.PositionAndPressure3D().iX, event.PositionAndPressure3D().iY, event.PositionAndPressure3D().iZ );
+    
+    switch( event.iType )
+        {
+        case TPointerEvent::EButton1Down:
+            {
+            iPointerDownPosition = event.iPosition;            
+            break;
+            }
+        case TPointerEvent::EButton1Up:
+            {
+            TInt xDelta = event.iPosition.iX - iPointerDownPosition.iX; 
+            TInt yDelta = event.iPosition.iY - iPointerDownPosition.iY;
+            
+            TInt xMagnitude = xDelta;
+            if( xMagnitude < 0 )
+                {
+                xMagnitude = -xMagnitude;
+                }
+            
+            TInt yMagnitude = yDelta;
+            if( yMagnitude < 0 )
+                {
+                yMagnitude = -yMagnitude;
+                }
+
+            const TInt KTapThreshold = 30;
+            
+            if( yMagnitude > xMagnitude )
+                {
+                if( yMagnitude < KTapThreshold )
+                    {
+                    RDebug::Printf( "POINTER EVENT ENTER x=%i y=%i", xDelta, yDelta );                            
+                    returnValue = EPointerEvent_Select;
+                    }
+                else if( yDelta < 0 )
+                    {
+                    RDebug::Printf( "POINTER EVENT UP x=%i y=%i", xDelta, yDelta );        
+                    returnValue = EPointerEvent_Up;
+                    }
+                else
+                    {
+                    RDebug::Printf( "POINTER EVENT DOWN x=%i y=%i", xDelta, yDelta );                            
+                    returnValue = EPointerEvent_Down;
+                    }                
+                }
+            else
+                {
+                if( xMagnitude < KTapThreshold )
+                    {
+                    RDebug::Printf( "POINTER EVENT ENTER x=%i y=%i", xDelta, yDelta );                            
+                    returnValue = EPointerEvent_Select;
+                    }
+                else if( xDelta < 0 )
+                    {
+                    RDebug::Printf( "POINTER EVENT LEFT x=%i y=%i", xDelta, yDelta );        
+                    returnValue = EPointerEvent_Left;
+                    }
+                else
+                    {
+                    RDebug::Printf( "POINTER EVENT RIGHT x=%i y=%i", xDelta, yDelta );                            
+                    returnValue = EPointerEvent_Right;
+                    }                                
+                }
+            break;
+            }
+        }
+    
+    return returnValue;
+    }
+
+void CTestAppBase::RunL()
+    {
+    if( iWait.IsStarted() )
+        {
+        // This is an event during synchronous list selection.  Stop the nested scheduler.
+        iWait.AsyncStop();
+        return;
+        }    
+    
+    TWsEvent event;
+    iWs.GetEvent(event);
+
+    TInt operationIndex = -1;
+    
+    TInt keyCode = 0;
+    bool processKeyCode = false;
+    
+    TInt operation = KOperation_None; 
+    
+    // Other potentially useful events are EEventKeyUp and EEventKeyDown.
+    
+    if( event.Type() == EEventKey )
+        {
+        keyCode = event.Key()->iCode;
+                   
+        RDebug::Printf( "key event keyCode=%x/%c scanCode=%x/%c", keyCode, keyCode, event.Key()->iScanCode, event.Key()->iScanCode );
+        
+        // Allow subclasses a chance to consume the key event directly.  If that happens, then
+        // do not handle the key as normal.
+        if( !ConsumeKeyEvent( keyCode ) )
+            {
+            processKeyCode = true;        
+            }
+        }
+    else if( event.Type() == EEventPointer )
+        {
+        TAdvancedPointerEvent* p = event.Pointer();
+
+        if( iRoutePointerEventsToApp  )
+            {
+            HandlePointerEvent( *p );
+            }
+        else
+            {        
+            TTestAppPointerEvent pointerEvent = CharacterizePointerEvent( *p );
+
+            switch( pointerEvent )
+                {
+                case EPointerEvent_None:
+                    // Do nothing.
+                    break;
+                case EPointerEvent_Up:
+                    operation = KOperation_PreviousOption;
+                    break;
+                case EPointerEvent_Down:
+                    operation = KOperation_NextOption;
+                    break;
+                case EPointerEvent_Left:
+                    operation = KOperation_PreviousOptionPage;
+                    break;
+                case EPointerEvent_Right:
+                    operation = KOperation_NextOptionPage;
+                    break;
+                case EPointerEvent_Select:
+                    operation = KOperation_ExecuteOption;
+                    break;
+                }
+            }
+        }
+    else
+        {
+        RDebug::Printf( "other event, type=%i", event.Type() );    
+        }
+        
+    if( processKeyCode )
+        {
+        // If one of the softkeys were pressed then take the appropriate action.
+        // This is to support a two button touch device with no numeric keypad.
+        // Support 'A' and 'B' also, for the NCP emulator where a keyboard  is
+        // not displayed.
+        switch( keyCode )
+            {
+            case KLeftSoftKeyCode:
+            case 'a':
+            case 'A':
+                {
+                operation = KOperation_NextOption;
+                break;
+                } 
+            case KRightSoftKeyCode:
+            case 'b':
+            case 'B':
+                {
+                // Execute softkey function.
+                operation = KOperation_ExecuteOption;
+                break;
+                }
+            default:
+                {
+                // Search for keycode in keymap.  If not found then the key was not a valid
+                // key, so ignore.                
+                TInt index = 0;
+                while( (index < KSupportedKeysCount) && (operationIndex == -1))
+                    {
+                    if( KSupportedKeys[index].keyCode == keyCode )
+                        {                
+                        // Found!
+                        operationIndex = index;
+                        }
+                    else
+                        {
+                        index++;
+                        }
+                    }
+                break;
+                }                
+            }        
+        }
+    
+    if( operation == KOperation_ExecuteOption )
+        {
+        operationIndex = iSoftkeyIndices[iCurrentPage];
+        }
+    
+    if( operationIndex >= 0 )
+        {
+        operation = KeyMapOperation(operationIndex, iCurrentPage);    
+        }
+    
+    if( operation != KOperation_None )
+        {
+        // Valid operation.
+
+        switch( operation )
+            {
+            case KOperation_Exit:
+                {                
+                CActiveScheduler::Stop();
+                break;
+                }
+            case KOperation_PreviousOption:
+                {
+                // Change softkey function.
+                DecrementKeymapIndex( iSoftkeyIndices[iCurrentPage], iCurrentPage );
+                
+                // Redraw help text, since a new function should now be underlined.
+                DrawHelpText();
+                
+                // Notify subclass that softkey function has been updated.
+                SoftkeyFunctionUpdated();
+                break;
+                }
+            case KOperation_NextOption:
+                {
+                // Change softkey function.
+                IncrementKeymapIndex( iSoftkeyIndices[iCurrentPage], iCurrentPage );
+                
+                // Redraw help text, since a new function should now be underlined.
+                DrawHelpText();
+                
+                // Notify subclass that softkey function has been updated.
+                SoftkeyFunctionUpdated();
+                break;
+                }
+            case KOperation_PreviousOptionPage:
+                {
+                iCurrentPage = (iCurrentPage + iPageCount - 1) % iPageCount;
+                DrawHelpText();
+                SoftkeyFunctionUpdated();                
+                break;
+                }
+            case KOperation_NextOptionPage:
+                {
+                iCurrentPage = (iCurrentPage + 1) % iPageCount;
+                DrawHelpText();
+                SoftkeyFunctionUpdated();                
+                break;
+                }
+            case KOperation_ToggleHelpVisibility:    
+                {
+                // Toggle help text on/off.
+                iHelpActive = !iHelpActive;
+                iHelpWindow->SetVisible(iHelpActive);
+                break;
+                }
+            case KOperation_ToggleHelpTransparency:
+                {
+                iHelpSemitransparentBackgroundActive = !iHelpSemitransparentBackgroundActive;
+                if( iHelpSemitransparentBackgroundActive )
+                    {
+                    // Turn on help if it is currently off.
+                    iHelpActive = true;
+                    iHelpWindow->SetVisible(true);
+                    }
+                DrawHelpText();
+                break;            
+                }
+            default:
+                {
+                // Pass operation to subclass.
+                TPtrC operatioName( KeyMapText(operationIndex, iCurrentPage) );
+                ExecuteOperation( operation, operatioName );                        
+                break;
+                }
+            }    
+        }        
+    
+    SetActive();
+    iWs.EventReady( &iStatus );
+    }            
+
+void CTestAppBase::DoCancel()
+    {
+    iWs.EventReadyCancel();
+    }
+
+// TODO: ALLOW SUBCLASS TO SPECIFY COLOR SELECTIONS
+
+TInt CTestAppBase::SelectFromListL( TPoint aTopLeft,
+                                    TSize aSize,
+                                    const TDesC& aHeaderText, 
+                                    RPointerArray<TDesC>& aSelectionList, 
+                                    TInt aInitialSelectionIndex )
+    {
+    iSelectionWindow->SetExtent( aTopLeft, aSize );
+    iSelectionWindow->SetVisible( true );
+
+    const TInt KRowIncrement = iFontSize + 2;
+    
+    TInt entriesPerPage = aSize.iHeight / KRowIncrement - 4;
+    
+    TInt returnValue = -2;
+    TInt startIndex = 0;
+    TInt selected = aInitialSelectionIndex;     
+    
+    while( returnValue == -2 )
+        {
+        iGc->Activate(*iSelectionWindow);
+    
+        iSelectionWindow->Invalidate();
+        iSelectionWindow->BeginRedraw();
+    
+        iGc->Reset();
+        
+        iGc->UseFont(iFont);                
+        iGc->SetBrushColor(KRgbDarkBlue);
+        
+        iGc->Clear();
+
+        // KRgbWhite seems to be having problems (0xffffff) in some emulators,
+        // but 0xfefefe is working, so use that instead of white.        
+        iGc->SetPenColor(0xfefefe);
+
+        const TInt KHeaderColumn = 5;
+        const TInt KEntryColumn = 15;
+        
+        TInt row = KRowIncrement;
+
+        iGc->SetUnderlineStyle(EUnderlineOff);
+
+        iGc->DrawText( aHeaderText, TPoint(KHeaderColumn, row) );
+        row += (KRowIncrement + 5);
+        
+        TBool again = true;
+        TInt backIndex = -1;
+        TInt forwardIndex = -1;
+        TInt offset = 0;
+                    
+        while( again )
+            {
+            if( selected == offset )
+                {
+                iGc->SetUnderlineStyle(EUnderlineOn);
+                }
+            else
+                {
+                iGc->SetUnderlineStyle(EUnderlineOff);            
+                }
+        
+            if( (offset < entriesPerPage) && (startIndex+offset < aSelectionList.Count()) )
+                {
+                iGc->DrawText( *aSelectionList[startIndex+offset], TPoint(KEntryColumn, row) );
+                row += KRowIncrement;
+
+                offset++;
+                }
+            else
+                {
+                again = false;
+                if( startIndex + offset < aSelectionList.Count() )
+                    {
+                    iGc->DrawText( _L("<page down>"), TPoint(KEntryColumn, row) );
+                    row += KRowIncrement;
+                    
+                    forwardIndex = offset;
+                    offset++;
+                    }
+                if( startIndex > 0 )
+                    {
+                    if( selected == offset )
+                        {
+                        iGc->SetUnderlineStyle(EUnderlineOn);
+                        }
+                    else
+                        {
+                        iGc->SetUnderlineStyle(EUnderlineOff);            
+                        }
+                
+                    iGc->DrawText( _L("<page up>"), TPoint(KEntryColumn, row) );
+                    row += KRowIncrement;
+
+                    backIndex = offset;
+                    offset++;
+                    }
+                }
+            }
+        
+        iSelectionWindow->EndRedraw();
+       
+        iGc->Deactivate();
+
+        TInt keyCode = WaitForAnyKey();        
+        
+        switch( keyCode )
+            {
+            case EKeyUpArrow:
+                if( selected == 0 )
+                    {
+                    selected = offset-1;
+                    }
+                else
+                    {
+                    selected -= 1;
+                    }
+                break;
+                
+            case EKeyDownArrow:
+            case KLeftSoftKeyCode:                        
+            case 'a':
+            case 'A':
+                selected += 1;
+                if( selected == offset )
+                    {
+                    selected = 0;
+                    }
+                break;
+
+            case EKeyLeftArrow:
+                if( backIndex >= 0 )
+                    {
+                    startIndex -= entriesPerPage;
+                    selected = 0;                        
+                    }
+                else
+                    {
+                    returnValue = -1;
+                    again = false;
+                    }
+                break;
+                
+            case EKeyRightArrow:
+                if( forwardIndex >= 0 )
+                    {
+                    startIndex += entriesPerPage;
+                    selected = 0;                    
+                    }
+                break;
+
+            case EKeyEnter:
+            case KRightSoftKeyCode:                        
+            case 'b':
+            case 'B':
+                if( selected == forwardIndex )
+                    {
+                    startIndex += entriesPerPage;
+                    selected = 0;                    
+                    }
+                else if( selected == backIndex )
+                    {
+                    startIndex -= entriesPerPage;
+                    selected = 0;
+                    }
+                else
+                    {
+                    returnValue = startIndex+selected;
+                    }
+                break;
+            }
+        }
+
+    iSelectionWindow->SetVisible( false );
+    
+    return returnValue;        
+    }
+
+TInt CTestAppBase::SelectFromListL( TPoint aTopLeft,
+                                    TSize aSize,
+                                    const TDesC& aHeaderText, 
+                                    RPointerArray<HBufC>& aSelectionList, 
+                                    TInt aInitialSelectionIndex )
+    {
+    RPointerArray<TDesC> aSelectionList2;
+    
+    for( TInt index = 0; index < aSelectionList.Count(); index++ )
+        {
+        aSelectionList2.Append( aSelectionList[index]);
+        }
+    
+    TInt returnValue = SelectFromListL( aTopLeft, aSize, aHeaderText, aSelectionList2, aInitialSelectionIndex );
+    
+    aSelectionList2.Close();
+    
+    return returnValue;
+    }
+
+void CTestAppBase::BuildDriveListL( RPointerArray<HBufC>& aDrives )
+    {
+    TDriveList driveList;
+    TInt err = iFs.DriveList( driveList );
+    
+    for( TInt index = 0; index < driveList.Length(); index++ )
+        {
+        if( driveList[index] != 0 )
+            {
+            HBufC* drive = HBufC::NewL( 2 );
+            drive->Des().Format( _L("%c:"), 'A' + index);
+            aDrives.Append( drive );
+            }
+        }
+    }
+
+bool CTestAppBase::SelectDriveL( TPoint aTopLeft,
+                                 TSize aWindowSize,
+                                 const TDesC& aHeaderText, 
+                                 TDes& aDrive )
+    {
+    RPointerArray<HBufC> drives;
+    BuildDriveListL( drives );
+    
+    TInt index = SelectFromListL( aTopLeft, aWindowSize, aHeaderText, drives );
+    
+    bool returnValue = false;
+    
+    if( index >= 0 )
+        {
+        returnValue = true;
+        aDrive.Copy( *(drives[index]) );
+        aDrive.Append( _L("\\") );
+        }
+    
+    drives.ResetAndDestroy();
+    
+    return returnValue;
+    }
+
+bool CTestAppBase::SelectFileL( TPoint aTopLeft,
+                                TSize aWindowSize,
+                                const TDesC& aHeaderText, 
+                                const TDesC& aDrive, 
+                                TDes& aFullFilename )
+    {
+    TFileName directory;
+    
+    DoSelectFileL( aTopLeft, aWindowSize, aHeaderText, aDrive, 0, directory, aFullFilename );
+    
+    aFullFilename.Insert( 0, directory );
+    
+    return aFullFilename.Length() > 0;
+    }
+
+bool CTestAppBase::SelectFileWithHistoryL( TPoint aTopLeft,
+                                           TSize aSize,
+                                           TDes& aFullFilename,
+                                           const TDesC& aHistoryFilename,
+                                           TInt aMaxHistoryEntries,
+                                           const TDesC& aPrompt )
+    {
+    RPointerArray<HBufC> drives;
+    BuildDriveListL( drives );
+        
+    RPointerArray<TDesC> selections;
+
+    for( TInt index = 0; index < drives.Count(); index++ )
+        {
+        selections.Append( drives[index]);
+        }
+    TInt drivesBaseIndex = 0;
+        
+    // Add file history to the end of the drive list.  Newest files are last, so add in reverse order.
+    // For convenience, add the last history entry at the top, before the drive list.
+    ReadFileHistory( aHistoryFilename );
+    if( iFileHistory.Count() > 0 )
+        {
+        selections.Insert( iFileHistory[iFileHistory.Count()-1], 0 );        
+        drivesBaseIndex++;
+        }
+    for(TInt index = iFileHistory.Count()-2; index >= 0; index-- )
+        {        
+        selections.Append( iFileHistory[index]);
+        }
+
+    bool done = false;
+    bool selected = true;
+    
+    while( !done )
+        {
+        TInt index = SelectFromListL( aTopLeft, aSize, aPrompt, selections );
+
+        if( index < 0 )
+            {
+            selected = false;
+            done = true;
+            }        
+        else if( (index >= drivesBaseIndex) && (index - drivesBaseIndex < drives.Count()) )
+            {
+            TBuf<10> drive;
+            drive.Copy( *(selections[index]) );
+            drive.Append( _L("\\") );
+            
+            done = SelectFileL( aTopLeft, aSize, aPrompt, drive, aFullFilename );        
+            }
+        else
+            {    
+            // Remove the selected file from the history, so that it will pop up to the top of the list
+            // as the most recently selected file.
+            TInt historyIndex;
+            if( index == 0 )
+                {
+                historyIndex = iFileHistory.Count() - 1;
+                }
+            else
+                {
+                historyIndex = iFileHistory.Count() - index + drives.Count() - 1;
+                }
+            aFullFilename.Copy( *(selections[index]) );
+            delete iFileHistory[historyIndex];
+            iFileHistory.Remove( historyIndex );            
+
+            done = true;
+            }
+        }
+    
+    if( selected )
+        {
+        AddToFileHistory( aFullFilename, aHistoryFilename, aMaxHistoryEntries );        
+        }
+    
+    selections.Reset();
+    drives.ResetAndDestroy();
+    
+    return selected;
+    }
+
+bool CTestAppBase::SelectIntegerL( TPoint aTopLeft,
+                                   TSize aSize,
+                                   const TDesC& aHeaderText,
+                                   TInt aMin,
+                                   TInt aMax,
+                                   TInt& aSelection )
+    {
+    // currently no way to exit out of this selection
+    
+    iSelectionWindow->SetExtent( aTopLeft, aSize );
+    iSelectionWindow->SetVisible( true );
+
+    bool done = false;
+    
+    while( !done )
+        {
+        iGc->Activate(*iSelectionWindow);
+    
+        iSelectionWindow->Invalidate();
+        iSelectionWindow->BeginRedraw();
+    
+        iGc->Reset();
+        
+        iGc->UseFont(iFont);                
+        iGc->SetBrushColor(KRgbDarkBlue);
+        
+        iGc->Clear();
+
+        // KRgbWhite seems to be having problems (0xffffff) in some emulators,
+        // but 0xfefefe is working, so use that instead of white.        
+        iGc->SetPenColor(0xfefefe);
+
+        TBuf<120> buffer;
+        buffer.Copy( aHeaderText );        
+        buffer.AppendFormat( _L(" %i"), aSelection );
+        
+        iGc->DrawText( buffer, TPoint(5, iFontSize+2) );
+
+        iSelectionWindow->EndRedraw();
+       
+        iGc->Deactivate();
+
+        TInt keyCode = WaitForAnyKey();
+        
+        switch( keyCode )
+            {
+            case EKeyUpArrow:
+                aSelection -= 10;
+                break;
+                
+            case EKeyDownArrow:
+            case KLeftSoftKeyCode:                        
+            case 'a':
+            case 'A':
+                aSelection += 10;
+                break;
+
+            case EKeyLeftArrow:
+                aSelection--;
+                break;
+                
+            case EKeyRightArrow:
+                aSelection++;
+                break;
+
+            case EKeyEnter:
+            case KRightSoftKeyCode:                        
+            case 'b':
+            case 'B':
+                done = true;
+                break;
+            }
+        
+        if( aSelection > aMax )
+            {
+            aSelection = aMin;
+            }
+        else if( aSelection < aMin )
+            {
+            aSelection = aMax;
+            }        
+        }
+
+    iSelectionWindow->SetVisible( false );
+    
+    return true;
+    }
+
+TInt CTestAppBase::WaitForAnyKey()
+    {
+    TInt returnValue = 0;
+    
+    bool done = false;
+    
+    while( !done )
+        {        
+        // Have to use this tricky nested active scheduler technique to allow the active object
+        // used to remap volume keys to run.
+        SetActive();
+        iWs.EventReady( &iStatus );
+        iWait.Start();
+    
+        TWsEvent event;
+        iWs.GetEvent(event);
+    
+        // Other potentially useful events are EEventKeyUp and EEventKeyDown.
+        
+        if( event.Type() == EEventKey )
+            {
+            done = true;
+            returnValue = event.Key()->iCode;
+            }
+        else if( event.Type() == EEventPointer )
+            {
+            TAdvancedPointerEvent* p = event.Pointer();
+
+            TTestAppPointerEvent pointerEvent = CharacterizePointerEvent( *p );
+
+            switch( pointerEvent )
+                {
+                case EPointerEvent_None:
+                    // Do nothing.
+                    break;
+                case EPointerEvent_Up:
+                    returnValue = EKeyUpArrow;
+                    done = true;
+                    break;
+                case EPointerEvent_Down:
+                    returnValue = EKeyDownArrow;
+                    done = true;
+                    break;
+                case EPointerEvent_Left:
+                    returnValue = EKeyLeftArrow;
+                    done = true;
+                    break;
+                case EPointerEvent_Right:
+                    returnValue = EKeyRightArrow;
+                    done = true;
+                    break;
+                case EPointerEvent_Select:
+                    returnValue = EKeyEnter;
+                    done = true;
+                    break;
+                }
+            }        
+        }
+    
+    return returnValue;
+    }
+
+TInt CTestAppBase::ReadFile( const TDesC& aFilename, RPointerArray<HBufC>& aContents )
+    {
+    RFile inputFile;
+    TInt err = inputFile.Open(iFs, aFilename, EFileShareReadersOnly | EFileStream | EFileRead );
+    
+    if( err == KErrNone )
+        {
+        TInt fileSize;
+        inputFile.Size( fileSize );
+        
+        RBuf8 contents;
+        contents.Create( fileSize );
+
+        inputFile.Read( contents, fileSize );
+
+        inputFile.Close();
+
+        TPtrC8 remaining( contents );
+        
+        while( remaining.Length() > 0 )
+            {
+            // Removing leading CR/LFs, if any.
+            while( remaining.Length() > 0 && (remaining[0] == '\n' || remaining[0] == '\r') )
+                {
+                remaining.Set(remaining.Right(remaining.Length()-1));            
+                }
+
+            if( remaining.Length() == 0 )
+                {
+                break;
+                }
+
+            // Find next CR/LF, or end of string.
+            TInt separatorIndex = 1;
+            while( (separatorIndex < remaining.Length()) && 
+                   (remaining[separatorIndex] != '\n') &&
+                   (remaining[separatorIndex] != '\r'))
+                {
+                separatorIndex++;
+                }
+                        
+            HBufC* line = HBufC::NewL( separatorIndex );
+            TPtrC8 line8 = remaining.Left( separatorIndex );
+            line->Des().Copy( line8 );
+        
+            aContents.Append( line );
+
+            TInt remainingLength = remaining.Length() - separatorIndex;            
+
+            remaining.Set(remaining.Right(remainingLength));            
+            }        
+        
+        contents.Close();
+        }
+    
+    return err;
+    }
+
+void CTestAppBase::ReadFileHistory( const TDesC& aHistoryFilename )
+    {
+    iFileHistory.ResetAndDestroy();
+    
+    ReadFile( aHistoryFilename, iFileHistory );
+    }
+
+void CTestAppBase::AddToFileHistory( const TDesC& aFilename, const TDesC& aHistoryFilename, TInt aMaxHistoryEntries )
+    {
+    HBufC* filename = HBufC::NewL( aFilename.Length() );
+    filename->Des().Copy( aFilename );
+    iFileHistory.Append( filename );
+
+    while( iFileHistory.Count() > aMaxHistoryEntries )
+        {
+        delete iFileHistory[0];
+        iFileHistory.Remove( 0 );
+        }    
+    
+    RFile historyFile;
+    TInt err = historyFile.Create(iFs, aHistoryFilename, EFileStream | EFileWrite );    
+    if( err == KErrAlreadyExists )
+        {
+        err = historyFile.Open(iFs, aHistoryFilename, EFileStream | EFileWrite );
+        historyFile.SetSize(0);
+        }
+    
+    if( err == KErrNone )
+        {
+        for( TInt index = 0; index < iFileHistory.Count(); index++ )
+            {
+            TBuf8<KMaxFileName> filename8;
+            filename8.Copy( iFileHistory[index]->Des() );
+            historyFile.Write( filename8 );
+            historyFile.Write( _L8("\n") );
+            }
+        }
+    
+    historyFile.Close();    
+    }
+
+void CTestAppBase::DoSelectFileL( TPoint aTopRight,
+                                  TSize aWindowSize,
+                                  const TDesC& aHeaderText, 
+                                  const TFileName& aDirectory, 
+                                  TInt aDirectoryLevel, 
+                                  TDes& aSelectedDirectory, 
+                                  TDes& aSelectedFilename )     
+    {
+    RPointerArray<TDesC> fileNames;
+    
+    ReadDirectoryEntriesL( aDirectory, fileNames );
+
+    TInt initialSelectionIndex = 0;
+    
+    _LIT( KUp, ".." );        
+    if( aDirectoryLevel > 0 )
+        {
+        TFileName* newEntry = new(ELeave) TFileName;
+        newEntry->Copy( KUp );            
+        fileNames.Insert( newEntry, 0 );
+        initialSelectionIndex++;
+        }
+    
+    bool done = false;    
+    
+    while( !done && (aSelectedFilename.Length() == 0) )
+        {
+        TInt index = SelectFromListL( aTopRight, aWindowSize, aHeaderText, fileNames, initialSelectionIndex );
+
+        if( index < 0 || index >= fileNames.Count() )
+            {
+            done = true;
+            }
+        else if( fileNames[index]->Compare(KUp) == 0 )
+            {
+            // Go up one directory.  Return to caller without setting aFilename
+            break;
+            }
+        else if( (*fileNames[index])[fileNames[index]->Length()-1] == '\\' )
+            {
+            // Directory selected.
+            TFileName directory;
+            directory.Copy( aDirectory );
+            directory.Append( *fileNames[index] );
+            DoSelectFileL( aTopRight, aWindowSize, aHeaderText, directory, aDirectoryLevel+1, aSelectedDirectory, aSelectedFilename );
+            }
+        else
+            {
+            // File selected.                            
+            aSelectedDirectory.Copy( aDirectory );
+            aSelectedFilename.Copy( *fileNames[index] );
+            done = true;
+            }
+        
+        }
+
+    fileNames.ResetAndDestroy();
+    }
+
+void CTestAppBase::ReadDirectoryEntriesL( const TFileName& aDirectoryName, RPointerArray<TDesC>& aFileNames )
+    {
+    aFileNames.ResetAndDestroy();
+    
+    RDir dir;
+    User::LeaveIfError( dir.Open( iFs, aDirectoryName, KEntryAttNormal|KEntryAttDir) );
+    
+    TEntryArray entries;
+    TInt err = KErrNone;
+    TInt directoryCount = 0;
+    while( err == KErrNone )
+        {
+        err = dir.Read( entries );
+                
+        for( TInt index = 0; index < entries.Count(); index++ )
+            {
+            // It was observed that not all devices sorted the list by default, so do an
+            // insertion sort here.            
+            TFileName* newEntry = new(ELeave) TFileName;
+            newEntry->Copy( entries[index].iName );
+            
+            // Put the directories first in the list.
+            if( entries[index].IsDir())
+                {
+                newEntry->Append( _L("\\") );
+                
+                TInt insertionIndex = 0;
+                while( insertionIndex < directoryCount && newEntry->CompareF(*aFileNames[insertionIndex]) > 0 )
+                    {
+                    insertionIndex++;
+                    }
+                aFileNames.Insert( newEntry, insertionIndex );
+                
+                directoryCount++;
+                }
+            else
+                {
+                TInt insertionIndex = directoryCount;
+                while( insertionIndex < aFileNames.Count() && newEntry->CompareF(*aFileNames[insertionIndex]) > 0 )
+                    {
+                    insertionIndex++;
+                    }
+                aFileNames.Insert( newEntry, insertionIndex );
+                }
+            }        
+        }      
+    
+    dir.Close();
+    }
+
+void CTestAppBase::DrawHelpText()
+    {
+    iGc->Activate(*iHelpWindow);
+
+    iHelpWindow->Invalidate();
+    iHelpWindow->BeginRedraw();
+
+    iGc->Reset();
+    
+    iGc->UseFont(iFont);                
+    iGc->SetBrushColor(KRgbTransparent);
+    
+    iGc->Clear();
+
+    if( iHelpSemitransparentBackgroundActive )
+        {
+        iGc->SetPenColor(KRgbTransparent);
+        iGc->SetBrushStyle(CWindowGc::ESolidBrush);
+        iGc->SetBrushColor( TRgb(0x7f7f7faf) );
+        iGc->DrawRect( TRect(iHelpWindowSize) );
+        }
+
+    // KRgbWhite seems to be having problems (0xffffff) in some emulators,
+    // but 0xfefefe is working, so use that instead of white.        
+    iGc->SetPenColor(0xfefefe);
+
+    const TInt KColumn1 = KHelpWindowBorderPixels;
+    const TInt KColumn2 = KColumn1 + iHelpWindowColumn1Width + KHelpWindowSpaceBetweenColumns;
+    const TInt KRowIncrement = iFontSize + KHelpWindowSpaceBetweenRows;
+    
+    TInt row = iFontSize + KHelpWindowBorderPixels;
+
+    for( TInt index = 0; index < KSupportedKeysCount; index++ )
+        {
+        iGc->SetUnderlineStyle(EUnderlineOff);        
+    
+        TPtrC text = KeyMapText( index, iCurrentPage ); 
+
+        iGc->DrawText( KeyName(index), TPoint(KColumn1, row) );
+
+        if( index == iSoftkeyIndices[iCurrentPage] )
+            {
+            iGc->SetUnderlineStyle(EUnderlineOn);
+            }
+        else
+            {
+            iGc->SetUnderlineStyle(EUnderlineOff);        
+            }
+
+        iGc->DrawText( text, TPoint(KColumn2, row) );
+        
+        row += KRowIncrement;
+        }
+
+    iHelpWindow->EndRedraw();
+   
+    iGc->Deactivate();
+    }
+
+void CTestAppBase::MrccatoCommand( TRemConCoreApiOperationId aOperationId,
+                                   TRemConCoreApiButtonAction /*aButtonAct*/ )
+    {
+    // Treat volume up like the right soft key, and volume down like the left soft key.
+    TKeyEvent keyEvent;
+    keyEvent.iCode = 0;
+    keyEvent.iScanCode = 0;
+    keyEvent.iModifiers = 0;
+    keyEvent.iRepeats = 0;
+    
+    switch (aOperationId)
+        {
+        case ERemConCoreApiVolumeUp:
+            keyEvent.iCode = KRightSoftKeyCode;
+            iWs.SimulateKeyEvent(keyEvent);
+            iWs.Flush();
+            break;
+        case ERemConCoreApiVolumeDown:
+            keyEvent.iCode = KLeftSoftKeyCode;
+            iWs.SimulateKeyEvent(keyEvent);
+            iWs.Flush();
+            break;
+        default:
+            break;
+        }
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/consoleplayer/common/testappbase.h	Fri Sep 03 19:37:02 2010 -0500
@@ -0,0 +1,282 @@
+/*
+ * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ * Header specifying the common test functionality.
+ * 
+ */
+
+#ifndef __TEST_APP_BASE_H__
+#define __TEST_APP_BASE_H__
+
+#include <e32base.h>
+#include <w32std.h>
+#include <remconcoreapitargetobserver.h>  // for volume key handling
+
+class CRemConCoreApiTarget;
+class CRemConInterfaceSelector;
+
+#define STR(a) (TText*)L##a
+
+// 17 keys are supported.  The keys are in this order:
+//    Enter, Up, Down, Left, Right, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, *, #
+const TInt KSupportedKeysCount = 17;
+
+struct TOperationEntry
+    {
+    const TText* text;
+    TInt         operation;
+    };
+
+struct TOperationsPage
+    {
+    const TText*    pageName;    
+    TInt            defaultSoftkeyIndex;
+    TOperationEntry mapping[KSupportedKeysCount];
+    };
+
+// Predefined standard operations
+const TInt KOperation_None = 0;
+const TInt KOperation_Exit = 1;
+const TInt KOperation_PreviousOptionPage = 2;
+const TInt KOperation_NextOptionPage = 3;
+const TInt KOperation_NextOption = 4;
+const TInt KOperation_PreviousOption = 5;
+const TInt KOperation_ExecuteOption = 6;
+const TInt KOperation_ToggleHelpVisibility = 7;
+const TInt KOperation_ToggleHelpTransparency = 8;
+const TInt KOperation_FirstCustomIndex = 10;  // app-specific operations can start here
+
+const TUint32 KNullWsHandle = 0xFFFFFFFF;
+
+class ITestAppPrompts
+    {
+public:
+    
+    // Presents a selection list to the user and returns the index of the selected entry.
+    // Synchronous call.
+    // returns -1 if the selection was backed out without making a selection
+    virtual TInt SelectFromListL( TPoint aTopLeft,
+                                  TSize aSize,
+                                  const TDesC& aHeaderText, 
+                                  RPointerArray<TDesC>& aSelectionList, 
+                                  TInt aInitialSelectionIndex = 0 ) = 0;
+
+    // overload with HBufC instead of TDesC
+    virtual TInt SelectFromListL( TPoint aTopLeft,
+                                  TSize aSize,
+                                  const TDesC& aHeaderText, 
+                                  RPointerArray<HBufC>& aSelectionList, 
+                                  TInt aInitialSelectionIndex = 0 ) = 0;
+
+    // Synchronous call.
+    // returns false if the selection was backed out without making a selection
+    virtual bool SelectDriveL( TPoint aTopLeft,
+                               TSize aSize,
+                               const TDesC& aHeaderText, 
+                               TDes& aDrive ) = 0;
+    
+    // Synchronous call.
+    // returns false if the selection was backed out without making a selection
+    virtual bool SelectFileL( TPoint aTopLeft,
+                              TSize aSize,
+                              const TDesC& aHeaderText, 
+                              const TDesC& aDrive, 
+                              TDes& aFullFilename ) = 0;
+
+    // Synchronous call.
+    // returns false if the selection was backed out without making a selection
+    virtual bool SelectFileWithHistoryL( TPoint aTopLeft,
+                                         TSize aSize,
+                                         TDes& aFullFilename,
+                                         const TDesC& aHistoryFilename,
+                                         TInt aMaxHistoryEntries,
+                                         const TDesC& aPrompt = _L("Select drive or recent file:") ) = 0;    
+    
+    // Synchronous call.
+    // returns false if the selection was backed out without making a selection
+    virtual bool SelectIntegerL( TPoint aTopLeft,
+                                 TSize aSize,
+                                 const TDesC& aHeaderText,
+                                 TInt aMin,
+                                 TInt aMax,
+                                 TInt& aSelection ) = 0;  // set aSelection to default value
+    
+    // Synchronous call.  Returns the scan code of the pressed key.
+    virtual TInt WaitForAnyKey() = 0;    
+    
+    virtual TSize DisplaySize() = 0;
+    };
+
+class CTestAppBase : public CActive,
+                     protected ITestAppPrompts,
+                     private MRemConCoreApiTargetObserver
+    {
+public:
+    
+    CTestAppBase( TInt aFontSize );
+    
+    ~CTestAppBase();
+    
+    // inherited from CActive
+    void RunL();
+    void DoCancel();
+
+protected:
+    
+    enum TTestAppPointerEvent
+        {
+        EPointerEvent_None,
+        EPointerEvent_Up,
+        EPointerEvent_Down,
+        EPointerEvent_Left,
+        EPointerEvent_Right,
+        EPointerEvent_Select
+        };
+    
+    virtual void ExecuteOperation( TInt aOperation, const TDesC& aOperationText ) = 0;
+
+    // Subclasses can override this function to take action when the current softkey function has been changed.
+    virtual void SoftkeyFunctionUpdated() {};
+    
+    // Subclasses can override this function to override the default key event handling.
+    virtual bool ConsumeKeyEvent( TInt /*aKeyCode*/ ) { return false; };
+    
+    void BaseConstructL( const TOperationsPage* aKeyMap, TInt aPageCount );
+    
+    void SetupVolumeKeysL();
+
+    void StartMonitoringWindowEvents();
+
+    TInt CurrentPageNumber();
+    
+    TPtrC CurrentPageName();
+    
+    TPtrC CurrentSoftkeyName();    
+    
+    // Each line in the file will be an entry in the aContents array
+    TInt ReadFile( const TDesC& aFilename, RPointerArray<HBufC>& aContents );    
+    
+    void BuildDriveListL( RPointerArray<HBufC>& aDrives );
+        
+    void StartReceivingPointerEvents();
+    void StopReceivingPointerEvents();
+
+    TTestAppPointerEvent CharacterizePointerEvent( const TAdvancedPointerEvent& event );    
+        
+    virtual void HandlePointerEvent( const TAdvancedPointerEvent& /*aEvent*/ ) {}
+    
+    // inherited from ITestAppPrompts
+    TInt SelectFromListL( TPoint aTopLeft,
+                          TSize aSize,
+                          const TDesC& aHeaderText, 
+                          RPointerArray<TDesC>& aSelectionList, 
+                          TInt aInitialSelectionIndex = 0 );
+    TInt SelectFromListL( TPoint aTopLeft,
+                          TSize aSize,
+                          const TDesC& aHeaderText, 
+                          RPointerArray<HBufC>& aSelectionList, 
+                          TInt aInitialSelectionIndex = 0 );
+    bool SelectDriveL( TPoint aTopLeft,
+                       TSize aSize,
+                       const TDesC& aHeaderText, 
+                       TDes& aDrive );
+    bool SelectFileL( TPoint aTopLeft,
+                      TSize aSize,
+                      const TDesC& aHeaderText, 
+                      const TDesC& aDrive, 
+                      TDes& aFullFilename );
+    bool SelectFileWithHistoryL( TPoint aTopLeft,
+                                 TSize aSize,
+                                 TDes& aFullFilename,
+                                 const TDesC& aHistoryFilename,
+                                 TInt aMaxHistoryEntries,
+                                 const TDesC& aPrompt = _L("Select drive or recent file:") );    
+    bool SelectIntegerL( TPoint aTopLeft,
+                         TSize aSize,
+                         const TDesC& aHeaderText,
+                         TInt aMin,
+                         TInt aMax,
+                         TInt& aSelection );  // set aSelection to default value
+    TInt WaitForAnyKey();    
+    TSize DisplaySize() {return iDisplaySize;}
+    
+    const TInt            iFontSize;
+    
+    RFs                   iFs;
+    RWsSession            iWs;
+    CWsScreenDevice*      iScreenDevice; 
+    RWindowGroup*         iWindowGroup;
+    CWindowGc*            iGc;
+    CFont*                iFont;
+    CFbsTypefaceStore*    iTypefaceStore;
+    TSize                 iDisplaySize;
+    RWindow*              iSelectionWindow;    
+    RWindow*              iHelpWindow;
+
+private:
+    
+    // inherited from MRemConCoreApiTargetObserver
+    void MrccatoCommand(TRemConCoreApiOperationId aOperationId,
+                        TRemConCoreApiButtonAction aButtonAct);
+
+    TInt KeyMapOperation(TInt aIndex, TInt aPage );
+    
+    TPtrC KeyMapText( TInt aIndex, TInt aPage );
+
+    void IncrementKeymapIndex( TInt& aIndex, TInt aPage );
+    
+    void DecrementKeymapIndex( TInt& aIndex, TInt aPage );
+    
+    void CalculateHelpWindowSize();
+
+    void DrawHelpText();
+    
+    void DoSelectFileL( TPoint aTopRight,
+                        TSize aWindowSize,
+                        const TDesC& aHeaderText, 
+                        const TFileName& aDirectory, 
+                        TInt aDirectoryLevel, 
+                        TDes& aSelectedDirectory, 
+                        TDes& aSelectedFilename );     
+    
+    void ReadDirectoryEntriesL( const TFileName& aDirectoryName, RPointerArray<TDesC>& aFileNames );
+    
+    void ReadFileHistory( const TDesC& aHistoryFilename );
+    
+    void AddToFileHistory( const TDesC& aFilename, const TDesC& aHistoryFilename, TInt aMaxHistoryEntries );
+
+    const TOperationsPage* iKeyMap;
+    TInt                   iPageCount;
+    TInt                   iCurrentPage;
+    TInt                   iSoftkeyIndices[30];
+    RPointerArray<HBufC>   iFileHistory;
+    
+    CActiveSchedulerWait  iWait;
+    
+    TPoint                iHelpWindowTopRight;
+    TSize                 iHelpWindowSize;
+    TInt                  iHelpWindowColumn1Width;
+    TInt                  iHelpWindowColumn2Width;
+    bool                  iHelpActive;
+    bool                  iHelpSemitransparentBackgroundActive;    
+    
+    bool                  iRoutePointerEventsToApp;
+    TPoint                iPointerDownPosition;
+    
+    // For volume key support
+    CRemConCoreApiTarget*     iCoreTarget;
+    CRemConInterfaceSelector* iInterfaceSelector;    
+    };
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/consoleplayer/common/timercallback.cpp	Fri Sep 03 19:37:02 2010 -0500
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ * Source code for handling the timer.
+ * 
+ */
+
+#include "timercallback.h"
+
+CTimerCallback::CTimerCallback( ITimerCallbackClient& aClient ) : 
+    CActive( EPriorityStandard ),
+    iClient( aClient )
+    {    
+    CActiveScheduler::Add(this);
+    }
+
+CTimerCallback::~CTimerCallback()
+    { 
+    Cancel();
+    }
+
+void CTimerCallback::Start(TTimeIntervalMicroSeconds32 aInterval)
+    {
+    iInterval = aInterval;
+    
+    if( iTimer.CreateLocal() == KErrNone )
+        {
+        SetActive();
+        iTimer.After( iStatus, 0 );
+        }
+    }
+
+// inherited from CActive
+
+void CTimerCallback::RunL()
+    {
+    SetActive();
+    iTimer.After( iStatus, iInterval );
+
+    iClient.TimerCallback();        
+    }
+
+void CTimerCallback::DoCancel()
+    {
+    iTimer.Cancel();
+    }
+    
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/consoleplayer/common/timercallback.h	Fri Sep 03 19:37:02 2010 -0500
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ * Header specifying the timer handling.
+ * 
+ */
+
+#ifndef __TIMER_CALLBACK_H__
+#define __TIMER_CALLBACK_H__
+
+#include <e32base.h>
+
+class ITimerCallbackClient
+    {
+public:
+    
+    virtual void TimerCallback() = 0;
+    
+    };
+
+class CTimerCallback : public CActive
+    {
+public:
+    
+    CTimerCallback( ITimerCallbackClient& aClient ); 
+    
+    ~CTimerCallback();
+    
+    void Start( TTimeIntervalMicroSeconds32 aInterval );
+    
+    // inherited from CActive
+    void RunL();
+    void DoCancel();
+    
+private:
+        
+    RTimer                      iTimer;
+    ITimerCallbackClient&       iClient;
+    TTimeIntervalMicroSeconds32 iInterval;
+    
+    };
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/consoleplayer/group/bld.inf	Fri Sep 03 19:37:02 2010 -0500
@@ -0,0 +1,17 @@
+/*
+ * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ */
+
+PRJ_MMPFILES
+
+#include "..\player\group\bld.inf"
+#include "..\thumbnail\group\bld.inf"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/consoleplayer/player/group/bld.inf	Fri Sep 03 19:37:02 2010 -0500
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ * This file provides the information required for building the
+ * Console Player test app.
+ *
+ */
+
+PRJ_MMPFILES
+
+ConsolePlayer.mmp
+ExternalPlayer.mmp
+ExternalPlayer2.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/consoleplayer/player/group/consoleplayer.mmp	Fri Sep 03 19:37:02 2010 -0500
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ * This file provides the information required for building the
+ * Console Player test app.
+ */
+
+#include <platform_paths.hrh>
+#include <bldvariant.hrh>
+
+TARGET          consoleplayer.exe
+TARGETTYPE      exe
+UID             0x0 0x10207C89
+VENDORID        VID_DEFAULT
+
+CAPABILITY      ALL -TCB
+
+EPOCSTACKSIZE   0x5000             //20KB
+EPOCHEAPSIZE    0x100000 0x1000000 //1MB-16MB
+
+START RESOURCE  consoleplayer_reg.rss
+TARGETPATH 	    \private\10003a3f\apps
+END 
+
+USERINCLUDE     ..\..\common
+USERINCLUDE     ..\inc
+USERINCLUDE     ..\src\mmf
+
+SOURCEPATH      ..\..\common
+SOURCE          testappbase.cpp
+SOURCE          timercallback.cpp
+
+SOURCEPATH      ..\src
+SOURCE          consoleplayer.cpp
+SOURCE          playerwindow.cpp
+
+SOURCEPATH      ..\src\mmf
+SOURCE          mmfplayerwindow.cpp
+
+MW_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE   \epoc32\include
+SYSTEMINCLUDE   \epoc32\include\stdapis
+
+LIBRARY         euser.lib
+LIBRARY         efsrv.lib
+LIBRARY         mediaclientvideo.lib
+LIBRARY	        gce.lib 
+LIBRARY         ws32.lib 
+LIBRARY         gdi.lib
+LIBRARY		    fntstr.lib
+LIBRARY         fbscli.lib
+LIBRARY         estor.lib 
+LIBRARY         ecom.lib
+
+// for volume key handling
+LIBRARY         remconcoreapi.lib
+LIBRARY         remconinterfacebase.lib
+
+// ----------------------------
+// CVideoPlayer TESTING SUPPORT
+// ----------------------------
+
+// Uncomment this out to use CVideoPlayerUtility API instead of CVideoPlayerUtility2.
+//MACRO __USE_VIDEOPLAYER_1__
+
+// --------------------------
+// OpenMAX AL TESTING SUPPORT
+// --------------------------
+
+#ifdef FF_OPENMAX_AL
+
+SYSTEMINCLUDE   \epoc32\include\platform\mw\khronos
+
+USERINCLUDE  ..\src\openmax_al
+SOURCEPATH   ..\src\openmax_al
+
+SOURCE       opmaxplayerwindow.cpp
+SOURCE       openmaxplayerutility.cpp
+LIBRARY      openmaxal.lib
+LIBRARY      libc.lib
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/consoleplayer/player/group/consoleplayer.pkg	Fri Sep 03 19:37:02 2010 -0500
@@ -0,0 +1,37 @@
+;
+; Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description: Console Player - UREL build
+;
+;File: consoleplayer.pkg
+
+;Languages
+&EN
+
+;Header
+#{"consoleplayer EXE"},(0x10207C89),1,0,0
+
+;Series 60 v5.0
+[0x1028315F], 0,0,0, {"Series60ProductID"}
+
+;Localised Vendor name
+%{"Nokia"}
+
+;Unique Vendor name
+:"Nokia"
+
+;Files To Copy...<src> <destination>
+"/epoc32/release/armv5/urel/consoleplayer.exe"		           -"!:/sys/bin/consoleplayer.exe"
+"/epoc32/release/armv5/urel/externalplayer.exe"		           -"!:/sys/bin/externalplayer.exe"
+"/epoc32/release/armv5/urel/externalplayer2.exe"		         -"!:/sys/bin/externalplayer2.exe"
+"/epoc32/data/z/private/10003a3f/apps/consoleplayer_reg.rsc" -"!:/private/10003a3f/import/apps/consoleplayer_reg.rsc"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/consoleplayer/player/group/consoleplayer_reg.rss	Fri Sep 03 19:37:02 2010 -0500
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ * Resource file for registering the ConsolePlayer to the Application
+ * Menu.
+ * 
+ */
+
+#include <appinfo.rh>
+
+UID2 KUidAppRegistrationResourceFile
+UID3 0x10207C89
+
+RESOURCE APP_REGISTRATION_INFO
+{
+    app_file="consoleplayer";  
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/consoleplayer/player/group/create_sis.bat	Fri Sep 03 19:37:02 2010 -0500
@@ -0,0 +1,22 @@
+cls
+@echo off
+echo.
+
+rem Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+rem All rights reserved.
+rem This component and the accompanying materials are made available
+rem under the terms of the "Eclipse Public License v1.0"
+rem which accompanies this distribution, and is available
+rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+rem
+rem Initial Contributors:
+rem Nokia Corporation - initial contribution.
+rem
+rem Contributors:
+rem
+echo Description:  Console Player package creation utility
+rem
+
+del consoleplayer.sis*
+makesis consoleplayer.pkg consoleplayer.sis
+signsis consoleplayer.sis consoleplayer.sisx rd.crt rd.key
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/consoleplayer/player/group/externalplayer.mmp	Fri Sep 03 19:37:02 2010 -0500
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ * This file provides the information required for building the
+ * External Player executable used by Console Player test app.
+ */
+
+#include <platform_paths.hrh>
+
+TARGET        externalplayer.exe
+TARGETTYPE    exe
+UID           0x0 0x10207CB0
+VENDORID      VID_DEFAULT
+
+CAPABILITY    ALL -TCB
+
+EPOCSTACKSIZE 0x5000           //20KB
+EPOCHEAPSIZE  0x400 0x1000000  //1KB-16MB
+
+USERINCLUDE   ..\..\common
+USERINCLUDE   ..\inc
+USERINCLUDE   ..\src\mmf
+
+SOURCEPATH    ..\src
+SOURCE        externalplayer.cpp
+SOURCE        playerwindow.cpp
+
+SOURCEPATH    ..\src\mmf
+SOURCE        mmfplayerwindow.cpp
+
+MW_LAYER_SYSTEMINCLUDE
+USERINCLUDE   .
+SYSTEMINCLUDE \epoc32\include
+
+LIBRARY       euser.lib
+LIBRARY       efsrv.lib
+LIBRARY       mediaclientvideo.lib
+LIBRARY	      gce.lib 
+LIBRARY       ws32.lib 
+LIBRARY       gdi.lib
+LIBRARY		  fntstr.lib
+LIBRARY       fbscli.lib
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/consoleplayer/player/group/externalplayer2.mmp	Fri Sep 03 19:37:02 2010 -0500
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ * This file provides the information required for building the
+ * External Player2 executable used by Console Player test app.
+ */
+
+#include <platform_paths.hrh>
+
+TARGET        externalplayer2.exe
+TARGETTYPE    exe
+UID           0x0 0x10207CB1
+VENDORID      VID_DEFAULT
+
+CAPABILITY    ALL -TCB
+
+EPOCSTACKSIZE 0x5000           //20KB
+EPOCHEAPSIZE  0x400 0x1000000  //1KB-16MB
+
+USERINCLUDE   ..\..\common
+USERINCLUDE   ..\inc
+USERINCLUDE   ..\src\mmf
+
+SOURCEPATH    ..\src
+SOURCE        externalplayer.cpp
+SOURCE        playerwindow.cpp
+
+SOURCEPATH    ..\src\mmf
+SOURCE        mmfplayerwindow.cpp
+
+MW_LAYER_SYSTEMINCLUDE
+USERINCLUDE   .
+SYSTEMINCLUDE \epoc32\include
+
+LIBRARY       euser.lib
+LIBRARY       efsrv.lib
+LIBRARY       mediaclientvideo.lib
+LIBRARY	      gce.lib 
+LIBRARY       ws32.lib 
+LIBRARY       gdi.lib
+LIBRARY		  fntstr.lib
+LIBRARY       fbscli.lib
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/consoleplayer/player/inc/consoleplayer.h	Fri Sep 03 19:37:02 2010 -0500
@@ -0,0 +1,175 @@
+/*
+ * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ * The header for the main class of the ConsolePlayer test app.
+ * 
+ */
+
+#ifndef __CONSOLE_PLAYER_H__
+#define __CONSOLE_PLAYER_H__
+
+#include <e32msgqueue.h>
+
+#include "testappbase.h"
+#include "timercallback.h"
+#include "playerwindow.h"
+#include "externalplayer.h"
+
+class CPlayerWindow;
+
+enum TOperations
+    {
+    EOperation_ChangeDisplayMode = KOperation_FirstCustomIndex,
+    EOperation_AbnormalTermination,
+    EOperation_ToggleSecondVideo,
+    EOperation_ToggleThirdVideo,
+    EOperation_ToggleExternalPlayer,
+    EOperation_ToggleExternalPlayer2,
+    EOperation_ObscureWindow,
+    EOperation_DragWindow,
+    EOperation_ToggleOrdinalPositions,
+    EOperation_LaunchAllWindows    
+    };
+
+const TInt KMaxHistoryEntries = 10;
+_LIT( KHistoryFilename, "c:\\console_player_history.txt" );
+
+_LIT( KUrlListFilename, "c:\\data\\urls.txt" );
+
+class CConsolePlayer : public CTestAppBase,
+                       private MPlayerWindowObserver,
+                       private ITimerCallbackClient,
+                       private MPlayerCommands
+                       
+{
+public: // Methods
+
+    static void ExecuteL();
+    
+private: // Methods
+
+    enum TActionToPerform
+        {
+        EAction_None = 0x0000,
+        EAction_PlayLocalFile = 0x0001,
+        EAction_PlayUrl = 0x0002,
+        EAction_SameAsMainPlayer = 0x0008
+        };
+    
+    enum TApiToUse
+        {
+        EApi_VideoPlayer = 0x1,
+        EApi_OpenMaxAl = 0x2
+        };
+    
+    CConsolePlayer(); 
+
+    ~CConsolePlayer();
+
+    void InitL();
+
+    void Main();
+        
+    void MainL();
+    
+    bool SelectUrlL( TDes& aUrl );
+
+    void UpdateVideoWindow();
+
+    void UpdateWindowOrdinalPositions();
+    
+    void EnableDragging();
+    
+    void DisableDragging();
+    
+    void SelectAction( TUint aActionMask, 
+                       TUint aApiMask, 
+                       bool aPresentPerformanceModeOption, 
+                       TActionToPerform& aAction, 
+                       TApiToUse& aApi, 
+                       bool& aPerformanceMode,
+                       TFileName& aLocation );
+    
+    void DoSelectAction( TUint aActionMask, 
+                         bool aPresentPerformanceModeOption, 
+                         TActionToPerform& aAction,
+                         bool& aPerformanceMode );
+    
+    bool DoSelectApi( TUint aApiMask, 
+                      TApiToUse& aApi ); 
+    
+    CPlayerWindow* PlayerWindowNewL( TApiToUse aApi,
+                                     TPoint aTopLeft,
+                                     TSize aSize,
+                                     bool aTransparent,
+                                     TRgb aBackgroundColor,
+                                     bool aSuppressGraphicsContext );
+    
+    TInt CreateAnotherPlayer( CPlayerWindow** aPlayerWindow, 
+                              CExternalPlayer** aExternalPlayer,
+                              const TDesC& aExternalPlayerExeName,
+                              TSize aSize, 
+                              TPoint aTopLeft );
+    
+    MPlayerCommands* CurrentPlayer();
+
+    void SendOperationToAllPlayers( TInt aOperation );
+    
+    void DrawBorderAroundActiveWindows();
+    
+    // inherited from CTestAppBase
+    virtual void SoftkeyFunctionUpdated();
+    virtual bool ConsumeKeyEvent( TInt aKeyCode );
+    virtual void ExecuteOperation( TInt aOperation, const TDesC& aOperationText );
+    virtual void HandlePointerEvent( const TAdvancedPointerEvent& aEvent );    
+
+    // inherited from MPlayerWindowObserver
+    virtual void PlayInitiated();
+    virtual void PlayStateChanged();
+    virtual void Error(TInt aError);
+        
+    // inherited from MPlayerCommands
+    virtual TInt ExecuteOperation( TInt aOperation );    
+    virtual void MoveWindow( TPoint aNewCenter );    
+    virtual void SetOrdinalPosition( TInt aPosition );
+    
+    // inherited from ITimerCallbackClient    
+    void TimerCallback();
+    
+private: // Attributes
+    
+    CTimerCallback*       iTimerCallback;    
+    TBuf<120>             iBuffer;
+    TInt                  iLastError;
+    TInt                  iVideoWindowTextMode;
+    TBuf<120>             iSelectedOptionText;
+    TInt                  iSelectedOptionTextCounter;
+    TInt                  iOrdinalIndex;
+    bool                  iVideoWindow2Transparent;
+    CPlayerWindow*        iVideoPlayer;
+    CPlayerWindow*        iVideoPlayer2;
+    CPlayerWindow*        iVideoPlayer3;
+    CExternalPlayer*      iExternalPlayer;
+    CExternalPlayer*      iExternalPlayer2;
+    MPlayerCommands*      iActivePlayer;
+    MPlayerCommands*      iPlayerBeingDragged;
+    RWindow*              iFullScreenWindow;
+    bool                  iObscured;
+    TInt                  iFinalResult;
+    TActionToPerform      iMainPlayerAction;
+    TApiToUse             iMainPlayerApi;
+    
+    };
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/consoleplayer/player/inc/externalplayer.h	Fri Sep 03 19:37:02 2010 -0500
@@ -0,0 +1,238 @@
+/*
+ * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ * Header for the external player main class.
+ * 
+ */
+
+#ifndef __EXTERNAL_PLAYER_H__
+#define __EXTERNAL_PLAYER_H__
+
+#include <e32base.h>
+#include <e32msgqueue.h>
+#include <w32std.h>
+
+#include "PlayerWindow.h"
+
+// Note: the executable name is also used as the message queue name.
+_LIT( KExternalPlayerExe, "externalplayer.exe" );
+_LIT( KExternalPlayerExe2, "externalplayer2.exe" );
+
+enum TExternalPlayerCommands
+    {
+    EExternalPlayer_StartPlayback,
+    EExternalPlayer_ExecuteOperation,
+    EExternalPlayer_MoveWindow,
+    EExternalPlayer_Shutdown
+    };
+
+struct TStartPlayback
+    {
+    TInt x;
+    TInt y;
+    TInt width;
+    TInt height;
+    TInt idOfParentWindowGroup;
+    bool locationIsFilename;
+    TInt length;
+    unsigned char name[200];
+    };
+
+struct TStartPlaybackReturn
+    {
+    TInt windowGroupId;
+    };
+
+struct TExecuteOperation
+    {
+    TInt operation;
+    };
+
+struct TMoveWindow
+    {
+    TInt centerX;
+    TInt centerY;
+    };
+
+_LIT( KMsgQueuePrefix, "-msg=" );
+
+// This is the client-side class for launching and controlling an external player executable.
+
+class CExternalPlayer : public CBase, public MPlayerCommands
+    {
+public:
+    
+    ~CExternalPlayer()
+        {
+        Terminate();
+        }
+    
+    CExternalPlayer( RWsSession& aWs ) : iWs( aWs )
+        {        
+        }
+    
+    TInt SendMsg( TExternalPlayerCommands aMsg )
+        {
+        TRequestStatus status;
+        status = KRequestPending;
+        iProcess.Rendezvous( status );
+        
+        iMsgQueue.SendBlocking( aMsg );
+                
+        User::WaitForRequest( status );   
+        
+        return status.Int();
+        }
+    
+    TInt Launch( const TDesC&  aExeName, 
+                 RWindowGroup& aParentWindowGroup, 
+                 const TDesC&  aLocation,
+                 bool          aLocationIsFilename, // false means location is URL
+                 TPoint        aTopRight, 
+                 TSize         aSize )
+        {
+        // The base name for message queue and chunk is the name of the executable followed by the address of this instance.
+        TBuf<80> nameBase;
+        nameBase.Copy( aExeName );
+        nameBase.AppendFormat(_L("%08x"), this );
+        
+        TBuf<100> commandLineArguments;
+        commandLineArguments.Copy( KMsgQueuePrefix );
+        commandLineArguments.Append( nameBase );
+        
+        TInt err = iProcess.Create( aExeName, commandLineArguments );
+
+        if( err == KErrNone )
+            {
+            aParentWindowGroup.AllowProcessToCreateChildWindowGroups( iProcess.SecureId() );
+        
+            iProcess.Resume();
+            
+            TRequestStatus status;
+            status = KRequestPending;
+            iProcess.Rendezvous( status );
+            User::WaitForRequest( status );
+            
+            err = status.Int();
+                    
+            if( err == KErrNone )
+                {  
+                err = iMsgQueue.OpenGlobal( nameBase );
+                }
+            
+            if( err == KErrNone )
+                {
+                nameBase.Append( _L("_chunk") );
+                err = iChunk.OpenGlobal( nameBase, EFalse );
+                }
+                
+            if( err == KErrNone )
+                {
+                iActive = true;
+                
+                // Send the start messages to the external player.
+                
+                TStartPlayback* chunk = (TStartPlayback*)iChunk.Base();
+                
+                TPtr8 filename( chunk->name, 0, 200 );
+                filename.Copy( aLocation );
+                chunk->length = filename.Length();            
+                chunk->locationIsFilename = aLocationIsFilename;
+                
+                chunk->x = aTopRight.iX;
+                chunk->y = aTopRight.iY;
+                chunk->width = aSize.iWidth;
+                chunk->height = aSize.iHeight;
+                chunk->idOfParentWindowGroup = aParentWindowGroup.Identifier();
+                err = SendMsg( EExternalPlayer_StartPlayback );
+                
+                if( err == KErrNone )
+                    {
+                    TStartPlaybackReturn* chunk = (TStartPlaybackReturn*)iChunk.Base();
+                    iWindowGroupId = chunk->windowGroupId;                            
+                    }
+                }
+            else
+                {
+                iProcess.Kill( KErrCancel );
+                iProcess.Close();     
+                }
+            
+            }
+        
+        return err;        
+        }
+
+    // inherited from MPlayerCommands
+    TInt ExecuteOperation( TInt aOperation )
+        {
+        TInt err = KErrNone;
+        
+        if( iActive )
+            {
+            TExecuteOperation* chunk = (TExecuteOperation*)iChunk.Base();
+            chunk->operation = aOperation;            
+            err = SendMsg( EExternalPlayer_ExecuteOperation );
+            }
+        
+        return err;
+        }
+    
+    // inherited from MPlayerCommands
+    void MoveWindow( TPoint aNewCenter )
+        {
+        if( iActive )
+            {
+            TMoveWindow* chunk = (TMoveWindow*)iChunk.Base();
+            chunk->centerX = aNewCenter.iX;            
+            chunk->centerY = aNewCenter.iY;            
+            SendMsg( EExternalPlayer_MoveWindow );
+            }
+        }
+    
+    void SetOrdinalPosition( TInt /*aPosition*/ )
+        {
+        if( iActive )
+            {        
+// TODO: DEBUG THIS.  HOW DOES WINDOW GROUP ORDINAL POSITION RELATE TO WINDOW ORDINAL POSITION?        
+//            iWs.SetWindowGroupOrdinalPosition( iWindowGroupId, aPosition );
+            }
+        }
+    
+    void Terminate()
+        {
+        if( iActive )
+            {
+            SendMsg( EExternalPlayer_Shutdown );
+        
+            iProcess.Close();
+            iMsgQueue.Close();
+            
+            iActive = false;
+            }
+        }
+    
+private:
+    
+    RWsSession&                        iWs;
+    RProcess                           iProcess;
+    bool                               iActive;
+    RMsgQueue<TExternalPlayerCommands> iMsgQueue;
+    RChunk                             iChunk;
+    TInt                               iWindowGroupId;
+
+    };
+    
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/consoleplayer/player/inc/playerwindow.h	Fri Sep 03 19:37:02 2010 -0500
@@ -0,0 +1,273 @@
+/*
+ * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ * Header specifying the abstract Player Window.
+ * 
+ */
+
+#ifndef __PLAYER_WINDOW_H__
+#define __PLAYER_WINDOW_H__
+
+#include <e32base.h>
+#include <f32file.h>
+#include <w32std.h>
+
+#include "testappbase.h"
+
+enum TPlayerWindowOperations
+    {
+    EOperation_PauseResume = KOperation_FirstCustomIndex+100,
+    EOperation_Pause,
+    EOperation_Resume,
+    EOperation_StopPlay,
+    EOperation_SeekBack,
+    EOperation_SeekForward,
+    EOperation_SeekStart,
+    EOperation_SeekEnd,
+    EOperation_Rotate,
+    EOperation_Autoscale,
+    EOperation_IncreaseHeightScale,
+    EOperation_DecreaseHeightScale,
+    EOperation_IncreaseWidthScale,
+    EOperation_DecreaseWidthScale,
+    EOperation_ClipRectangle,
+    EOperation_Extent,
+    EOperation_ResetToDefaults,
+    EOperation_IncreaseVolume,
+    EOperation_DecreaseVolume,
+    EOperation_MaximumVolume,
+    EOperation_Mute,
+    EOperation_BalanceLeft,
+    EOperation_BalanceRight,
+    EOperation_BalanceCenter,
+    EOperation_BalanceMaxLeft,
+    EOperation_BalanceMaxRight,
+    EOperation_FrameStepForward,
+    EOperation_FrameStepBackward,
+    EOperation_IncreasePlayVelocity,
+    EOperation_DecreasePlayVelocity,
+    EOperation_MoveWindowUp,
+    EOperation_MoveWindowDown,
+    EOperation_MoveWindowLeft,
+    EOperation_MoveWindowRight,
+    EOperation_ChangeWindowSize,
+    EOperation_ToggleWindowTransparency,
+    EOperation_DrawWhiteBorderAroundWindow,
+    EOperation_DrawRedBorderAroundWindow,
+    EOperation_ClearBorderAroundWindow
+    };
+
+class MPlayerWindowObserver
+    {
+public:
+    
+    virtual void PlayInitiated() = 0;
+    
+    virtual void PlayStateChanged() = 0;
+    
+    virtual void Error(TInt aError) = 0;
+    };
+
+class MPlayerCommands
+    {
+public:
+    
+    virtual TInt ExecuteOperation( TInt aOperation ) = 0;
+    
+    virtual void MoveWindow( TPoint aNewCenter ) = 0;
+    
+    virtual void SetOrdinalPosition( TInt aPosition ) = 0;
+    };
+
+class CPlayerWindow : public CBase, public MPlayerCommands
+    {
+public:
+
+    enum TPlayState
+        {
+        EStopped,
+        EPlaying,
+        EPaused
+        };
+
+    enum TAutoscaleMode
+        {
+        EDoNotAutoscale,
+        EBestFit,
+        EStretch
+        };
+    
+    virtual ~CPlayerWindow();
+
+    // inherited from MPlayerCommands
+    virtual TInt ExecuteOperation( TInt aOperation );
+    virtual void MoveWindow( TPoint aNewCenter );    
+    virtual void SetOrdinalPosition( TInt aPosition );
+
+    void StartWithFilenameL( const TDesC& aFullFilename,
+                             TAutoscaleMode aDefaultAutoscale,
+                             MPlayerWindowObserver* aObserver = NULL );
+
+    void StartWithUrlL( const TDesC& aUrl,
+                        TAutoscaleMode aDefaultAutoscale,
+                        MPlayerWindowObserver* aObserver = NULL );
+
+    RWindow& Window();
+
+    void WriteAdvancedText( CWindowGc& aGc, TInt aColumn, TInt& aRow, TInt aRowIncrement );        
+    
+    const TDesC& FullFilename();
+    
+    const TDesC& Filename();
+    
+    const TDesC& Url();
+    
+    TPlayState PlayState();
+
+    TSize VideoSize();
+        
+    TInt PositionInMs();
+    
+    TInt DurationInMs();
+    
+    virtual TInt SetVideoExtent( TRect aExtent ) = 0;
+
+    virtual TInt Play() = 0;
+    
+    virtual TInt Pause() = 0;
+
+protected:
+    
+    CPlayerWindow( RFs& aFs, RWsSession& aWs, CWsScreenDevice& aScreenDevice, bool aSuppressGraphicsContext );
+    
+    void CheckWindowLimits();
+    
+    void DrawBorderAroundWindow();
+    
+    // These functions must be called by subclasses
+    
+    void BaseConstructL( const RWindowTreeNode &aParentWindow, TPoint aTopLeft, TSize aSize, bool aTransparent, TRgb aBackgroundColor );
+    void PlayInitiated();
+    void PlayComplete();    
+    void CheckError( TInt aError, const char* pDescription );
+    void Error( TInt aError, const char* pDescription = NULL );
+    
+    // These functions must be implemented by subclasses
+    
+    virtual void InitializeParameters( TSize& aVideoSize, 
+                                       TTimeIntervalMicroSeconds& aDuration, 
+                                       TInt& aMaxVolume, 
+                                       TInt& aCurrentVolume,
+                                       TInt& aBalanceCenter,
+                                       TInt& aBalanceMaxLeft,
+                                       TInt& aBalanceMaxRight,
+                                       TInt& aDefaultBalance, 
+                                       TInt& aCurrentBalance ) = 0;
+    
+    virtual void SetDefaultAutoscaleMode( TAutoscaleMode aDefaultAutoscale ) = 0;
+    
+    virtual void PreparePlayerWithFile( RFile& aFile ) = 0;
+
+    virtual void PreparePlayerWithUrl( const TDesC& aUrl ) = 0;
+
+    virtual TInt DoExecuteOperation( TInt aOperation ) = 0;
+
+    virtual TTimeIntervalMicroSeconds Position() = 0; // microseconds
+    
+    virtual TInt SetVolume( TInt aVolume ) = 0;
+    
+    virtual TInt SetBalance( TInt aBalance ) = 0;
+    
+    virtual TInt RotationAngle() = 0;
+    
+    virtual TInt NextRotationAngle() = 0;
+    
+    virtual TInt ResetRotation() = 0;
+    
+    virtual TInt NextAutoscaleMode() = 0;
+    
+    virtual TInt ResetAutoscale() = 0;
+    
+    virtual void AppendAutoscaleModeText( TDes& aString ) = 0;
+    
+    virtual TInt SetClipRectangle( TRect aRect ) = 0;
+    
+    virtual TInt SetScaleFactor( TReal aWidthScaleFactor, TReal aHeightScaleFactor ) = 0;
+    
+    virtual TInt Stop() = 0;
+    
+    virtual TInt SetPosition( TTimeIntervalMicroSeconds ) = 0;
+    
+    virtual TInt StepForward() = 0;
+    
+    virtual TInt StepBackward() = 0;
+    
+    virtual TInt SetPlayVelocity( TInt aVelocity ) = 0;
+    
+    RFs&                    iFs;
+    RFile                   iFile;
+    RWsSession&             iWs;
+    CWsScreenDevice&        iScreenDevice;
+    CWindowGc*              iGc;
+    
+    RWindow                 iWindow;
+    TBuf<120>               iBuffer;
+
+private:
+    
+    TRect Rectangle( TInt aModeIndex );
+    
+    TInt Seek( TTimeIntervalMicroSeconds aPosition ); 
+    
+    TInt UpdateScaleFactor();
+
+    TInt ResetToDefaults();
+    
+    TFileName                 iFullFilename;
+    TFileName                 iFilename;
+    TFileName                 iUrl;
+    MPlayerWindowObserver*    iObserver;
+    bool                      iSuppressGraphicsContext;
+    
+    TPlayState                iPlayState;
+    TTimeIntervalMicroSeconds iDuration;
+    TInt                      iDurationInMs;
+    TInt                      iCurrentVelocity;
+    
+    // Video attributes
+    TSize                     iVideoSize;
+    TInt                      iWidthScaleIndex;
+    TInt                      iHeightScaleIndex;   
+    TInt                      iClipModeIndex;
+    TInt                      iExtentModeIndex;
+    TPoint                    iWindowTopLeft;
+    TSize                     iDefaultWindowSize;
+    TSize                     iWindowSize;
+    TInt                      iWindowSizeDivisor;
+    bool                      iWindowTransparent;
+    TRgb                  iBorderColor;
+        
+    // Audio attributes
+    TInt                      iMaxVolume;
+    TInt                      iDefaultVolume;
+    TInt                      iCurrentVolume;
+    TInt                      iBalanceCenter;
+    TInt                      iBalanceMaxRight;
+    TInt                      iBalanceMaxLeft;
+    TInt                      iDefaultBalance;
+    TInt                      iCurrentBalance;
+  
+    };
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/consoleplayer/player/src/consoleplayer.cpp	Fri Sep 03 19:37:02 2010 -0500
@@ -0,0 +1,1502 @@
+/*
+ * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ * Source file for the main class of the ConsolePlayer test app.
+ * 
+ */
+
+#include "consoleplayer.h"
+
+#include <e32base.h>
+#include <e32debug.h>
+#include <f32file.h>
+#include <bldvariant.hrh>
+
+#include "MmfPlayerWindow.h"
+#include "ExternalPlayer.h"
+
+#ifdef FF_OPENMAX_AL
+#include "opmaxplayerwindow.h"
+#endif
+
+const TInt KFontSize = 15;
+
+const TInt KOrdinalPositionConfigurationCount = 7;
+const TInt KPlayerCount = 5;
+
+enum TPlayerNames
+    {
+    EVideoPlayer,
+    EVideoPlayer2,
+    EVideoPlayer3,
+    EExternalPlayer,
+    EExternalPlayer2
+    };
+
+// entries are sorted with foreground windows first
+const TPlayerNames KOrdinalPositions[KOrdinalPositionConfigurationCount][KPlayerCount] =
+    {
+        {EVideoPlayer3, EVideoPlayer2, EExternalPlayer, EExternalPlayer2, EVideoPlayer},
+        {EVideoPlayer2, EVideoPlayer3, EExternalPlayer2, EExternalPlayer, EVideoPlayer},
+        {EExternalPlayer, EExternalPlayer2, EVideoPlayer3, EVideoPlayer2, EVideoPlayer},
+        {EVideoPlayer3, EExternalPlayer2, EVideoPlayer2, EExternalPlayer, EVideoPlayer},
+        {EVideoPlayer3, EVideoPlayer2, EVideoPlayer, EExternalPlayer, EExternalPlayer2},
+        {EExternalPlayer, EExternalPlayer2, EVideoPlayer, EVideoPlayer3, EVideoPlayer2},
+        {EVideoPlayer, EVideoPlayer3, EVideoPlayer2, EExternalPlayer, EExternalPlayer2}
+    };
+
+// Key map
+// This section maps the options to keys for each page of options.
+
+const TInt KKeyMapPageCount = 9;
+
+const TInt KWindow2Page = 5;
+const TInt KWindow3Page = 6; 
+const TInt KExternalPlayerPage = 7;
+const TInt KExternalPlayer2Page = 8;
+const TInt KAllPlayersPage = 9;
+
+const TOperationsPage KKeyMap[KKeyMapPageCount] =
+    {        
+        {STR("Standard controls"),
+         5, // default softkey index
+            {
+                // Enter
+                {STR("Pause/Resume"),                EOperation_PauseResume}, 
+                // Up / Down / Left / Right
+                {STR("Seek back 5 seconds"),         EOperation_SeekBack},
+                {STR("Seek forward 5 seconds"),      EOperation_SeekForward},
+                {STR("Seek to start of clip"),       EOperation_SeekStart},
+                {STR("Seek to end minus 5 secs"),    EOperation_SeekEnd},
+                // 0 - 9
+                {STR("Help text on/off"),            KOperation_ToggleHelpVisibility},  
+                {STR("Go to next options page"),     KOperation_NextOptionPage},  
+                {STR("Stop/Play"),                   EOperation_StopPlay},  
+                {STR("Obscure entire screen"),       EOperation_ObscureWindow},
+                {STR("Toggle help transparency"),    KOperation_ToggleHelpTransparency},  
+                {STR("Change video window size"),    EOperation_ChangeWindowSize},
+                {STR("Panic this process"),          EOperation_AbnormalTermination},  
+                {STR(""),                            KOperation_None},  
+                {STR(""),                            KOperation_None},  
+                {STR(""),                            KOperation_None},  
+                // *, #
+                {STR("Change display mode"),         EOperation_ChangeDisplayMode},  
+                {STR("Exit"),                        KOperation_Exit}                
+            }
+        },
+        {STR("Video controls"),
+         7, // default softkey index
+            {
+                // Enter
+                {STR("Pause/Resume"),                EOperation_PauseResume},
+                // Up / Down / Left / Right
+                {STR("Increase height scale"),       EOperation_IncreaseHeightScale},
+                {STR("Decrease height scale"),       EOperation_DecreaseHeightScale},
+                {STR("Increase width scale"),        EOperation_IncreaseWidthScale},
+                {STR("Decrease width scale"),        EOperation_DecreaseWidthScale},
+                // 0 - 9
+                {STR("Help text on/off"),            KOperation_ToggleHelpVisibility},
+                {STR("Go to next options page"),     KOperation_NextOptionPage},  
+                {STR("Change rotation angle"),       EOperation_Rotate},
+                {STR("Change autoscale mode"),       EOperation_Autoscale},
+                {STR("Change clipping rectangle"),   EOperation_ClipRectangle},
+                {STR("Change extent rectangle"),     EOperation_Extent},
+                {STR(""),                            KOperation_None},
+                {STR(""),                            KOperation_None},  
+                {STR(""),                            KOperation_None},  
+                {STR("Reset to defaults"),           EOperation_ResetToDefaults},
+                // *, #
+                {STR("Change display mode"),         EOperation_ChangeDisplayMode},
+                {STR("Exit"),                        KOperation_Exit}
+            }
+        },
+        {STR("Trick play"),
+         5, // default softkey index
+            {   
+                // Enter
+                {STR("Pause/Resume"),                EOperation_PauseResume}, 
+                // Up / Down / Left / Right
+                {STR("Frame step forward"),          EOperation_FrameStepForward}, 
+                {STR("Frame step backward"),         EOperation_FrameStepBackward},  
+                {STR("Decrease play velocity"),      EOperation_DecreasePlayVelocity},
+                {STR("Increase play velocity"),      EOperation_IncreasePlayVelocity},
+                // 0 - 9
+                {STR("Help text on/off"),            KOperation_ToggleHelpVisibility},
+                {STR("Go to next options page"),     KOperation_NextOptionPage},  
+                {STR(""),                            KOperation_None},
+                {STR(""),                            KOperation_None},
+                {STR(""),                            KOperation_None},
+                {STR(""),                            KOperation_None},
+                {STR(""),                            KOperation_None},
+                {STR(""),                            KOperation_None},  
+                {STR(""),                            KOperation_None},  
+                {STR("Reset to defaults"),           EOperation_ResetToDefaults},
+                // *, #
+                {STR("Change display mode"),         EOperation_ChangeDisplayMode},
+                {STR("Exit"),                        KOperation_Exit}
+            } 
+        },
+        {STR("Audio controls"),
+         0, // default softkey index
+            {
+                // Enter
+                {STR("Pause/Resume"),                EOperation_PauseResume},
+                // Up / Down / Left / Right
+                {STR("Increase volume 10%"),         EOperation_IncreaseVolume},
+                {STR("Decrease volume 10%"),         EOperation_DecreaseVolume},
+                {STR("Balance left"),                EOperation_BalanceLeft},
+                {STR("Balance right"),               EOperation_BalanceRight},
+                // 0 - 9
+                {STR("Help text on/off"),            KOperation_ToggleHelpVisibility},
+                {STR("Go to next options page"),     KOperation_NextOptionPage},  
+                {STR("Maximum volume"),              EOperation_MaximumVolume},
+                {STR("Mute"),                        EOperation_Mute},
+                {STR("Balance maximum left"),        EOperation_BalanceMaxLeft},
+                {STR("Balance maximum right"),       EOperation_BalanceMaxRight},
+                {STR(""),                            KOperation_None},
+                {STR(""),                            KOperation_None},  
+                {STR(""),                            KOperation_None},  
+                {STR("Reset to defaults"),           EOperation_ResetToDefaults},
+                // *, #
+                {STR("Change display mode"),         EOperation_ChangeDisplayMode},
+                {STR("Exit"),                        KOperation_Exit}
+            }
+        },        
+        {STR("Video window #2 (same process)"),
+         7, // default softkey index
+            {   
+                // Enter
+                {STR("Pause/Resume"),                EOperation_PauseResume},
+                // Up / Down / Left / Right
+                {STR("Move window up"),              EOperation_MoveWindowUp},
+                {STR("Move window down"),            EOperation_MoveWindowDown},
+                {STR("Move window left"),            EOperation_MoveWindowLeft},
+                {STR("Move window right"),           EOperation_MoveWindowRight},
+                // 0 - 9
+                {STR("Help text on/off"),            KOperation_ToggleHelpVisibility},
+                {STR("Go to next options page"),     KOperation_NextOptionPage},  
+                {STR("Toggle window on/off"),        EOperation_ToggleSecondVideo},
+                {STR("Drag window"),                 EOperation_DragWindow},
+                {STR("Toggle window transparency"),  EOperation_ToggleWindowTransparency},
+                {STR("Change video window size"),    EOperation_ChangeWindowSize},
+                {STR("Change autoscale mode"),       EOperation_Autoscale},
+                {STR(""),                            KOperation_None},
+                {STR(""),                            KOperation_None},  
+                {STR("Reset to defaults"),           EOperation_ResetToDefaults},
+                // *, #
+                {STR("Change display mode"),         EOperation_ChangeDisplayMode},
+                {STR("Exit"),                        KOperation_Exit}
+            }
+        },
+        {STR("Video window #3 (same process)"),
+         7, // default softkey index
+            {   
+                // Enter
+                {STR("Pause/Resume"),                EOperation_PauseResume},
+                // Up / Down / Left / Right
+                {STR("Move window up"),              EOperation_MoveWindowUp},
+                {STR("Move window down"),            EOperation_MoveWindowDown},
+                {STR("Move window left"),            EOperation_MoveWindowLeft},
+                {STR("Move window right"),           EOperation_MoveWindowRight},
+                // 0 - 9
+                {STR("Help text on/off"),            KOperation_ToggleHelpVisibility},
+                {STR("Go to next options page"),     KOperation_NextOptionPage},  
+                {STR("Toggle window on/off"),        EOperation_ToggleThirdVideo},
+                {STR("Drag window"),                 EOperation_DragWindow},
+                {STR("Toggle window transparency"),  EOperation_ToggleWindowTransparency},
+                {STR("Change video window size"),    EOperation_ChangeWindowSize},
+                {STR("Change autoscale mode"),       EOperation_Autoscale},
+                {STR(""),                            KOperation_None},
+                {STR(""),                            KOperation_None},  
+                {STR("Reset to defaults"),           EOperation_ResetToDefaults},
+                // *, #
+                {STR("Change display mode"),         EOperation_ChangeDisplayMode},
+                {STR("Exit"),                        KOperation_Exit}
+            }
+        },
+        {STR("Video window #4 (another process)"),
+         7, // default softkey index
+            {   
+                // Enter
+                {STR("Pause/Resume"),                EOperation_PauseResume},
+                // Up / Down / Left / Right
+                {STR("Move window up"),              EOperation_MoveWindowUp},
+                {STR("Move window down"),            EOperation_MoveWindowDown},
+                {STR("Move window left"),            EOperation_MoveWindowLeft},
+                {STR("Move window right"),           EOperation_MoveWindowRight},
+                // 0 - 9
+                {STR("Help text on/off"),            KOperation_ToggleHelpVisibility},
+                {STR("Go to next options page"),     KOperation_NextOptionPage},  
+                {STR("Toggle window on/off"),        EOperation_ToggleExternalPlayer},
+                {STR("Drag window"),                 EOperation_DragWindow},
+                {STR("Toggle window transparency"),  EOperation_ToggleWindowTransparency},
+                {STR("Change video window size"),    EOperation_ChangeWindowSize},
+                {STR("Change autoscale mode"),       EOperation_Autoscale},
+                {STR(""),                            KOperation_None},
+                {STR(""),                            KOperation_None},  
+                {STR("Reset to defaults"),           EOperation_ResetToDefaults},
+                // *, #
+                {STR("Change display mode"),         EOperation_ChangeDisplayMode},
+                {STR("Exit"),                        KOperation_Exit}
+            } 
+        },
+        {STR("Video window #5 (another process)"),
+         7, // default softkey index
+            {   
+                // Enter
+                {STR("Pause/Resume"),                EOperation_PauseResume},
+                // Up / Down / Left / Right
+                {STR("Move window up"),              EOperation_MoveWindowUp},
+                {STR("Move window down"),            EOperation_MoveWindowDown},
+                {STR("Move window left"),            EOperation_MoveWindowLeft},
+                {STR("Move window right"),           EOperation_MoveWindowRight},
+                // 0 - 9
+                {STR("Help text on/off"),            KOperation_ToggleHelpVisibility},
+                {STR("Go to next options page"),     KOperation_NextOptionPage},  
+                {STR("Toggle window on/off"),        EOperation_ToggleExternalPlayer2},
+                {STR("Drag window"),                 EOperation_DragWindow},
+                {STR("Toggle window transparency"),  EOperation_ToggleWindowTransparency},
+                {STR("Change video window size"),    EOperation_ChangeWindowSize},
+                {STR("Change autoscale mode"),       EOperation_Autoscale},
+                {STR(""),                            KOperation_None},
+                {STR(""),                            KOperation_None},  
+                {STR("Reset to defaults"),           EOperation_ResetToDefaults},
+                // *, #
+                {STR("Change display mode"),         EOperation_ChangeDisplayMode},
+                {STR("Exit"),                        KOperation_Exit}
+            } 
+        },
+        {STR("Control all windows"),
+         7, // default softkey index
+            {   
+                // Enter
+                {STR("Pause/Resume"),                EOperation_PauseResume},
+                // Up / Down / Left / Right
+                {STR("Seek back 5 seconds"),         EOperation_SeekBack},
+                {STR("Seek forward 5 seconds"),      EOperation_SeekForward},
+                {STR("Seek to start of clip"),       EOperation_SeekStart},
+                {STR("Seek to end minus 5 secs"),    EOperation_SeekEnd},
+                // 0 - 9
+                {STR("Help text on/off"),            KOperation_ToggleHelpVisibility},
+                {STR("Go to next options page"),     KOperation_NextOptionPage},  
+                {STR("Create all windows"),          EOperation_LaunchAllWindows},
+                {STR("Toggle ordinal positions"),    EOperation_ToggleOrdinalPositions},
+                {STR("Pause all"),                   EOperation_Pause},  
+                {STR("Resume all"),                  EOperation_Resume},  
+                {STR("Stop/Play all"),               EOperation_StopPlay},  
+                {STR(""),                            KOperation_None},  
+                {STR(""),                            KOperation_None},  
+                {STR("Reset to defaults"),           EOperation_ResetToDefaults},
+                // *, #
+                {STR("Change display mode"),         EOperation_ChangeDisplayMode},
+                {STR("Exit"),                        KOperation_Exit}
+            } 
+        }
+    };
+
+
+// Console player implementation
+
+void CConsolePlayer::ExecuteL()
+    {
+    CConsolePlayer* self = new(ELeave) CConsolePlayer;
+    CleanupStack::PushL( self );
+    self->InitL();
+    self->Main();
+    CleanupStack::PopAndDestroy( self );    
+    }
+    
+CConsolePlayer::CConsolePlayer() : 
+    CTestAppBase( KFontSize ),
+    iLastError( KErrNone ),
+    iVideoWindowTextMode( 1 ),
+    iFinalResult( 0 )
+    {    
+    }
+    
+CConsolePlayer::~CConsolePlayer()
+    {
+    Cancel();
+    
+    if( iGc && iFullScreenWindow )
+    {
+        iGc->Activate(*iFullScreenWindow);
+        
+        iFullScreenWindow->Invalidate();
+        iFullScreenWindow->BeginRedraw();
+        
+        iGc->Reset();
+        
+        iGc->UseFont(iFont);                
+        iGc->SetBrushColor(KRgbDarkBlue);
+        
+        iGc->Clear();
+
+        if( iFinalResult == KErrNone )
+            {
+            // KRgbWhite seems to be having problems (0xffffff) in some emulators,
+            // but 0xfefefe is working, so use that instead of white.        
+            iGc->SetPenColor(0xfefefe);                 
+            }
+        else
+            {
+            iGc->SetPenColor(KRgbRed);
+            }
+    
+        iBuffer.Format( _L("CONSOLEPLAYER EXIT, result = %i"), iFinalResult );
+        iGc->DrawText( iBuffer, TPoint(5, 20) );
+       
+        iFullScreenWindow->EndRedraw();
+        
+        iGc->Deactivate();
+        
+        iFullScreenWindow->SetVisible( ETrue );
+        
+        WaitForAnyKey();
+    }    
+    
+    delete iExternalPlayer;
+    delete iExternalPlayer2;
+    delete iVideoPlayer;        
+    delete iVideoPlayer2;
+    delete iVideoPlayer3;
+    delete iTimerCallback;
+    delete iFullScreenWindow;
+    }
+    
+void CConsolePlayer::InitL()
+    {
+    BaseConstructL( KKeyMap, KKeyMapPageCount );
+    
+    iFullScreenWindow = new(ELeave) RWindow( iWs );
+    User::LeaveIfError( iFullScreenWindow->Construct( *iWindowGroup, KNullWsHandle ) );
+    iFullScreenWindow->SetExtent( TPoint(0,0), iDisplaySize );
+    iFullScreenWindow->SetNonTransparent();
+    iFullScreenWindow->SetBackgroundColor(KRgbBlack);
+    iFullScreenWindow->SetVisible(false);
+    iFullScreenWindow->Activate();
+        
+    iGc->Activate(*iFullScreenWindow);
+
+    iFullScreenWindow->BeginRedraw();
+    
+    iGc->Reset();    
+    iGc->UseFont(iFont);                
+    iGc->SetBrushStyle(CWindowGc::ESolidBrush);
+    iGc->SetBrushColor(KRgbBlack);    
+    iGc->Clear();
+    
+    iFullScreenWindow->EndRedraw();
+    
+    iGc->Deactivate();    
+    }
+
+void CConsolePlayer::Main()
+    {    
+    TRAPD( err, MainL() ); 
+    
+    RDebug::Printf( "CONSOLEPLAYER Completed, err=%i", err );    
+    }
+    
+void CConsolePlayer::DoSelectAction( TUint aActionMask, 
+                                     bool aPresentPerformanceModeOption, 
+                                     TActionToPerform& aAction,
+                                     bool& aPerformanceMode )
+    {
+    RPointerArray<TDesC> operations;
+
+    TInt sameAsMainPlayerIndex = -2;
+    TInt playLocalFileIndex = -2;
+    TInt playLocalFilePerformanceIndex = -2;
+    TInt playUrlIndex = -2;
+    TInt playUrlPerformanceIndex = -2;
+    
+    if( aActionMask & EAction_SameAsMainPlayer )
+        {
+        _LIT( KSameAsMainPlayer, "Same as main player" );
+        sameAsMainPlayerIndex = operations.Count();
+        operations.Append( &KSameAsMainPlayer );
+        }
+    
+    if( aActionMask & EAction_PlayLocalFile )
+        {
+        _LIT( KPlayLocalFile, "Play local file" );
+        playLocalFileIndex = operations.Count();
+        operations.Append( &KPlayLocalFile );
+        
+        if( aPresentPerformanceModeOption )
+            {
+            _LIT( KPlayLocalFilePerformance, "Play local file (performance mode)" );
+            playLocalFilePerformanceIndex = operations.Count();
+            operations.Append( &KPlayLocalFilePerformance );
+            }
+        }
+    
+    if( aActionMask & EAction_PlayUrl )
+        {
+        _LIT( KPlayUrl, "Play URL from c:\\data\\urls.txt" );
+        playUrlIndex = operations.Count();
+        operations.Append( &KPlayUrl );
+        
+        if( aPresentPerformanceModeOption )
+            {
+            _LIT( KPlayUrlPerformance, "Play URL from c:\\data\\urls.txt (performance mode)" );
+            playUrlPerformanceIndex = operations.Count();
+            operations.Append( &KPlayUrlPerformance );
+            }
+        }
+    
+    _LIT( KExit, "Exit" );
+    operations.Append( &KExit );
+
+    TInt index = 0;
+    
+    if( operations.Count() > 1 )
+        {
+        index = SelectFromListL( TPoint(0,0), iDisplaySize, _L("Select operation to perform:"), operations );
+        }
+    
+    if( index == sameAsMainPlayerIndex )
+        {
+        aAction = EAction_SameAsMainPlayer;
+        }
+    else if( index == playLocalFileIndex )
+        {
+        aAction = EAction_PlayLocalFile;
+        aPerformanceMode = false;
+        }
+    else if( index == playLocalFilePerformanceIndex )
+        {    
+        aAction = EAction_PlayLocalFile;
+        aPerformanceMode = true;
+        }
+    else if( index == playUrlIndex )
+        {    
+        aAction = EAction_PlayUrl;
+        aPerformanceMode = false;
+        }
+    else if( index == playUrlPerformanceIndex )
+        {    
+        aAction = EAction_PlayUrl;
+        aPerformanceMode = true;
+        }
+    else
+        {
+        aAction = EAction_None;
+        }
+    
+    operations.Close();
+    }
+
+bool CConsolePlayer::DoSelectApi( TUint aApiMask, 
+                                  TApiToUse& aApi )
+    {
+    RPointerArray<TDesC> apiList;
+
+    TInt videoPlayerIndex = -2;
+    TInt omxAlIndex = -2;
+    
+    if( aApiMask & EApi_VideoPlayer )
+        {
+        _LIT( KVideoPlayer, "Video player" );
+        videoPlayerIndex = apiList.Count();
+        apiList.Append( &KVideoPlayer );
+        }
+    
+    if( aApiMask & EApi_OpenMaxAl )
+        {
+        _LIT( KOmxAl, "OpenMAX AL" );
+        omxAlIndex = apiList.Count();
+        apiList.Append( &KOmxAl );
+        }
+    
+    TInt index = 0;
+    
+    if( apiList.Count() > 1 )
+        {
+        index = SelectFromListL( TPoint(0,0), iDisplaySize, _L("Select API to use:"), apiList );
+        }
+
+    bool selected = true;
+    
+    if( index == videoPlayerIndex )
+        {
+        aApi = EApi_VideoPlayer;
+        }
+    else if( index == omxAlIndex )
+        {
+        aApi = EApi_OpenMaxAl;
+        }
+    else
+        {
+        selected = false;
+        }
+    
+    apiList.Close();
+    
+    return selected;
+    }
+
+void CConsolePlayer::SelectAction( TUint aActionMask,
+                                   TUint aApiMask, 
+                                   bool aPresentPerformanceModeOption,
+                                   TActionToPerform& aAction, 
+                                   TApiToUse& aApi, 
+                                   bool& aPerformanceMode,
+                                   TFileName& aLocation )
+    {
+    bool done = false;
+    
+    while( !done )
+        {
+        DoSelectAction( aActionMask, aPresentPerformanceModeOption, aAction, aPerformanceMode );
+    
+        switch( aAction )
+            {
+            case EAction_None:
+            case EAction_SameAsMainPlayer:
+                
+                done = true;
+                break;
+                
+            case EAction_PlayLocalFile:
+                
+                while( !done && DoSelectApi( aApiMask, aApi ) )
+                    {
+                    done = SelectFileWithHistoryL( TPoint(0,0), iDisplaySize, aLocation, KHistoryFilename, KMaxHistoryEntries );
+                    }
+                break;
+                
+            case EAction_PlayUrl:
+                
+                while( !done && DoSelectApi( aApiMask, aApi ) )
+                    {
+                    done = SelectUrlL( aLocation );
+                    }                
+                break;
+            }        
+        }    
+    }
+
+void CConsolePlayer::MainL()        
+    {
+    bool performanceMode;
+    TFileName location;
+    
+    TUint actionMask = (EAction_PlayLocalFile | EAction_PlayUrl);  
+            
+    TUint apiMask = EApi_VideoPlayer;
+
+#ifdef FF_OPENMAX_AL
+    apiMask |= EApi_OpenMaxAl; 
+#endif
+    
+    bool done = false;
+    
+    while( !done )
+        {    
+        SelectAction( actionMask, apiMask, true, iMainPlayerAction, iMainPlayerApi, performanceMode, location );
+    
+        switch( iMainPlayerAction )
+            {
+            case EAction_None:
+    
+                // Do nothing.  Exit program.
+                done = true;
+                break;
+                
+            case EAction_PlayLocalFile:
+            case EAction_PlayUrl:
+                {
+                CPlayerWindow::TAutoscaleMode autoscale = CPlayerWindow::EDoNotAutoscale;
+                
+                if( performanceMode )
+                    {
+                    // turn off text
+                    iVideoWindowTextMode = 0;
+                    
+                    // stretch video to full window
+                    autoscale = CPlayerWindow::EStretch;
+                    
+                    // do not use timer in performance mode
+                    }
+                else
+                    {    
+                    iTimerCallback = new(ELeave) CTimerCallback( *this );    
+                    }
+                
+                // The first video player window is full screen. 
+                iVideoPlayer = PlayerWindowNewL( iMainPlayerApi,
+                                                 TPoint(0,0), 
+                                                 iDisplaySize, 
+                                                 false,  // not transparent 
+                                                 KRgbDarkBlue,
+                                                 true ); 
+                        
+                iActivePlayer = iVideoPlayer;
+
+                if( iMainPlayerAction == EAction_PlayLocalFile )
+                    {
+                    // RDebug::Printf only supports 8-bit strings, but RawPrint can handle 16-bit descriptors.
+                    RDebug::Printf( "CONSOLEPLAYER file:" );
+                    RDebug::RawPrint( location );
+                
+                    iVideoPlayer->StartWithFilenameL(location, autoscale, this);
+                    }
+                else
+                    {
+                    // RDebug::Printf only supports 8-bit strings, but RawPrint can handle 16-bit descriptors.
+                    RDebug::Printf( "CONSOLEPLAYER URL:" );
+                    RDebug::RawPrint( location );
+                            
+                    iVideoPlayer->StartWithUrlL(location, autoscale, this);
+                    }
+                
+                done = true;
+                CActiveScheduler::Start();
+                }
+                break;
+                
+            }
+        }
+    }
+  
+bool CConsolePlayer::SelectUrlL( TDes& aUrl )
+    {    
+    RPointerArray<HBufC> urlList;
+    TInt err = ReadFile( KUrlListFilename, urlList );
+
+    bool selected = false; 
+    
+    if( err == KErrNone )
+        {
+        TInt index = SelectFromListL( TPoint(0,0), iDisplaySize, _L("Select URL:"), urlList );
+        
+        if( index >= 0 )
+            {
+            selected = true;
+            aUrl.Copy( urlList[index]->Des() );
+            }
+        }
+    
+    urlList.ResetAndDestroy();
+    
+    return selected;
+    }
+
+MPlayerCommands* CConsolePlayer::CurrentPlayer()
+    {
+    MPlayerCommands* player = NULL;
+    
+    switch( CurrentPageNumber() )
+        {
+        case KWindow2Page:
+            player = iVideoPlayer2;
+            break;
+        case KWindow3Page:
+            player = iVideoPlayer3;
+            break;
+        case KExternalPlayerPage:
+            player = iExternalPlayer;
+            break;
+        case KExternalPlayer2Page:
+            player = iExternalPlayer2;
+            break;
+        case KAllPlayersPage:
+            player = this;  // means to route command to all players
+            break;
+        default:
+            // By default, route other commands to the main player.
+            player = iVideoPlayer;
+            break;
+        }
+    
+    return player;
+    }
+        
+void CConsolePlayer::SoftkeyFunctionUpdated()
+    {
+    MPlayerCommands* currentPlayer = CurrentPlayer();
+
+    if( currentPlayer != iActivePlayer )
+        {
+        if( iActivePlayer != NULL )
+            {
+            iActivePlayer->ExecuteOperation( EOperation_ClearBorderAroundWindow );
+            }
+    
+        iActivePlayer = currentPlayer;
+        
+        DrawBorderAroundActiveWindows();
+        }
+    
+    UpdateVideoWindow();    
+    }
+
+void CConsolePlayer::DrawBorderAroundActiveWindows()
+    {    
+    if( (iActivePlayer != NULL) && (iActivePlayer != iVideoPlayer) )
+        {               
+        iActivePlayer->ExecuteOperation( EOperation_DrawWhiteBorderAroundWindow );
+        }    
+    }
+
+bool CConsolePlayer::ConsumeKeyEvent( TInt /*aKeyCode*/ )
+    {
+    return false;    
+    }
+
+void CConsolePlayer::UpdateVideoWindow()
+    {
+    iGc->Activate(iVideoPlayer->Window());
+
+    iVideoPlayer->Window().Invalidate();
+    iVideoPlayer->Window().BeginRedraw();
+    
+    iGc->Reset();
+    iGc->SetBrushColor(KRgbTransparent);
+    iGc->Clear();
+
+    iGc->SetPenColor(KRgbCyan);
+
+    if( iVideoWindowTextMode > 0 )
+        {
+        iGc->UseFont(iFont);                
+
+        if( iSelectedOptionText.Length() > 0 )
+            {
+            // POPUP WINDOW (AFTER OPTION IS SELECTED)
+
+            iGc->SetBrushStyle(CWindowGc::ESolidBrush);
+            iGc->SetBrushColor(KRgbBlue);
+            
+            const TInt KSelectionWindowWidth = iFont->TextWidthInPixels(iSelectedOptionText)+10;
+            const TInt KSelectionWindowHeight = KFontSize+10;
+            const TInt KOffsetFromBottom = 20;
+
+            TRect box(iDisplaySize.iWidth/2-KSelectionWindowWidth/2, 
+                      iDisplaySize.iHeight-KOffsetFromBottom-KSelectionWindowHeight,
+                      iDisplaySize.iWidth/2+KSelectionWindowWidth/2, 
+                      iDisplaySize.iHeight-KOffsetFromBottom);
+            iGc->DrawText( iSelectedOptionText, box, KFontSize+2, CWindowGc::ECenter);
+
+            iGc->SetBrushStyle(CWindowGc::ENullBrush);
+            iGc->SetBrushColor(KRgbTransparent);
+            }
+        
+        // BASIC TEXT
+
+        TInt posInSec = iVideoPlayer->PositionInMs() / 1000;
+       
+        TInt durationInSec = iVideoPlayer->DurationInMs() / 1000;
+        
+        const TInt KColumn = 3;
+        const TInt KRowIncrement = KFontSize + 1;
+        TInt row = KRowIncrement;
+
+        iBuffer.Format( _L("Options page %i: "), CurrentPageNumber() );
+        iBuffer.Append( CurrentPageName() );
+        iGc->DrawText( iBuffer, TPoint(KColumn, row) );
+        row += KRowIncrement;
+        
+        iBuffer.Copy( _L("Softkey: ") );
+        iBuffer.Append( CurrentSoftkeyName() );
+        iGc->DrawText( iBuffer, TPoint(KColumn, row) );
+        row += KRowIncrement;
+        
+        iBuffer.Format( _L("Position: %i/%i secs "), posInSec, durationInSec );
+        switch( iVideoPlayer->PlayState() )
+            {
+            case CPlayerWindow::EPlaying:
+                iBuffer.Append( _L("<playing>") );
+                break;
+            case CPlayerWindow::EPaused:
+                iBuffer.Append( _L("<paused>") );
+                break;
+            case CPlayerWindow::EStopped:
+                iBuffer.Append( _L("<stopped>") );
+                break;
+            }
+        iGc->DrawText( iBuffer, TPoint(KColumn, row) );
+        row += KRowIncrement;
+        
+        if( iLastError != KErrNone )
+            {
+            iGc->SetPenColor(KRgbRed);        
+            }
+        
+        iBuffer.Format ( _L("Last error: %i"), iLastError );
+        iGc->DrawText( iBuffer, TPoint(KColumn, row) );
+        row += KRowIncrement;
+
+        iGc->SetPenColor(KRgbCyan);
+        
+        RDebug::Printf( "CONSOLEPLAYER position=%i", posInSec );
+
+        
+        if( iVideoWindowTextMode > 1 )
+            {
+            // ADVANCED TEXT
+
+            // skip a row
+            row += KRowIncrement;
+
+            iGc->DrawText( iVideoPlayer->Filename(), TPoint(KColumn, row) );
+            row += KRowIncrement;
+            
+            iBuffer.Format( _L("Display size: %ix%i"), iDisplaySize.iWidth, iDisplaySize.iHeight );
+            iGc->DrawText( iBuffer, TPoint(KColumn, row) );
+            row += KRowIncrement;
+            
+            iBuffer.Format( _L("Video size: %ix%i"), iVideoPlayer->VideoSize().iWidth, iVideoPlayer->VideoSize().iHeight );
+            iGc->DrawText( iBuffer, TPoint(KColumn, row) );
+            row += KRowIncrement;            
+            
+            iVideoPlayer->WriteAdvancedText( *iGc, KColumn, row, KRowIncrement );        
+            }
+        }
+            
+    iVideoPlayer->Window().EndRedraw();
+
+    iGc->Deactivate();
+
+    iWs.Flush();
+    }
+
+void CConsolePlayer::UpdateWindowOrdinalPositions()
+    {    
+    TInt nextOrdinal = 0;
+    
+    iSelectionWindow->SetOrdinalPosition( nextOrdinal );
+    nextOrdinal++;
+    
+    iHelpWindow->SetOrdinalPosition( nextOrdinal );
+    nextOrdinal++;
+
+    iFullScreenWindow->SetOrdinalPosition( nextOrdinal );
+    nextOrdinal++;
+
+    for( TInt playerIndex = 0; playerIndex < KPlayerCount; playerIndex++ )
+        {
+        MPlayerCommands* player = NULL;
+        
+        switch( KOrdinalPositions[iOrdinalIndex][playerIndex] )
+            {
+            case EVideoPlayer:
+                player = iVideoPlayer;
+                break;
+            case EVideoPlayer2:
+                player = iVideoPlayer2;
+                break;
+            case EVideoPlayer3:
+                player = iVideoPlayer3;
+                break;
+            case EExternalPlayer:
+                player = iExternalPlayer;
+                break;
+            case EExternalPlayer2:
+                player = iExternalPlayer2;
+                break;
+            }
+    
+        if( player )
+            {
+            player->SetOrdinalPosition( nextOrdinal );
+            nextOrdinal++;
+            }
+        }
+    }
+
+CPlayerWindow* CConsolePlayer::PlayerWindowNewL( TApiToUse aApi,
+                                                 TPoint aTopLeft,
+                                                 TSize aSize,
+                                                 bool aTransparent,
+                                                 TRgb aBackgroundColor,
+                                                 bool aSuppressGraphicsContext )
+    {
+    CPlayerWindow* player = NULL;
+    
+    switch( aApi )
+        {
+        case EApi_VideoPlayer:
+            
+            player = CMmfPlayerWindow::NewL( iFs, 
+                                             iWs, 
+                                             *iScreenDevice, 
+                                             *iWindowGroup,
+                                             aTopLeft, 
+                                             aSize, 
+                                             aTransparent, 
+                                             aBackgroundColor,
+                                             aSuppressGraphicsContext );
+            break;
+            
+        case EApi_OpenMaxAl: 
+#ifdef FF_OPENMAX_AL
+        
+            player = COpMaxPlayerWindow::NewL( iFs, 
+                                               iWs, 
+                                               *iScreenDevice, 
+                                               *iWindowGroup, 
+                                               aTopLeft, 
+                                               aSize, 
+                                               aTransparent, 
+                                               aBackgroundColor,
+                                               aSuppressGraphicsContext);
+#endif            
+            break;            
+        }
+    
+    return player;
+    }
+
+void CConsolePlayer::EnableDragging()
+    {
+    iPlayerBeingDragged = CurrentPlayer();
+    
+    if( iPlayerBeingDragged )
+        {
+        iPlayerBeingDragged->ExecuteOperation( EOperation_DrawRedBorderAroundWindow );
+        StartReceivingPointerEvents();    
+        }
+    }
+
+void CConsolePlayer::DisableDragging()
+    {
+    if( iPlayerBeingDragged )
+        {
+        // Stop routing pointer events to app.
+        StopReceivingPointerEvents(); 
+        
+        if( iPlayerBeingDragged == CurrentPlayer() )
+            {
+            iPlayerBeingDragged->ExecuteOperation( EOperation_DrawWhiteBorderAroundWindow );
+            }
+        else
+            {
+            iPlayerBeingDragged->ExecuteOperation( EOperation_ClearBorderAroundWindow );
+            }
+        
+        iPlayerBeingDragged = NULL;
+        }
+    }
+
+TInt CConsolePlayer::CreateAnotherPlayer( CPlayerWindow** aPlayerWindow, 
+                                          CExternalPlayer** aExternalPlayer,
+                                          const TDesC& aExternalPlayerExeName,
+                                          TSize aSize, 
+                                          TPoint aTopLeft )
+    {
+    TInt err = KErrNone;
+
+    bool resumePlayer1 = false;
+    bool resumePlayer2 = false;
+    bool resumePlayer3 = false;
+    bool resumeExternalPlayer1 = false;
+    bool resumeExternalPlayer2 = false;
+    
+    if( iVideoPlayer->PlayState() == CPlayerWindow::EPlaying )
+        {
+        iVideoPlayer->Pause();
+        resumePlayer1 = true;
+        }
+
+    if( iVideoPlayer2 && iVideoPlayer2->PlayState() == CPlayerWindow::EPlaying )
+        {
+        iVideoPlayer2->Pause();
+        resumePlayer2 = true;
+        }
+    
+    if( iVideoPlayer3 && iVideoPlayer3->PlayState() == CPlayerWindow::EPlaying  )
+        {
+        iVideoPlayer3->Pause();
+        resumePlayer3 = true;
+        }
+    
+    if( iExternalPlayer )
+        {
+        iExternalPlayer->ExecuteOperation( EOperation_Pause );
+        resumeExternalPlayer1 = true;
+        }
+    
+    if( iExternalPlayer2 )
+        {
+        iExternalPlayer2->ExecuteOperation( EOperation_Pause );
+        resumeExternalPlayer2 = true;
+        }
+    
+    TActionToPerform action;
+    TApiToUse api;
+    bool dummy;
+    TFileName location;
+        
+    TUint actionMask = (EAction_PlayLocalFile | EAction_PlayUrl | EAction_SameAsMainPlayer );  
+
+    TUint apiMask = EApi_VideoPlayer;
+
+    SelectAction( actionMask, apiMask, false, action, api, dummy, location );
+
+    if( action == EAction_SameAsMainPlayer )
+        {
+        action = iMainPlayerAction;
+        api = iMainPlayerApi;
+        
+        if( action == EAction_PlayLocalFile )
+            {
+            location = iVideoPlayer->FullFilename();
+            }
+        else
+            {
+            location = iVideoPlayer->Url();            
+            }
+        }            
+    
+    if( location.Length() > 0 )
+        {
+        if( aPlayerWindow != NULL )
+            {
+            // Create player as another window within this process.
+            TRAP( err, (*aPlayerWindow) = PlayerWindowNewL( api,
+                                                            aTopLeft, 
+                                                            aSize, 
+                                                            true,  // transparent 
+                                                            KRgbTransparent,
+                                                            false ) );            
+            if( (*aPlayerWindow ) != NULL )
+                {
+                if( action == EAction_PlayLocalFile )
+                    {
+                    TRAP( err, (*aPlayerWindow)->StartWithFilenameL( location, CPlayerWindow::EBestFit) );            
+                    }
+                else
+                    {
+                    TRAP( err, (*aPlayerWindow)->StartWithUrlL( location, CPlayerWindow::EBestFit) );                        
+                    }
+    
+                if( err != KErrNone )
+                    {
+                    delete (*aPlayerWindow);
+                    aPlayerWindow = NULL;
+                    }
+                }
+            }
+        else
+            {
+            // Launch player within another process.
+            (*aExternalPlayer) = new CExternalPlayer( iWs );
+            
+            if( (*aExternalPlayer) == NULL )
+                {
+                err = KErrNoMemory;
+                }
+            else if( action == EAction_PlayLocalFile )
+                {            
+                err = (*aExternalPlayer)->Launch( aExternalPlayerExeName,
+                                                  *iWindowGroup,
+                                                  location,
+                                                  true,
+                                                  aTopLeft,
+                                                  aSize );
+                }
+            else
+                {
+                err = (*aExternalPlayer)->Launch( aExternalPlayerExeName,
+                                                  *iWindowGroup,
+                                                  location,
+                                                  false,
+                                                  aTopLeft,
+                                                  aSize );
+                }
+            }
+        
+        UpdateWindowOrdinalPositions();        
+        }
+    
+    if( resumePlayer1 )
+        {
+        iVideoPlayer->Play();
+        }
+    
+    if( resumePlayer2 )
+        {
+        iVideoPlayer2->Play();
+        }
+    
+    if( resumePlayer3 )
+        {
+        iVideoPlayer3->Play();
+        }
+
+    if( resumeExternalPlayer1 )
+        {
+        iExternalPlayer->ExecuteOperation( EOperation_Resume );
+        }
+    
+    if( resumeExternalPlayer2 )
+        {
+        iExternalPlayer2->ExecuteOperation( EOperation_Resume );
+        }
+    
+    return err;
+    }
+
+TInt CConsolePlayer::ExecuteOperation( TInt aOperation )
+    {
+    SendOperationToAllPlayers( aOperation );
+    return KErrNone;
+    }
+
+void CConsolePlayer::MoveWindow( TPoint /*aNewCenter*/ )    
+    {
+    // Not used.
+    }
+
+void CConsolePlayer::SetOrdinalPosition( TInt /*aPosition*/ )
+    {
+    // Not used.
+    }
+
+void CConsolePlayer::SendOperationToAllPlayers( TInt aOperation )
+    {
+    iVideoPlayer->ExecuteOperation(aOperation);            
+    if( iVideoPlayer2 )
+        {
+        iVideoPlayer2->ExecuteOperation(aOperation);            
+        }            
+    if( iVideoPlayer3 )
+        {
+        iVideoPlayer3->ExecuteOperation(aOperation);            
+        }            
+    if( iExternalPlayer )
+        {
+        iExternalPlayer->ExecuteOperation(aOperation);            
+        }            
+    if( iExternalPlayer2 )
+        {
+        iExternalPlayer2->ExecuteOperation(aOperation);            
+        }
+    }
+
+void CConsolePlayer::ExecuteOperation( TInt aOperation, const TDesC& aOperationText )
+    {
+    iSelectedOptionText.Copy( aOperationText );                    
+    iSelectedOptionTextCounter = 2;
+
+    RDebug::Printf( "CONSOLE PLAYER executing operation:" );
+    RDebug::RawPrint( iSelectedOptionText );
+
+    if( iPlayerBeingDragged != NULL )
+        {
+        DisableDragging();
+        }
+    
+    iLastError = KErrNone;
+    
+    switch( aOperation )
+        {
+        case EOperation_ChangeDisplayMode:
+            {                
+            // Change video window text mode.
+            iVideoWindowTextMode = (iVideoWindowTextMode+1) % 3;                    
+            break;
+            }
+        case EOperation_ToggleSecondVideo:
+            {
+            if( iVideoPlayer2 )
+                {
+                delete iVideoPlayer2;
+                iVideoPlayer2 = NULL;
+                iActivePlayer = NULL;
+                }
+            else
+                {
+                iLastError = CreateAnotherPlayer(&iVideoPlayer2,
+                                                 NULL,
+                                                 KNullDesC,
+                                                 TSize(iDisplaySize.iWidth/2, iDisplaySize.iHeight/2), 
+                                                 TPoint(0,iDisplaySize.iHeight/2));
+                
+                iActivePlayer = iVideoPlayer2;
+                EnableDragging();
+                }
+            break;
+            }            
+        case EOperation_ToggleThirdVideo:
+            {
+            if( iVideoPlayer3 )
+                {
+                delete iVideoPlayer3;
+                iVideoPlayer3 = NULL;
+                iActivePlayer = NULL;
+                }
+            else
+                {
+                iLastError = CreateAnotherPlayer(&iVideoPlayer3,
+                                                 NULL,
+                                                 KNullDesC,
+                                                 TSize(iDisplaySize.iWidth/3,iDisplaySize.iHeight/3), 
+                                                 TPoint(0,2*iDisplaySize.iHeight/3));
+
+                iActivePlayer = iVideoPlayer3;
+                EnableDragging();
+                }
+            break;
+            }
+        case EOperation_DragWindow:
+            {
+            EnableDragging();
+            iSelectedOptionTextCounter = 1000;
+            break;
+            }
+        case EOperation_ToggleOrdinalPositions:
+            {
+            iOrdinalIndex = (iOrdinalIndex+1) % KOrdinalPositionConfigurationCount;
+            UpdateWindowOrdinalPositions();
+            
+            iSelectedOptionTextCounter = 6;
+            iSelectedOptionText.Format(_L("Ordinals: %i %i %i %i %i"), 
+                    KOrdinalPositions[iOrdinalIndex][0] + 1,
+                    KOrdinalPositions[iOrdinalIndex][1] + 1,
+                    KOrdinalPositions[iOrdinalIndex][2] + 1,
+                    KOrdinalPositions[iOrdinalIndex][3] + 1,
+                    KOrdinalPositions[iOrdinalIndex][4] + 1 );
+            break;
+            }
+        case EOperation_AbnormalTermination:
+            {
+            User::Panic( _L("Abnormal termination"), 123 );
+            break;            
+            }
+        case EOperation_ToggleExternalPlayer:
+            {
+            if( iExternalPlayer )
+                {
+                delete iExternalPlayer;
+                iExternalPlayer = NULL;
+                iActivePlayer = NULL;
+                }
+            else
+                {
+                iLastError = CreateAnotherPlayer(NULL,
+                                                 &iExternalPlayer,
+                                                 KExternalPlayerExe,
+                                                 TSize(iDisplaySize.iWidth/2, iDisplaySize.iHeight/2),
+                                                 TPoint(iDisplaySize.iWidth/2, 0));
+                iActivePlayer = iExternalPlayer;
+                EnableDragging();
+                }            
+            break;
+            }
+        case EOperation_ToggleExternalPlayer2:
+            {
+            if( iExternalPlayer2 )
+                {
+                delete iExternalPlayer2;
+                iExternalPlayer2 = NULL;
+                iActivePlayer = NULL;
+                }
+            else
+                {
+                iLastError = CreateAnotherPlayer(NULL,
+                                                 &iExternalPlayer2,
+                                                 KExternalPlayerExe2,
+                                                 TSize(iDisplaySize.iWidth/2, iDisplaySize.iHeight/2),
+                                                 TPoint(iDisplaySize.iWidth/2, iDisplaySize.iHeight/2));            
+                iActivePlayer = iExternalPlayer2;
+                EnableDragging();
+                }
+            break;
+            }            
+        case EOperation_LaunchAllWindows:
+            {
+            if( iVideoPlayer->FullFilename().Length() > 0 )
+                {
+                if( iVideoPlayer2 == NULL )
+                    {
+                    iVideoPlayer2 = PlayerWindowNewL( iMainPlayerApi,
+                                                      TPoint(0,iDisplaySize.iHeight/2), 
+                                                      TSize(iDisplaySize.iWidth/2, iDisplaySize.iHeight/2), 
+                                                      true,  // transparent 
+                                                      KRgbTransparent,
+                                                      false );
+                
+                    iVideoPlayer2->StartWithFilenameL( iVideoPlayer->FullFilename(), CPlayerWindow::EBestFit);
+                    }
+
+                if( iVideoPlayer3 == NULL )
+                    {
+                    iVideoPlayer3 = PlayerWindowNewL( iMainPlayerApi,
+                                                      TPoint(0,2*iDisplaySize.iHeight/3),
+                                                      TSize(iDisplaySize.iWidth/3,iDisplaySize.iHeight/3), 
+                                                      true,  // transparent 
+                                                      KRgbTransparent,
+                                                      false );
+                
+                    iVideoPlayer3->StartWithFilenameL( iVideoPlayer->FullFilename(), CPlayerWindow::EBestFit);
+                    }
+            
+                if( iExternalPlayer == NULL )
+                    {
+                    iExternalPlayer = new CExternalPlayer( iWs );
+                
+                    iExternalPlayer->Launch( KExternalPlayerExe,
+                                             *iWindowGroup,
+                                             iVideoPlayer->FullFilename(),
+                                             true,
+                                             TPoint(iDisplaySize.iWidth/2, 0),
+                                             TSize(iDisplaySize.iWidth/2, iDisplaySize.iHeight/2) );
+                    }
+                            
+                /* TODO: FIGURE OUT HOW TO LAUNCH TWO EXTERNAL WINDOWS
+                if( iExternalPlayer2 == NULL )
+                    {
+                    iExternalPlayer2 = new CExternalPlayer();
+                
+                    iExternalPlayer2->Launch( KExternalPlayerExe2,
+                                              *iWindowGroup,
+                                              iVideoPlayer->FullFilename(),
+                                              true,
+                                              TPoint(iDisplaySize.iWidth/2, iDisplaySize.iHeight/2),
+                                              TSize(iDisplaySize.iWidth/2, iDisplaySize.iHeight/2) );
+                                              
+                    }                         
+                */  
+                
+                UpdateWindowOrdinalPositions();
+                
+                DrawBorderAroundActiveWindows();
+                }
+            break;
+            }            
+        case EOperation_ObscureWindow:
+            {
+            iObscured = !iObscured;
+            iFullScreenWindow->SetVisible( iObscured );            
+            break;
+            }
+        default:
+            {
+            // Route the operation to the appropriate player window.
+            MPlayerCommands* player = CurrentPlayer();
+            if( player )
+                {
+                iLastError = player->ExecuteOperation( aOperation );
+                }
+            else
+                {
+                // Do not show the operation text.
+                iSelectedOptionText.SetLength(0);
+                }
+            break;
+            }
+        }
+
+    UpdateVideoWindow();
+    
+    if( iLastError != KErrNone )
+        {
+        RDebug::Printf( "CONSOLEPLAYER error=%i", iLastError );            
+        }        
+    }
+
+void CConsolePlayer::HandlePointerEvent( const TAdvancedPointerEvent& aEvent )
+    {    
+    TTestAppPointerEvent pointerEvent = CharacterizePointerEvent( aEvent );
+
+    if( pointerEvent == EPointerEvent_Select )
+        {
+        DisableDragging();
+        iSelectedOptionText.Copy( _L("Drag disabled") );
+        iSelectedOptionTextCounter = 3;
+        UpdateVideoWindow();        
+        }
+    else         
+        {
+        MPlayerCommands* player = CurrentPlayer();
+        if( player )
+            {        
+            player->MoveWindow( aEvent.iParentPosition );
+            }
+        
+        UpdateVideoWindow();        
+        }    
+    }
+
+void CConsolePlayer::PlayInitiated()
+    {
+    RDebug::Printf( "CONSOLEPLAYER PlayInitiated" );
+   
+    UpdateWindowOrdinalPositions();
+    
+    if( iTimerCallback )
+        {
+        iTimerCallback->Start( 1000000 );  // 1 second
+        }
+
+    // Display this text at startup.
+    iSelectedOptionText.Copy( _L("Press '0' during playback for help") );
+    iSelectedOptionTextCounter = 5;
+
+    StartMonitoringWindowEvents();
+    }
+
+void CConsolePlayer::PlayStateChanged()
+    {
+    UpdateVideoWindow();
+    }
+
+void CConsolePlayer::Error(TInt aError)
+    {
+    RDebug::Printf( "CONSOLEPLAYER error=%i", aError );
+    CActiveScheduler::Stop();
+    
+    iFinalResult = aError;
+    }
+
+void CConsolePlayer::TimerCallback()
+    {
+    if( iSelectedOptionText.Length() > 0 )
+        {
+        iSelectedOptionTextCounter--;
+        
+        if( iSelectedOptionTextCounter == 0 )
+            {
+            iSelectedOptionText.SetLength(0);
+            }
+        }
+    
+    if( iVideoWindowTextMode > 0 )
+        {
+        UpdateVideoWindow();
+        }
+    }
+
+GLDEF_C TInt E32Main()
+    {
+    __UHEAP_MARK;
+    
+    CActiveScheduler* scheduler = new CActiveScheduler;
+    CTrapCleanup* cleanup = CTrapCleanup::New();
+    if( scheduler != NULL && cleanup != NULL )
+    {
+        CActiveScheduler::Install( scheduler );
+        TRAP_IGNORE( CConsolePlayer::ExecuteL() );
+    }
+    delete cleanup;
+    delete scheduler;
+    REComSession::FinalClose();
+    __UHEAP_MARKEND;
+    return 0;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/consoleplayer/player/src/externalplayer.cpp	Fri Sep 03 19:37:02 2010 -0500
@@ -0,0 +1,224 @@
+/*
+ * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ * Source file for the main class of the external player executable.
+ * 
+ */
+
+#include "externalplayer.h"
+#include "mmfplayerwindow.h"
+#include "testappbase.h"
+
+// This is the implementation for the external player executable.
+
+class CExternalPlayerExe : public CActive
+    {
+public:
+    
+    static void ExecuteL()
+        {
+        CExternalPlayerExe* self = new(ELeave) CExternalPlayerExe;
+        CleanupStack::PushL( self );
+        self->MainL();
+        CleanupStack::PopAndDestroy( self );    
+        }
+    
+private:
+    
+    CExternalPlayerExe() : CActive( EPriorityStandard )
+        {
+        CActiveScheduler::Add( this );
+        }
+    
+    ~CExternalPlayerExe()
+        {
+        Cancel();
+        iMsgQueue.Close();
+        iChunk.Close();
+        delete iVideoPlayer;
+        delete iWindowGroup;
+        delete iScreenDevice;
+        iWs.Close();
+        iFs.Close();
+        }
+    
+    void MainL()
+        {
+        TInt err = KErrNone;
+                
+        User::LeaveIfError( iFs.Connect() );        
+        
+        User::LeaveIfError( iWs.Connect() );    
+        
+        iScreenDevice = new(ELeave) CWsScreenDevice( iWs );
+        User::LeaveIfError( iScreenDevice->Construct() );
+
+        TBuf<200> commandLine;
+        User::CommandLine( commandLine );
+
+        TInt startIndex = commandLine.Find(KMsgQueuePrefix);
+        
+        if( startIndex < 0 )
+            {
+            err = startIndex;
+            }
+        else
+            {
+            TPtrC msgQueueName = commandLine.Right( commandLine.Length() - startIndex - KMsgQueuePrefix().Length());
+            err = iMsgQueue.CreateGlobal( msgQueueName, 3 );
+
+            if( err == KErrNone )
+                {
+                TBuf<80> chunkName;
+                chunkName.Copy( msgQueueName );
+                chunkName.Append( _L("_chunk") );
+                err = iChunk.CreateGlobal( chunkName, 2048, 2048 );  // 2K chunk        
+                }            
+            }
+        
+        RProcess::Rendezvous( err );
+        
+        if( err == KErrNone )
+            {
+            SetActive();
+            iMsgQueue.NotifyDataAvailable( iStatus );
+        
+            CActiveScheduler::Start();
+            }
+        }
+    
+    // inherited from CActive
+    
+    void RunL()
+        {        
+        if( iStatus == KErrNone )
+            {
+            TInt err = KErrNone;
+        
+            TExternalPlayerCommands msg;
+            iMsgQueue.Receive( msg );
+            
+            RDebug::Printf( "EXTERNALPLAYER RunL() msg=%i", msg );
+    
+            switch( msg )
+                {
+                case EExternalPlayer_StartPlayback:
+                    {
+                    TStartPlayback* chunk = (TStartPlayback*)iChunk.Base();
+                    
+                    TPtrC8 filename( chunk->name, chunk->length );
+                    iLocation.Copy( filename ); 
+                    iLocationIsFilename = chunk->locationIsFilename;
+                    
+                    iWindowTopRight.iX  = chunk->x;
+                    iWindowTopRight.iY  = chunk->y;
+                    iWindowSize.iWidth  = chunk->width;
+                    iWindowSize.iHeight = chunk->height;
+                    
+                    iWindowGroup = new RWindowGroup( iWs );
+                    err = iWindowGroup->ConstructChildApp( chunk->idOfParentWindowGroup,  
+                                                           KNullWsHandle, 
+                                                           false );
+                    ASSERT( err == KErrNone );   
+                    
+                    TStartPlaybackReturn* chunkReturn = (TStartPlaybackReturn*)iChunk.Base();
+                    
+                    chunkReturn->windowGroupId = iWindowGroup->Identifier();
+                    
+                    iVideoPlayer = CMmfPlayerWindow::NewL( iFs, 
+                                                           iWs, 
+                                                           *iScreenDevice, 
+                                                           *iWindowGroup,
+                                                           iWindowTopRight,
+                                                           iWindowSize,
+                                                           true,  // transparent
+                                                           KRgbTransparent,
+                                                           true );
+                    
+                    if( iLocationIsFilename )
+                        {
+                        iVideoPlayer->StartWithFilenameL( iLocation, CPlayerWindow::EBestFit);
+                        }
+                    else
+                        {
+                        iVideoPlayer->StartWithUrlL( iLocation, CPlayerWindow::EBestFit);                
+                        }
+                    
+                    RDebug::Printf( "EXTERNALPLAYER player started" );
+                    break;
+                    }
+                case EExternalPlayer_ExecuteOperation:
+                    {
+                    TExecuteOperation* chunk = (TExecuteOperation*)iChunk.Base();
+                    err = iVideoPlayer->ExecuteOperation(chunk->operation );
+                    break;
+                    }
+                case EExternalPlayer_MoveWindow:
+                    {
+                    TMoveWindow* chunk = (TMoveWindow*)iChunk.Base();
+                    iVideoPlayer->MoveWindow( TPoint(chunk->centerX, chunk->centerY) );
+                    break;
+                    }
+                case EExternalPlayer_Shutdown:
+                    {
+                    RDebug::Printf( "EXTERNALPLAYER player stopped" );
+                    
+                    CActiveScheduler::Stop();
+                    break;
+                    }
+                }
+            
+            RProcess::Rendezvous( err );
+            
+            SetActive();
+            iMsgQueue.NotifyDataAvailable( iStatus );
+            }
+        }
+    
+    void DoCancel()
+        {
+        iMsgQueue.CancelDataAvailable();
+        }    
+    
+    RFs                                iFs;
+    RWsSession                         iWs;
+    CWsScreenDevice*                   iScreenDevice; 
+    RWindowGroup*                      iWindowGroup;
+    CPlayerWindow*                     iVideoPlayer;
+    RMsgQueue<TExternalPlayerCommands> iMsgQueue;
+    RChunk                             iChunk;
+    TFileName                          iLocation;
+    bool                               iLocationIsFilename;
+    TPoint                             iWindowTopRight;
+    TSize                              iWindowSize;
+    
+    };
+
+GLDEF_C TInt E32Main()
+    {
+    __UHEAP_MARK;
+    
+    CActiveScheduler* scheduler = new CActiveScheduler;
+    CTrapCleanup* cleanup = CTrapCleanup::New();
+    if( scheduler != NULL && cleanup != NULL )
+    {
+        CActiveScheduler::Install( scheduler );
+        TRAP_IGNORE( CExternalPlayerExe::ExecuteL() );
+    }
+    delete cleanup;
+    delete scheduler;
+    __UHEAP_MARKEND;
+    return 0;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/consoleplayer/player/src/mmf/mmfplayerwindow.cpp	Fri Sep 03 19:37:02 2010 -0500
@@ -0,0 +1,507 @@
+/*
+ * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ * Source file for the MMF Player Window.
+ * 
+ */
+
+#include "mmfplayerwindow.h"
+
+bool IgnoreError( TInt aError )
+    {
+    bool ignore = false;
+    // Some errors should be ignored.
+    
+    if( aError == -12017 )  
+        {
+        // partial playback - do not treat as an error
+        ignore = true;
+        RDebug::Printf( "CONSOLEPLAYER partial playback" );            
+        }
+    
+    return ignore;
+    }
+
+CMmfPlayerWindow* CMmfPlayerWindow::NewL( RFs& aFs, 
+                                          RWsSession& aWs,
+                                          CWsScreenDevice& aScreenDevice,
+                                          const RWindowTreeNode &aParentWindow,
+                                          TPoint aTopRight,
+                                          TSize aSize,
+                                          bool aTransparent,
+                                          TRgb aBackgroundColor,
+                                          bool aSuppressGraphicsContext,
+                                          TUint32 aControllerUid )
+    {
+    CMmfPlayerWindow* self = new(ELeave) CMmfPlayerWindow( aFs, aWs, aScreenDevice, aSuppressGraphicsContext, aControllerUid );
+    CleanupStack::PushL( self );
+    self->ConstructL( aParentWindow, aTopRight, aSize, aTransparent, aBackgroundColor );
+    CleanupStack::Pop();
+    return self;   
+    }
+    
+CMmfPlayerWindow::CMmfPlayerWindow( RFs& aFs, RWsSession& aWs, CWsScreenDevice& aScreenDevice, bool aSuppressGraphicsContext, TUint32 aControllerUid ) :
+    CPlayerWindow( aFs, aWs, aScreenDevice, aSuppressGraphicsContext ),
+    iControllerUid( aControllerUid )
+    {    
+    }
+
+CMmfPlayerWindow::~CMmfPlayerWindow()
+    {    
+    delete iVideoPlayer;
+    }
+
+void CMmfPlayerWindow::ConstructL( const RWindowTreeNode &aParentWindow, TPoint aTopRight, TSize aSize, bool aTransparent, TRgb aBackgroundColor )
+    {
+    BaseConstructL( aParentWindow, aTopRight, aSize, aTransparent, aBackgroundColor );
+
+#ifdef __USE_VIDEOPLAYER_1__
+    iVideoPlayer = CVideoPlayerUtility::NewL(*this,
+                                             EMdaPriorityNormal,
+                                             EMdaPriorityPreferenceTimeAndQuality,
+                                             iWs,
+                                             iScreenDevice,
+                                             iWindow,
+                                             TRect(iScreenDevice.SizeInPixels()),
+                                             TRect(iScreenDevice.SizeInPixels()));
+#else
+    iVideoPlayer = CVideoPlayerUtility2::NewL(*this,EMdaPriorityNormal,EMdaPriorityPreferenceTimeAndQuality);
+#endif
+    }
+
+
+void CMmfPlayerWindow::InitializeParameters( TSize& aVideoSize, 
+                                             TTimeIntervalMicroSeconds& aDuration, 
+                                             TInt& aMaxVolume, 
+                                             TInt& aCurrentVolume,
+                                             TInt& aBalanceCenter,
+                                             TInt& aBalanceMaxLeft,
+                                             TInt& aBalanceMaxRight,
+                                             TInt& aDefaultBalance, 
+                                             TInt& aCurrentBalance )
+    {
+    TRAPD( err, iVideoPlayer->VideoFrameSizeL(aVideoSize) );
+    CheckError( err, "VideoFrameSizeL" );
+    TRAP( err, aDuration = iVideoPlayer->DurationL() );
+    CheckError( err, "DurationL" );
+    aMaxVolume = iVideoPlayer->MaxVolume();
+    aCurrentVolume = iVideoPlayer->Volume();
+    aBalanceCenter = KMMFBalanceCenter;
+    aBalanceMaxLeft = KMMFBalanceMaxLeft;
+    aBalanceMaxRight = KMMFBalanceMaxRight;
+    aDefaultBalance = iVideoPlayer->Balance();
+    aCurrentBalance = aDefaultBalance;
+    }
+
+void CMmfPlayerWindow::SetDefaultAutoscaleMode( TAutoscaleMode aDefaultAutoscale )
+    {
+    switch( aDefaultAutoscale )
+        {
+        case EDoNotAutoscale:
+            iAutoScale = EAutoScaleNone;
+            break;
+        case EBestFit:
+            iAutoScale = EAutoScaleBestFit;
+            break;
+        case EStretch:
+            iAutoScale = EAutoScaleStretch;
+            break;
+        }
+    iDefaultAutoScale = iAutoScale;
+#ifdef __USE_VIDEOPLAYER_1__
+    TRAPD(err, iVideoPlayer->SetAutoScaleL(iAutoScale));
+#else
+    TRAPD(err, iVideoPlayer->SetAutoScaleL(iWindow, iAutoScale));
+#endif
+    if( err == KErrNotReady )
+        {
+        // Too soon to call this.  Will get called later, at the appropriate time.
+        }
+    else
+        {
+        CheckError( err, "SetDefaultAutoscaleMode" );
+        }
+    }    
+
+void CMmfPlayerWindow::PreparePlayerWithFile( RFile& aFile )
+    {
+    const TUid KUidController = { iControllerUid };
+    TRAPD( err, iVideoPlayer->OpenFileL(aFile, KUidController) );
+    CheckError( err, "OpenFileL" );
+    
+    // Now wait for MvpuoOpenComplete callback.            
+    }
+
+void CMmfPlayerWindow::PreparePlayerWithUrl( const TDesC& aUrl )
+    {
+    TRAPD( err, iVideoPlayer->OpenUrlL(aUrl) );
+    CheckError( err, "OpenUrlL" );
+
+    // Now wait for MvpuoOpenComplete callback.                
+    }
+
+TInt CMmfPlayerWindow::DoExecuteOperation( TInt /*aOperation*/ )
+    {
+    // Currently there are no MMF-specific commands.
+    return KErrNotSupported;
+    }
+
+TTimeIntervalMicroSeconds CMmfPlayerWindow::Position()
+    {
+    TTimeIntervalMicroSeconds position = 0;
+    TRAPD( err, position = iVideoPlayer->PositionL() );
+    CheckError( err, "PositionL" );
+    return position;
+    }
+
+TInt CMmfPlayerWindow::SetVolume( TInt aVolume )
+    {
+    TRAPD( err, iVideoPlayer->SetVolumeL( aVolume ) );
+    if( err != KErrNone )
+        {
+        RDebug::Printf( "CONSOLEPLAYER SetVolumeL %i err=%i", aVolume, err );
+        }
+    return err;
+    }
+
+TInt CMmfPlayerWindow::SetBalance( TInt aBalance )
+    {
+    TRAPD( err, iVideoPlayer->SetBalanceL( aBalance ) );
+    if( err != KErrNone )
+        {
+        RDebug::Printf( "CONSOLEPLAYER SetBalanceL %i err=%i", aBalance, err );
+        }
+    return err;    
+    }
+
+TInt CMmfPlayerWindow::RotationAngle()
+    {
+    switch( iRotation )
+        {
+        case EVideoRotationClockwise90:
+            return 90;
+        case EVideoRotationClockwise180:
+            return 180;
+        case EVideoRotationClockwise270:
+            return 270;
+        default:
+            return 0;
+        }        
+    }
+
+TInt CMmfPlayerWindow::NextRotationAngle()
+    {
+    switch( iRotation )
+        {
+        case EVideoRotationNone:
+            iRotation = EVideoRotationClockwise90;
+            break;
+        case EVideoRotationClockwise90:
+            iRotation = EVideoRotationClockwise180;
+            break;
+        case EVideoRotationClockwise180:
+            iRotation = EVideoRotationClockwise270;
+            break;
+        case EVideoRotationClockwise270:
+            iRotation = EVideoRotationNone;
+            break;
+        }
+#ifdef __USE_VIDEOPLAYER_1__
+    TRAPD( err, iVideoPlayer->SetRotationL(iRotation) );
+#else
+    TRAPD( err, iVideoPlayer->SetRotationL(iWindow, iRotation) );
+#endif
+    if( err != KErrNone )
+        {
+        RDebug::Printf( "CONSOLEPLAYER SetRotationL(%i) err=%i", iRotation, err );
+        }    
+    return err;
+    }
+
+TInt CMmfPlayerWindow::ResetRotation()
+    {
+    iRotation = EVideoRotationNone;
+#ifdef __USE_VIDEOPLAYER_1__
+    TRAPD( err, iVideoPlayer->SetRotationL(iRotation) );
+#else
+    TRAPD( err, iVideoPlayer->SetRotationL(iWindow, iRotation) );
+#endif
+    if( err != KErrNone )
+        {
+        RDebug::Printf( "CONSOLEPLAYER SetRotationL(reset) err=%i", err );
+        }        
+    return err;
+    }
+
+TInt CMmfPlayerWindow::NextAutoscaleMode()
+    {
+    switch( iAutoScale )
+        {
+        case EAutoScaleNone:
+            iAutoScale = EAutoScaleBestFit;
+            break;
+        case EAutoScaleBestFit:
+            iAutoScale = EAutoScaleClip;
+            break;
+        case EAutoScaleClip:
+            iAutoScale = EAutoScaleStretch;
+            break;
+        case EAutoScaleStretch:
+            iAutoScale = EAutoScaleNone;
+            break;
+        }     
+#ifdef __USE_VIDEOPLAYER_1__
+    TRAPD( err, iVideoPlayer->SetAutoScaleL(iAutoScale) );
+#else
+    TRAPD( err, iVideoPlayer->SetAutoScaleL(iWindow, iAutoScale) );
+#endif
+    if( err != KErrNone )
+        {
+        RDebug::Printf( "CONSOLEPLAYER SetAutoScaleL(%i) err=%i", iAutoScale, err );
+        }    
+    return err;
+    }
+
+TInt CMmfPlayerWindow::ResetAutoscale()
+    {
+    iAutoScale = iDefaultAutoScale;
+#ifdef __USE_VIDEOPLAYER_1__
+    TRAPD( err, iVideoPlayer->SetAutoScaleL(iAutoScale) );
+#else
+    TRAPD( err, iVideoPlayer->SetAutoScaleL(iWindow, iAutoScale) );
+#endif
+    if( err != KErrNone )
+        {
+        RDebug::Printf( "CONSOLEPLAYER SetAutoScaleL(%i) err=%i", iAutoScale, err );
+        }    
+    return err;
+    }
+
+void CMmfPlayerWindow::AppendAutoscaleModeText( TDes& aString )
+    {
+    switch( iAutoScale )
+        {
+        case EAutoScaleNone:
+            aString.Append(_L("None"));
+            break;
+        case EAutoScaleBestFit:
+            aString.Append(_L("Best Fit"));
+            break;
+        case EAutoScaleClip:
+            aString.Append(_L("Clip"));
+            break;
+        case EAutoScaleStretch:
+            aString.Append(_L("Stretch"));
+            break;
+        } 
+    }
+
+TInt CMmfPlayerWindow::SetClipRectangle( TRect aRect )
+    {
+#ifdef __USE_VIDEOPLAYER_1__   
+    TRAPD( err, iVideoPlayer->SetCropRegionL(aRect) );
+    if( err != KErrNone )
+        {
+        RDebug::Printf( "CONSOLEPLAYER SetCropRegionL err=%i", err );
+        }    
+#else
+    TRAPD( err, iVideoPlayer->SetWindowClipRectL(iWindow, aRect) );
+    if( err != KErrNone )
+        {
+        RDebug::Printf( "CONSOLEPLAYER SetCropRegionL err=%i", err );
+        }    
+#endif
+    return err;
+    }
+
+TInt CMmfPlayerWindow::SetVideoExtent( TRect aExtent )
+    {
+#ifdef __USE_VIDEOPLAYER_1__
+    // TODO: HOW DO YOU DO THIS WITH OLD VIDEO PLAYER?
+    TInt err = KErrNotSupported;
+    RDebug::Printf( "CONSOLEPLAYER SetVideoExtent not supported with video player 1" );
+#else
+    TRAPD( err, iVideoPlayer->SetVideoExtentL(iWindow, aExtent) );
+    if( err != KErrNone )
+        {
+        RDebug::Printf( "CONSOLEPLAYER SetVideoExtentL err=%i", err );
+        }    
+#endif
+    return err;
+    }
+
+TInt CMmfPlayerWindow::SetScaleFactor( TReal aWidthScaleFactor, TReal aHeightScaleFactor )
+    {
+#ifdef __USE_VIDEOPLAYER_1__
+    // TODO: WHAT VALUE SHOULD BE USED FOR aAntiAliasFiltering?    
+    TRAPD( err, iVideoPlayer->SetScaleFactorL(aWidthScaleFactor, aHeightScaleFactor, ETrue) );
+#else
+    TRAPD( err, iVideoPlayer->SetScaleFactorL(iWindow, aWidthScaleFactor, aHeightScaleFactor) );
+#endif
+    if( err != KErrNone )
+        {
+        RDebug::Printf( "CONSOLEPLAYER SetScaleFactorL err=%i", err );
+        }    
+    return err;
+    }
+
+TInt CMmfPlayerWindow::Play()
+    {
+    iVideoPlayer->Play();
+    return KErrNone;
+    }
+
+TInt CMmfPlayerWindow::Pause()
+    {
+    TRAPD(err, iVideoPlayer->PauseL());
+    if( err != KErrNone )
+        {
+        RDebug::Printf( "CONSOLEPLAYER PauseL err=%i", err );
+        }        
+    return err;
+    }
+
+TInt CMmfPlayerWindow::Stop()
+    {
+    TInt err = iVideoPlayer->Stop();
+    if( err != KErrNone )
+        {
+        RDebug::Printf( "CONSOLEPLAYER Stop err=%i", err );
+        }        
+    return err;
+    }
+
+TInt CMmfPlayerWindow::SetPosition( TTimeIntervalMicroSeconds aPositionInMs )
+    {
+    TRAPD( err, iVideoPlayer->SetPositionL( aPositionInMs ) );
+    if( err != KErrNone )
+        {
+        RDebug::Printf( "CONSOLEPLAYER SetPositionL err=%i", err );
+        }        
+    return err;
+    }
+
+TInt CMmfPlayerWindow::StepForward()
+    {
+    TRAPD( err, iVideoPlayer->StepFrameL(1) );
+    if( err != KErrNone )
+        {
+        RDebug::Printf( "CONSOLEPLAYER StepFrameL(1) err=%i", err );
+        }            
+    return err;    
+    }
+
+TInt CMmfPlayerWindow::StepBackward()
+    {
+    TRAPD( err, iVideoPlayer->StepFrameL(-1) );
+    if( err != KErrNone )
+        {
+        RDebug::Printf( "CONSOLEPLAYER StepFrameL(-1) err=%i", err );
+        }            
+    return err;   
+    }
+
+TInt CMmfPlayerWindow::SetPlayVelocity( TInt aVelocity )
+    {
+    TRAPD( err,iVideoPlayer->SetPlayVelocityL(aVelocity) );
+    if( err != KErrNone )
+        {
+        RDebug::Printf( "CONSOLEPLAYER SetPlayVelocityL %i err=%i", aVelocity, err );
+        }            
+    return err;
+    }
+    
+// inherited from MVideoPlayerUtilityObserver
+
+void CMmfPlayerWindow::MvpuoOpenComplete(TInt aError)
+    {
+    RDebug::Printf( "CONSOLEPLAYER MvpuoOpenComplete(%i)", aError );
+    
+    if( aError == KErrNone )
+        {
+        iVideoPlayer->Prepare();
+    
+        // Now wait for MvpuoPrepareComplete callback.
+        }
+    else if( !IgnoreError( aError ) )
+        {
+        CheckError( aError, "MvpuOpenComplete" );
+        }
+    }
+
+void CMmfPlayerWindow::MvpuoPrepareComplete(TInt aError)
+    {
+    RDebug::Printf( "CONSOLEPLAYER MvpuoPrepareComplete(%i)", aError );
+    
+    if( aError == KErrNone )
+        {
+#ifdef __USE_VIDEOPLAYER_1__   
+        TRAPD( err, iVideoPlayer->SetDisplayWindowL( iWs, 
+                                                     iScreenDevice, 
+                                                     iWindow, 
+                                                     TRect(iWindow.Position(), iWindow.Size()),
+                                                     TRect(iWindow.Position(), iWindow.Size())) );
+#else
+        TRAPD( err, iVideoPlayer->AddDisplayWindowL( iWs, iScreenDevice, iWindow ) );
+#endif
+        if( err == KErrNone )
+            {
+            Play();
+            ResetAutoscale();
+            }
+        else
+            {
+            RDebug::Printf("CONSOLEPLAYER AddDisplayWindowL failed, err=%i", err );
+            }
+        PlayInitiated();
+        }
+    else if( !IgnoreError( aError ) )
+        {
+        Error( aError );
+        }
+    }
+
+void CMmfPlayerWindow::MvpuoFrameReady(CFbsBitmap& /*aFrame*/,TInt aError)
+    {
+    RDebug::Printf( "CONSOLEPLAYER MvpuoFrameReady(%i)", aError );
+    
+    if( (aError != KErrNone) && !IgnoreError( aError ) )
+        {
+        Error( aError );
+        }
+    }
+
+void CMmfPlayerWindow::MvpuoPlayComplete(TInt aError)
+    {
+    RDebug::Printf( "CONSOLEPLAYER MvpuoPlayComplete(%i)", aError );
+    
+    if( aError == KErrNone )
+        {
+        PlayComplete();
+        }
+    else if( !IgnoreError( aError ) )
+        {
+        Error( aError );
+        }
+    }
+
+void CMmfPlayerWindow::MvpuoEvent(const TMMFEvent& aEvent)
+    {   
+    RDebug::Printf( "CONSOLEPLAYER MvpuoEvent event=%x error=%i", aEvent.iEventType.iUid, aEvent.iErrorCode );    
+
+    if( aEvent.iErrorCode != KErrNone && !IgnoreError( aEvent.iErrorCode ) )
+        {
+        Error( aEvent.iErrorCode );
+        }
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/consoleplayer/player/src/mmf/mmfplayerwindow.h	Fri Sep 03 19:37:02 2010 -0500
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ * Header file specifing the interface for the MMF Player Window.
+ * 
+ */
+
+#ifndef __MMF_PLAYER_WINDOW_H__
+#define __MMF_PLAYER_WINDOW_H__
+
+#include <e32base.h>
+
+#ifdef __USE_VIDEOPLAYER_1__
+#include <videoplayer.h>
+#else
+#include <videoplayer2.h>
+#endif
+
+#include "playerwindow.h" 
+
+const TUint32 KUidVideoController = { 0x101f8514 };
+
+class CMmfPlayerWindow : public CPlayerWindow,
+                         private MVideoPlayerUtilityObserver
+    {
+public:
+
+    static CMmfPlayerWindow* NewL( RFs& aFs, 
+                                   RWsSession& aWs,
+                                   CWsScreenDevice& aScreenDevice,
+                                   const RWindowTreeNode &aParentWindow,
+                                   TPoint aTopRight,
+                                   TSize aSize,
+                                   bool aTransparent,
+                                   TRgb aBackgroundColor,
+                                   bool aSuppressGraphicsContext,
+                                   TUint32 aControllerUid = KUidVideoController );
+    
+    virtual ~CMmfPlayerWindow();
+
+    // inherited from CPlayerWindow
+    virtual TTimeIntervalMicroSeconds Position();
+    virtual TInt SetVolume( TInt aVolume );
+    virtual TInt SetBalance( TInt aBalance );
+    virtual TInt RotationAngle();
+    virtual TInt NextRotationAngle();
+    virtual TInt ResetRotation();
+    virtual TInt NextAutoscaleMode();
+    virtual TInt ResetAutoscale();
+    virtual void AppendAutoscaleModeText( TDes& aString );
+    virtual TInt SetClipRectangle( TRect aRect );
+    virtual TInt SetVideoExtent( TRect aExtent );
+    virtual TInt SetScaleFactor( TReal aWidthScaleFactor, TReal aHeightScaleFactor );
+    virtual TInt Play();
+    virtual TInt Pause();
+    virtual TInt Stop();
+    virtual TInt SetPosition( TTimeIntervalMicroSeconds aPositionInMs );
+    virtual TInt StepForward();
+    virtual TInt StepBackward();
+    virtual TInt SetPlayVelocity( TInt aVelocity );
+    virtual TInt DoExecuteOperation( TInt aOperation );
+    virtual void InitializeParameters( TSize& aVideoSize, 
+                                       TTimeIntervalMicroSeconds& aDuration, 
+                                       TInt& aMaxVolume, 
+                                       TInt& aCurrentVolume,
+                                       TInt& aBalanceCenter,
+                                       TInt& aBalanceMaxLeft,
+                                       TInt& aBalanceMaxRight,
+                                       TInt& aDefaultBalance, 
+                                       TInt& aCurrentBalance );
+    virtual void SetDefaultAutoscaleMode( TAutoscaleMode aDefaultAutoscale );    
+    virtual void PreparePlayerWithFile( RFile& aFile );
+    virtual void PreparePlayerWithUrl( const TDesC& aUrl );
+    
+private:
+    
+    CMmfPlayerWindow( RFs& aFs, RWsSession& aWs, CWsScreenDevice& aScreenDevice, bool aSuppressGraphicsContext, TUint32 aControllerUid );
+    
+    void ConstructL( const RWindowTreeNode &aParentWindow, TPoint aTopRight, TSize aSize, bool aTransparent, TRgb aBackgroundColor );
+    
+    // inherited from MVideoPlayerUtilityObserver
+    virtual void MvpuoOpenComplete(TInt aError);
+    virtual void MvpuoPrepareComplete(TInt aError);
+    virtual void MvpuoFrameReady(CFbsBitmap& aFrame,TInt aError);
+    virtual void MvpuoPlayComplete(TInt aError);
+    virtual void MvpuoEvent(const TMMFEvent& aEvent);
+
+#ifdef __USE_VIDEOPLAYER_1__
+    CVideoPlayerUtility*   iVideoPlayer;
+#else    
+    CVideoPlayerUtility2*  iVideoPlayer;
+#endif
+    
+    TVideoRotation iRotation;
+    TAutoScaleType iDefaultAutoScale;    
+    TAutoScaleType iAutoScale;
+    TUint32        iControllerUid;
+  
+    };
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/consoleplayer/player/src/openmax_al/openmaxplayerutility.cpp	Fri Sep 03 19:37:02 2010 -0500
@@ -0,0 +1,453 @@
+#include <string.h>
+#include <stdlib.h> 
+#include "openmaxplayerutility.h"
+
+#define FILE_EXTN "file:///"
+#define FILE_EXTN_LEN strlen("file:///")
+
+XAboolean  bIsPlayDone = XA_BOOLEAN_FALSE;
+
+void PlayCallbackFun (XAPlayItf /*caller*/, void* pContext, XAuint32 event)
+{
+    char callback_string[50];
+    COpenMaxPlayerUtility* pSelf = (COpenMaxPlayerUtility*)pContext;
+    if(event & XA_PLAYEVENT_HEADMOVING)
+    {
+        strcpy(callback_string, "XA_PLAYEVENT_HEADMOVING");    
+    }
+    else if(event & XA_PLAYEVENT_HEADATEND)
+    {
+        strcpy(callback_string, "XA_PLAYEVENT_HEADATEND");
+        bIsPlayDone = XA_BOOLEAN_TRUE;
+        pSelf->Stop();
+    }
+    else if(event & XA_PLAYEVENT_HEADATMARKER)
+    {
+        strcpy(callback_string, "XA_PLAYEVENT_HEADATMARKER");    
+    }
+    else if(event & XA_PLAYEVENT_HEADATNEWPOS)
+    {
+        strcpy(callback_string, "XA_PLAYEVENT_HEADATNEWPOS");    
+    }
+    else if(event & XA_PLAYEVENT_HEADSTALLED)
+    {
+        strcpy(callback_string, "XA_PLAYEVENT_HEADSTALLED");    
+    }
+    //LOGFILE (callback_string);
+}
+
+COpenMaxPlayerUtility::COpenMaxPlayerUtility()
+{
+    Init();
+}
+
+COpenMaxPlayerUtility::~COpenMaxPlayerUtility()
+{
+    /* Destroy the player */
+    DestroyPlayer ();
+    
+    /* Destroy Output Mix object */
+    (*m_outputMix)->Destroy(m_outputMix);
+    
+    /* Shutdown OpenMAX AL */
+    (*m_engine)->Destroy(m_engine);
+}
+
+// Initializes the OpenMAX AL engine and start the playback of some
+// music from a file and draw the graphical equalizer
+//
+void COpenMaxPlayerUtility::Init (void)
+{
+    XAresult res;
+    int i;
+    XAEngineOption EngineOption[] = {
+        (XAuint32) XA_ENGINEOPTION_THREADSAFE,
+        (XAuint32) XA_BOOLEAN_TRUE
+    };
+
+    /* Create OpenMAX AL */
+   res = xaCreateEngine(&m_engine, 1, EngineOption, 0, NULL, NULL); 
+   CheckErr(res, "xaCreateEngine");
+
+    /* Realizing the XA Engine in synchronous mode. */
+   res = (*m_engine)->Realize(m_engine, XA_BOOLEAN_FALSE); 
+   CheckErr(res, "Realize(engine)");
+
+    /* Get the XA Engine Interface which is implicit */
+   res = (*m_engine)->GetInterface(m_engine, XA_IID_ENGINE, (void**) &m_EngineItf); 
+   CheckErr(res, "GetInterface(engine)");
+
+    /* Initialize arrays required[] and iidArray[] */
+    for (i = 0; i < MAX_NUMBER_INTERFACES; i++)
+    {
+        m_required[i] = XA_BOOLEAN_FALSE;
+        m_iidArray[i] = XA_IID_NULL;
+    }
+
+    /* Set arrays required[] and iidArray[] for VOLUME and EQUALIZER interfaces */
+    m_required[0] = XA_BOOLEAN_TRUE;
+    m_iidArray[0] = XA_IID_VOLUME;
+    m_required[1] = XA_BOOLEAN_TRUE;
+    m_iidArray[1] = XA_IID_EQUALIZER;
+
+    /* Create Output Mix object to be used by player */
+    res = (*m_EngineItf)->CreateOutputMix(m_EngineItf, &m_outputMix, 2, m_iidArray, m_required); 
+    CheckErr(res, "CreateOutputMix");
+
+    /* Realizing the Output Mix object in synchronous mode. */
+    res = (*m_outputMix)->Realize(m_outputMix, XA_BOOLEAN_FALSE); 
+    CheckErr(res, "Realize(outputMix)");
+
+    /* Get volume and equalizer interfaces */
+    res = (*m_outputMix)->GetInterface(m_outputMix, XA_IID_VOLUME, (void**) &m_volumeItf); 
+    CheckErr(res, "GetInterface(volume)");
+    res = (*m_outputMix)->GetInterface(m_outputMix, XA_IID_EQUALIZER, (void**) &m_equalizerItf); 
+    CheckErr(res, "GetInterface(equalizer)");
+
+    // Setup the audio sink structure 
+    m_locator_outputmix.locatorType = XA_DATALOCATOR_OUTPUTMIX;
+    m_locator_outputmix.outputMix = m_outputMix;
+    m_audioSink.pLocator = (void*) &m_locator_outputmix;
+    m_audioSink.pFormat = NULL;
+
+    /* Set arrays required[] and iidArray[] for no interfaces (PlayItf is implicit) */
+    m_required[0] = XA_BOOLEAN_TRUE;
+    m_iidArray[0] = XA_IID_DYNAMICSOURCE;
+    m_required[1] = XA_BOOLEAN_FALSE;
+    m_iidArray[1] = XA_IID_NULL;
+
+    // Setup the video sink structure 
+    // Set nativeWindowHandle and nativeDisplayHandle to platform specific values 
+    XANativeHandle nativeWindowHandle = NULL;
+    XANativeHandle nativeDisplayHandle = NULL;
+    
+    m_locator_displayregion.locatorType = XA_DATALOCATOR_NATIVEDISPLAY;
+    m_locator_displayregion.hDisplay = nativeDisplayHandle;
+    m_locator_displayregion.hWindow = nativeWindowHandle; 
+    m_videoSink.pLocator = (void*) &m_locator_displayregion;
+    m_videoSink.pFormat = NULL;
+
+    /* Before we start set volume to -3dB (-300mB) and enable equalizer */
+    XAmillibel minVol = m_nVolume = XA_MILLIBEL_MIN;
+    XAmillibel maxVol = 0;
+    res = (*m_volumeItf)->GetMaxVolumeLevel (m_volumeItf, &maxVol);
+    CheckErr(res, "GetMaxVolumeLevel");
+
+    // before Play, set volume 
+    res = (*m_volumeItf)->SetVolumeLevel(m_volumeItf, minVol); 
+    CheckErr(res, "SetVolumeLevel");
+}
+
+void COpenMaxPlayerUtility::DestroyPlayer ()
+    {
+    XAresult res;
+    XAuint32 playState;
+    /* Stop the music */
+    res = (*m_playItf)->GetPlayState(m_playItf, &playState);
+    CheckErr(res, "GetPlayState");
+    
+    if ( playState != XA_PLAYSTATE_STOPPED )
+        {
+        res = (*m_playItf)->SetPlayState(m_playItf, XA_PLAYSTATE_STOPPED); 
+        CheckErr(res, "SetPlayState(stopped)");
+        }
+    
+    // Destroy the player caused app to crash 
+//    (*player)->Destroy(player);
+    }
+
+/*
+* Called when the display is repainted.
+*/
+void COpenMaxPlayerUtility::DrawEQDisplay (void)
+{
+    XAuint16 numBands;
+    XAmillibel bandLevel;
+    XAmillibel minLevel;
+    XAmillibel maxLevel;
+    XAmilliHertz minFreq;
+    XAmilliHertz maxFreq;
+    int band;
+    XAresult res;
+    res = (*m_equalizerItf)->GetNumberOfBands(m_equalizerItf, &numBands); 
+    CheckErr(res, "GetNumberOfBands(equalizerItf)");
+    res = (*m_equalizerItf)->GetBandLevelRange(m_equalizerItf, &minLevel, &maxLevel); 
+    CheckErr(res, "GetBandLevelRange(equalizerItf)");
+    for (band = 0; band<numBands; band++)
+    {
+        res = (*m_equalizerItf)->GetBandFreqRange(m_equalizerItf, (XAint16) band, &minFreq, &maxFreq); 
+        CheckErr(res, "GetBandFreqRange(equalizerItf)");
+        res = (*m_equalizerItf)->GetBandLevel(m_equalizerItf, (XAint16)band, &bandLevel); 
+        CheckErr(res, "GetBandLevel(equalizerItf)");
+ //       drawEQBand(minFreq, maxFreq, bandLevel);
+    }
+}
+
+void COpenMaxPlayerUtility::VideoFrameSize(TSize& /*aSize*/) const
+{
+}
+
+TTimeIntervalMicroSeconds COpenMaxPlayerUtility::Position() const
+{
+    return 0;
+}
+
+TTimeIntervalMicroSeconds COpenMaxPlayerUtility::Duration() const
+{
+    return 0;
+}
+
+TInt COpenMaxPlayerUtility::Volume() const
+    {
+    return m_nVolume;
+    }
+
+TInt COpenMaxPlayerUtility::MaxVolume() const
+    {
+    return m_nVolume;
+    }
+
+TInt COpenMaxPlayerUtility::Balance()const
+{
+    return 0;
+}
+
+TVideoRotation COpenMaxPlayerUtility::Rotation() const
+{
+    return EVideoRotationNone;
+}
+
+void COpenMaxPlayerUtility::SetVolume(TInt aVolume)
+    {
+    m_nVolume = aVolume;
+    XAresult res = (*m_volumeItf)->SetVolumeLevel(m_volumeItf, (XAmillibel)m_nVolume); 
+    CheckErr(res, "SetVolumeL");
+    }
+
+void COpenMaxPlayerUtility::SetBalance(TInt /*aBalance*/)
+    {
+    }
+
+void COpenMaxPlayerUtility::SetPosition(const TTimeIntervalMicroSeconds& /*aPosition*/)
+    {
+    
+    }
+
+void COpenMaxPlayerUtility::SetRotation(const RWindow& /*aWindow*/, TVideoRotation /*aRotation*/)
+    {
+    
+    }
+
+void COpenMaxPlayerUtility::SetScaleFactor(const RWindow& /*aWindow*/, TReal32 /*aWidthPercentage*/, 
+        TReal32 /*aHeightPercentage*/)
+    {
+    
+    }
+
+void COpenMaxPlayerUtility::SetAutoScale(const RWindow& /*aWindow*/, TAutoScaleType /*aScaleType*/)
+    {
+    
+    }
+
+void COpenMaxPlayerUtility::StepFrame(TInt /*aStep*/)
+    {
+    
+    }
+
+void COpenMaxPlayerUtility::OpenFile(const TDesC& aFileName, TUid /*aControllerUid*/)
+    {
+    const TUint16 *pFile = aFileName.Ptr();
+    TInt len = aFileName.Length();
+    
+    if (pFile) 
+        {
+        strcpy((char*)m_sourceName, FILE_EXTN);
+        len = wcstombs((char*)&m_sourceName[FILE_EXTN_LEN], (const wchar_t *)pFile, len);
+        m_sourceName[FILE_EXTN_LEN + len] = '\0';
+        uri.locatorType = XA_DATALOCATOR_URI;
+        uri.URI = (XAchar*) m_sourceName;
+        m_mime.formatType = XA_DATAFORMAT_MIME;
+        m_mime.mimeType = (XAchar *) "audio/ra";
+        
+		//Do we need this here?
+        PlaySource (uri);
+        }
+    }
+
+void COpenMaxPlayerUtility::OpenUrl(const TDesC& /*aUrl*/)
+    {
+    
+    }
+
+void COpenMaxPlayerUtility::Prepare()
+    {
+    
+    }
+
+void COpenMaxPlayerUtility::Close()
+    {
+    
+    }
+
+void COpenMaxPlayerUtility::Pause()
+    {
+    XAresult res;
+    res = (*m_playItf)->SetPlayState(m_playItf, XA_PLAYSTATE_PAUSED); 
+    CheckErr(res, "SetPlayState(paused)");
+    }
+
+void COpenMaxPlayerUtility::Play()
+    {
+    XAresult res;
+    res = (*m_playItf)->SetPlayState(m_playItf, XA_PLAYSTATE_PLAYING); 
+    CheckErr(res, "SetPlayState(playing)");
+    }
+
+TInt COpenMaxPlayerUtility::Stop()
+    {
+    DestroyPlayer();
+	  return 0;
+    }
+
+void COpenMaxPlayerUtility::AddDisplayWindow(RWsSession& aWs, CWsScreenDevice& /*aScreenDevice*/, RWindow& aWindow)
+    {
+    m_locator_displayregion.hDisplay = &aWs; //pointer to RWsSession
+    m_locator_displayregion.hWindow = &aWindow; //pointer to RWindow
+    }
+
+void COpenMaxPlayerUtility::SetWindowClipRect(const RWindow& /*aWindow*/, const TRect& /*aWindowClipRect*/)
+    {
+    
+    }
+
+void COpenMaxPlayerUtility::SetVideoExtent(const RWindow& /*aWindow*/, const TRect& /*aVideoExtent*/)
+    {
+    
+    }
+
+/* Checks for error. If any errors exit the application! */
+bool COpenMaxPlayerUtility::CheckErr (XAresult res, char* /*aMsg*/)
+{
+    return (res == XA_RESULT_SUCCESS);
+}
+
+
+/*
+* Called by UI when user increases or decreases a band level.
+*/
+void COpenMaxPlayerUtility::SetBandLevel(XAint16 band, XAboolean increase)
+{
+    XAuint16 numBands;
+    XAmillibel bandLevel;
+    XAmillibel minLevel;
+    XAmillibel maxLevel;
+    XAresult res;
+
+    res = (*m_equalizerItf)->GetNumberOfBands(m_equalizerItf, &numBands); 
+    CheckErr(res, "GetNumberOfBands");
+
+    res = (*m_equalizerItf)->GetBandLevelRange(m_equalizerItf, &minLevel, &maxLevel); 
+    CheckErr(res, "GetBandLevelRange");
+    if (band >= numBands)
+    {
+        /* Error. Insert debug print here. */
+        exit(0);
+    }
+
+    res = (*m_equalizerItf)->GetBandLevel(m_equalizerItf, band, &bandLevel); 
+    CheckErr(res, "GetBandLevel");
+
+    if (increase==XA_BOOLEAN_TRUE)
+    {
+        /* increase the level by 1 dB (100mB) if the max supported level
+        * is not exceeded */
+        bandLevel = bandLevel + 100;
+        if(bandLevel < maxLevel)
+        {
+            res = (*m_equalizerItf)->SetBandLevel(m_equalizerItf, band, bandLevel); 
+            CheckErr(res);
+            DrawEQDisplay();
+        }
+    }
+    else /* increase==false */
+    {
+        /* decrease the level by 1 dB (100mB) if the min supported level
+        * is not crossed */
+        bandLevel = bandLevel - 100;
+        if( bandLevel > minLevel )
+        {
+            res = (*m_equalizerItf)->SetBandLevel(m_equalizerItf, band, bandLevel); 
+            CheckErr(res);
+            DrawEQDisplay();
+        }
+    }
+}
+
+void COpenMaxPlayerUtility::PlaySource(const XADataLocator_URI &source)
+    {
+    m_dataSource.pLocator = (void*) &source;
+    m_dataSource.pFormat = (void*) &m_mime;
+
+    // Create the music player //
+    XAresult res;
+    res = (*m_EngineItf)->CreateMediaPlayer ( m_EngineItf, &player, &m_dataSource, NULL, &m_audioSink, 
+            &m_videoSink, NULL, NULL, 1, m_iidArray, m_required); 
+    CheckErr(res, "CreateMediaPlayer");
+    
+    // Realizing the player in synchronous mode. 
+    res = (*player)->Realize(player, XA_BOOLEAN_FALSE); 
+    CheckErr(res, "Realize(player)");
+
+    // Get the play interface 
+    res = (*player)->GetInterface(player, XA_IID_PLAY, (void**) &m_playItf); 
+    CheckErr(res, "GetInterface(player)");
+
+/*    XADynamicSourceItf sourceItf;
+    res = (*player)->GetInterface(player, XA_IID_DYNAMICSOURCE, (void**) &sourceItf); 
+    CheckErr(res, "GetDynamicSource");
+
+    res = (*sourceItf)->SetSource (sourceItf, &m_dataSource);
+    CheckErr(res, "SetSource");
+*/
+    // before Play, set volume 
+    res = (*m_volumeItf)->SetVolumeLevel(m_volumeItf, m_nVolume); 
+    CheckErr(res, "SetVolumeLevel");
+
+    XAmillisecond playDuration = 0;
+    res = (*m_playItf)->GetDuration(m_playItf, &playDuration); 
+    bool b = CheckErr(res, "GetDuration");
+    //if ( b && (playDuration != XA_DURATION_UNKNOWN) )
+        //SetDurationL ((playDuration/1000));
+
+    res = (*m_playItf)->SetCallbackEventsMask(m_playItf, XA_PLAYEVENT_HEADATEND | XA_PLAYEVENT_HEADMOVING); 
+    CheckErr(res, "SetCallbackEventsMask");
+    
+    res = (*m_playItf)->RegisterCallback(m_playItf, PlayCallbackFun, this);
+    CheckErr(res, "RegisterCallback");
+	//Do we need this here?
+    Play();
+    }
+
+void COpenMaxPlayerUtility::PlayPause(bool bChecked)
+    {
+    if (bChecked)
+        {
+        Pause();
+        }
+    else
+        {
+        Play();
+        }
+    }
+
+void COpenMaxPlayerUtility::MuteChanged(bool bChecked)
+    {
+    XAresult res = (*m_volumeItf)->SetMute(m_volumeItf, (XAboolean)bChecked); 
+    CheckErr(res, "MuteChanged");
+    }
+
+TInt COpenMaxPlayerUtility::SetPlayVelocity( TInt aVelocity )
+    {
+    m_Velocity = aVelocity;
+    return 0;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/consoleplayer/player/src/openmax_al/openmaxplayerutility.h	Fri Sep 03 19:37:02 2010 -0500
@@ -0,0 +1,89 @@
+#ifndef OPENMAX_PLAYER_UTILITY_H
+#define OPENMAX_PLAYER_UTILITY_H
+
+#include <string.h>
+#include <e32std.h>
+#include <w32std.h>
+#include <mmf\common\Mmfvideo.h> // for TVideoRotation and TAutoScaleType
+#include "playerwindow.h"
+#include "openmaxal.h"
+
+#define MAX_NUMBER_INTERFACES 5
+
+class COpenMaxPlayerUtility
+{
+public:
+    COpenMaxPlayerUtility();
+    ~COpenMaxPlayerUtility();
+    
+    void VideoFrameSize(TSize& aSize) const;
+    TTimeIntervalMicroSeconds Position() const;
+    TTimeIntervalMicroSeconds Duration() const;
+    TInt Volume() const;
+    TInt MaxVolume() const;
+    TInt Balance()const;
+    TVideoRotation Rotation() const;
+    
+    void SetVolume(TInt aVolume);
+    void SetBalance(TInt aBalance);
+    void SetPosition(const TTimeIntervalMicroSeconds& aPosition);
+    void SetRotation(const RWindow& aWindow, TVideoRotation aRotation);
+    void SetScaleFactor(const RWindow& aWindow, TReal32 aWidthPercentage, TReal32 aHeightPercentage);
+    void SetAutoScale(const RWindow& aWindow, TAutoScaleType aScaleType);
+    void StepFrame(TInt aStep);
+    
+    void OpenFile(const TDesC& aFileName,TUid aControllerUid = KNullUid);
+    void OpenUrl(const TDesC& aUrl);
+    void Prepare();
+    void Close();
+    void Play();
+    TInt Stop();
+    void Pause();
+
+    void AddDisplayWindow(RWsSession& aWs, CWsScreenDevice& aScreenDevice, RWindow& aWindow);
+    void SetWindowClipRect(const RWindow& aWindow, const TRect& aWindowClipRect);
+    void SetVideoExtent(const RWindow& aWindow, const TRect& aVideoExtent);
+
+    bool CheckErr (XAresult res, char* aMsg = "");
+
+    void Init (void);
+    void DestroyPlayer ();
+    void DrawEQDisplay (void);
+    void SetBandLevel(XAint16 band, XAboolean increase);
+    void PlaySource(const XADataLocator_URI &source);
+    void PlayPause(bool);
+    void MuteChanged(bool);
+    TInt SetPlayVelocity( TInt aVelocity );
+    
+protected:
+    void StartBackLightTimer();
+    void CancelBackLightTimer();
+    
+private:
+    XAObjectItf m_engine; /* OpenMAX AL Engine */
+    XAObjectItf player;
+    XAObjectItf m_outputMix;
+
+    XAEngineItf m_EngineItf;
+    XAPlayItf m_playItf;
+    XAEqualizerItf m_equalizerItf;
+    XAVolumeItf m_volumeItf;
+
+    XAInterfaceID m_iidArray[MAX_NUMBER_INTERFACES];
+    XAboolean m_required[MAX_NUMBER_INTERFACES];
+
+    XADataSource m_dataSource;
+    XADataSink          m_audioSink;
+    XADataSink          m_videoSink;
+    XADataFormat_MIME m_mime;
+    XADataLocator_OutputMix m_locator_outputmix;
+    XADataLocator_NativeDisplay m_locator_displayregion;
+    XADataLocator_URI uri;
+    
+    TRect   m_displayRect;
+    int     m_nVolume;
+    int     m_Velocity;
+    XAchar  m_sourceName[1000];
+};
+
+#endif // OPENMAX_PLAYER_UTILITY_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/consoleplayer/player/src/openmax_al/opmaxplayerwindow.cpp	Fri Sep 03 19:37:02 2010 -0500
@@ -0,0 +1,347 @@
+#include "opmaxplayerwindow.h"
+#include "openmaxplayerutility.h"
+
+
+/**
+Balance values from mmfstandardcustomcommands.h
+*/
+#if 0
+const TInt KMMFBalanceCenter = 0;
+const TInt KMMFBalanceMaxLeft = -100;
+const TInt KMMFBalanceMaxRight = 100;
+#endif
+
+COpMaxPlayerWindow* COpMaxPlayerWindow::NewL( RFs& aFs, 
+                                          RWsSession& aWs,
+                                          CWsScreenDevice& aScreenDevice,
+                                          const RWindowTreeNode &aParentWindow,
+                                          TPoint aTopRight,
+                                          TSize aSize,
+                                          bool aTransparent,
+                                          TRgb aBackgroundColor,
+                                          bool aSuppressGraphicsContext)
+    {
+    COpMaxPlayerWindow* self = new(ELeave) COpMaxPlayerWindow( aFs, aWs, aScreenDevice, aSuppressGraphicsContext);
+    CleanupStack::PushL( self );
+    self->ConstructL( aParentWindow, aTopRight, aSize, aTransparent, aBackgroundColor );
+    CleanupStack::Pop();
+    return self;   
+    }
+    
+COpMaxPlayerWindow::COpMaxPlayerWindow( RFs& aFs, RWsSession& aWs, CWsScreenDevice& aScreenDevice, bool aSuppressGraphicsContext ) :
+    CPlayerWindow( aFs, aWs, aScreenDevice, aSuppressGraphicsContext )
+    {    
+    }
+
+COpMaxPlayerWindow::~COpMaxPlayerWindow()
+    {    
+    delete iVideoPlayer;
+    }
+
+void COpMaxPlayerWindow::ConstructL( const RWindowTreeNode &aParentWindow, TPoint aTopRight, TSize aSize, bool aTransparent, TRgb aBackgroundColor )
+    {
+    BaseConstructL( aParentWindow, aTopRight, aSize, aTransparent, aBackgroundColor );
+
+    iVideoPlayer = new (ELeave) COpenMaxPlayerUtility;
+    iVideoPlayer->AddDisplayWindow( iWs, iScreenDevice, iWindow );
+    }
+
+
+void COpMaxPlayerWindow::InitializeParameters( TSize& aVideoSize, 
+                                             TTimeIntervalMicroSeconds& aDuration, 
+                                             TInt& aMaxVolume, 
+                                             TInt& aCurrentVolume,
+                                             TInt& aBalanceCenter,
+                                             TInt& aBalanceMaxLeft,
+                                             TInt& aBalanceMaxRight,
+                                             TInt& aDefaultBalance, 
+                                             TInt& aCurrentBalance )
+    {
+    iVideoPlayer->VideoFrameSize(aVideoSize);               
+    aDuration = iVideoPlayer->Duration();
+    aMaxVolume = iVideoPlayer->MaxVolume();
+    aCurrentVolume = iVideoPlayer->Volume();
+    aBalanceCenter = KMMFBalanceCenter;
+    aBalanceMaxLeft = KMMFBalanceMaxLeft;
+    aBalanceMaxRight = KMMFBalanceMaxRight;
+    aDefaultBalance = iVideoPlayer->Balance();
+    aCurrentBalance = aDefaultBalance;
+    }
+
+void COpMaxPlayerWindow::SetDefaultAutoscaleMode( TAutoscaleMode aDefaultAutoscale )
+    {
+    switch( aDefaultAutoscale )
+        {
+        case EDoNotAutoscale:
+            iAutoScale = EAutoScaleNone;
+            break;
+        case EBestFit:
+            iAutoScale = EAutoScaleBestFit;
+            break;
+        case EStretch:
+            iAutoScale = EAutoScaleStretch;
+            break;
+        }
+    iDefaultAutoScale = iAutoScale;
+    iVideoPlayer->SetAutoScale(iWindow, iAutoScale);                        
+    }    
+
+void COpMaxPlayerWindow::PreparePlayerWithFile( RFile& aFile )
+    {
+    TFileName fileName;
+    aFile.FullName(fileName);
+    iVideoPlayer->OpenFile(fileName);
+    
+    // Now wait for MvpuoOpenComplete callback.
+    PlayInitiated();
+    }
+
+void COpMaxPlayerWindow::PreparePlayerWithUrl( const TDesC& aUrl )
+    {
+    iVideoPlayer->OpenFile(aUrl);
+    
+    // Now wait for MvpuoOpenComplete callback.            
+    }
+
+TInt COpMaxPlayerWindow::DoExecuteOperation( TInt /*aOperation*/ )
+    {
+    // Currently there are no MMF-specific commands.
+    return KErrNotSupported;
+    }
+
+TTimeIntervalMicroSeconds COpMaxPlayerWindow::Position()
+    {
+    TTimeIntervalMicroSeconds position = iVideoPlayer->Position();
+    return position;
+    }
+
+TInt COpMaxPlayerWindow::SetVolume( TInt aVolume )
+    {
+    iVideoPlayer->SetVolume( aVolume );
+    return 0;
+    }
+
+TInt COpMaxPlayerWindow::SetBalance( TInt aBalance )
+    {
+    iVideoPlayer->SetBalance( aBalance );
+    return 0;
+    }
+
+TInt COpMaxPlayerWindow::RotationAngle()
+    {
+    TInt rotAngle = 0;
+    switch( iRotation )
+        {
+        case EVideoRotationClockwise90:
+            rotAngle = 90;
+        case EVideoRotationClockwise180:
+            rotAngle = 180;
+        case EVideoRotationClockwise270:
+            rotAngle = 270;
+        default:
+            rotAngle = 0;
+        }
+    return rotAngle;
+    }
+
+TInt COpMaxPlayerWindow::NextRotationAngle()
+    {
+    switch( iRotation )
+        {
+        case EVideoRotationNone:
+            iRotation = EVideoRotationClockwise90;
+            break;
+        case EVideoRotationClockwise90:
+            iRotation = EVideoRotationClockwise180;
+            break;
+        case EVideoRotationClockwise180:
+            iRotation = EVideoRotationClockwise270;
+            break;
+        case EVideoRotationClockwise270:
+            iRotation = EVideoRotationNone;
+            break;
+        }
+    iVideoPlayer->SetRotation(iWindow, iRotation);
+    return 0;
+    }
+
+TInt COpMaxPlayerWindow::ResetRotation()
+    {
+    iRotation = EVideoRotationNone;
+    iVideoPlayer->SetRotation(iWindow, iRotation);
+    return 0;
+    }
+
+TInt COpMaxPlayerWindow::NextAutoscaleMode()
+    {
+    switch( iAutoScale )
+        {
+        case EAutoScaleNone:
+            iAutoScale = EAutoScaleBestFit;
+            break;
+        case EAutoScaleBestFit:
+            iAutoScale = EAutoScaleClip;
+            break;
+        case EAutoScaleClip:
+            iAutoScale = EAutoScaleStretch;
+            break;
+        case EAutoScaleStretch:
+            iAutoScale = EAutoScaleNone;
+            break;
+        }     
+    iVideoPlayer->SetAutoScale(iWindow, iAutoScale);
+    return 0;
+    }
+
+TInt COpMaxPlayerWindow::ResetAutoscale()
+    {
+    iAutoScale = iDefaultAutoScale;
+    iVideoPlayer->SetAutoScale(iWindow, iAutoScale);
+    return 0;
+    }
+
+void COpMaxPlayerWindow::AppendAutoscaleModeText( TDes& aString )
+    {
+    switch( iAutoScale )
+        {
+        case EAutoScaleNone:
+            aString.Append(_L("None"));
+            break;
+        case EAutoScaleBestFit:
+            aString.Append(_L("Best Fit"));
+            break;
+        case EAutoScaleClip:
+            aString.Append(_L("Clip"));
+            break;
+        case EAutoScaleStretch:
+            aString.Append(_L("Stretch"));
+            break;
+        }
+    }
+
+TInt COpMaxPlayerWindow::SetClipRectangle( TRect aRect )
+    {
+    iVideoPlayer->SetWindowClipRect(iWindow, aRect);
+    return 0;
+    }
+
+TInt COpMaxPlayerWindow::SetVideoExtent( TRect aExtent )
+    {
+    iVideoPlayer->SetVideoExtent(iWindow, aExtent);
+    return 0;
+    }
+
+TInt COpMaxPlayerWindow::SetScaleFactor( TReal aWidthScaleFactor, TReal aHeightScaleFactor )
+    {
+    iVideoPlayer->SetScaleFactor(iWindow, aWidthScaleFactor, aHeightScaleFactor);
+    return 0;
+    }
+
+TInt COpMaxPlayerWindow::Play()
+    {
+    iVideoPlayer->Play();
+    return KErrNone;
+    }
+
+TInt COpMaxPlayerWindow::Pause()
+    {
+    iVideoPlayer->Pause();
+    return 0;
+    }
+
+TInt COpMaxPlayerWindow::Stop()
+    {
+    return iVideoPlayer->Stop();
+    }
+
+TInt COpMaxPlayerWindow::SetPosition( TTimeIntervalMicroSeconds aPositionInMs )
+    {
+    iVideoPlayer->SetPosition( aPositionInMs );
+    return 0;
+    }
+
+TInt COpMaxPlayerWindow::StepForward()
+    {
+    iVideoPlayer->StepFrame(1);
+    return 0;
+    }
+
+TInt COpMaxPlayerWindow::StepBackward()
+    {
+    iVideoPlayer->StepFrame(-1);
+    return 0;
+    }
+
+TInt COpMaxPlayerWindow::SetPlayVelocity( TInt aVelocity )
+    {
+    TRAPD( err, iVideoPlayer->SetPlayVelocity(aVelocity) );
+    return err;
+    }
+
+// inherited from MVideoPlayerUtilityObserver
+void COpMaxPlayerWindow::MvpuoOpenComplete(TInt aError)
+    {
+    RDebug::Printf( "CONSOLEPLAYER MvpuoOpenComplete(%i)", aError );
+    
+    if( aError == KErrNone )
+        {
+        iVideoPlayer->Prepare();
+    
+        // Now wait for MvpuoPrepareComplete callback.
+        }
+    else
+        {
+        Error( aError );
+        }
+    }
+
+void COpMaxPlayerWindow::MvpuoPrepareComplete(TInt aError)
+    {
+    RDebug::Printf( "CONSOLEPLAYER MvpuoPrepareComplete(%i)", aError );
+    
+    if( aError == KErrNone )
+        {
+        iVideoPlayer->AddDisplayWindow( iWs, iScreenDevice, iWindow );
+        Play();
+        ResetAutoscale();
+        PlayInitiated();
+        }
+    else
+        {
+        Error( aError );
+        }
+    }
+
+void COpMaxPlayerWindow::MvpuoFrameReady(CFbsBitmap& /*aFrame*/,TInt aError)
+    {
+    RDebug::Printf( "CONSOLEPLAYER MvpuoFrameReady(%i)", aError );
+    
+    if( aError != KErrNone )
+        {
+        Error( aError );
+        }
+    }
+
+void COpMaxPlayerWindow::MvpuoPlayComplete(TInt aError)
+    {
+    RDebug::Printf( "CONSOLEPLAYER MvpuoPlayComplete(%i)", aError );
+    
+    if( aError == KErrNone )
+        {
+        PlayComplete();
+        }
+    else
+        {
+        Error( aError );
+        }
+    }
+
+void COpMaxPlayerWindow::MvpuoEvent(const TMMFEvent& aEvent)
+    {   
+    RDebug::Printf( "CONSOLEPLAYER MvpuoEvent event=%x error=%i", aEvent.iEventType.iUid, aEvent.iErrorCode );    
+
+    if( aEvent.iErrorCode != KErrNone )
+        {
+        Error( aEvent.iErrorCode );
+        }
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/consoleplayer/player/src/openmax_al/opmaxplayerwindow.h	Fri Sep 03 19:37:02 2010 -0500
@@ -0,0 +1,85 @@
+#ifndef __OPMAX_PLAYER_WINDOW_H__
+#define __OPMAX_PLAYER_WINDOW_H__
+
+#include <e32base.h>
+#ifdef __USE_VIDEOPLAYER_1__
+#include <videoplayer.h>
+#else
+#include <videoplayer2.h>
+#endif
+#include "playerwindow.h"
+#include "openmaxplayerutility.h"
+
+class COpMaxPlayerWindow : public CPlayerWindow
+                         , private MVideoPlayerUtilityObserver
+    {
+public:
+
+    static COpMaxPlayerWindow* NewL( RFs& aFs, 
+                                   RWsSession& aWs,
+                                   CWsScreenDevice& aScreenDevice,
+                                   const RWindowTreeNode &aParentWindow,
+                                   TPoint aTopRight,
+                                   TSize aSize,
+                                   bool aTransparent,
+                                   TRgb aBackgroundColor,
+                                   bool aSuppressGraphicsContext);
+    
+    virtual ~COpMaxPlayerWindow();
+
+    // inherited from CPlayerWindow
+    virtual TTimeIntervalMicroSeconds Position();
+    virtual TInt SetVolume( TInt aVolume );
+    virtual TInt SetBalance( TInt aBalance );
+    virtual TInt RotationAngle();
+    virtual TInt NextRotationAngle();
+    virtual TInt ResetRotation();
+    virtual TInt NextAutoscaleMode();
+    virtual TInt ResetAutoscale();
+    virtual void AppendAutoscaleModeText( TDes& aString );
+    virtual TInt SetClipRectangle( TRect aRect );
+    virtual TInt SetVideoExtent( TRect aExtent );
+    virtual TInt SetScaleFactor( TReal aWidthScaleFactor, TReal aHeightScaleFactor );
+    virtual TInt Play();
+    virtual TInt Pause();
+    virtual TInt Stop();
+    virtual TInt SetPosition( TTimeIntervalMicroSeconds aPositionInMs );
+    virtual TInt StepForward();
+    virtual TInt StepBackward();
+    virtual TInt SetPlayVelocity( TInt aVelocity );
+    virtual TInt DoExecuteOperation( TInt aOperation );
+    virtual void InitializeParameters( TSize& aVideoSize, 
+                                       TTimeIntervalMicroSeconds& aDuration, 
+                                       TInt& aMaxVolume, 
+                                       TInt& aCurrentVolume,
+                                       TInt& aBalanceCenter,
+                                       TInt& aBalanceMaxLeft,
+                                       TInt& aBalanceMaxRight,
+                                       TInt& aDefaultBalance, 
+                                       TInt& aCurrentBalance );
+    virtual void SetDefaultAutoscaleMode( TAutoscaleMode aDefaultAutoscale );    
+    virtual void PreparePlayerWithFile( RFile& aFile );
+    virtual void PreparePlayerWithUrl( const TDesC& aUrl );
+    
+    
+private:
+    
+    COpMaxPlayerWindow( RFs& aFs, RWsSession& aWs, CWsScreenDevice& aScreenDevice, bool aSuppressGraphicsContext );
+    
+    void ConstructL( const RWindowTreeNode &aParentWindow, TPoint aTopRight, TSize aSize, bool aTransparent, TRgb aBackgroundColor );
+    
+    // inherited from MVideoPlayerUtilityObserver
+    virtual void MvpuoOpenComplete(TInt aError);
+    virtual void MvpuoPrepareComplete(TInt aError);
+    virtual void MvpuoFrameReady(CFbsBitmap& aFrame,TInt aError);
+    virtual void MvpuoPlayComplete(TInt aError);
+    virtual void MvpuoEvent(const TMMFEvent& aEvent);
+    
+    COpenMaxPlayerUtility*   iVideoPlayer;    
+    TVideoRotation          iRotation;
+    TAutoScaleType          iDefaultAutoScale;    
+    TAutoScaleType          iAutoScale;    
+  
+    };
+
+#endif 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/consoleplayer/player/src/playerwindow.cpp	Fri Sep 03 19:37:02 2010 -0500
@@ -0,0 +1,704 @@
+/*
+ * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ * The source of the common Player Window functionality.
+ * 
+ */
+
+#include "playerwindow.h"
+#include "consoleplayer.h"
+
+const TInt  KDefaultScalePercentagesIndex = 5;
+const TInt  KScalePercentagesCount = 10;
+const TReal KScalePercentages[] = {10.0, 25.0, 50.0, 75.0, 100.0, 125.0, 150.0, 175.0, 200.0, 250.0};
+
+// this constant must be consistent with the Rectangle function
+const TInt KRectangleModeCount = 5;
+
+const TInt KMoveWindowDelta = 8;
+
+
+CPlayerWindow::CPlayerWindow( RFs& aFs, RWsSession& aWs, CWsScreenDevice& aScreenDevice, bool aSuppressGraphicsContext ) :
+    iFs( aFs ),
+    iWs( aWs ),
+    iScreenDevice( aScreenDevice ),
+    iWindow( aWs ),
+	iSuppressGraphicsContext( aSuppressGraphicsContext ),
+    iCurrentVelocity( 100 ),
+    iWidthScaleIndex( KDefaultScalePercentagesIndex ),
+    iHeightScaleIndex( KDefaultScalePercentagesIndex )
+    {    
+    }
+
+void CPlayerWindow::BaseConstructL( const RWindowTreeNode &aParentWindow, TPoint aTopLeft, TSize aSize, bool aTransparent, TRgb aBackgroundColor )
+    {
+    // A graphics context should not be used with performance mode.
+    if( !iSuppressGraphicsContext )
+    {
+        User::LeaveIfError( iScreenDevice.CreateContext(iGc) );
+    }
+    
+    User::LeaveIfError( iWindow.Construct( aParentWindow, KNullWsHandle ) );
+
+    iWindowTopLeft = aTopLeft;
+    iDefaultWindowSize = aSize;
+    iWindowSize = aSize;
+    iWindowSizeDivisor = 1;
+    
+    iWindow.SetExtent( aTopLeft, aSize );
+    if( aTransparent )
+        {
+        iWindow.SetTransparencyAlphaChannel();
+        }
+    else
+        {
+        iWindow.SetNonTransparent();    
+        }
+    iWindow.SetBackgroundColor(aBackgroundColor); 
+    iWindow.SetVisible(false);
+    iWindow.Activate();
+    
+    // enable drag events
+    iWindow.PointerFilter(EPointerFilterDrag, 0);
+    }
+
+CPlayerWindow::~CPlayerWindow()
+    {
+    delete iGc;
+    iFile.Close();
+    }
+
+void CPlayerWindow::StartWithFilenameL( const TDesC& aFullFilename,
+                                        TAutoscaleMode aDefaultAutoscale,
+                                        MPlayerWindowObserver* aObserver )
+    {
+    iFullFilename.Copy( aFullFilename );
+    iObserver = aObserver;        
+
+    SetDefaultAutoscaleMode( aDefaultAutoscale );
+    
+    User::LeaveIfError( iFile.Open( iFs, iFullFilename, EFileShareReadersOnly | EFileStream | EFileRead ) );
+
+    iFile.Name( iFilename );
+    
+    PreparePlayerWithFile( iFile );
+    
+    // Now wait for subclass to call PrepareComplete.        
+    }
+
+void CPlayerWindow::StartWithUrlL( const TDesC& aUrl,
+                                   TAutoscaleMode aDefaultAutoscale,
+                                   MPlayerWindowObserver* aObserver )
+    {
+    iUrl.Copy( aUrl );
+    iObserver = aObserver;        
+
+    SetDefaultAutoscaleMode( aDefaultAutoscale );
+    
+    PreparePlayerWithUrl( aUrl );
+    
+    // Now wait for subclass to call PrepareComplete.        
+    }
+
+RWindow& CPlayerWindow::Window()
+    {
+    return iWindow;
+    }
+
+const TDesC& CPlayerWindow::FullFilename()
+    {
+    return iFullFilename;
+    }
+
+const TDesC& CPlayerWindow::Filename()
+    {
+    return iFilename;
+    }
+
+const TDesC& CPlayerWindow::Url()
+    {
+    return iUrl;
+    }
+
+void CPlayerWindow::PlayInitiated()
+    {
+    InitializeParameters( iVideoSize, 
+                          iDuration, 
+                          iMaxVolume, 
+                          iCurrentVolume,
+                          iBalanceCenter,
+                          iBalanceMaxLeft,
+                          iBalanceMaxRight,
+                          iDefaultBalance, 
+                          iCurrentBalance );
+    
+    iDurationInMs = iDuration.Int64() / 1000;
+    
+    if( iBorderColor != 0 )
+        {
+        DrawBorderAroundWindow();
+        }
+    
+    iWindow.SetVisible(true);  
+    
+    iPlayState = EPlaying;
+
+    if( iObserver )
+        {
+        iObserver->PlayInitiated();
+        }
+    }
+
+void CPlayerWindow::PlayComplete()
+    {
+    iPlayState = EStopped; 
+    
+    if( iObserver )
+        {
+        iObserver->PlayStateChanged();
+        }       
+    }
+
+void CPlayerWindow::Error( TInt aError, const char* pDescription )
+    {
+    if( pDescription != NULL )
+        {
+        RDebug::Printf( "CONSOLEPLAYER ERROR %i %s", pDescription );
+        }
+    
+    if( iObserver )
+        {
+        iObserver->Error( aError );
+        }       
+    }
+
+void CPlayerWindow::CheckError( TInt aError, const char* pDescription )
+    {
+    if( aError != KErrNone )
+        {
+        Error( aError, pDescription );
+        }
+    }
+
+CPlayerWindow::TPlayState CPlayerWindow::PlayState()
+    {
+    return iPlayState;
+    }
+
+TInt CPlayerWindow::PositionInMs()
+    {    
+    return Position().Int64() / 1000;
+    }
+
+TInt CPlayerWindow::DurationInMs()
+    {    
+    return iDurationInMs;;
+    }
+
+TSize CPlayerWindow::VideoSize()
+    {    
+    return iVideoSize;
+    }
+
+TInt CPlayerWindow::Seek( TTimeIntervalMicroSeconds position )
+    {
+    RDebug::Printf( "CONSOLEPLAYER Seek %lu", position.Int64() );	
+    	
+    if( position < 0 )
+        {
+        position = 0;
+        }           
+    else if( position > iDuration )
+        {
+        position = iDuration;
+        }
+
+    TInt err = Pause();
+    
+    if( err == KErrNone )
+        {
+        err = SetPosition( position.Int64() );
+        }
+
+    if( (err == KErrNone) && (iPlayState == EPlaying) )
+        {
+        err = Play();
+        }
+    
+    return err;
+    }
+
+TInt CPlayerWindow::UpdateScaleFactor()
+    {
+    return SetScaleFactor(KScalePercentages[iWidthScaleIndex], KScalePercentages[iHeightScaleIndex]);
+    }
+
+TInt CPlayerWindow::ResetToDefaults()
+    {
+    iWidthScaleIndex = KDefaultScalePercentagesIndex;
+    iHeightScaleIndex = KDefaultScalePercentagesIndex;
+    iExtentModeIndex = 0;
+    iClipModeIndex = 0;
+    iCurrentVelocity = 100;
+    iCurrentVolume = iDefaultVolume;
+    iCurrentBalance = iDefaultBalance;
+    iWindowSize = iDefaultWindowSize;
+    iWindowSizeDivisor = 1;
+    ResetAutoscale();
+    ResetRotation();    
+    UpdateScaleFactor();
+    SetClipRectangle(Rectangle(iClipModeIndex));
+    SetVideoExtent(Rectangle(iExtentModeIndex));
+    SetPlayVelocity(iCurrentVelocity);
+    SetVolume(iCurrentVolume);
+    SetBalance(iCurrentBalance);    
+    return KErrNone;
+    }
+
+// Iterates through a standard set of rectangles for the clipping and extent.
+TRect CPlayerWindow::Rectangle( TInt aModeIndex )
+    {
+    TRect rectangle;
+    
+    TSize windowSize = iWindow.Size();
+        
+    switch( aModeIndex )
+        {
+        case 0:
+            // Full window.
+            rectangle = TRect(windowSize); ;
+            break;
+        case 1:
+            // 100x100 square in center of window.
+            rectangle = TRect( windowSize.iWidth/2 - 50, windowSize.iHeight/2 - 50,
+                               windowSize.iWidth/2 + 50, windowSize.iHeight/2 + 50 );
+            break;
+        case 2:
+            // Top half of window.
+            rectangle = TRect( 0, 0, windowSize.iWidth, windowSize.iHeight/2 );
+            break;
+        case 3:
+            // Left half of window.
+            rectangle = TRect( 0, 0, windowSize.iWidth/2, windowSize.iHeight );
+            break;
+        case 4:
+            // Top-Left quarter of window.
+            rectangle = TRect( 0, 0, windowSize.iWidth/2, windowSize.iHeight/2 );
+            break;
+        }
+    
+    return rectangle;        
+    }
+
+// Checks to make sure that the second video window is within the limits of the display.
+void CPlayerWindow::CheckWindowLimits()
+    {
+    if( iWindowTopLeft.iX < 0 )
+        {
+        iWindowTopLeft.iX = 0;
+        }
+    else if( iWindowTopLeft.iX + iWindowSize.iWidth > iScreenDevice.SizeInPixels().iWidth )
+        {
+        iWindowTopLeft.iX = iScreenDevice.SizeInPixels().iWidth - iWindowSize.iWidth;
+        }
+
+    if( iWindowTopLeft.iY < 0 )
+        {
+        iWindowTopLeft.iY = 0;
+        }
+    else if( iWindowTopLeft.iY + iWindowSize.iHeight > iScreenDevice.SizeInPixels().iHeight )
+        {
+        iWindowTopLeft.iY = iScreenDevice.SizeInPixels().iHeight - iWindowSize.iHeight;
+        }
+    }
+
+TInt CPlayerWindow::ExecuteOperation( TInt aOperation )
+    {
+    TInt err = KErrNone;
+    
+    switch( aOperation )
+        {
+        case EOperation_StopPlay:
+            {
+            if( iPlayState == EStopped )
+                {
+                err = Play();
+                iPlayState = EPlaying;
+                }
+            else
+                {
+                err = Stop();
+                iPlayState = EStopped;
+                }
+            break;
+            }
+        case EOperation_PauseResume:
+            {
+            if( iPlayState == EPaused )
+                {
+                err = Play();
+                iPlayState = EPlaying;
+                }
+            else if( iPlayState == EPlaying )
+                {
+                err = Pause();                    
+                iPlayState = EPaused;
+                }
+            break;
+            }
+        case EOperation_Pause:
+            {
+            if( iPlayState == EPlaying )
+                {
+                err = Pause();                    
+                iPlayState = EPaused;
+                }
+            break;
+            }
+        case EOperation_Resume:
+            {
+            if( iPlayState == EPaused )
+                {
+                err = Play();
+                iPlayState = EPlaying;
+                }
+            break;
+            }
+        case EOperation_SeekBack:
+            {
+            // Reverse seek 5 seconds
+            TInt64 pos = Position().Int64();
+            pos -= 5000000;
+            err = Seek( pos );
+            break;
+            }
+        case EOperation_SeekForward:
+            {
+            // Forward 5 seconds
+            TInt64 pos = Position().Int64();
+            pos += 5000000;
+            err = Seek( pos );
+            break;
+            }
+        case EOperation_SeekStart:
+            {
+            err = Seek( 0 );
+            break;
+            }
+        case EOperation_SeekEnd:
+            {
+            // Seek to 5 seconds before the end of the clip.
+            TInt64 pos = iDuration.Int64() - 5000000;
+            err = Seek( pos );
+            break;
+            }
+        case EOperation_FrameStepForward:    
+            {
+            err = StepForward();
+            break;
+            }
+        case EOperation_FrameStepBackward:    
+            {
+            err = StepBackward();
+            break;
+            }
+        case EOperation_IncreasePlayVelocity:    
+            {
+            iCurrentVelocity += 50;
+            err = SetPlayVelocity( iCurrentVelocity );
+            break;
+            }
+        case EOperation_DecreasePlayVelocity:    
+            {
+            iCurrentVelocity -= 50;
+            err = SetPlayVelocity( iCurrentVelocity );
+            break;
+            }
+        case EOperation_IncreaseHeightScale:
+            {
+            if( iHeightScaleIndex < KScalePercentagesCount )
+                {
+                iHeightScaleIndex++;                            
+                }
+            err = UpdateScaleFactor();
+            break;
+            }
+        case EOperation_DecreaseHeightScale:
+            {
+            if( iHeightScaleIndex > 0 )
+                {
+                iHeightScaleIndex--;
+                }                    
+            err = UpdateScaleFactor();
+            break;
+            }                
+        case EOperation_IncreaseWidthScale:    
+            {
+            if( iWidthScaleIndex < KScalePercentagesCount )
+                {
+                iWidthScaleIndex++;                            
+                }                        
+            err = UpdateScaleFactor();
+            break;
+            }                
+        case EOperation_DecreaseWidthScale:    
+            {
+            if( iWidthScaleIndex > 0 )
+                {
+                iWidthScaleIndex--;                            
+                }                        
+            err = UpdateScaleFactor();
+            break;
+            }
+        case EOperation_Rotate:
+            {
+            err = NextRotationAngle();
+            break;
+            }                
+        case EOperation_Autoscale:
+            {
+            err = NextAutoscaleMode();
+            break;
+            }                
+        case EOperation_ClipRectangle:    
+            {
+            iClipModeIndex = (iClipModeIndex+1) % KRectangleModeCount;
+            err = SetClipRectangle(Rectangle( iClipModeIndex ));                        
+            break;
+            }                
+        case EOperation_Extent:    
+            {
+            // Advance to next extent mode.
+            iExtentModeIndex = (iExtentModeIndex+1) % KRectangleModeCount;
+            err = SetVideoExtent(Rectangle( iExtentModeIndex ));
+            break;
+            }                
+        case EOperation_ResetToDefaults:    
+            {
+            err = ResetToDefaults();
+            break;
+            }
+        case EOperation_IncreaseVolume:
+            {
+            err = SetVolume( iCurrentVolume + iMaxVolume / 10 );
+            break;
+            }
+        case EOperation_DecreaseVolume:
+            {
+            err = SetVolume( iCurrentVolume - iMaxVolume / 10 );
+            break;
+            }
+        case EOperation_MaximumVolume:
+            {
+            err = SetVolume( iMaxVolume );
+            break;
+            }            
+        case EOperation_Mute:
+            {
+            err = SetVolume( 0 );
+            break;
+            }
+        case EOperation_BalanceLeft:
+            {
+            err = SetBalance( iCurrentBalance - 10 );
+            break;
+            }
+        case EOperation_BalanceRight:
+            {
+            err = SetBalance( iCurrentBalance + 10 );
+            break;
+            }
+        case EOperation_BalanceCenter:
+            {
+            err = SetBalance( iBalanceCenter );
+            break;
+            }
+        case EOperation_BalanceMaxLeft:
+            {
+            err = SetBalance( iBalanceMaxLeft );
+            break;
+            }
+        case EOperation_BalanceMaxRight:
+            {
+            err = SetBalance( iBalanceMaxRight );
+            break;
+            }                 
+        case EOperation_MoveWindowUp:
+            {
+            iWindowTopLeft.iY -= KMoveWindowDelta;
+            CheckWindowLimits();
+            iWindow.SetExtent( iWindowTopLeft, iWindowSize );
+            break;
+            }
+        case EOperation_MoveWindowDown:
+            {
+            iWindowTopLeft.iY += KMoveWindowDelta;
+            CheckWindowLimits();
+            iWindow.SetExtent( iWindowTopLeft, iWindowSize );
+            break;
+            }
+        case EOperation_MoveWindowLeft:
+            {
+            iWindowTopLeft.iX -= KMoveWindowDelta;
+            CheckWindowLimits();
+            iWindow.SetExtent( iWindowTopLeft, iWindowSize );
+            break;
+            }
+        case EOperation_MoveWindowRight:
+            {
+            iWindowTopLeft.iX += KMoveWindowDelta;
+            CheckWindowLimits();
+            iWindow.SetExtent( iWindowTopLeft, iWindowSize );
+            break;
+            }
+        case EOperation_ChangeWindowSize:                
+            {
+            iWindowSizeDivisor = (iWindowSizeDivisor % 5) + 1;
+
+            iWindowSize = TSize(iDefaultWindowSize.iWidth/iWindowSizeDivisor,
+                                iDefaultWindowSize.iHeight/iWindowSizeDivisor);
+            CheckWindowLimits();
+            iWindow.SetExtent( iWindowTopLeft, iWindowSize);
+            SetVideoExtent( TRect(iWindowSize) );
+            
+            if( iBorderColor != 0 )
+                {
+                DrawBorderAroundWindow();
+                }
+            break;
+            }
+        case EOperation_ToggleWindowTransparency:                
+            {
+            // Black is completely transparent, and white is completely opaque.
+            iWindowTransparent = !iWindowTransparent;
+            iWindow.SetTransparencyFactor( KRgbGray );
+            iWindow.SetSurfaceTransparency( iWindowTransparent );
+            break;
+            }
+        case EOperation_DrawWhiteBorderAroundWindow:
+            {
+            iBorderColor = 0xfefefe;
+            DrawBorderAroundWindow();
+            break;
+            }
+        case EOperation_DrawRedBorderAroundWindow:
+            {
+            iBorderColor = KRgbRed;
+            DrawBorderAroundWindow();
+            break;
+            }
+        case EOperation_ClearBorderAroundWindow:
+            {            
+            iBorderColor = 0;
+            if( iGc )
+                {
+                iGc->Activate(iWindow);            
+                iWindow.Invalidate();
+                iWindow.BeginRedraw();            
+                iGc->Reset();            
+                iWindow.EndRedraw();                        
+                iGc->Deactivate();
+                }
+            break;
+            }
+        default:
+            {
+            // Give operation to subclass to execute.
+            err = DoExecuteOperation( aOperation );
+            break;
+            }
+        }    
+    
+    return err;
+    }
+
+void CPlayerWindow::DrawBorderAroundWindow()
+    {
+    if( iGc )
+        {
+        iGc->Activate(iWindow);
+        
+        iWindow.Invalidate();
+        iWindow.BeginRedraw();
+        
+        iGc->Reset();
+        
+        iGc->SetPenColor(iBorderColor);
+        iGc->SetPenStyle(CWindowGc::ESolidPen);            
+        iGc->DrawRect( TRect(iWindow.Size()) );
+                    
+        iWindow.EndRedraw();
+        
+        iGc->Deactivate();
+        }
+    }
+
+
+void CPlayerWindow::WriteAdvancedText( CWindowGc& aGc, TInt aColumn, TInt& aRow, TInt aRowIncrement )
+    {
+    TRect rect = Rectangle( iExtentModeIndex );
+    iBuffer.Format( _L("Extent: (%i,%i) (%i,%i)"), rect.iTl.iX, rect.iTl.iY, rect.iBr.iX, rect.iBr.iY );
+    aGc.DrawText( iBuffer, TPoint(aColumn, aRow) );
+    aRow += aRowIncrement;
+                    
+    rect = Rectangle( iClipModeIndex );
+    iBuffer.Format( _L("Clip: (%i,%i) (%i,%i)"), rect.iTl.iX, rect.iTl.iY, rect.iBr.iX, rect.iBr.iY );
+    aGc.DrawText( iBuffer, TPoint(aColumn, aRow) );
+    aRow += aRowIncrement;
+    
+    iBuffer.Copy( _L("Autoscale: ") );
+    AppendAutoscaleModeText( iBuffer );
+    aGc.DrawText( iBuffer, TPoint(aColumn, aRow) );
+    aRow += aRowIncrement;
+    
+    aGc.DrawText( _L("Scale factor:"), TPoint(aColumn, aRow) );
+    aRow += aRowIncrement;
+    
+    iBuffer.Format( _L("width=%.1f"), KScalePercentages[iWidthScaleIndex] );
+    aGc.DrawText( iBuffer, TPoint(aColumn+25, aRow) );
+    aRow += aRowIncrement;
+    
+    iBuffer.Format( _L("height=%.1f"), KScalePercentages[iHeightScaleIndex] );
+    aGc.DrawText( iBuffer, TPoint(aColumn+25, aRow) );
+    aRow += aRowIncrement;
+    
+    iBuffer.Format( _L("Rotation: %i"), RotationAngle() );
+    aGc.DrawText( iBuffer, TPoint(aColumn, aRow) );
+    aRow += aRowIncrement;
+    
+    iBuffer.Format( _L("Velocity: %i"), iCurrentVelocity );
+    aGc.DrawText( iBuffer, TPoint(aColumn, aRow) );
+    aRow += aRowIncrement;
+    
+    iBuffer.Format( _L("Volume: %i/%i"), iCurrentVolume, iMaxVolume );
+    aGc.DrawText( iBuffer, TPoint(aColumn, aRow) );
+    aRow += aRowIncrement;
+    
+    iBuffer.Format( _L("Balance: %i"), iCurrentBalance );
+    aGc.DrawText( iBuffer, TPoint(aColumn, aRow) );
+    aRow += aRowIncrement;    
+    }
+
+void CPlayerWindow::MoveWindow( TPoint aCenter )
+    {    
+    iWindowTopLeft.iX = aCenter.iX - iWindowSize.iWidth / 2;
+    iWindowTopLeft.iY = aCenter.iY- iWindowSize.iHeight / 2;;
+    CheckWindowLimits();
+    iWindow.SetExtent( iWindowTopLeft, iWindowSize );
+    }
+
+void CPlayerWindow::SetOrdinalPosition( TInt aPosition )
+    {
+    iWindow.SetOrdinalPosition( aPosition );
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/consoleplayer/thumbnail/group/bld.inf	Fri Sep 03 19:37:02 2010 -0500
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ * This file provides the information required for building the
+ * Thumbnail Tester test app.
+ *
+ */
+
+PRJ_MMPFILES
+
+thumbnailtester.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/consoleplayer/thumbnail/group/create_sis.bat	Fri Sep 03 19:37:02 2010 -0500
@@ -0,0 +1,22 @@
+cls
+@echo off
+echo.
+
+rem Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+rem All rights reserved.
+rem This component and the accompanying materials are made available
+rem under the terms of the "Eclipse Public License v1.0"
+rem which accompanies this distribution, and is available
+rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+rem
+rem Initial Contributors:
+rem Nokia Corporation - initial contribution.
+rem
+rem Contributors:
+rem
+echo Description:  Thumbnail Tester package creation utility
+rem
+
+del consoleplayer.sis*
+makesis thumbnailtester.pkg thumbnailtester.sis
+signsis thumbnailtester.sis thumbnailtester.sisx rd.crt rd.key
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/consoleplayer/thumbnail/group/thumbnailtester.mmp	Fri Sep 03 19:37:02 2010 -0500
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ * This file provides the information required for building the
+ * Thumbnail Tester test app.
+ */
+
+#include <platform_paths.hrh>
+
+TARGET        thumbnailtester.exe
+TARGETTYPE    exe
+UID           0x0 0xE9081726
+VENDORID      VID_DEFAULT
+
+CAPABILITY    ALL -TCB
+
+EPOCSTACKSIZE 0x5000             //20KB
+EPOCHEAPSIZE  0x100000 0x1000000 //1MB-16MB
+
+START RESOURCE  thumbnailtester_reg.rss
+TARGETPATH 	    \private\10003a3f\apps
+END 
+
+USERINCLUDE   ..\..\common
+
+SOURCEPATH    ..\..\common
+SOURCE        testappbase.cpp
+
+SOURCEPATH    ..\src
+SOURCE        thumbnailtester.cpp
+SOURCE        yuv2rgb24.cpp
+
+MW_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE \epoc32\include
+SYSTEMINCLUDE \epoc32\include\stdapis
+USERINCLUDE   \sf\mw\helix\helix_ren\src\datatype\tools\metadataeng\common\pub
+USERINCLUDE   \sf\mw\helix\helix_ren\src\datatype\tools\metadataeng\utility\platform\symbian
+
+STATICLIBRARY hxmetadatautil.lib
+LIBRARY       flogger.lib
+
+LIBRARY       euser.lib
+LIBRARY       efsrv.lib
+LIBRARY	      gce.lib 
+LIBRARY       ws32.lib 
+LIBRARY       gdi.lib
+LIBRARY		    fntstr.lib
+LIBRARY       fbscli.lib
+LIBRARY       estor.lib 
+LIBRARY       ecom.lib
+
+// for volume key handling
+LIBRARY       remconcoreapi.lib
+LIBRARY       remconinterfacebase.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/consoleplayer/thumbnail/group/thumbnailtester.pkg	Fri Sep 03 19:37:02 2010 -0500
@@ -0,0 +1,35 @@
+;
+; Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description: Thumbnail Tester - UREL build
+;
+; File: thumbnailtester.pkg
+
+;Languages
+&EN
+
+;Header
+#{"thumbnailtester EXE"},(0xE9081726),1,0,0
+
+;Series 60 v5.0
+[0x1028315F], 0,0,0, {"Series60ProductID"}
+
+;Localised Vendor name
+%{"Nokia"}
+
+;Unique Vendor name
+:"Nokia"
+
+;Files To Copy...<src> <destination>
+"/epoc32/release/armv5/urel/thumbnailtester.exe"		           -"!:/sys/bin/thumbnailtester.exe"
+"/epoc32/data/z/private/10003a3f/apps/thumbnailtester_reg.rsc" -"!:/private/10003a3f/import/apps/thumbnailtester_reg.rsc"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/consoleplayer/thumbnail/group/thumbnailtester_reg.rss	Fri Sep 03 19:37:02 2010 -0500
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ * Resource file for registering the Thumbnail Tester to the Application
+ * Menu.
+ * 
+ */
+
+#include <appinfo.rh>
+
+UID2 KUidAppRegistrationResourceFile
+UID3 0xE9081726
+
+RESOURCE APP_REGISTRATION_INFO
+{
+    app_file="thumbnailtester";  
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/consoleplayer/thumbnail/src/brightnesscontrast.h	Fri Sep 03 19:37:02 2010 -0500
@@ -0,0 +1,64 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   Const parameters for brightness/constrast enhancement
+*                The tuning has 9 steps, each represented by 3 parameters.
+*                The smaller indices in the table generate "lighter" pictures.
+*
+*/
+
+
+
+#ifndef     __BRIGHTNESSCONTRAST_H__
+#define     __BRIGHTNESSCONTRAST_H__
+
+
+const TInt KMinBrightnessContrastIndex = 0;
+const TInt KMedBrightnessContrastIndex = 10;
+const TInt KMaxBrightnessContrastIndex = 20;
+
+const TInt KMaxBCInputIndex = 100;
+
+struct SEnhParam {
+    TReal   a;
+    TReal   b;
+    TReal   g;
+};
+
+const struct SEnhParam KBrightnessContrastEnhParam[21] = {   
+   {2.35, -0.1215, 0.5},
+   {2.17, -0.0936, 0.55},
+   {2, -0.07, 0.6},
+   {1.84, -0.0504, 0.65},
+   {1.69, -0.0345, 0.7},
+   {1.55, -0.022, 0.75},
+   {1.42, -0.0126, 0.8},
+   {1.3, -0.006, 0.85},
+   {1.19, -0.0019, 0.9},
+   {1.09, 0, 0.95},
+   {1, 0, 1},
+   {1.04, -0.04, 1.05},
+   {1.09, -0.0891, 1.1},
+   {1.15, -0.147, 1.15},
+   {1.22, -0.2134, 1.2},
+   {1.3, -0.288, 1.25},
+   {1.39, -0.3705, 1.3},
+   {1.49, -0.4606, 1.35},
+   {1.6, -0.558, 1.4},
+   {1.72, -0.6624, 1.45},
+   {1.85, -0.7735, 1.5}
+};
+
+#endif      //  __BRIGHTNESSCONTRAST_H__
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/consoleplayer/thumbnail/src/thumbnailtester.cpp	Fri Sep 03 19:37:02 2010 -0500
@@ -0,0 +1,488 @@
+/*
+ * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ * Source file for the main class of the Thumbnail Tester test app.
+ * 
+ */
+
+#include "thumbnailtester.h"
+#include "yuv2rgb24.h"
+
+#include <e32base.h>
+#include <e32debug.h>
+#include <f32file.h>
+
+const TInt KFontSize = 15;
+
+// Thumbnail tester implementation
+
+void CThumbnailTester::ExecuteL()
+    {
+    CThumbnailTester* self = new(ELeave) CThumbnailTester;
+    CleanupStack::PushL( self );
+    self->InitL();
+    self->Main();
+    CleanupStack::PopAndDestroy( self );    
+    }
+    
+CThumbnailTester::CThumbnailTester() : 
+    CTestAppBase( KFontSize )
+    {    
+    }
+    
+CThumbnailTester::~CThumbnailTester()
+    {
+    Cancel();
+    
+    if( iGc && iFullScreenWindow )
+	      {
+        iGc->Activate(*iFullScreenWindow);
+        
+        iFullScreenWindow->Invalidate();
+        iFullScreenWindow->BeginRedraw();
+        
+        iGc->Reset();
+        
+        iGc->UseFont(iFont);                
+        iGc->SetBrushColor(KRgbDarkBlue);
+        
+        iGc->Clear();
+
+        if( iFinalResult == KErrNone )
+            {
+            // KRgbWhite seems to be having problems (0xffffff) in some emulators,
+            // but 0xfefefe is working, so use that instead of white.        
+            iGc->SetPenColor(0xfefefe);                 
+            }
+        else
+            {
+            iGc->SetPenColor(KRgbRed);
+            }
+    
+        iBuffer.Format( _L("THUMBNAILTESTER EXIT, result = %i"), iFinalResult );
+        iGc->DrawText( iBuffer, TPoint(5, 20) );
+       
+        iFullScreenWindow->EndRedraw();
+        
+        iGc->Deactivate();
+        
+        iFullScreenWindow->SetVisible( ETrue );
+        
+        WaitForAnyKey();
+        }    
+    
+    }
+    
+void CThumbnailTester::InitL()
+    {
+    BaseConstructL( NULL, 0 );  // this app doesn't use the option pages concept
+    
+    iFullScreenWindow = new(ELeave) RWindow( iWs );
+    User::LeaveIfError( iFullScreenWindow->Construct( *iWindowGroup, KNullWsHandle ) );
+    iFullScreenWindow->SetExtent( TPoint(0,0), iDisplaySize );
+    iFullScreenWindow->SetNonTransparent();
+    iFullScreenWindow->SetBackgroundColor(KRgbBlack);
+    iFullScreenWindow->SetVisible(false);
+    iFullScreenWindow->Activate();
+        
+    iGc->Activate(*iFullScreenWindow);
+
+    iFullScreenWindow->BeginRedraw();
+    
+    iGc->Reset();    
+    iGc->UseFont(iFont);                
+    iGc->SetBrushStyle(CWindowGc::ESolidBrush);
+    iGc->SetBrushColor(KRgbBlack);    
+    iGc->Clear();
+    
+    iFullScreenWindow->EndRedraw();
+    
+    iGc->Deactivate();    
+    }
+
+void CThumbnailTester::Main()
+    {    
+    TRAPD( err, MainL() ); 
+    
+    RDebug::Printf( "THUMBNAILTESTER Completed, err=%i", err );    
+    }
+
+void CThumbnailTester::MainL()        
+    {
+    TFileName filename;
+    
+    SelectFileWithHistoryL( TPoint(0,0), iDisplaySize, filename, KHistoryFilename, KMaxHistoryEntries );
+    
+    GenerateThumbnailL( filename );
+    }
+  
+void CThumbnailTester::GenerateThumbnailL( TDes& aFileName )
+    {
+    SelectIntegerL( TPoint(0,0), iDisplaySize, _L("Select starting position(seconds):"), 0, 9999, iStartPositionInMs );
+    
+    // Convert from seconds to ms.
+    iStartPositionInMs *= 1000;
+        
+    _LIT( KFull,   "Full speed" );
+    _LIT( KMedium, "100 millisecond delay" );
+    _LIT( KSlow,   "1 second delay" );
+
+    RPointerArray<TDesC> speed;
+    speed.Append( &KFull );
+    speed.Append( &KMedium );
+    speed.Append( &KSlow );
+    
+    TInt index = SelectFromListL( TPoint(0,0), iDisplaySize, _L("Select speed:"), speed );
+    
+    speed.Reset();
+    
+    switch( index )
+        {
+        case 0:
+            iDelayBetweenFrames = 0;
+            break;
+        case 1:
+            iDelayBetweenFrames = 100000;  // 1/10 second
+            break;
+        case 2:
+            iDelayBetweenFrames = 1000000;  // 1 second
+            break;
+        }
+
+    RFile file;    
+    User::LeaveIfError( file.Open( iFs, aFileName, EFileShareReadersOnly | EFileStream | EFileRead ) );
+    
+    iThumbnailUtility = CHXThumbnailUtility::NewL(*this);
+
+    bool done = false;
+
+    iStopThumbnailGeneration = false;
+    
+    StartMonitoringWindowEvents();
+    
+    TInt originalStartPositionInMs = iStartPositionInMs;
+    
+    while( !done )
+        {
+        iThumbnailUtility->OpenFileL( file, iStartPositionInMs );
+
+        // OpenFileL will block until all bitmaps have been passed to PacketReady.
+        
+        // This isn't necessarily exact, but advance the start position by the time represented
+        // by the number of renderered frames.
+        iStartPositionInMs = originalStartPositionInMs + (iTotalFramesRendered * 1000) / iFrameRateInSec;
+                
+        done = ((iFramesRendered < 5) || iStopThumbnailGeneration);
+        
+        iFramesRendered = 0;
+        }
+    
+    Cancel();
+ 
+    WaitForAnyKey();
+    
+    delete iThumbnailUtility;
+    iThumbnailUtility = NULL;
+    
+    file.Close();    
+    }
+           
+bool CThumbnailTester::ConsumeKeyEvent( TInt /*aKeyCode*/ )
+    {
+    // Stop thumbnail generation when a key is pressed.
+    iStopThumbnailGeneration = true;
+    iThumbnailUtility->CancelThumb();
+    return true;
+    }
+
+void CThumbnailTester::ExecuteOperation( TInt aOperation, const TDesC& aOperationText )
+    {    
+    }
+
+void CThumbnailTester::MetaDataReady(TInt aError)
+    {
+    RDebug::Printf( "THUMBNAILTESTER MetadataReady(%i)", aError );
+    
+    // Get basic meta data.
+    
+    TUint lCount = 0;
+    TUint i=0;
+    
+    iThumbnailUtility->GetMetaDataCount(lCount);
+
+    RDebug::Printf( "THUMBNAILTESTER metadata count=%i", lCount );
+    
+    for (i=0; i<lCount; i++)
+        {
+        HBufC *pDes = NULL;           
+        HXMetaDataKeys::EHXMetaDataId id;        
+        iThumbnailUtility->GetMetaDataAt(i, id, pDes);
+
+        const char* key = "";
+        
+        for( TInt j = 0; j < sizeof(HXMetaDataKeyTab)/sizeof(HXMetaDataKeys); j++ )
+            {
+            if( id == HXMetaDataKeyTab[j].m_id )
+                {
+                key = HXMetaDataKeyTab[j].m_pHXKey;
+                }
+            }
+        
+        for( TInt j = 0; j < sizeof(HXStreamMetaDataKeyTab)/sizeof(HXMetaDataKeys); j++ )
+            {
+            if( id == HXStreamMetaDataKeyTab[j].m_id )
+                {
+                key = HXStreamMetaDataKeyTab[j].m_pHXKey;
+                }
+            }
+        
+        RDebug::Printf( "THUMBNAILTESTER metadata[%i] id=%i key=%s", i, id, key );        
+        
+        TInt current = 0;
+        TBuf8<400> outputLine;
+        while( current < pDes->Length() )
+            {
+            char c = pDes->Des()[current];                
+            char c2 = c;
+            if( c2 < ' ' || c2 > '~' )
+                {
+                c2 = ' ';
+                }
+            
+            outputLine.AppendFormat(_L8("%02x/%c "), c, c2 ); 
+            
+            current++;
+            
+            if( (current % 20 == 0) || current == pDes->Length()  )
+                {
+                outputLine.Append( '\0' );
+                RDebug::Printf( (char*)outputLine.Ptr() );
+                outputLine.SetLength(0);
+                }            
+            }        
+        
+        if (id == HXMetaDataKeys::EHXFrameSize && pDes)
+            {
+            TPtr pFrameSizePtr = pDes->Des();
+            _LIT(KChar_x, "x");
+            TInt xLoc = pFrameSizePtr.Find(KChar_x);
+            if (xLoc != KErrNotFound)
+                {                           
+                TLex lexWidth(pFrameSizePtr.Mid(0, xLoc));
+                TLex lexHeight(pFrameSizePtr.Mid(xLoc+1));
+                lexWidth.Val(iWidth);  // Storing into local iWidth variable
+                lexHeight.Val(iHeight);  // Storing into local iHeight variable  
+                }
+            }
+        else if (id == HXMetaDataKeys::EHXDuration && pDes)
+            {
+            TLex lexDuration(pDes->Des());
+            lexDuration.Val(iDuration);
+            }        
+        else if (id == HXMetaDataKeys::EHXFramesPerSecond && pDes)
+            {
+            TLex lexFramesPerSecond(pDes->Des());           
+            lexFramesPerSecond.Val(iFrameRateInSec);            
+            }
+        else if (id == HXMetaDataKeys::EHXClipBitRate && pDes)
+            {
+            TLex lexBitRate(pDes->Des());           
+            lexBitRate.Val(iClipBitRate);            
+            }
+        else if (id == HXMetaDataKeys::EHXVideoBitRate && pDes)
+            {
+            TLex lexBitRate(pDes->Des());           
+            lexBitRate.Val(iVideoBitRate);            
+            }
+        else if (id == HXMetaDataKeys::EHXAudioBitRate && pDes)
+            {
+            TLex lexBitRate(pDes->Des());           
+            lexBitRate.Val(iAudioBitRate);            
+            }
+        
+        } // end for
+    
+    iTotalFrameCount = ( (iDuration+500)/1000 ) * iFrameRateInSec;
+    
+    RDebug::Printf( "THUMBNAILTESTER width=%i", iWidth );
+    RDebug::Printf( "THUMBNAILTESTER height=%i", iHeight );
+    RDebug::Printf( "THUMBNAILTESTER frame rate=%i", iFrameRateInSec );
+    RDebug::Printf( "THUMBNAILTESTER duration=%i", iDuration );
+    RDebug::Printf( "THUMBNAILTESTER frame count=%i", iTotalFrameCount );
+    RDebug::Printf( "THUMBNAILTESTER clip bit rate=%i", iClipBitRate );
+    RDebug::Printf( "THUMBNAILTESTER video bit rate=%i", iVideoBitRate );
+    RDebug::Printf( "THUMBNAILTESTER audio bit rate=%i", iAudioBitRate );
+    }
+
+void CThumbnailTester::PacketReady(TInt /*aError*/, void *pYuvBuffer, TUint32 /*aYuvBufferSize*/)
+    {
+    // TODO: HANDLE aError
+    
+    iFramesRendered++;
+    iTotalFramesRendered++;
+    
+    // Convert from YUV420 to RGB24.
+    
+    const TInt KBytesPerPixel = 3; // 24-bit rgb takes 3 bytes
+    
+    TUint32 rgbBufferSize = iWidth * iHeight * KBytesPerPixel;
+    TUint8 *pRgbBuffer =(TUint8*) User::AllocL(rgbBufferSize);
+        
+    CYuv2Rgb24* yuvConverter = NULL; 
+    TRAPD(err, yuvConverter = new(ELeave) CYuv2Rgb24);
+    
+    // TODO: CHECK ERROR
+
+    TRAP(err, yuvConverter->ConstructL(iWidth, iHeight, iWidth, iHeight))
+
+    // TODO: CHECK ERROR
+
+    TInt scanLineLength = iWidth * KBytesPerPixel;
+    
+    TUint8* yBuf = (TUint8*)pYuvBuffer;
+    TUint8* uBuf = yBuf + iWidth*iHeight;
+    TUint8* vBuf = uBuf + (iWidth*iHeight)/4;    
+    
+    yuvConverter->Convert(yBuf, uBuf, vBuf, iWidth, iHeight, pRgbBuffer, scanLineLength);
+    
+    delete yuvConverter;        
+
+    // Use RGB24 buffer to create CFbsBitmap.
+    
+    CFbsBitmap* pBitmap = NULL;
+    
+    TRAP(err, pBitmap = new (ELeave) CFbsBitmap);
+    if( err == KErrNone )
+        {
+        err = pBitmap->Create(TSize(iWidth, iHeight), EColor16M); 
+    
+        if( err == KErrNone )
+            {
+            // fill image from rgb buffer to input bitmap buffer 
+            TPtr8 linePtr(0,0); 
+            TInt lineLength = pBitmap->ScanLineLength(iWidth, EColor16M); 
+            for(int j=0, i=0; j<iHeight; j++, i+=lineLength)
+                {
+                linePtr.Set(pRgbBuffer+i, lineLength, lineLength);
+                pBitmap->SetScanLine((TDes8&)linePtr,j); 
+                }
+                
+            iGc->Activate(*iSelectionWindow);
+            
+            iSelectionWindow->Invalidate();
+            iSelectionWindow->BeginRedraw();
+            
+            iGc->Reset();
+            
+            iGc->UseFont(iFont);                
+            iGc->SetBrushColor(KRgbDarkBlue);
+            
+            iGc->Clear();
+            
+            // KRgbWhite seems to be having problems (0xffffff) in some emulators,
+            // but 0xfefefe is working, so use that instead of white.        
+            iGc->SetPenColor(0xfefefe);
+
+            TPoint topLeft( iDisplaySize.iWidth/2 - iWidth/2, 
+                            iDisplaySize.iHeight/2 - iHeight/2 ); 
+            iGc->BitBlt( topLeft, pBitmap );
+            
+            const TInt KColumn = 3;
+            const TInt KRowIncrement = KFontSize + 1;
+            TInt row = KRowIncrement;
+
+            iBuffer.Format( _L("Frame # %i"), iFramesRendered );
+            iGc->DrawText( iBuffer, TPoint(KColumn, row) );
+            row += KRowIncrement;
+
+            iBuffer.Format( _L("Total frames rendered: %i"), iTotalFramesRendered );
+            iGc->DrawText( iBuffer, TPoint(KColumn, row) );
+            row += KRowIncrement;
+
+            iBuffer.Format( _L("Start time(ms): %i"), iStartPositionInMs );
+            iGc->DrawText( iBuffer, TPoint(KColumn, row) );
+            row += KRowIncrement;
+
+            iBuffer.Format( _L("Display size: %ix%i"), iDisplaySize.iWidth, iDisplaySize.iHeight );
+            iGc->DrawText( iBuffer, TPoint(KColumn, row) );
+            row += KRowIncrement;
+            
+            iBuffer.Format( _L("Video size: %ix%i"), iWidth, iHeight );
+            iGc->DrawText( iBuffer, TPoint(KColumn, row) );
+            row += KRowIncrement;            
+            
+            iBuffer.Format( _L("Total frame count: %i"), iTotalFrameCount );
+            iGc->DrawText( iBuffer, TPoint(KColumn, row) );
+            row += KRowIncrement;            
+            
+            iBuffer.Format( _L("Duration: %i"), iDuration );
+            iGc->DrawText( iBuffer, TPoint(KColumn, row) );
+            row += KRowIncrement;            
+            
+            iBuffer.Format( _L("Frame rate: %i"), iFrameRateInSec );
+            iGc->DrawText( iBuffer, TPoint(KColumn, row) );
+            row += KRowIncrement;            
+            
+            iBuffer.Format( _L("Clip bit rate: %i"), iClipBitRate );
+            iGc->DrawText( iBuffer, TPoint(KColumn, row) );
+            row += KRowIncrement;            
+            
+            iBuffer.Format( _L("Video bit rate: %i"), iVideoBitRate );
+            iGc->DrawText( iBuffer, TPoint(KColumn, row) );
+            row += KRowIncrement;            
+            
+            iBuffer.Format( _L("Audio bit rate: %i"), iAudioBitRate );
+            iGc->DrawText( iBuffer, TPoint(KColumn, row) );
+            row += KRowIncrement;            
+
+            iGc->DrawText( _L("<Press key to stop then another to exit>"), TPoint(KColumn, iDisplaySize.iHeight-10) );
+            
+            iSelectionWindow->EndRedraw();
+            
+            iGc->Deactivate();
+            
+            iSelectionWindow->SetVisible( ETrue );            
+            }
+        
+        delete pBitmap;
+        }
+    
+    delete pRgbBuffer;    
+
+    User::After( iDelayBetweenFrames );    
+    }
+
+void CThumbnailTester::EndOfPackets()
+    {
+    RDebug::Printf( "THUMBNAILTESTER end of packets" );
+    }
+
+GLDEF_C TInt E32Main()
+    {
+    __UHEAP_MARK;
+    
+    CActiveScheduler* scheduler = new CActiveScheduler;
+    CTrapCleanup* cleanup = CTrapCleanup::New();
+    if( scheduler != NULL && cleanup != NULL )
+    {
+        CActiveScheduler::Install( scheduler );
+        TRAP_IGNORE( CThumbnailTester::ExecuteL() );
+    }
+    delete cleanup;
+    delete scheduler;
+    REComSession::FinalClose();
+    __UHEAP_MARKEND;
+    return 0;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/consoleplayer/thumbnail/src/thumbnailtester.h	Fri Sep 03 19:37:02 2010 -0500
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ * The header for the main class of the ConsolePlayer test app.
+ * 
+ */
+
+#ifndef __CONSOLE_PLAYER_H__
+#define __CONSOLE_PLAYER_H__
+
+#include <e32msgqueue.h>
+
+#include "hxtnutil.h"
+#include "testappbase.h"
+
+const TInt KMaxHistoryEntries = 10;
+_LIT( KHistoryFilename, "c:\\thumbnail_tester_history.txt" );
+
+class CThumbnailTester : public CTestAppBase,
+                         private MHXThumbnailUtilityImplObserver
+                       
+{
+public: // Methods
+
+    static void ExecuteL();
+    
+private: // Methods
+
+    CThumbnailTester(); 
+
+    ~CThumbnailTester();
+
+    void InitL();
+
+    void Main();
+        
+    void MainL();
+    
+    void GenerateThumbnailL( TDes& aFileName );
+    
+    // inherited from CTestAppBase
+    virtual bool ConsumeKeyEvent( TInt aKeyCode );
+    virtual void ExecuteOperation( TInt aOperation, const TDesC& aOperationText );
+
+private:
+    
+    // inherited from MHXThumbnailUtilityImplObserver
+    virtual void MetaDataReady(TInt aError);
+    virtual void PacketReady(TInt aError, void *pData, TUint32 aDataSize);    
+    virtual void EndOfPackets();
+    
+    TBuf<120>             iBuffer;
+    RWindow*              iFullScreenWindow;    
+    CHXThumbnailUtility*  iThumbnailUtility;
+    TInt                  iFinalResult;
+    TInt                  iStartPositionInMs;
+    TInt                  iFramesRendered;
+    TInt                  iTotalFramesRendered;
+    TInt                  iWidth;
+    TInt                  iHeight;
+    TUint                 iClipBitRate;
+    TUint                 iVideoBitRate;
+    TUint                 iAudioBitRate;
+    TUint                 iFrameRateInSec;
+    TUint                 iDuration;
+    TInt                  iTotalFrameCount;
+    TInt                  iDelayBetweenFrames;
+    bool                  iStopThumbnailGeneration;
+    
+    };
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/consoleplayer/thumbnail/src/yuv2rgb24.cpp	Fri Sep 03 19:37:02 2010 -0500
@@ -0,0 +1,417 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   Implementation of class CYuv2Rgb24.
+*                YUV to EColor16M colorspace converter concrete classes 
+*
+*/
+
+
+
+
+
+//  EXTERNAL RESOURCES  
+
+
+//  Include Files  
+
+#include <e32math.h>
+#include "yuv2rgb24.h"
+#include "brightnesscontrast.h"
+
+
+//  MEMBER FUNCTIONS
+
+
+//=============================================================================
+
+/*
+-----------------------------------------------------------------------------
+
+    CYuv2Rgb24
+
+    CYuv2Rgb24()
+
+    Standard C++ constructor
+
+-----------------------------------------------------------------------------
+*/
+
+CYuv2Rgb24::CYuv2Rgb24()
+{
+    iRgbLookupTable = 0;
+    iGamma = 65536;
+    iBrightnessContrast = KMedBrightnessContrastIndex;
+
+}
+
+
+
+/*
+-----------------------------------------------------------------------------
+
+    CYuv2Rgb24
+
+    ~CYuv2Rgb24()
+
+    Standard C++ destructor
+
+-----------------------------------------------------------------------------
+*/
+
+CYuv2Rgb24::~CYuv2Rgb24()
+{
+    User::Free(iRgbLookupTable);
+}
+
+
+
+/*
+-----------------------------------------------------------------------------
+
+    CYuv2Rgb24
+
+    ConstructL()
+
+    Standard Symbian OS second-phase constructor. Initializes the object.
+
+-----------------------------------------------------------------------------
+*/
+
+void CYuv2Rgb24::ConstructL(TUint aWidth, TUint aHeight, TUint aMaxWidth, TUint aMaxHeight)
+{
+    // Remember the dimensions
+//    __ASSERT_ALWAYS(((aWidth & 1) == 0) && ((aHeight & 1) == 0),
+//                    User::Leave(KErrArgument));
+    iWidth = aWidth;
+    iHeight = aHeight;
+    if ( iWidth > aMaxWidth ) {
+        iCropWidth = (iWidth-aMaxWidth)/2;
+        iWidth = aMaxWidth;
+    }
+    else {
+        iCropWidth = 0;
+    }
+    if ( iHeight > aMaxHeight ) {
+        iCropHeight = (iHeight-aMaxHeight)/2;
+        iHeight = aMaxHeight;
+    }
+    else {
+        iCropHeight = 0;
+    }
+
+    // Allocate the RGB saturate/gamma lookup table    
+    iRgbLookupTable = (TUint8*) User::AllocL(ESaturateLength);
+
+    // Initialize brightness & contrast value, this will calculate the conversion table
+    // Since this uses the median index, it makes no difference if the preferred 
+    // enhancement is this or gamma. Furthermore, changes to the value will be done using
+    // the appropriate method.
+    SetBrightnessContrast(KMaxBCInputIndex/2);
+}
+
+
+
+/*
+-----------------------------------------------------------------------------
+
+    CYuv2Rgb24
+
+    SetGamma()
+
+    Sets the conversion gamma value and recalculates the look-up table
+
+-----------------------------------------------------------------------------
+*/
+
+void CYuv2Rgb24::SetGamma(TInt aGamma)
+{
+    TInt i, v;
+    TReal vNorm;
+    
+    // Remember gamma and convert it to floating point
+    iGamma = aGamma;
+    TReal fGamma = TReal(iGamma) / TReal(65536);
+
+    // Calculate table entries for all possible RGB values:
+    for ( i = 0; i < ESaturateLength; i++ )
+    {
+        // Actual RGB value for this table index
+        v = i - ESaturateOffset;
+
+        // Saturate if <0 or >255, otherwise calculate gamma       
+        if ( v < 0 )
+            v = 0;
+        else if ( v > 255 )
+            v = 255;
+        else
+        {
+            // Normalize v:
+            vNorm = TReal(v) / TReal(255);
+
+            // Gamma-correct: v = v ^ gamma
+            Math::Pow(vNorm, vNorm, fGamma);
+
+            // Scale back to [0..255] and clamp:
+            vNorm = (TReal(255) * vNorm) + 0.5;
+            v = (TInt) vNorm;
+            if ( v < 0 ) v = 0;
+            if ( v > 255 ) v = 255;
+        }
+
+        // 24bpp RGB has range [0..255] for all components, store to table:
+        iRgbLookupTable[i] = (TUint8) v;
+    }
+}
+
+/*
+-----------------------------------------------------------------------------
+
+    CYuv2Rgb24
+
+    SetBrightnessContrast()
+
+    Sets the index to the predefined brightness&contrast lookup table 
+    (KBrightnessContrastEnhParam) and recalculates the RGB look-up table
+    The algorithm was developed by IMAAMI for Kenny display.
+
+-----------------------------------------------------------------------------
+*/
+void CYuv2Rgb24::SetBrightnessContrast(TInt aBCIndex)
+{
+    TInt i, v;
+    TReal vNorm;
+    
+    // Convert & remember brightness-contrast index. aBCIndex == 0 to KMaxBCInputIndex.
+    iBrightnessContrast = (aBCIndex*KMaxBrightnessContrastIndex)/KMaxBCInputIndex;
+
+    // Calculate table entries for all possible RGB values:
+    for ( i = 0; i < ESaturateLength; i++ )
+    {
+        // Actual RGB value for this table index
+        v = 298 * (i - ESaturateOffset - 16) / 256;
+        // (see Convert())
+
+        // Saturate if <0 or >255, otherwise calculate value
+        if ( v < 0 )
+            v = 0;
+        else if ( v > 255 )
+            v = 255;
+        else
+        {
+
+            // Normalize v:
+            vNorm = TReal(v) / TReal(255);
+
+            vNorm = KBrightnessContrastEnhParam[iBrightnessContrast].a * vNorm + KBrightnessContrastEnhParam[iBrightnessContrast].b;
+            if ( vNorm < 0 ) 
+                vNorm = 0;
+            else if ( vNorm > 1 )
+                vNorm = 1;
+            Math::Pow( vNorm, vNorm, KBrightnessContrastEnhParam[iBrightnessContrast].g );
+
+            // Scale back to [0..255] and clamp:
+            vNorm = (TReal(255) * vNorm) + 0.5;
+            v = (TInt) vNorm;
+            if ( v < 0 ) v = 0;
+            if ( v > 255 ) v = 255;
+        }
+
+        // 24bpp RGB has range [0..255] for all components, store to table:
+        iRgbLookupTable[i] = (TUint8) v;
+    }
+}
+
+
+/*
+-----------------------------------------------------------------------------
+
+    CYuv2Rgb24
+
+    Convert()
+
+    Converts a YUV frame to a EColor16M frame
+
+-----------------------------------------------------------------------------
+*/
+
+void CYuv2Rgb24::Convert(const TUint8 *aYBuf, const TUint8 *aUBuf,
+                         const TUint8 *aVBuf,
+                         TUint aBufWidth, TUint aBufHeight,
+                         TUint8 *aTarget, TUint aTargetScanlineLength)
+{
+    TUint cols;
+    TUint rows = iHeight;
+    TUint8 *target;
+    TUint8 *target2;
+    const TUint8 *yb, *yb2;
+    TInt rc, gc, bc;
+    TInt y;
+    TInt uval, vval;
+    TUint8 val;
+
+
+    __ASSERT_ALWAYS((aBufWidth >= iWidth) && (aBufHeight >= iHeight),
+                    User::Invariant());
+
+    // Cropping needed? 
+    if ( iCropWidth > 0 ) {
+        //sets offset to buffers; from now on increments below will always result the same offset, since the increment is aBufWidth
+        aYBuf += iCropWidth;
+        aUBuf += iCropWidth/2;
+        aVBuf += iCropWidth/2;
+    }
+    if ( iCropHeight > 0 ) {
+        //skip lines on top
+        aYBuf += iCropHeight*aBufWidth;
+        aUBuf += (iCropHeight/2)*aBufWidth/2;
+        aVBuf += (iCropHeight/2)*aBufWidth/2;
+    }
+    // We don't interpolate the chrominance values at all, since that way we
+    // can save a lot of multiplications. This actually doesn't affect the
+    // subjective picture quality much, if at all, with natural images.
+
+    // Conversion is done 2x2 pixels at a time
+
+    // Luminance-only conversion?
+    if ( (aUBuf != NULL) && (aVBuf != NULL) )
+    {
+        // Full conversion
+        
+        // Convert all rows, two at a time
+        while ( rows )
+        {
+            // Convert all pixels in this row, two at a time
+            cols = iWidth;
+            target = aTarget;
+            target2 = aTarget + aTargetScanlineLength;
+            yb = aYBuf;
+            yb2 = aYBuf + aBufWidth;
+        
+            while ( cols )
+            {
+                // Charles Poynton: Color FAQ
+                // (http://www.inforamp.net/~poynton/ColorFAQ.html)
+                // 30. How do I encode Y'CBCR components from computer R'G'B' ?
+
+                // [normalized]
+                // R =  1.1643828125 * (Y-16)  +  1.59602734375 * (Cr-128)
+                // G =  1.1643828125 * (Y-16)  +  -0.39178515625 * (Cb-128) + -0.81296875 * (Cr-128)
+                // B =  1.1643828125 * (Y-16)  +  2.01723046875 * (Cb-128)
+
+                // We'll use fixed-point with 16 bits of fractional part for
+                // accuracy. Besides, 24bpp RGB is not likely to be used in
+                // low-CPU devices in the near future...
+
+                // Red chrominance part for this 2x2 block:
+                vval = ((TInt) aVBuf[0]) - 128;
+                rc =  104597 * vval;
+
+                // Green chrominance:
+                uval = ((TInt) aUBuf[0]) - 128;
+                gc = -25676*uval - 53279*vval;
+
+                // Blue chrominance:
+                bc = 132201 * uval;
+
+                // Upper left pixel y part for all components:
+                y = 76309 * (((TInt) yb[0]) - 16) + 32768; // round up
+
+                // Calculate components and store:
+                // Bitmap format: bbbbbbbb gggggggg rrrrrrrr
+                target[0] = iRgbLookupTable[((y+bc) >> 16) + ESaturateOffset];
+                target[1] = iRgbLookupTable[((y+gc) >> 16) + ESaturateOffset];
+                target[2] = iRgbLookupTable[((y+rc) >> 16) + ESaturateOffset];
+
+                // Upper right pixel:
+                y = 76309 * (((TInt) yb[1]) - 16) + 32768;
+                target[3] = iRgbLookupTable[((y+bc) >> 16) + ESaturateOffset];
+                target[4] = iRgbLookupTable[((y+gc) >> 16) + ESaturateOffset];
+                target[5] = iRgbLookupTable[((y+rc) >> 16) + ESaturateOffset];
+
+                // Lower left:
+                y = 76309 * (((TInt) yb2[0]) - 16) + 32768;
+                target2[0] = iRgbLookupTable[((y+bc) >> 16) + ESaturateOffset];
+                target2[1] = iRgbLookupTable[((y+gc) >> 16) + ESaturateOffset];
+                target2[2] = iRgbLookupTable[((y+rc) >> 16) + ESaturateOffset];
+
+                // Lower right:
+                y = 76309 * (((TInt) yb2[1]) - 16) + 32768;
+                target2[3] = iRgbLookupTable[((y+bc) >> 16) + ESaturateOffset];
+                target2[4] = iRgbLookupTable[((y+gc) >> 16) + ESaturateOffset];
+                target2[5] = iRgbLookupTable[((y+rc) >> 16) + ESaturateOffset];
+
+                // Next two pixels:
+                target += 6;
+                target2 += 6;
+                yb += 2;
+                yb2 += 2;
+                aUBuf++;
+                aVBuf++;
+                cols -= 2;
+            }
+
+            // Next rows
+            rows -= 2;
+            aYBuf += 2*aBufWidth;
+            aUBuf += (aBufWidth - iWidth)/2;
+            aVBuf += (aBufWidth - iWidth)/2;
+            aTarget += 2*aTargetScanlineLength;
+        }
+    }
+    else
+    {
+        // No chrominance given, do a luminance-only conversion
+        
+        // Convert all rows
+        while ( rows )
+        {
+            // Convert all pixels in this row, two at a time
+            cols = iWidth;
+            target = aTarget;
+        
+            while ( cols )
+            {
+                // Do a pixel:
+                y = 76309 * (((TInt) aYBuf[0]) - 16) + 32768;
+                val = iRgbLookupTable[(y >> 16) + ESaturateOffset];
+                target[0] = val;
+                target[1] = val;
+                target[2] = val;
+
+                // And another one:
+                y = 76309 * (((TInt) aYBuf[1]) - 16) + 32768;
+                val = iRgbLookupTable[(y >> 16) + ESaturateOffset];
+                target[3] = val;
+                target[4] = val;
+                target[5] = val;
+
+                // Next two pixels:
+                target += 6;
+                aYBuf += 2;
+                cols -= 2;
+            }
+
+            // Next row
+            rows--;
+            aYBuf += aBufWidth - iWidth;
+            aTarget += aTargetScanlineLength;
+        }
+    }
+}
+
+
+
+
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tsrc/consoleplayer/thumbnail/src/yuv2rgb24.h	Fri Sep 03 19:37:02 2010 -0500
@@ -0,0 +1,56 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   YUV to EColor16M colorspace converter concrete classes 
+*
+*/
+
+#ifndef __YUV2RGB24_H__
+#define __YUV2RGB24_H__
+
+//  INCLUDES
+#include <e32base.h>
+
+//  CLASS DEFINITIONS
+
+// Normal YUV to Rgb24
+class CYuv2Rgb24 : public CBase
+{
+public: // CYuvConverter methods
+    // Constructors & destructor
+    CYuv2Rgb24();
+    ~CYuv2Rgb24();
+    void ConstructL(TUint aWidth, TUint aHeight, TUint aMaxWidth, TUint aMaxHeight);
+
+    void SetGamma(TInt aGamma);
+    void SetBrightnessContrast(TInt aBCIndex);
+    void Convert(const TUint8 *aYBuf, const TUint8 *aUBuf,
+                 const TUint8 *aVBuf,
+                 TUint aBufWidth, TUint aBufHeight,
+                 TUint8 *aTarget, TUint aTargetScanlineLength);
+
+protected: // Data
+    enum
+    {
+        ESaturateOffset = 276, // saturation table offset
+        ESaturateLength = 561+ESaturateOffset // table length
+    };
+    TUint8 *iRgbLookupTable; // RGB clamp/gamma lookup table
+    TUint iWidth, iHeight, iCropWidth, iCropHeight;
+    TInt iGamma;
+    TInt iBrightnessContrast;
+};
+
+#endif      //  __YUV2RGB24_H__
+            
+// End of File