photosgallery/viewframework/tvout/src/glxhdmicontroller.cpp
branchRCL_3
changeset 35 420f6808bf21
parent 32 78ad99c24f08
equal deleted inserted replaced
32:78ad99c24f08 35:420f6808bf21
     1 /*
     1 /*
     2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). 
     2  * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). 
     3 * All rights reserved.
     3  * All rights reserved.
     4 * This component and the accompanying materials are made available
     4  * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5  * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6  * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     8  *
     9 * Initial Contributors:
     9  * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10  * Nokia Corporation - initial contribution.
    11 *
    11  *
    12 * Contributors:
    12  * Contributors:
    13 *
    13  *
    14 * Description:    
    14  * Description:    
    15 *
    15  *
    16 */
    16  */
    17 
    17 
    18 #include <w32std.h>
    18 #include <w32std.h>
    19 #include <alf/alfutil.h>
    19 #include <alf/alfutil.h>
    20 #include <glxtracer.h>
    20 #include <glxtracer.h>
    21 #include <glxlog.h>
    21 #include <glxlog.h>
    26 #include "glxhdmicontroller.h"
    26 #include "glxhdmicontroller.h"
    27 
    27 
    28 // -----------------------------------------------------------------------------
    28 // -----------------------------------------------------------------------------
    29 // NewLC
    29 // NewLC
    30 // -----------------------------------------------------------------------------
    30 // -----------------------------------------------------------------------------
    31 EXPORT_C CGlxHdmiController* CGlxHdmiController::NewL()
    31 EXPORT_C CGlxHdmiController* CGlxHdmiController::NewL(
       
    32         MGlxHDMIDecoderObserver& aDecoderObserver)
    32     {
    33     {
    33     TRACER("CGlxHdmiController* CGlxHdmiController::NewL()");
    34     TRACER("CGlxHdmiController* CGlxHdmiController::NewL()");
    34     CGlxHdmiController* self = new (ELeave) CGlxHdmiController();
    35     CGlxHdmiController* self = new (ELeave) CGlxHdmiController(
       
    36             aDecoderObserver);
    35     CleanupStack::PushL(self);
    37     CleanupStack::PushL(self);
    36     self->ConstructL();
    38     self->ConstructL();
    37     CleanupStack::Pop(self);
    39     CleanupStack::Pop(self);
    38     return self;
    40     return self;
    39     }
    41     }
    45     {
    47     {
    46     TRACER("CGlxHdmiController::~CGlxHdmiController()");
    48     TRACER("CGlxHdmiController::~CGlxHdmiController()");
    47     DestroySurfaceUpdater();
    49     DestroySurfaceUpdater();
    48     DestroyContainer();
    50     DestroyContainer();
    49     delete iStoredImagePath;
    51     delete iStoredImagePath;
    50     iStoredImagePath = NULL;
    52     delete iStoredNextImagePath;
    51     if (iFsBitmap)
    53     if (iFsBitmap)
    52         {
    54         {
    53         delete iFsBitmap;
    55         delete iFsBitmap;
    54         iFsBitmap = NULL;
    56         }
    55         }
    57     if (iGlxTvOut)
    56     if(iGlxTvOut)
    58         {
    57 		{
       
    58         delete iGlxTvOut;
    59         delete iGlxTvOut;
    59 		}
    60         }
    60     }
    61     }
    61 
    62 
    62 // -----------------------------------------------------------------------------
    63 // -----------------------------------------------------------------------------
    63 // Setting an Image Path 
    64 // Setting an Image Path 
    64 // -----------------------------------------------------------------------------
    65 // -----------------------------------------------------------------------------
    65 EXPORT_C void CGlxHdmiController::SetImageL(const TDesC& aImageFile, CFbsBitmap* aFsBitmap,
    66 EXPORT_C void CGlxHdmiController::SetImageL(const TDesC& aImageFile,
    66                                              TBool aStore)
    67         const TDesC& aNextImageFile, CFbsBitmap* aFsBitmap, TBool aStore)
    67     {
    68     {
    68     TRACER("CGlxHdmiController::SetImageL()");
    69     TRACER("CGlxHdmiController::SetImageL()");
    69     if (aFsBitmap == NULL || !aImageFile.Length())
    70     if (aFsBitmap == NULL || !aImageFile.Length())
    70         {
    71         {
    71         GLX_LOG_INFO("CGlxHdmiController::SetImageL() - NULL Uri");
    72         GLX_LOG_INFO("CGlxHdmiController::SetImageL() - NULL Uri");
    72         return;
    73         return;
    73         }
    74         }
    74     if (aStore)
    75     if (aStore)
    75         {
    76         {
    76         iIsImageSupported = ETrue;
    77         iIsImageSupported = ETrue;
    77         StoreImageInfoL( aImageFile, aFsBitmap );
    78         StoreImageInfoL(aImageFile, aNextImageFile, aFsBitmap);
    78         }
    79         }
    79     if (iGlxTvOut->IsHDMIConnected())
    80     if (iGlxTvOut->IsHDMIConnected())
    80         {
    81         {
    81         iIsPhotosInForeground = ETrue;         // the image should be in posting mode
    82         iIsPhotosInForeground = ETrue; // the image should be in posting mode
    82         GLX_LOG_INFO("CGlxHdmiController::SetImageL() - 2");
    83         GLX_LOG_INFO("CGlxHdmiController::SetImageL() - 2");
    83         // do not close the surface , use the same surface instead.
    84         // do not close the surface , use the same surface instead.
    84         // Call a function to pass imagefile
    85         // Call a function to pass imagefile
    85         if (!iHdmiContainer)
    86         if (!iHdmiContainer)
    86             {            
    87             {
    87             CreateHdmiContainerL(); 
    88             CreateHdmiContainerL();
    88             }            
    89             }
    89         if (!iSurfaceUpdater)
    90         if (!iSurfaceUpdater)
    90             {
    91             {
    91             // This case would come when surface updater is not created at the first instance and also
    92             // This case would come when surface updater is not created at the first instance and also
    92             // it satisfies the 720p condition                
    93             // it satisfies the 720p condition                
    93             CreateSurfaceUpdaterL(aImageFile);
    94             CreateSurfaceUpdaterL(aImageFile, aNextImageFile);
    94             }
    95             }
    95         else
    96         else
    96             {
    97             {
    97             GLX_LOG_INFO("CGlxHdmiController::SetImageL() - 3");
    98             GLX_LOG_INFO("CGlxHdmiController::SetImageL() - 3");
    98             iSurfaceUpdater->UpdateNewImageL(aImageFile, aFsBitmap);
    99             iSurfaceUpdater->UpdateNewImageL(aImageFile, aNextImageFile,
       
   100                     aFsBitmap);
    99             }
   101             }
   100         iHdmiContainer->DrawNow();
   102         iHdmiContainer->DrawNow();
   101         }
   103         }
   102     }
   104     }
   103 
   105 
   111     if (iGlxTvOut->IsHDMIConnected())
   113     if (iGlxTvOut->IsHDMIConnected())
   112         {
   114         {
   113         DestroySurfaceUpdater();
   115         DestroySurfaceUpdater();
   114         }
   116         }
   115     }
   117     }
   116 
       
   117 
   118 
   118 // -----------------------------------------------------------------------------
   119 // -----------------------------------------------------------------------------
   119 // ActivateZoom 
   120 // ActivateZoom 
   120 // -----------------------------------------------------------------------------
   121 // -----------------------------------------------------------------------------
   121 EXPORT_C void CGlxHdmiController::ActivateZoom(TBool aAutoZoomOut)
   122 EXPORT_C void CGlxHdmiController::ActivateZoom(TBool aAutoZoomOut)
   168             // This case would come when HDMI connected, TvOut /headphones being connected
   169             // This case would come when HDMI connected, TvOut /headphones being connected
   169             // and then it shows a popup of "microphone connected" 
   170             // and then it shows a popup of "microphone connected" 
   170             // thus Background - Foreground when headphones connected during HDMI connected
   171             // thus Background - Foreground when headphones connected during HDMI connected
   171             if (iFsBitmap == NULL || !iStoredImagePath->Length())
   172             if (iFsBitmap == NULL || !iStoredImagePath->Length())
   172                 {
   173                 {
   173                 GLX_LOG_INFO("CGlxHdmiController::ShiftToPostingMode() - NULL Uri");
   174                 GLX_LOG_INFO(
       
   175                         "CGlxHdmiController::ShiftToPostingMode() - NULL Uri");
   174                 return;
   176                 return;
   175                 }
   177                 }
   176             SetImageL(iStoredImagePath->Des(), iFsBitmap, EFalse);
   178             SetImageL(iStoredImagePath->Des(), KNullDesC, iFsBitmap, EFalse);
   177             }
   179             }
   178         else
   180         else
   179             {
   181             {
   180             GLX_LOG_INFO("CGlxHdmiController::ShiftToPostingMode() - 2");
   182             GLX_LOG_INFO("CGlxHdmiController::ShiftToPostingMode() - 2");
   181             iSurfaceUpdater->ShiftToPostingMode();
   183             iSurfaceUpdater->ShiftToPostingMode();
   187 // IsHDMIConnected 
   189 // IsHDMIConnected 
   188 // -----------------------------------------------------------------------------
   190 // -----------------------------------------------------------------------------
   189 EXPORT_C TBool CGlxHdmiController::IsHDMIConnected()
   191 EXPORT_C TBool CGlxHdmiController::IsHDMIConnected()
   190     {
   192     {
   191     TRACER("CGlxHdmiController::IsHDMIConnected()");
   193     TRACER("CGlxHdmiController::IsHDMIConnected()");
   192     return iGlxTvOut->IsHDMIConnected(); 
   194     return iGlxTvOut->IsHDMIConnected();
   193     }
   195     }
   194 
       
   195 
   196 
   196 // -----------------------------------------------------------------------------
   197 // -----------------------------------------------------------------------------
   197 // Constructor
   198 // Constructor
   198 // -----------------------------------------------------------------------------
   199 // -----------------------------------------------------------------------------
   199 CGlxHdmiController::CGlxHdmiController():
   200 CGlxHdmiController::CGlxHdmiController(
   200             iFsBitmap(NULL),
   201         MGlxHDMIDecoderObserver& aDecoderObserver) :
   201             iStoredImagePath(NULL),
   202     iFsBitmap(NULL), iStoredImagePath(NULL), iStoredNextImagePath(NULL),
   202             iIsPhotosInForeground(EFalse)
   203             iIsPhotosInForeground(EFalse), iDecoderObserver(aDecoderObserver)
   203     {
   204     {
   204     TRACER("CGlxHdmiController::CGlxHdmiController()");
   205     TRACER("CGlxHdmiController::CGlxHdmiController()");
   205     // Implement nothing here
   206     // Implement nothing here
   206     }
   207     }
   207 
   208 
   220 void CGlxHdmiController::DestroyContainer()
   221 void CGlxHdmiController::DestroyContainer()
   221     {
   222     {
   222     TRACER("CGlxHdmiController::DestroyContainer()");
   223     TRACER("CGlxHdmiController::DestroyContainer()");
   223     if (iHdmiContainer)
   224     if (iHdmiContainer)
   224         {
   225         {
   225         GLX_LOG_INFO("CGlxHdmiController::DestroyHdmi() - deleting iHdmiContainer 1");
   226         GLX_LOG_INFO(
       
   227                 "CGlxHdmiController::DestroyHdmi() - deleting iHdmiContainer 1");
   226         delete iHdmiContainer;
   228         delete iHdmiContainer;
   227         iHdmiContainer = NULL;
   229         iHdmiContainer = NULL;
   228         }
   230         }
   229     }
   231     }
   230 
   232 
   236     TRACER("CGlxHdmiController::DestroySurfaceUpdater()");
   238     TRACER("CGlxHdmiController::DestroySurfaceUpdater()");
   237     if (iSurfaceUpdater)
   239     if (iSurfaceUpdater)
   238         {
   240         {
   239         delete iSurfaceUpdater;
   241         delete iSurfaceUpdater;
   240         iSurfaceUpdater = NULL;
   242         iSurfaceUpdater = NULL;
   241         }    
   243         }
   242     }
   244     }
   243 
   245 
   244 // -----------------------------------------------------------------------------
   246 // -----------------------------------------------------------------------------
   245 // CreateHdmiContainerL 
   247 // CreateHdmiContainerL 
   246 // -----------------------------------------------------------------------------
   248 // -----------------------------------------------------------------------------
   252     }
   254     }
   253 
   255 
   254 // -----------------------------------------------------------------------------
   256 // -----------------------------------------------------------------------------
   255 // CreateSurfaceUpdaterL 
   257 // CreateSurfaceUpdaterL 
   256 // -----------------------------------------------------------------------------
   258 // -----------------------------------------------------------------------------
   257 void CGlxHdmiController::CreateSurfaceUpdaterL(const TDesC& aImageFile)
   259 void CGlxHdmiController::CreateSurfaceUpdaterL(const TDesC& aImageFile,
       
   260         const TDesC& aNextImageFile)
   258     {
   261     {
   259     TRACER("CGlxHdmiController::CreateSurfaceUpdater()");
   262     TRACER("CGlxHdmiController::CreateSurfaceUpdater()");
   260     RWindow* window = iHdmiContainer->GetWindow();
   263     RWindow* window = iHdmiContainer->GetWindow();
   261     iSurfaceUpdater = CGlxHdmiSurfaceUpdater::NewL(window, aImageFile, iFsBitmap,
   264     iSurfaceUpdater = CGlxHdmiSurfaceUpdater::NewL(window, aImageFile,
   262                                                     iHdmiContainer);
   265             aNextImageFile, iFsBitmap, iHdmiContainer, iDecoderObserver);
   263     iHdmiContainer->DrawNow();
   266     iHdmiContainer->DrawNow();
   264     }
   267     }
   265 
   268 
   266 // -----------------------------------------------------------------------------
   269 // -----------------------------------------------------------------------------
   267 // StoreImageInfoL 
   270 // StoreImageInfoL 
   268 // -----------------------------------------------------------------------------
   271 // -----------------------------------------------------------------------------
   269 void CGlxHdmiController::StoreImageInfoL(const TDesC& aImageFile, CFbsBitmap* aFsBitmap)
   272 void CGlxHdmiController::StoreImageInfoL(const TDesC& aImageFile,
       
   273         const TDesC& aNextImageFile, CFbsBitmap* aFsBitmap)
   270     {
   274     {
   271     TRACER("CGlxHdmiController::StoreImageInfoL()");
   275     TRACER("CGlxHdmiController::StoreImageInfoL()");
   272     if(iStoredImagePath)
   276     if (iStoredImagePath)
   273         {
   277         {
   274         delete iStoredImagePath;
   278         delete iStoredImagePath;
   275         iStoredImagePath = NULL;
   279         iStoredImagePath = NULL;
   276         }
   280         }
       
   281     if (iStoredNextImagePath)
       
   282         {
       
   283         delete iStoredNextImagePath;
       
   284         iStoredNextImagePath = NULL;
       
   285         }
   277     if (iFsBitmap)
   286     if (iFsBitmap)
   278         {
   287         {
   279         delete iFsBitmap;
   288         delete iFsBitmap;
   280         iFsBitmap = NULL;
   289         iFsBitmap = NULL;
   281         }
   290         }
   282     iStoredImagePath = aImageFile.AllocL();
   291     iStoredImagePath = aImageFile.AllocL();
       
   292     iStoredNextImagePath = aNextImageFile.AllocL();
   283     iFsBitmap = new (ELeave) CFbsBitmap;
   293     iFsBitmap = new (ELeave) CFbsBitmap;
   284     iFsBitmap->Duplicate(aFsBitmap->Handle());
   294     iFsBitmap->Duplicate(aFsBitmap->Handle());
   285     }
   295     }
   286 
   296 
   287 // -----------------------------------------------------------------------------
   297 // -----------------------------------------------------------------------------
   288 // HandleTvStatusChangedL 
   298 // HandleTvStatusChangedL 
   289 // -----------------------------------------------------------------------------
   299 // -----------------------------------------------------------------------------
   290 void CGlxHdmiController::HandleTvStatusChangedL( TTvChangeType aChangeType )
   300 void CGlxHdmiController::HandleTvStatusChangedL(TTvChangeType aChangeType)
   291     {
   301     {
   292     TRACER("CGlxHdmiController::HandleTvStatusChangedL()");
   302     TRACER("CGlxHdmiController::HandleTvStatusChangedL()");
   293     if ( aChangeType == ETvConnectionChanged )          
   303     if (aChangeType == ETvConnectionChanged)
   294         {
   304         {
   295         if ( iGlxTvOut->IsHDMIConnected() && iGlxTvOut->IsConnected() && iSurfaceUpdater)
   305         if (iGlxTvOut->IsHDMIConnected() && iGlxTvOut->IsConnected()
   296             {
   306                 && iSurfaceUpdater)
   297             GLX_LOG_INFO("CGlxHdmiController::HandleTvStatusChangedL() - HDMI and TV Connected");
   307             {
       
   308             GLX_LOG_INFO(
       
   309                     "CGlxHdmiController::HandleTvStatusChangedL() - HDMI and TV Connected");
   298             // Do nothing , as this means HDMI is already connected and headset/tv cable connected
   310             // Do nothing , as this means HDMI is already connected and headset/tv cable connected
   299             // meaning we shouldnt destroy HDMI and neither have to create surface updater.
   311             // meaning we shouldnt destroy HDMI and neither have to create surface updater.
   300             return;
   312             return;
   301             }
   313             }
   302         else if ( iGlxTvOut->IsHDMIConnected() && iIsImageSupported && iIsPhotosInForeground)
   314         else if (iGlxTvOut->IsHDMIConnected() && iIsImageSupported
   303             {
   315                 && iIsPhotosInForeground)
   304             GLX_LOG_INFO("CGlxHdmiController::HandleTvStatusChangedL() - HDMI Connected");
   316             {
       
   317             GLX_LOG_INFO(
       
   318                     "CGlxHdmiController::HandleTvStatusChangedL() - HDMI Connected");
   305             // Calling SetImageL() with appropriate parameters
   319             // Calling SetImageL() with appropriate parameters
   306             SetImageL(iStoredImagePath->Des(), iFsBitmap, EFalse);
   320             if (iStoredNextImagePath)
       
   321                 {
       
   322                 SetImageL(iStoredImagePath->Des(),
       
   323                         iStoredNextImagePath->Des(), iFsBitmap, EFalse);
       
   324                 }
       
   325             else
       
   326                 {
       
   327                 SetImageL(iStoredImagePath->Des(), KNullDesC, iFsBitmap,
       
   328                         EFalse);
       
   329                 }
   307             }
   330             }
   308         else
   331         else
   309             {
   332             {
   310             GLX_LOG_INFO3("CGlxHdmiController::HandleTvStatusChangedL() iIsImageSupported=%d, iGlxTvOut->IsHDMIConnected()=%d, iIsPostingMode=%d", 
   333             GLX_LOG_INFO3(
   311                     iIsImageSupported,iGlxTvOut->IsHDMIConnected(),iIsPhotosInForeground);
   334                     "CGlxHdmiController::HandleTvStatusChangedL() iIsImageSupported=%d, iGlxTvOut->IsHDMIConnected()=%d, iIsPostingMode=%d",
       
   335                     iIsImageSupported, iGlxTvOut->IsHDMIConnected(),
       
   336                     iIsPhotosInForeground);
   312             // if it gets disconnected, destroy the surface 
   337             // if it gets disconnected, destroy the surface 
   313             GLX_LOG_INFO("CGlxHdmiController::HandleTvStatusChangedL() - HDMI Not Connected");
   338             GLX_LOG_INFO(
       
   339                     "CGlxHdmiController::HandleTvStatusChangedL() - HDMI Not Connected");
   314             DestroySurfaceUpdater();
   340             DestroySurfaceUpdater();
   315             }
   341             }
   316         }
   342         }
   317     }
   343     }
   318 
   344