You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
262 lines
9.9 KiB
262 lines
9.9 KiB
//----------------------------------------------------------------------------
|
|
// Laser Guard Ltd.
|
|
// Copyright © 2000-2002. All Rights Reserved.
|
|
// Version 1.0 01/01/2000
|
|
// Last modification: 08/10/2003
|
|
// PROJECT:
|
|
// SUBSYSTEM:
|
|
// FILE: LgRemoteClientTcpIpMaster.cpp
|
|
// AUTHOR: Sergey Chizhevskiy
|
|
// OVERVIEW
|
|
// ~~~~~~~~
|
|
// Source file of LgRemoteClientTcpIpMaster.cpp
|
|
//----------------------------------------------------------------------------
|
|
#include "stdafx.h"
|
|
#include "..\Version.h"
|
|
#include "LgRemoteClientTcpIpMaster.h"
|
|
|
|
CLgRemoteClientTcpIpMultiIPI::CLgRemoteClientTcpIpMultiIPI()
|
|
{
|
|
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CLgRemoteClientTcpIpMultiIPI::CLgRemoteClientTcpIpMultiIPI" );
|
|
}
|
|
|
|
CLgRemoteClientTcpIpMultiIPI::~CLgRemoteClientTcpIpMultiIPI()
|
|
{
|
|
CLgRemoteClientTcpIp::Destroy();
|
|
|
|
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CLgRemoteClientTcpIpMultiIPI::~CLgRemoteClientTcpIpMultiIPI" );
|
|
}
|
|
|
|
void CLgRemoteClientTcpIpMultiIPI::Destroy()
|
|
{
|
|
// unlink all intercaces
|
|
CLgRemoteInterfacePtz::Unlink();
|
|
CLgRemoteInterfaceVideo::Unlink();
|
|
CLgRemoteInterfaceLGS::Unlink();
|
|
CLgRemoteInterfaceReport::Unlink();
|
|
|
|
// destroy remote socket
|
|
CLgRemoteClientTcpIp::Destroy();
|
|
}
|
|
|
|
BOOL CLgRemoteClientTcpIpMultiIPI::Create( LPCTSTR lpszHostAddress, UINT nHostPort )
|
|
{
|
|
if( !CLgRemoteClientTcpIp::Create( lpszHostAddress, nHostPort, LG_REMOTE_E_SESSION_TYPE_MULTI_IPI, LG_REMOTE_E_CONNECT_TYPE_MASTER ) )
|
|
{
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CLgRemoteClientTcpIpMultiIPI::Create"), _T("CLgRemoteClientTcpIp::Create failed") );
|
|
return FALSE;
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
void CLgRemoteClientTcpIpMultiIPI::OnPacketVideo( PLG_TCP_PACKET_VIDEO pReceivePacket )
|
|
{
|
|
// store into pending list and wait for next video sample
|
|
CLgLocker Lock( &m_PendingVideo );
|
|
m_PendingVideo.Add( *pReceivePacket );
|
|
}
|
|
|
|
void CLgRemoteClientTcpIpMultiIPI::OnPacketLGS( PLG_TCP_PACKET_LGS pReceivePacket )
|
|
{
|
|
switch( pReceivePacket->bSubType )
|
|
{
|
|
case LG_TCP_PACKET_LGS::LGS_TYPE_RESET:
|
|
if( !DoRemoteLgsReset() )
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CLgRemoteClientTcpIpMultiIPI::OnPacketLGS"), _T("DoRemoteLgsReset failed") );
|
|
break;
|
|
case LG_TCP_PACKET_LGS::LGS_TYPE_BORDER:
|
|
if( !DoRemoteLgsBorder() )
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CLgRemoteClientTcpIpMultiIPI::OnPacketLGS"), _T("DoRemoteLgsBorder failed") );
|
|
break;
|
|
case LG_TCP_PACKET_LGS::LGS_TYPE_CLEAR:
|
|
if( !DoRemoteLgsClear() )
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CLgRemoteClientTcpIpMultiIPI::OnPacketLGS"), _T("DoRemoteLgsClear failed") );
|
|
break;
|
|
case LG_TCP_PACKET_LGS::LGS_TYPE_SENSITIVITY:
|
|
if( !DoRemoteLgsSensitivity( pReceivePacket->bSensitivity ) )
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CLgRemoteClientTcpIpMultiIPI::OnPacketLGS"), _T("DoRemoteLgsSensitivity failed") );
|
|
break;
|
|
case LG_TCP_PACKET_LGS::LGS_TYPE_HIDDEN_ON:
|
|
if( !DoRemoteLgsHiddenOn( pReceivePacket->bHiddenSet, pReceivePacket->bHiddenOn ) )
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CLgRemoteClientTcpIpMultiIPI::OnPacketLGS"), _T("DoRemoteLgsHiddenOn failed") );
|
|
break;
|
|
case LG_TCP_PACKET_LGS::LGS_TYPE_CONNECT:
|
|
if( !DoRemoteLgsConnect() )
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CLgRemoteClientTcpIpMultiIPI::OnPacketLGS"), _T("DoRemoteLgsConnect failed") );
|
|
break;
|
|
case LG_TCP_PACKET_LGS::LGS_TYPE_PHOTO:
|
|
if( !DoRemoteLgsPhoto() )
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CLgRemoteClientTcpIpMultiIPI::OnPacketLGS"), _T("DoRemoteLgsPhoto failed") );
|
|
break;
|
|
case LG_TCP_PACKET_LGS::LGS_TYPE_VOLTAGE:
|
|
if( !DoRemoteLgsVoltage() )
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CLgRemoteClientTcpIpMultiIPI::OnPacketLGS"), _T("DoRemoteLgsVoltage failed") );
|
|
break;
|
|
default:
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CLgRemoteClientTcpIpMultiIPI::OnPacketLGS"), _T("Unknown packet sub type %d"), pReceivePacket->bSubType );
|
|
break;
|
|
}
|
|
}
|
|
|
|
void CLgRemoteClientTcpIpMultiIPI::OnPacketPTZ( PLG_TCP_PACKET_PTZ pReceivePacket )
|
|
{
|
|
switch( pReceivePacket->bSubType )
|
|
{
|
|
case LG_TCP_PACKET_PTZ::PTZ_TYPE_POSITION:
|
|
if( !DoRemotePtzPosition( pReceivePacket->bPositionSet, pReceivePacket->dPositionPan, pReceivePacket->dPositionTilt, pReceivePacket->dPositionZoom ) )
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CLgRemoteClientTcpIpMultiIPI::OnPacketPTZ"), _T("DoRemotePtzPosition failed") );
|
|
break;
|
|
case LG_TCP_PACKET_PTZ::PTZ_TYPE_IRIS:
|
|
if( !DoRemotePtzIris( pReceivePacket->bIrisSet, pReceivePacket->bIrisDay ) )
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CLgRemoteClientTcpIpMultiIPI::OnPacketPTZ"), _T("DoRemotePtzIris failed") );
|
|
break;
|
|
default:
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CLgRemoteClientTcpIpMultiIPI::OnPacketPTZ"), _T("Unknown packet sub type %d"), pReceivePacket->bSubType );
|
|
break;
|
|
}
|
|
}
|
|
|
|
void CLgRemoteClientTcpIpMultiIPI::OnPacketReport( PLG_TCP_PACKET_REPORT pReceivePacket )
|
|
{
|
|
// perform default processing
|
|
switch( pReceivePacket->bSubType )
|
|
{
|
|
case LG_TCP_PACKET_REPORT::REPORT_TYPE_LIST:
|
|
if( !DoRemoteReportList( (REMOTE_CONTEXT)pReceivePacket->nConnectionID, (LPCTSTR)pReceivePacket + sizeof(LG_TCP_PACKET_REPORT), pReceivePacket->nLength - sizeof(LG_TCP_PACKET_REPORT) ) )
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CLgRemoteClientTcpIpMultiIPI::OnPacketReport"), _T("DoRemoteReportList failed") );
|
|
break;
|
|
case LG_TCP_PACKET_REPORT::REPORT_TYPE_FILE:
|
|
if( !DoRemoteReportFile( (REMOTE_CONTEXT)pReceivePacket->nConnectionID, (LPCTSTR)pReceivePacket + sizeof(LG_TCP_PACKET_REPORT), pReceivePacket->nLength - sizeof(LG_TCP_PACKET_REPORT), pReceivePacket->dwPosition ) )
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CLgRemoteClientTcpIpMultiIPI::OnPacketReport"), _T("DoRemoteReportFile failed") );
|
|
break;
|
|
default:
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CLgRemoteClientTcpIpMultiIPI::OnPacketReport"), _T("Unknown packet sub type %d"), pReceivePacket->bSubType );
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
BOOL CLgRemoteClientTcpIpMultiIPI::OnRemotePtzPosition( BOOL bSet, double dPan, double dTilt, double dZoom )
|
|
{
|
|
if( SendPtzPosition( bSet, dPan, dTilt, dZoom ) )
|
|
return TRUE;
|
|
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CLgRemoteClientTcpIpMultiIPI::OnRemotePtzPosition"), _T("SendPtzPosition failed") );
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL CLgRemoteClientTcpIpMultiIPI::OnRemotePtzIris( BOOL bSet, BOOL bDay )
|
|
{
|
|
if( SendPtzIris( bSet, bDay ) )
|
|
return TRUE;
|
|
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CLgRemoteClientTcpIpMultiIPI::OnRemotePtzIris"), _T("SendPtzIris failed") );
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL CLgRemoteClientTcpIpMultiIPI::OnRemoteLgsReset()
|
|
{
|
|
if( SendLgsReset() )
|
|
return TRUE;
|
|
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CLgRemoteClientTcpIpMultiIPI::OnRemoteLgsReset"), _T("SendLgsReset failed") );
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL CLgRemoteClientTcpIpMultiIPI::OnRemoteLgsClear()
|
|
{
|
|
if( SendLgsClear() )
|
|
return TRUE;
|
|
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CLgRemoteClientTcpIpMultiIPI::OnRemoteLgsClear"), _T("SendLgsClear failed") );
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL CLgRemoteClientTcpIpMultiIPI::OnRemoteLgsTarget( BYTE bType, double dAngle, double dRange )
|
|
{
|
|
if( SendLgsTarget( bType, dAngle, dRange ) )
|
|
return TRUE;
|
|
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CLgRemoteClientTcpIpMultiIPI::OnRemoteLgsTarget"), _T("SendLgsTarget failed") );
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL CLgRemoteClientTcpIpMultiIPI::OnRemoteLgsConnect( BOOL bConnected )
|
|
{
|
|
if( SendLgsConnect( bConnected ) )
|
|
return TRUE;
|
|
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CLgRemoteClientTcpIpMultiIPI::OnRemoteLgsConnect"), _T("SendLgsConnect failed") );
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL CLgRemoteClientTcpIpMultiIPI::OnRemoteLgsVoltage( BOOL bVoltageOk )
|
|
{
|
|
if( SendLgsVoltage( bVoltageOk ) )
|
|
return TRUE;
|
|
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CLgRemoteClientTcpIpMultiIPI::OnRemoteLgsVoltage"), _T("SendLgsVoltage failed") );
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL CLgRemoteClientTcpIpMultiIPI::OnRemoteLgsSensitivity( BYTE bSensitivity )
|
|
{
|
|
if( SendLgsSensitivity( bSensitivity ) )
|
|
return TRUE;
|
|
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CLgRemoteClientTcpIpMultiIPI::OnRemoteLgsSensitivity"), _T("SendLgsSensitivity failed") );
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL CLgRemoteClientTcpIpMultiIPI::OnRemoteLgsHiddenOn( BOOL bSet, BYTE bHidden )
|
|
{
|
|
if( SendLgsHiddenOn( bSet, bHidden ) )
|
|
return TRUE;
|
|
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CLgRemoteClientTcpIpMultiIPI::OnRemoteLgsHiddenOn"), _T("SendLgsHiddenOn failed") );
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL CLgRemoteClientTcpIpMultiIPI::OnRemoteVideo( CLgImageDIB *pDIB, BYTE bSequence )
|
|
{
|
|
CLgLocker Lock( &m_PendingVideo );
|
|
|
|
for( INT i = 0; i < m_PendingVideo.GetCount(); i++ )
|
|
{
|
|
if( !SendVideo( m_PendingVideo[i].nConnectionID, pDIB, m_PendingVideo[i].bQuality, bSequence ) )
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CLgRemoteClientTcpIpMultiIPI::OnRemoteVideo"), _T("SendVideo failed") );
|
|
}
|
|
|
|
m_PendingVideo.RemoveAll();
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CLgRemoteClientTcpIpMultiIPI::OnRemoteLgsBorder( CLgImageDIB *pDIB )
|
|
{
|
|
CLgImageJPEG Jpeg;
|
|
if( Jpeg.Create( *pDIB, *pDIB, 80 ) )
|
|
return SendLgsBorder( &Jpeg );
|
|
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CLgRemoteClientTcpIpMultiIPI::OnRemoteLgsBorder"), _T("Jpeg.Create failed") );
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL CLgRemoteClientTcpIpMultiIPI::OnRemoteReportList( REMOTE_CONTEXT rc, PBYTE pText, INT nCount )
|
|
{
|
|
if( SendReportList( rc, pText, nCount ) )
|
|
return TRUE;
|
|
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CLgRemoteClientTcpIpMultiIPI::OnRemoteReportList"), _T("SendReportList failed") );
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL CLgRemoteClientTcpIpMultiIPI::OnRemoteReportFile( REMOTE_CONTEXT rc, PBYTE pText, INT nCount )
|
|
{
|
|
if( SendReportFile( rc, pText, nCount ) )
|
|
return TRUE;
|
|
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CLgRemoteClientTcpIpMultiIPI::OnRemoteReportFile"), _T("SendReportFile failed") );
|
|
return FALSE;
|
|
}
|