tvout/tvoutengine/src/glxtvconnectionmonitor.cpp
changeset 33 1ee2af37811f
parent 29 2c833fc9e98f
child 36 6481344a6d67
equal deleted inserted replaced
29:2c833fc9e98f 33:1ee2af37811f
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 
    19 
    20 /**
       
    21  * @internal reviewed 24/08/2007 by D Holland
       
    22  */
       
    23 
       
    24 //  CLASS HEADER
    20 //  CLASS HEADER
    25 #include "glxtvconnectionmonitor.h"
    21 #include "glxtvconnectionmonitor.h"
    26 
    22 
    27 //  EXTERNAL INCLUDES
    23 //  EXTERNAL INCLUDES
    28 
    24 
    67 
    63 
    68 //-----------------------------------------------------------------------------
    64 //-----------------------------------------------------------------------------
    69 // Default C++ constructor
    65 // Default C++ constructor
    70 //-----------------------------------------------------------------------------
    66 //-----------------------------------------------------------------------------
    71 //
    67 //
    72 CGlxTvConnectionMonitor::CGlxTvConnectionMonitor
    68 CGlxTvConnectionMonitor::CGlxTvConnectionMonitor(
    73                            ( MGlxTvConnectionObserver& aConnectionObserver ) 
    69 		MGlxTvConnectionObserver& aConnectionObserver) :
    74                             :CActive(EPriorityStandard), 
    70 	CActive(EPriorityStandard), iConnectionObserver(aConnectionObserver),
    75                              iConnectionObserver ( aConnectionObserver ),
    71 			iIsTvOutConnected(EFalse), iIsHDMIConnected(EFalse)
    76                              iTvOutConnectionState(EFalse),
    72 
    77                              iHDMIConnectionState(EFalse)
    73 	{
    78 
    74 	TRACER("CGlxTvConnectionMonitor");
    79     {
    75 	CActiveScheduler::Add(this);
    80     TRACER("CGlxTvConnectionMonitor");
    76 	}
    81     CActiveScheduler::Add( this );
       
    82     }
       
    83 
    77 
    84 
    78 
    85 //-----------------------------------------------------------------------------
    79 //-----------------------------------------------------------------------------
    86 // Symbian second phase constructor
    80 // Symbian second phase constructor
    87 //-----------------------------------------------------------------------------
    81 //-----------------------------------------------------------------------------
   144 //-----------------------------------------------------------------------------
   138 //-----------------------------------------------------------------------------
   145 //
   139 //
   146 TBool CGlxTvConnectionMonitor::IsConnected() const
   140 TBool CGlxTvConnectionMonitor::IsConnected() const
   147     {
   141     {
   148     TRACER("CGlxTvConnectionMonitor::IsConnected");
   142     TRACER("CGlxTvConnectionMonitor::IsConnected");
   149     GLX_LOG_INFO1("CGlxTvConnectionMonitor::IsConnected iTvOutConnectionState=%d",iTvOutConnectionState);
   143     GLX_LOG_INFO1("CGlxTvConnectionMonitor::IsConnected iIsTvOutConnected=%d",iIsTvOutConnected);
   150     return iTvOutConnectionState;
   144     return iIsTvOutConnected;
   151     }
   145     }
   152 
   146 
   153 //-----------------------------------------------------------------------------
   147 //-----------------------------------------------------------------------------
   154 // Is the TV out cable connected
   148 // Is the TV out cable connected
   155 // IsConnected
   149 // IsConnected
   156 //-----------------------------------------------------------------------------
   150 //-----------------------------------------------------------------------------
   157 //
   151 //
   158 TBool CGlxTvConnectionMonitor::IsHDMIConnected() const
   152 TBool CGlxTvConnectionMonitor::IsHDMIConnected() const
   159     {
   153     {
   160     TRACER("CGlxTvConnectionMonitor::IsHDMIConnected");
   154     TRACER("CGlxTvConnectionMonitor::IsHDMIConnected");
   161     GLX_LOG_INFO1("CGlxTvConnectionMonitor::IsHDMIConnected iHDMIConnectionState=%d",iHDMIConnectionState);
   155     GLX_LOG_INFO1("CGlxTvConnectionMonitor::IsHDMIConnected iIsHDMIConnected=%d",iIsHDMIConnected);
   162     return iHDMIConnectionState;
   156     return iIsHDMIConnected;
   163     }
   157     }
   164 
   158 
   165 //-----------------------------------------------------------------------------
   159 //-----------------------------------------------------------------------------
   166 // Request accessory server events
   160 // Request accessory server events
   167 //-----------------------------------------------------------------------------
   161 //-----------------------------------------------------------------------------
   179 //-----------------------------------------------------------------------------
   173 //-----------------------------------------------------------------------------
   180 // Sends notification to observers if TV Out is connected
   174 // Sends notification to observers if TV Out is connected
   181 //-----------------------------------------------------------------------------
   175 //-----------------------------------------------------------------------------
   182 //
   176 //
   183 void CGlxTvConnectionMonitor::IssueNotificationL()
   177 void CGlxTvConnectionMonitor::IssueNotificationL()
   184     {
   178 	{
   185     TRACER("CGlxTvConnectionMonitor::IssueNotificationL");
   179 	TRACER("CGlxTvConnectionMonitor::IssueNotificationL");
   186 	TBool previousTvState = iTvOutConnectionState;
   180 	TBool previousTvState = iIsTvOutConnected;
   187 	TBool previousHDMIState = iHDMIConnectionState;
   181 	TBool previousHDMIState = iIsHDMIConnected;
   188 	
   182 
   189 	// Update the connection status
   183 	// Update the connection status
   190 	UpdateConnectionStatusL();
   184 	UpdateConnectionStatusL();
   191     
   185 
   192 	// trigger tvstatus change only when there is actually a change the in the connection and not 
   186 	// trigger tvstatus change only when there is actually a change the in the connection and not 
   193 	// for spurious events
   187 	// for spurious events
   194 	if (previousTvState !=iTvOutConnectionState || previousHDMIState != iHDMIConnectionState)
   188 	if (previousTvState != iIsTvOutConnected || previousHDMIState
   195 	    {
   189 			!= iIsHDMIConnected)
   196 	    GLX_LOG_INFO("CGlxTvConnectionMonitor::IssueNotificationL - Connection Altered");
   190 		{
   197 	    iConnectionObserver.HandleTvConnectionStatusChangedL();
   191 		GLX_LOG_INFO("CGlxTvConnectionMonitor::IssueNotificationL - Connection Altered");
   198 	    }
   192 		iConnectionObserver.HandleTvConnectionStatusChangedL();
       
   193 		}
   199 	}
   194 	}
   200 
   195 
   201 //-----------------------------------------------------------------------------
   196 //-----------------------------------------------------------------------------
   202 // UpdateConnectionStatusL()
   197 // UpdateConnectionStatusL()
   203 //-----------------------------------------------------------------------------
   198 //-----------------------------------------------------------------------------
   205 void CGlxTvConnectionMonitor::UpdateConnectionStatusL()
   200 void CGlxTvConnectionMonitor::UpdateConnectionStatusL()
   206     {
   201     {
   207     TRACER("CGlxTvConnectionMonitor::UpdateConnectionStatusL()");
   202     TRACER("CGlxTvConnectionMonitor::UpdateConnectionStatusL()");
   208 
   203 
   209     GLX_LOG_INFO2("CGlxTvConnectionMonitor::UpdateConnectionStatusL previousTvState = %d , previousHDMIState = %d",
   204     GLX_LOG_INFO2("CGlxTvConnectionMonitor::UpdateConnectionStatusL previousTvState = %d , previousHDMIState = %d",
   210             iTvOutConnectionState,iHDMIConnectionState);
   205             iIsTvOutConnected,iIsHDMIConnected);
       
   206 
       
   207     // reset the states
       
   208     iIsHDMIConnected = EFalse;
       
   209     iIsTvOutConnected = EFalse;
   211 
   210 
   212     //gets the TV status in to the iCurrentAccArray and haves the Latest Accesory in 0-index
   211     //gets the TV status in to the iCurrentAccArray and haves the Latest Accesory in 0-index
   213     User::LeaveIfError(iTvAccCon.GetAccessoryConnectionStatus(iCurrentAccArray));
   212     User::LeaveIfError(iTvAccCon.GetAccessoryConnectionStatus(iCurrentAccArray));
   214 
   213 
   215     CAccPolSubblockNameArray* nameArray = CAccPolSubblockNameArray::NewL();
   214     CAccPolSubblockNameArray* nameArray = CAccPolSubblockNameArray::NewL();
   216     CleanupStack::PushL(nameArray);
   215     CleanupStack::PushL(nameArray);
       
   216 
   217     //  Get the number of currently connected accessories
   217     //  Get the number of currently connected accessories
   218     //  Loop through each connected accessory looking for
   218     //  Loop through each connected accessory looking for
   219     //  the desired capabilities
   219     //  the desired capabilities
   220     //
   220     //
   221     const TInt count = iCurrentAccArray.Count();
   221     const TInt count = iCurrentAccArray.Count();
   222     GLX_LOG_INFO1("CGlxTvConnectionMonitor::UpdateConnectionStatusL current count value is %d",count);
   222     GLX_LOG_INFO1("CGlxTvConnectionMonitor::UpdateConnectionStatusL current count value is %d",count);
   223     for (TInt index = 0; index <count; index++)
   223     for (TInt index = 0; index < count; index++)
   224         {
   224         {
   225         TAccPolGenericID genId = iCurrentAccArray.GetGenericIDL(index);
   225         const TAccPolGenericID genId = iCurrentAccArray.GetGenericIDL(index);
   226         //  Get all supported capabilities for this connected accessory.
       
   227         iTvAccCon.GetSubblockNameArrayL(genId, *nameArray);
       
   228         //  Check if this connected accessory supports TV-Out capabality.
   226         //  Check if this connected accessory supports TV-Out capabality.
   229         GLX_LOG_INFO1("CGlxTvConnectionMonitor::UpdateConnectionStatusL current index value is %d",index);
   227         GLX_LOG_INFO1("CGlxTvConnectionMonitor::UpdateConnectionStatusL current index value is %d",index);
   230         if (nameArray->HasName(KAccVideoOut))
   228         GLX_LOG_INFO("CGlxTvConnectionMonitor::UpdateConnectionStatusL Video Accessory Supported");
       
   229         TAccPolNameRecord nameRecord;
       
   230         nameRecord.SetNameL(KAccVideoOut);
       
   231 
       
   232         if (genId.DeviceTypeCaps( KDTAVDevice ) &&
       
   233                 genId.PhysicalConnectionCaps( KPCHDMI ))
   231             {
   234             {
   232             GLX_LOG_INFO("CGlxTvConnectionMonitor::UpdateConnectionStatusL Video Accessory Supported");
       
   233             TAccPolNameRecord nameRecord;
       
   234             nameRecord.SetNameL(KAccVideoOut);
       
   235             TAccValueTypeTInt value;
   235             TAccValueTypeTInt value;
   236             iTvAccCon.GetValueL(genId, nameRecord, value);
   236             TInt err = iTvAccCon.GetValueL(genId, nameRecord, value);
   237             if (value.iValue == EAccVideoOutEHDMI)
   237             if (err ==KErrNone)
   238                 {
   238                 {
   239                 GLX_LOG_INFO("CGlxTvConnectionMonitor::UpdateConnectionStatusL HDMI is connected");
   239                 if (value.iValue == EAccVideoOutEHDMI)
   240                 iHDMIConnectionState = ETrue;
   240                     {
       
   241                     GLX_LOG_INFO("CGlxTvConnectionMonitor::UpdateConnectionStatusL HDMI is connected");
       
   242                     iIsHDMIConnected = ETrue;
       
   243                     }
   241                 }
   244                 }
   242             else if (value.iValue == EAccVideoOutCVideo)
   245             }
       
   246         else if (genId.DeviceTypeCaps( KDTAVDevice ) &&
       
   247                 genId.PhysicalConnectionCaps( KPCWired ))
       
   248             {
       
   249             TAccValueTypeTInt value;
       
   250             TInt err = iTvAccCon.GetValueL(genId, nameRecord, value);
       
   251             if (err ==KErrNone)
   243                 {
   252                 {
   244                 GLX_LOG_INFO("CGlxTvConnectionMonitor::UpdateConnectionStatusL TV is connected");
   253                 if (value.iValue == EAccVideoOutCVideo)
   245                 iTvOutConnectionState = ETrue;
   254                     {
       
   255                     GLX_LOG_INFO("CGlxTvConnectionMonitor::UpdateConnectionStatusL Tv is connected");
       
   256                     iIsTvOutConnected = ETrue;
       
   257                     }
   246                 }
   258                 }
   247             }
   259             }
   248         }
   260         }
   249     CleanupStack::PopAndDestroy(nameArray);
   261     CleanupStack::PopAndDestroy(nameArray);
   250 
   262 
   251     GLX_LOG_INFO2("CGlxTvConnectionMonitor::UpdateConnectionStatusL CurrentTvState = %d , CurrentHDMIState = %d",
   263     GLX_LOG_INFO2("CGlxTvConnectionMonitor::UpdateConnectionStatusL CurrentTvState = %d , CurrentHDMIState = %d",
   252             iTvOutConnectionState,iHDMIConnectionState);
   264             iIsTvOutConnected,iIsHDMIConnected);
   253     }
   265     }