tvout/tvoutengine/src/glxhdmicontroller.cpp
changeset 42 5e1df1b52eb3
parent 40 112f0ac2d1f0
child 36 6481344a6d67
equal deleted inserted replaced
41:ae07d189b490 42:5e1df1b52eb3
    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>
    22 #include "glxtv.h"                      // for CGlxTv
    22 
    23 #include "glxhdmicontainer.h"
    23 #include "glxhdmicontainer.h"
    24 #include "glxhdmisurfaceupdater.h"
    24 #include "glxhdmisurfaceupdater.h"
    25 
    25 
    26 #include "glxhdmicontroller.h"
    26 #include "glxhdmicontroller.h"
    27 
    27 
    51     if (iFsBitmap)
    51     if (iFsBitmap)
    52         {
    52         {
    53         delete iFsBitmap;
    53         delete iFsBitmap;
    54         iFsBitmap = NULL;
    54         iFsBitmap = NULL;
    55         }
    55         }
    56     if(iGlxTvOut)
       
    57 		{
       
    58         delete iGlxTvOut;
       
    59 		}
       
    60     }
    56     }
    61 
    57 
    62 // -----------------------------------------------------------------------------
    58 // -----------------------------------------------------------------------------
    63 // Setting an Image Path 
    59 // Setting an Image Path 
    64 // -----------------------------------------------------------------------------
    60 // -----------------------------------------------------------------------------
    65 EXPORT_C void CGlxHdmiController::SetImageL(const TDesC& aImageFile, CFbsBitmap* aFsBitmap,
    61 EXPORT_C void CGlxHdmiController::SetImageL(const TDesC& aImageFile, CFbsBitmap* aFsBitmap,
    66                                              TBool aStore)
    62                                              TBool aStore)
    67     {
    63     {
    68     TRACER("CGlxHdmiController::SetImageL()");
    64     TRACER("CGlxHdmiController::SetImageL()");
       
    65     if (aFsBitmap == NULL || !aImageFile.Length())
       
    66         {
       
    67         GLX_LOG_INFO("CGlxHdmiController::SetImageL() - NULL Uri");
       
    68         return;
       
    69         }
    69     if (aStore)
    70     if (aStore)
    70         {
    71         {
    71         iIsImageSupported = ETrue;
    72         iIsImageSupported = ETrue;
    72         StoreImageInfoL( aImageFile, aFsBitmap );
    73         StoreImageInfoL( aImageFile, aFsBitmap );
    73         }
    74         }
    74     if (iGlxTvOut->IsHDMIConnected())
    75     GLX_LOG_INFO("CGlxHdmiController::SetImageL() - 2");
    75         {
    76     // do not close the surface , use the same surface instead.
    76         iIsPostingMode = ETrue;         // the image should be in posting mode
    77     // Call a function to pass imagefile
    77         GLX_LOG_INFO("CGlxHdmiController::SetImageL() - 2");
    78     if (!iHdmiContainer)
    78         // do not close the surface , use the same surface instead.
    79         {            
    79         // Call a function to pass imagefile
    80         CreateHdmiContainerL(); 
    80         if (!iHdmiContainer)
    81         }            
    81             {            
    82     if (!iSurfaceUpdater)
    82             CreateHdmiContainerL(); 
    83         {
    83             }            
    84         // This case would come when surface updater is not created at the first instance and also
    84         if (!iSurfaceUpdater)
    85         // it satisfies the 720p condition                
    85             {
    86         CreateSurfaceUpdaterL(aImageFile);
    86             // This case would come when surface updater is not created at the first instance and also
    87         }
    87             // it satisfies the 720p condition                
    88     else
    88             CreateSurfaceUpdaterL(aImageFile);
    89         {
    89             }
    90         GLX_LOG_INFO("CGlxHdmiController::SetImageL() - 3");
    90         else
    91         iSurfaceUpdater->UpdateNewImageL(aImageFile, aFsBitmap);
    91             {
    92         }
    92             GLX_LOG_INFO("CGlxHdmiController::SetImageL() - 3");
    93     iHdmiContainer->DrawNow();
    93             iSurfaceUpdater->UpdateNewImageL(aImageFile, aFsBitmap);
    94     }
    94             }
    95 
    95         iHdmiContainer->DrawNow();
    96 // -----------------------------------------------------------------------------
    96         }
    97 // ItemNotSupported 
    97     }
       
    98 
       
    99 // -----------------------------------------------------------------------------
       
   100 // IsVideo 
       
   101 // -----------------------------------------------------------------------------
    98 // -----------------------------------------------------------------------------
   102 EXPORT_C void CGlxHdmiController::ItemNotSupported()
    99 EXPORT_C void CGlxHdmiController::ItemNotSupported()
   103     {
   100     {
   104     TRACER("CGlxHdmiController::IsVideo()");
   101     TRACER("CGlxHdmiController::IsVideo()");
   105     iIsImageSupported = EFalse;
   102     iIsImageSupported = EFalse;
   106     if (iGlxTvOut->IsHDMIConnected())
   103     DestroySurfaceUpdater();
   107         {
       
   108         DestroySurfaceUpdater();
       
   109         }
       
   110     }
   104     }
   111 
   105 
   112 
   106 
   113 // -----------------------------------------------------------------------------
   107 // -----------------------------------------------------------------------------
   114 // ActivateZoom 
   108 // ActivateZoom 
   115 // -----------------------------------------------------------------------------
   109 // -----------------------------------------------------------------------------
   116 EXPORT_C void CGlxHdmiController::ActivateZoom(TBool aAutoZoomOut)
   110 EXPORT_C void CGlxHdmiController::ActivateZoom(TBool aAutoZoomOut)
   117     {
   111     {
   118     TRACER("CGlxHdmiController::ActivateZoom()");
   112     TRACER("CGlxHdmiController::ActivateZoom()");
   119     if (iGlxTvOut->IsHDMIConnected())
   113     if (iSurfaceUpdater)
   120         {
   114         {
   121         iSurfaceUpdater->ActivateZoom(aAutoZoomOut);
   115         iSurfaceUpdater->ActivateZoom(aAutoZoomOut);
   122         }
   116         }
   123     }
   117     }
   124 
   118 
   126 // DeactivateZoom 
   120 // DeactivateZoom 
   127 // -----------------------------------------------------------------------------
   121 // -----------------------------------------------------------------------------
   128 EXPORT_C void CGlxHdmiController::DeactivateZoom()
   122 EXPORT_C void CGlxHdmiController::DeactivateZoom()
   129     {
   123     {
   130     TRACER("CGlxHdmiController::DeactivateZoom()");
   124     TRACER("CGlxHdmiController::DeactivateZoom()");
   131     if (iGlxTvOut->IsHDMIConnected())
   125     if (iSurfaceUpdater)
   132         {
   126         {
   133         iSurfaceUpdater->DeactivateZoom();
   127         iSurfaceUpdater->DeactivateZoom();
   134         }
   128         }
   135     }
   129     }
   136 
   130 
   139 // -----------------------------------------------------------------------------
   133 // -----------------------------------------------------------------------------
   140 EXPORT_C void CGlxHdmiController::ShiftToCloningMode()
   134 EXPORT_C void CGlxHdmiController::ShiftToCloningMode()
   141     {
   135     {
   142     TRACER("CGlxHdmiController::ShiftToCloningMode()");
   136     TRACER("CGlxHdmiController::ShiftToCloningMode()");
   143     // Shift to cloning only if HDMI is connected and surfaceupdater available.
   137     // Shift to cloning only if HDMI is connected and surfaceupdater available.
   144     if (iGlxTvOut->IsHDMIConnected() && iSurfaceUpdater)
   138     if (iSurfaceUpdater)
   145         {
   139         {
   146         iIsPostingMode = EFalse;
       
   147         iSurfaceUpdater->ShiftToCloningMode();
   140         iSurfaceUpdater->ShiftToCloningMode();
   148         }
   141         }
   149     }
   142     }
   150 
   143 
   151 // -----------------------------------------------------------------------------
   144 // -----------------------------------------------------------------------------
   152 // ShiftToPostingMode 
   145 // ShiftToPostingMode 
   153 // -----------------------------------------------------------------------------
   146 // -----------------------------------------------------------------------------
   154 EXPORT_C void CGlxHdmiController::ShiftToPostingMode()
   147 EXPORT_C void CGlxHdmiController::ShiftToPostingMode()
   155     {
   148     {
   156     TRACER("CGlxHdmiController::ShiftToPostingMode()");
   149     TRACER("CGlxHdmiController::ShiftToPostingMode()");
   157     if (iGlxTvOut->IsHDMIConnected())
   150     if (!iSurfaceUpdater)
   158         {
   151         {
   159         if (!iSurfaceUpdater)
   152         GLX_LOG_INFO("CGlxHdmiController::ShiftToPostingMode() - 1");
       
   153         // This case would come when HDMI connected, TvOut /headphones being connected
       
   154         // and then it shows a popup of "microphone connected" 
       
   155         // thus Background - Foreground when headphones connected during HDMI connected
       
   156         if (iFsBitmap == NULL || !iStoredImagePath->Length())
   160             {
   157             {
   161             GLX_LOG_INFO("CGlxHdmiController::ShiftToPostingMode() - 1");
   158             GLX_LOG_INFO("CGlxHdmiController::ShiftToPostingMode() - NULL Uri");
   162             // This case would come when HDMI connected, TvOut /headphones being connected
   159             return;
   163             // and then it shows a popup of "microphone connected" 
       
   164             // thus Background - Foreground when headphones connected during HDMI connected
       
   165             SetImageL(iStoredImagePath->Des(), iFsBitmap, EFalse);
       
   166             }
   160             }
   167         else
   161         SetImageL(iStoredImagePath->Des(), iFsBitmap, EFalse);
   168             {
   162         }
   169             GLX_LOG_INFO("CGlxHdmiController::ShiftToPostingMode() - 2");
   163     else
   170             iSurfaceUpdater->ShiftToPostingMode();
   164         {
   171             }
   165         GLX_LOG_INFO("CGlxHdmiController::ShiftToPostingMode() - 2");
   172         iIsPostingMode = ETrue;
   166         iSurfaceUpdater->ShiftToPostingMode();
   173         }
   167         }
   174     }
   168     }
   175 
       
   176 // -----------------------------------------------------------------------------
       
   177 // IsHDMIConnected 
       
   178 // -----------------------------------------------------------------------------
       
   179 EXPORT_C TBool CGlxHdmiController::IsHDMIConnected()
       
   180     {
       
   181     TRACER("CGlxHdmiController::IsHDMIConnected()");
       
   182     return iGlxTvOut->IsHDMIConnected(); 
       
   183     }
       
   184 
       
   185 
   169 
   186 // -----------------------------------------------------------------------------
   170 // -----------------------------------------------------------------------------
   187 // Constructor
   171 // Constructor
   188 // -----------------------------------------------------------------------------
   172 // -----------------------------------------------------------------------------
   189 CGlxHdmiController::CGlxHdmiController():
   173 CGlxHdmiController::CGlxHdmiController():
   190             iFsBitmap(NULL),
   174             iFsBitmap(NULL),
   191             iIsPostingMode(EFalse)
   175             iStoredImagePath(NULL)
   192     {
   176     {
   193     TRACER("CGlxHdmiController::CGlxHdmiController()");
   177     TRACER("CGlxHdmiController::CGlxHdmiController()");
   194     // Implement nothing here
   178     // Implement nothing here
   195     }
   179     }
   196 
   180 
   198 // ConstructL 
   182 // ConstructL 
   199 // -----------------------------------------------------------------------------
   183 // -----------------------------------------------------------------------------
   200 void CGlxHdmiController::ConstructL()
   184 void CGlxHdmiController::ConstructL()
   201     {
   185     {
   202     TRACER("CGlxHdmiController::ConstructL()");
   186     TRACER("CGlxHdmiController::ConstructL()");
   203     iGlxTvOut = CGlxTv::NewL(*this);
       
   204     }
   187     }
   205 
   188 
   206 // -----------------------------------------------------------------------------
   189 // -----------------------------------------------------------------------------
   207 // DestroyContainer 
   190 // DestroyContainer 
   208 // -----------------------------------------------------------------------------
   191 // -----------------------------------------------------------------------------
   226     if (iSurfaceUpdater)
   209     if (iSurfaceUpdater)
   227         {
   210         {
   228         delete iSurfaceUpdater;
   211         delete iSurfaceUpdater;
   229         iSurfaceUpdater = NULL;
   212         iSurfaceUpdater = NULL;
   230         }    
   213         }    
   231     iIsPostingMode = EFalse;
       
   232     }
   214     }
   233 
   215 
   234 // -----------------------------------------------------------------------------
   216 // -----------------------------------------------------------------------------
   235 // CreateHdmiContainerL 
   217 // CreateHdmiContainerL 
   236 // -----------------------------------------------------------------------------
   218 // -----------------------------------------------------------------------------
   272     iStoredImagePath = aImageFile.AllocL();
   254     iStoredImagePath = aImageFile.AllocL();
   273     iFsBitmap = new (ELeave) CFbsBitmap;
   255     iFsBitmap = new (ELeave) CFbsBitmap;
   274     iFsBitmap->Duplicate(aFsBitmap->Handle());
   256     iFsBitmap->Duplicate(aFsBitmap->Handle());
   275     }
   257     }
   276 
   258 
   277 // -----------------------------------------------------------------------------
       
   278 // HandleTvStatusChangedL 
       
   279 // -----------------------------------------------------------------------------
       
   280 void CGlxHdmiController::HandleTvStatusChangedL( TTvChangeType aChangeType )
       
   281     {
       
   282     TRACER("CGlxHdmiController::HandleTvStatusChangedL()");
       
   283     if ( aChangeType == ETvConnectionChanged )          
       
   284         {
       
   285         if ( iGlxTvOut->IsHDMIConnected() && iGlxTvOut->IsConnected() && iSurfaceUpdater)
       
   286             {
       
   287             GLX_LOG_INFO("CGlxHdmiController::HandleTvStatusChangedL() - HDMI and TV Connected");
       
   288             // Do nothing , as this means HDMI is already connected and headset/tv cable connected
       
   289             // meaning we shouldnt destroy HDMI and neither have to create surface updater.
       
   290             return;
       
   291             }
       
   292         else if ( iGlxTvOut->IsHDMIConnected() && iIsImageSupported && iIsPostingMode)
       
   293             {
       
   294             GLX_LOG_INFO("CGlxHdmiController::HandleTvStatusChangedL() - HDMI Connected");
       
   295             // Calling SetImageL() with appropriate parameters
       
   296             SetImageL(iStoredImagePath->Des(), iFsBitmap, EFalse);
       
   297             }
       
   298         else
       
   299             {
       
   300             GLX_LOG_INFO3("CGlxHdmiController::HandleTvStatusChangedL() iIsImageSupported=%d, iGlxTvOut->IsHDMIConnected()=%d, iIsPostingMode=%d", 
       
   301                     iIsImageSupported,iGlxTvOut->IsHDMIConnected(),iIsPostingMode);
       
   302             // if it gets disconnected, destroy the surface 
       
   303             GLX_LOG_INFO("CGlxHdmiController::HandleTvStatusChangedL() - HDMI Not Connected");
       
   304             DestroySurfaceUpdater();
       
   305             }
       
   306         }
       
   307     }
       
   308