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.
152 lines
3.2 KiB
152 lines
3.2 KiB
//----------------------------------------------------------------------------
|
|
// Laser Guard Ltd.
|
|
// Copyright © 2000-2002. All Rights Reserved.
|
|
// Version 1.0 01/01/2000
|
|
// Last modification: 08/10/2003
|
|
// PROJECT:
|
|
// SUBSYSTEM:
|
|
// FILE: VideoCamera.cpp
|
|
// AUTHOR: Sergey Chizhevskiy
|
|
// OVERVIEW
|
|
// ~~~~~~~~
|
|
// Source file of VideoCamera.cpp
|
|
//----------------------------------------------------------------------------
|
|
// VideoCamera.cpp: implementation of the CVideoCamera class.
|
|
//
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
#include "stdafx.h"
|
|
#include "VideoCamera.h"
|
|
#include "VideoCaptureSource.h"
|
|
#include "..\..\LgLib\Version.h"
|
|
|
|
#ifdef _DEBUG
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[]=__FILE__;
|
|
#define new DEBUG_NEW
|
|
#endif
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
// Construction/Destruction
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
CVideoCamera::CVideoCamera()
|
|
{
|
|
CVideoDevice::SetIOCount( 0, 1 );
|
|
|
|
m_pWaitPin = NULL;
|
|
|
|
m_nType = VC_FIX;
|
|
|
|
m_bLock = FALSE;
|
|
|
|
m_pVideoCaptureSource = NULL;
|
|
|
|
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CVideoCamera::CVideoCamera") );
|
|
}
|
|
|
|
CVideoCamera::~CVideoCamera()
|
|
{
|
|
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CVideoCamera::~CVideoCamera") );
|
|
}
|
|
|
|
BOOL CVideoCamera::Connect( CVideoPin *pPin, BOOL bAutoConnect, BOOL bAutoDisconnect, DWORD dwTimeLimit )
|
|
{
|
|
CVideoPin *pOPin = GetOutput(0);
|
|
|
|
if( pOPin )
|
|
{
|
|
// automatic connection
|
|
if( bAutoConnect )
|
|
{
|
|
m_pWaitPin = pPin;
|
|
m_dwWaitTime = ::GetTickCount();
|
|
m_bAutoDisconnect = bAutoDisconnect;
|
|
m_dwTimeLimit = dwTimeLimit;
|
|
}
|
|
else
|
|
{
|
|
m_pWaitPin = NULL;
|
|
}
|
|
|
|
|
|
// search for video line conections path
|
|
if( !pOPin->IsLocked() )
|
|
{
|
|
if( !pOPin->WayLock( pPin ) )
|
|
{
|
|
return FALSE;
|
|
}
|
|
}
|
|
|
|
// test all video line conections (video switchers)
|
|
if( pOPin->WayCheck() )
|
|
return TRUE;
|
|
}
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL CVideoCamera::Disconnect()
|
|
{
|
|
CVideoPin *pOPin = GetOutput(0);
|
|
|
|
if( pOPin )
|
|
{
|
|
// disable automatic connection
|
|
m_pWaitPin = NULL;
|
|
|
|
// nothing connected, nothing so to disconnect
|
|
if( !pOPin->IsLocked() )
|
|
return TRUE;
|
|
|
|
// release line owning
|
|
pOPin->WayUnlock();
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
void CVideoCamera::CheckState()
|
|
{
|
|
if( m_pWaitPin )
|
|
{
|
|
CVideoPin *pOPin = GetOutput(0);
|
|
|
|
if( ( pOPin->IsLocked() || pOPin->WayLock( m_pWaitPin ) ) &&
|
|
pOPin->WayCheck() )
|
|
{
|
|
// automatic disconnection immediatlly after connection
|
|
if( m_bAutoDisconnect )
|
|
{
|
|
Disconnect();
|
|
}
|
|
m_pWaitPin = NULL;
|
|
}
|
|
else
|
|
if( ::GetTickCount() - m_dwWaitTime > m_dwTimeLimit )
|
|
{
|
|
// connection time expaired
|
|
Disconnect();
|
|
m_pWaitPin = NULL;
|
|
}
|
|
}
|
|
}
|
|
|
|
BOOL CVideoCamera::AssignCaptureSource( CVideoCaptureSource *pVideoCaptureSource )
|
|
{
|
|
if( m_pVideoCaptureSource != pVideoCaptureSource )
|
|
{
|
|
if( m_pVideoCaptureSource )
|
|
m_pVideoCaptureSource->AssignVideoCamera( NULL );
|
|
|
|
m_pVideoCaptureSource = pVideoCaptureSource;
|
|
|
|
if( m_pVideoCaptureSource )
|
|
m_pVideoCaptureSource->AssignVideoCamera( this );
|
|
}
|
|
|
|
return TRUE;
|
|
}
|