tvout/src/glxhdmicontroller.cpp
changeset 26 c499df2dbb33
parent 24 99ad1390cd33
child 27 0d818da5a659
child 29 2c833fc9e98f
child 40 112f0ac2d1f0
equal deleted inserted replaced
24:99ad1390cd33 26:c499df2dbb33
     1 /*
       
     2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:    
       
    15 *
       
    16 */
       
    17 
       
    18 #include <w32std.h>
       
    19 #include <alf/alfutil.h>
       
    20 #include <glxtracer.h>
       
    21 #include <glxlog.h>
       
    22 #include "glxtv.h"                      // for CGlxTv
       
    23 #include "glxhdmicontainer.h"
       
    24 #include "glxhdmisurfaceupdater.h"
       
    25 
       
    26 
       
    27 #include "glxhdmicontroller.h"
       
    28 
       
    29 // -----------------------------------------------------------------------------
       
    30 // NewLC
       
    31 // -----------------------------------------------------------------------------
       
    32 EXPORT_C CGlxHdmiController* CGlxHdmiController::NewL()
       
    33     {
       
    34     TRACER("CGlxHdmiController* CGlxHdmiController::NewL()");
       
    35     CGlxHdmiController* self = new (ELeave) CGlxHdmiController();
       
    36     CleanupStack::PushL(self);
       
    37     self->ConstructL();
       
    38     CleanupStack::Pop(self);
       
    39     return self;
       
    40     }
       
    41 
       
    42 // -----------------------------------------------------------------------------
       
    43 // destructor 
       
    44 // -----------------------------------------------------------------------------
       
    45 EXPORT_C CGlxHdmiController::~CGlxHdmiController()
       
    46     {
       
    47     TRACER("CGlxHdmiController::~CGlxHdmiController()");
       
    48     DestroySurfaceUpdater();
       
    49     DestroyContainer();
       
    50     delete iStoredImagePath;
       
    51     iStoredImagePath = NULL;
       
    52     if(iGlxTvOut)
       
    53 		{
       
    54         delete iGlxTvOut;
       
    55 		}
       
    56     }
       
    57 
       
    58 // -----------------------------------------------------------------------------
       
    59 // Setting an Image Path 
       
    60 // -----------------------------------------------------------------------------
       
    61 EXPORT_C void CGlxHdmiController::SetImageL(const TDesC& aImageFile,
       
    62                                              TBool aStore)
       
    63     {
       
    64     TRACER("CGlxHdmiController::SetImageL()");
       
    65     if (aStore)
       
    66         {
       
    67         iIsImageSupported = ETrue;
       
    68         StoreImageInfoL(aImageFile);
       
    69         }
       
    70     if (iGlxTvOut->IsHDMIConnected())
       
    71         {
       
    72 		iIsPostingMode = ETrue;
       
    73             GLX_LOG_INFO("CGlxHdmiController::SetImageL() - 2");
       
    74             // do not close the surface , use the same surface instead.
       
    75             // Call a function to pass imagefile
       
    76             if (!iHdmiContainer)
       
    77                 {            
       
    78                 CreateHdmiContainerL(); 
       
    79                 }            
       
    80             if (!iSurfaceUpdater)
       
    81                 {
       
    82                 // This case would come when surface updater is not created at the first instance and also
       
    83                 // it satisfies the 720p condition                
       
    84                 CreateSurfaceUpdaterL(aImageFile);
       
    85                 }
       
    86             else
       
    87                 {
       
    88             GLX_LOG_INFO("CGlxHdmiController::SetImageL() - 3");
       
    89             iSurfaceUpdater->UpdateNewImageL(aImageFile);
       
    90             }
       
    91         iHdmiContainer->DrawNow();
       
    92         }
       
    93     }
       
    94 
       
    95 // -----------------------------------------------------------------------------
       
    96 // IsVideo 
       
    97 // -----------------------------------------------------------------------------
       
    98 EXPORT_C void CGlxHdmiController::ItemNotSupported()
       
    99     {
       
   100     TRACER("CGlxHdmiController::IsVideo()");
       
   101     iIsImageSupported = EFalse;
       
   102     if (iGlxTvOut->IsHDMIConnected())
       
   103         {
       
   104         DestroySurfaceUpdater();
       
   105         }
       
   106     }
       
   107 
       
   108 
       
   109 // -----------------------------------------------------------------------------
       
   110 // ActivateZoom 
       
   111 // -----------------------------------------------------------------------------
       
   112 EXPORT_C void CGlxHdmiController::ActivateZoom(TBool aAutoZoomOut)
       
   113     {
       
   114     TRACER("CGlxHdmiController::ActivateZoom()");
       
   115     if (iGlxTvOut->IsHDMIConnected())
       
   116         {
       
   117         iSurfaceUpdater->ActivateZoom(aAutoZoomOut);
       
   118         }
       
   119     }
       
   120 
       
   121 // -----------------------------------------------------------------------------
       
   122 // DeactivateZoom 
       
   123 // -----------------------------------------------------------------------------
       
   124 EXPORT_C void CGlxHdmiController::DeactivateZoom()
       
   125     {
       
   126     TRACER("CGlxHdmiController::DeactivateZoom()");
       
   127     if (iGlxTvOut->IsHDMIConnected())
       
   128         {
       
   129         iSurfaceUpdater->DeactivateZoom();
       
   130         }
       
   131     }
       
   132 
       
   133 // -----------------------------------------------------------------------------
       
   134 // ShiftToCloningMode 
       
   135 // -----------------------------------------------------------------------------
       
   136 EXPORT_C void CGlxHdmiController::ShiftToCloningMode()
       
   137     {
       
   138     TRACER("CGlxHdmiController::ShiftToCloningMode()");
       
   139     iIsPostingMode = EFalse;
       
   140     if (iGlxTvOut->IsHDMIConnected() && iSurfaceUpdater)
       
   141         {
       
   142         iSurfaceUpdater->ShiftToCloningMode();
       
   143         }
       
   144     }
       
   145 
       
   146 // -----------------------------------------------------------------------------
       
   147 // ShiftToPostingMode 
       
   148 // -----------------------------------------------------------------------------
       
   149 EXPORT_C void CGlxHdmiController::ShiftToPostingMode()
       
   150     {
       
   151     TRACER("CGlxHdmiController::ShiftToPostingMode()");
       
   152     iIsPostingMode = ETrue;
       
   153     if (iGlxTvOut->IsHDMIConnected() && iSurfaceUpdater)
       
   154         {
       
   155         iSurfaceUpdater->ShiftToPostingMode();
       
   156         }
       
   157     }
       
   158 
       
   159 // -----------------------------------------------------------------------------
       
   160 // Constructor
       
   161 // -----------------------------------------------------------------------------
       
   162 CGlxHdmiController::CGlxHdmiController():
       
   163         iIsPostingMode(EFalse)
       
   164     {
       
   165     TRACER("CGlxHdmiController::CGlxHdmiController()");
       
   166     // Implement nothing here
       
   167     }
       
   168 
       
   169 // -----------------------------------------------------------------------------
       
   170 // ConstructL 
       
   171 // -----------------------------------------------------------------------------
       
   172 void CGlxHdmiController::ConstructL()
       
   173     {
       
   174     TRACER("CGlxHdmiController::ConstructL()");
       
   175     iGlxTvOut = CGlxTv::NewL(*this);
       
   176     }
       
   177 
       
   178 // -----------------------------------------------------------------------------
       
   179 // DestroyContainer 
       
   180 // -----------------------------------------------------------------------------
       
   181 void CGlxHdmiController::DestroyContainer()
       
   182     {
       
   183     TRACER("CGlxHdmiController::DestroyContainer()");
       
   184     if (iHdmiContainer)
       
   185         {
       
   186         GLX_LOG_INFO("CGlxHdmiController::DestroyHdmi() - deleting iHdmiContainer 1");
       
   187         delete iHdmiContainer;
       
   188         iHdmiContainer = NULL;
       
   189         }
       
   190     }
       
   191 
       
   192 // -----------------------------------------------------------------------------
       
   193 // DestroySurfaceUpdater 
       
   194 // -----------------------------------------------------------------------------
       
   195 void CGlxHdmiController::DestroySurfaceUpdater()
       
   196     {
       
   197     TRACER("CGlxHdmiController::DestroySurfaceUpdater()");
       
   198     if (iSurfaceUpdater)
       
   199         {
       
   200         delete iSurfaceUpdater;
       
   201         iSurfaceUpdater = NULL;
       
   202         }    
       
   203     }
       
   204 
       
   205 
       
   206 // -----------------------------------------------------------------------------
       
   207 // CreateHdmiContainerL 
       
   208 // -----------------------------------------------------------------------------
       
   209 void CGlxHdmiController::CreateHdmiContainerL()
       
   210     {
       
   211     TRACER("CGlxHdmiController::CreateHdmiContainer()");
       
   212     TRect rect = AlfUtil::ScreenSize();
       
   213     iHdmiContainer = CGlxHdmiContainer::NewL(rect);
       
   214     }
       
   215 
       
   216 // -----------------------------------------------------------------------------
       
   217 // CreateSurfaceUpdaterL 
       
   218 // -----------------------------------------------------------------------------
       
   219 void CGlxHdmiController::CreateSurfaceUpdaterL(const TDesC& aImageFile)
       
   220     {
       
   221     TRACER("CGlxHdmiController::CreateSurfaceUpdater()");
       
   222     RWindow* window = iHdmiContainer->GetWindow();
       
   223     iSurfaceUpdater = CGlxHdmiSurfaceUpdater::NewL(window, aImageFile, 
       
   224                                                     iHdmiContainer);
       
   225     iHdmiContainer->DrawNow();
       
   226     }
       
   227 
       
   228 // -----------------------------------------------------------------------------
       
   229 // StoreImageInfoL 
       
   230 // -----------------------------------------------------------------------------
       
   231 void CGlxHdmiController::StoreImageInfoL(const TDesC& aImageFile)
       
   232     {
       
   233     TRACER("CGlxHdmiController::StoreImageInfoL()");
       
   234     if(iStoredImagePath)
       
   235         {
       
   236         delete iStoredImagePath;
       
   237         iStoredImagePath = NULL;
       
   238         }
       
   239     iStoredImagePath = aImageFile.AllocL();
       
   240     }
       
   241 
       
   242 // -----------------------------------------------------------------------------
       
   243 // HandleTvStatusChangedL 
       
   244 // -----------------------------------------------------------------------------
       
   245 void CGlxHdmiController::HandleTvStatusChangedL( TTvChangeType aChangeType )
       
   246     {
       
   247     TRACER("CGlxHdmiController::HandleTvStatusChangedL()");
       
   248     if ( aChangeType == ETvConnectionChanged )          
       
   249         {
       
   250         if ( iGlxTvOut->IsHDMIConnected() && iIsImageSupported && iIsPostingMode)
       
   251             {
       
   252             GLX_LOG_INFO("CGlxHdmiController::HandleTvStatusChangedL() - HDMI Connected");
       
   253             // Calling SetImageL() with appropriate parameters
       
   254             SetImageL(iStoredImagePath->Des(), EFalse);
       
   255             }
       
   256         else
       
   257             {
       
   258             // if it gets disconnected, destroy the surface 
       
   259             GLX_LOG_INFO("CGlxHdmiController::HandleTvStatusChangedL() - HDMI Not Connected");
       
   260             DestroySurfaceUpdater();
       
   261             }
       
   262         }
       
   263     }
       
   264 
       
   265 // -----------------------------------------------------------------------------
       
   266 // HandleTvStatusChangedL 
       
   267 // -----------------------------------------------------------------------------
       
   268 EXPORT_C TBool CGlxHdmiController::IsHDMIConnected()
       
   269     {
       
   270     TRACER("CGlxHdmiController::IsHDMIConnected()");
       
   271     return iGlxTvOut->IsHDMIConnected(); 
       
   272     }
       
   273