📄 camerapdd.cpp
字号:
ASSERT( ModeContext );
m_ppModeContext[ulModeType] = ModeContext;
return ERROR_SUCCESS;
}
DWORD CCameraPdd::DeInitSensorMode( ULONG ulModeType )
{
return ERROR_SUCCESS;
}
DWORD CCameraPdd::SetSensorState( ULONG lModeType, CSSTATE csState )
{
DWORD dwError = ERROR_SUCCESS;
DEBUGMSG( ZONE_IOCTL, ( _T("CAM: CCameraPdd::SetSensorState to %d\r\n"),csState) );
switch ( csState )
{
case CSSTATE_STOP:
DEBUGMSG( ZONE_IOCTL, ( _T("CAM: CCameraPdd::SetSensorState CSSTATE_STOP\r\n")) );
m_CsState[lModeType] = CSSTATE_STOP;
if( STILL == lModeType )
{
m_bStillCapInProgress = false;
}
if (!is_qci_capturing)
break;
qci_set_capture_callback(NULL,
reinterpret_cast<ULONG>(this),
lModeType);
stop_capture();
power_off();
is_qci_capturing = FALSE;
break;
case CSSTATE_PAUSE:
DEBUGMSG( ZONE_IOCTL, ( _T("CAM: CCameraPdd::SetSensorState CSSTATE_PAUSE\r\n")) );
m_CsState[lModeType] = CSSTATE_PAUSE;
// start_capture(lModeType);
qci_set_capture_callback(NULL,
reinterpret_cast<ULONG>(this),
lModeType);
break;
case CSSTATE_RUN:
DEBUGMSG( ZONE_IOCTL, ( _T("CAM: CCameraPdd::SetSensorState CSSTATE_RUN\r\n")) );
m_CsState[lModeType] = CSSTATE_RUN;
qci_set_capture_callback(CCameraPdd::CaptureInterruptCallBack,
reinterpret_cast<ULONG>(this),
lModeType);
if (is_qci_capturing)
break;
start_capture(lModeType);
is_qci_capturing = TRUE;
break;
default:
DEBUGMSG( ZONE_IOCTL|ZONE_ERROR, ( _T("CAM: IOControl(%08x): Incorrect State\r\n"), this ) );
dwError = ERROR_INVALID_PARAMETER;
}
return dwError;
}
DWORD CCameraPdd::TakeStillPicture( LPVOID pBurstModeInfo )
{
DWORD dwError = ERROR_SUCCESS;
m_bStillCapInProgress = true;
//Ignore pBurstModeInfo
m_CsState[STILL] = CSSTATE_RUN;
if (is_qci_capturing)
{
stop_capture();
is_qci_capturing = FALSE;
}
start_capture(STILL);
is_qci_capturing = TRUE;
qci_set_capture_callback(CCameraPdd::CaptureInterruptCallBack,
reinterpret_cast<ULONG>(this),
STILL);
return dwError;
}
DWORD CCameraPdd::GetSensorModeInfo( ULONG ulModeType, PSENSORMODEINFO pSensorModeInfo )
{
pSensorModeInfo->MemoryModel = m_SensorModeInfo[ulModeType].MemoryModel;
pSensorModeInfo->MaxNumOfBuffers = m_SensorModeInfo[ulModeType].MaxNumOfBuffers;
pSensorModeInfo->PossibleCount = m_SensorModeInfo[ulModeType].PossibleCount;
pSensorModeInfo->VideoCaps.DefaultVideoControlCaps = DefaultVideoControlCaps[ulModeType];
pSensorModeInfo->VideoCaps.CurrentVideoControlCaps = m_pModeVideoCaps[ulModeType].CurrentVideoControlCaps;
pSensorModeInfo->pVideoFormat = &m_pModeVideoFormat[ulModeType];
return ERROR_SUCCESS;
}
DWORD CCameraPdd::SetSensorModeFormat( ULONG ulModeType, PCS_DATARANGE_VIDEO pCsDataRangeVideo )
{
memcpy( &m_pCurrentFormat[ulModeType], pCsDataRangeVideo, sizeof ( CS_DATARANGE_VIDEO ) );
return ERROR_SUCCESS;
}
PVOID CCameraPdd::AllocateBuffer( ULONG ulModeType )
{
// Real PDD may want to save off this allocated pointer
// in an array.
ULONG ulFrameSize = CS__DIBSIZE (m_pCurrentFormat[ulModeType].VideoInfoHeader.bmiHeader);
return RemoteLocalAlloc( LPTR, ulFrameSize );
}
DWORD CCameraPdd::DeAllocateBuffer( ULONG ulModeType, PVOID pBuffer )
{
RemoteLocalFree( pBuffer );
return ERROR_SUCCESS;
}
DWORD CCameraPdd::RegisterClientBuffer( ULONG ulModeType, PVOID pBuffer )
{
// Real PDD may want to save pBuffer which is a pointer to buffer that DShow created.
return ERROR_SUCCESS;
}
DWORD CCameraPdd::UnRegisterClientBuffer( ULONG ulModeType, PVOID pBuffer )
{
// DShow is not going to use pBuffer (which was originally allocated by DShow) anymore. If the PDD
// is keeping a cached pBuffer pointer (in RegisterClientBuffer()) then this is the right place to
// stop using it and maybe set the cached pointer to NULL.
// Note: PDD must not delete this pointer as it will be deleted by DShow itself
return ERROR_SUCCESS;
}
DWORD CCameraPdd::HandleSensorModeCustomProperties( ULONG ulModeType, PUCHAR pInBuf, DWORD InBufLen, PUCHAR pOutBuf, DWORD OutBufLen, PDWORD pdwBytesTransferred )
{
DEBUGMSG( ZONE_IOCTL, ( _T("CAM: IOControl: Unsupported PropertySet Request\r\n")) );
return ERROR_NOT_SUPPORTED;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// The following code is only meant for this sample pdd
// The real PDD should not contain any of the code below.
// Instead the real PDD should implement its own FillPinBuffer()
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
extern "C" { WINGDIAPI HBITMAP WINAPI CreateBitmapFromPointer( CONST BITMAPINFO *pbmi, int iStride, PVOID pvBits); }
DWORD CCameraPdd::FillBuffer( ULONG ulModeType, PUCHAR pImage )
{
PCS_VIDEOINFOHEADER pCsVideoInfoHdr = &m_pCurrentFormat[ulModeType].VideoInfoHeader;
UINT32 biSizeImage = pCsVideoInfoHdr->bmiHeader.biSizeImage;
if (sensor && qci_frame)
{
sensor->handle_frame_interrupt(pImage,
&pCsVideoInfoHdr->bmiHeader,
qci_frame);
return biSizeImage;
} else
return 0;
}
void CCameraPdd :: CaptureInterruptCallBack(ULONG user, ULONG mode)
{
CCameraPdd *pCameraPdd= reinterpret_cast<CCameraPdd *>(user);
if( NULL == pCameraPdd )
{
DEBUGMSG(ZONE_IOCTL|ZONE_ERROR, (_T("CAM: IOControl: pCameraPdd is NULL.\r\n"))) ;
}
else
{
__try
{
pCameraPdd->HandleCaptureInterrupt(mode);
}
__except(GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH)
{
DEBUGMSG(ZONE_IOCTL|ZONE_ERROR, (_T("CAM: IOControl: Access violation.\r\n"))) ;
}
}
}
void CCameraPdd :: HandleCaptureInterrupt(ULONG mode)
{
if(mode != STILL && m_bStillCapInProgress )
return;
if (mode == STILL)
{
stop_capture();
power_off();
is_qci_capturing = FALSE;
m_bStillCapInProgress = false;
}
MDD_HandleIO( m_ppModeContext[mode], mode );
}
bool CCameraPdd::ReadMemoryModelFromRegistry()
{
HKEY hKey = 0;
DWORD dwType = 0;
DWORD dwSize = sizeof ( DWORD );
DWORD dwValue = -1;
if( ERROR_SUCCESS != RegOpenKeyEx( HKEY_LOCAL_MACHINE, L"Drivers\\Capture\\SampleCam", 0, 0, &hKey ))
{
false;
}
if( ERROR_SUCCESS == RegQueryValueEx( hKey, L"MemoryModel", 0, &dwType, (BYTE *)&dwValue, &dwSize ) )
{
if( ( REG_DWORD == dwType )
&& ( sizeof( DWORD ) == dwSize )
&& (( dwValue == CSPROPERTY_BUFFER_DRIVER ) || ( dwValue == CSPROPERTY_BUFFER_CLIENT_LIMITED ) || ( dwValue == CSPROPERTY_BUFFER_CLIENT_UNLIMITED )))
{
for( int i=0; i<MAX_SUPPORTED_PINS ; i++ )
{
m_SensorModeInfo[i].MemoryModel = (CSPROPERTY_BUFFER_MODE) dwValue;
}
}
}
// Find out if we should be using some other number of supported modes. The only
// valid options are 2 or 3. Default to 2.
if ( ERROR_SUCCESS == RegQueryValueEx( hKey, L"PinCount", 0, &dwType, (BYTE *)&dwValue, &dwSize ) )
{
if ( REG_DWORD == dwType
&& sizeof ( DWORD ) == dwSize
&& 3 == dwValue )
{
m_ulCTypes = 3;
}
}
RegCloseKey( hKey );
return true;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -