📄 cameradevice.cpp
字号:
// InBufLen
// [in] Input buffer length.
//
// pOutBuf
// [in] Output buffer.
//
// OutBufLen
// [in] Output buffer length.
//
// pdwBytesTransferred
// [in] Bytes transferred.
//
// Returns:
// Returns ERROR_SUCCESS if the operation completes successfully;
// Otherwise, returns ERROR_INVALID_PARAMETER.
//
//-----------------------------------------------------------------------------
DWORD CCameraDevice::AdapterHandleCamControlRequests(
PUCHAR pInBuf,
DWORD InBufLen,
PUCHAR pOutBuf,
DWORD OutBufLen,
PDWORD pdwBytesTransferred
)
{
DEBUGMSG(1, (_T("CAM_IOControl(%08x): HandleCamControlRequests\r\n"), this));
DWORD dwError = ERROR_INVALID_PARAMETER;
long lValue = 0;
PCSPROPERTY pCsProp = NULL;
PDEV_PROPERTY pDevProp = NULL;
PCSPROPERTY_CAMERACONTROL_S pCsPropCamControlOutput = NULL;
PCSPROPERTY_CAMERACONTROL_S pCsPropCamControlInput = NULL;
pCsProp = reinterpret_cast<PCSPROPERTY>(ValidateBuffer(pInBuf, InBufLen, sizeof(CSPROPERTY), &dwError));
if (NULL == pCsProp)
{
return dwError;
}
*pdwBytesTransferred = 0;
// we support PROPSETID_Pin, so just return success
if (CSPROPERTY_TYPE_SETSUPPORT == pCsProp->Flags)
{
return ERROR_SUCCESS;
}
// We support CSPROPERTY_CAMERACONTROL_ZOOM property only.
if ((pCsProp->Id != CSPROPERTY_CAMERACONTROL_ZOOM) &&
(pCsProp->Id != CSPROPERTY_CAMERACONTROL_TILT))
{
DEBUGMSG(ZONE_IOCTL, (_T("CAM_IOControl(%08x): Invalid Property\r\n"), this));
return dwError ;
}
pDevProp = reinterpret_cast<PDEV_PROPERTY>(m_DevProps + (pCsProp->Id + NUM_VIDEOPROCAMP_ITEMS) );
if (NULL == (pCsPropCamControlInput = reinterpret_cast<PCSPROPERTY_CAMERACONTROL_S>( ValidateBuffer( pInBuf, InBufLen, sizeof(CSPROPERTY_CAMERACONTROL_S), &dwError))))
{
return dwError;
}
switch(pCsProp->Flags)
{
case CSPROPERTY_TYPE_GET :
if (FALSE == pDevProp->fGetSupported)
{
SetLastError(ERROR_INVALID_OPERATION);
break;
}
*pdwBytesTransferred = sizeof(CSPROPERTY_CAMERACONTROL_S);
if(NULL == (pCsPropCamControlOutput = reinterpret_cast<PCSPROPERTY_CAMERACONTROL_S>(ValidateBuffer(pOutBuf, OutBufLen, *pdwBytesTransferred, &dwError))))
{
dwError = ERROR_MORE_DATA;
break;
}
//Copy the CSPROPERTY structure to the output buffer just in case!
memcpy( pCsPropCamControlOutput, pCsPropCamControlInput, sizeof(CSPROPERTY) ) ;
pCsPropCamControlOutput->Value = pDevProp->ulCurrentValue ;
pCsPropCamControlOutput->Flags = pDevProp->ulFlags ;
pCsPropCamControlOutput->Capabilities = pDevProp->ulCapabilities ;
dwError = ERROR_SUCCESS;
break;
case CSPROPERTY_TYPE_SET:
DEBUGMSG(ZONE_FUNCTION, (_T("CAM_IOControl(%08x): HandleCamControlRequests inter CSPROPERTY_TYPE_SET\r\n"), this));
if (FALSE == pDevProp->fSetSupported)
{
SetLastError(ERROR_INVALID_OPERATION);
break;
}
DEBUGMSG(ZONE_FUNCTION, (_T("CAM_IOControl(%08x): HandleCamControlRequests: fSetSupported is true.\r\n"), this));
lValue = pCsPropCamControlInput->Value;
if (lValue < pDevProp->pRangeNStep->Bounds.SignedMinimum ||
lValue > pDevProp->pRangeNStep->Bounds.SignedMaximum ||
((lValue - pDevProp->pRangeNStep->Bounds.SignedMinimum) % pDevProp->pRangeNStep->SteppingDelta) ||
(pCsPropCamControlInput->Flags & ~pDevProp->ulCapabilities))
{
break;
}
pDevProp->ulCurrentValue = lValue;
pDevProp->ulFlags = pCsPropCamControlInput->Flags;
if (pCsProp->Id == CSPROPERTY_CAMERACONTROL_ZOOM)
{
CameraSensorZoom(pDevProp->ulCurrentValue);
}
else if (pCsProp->Id == CSPROPERTY_CAMERACONTROL_TILT)
{
if (pDevProp->ulCurrentValue == 90)
{
if (!m_bRotate)
{
// Rotation turned from OFF to ON state
m_bRotate = TRUE;
DEBUGMSG(ZONE_DEVICE, (_T("CAM_IOControl(%08x): Just set up for 90 degree Rotation.\r\n"), this));
// Assure that we will reconfigure IPU before starting.
m_bCameraEncConfig = FALSE;
m_bCameraVfConfig = FALSE;
}
}
else if (pDevProp->ulCurrentValue == 0)
{
if (m_bRotate)
{
m_bRotate = FALSE;
// Assure that we will reconfigure IPU before starting.
m_bCameraEncConfig = FALSE;
m_bCameraVfConfig = FALSE;
}
}
else
{
// Invalid rotation value
DEBUGMSG(ZONE_ERROR, (_T("CAM_IOControl(%08x): Invalid value for tilt.\r\n"), this));
}
}
dwError = ERROR_SUCCESS;
break;
case CSPROPERTY_TYPE_DEFAULTVALUES:
*pdwBytesTransferred = sizeof(CSPROPERTY_CAMERACONTROL_S);
if(NULL == (pCsPropCamControlOutput = reinterpret_cast<PCSPROPERTY_CAMERACONTROL_S>(ValidateBuffer(pOutBuf, OutBufLen, *pdwBytesTransferred, &dwError))))
{
dwError = ERROR_MORE_DATA;
break;
}
//Copy the CSPROPERTY structure to the output buffer just in case!
memcpy(pCsPropCamControlOutput, pCsPropCamControlInput, sizeof(CSPROPERTY));
pCsPropCamControlOutput->Value = pDevProp->ulDefaultValue;
pCsPropCamControlOutput->Flags = pDevProp->ulFlags ;
pCsPropCamControlOutput->Capabilities = pDevProp->ulCapabilities;
dwError = ERROR_SUCCESS;
break;
case CSPROPERTY_TYPE_BASICSUPPORT:
GetBasicSupportInfo(pOutBuf, OutBufLen, pdwBytesTransferred, pDevProp, &dwError);
break;
default:
DEBUGMSG(ZONE_IOCTL, (_T("CAM_IOControl(%08x): Invalid Request\r\n"), this));
return dwError ;
}
return dwError;
}
//-----------------------------------------------------------------------------
//
// Function: AdapterHandleCompressionRequests
//
// Get and set video compression settings for the device.
//
// Parameters:
// pInBuf
// [in] Input buffer.
//
// InBufLen
// [in] Input buffer length.
//
// pOutBuf
// [in] Output buffer.
//
// OutBufLen
// [in] Output buffer length.
//
// pdwBytesTransferred
// [in] Bytes transferred.
//
// Returns:
// Returns ERROR_INVALID_PARAMETER.
//
//-----------------------------------------------------------------------------
DWORD CCameraDevice::AdapterHandleCompressionRequests(
PUCHAR pInBuf,
DWORD InBufLen,
PUCHAR pOutBuf,
DWORD OutBufLen,
PDWORD pdwBytesTransferred
)
{
DEBUGMSG(ZONE_IOCTL, (_T("CAM_IOControl(%08x): HandleCompressionRequests\r\n"), this));
return ERROR_INVALID_PARAMETER;
}
//-----------------------------------------------------------------------------
//
// Function: AdapterHandleVideoControlRequests
//
// Controls additional aspects of the video capture operation.
//
// Parameters:
// pInBuf
// [in] Input buffer.
//
// InBufLen
// [in] Input buffer length.
//
// pOutBuf
// [in] Output buffer.
//
// OutBufLen
// [in] Output buffer length.
//
// pdwBytesTransferred
// [in] Bytes transferred.
//
// Returns:
// Returns ERROR_SUCCESS if the operation completes successfully;
// Otherwise, returns a Microsoft Win32 error code.
//
//-----------------------------------------------------------------------------
DWORD CCameraDevice::AdapterHandleVideoControlRequests(
PUCHAR pInBuf,
DWORD InBufLen,
PUCHAR pOutBuf,
DWORD OutBufLen,
PDWORD pdwBytesTransferred
)
{
DEBUGMSG(ZONE_IOCTL, (_T("CAM_IOControl(%08x): HandleVideoControlRequests\r\n"), this));
DWORD dwError = ERROR_INVALID_PARAMETER;
LONG lValue = 0;
ULONG ulCaps = 0;
ULONG ulMode = 0;
PCSPROPERTY_VIDEOCONTROL_CAPS_S pCsPropVideoControlCapsOutput = NULL;
PCSPROPERTY_VIDEOCONTROL_CAPS_S pCsPropVideoControlCapsInput = NULL;
PCSPROPERTY_VIDEOCONTROL_MODE_S pCsPropVideoControlModeOutput = NULL;
PCSPROPERTY_VIDEOCONTROL_MODE_S pCsPropVideoControlModeInput = NULL;
PCSPROPERTY_VIDEOCONTROL_FRAME_RATES_S pCsPropVideoControlFrameRateOutput = NULL;
PCSPROPERTY_VIDEOCONTROL_FRAME_RATES_S pCsPropVideoControlFrameRateInput = NULL;
PCSPROPERTY_VIDEOCONTROL_ACTUAL_FRAME_RATE_S pCsPropVideoControlActFrameRateOutput = NULL;
PCSPROPERTY_VIDEOCONTROL_ACTUAL_FRAME_RATE_S pCsPropVideoControlActFrameRateInput = NULL;
DEBUGMSG(ZONE_ERROR, (_T("CAM_IOControl(%08x): Earlier...In Buffer size = 0x%x, Expected Buffer size = 0x%x.\r\n"),
this, InBufLen, sizeof(CSPROPERTY_VIDEOCONTROL_MODE_S)));
PCSPROPERTY pCsProp = reinterpret_cast<PCSPROPERTY>(ValidateBuffer( pInBuf, InBufLen, sizeof (CSPROPERTY), &dwError));
if (NULL == pCsProp)
{
return dwError;
}
*pdwBytesTransferred = 0;
// we support PROPSETID_Pin, so just return success
if (CSPROPERTY_TYPE_SETSUPPORT == pCsProp->Flags)
{
return ERROR_SUCCESS;
}
switch(pCsProp->Id)
{
case CSPROPERTY_VIDEOCONTROL_CAPS:
if(NULL == (pCsPropVideoControlCapsInput = reinterpret_cast<PCSPROPERTY_VIDEOCONTROL_CAPS_S>(ValidateBuffer(pInBuf, InBufLen, sizeof(CSPROPERTY_VIDEOCONTROL_CAPS_S), &dwError))))
{
break;
}
if (false == IsValidPin(pCsPropVideoControlCapsInput->StreamIndex))
{
DEBUGMSG(ZONE_IOCTL, (_T("CAM_IOControl(%08x): Invalid PinId\r\n"), this));
break;
}
switch (pCsProp->Flags)
{
case CSPROPERTY_TYPE_GET:
*pdwBytesTransferred = sizeof(CSPROPERTY_VIDEOCONTROL_CAPS_S);
if (NULL == (pCsPropVideoControlCapsOutput = reinterpret_cast<PCSPROPERTY_VIDEOCONTROL_CAPS_S>(ValidateBuffer( pOutBuf, OutBufLen, *pdwBytesTransferred, &dwError))))
{
dwError = ERROR_MORE_DATA;
break;
}
//Copy the CSPROPERTY structure to the output buffer just in case!
memcpy(pCsPropVideoControlCapsOutput, pCsPropVideoControlCapsInput, sizeof( CSPROPERTY));
pCsPropVideoControlCapsOutput->StreamIndex = pCsPropVideoControlCapsInput->StreamIndex;
pCsPropVideoControlCapsOutput->VideoControlCaps = m_PinVideoCaps[pCsPropVideoControlCapsInput->StreamIndex].ulVideoControlCaps;
dwError = ERROR_SUCCESS;
break;
case CSPROPERTY_TYPE_SET:
ulCaps = pCsPropVideoControlCapsInput->VideoControlCaps;
if (ulCaps & ~(CS_VideoControlFlag_FlipHorizontal |
CS_VideoControlFlag_FlipVertical |
CS_VideoControlFlag_ExternalTriggerEnable |
CS_VideoControlFlag_Trigger))
{
DEBUGMSG(ZONE_IOCTL, (_T("CAM_IOControl(%08x): Invalid flag specified as Video Control Caps.\r\n"), this));
break;
}
m_PinVideoCaps[pCsPropVideoControlCapsInput->StreamIndex].ulVideoControlCaps = ulCaps;
dwError = ERROR_SUCCESS;
break;
case CSPROPERTY_TYPE_DEFAULTVALUES:
*pdwBytesTransferred = sizeof(CSPROPERTY_VIDEOCONTROL_CAPS_S);
if (NULL == (pCsPropVideoControlCapsOutput = reinterpret_cast<PCSPROPERTY_VIDEOCONTROL_CAPS_S>(ValidateBuffer(pOutBuf, OutBufLen, *pdwBytesTransferred, &dwError))))
{
dwError = ERROR_MORE_DATA;
break;
}
//Copy the CSPROPERTY structure to the output buffer just in case!
memcpy( pCsPropVideoControlCapsOutput, pCsPropVideoControlCapsInput, sizeof(CSPROPERTY));
pCsPropVideoControlCapsOutput->StreamIndex = pCsPropVideoControlCapsInput->StreamIndex;
pCsPropVideoControlCapsOutput->VideoControlCaps = DefaultVideoControlCaps[pCsPropVideoControlCapsInput->StreamIndex];
dwError = ERROR_SUCCESS;
break;
default:
DEBUGMSG(ZONE_IOCTL, (_T("CAM_IOControl(%08x): Invalid Request\r\n"), this));
break;
}
break;
case CSPROPERTY_VIDEOCONTROL_MODE:
DEBUGMSG(ZONE_ERROR, (_T("CAM_IOControl(%08x): In Buffer size = 0x%x, Expected Buffer size = 0x%x.\r\n"),
this, InBufLen, sizeof(CSPROPERTY_VIDEOCONTROL_MODE_S)));
if(NULL == (pCsPropVideoControlModeInput = reinterpret_cast<PCSPROPERTY_VIDEOCONTROL_MODE_S>(ValidateBuffer( pInBuf, InBufLen, sizeof(CSPROPERTY_VIDEOCONTROL_MODE_S), &dwError))))
{
break;
}
DEBUGMSG(ZONE_ERROR, (_T("CAM_IOControl(%08x): Past Valid Buffer Check.\r\n"), this));
if (false == IsValidPin(pCsPropVideoControlModeInput->StreamIndex))
{
DEBUGMSG(ZONE_IOCTL, (_T("CAM_IOControl(%08x): Invalid PinId\r\n"), this));
break;
}
switch(pCsProp->Flags)
{
case CSPROPERTY_TYPE_SET:
ulMode = pCsPropVideoControlModeInput->Mode;
if (ulMode & CS_VideoControlFlag_Trigger)
{
if (m_StrmInstances[pCsPropVideoC
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -