/MKLiveView/v1.0/Source/WebCamLib/ClassDiagram.cd |
---|
0,0 → 1,2 |
<?xml version="1.0" encoding="utf-8"?> |
<ClassDiagram /> |
/MKLiveView/v1.0/Source/WebCamLib/WebCamLib.cpp |
---|
0,0 → 1,1350 |
//***************************************************************************************** |
// File: WebCamLib.cpp |
// Project: WebcamLib |
// Author(s): John Conwell |
// Gary Caldwell |
// |
// Defines the webcam DirectShow wrapper used by TouchlessLib |
//***************************************************************************************** |
#include <dshow.h> |
#include <strsafe.h> |
#define __IDxtCompositor_INTERFACE_DEFINED__ |
#define __IDxtAlphaSetter_INTERFACE_DEFINED__ |
#define __IDxtJpeg_INTERFACE_DEFINED__ |
#define __IDxtKey_INTERFACE_DEFINED__ |
#pragma include_alias( "dxtrans.h", "qedit.h" ) |
#include "qedit.h" |
#include "WebCamLib.h" |
using namespace System; |
using namespace System::Reflection; |
using namespace WebCamLib; |
// Private variables |
#define MAX_CAMERAS 10 |
#pragma region CameraInfo Items |
CameraInfo::CameraInfo( int index, String^ name ) |
{ |
Index = index; |
Name = name; |
} |
int CameraInfo::Index::get() |
{ |
return index; |
} |
void CameraInfo::Index::set( int value ) |
{ |
index = value; |
} |
String^ CameraInfo::Name::get() |
{ |
return name; |
} |
void CameraInfo::Name::set( String^ value ) |
{ |
if( value != nullptr ) |
name = value; |
else |
throw gcnew ArgumentNullException( "Name cannot be null." ); |
} |
#pragma endregion |
#pragma region CameraPropertyCapabilities Items |
CameraPropertyCapabilities::CameraPropertyCapabilities( int cameraIndex, CameraProperty prop, bool isGetSupported, bool isSetSupported, bool isGetRangeSupported ) |
{ |
CameraIndex = cameraIndex; |
Property = prop; |
IsGetSupported = isGetSupported; |
IsSetSupported = isSetSupported; |
IsGetRangeSupported = isGetRangeSupported; |
} |
int CameraPropertyCapabilities::CameraIndex::get() |
{ |
return cameraIndex; |
} |
void CameraPropertyCapabilities::CameraIndex::set( int value ) |
{ |
cameraIndex =value; |
} |
CameraProperty CameraPropertyCapabilities::Property::get() |
{ |
return prop; |
} |
void CameraPropertyCapabilities::Property::set( CameraProperty value ) |
{ |
prop = value; |
} |
bool CameraPropertyCapabilities::IsGetSupported::get() |
{ |
return isGetSupported; |
} |
void CameraPropertyCapabilities::IsGetSupported::set( bool value ) |
{ |
isGetSupported = value; |
} |
bool CameraPropertyCapabilities::IsSetSupported::get() |
{ |
return isSetSupported; |
} |
void CameraPropertyCapabilities::IsSetSupported::set( bool value ) |
{ |
isSetSupported = value; |
} |
bool CameraPropertyCapabilities::IsGetRangeSupported::get() |
{ |
return isGetRangeSupported; |
} |
void CameraPropertyCapabilities::IsGetRangeSupported::set( bool value ) |
{ |
isGetRangeSupported = value; |
} |
bool CameraPropertyCapabilities::IsSupported::get() |
{ |
return IsGetSupported || IsSetSupported || IsGetRangeSupported; |
} |
bool CameraPropertyCapabilities::IsFullySupported::get() |
{ |
return IsGetSupported && IsSetSupported && IsGetRangeSupported; |
} |
#pragma endregion |
// Structure to hold camera information |
struct CameraInfoStruct |
{ |
BSTR bstrName; |
IMoniker* pMoniker; |
}; |
// Private global variables |
IGraphBuilder* g_pGraphBuilder = NULL; |
IMediaControl* g_pMediaControl = NULL; |
ICaptureGraphBuilder2* g_pCaptureGraphBuilder = NULL; |
IBaseFilter* g_pIBaseFilterCam = NULL; |
IBaseFilter* g_pIBaseFilterSampleGrabber = NULL; |
IBaseFilter* g_pIBaseFilterNullRenderer = NULL; |
CameraInfoStruct g_aCameraInfo[MAX_CAMERAS] = {0}; |
IMediaSeeking *m_pMediaSeek = NULL; |
// http://social.msdn.microsoft.com/Forums/sk/windowsdirectshowdevelopment/thread/052d6a15-f092-4913-b52d-d28f9a51e3b6 |
void MyFreeMediaType(AM_MEDIA_TYPE& mt) { |
if (mt.cbFormat != 0) { |
CoTaskMemFree((PVOID)mt.pbFormat); |
mt.cbFormat = 0; |
mt.pbFormat = NULL; |
} |
if (mt.pUnk != NULL) { |
// Unecessary because pUnk should not be used, but safest. |
mt.pUnk->Release(); |
mt.pUnk = NULL; |
} |
} |
void MyDeleteMediaType(AM_MEDIA_TYPE *pmt) { |
if (pmt != NULL) { |
MyFreeMediaType(*pmt); // See FreeMediaType for the implementation. |
CoTaskMemFree(pmt); |
} |
} |
/// <summary> |
/// Initializes information about all web cams connected to machine |
/// </summary> |
CameraMethods::CameraMethods() |
{ |
// Set to not disposed |
this->disposed = false; |
// Get and cache camera info |
RefreshCameraList(); |
} |
/// <summary> |
/// IDispose |
/// </summary> |
CameraMethods::~CameraMethods() |
{ |
Cleanup(); |
disposed = true; |
} |
/// <summary> |
/// Finalizer |
/// </summary> |
CameraMethods::!CameraMethods() |
{ |
if (!disposed) |
{ |
Cleanup(); |
} |
} |
/// <summary> |
/// Initialize information about webcams installed on machine |
/// </summary> |
void CameraMethods::RefreshCameraList() |
{ |
IEnumMoniker* pclassEnum = NULL; |
ICreateDevEnum* pdevEnum = NULL; |
int count = 0; |
CleanupCameraInfo(); |
HRESULT hr = CoCreateInstance(CLSID_SystemDeviceEnum, |
NULL, |
CLSCTX_INPROC, |
IID_ICreateDevEnum, |
(LPVOID*)&pdevEnum); |
if (SUCCEEDED(hr)) |
{ |
hr = pdevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, &pclassEnum, 0); |
} |
if (pdevEnum != NULL) |
{ |
pdevEnum->Release(); |
pdevEnum = NULL; |
} |
if (pclassEnum != NULL) |
{ |
IMoniker* apIMoniker[1]; |
ULONG ulCount = 0; |
while (SUCCEEDED(hr) && (count) < MAX_CAMERAS && pclassEnum->Next(1, apIMoniker, &ulCount) == S_OK) |
{ |
g_aCameraInfo[count].pMoniker = apIMoniker[0]; |
g_aCameraInfo[count].pMoniker->AddRef(); |
IPropertyBag *pPropBag; |
hr = apIMoniker[0]->BindToStorage(NULL, NULL, IID_IPropertyBag, (void **)&pPropBag); |
if (SUCCEEDED(hr)) |
{ |
// Retrieve the filter's friendly name |
VARIANT varName; |
VariantInit(&varName); |
hr = pPropBag->Read(L"FriendlyName", &varName, 0); |
if (SUCCEEDED(hr) && varName.vt == VT_BSTR) |
{ |
g_aCameraInfo[count].bstrName = SysAllocString(varName.bstrVal); |
} |
VariantClear(&varName); |
pPropBag->Release(); |
} |
count++; |
} |
pclassEnum->Release(); |
} |
this->Count = count; |
if (!SUCCEEDED(hr)) |
throw gcnew COMException("Error Refreshing Camera List", hr); |
} |
/// <summary> |
/// Retrieve information about a specific camera |
/// Use the count property to determine valid indicies to pass in |
/// </summary> |
CameraInfo^ CameraMethods::GetCameraInfo(int camIndex) |
{ |
if (camIndex >= Count) |
throw gcnew ArgumentOutOfRangeException("Camera index is out of bounds: " + Count.ToString()); |
if (g_aCameraInfo[camIndex].pMoniker == NULL) |
throw gcnew ArgumentException("There is no camera at index: " + camIndex.ToString()); |
CameraInfo^ camInfo = gcnew CameraInfo( camIndex, Marshal::PtrToStringBSTR((IntPtr)g_aCameraInfo[camIndex].bstrName) ); |
return camInfo; |
} |
/// <summary> |
/// Start the camera associated with the input handle |
/// </summary> |
void CameraMethods::StartCamera(int camIndex, interior_ptr<int> width, interior_ptr<int> height, interior_ptr<int> bpp, interior_ptr<bool> successful) |
{ |
*successful = StartCamera( camIndex, width, height, bpp ); |
} |
/// <summary> |
/// Start the camera associated with the input handle |
/// </summary> |
bool CameraMethods::StartCamera(int camIndex, interior_ptr<int> width, interior_ptr<int> height, interior_ptr<int> bpp) |
{ |
if (camIndex >= Count) |
throw gcnew ArgumentException("Camera index is out of bounds: " + Count.ToString()); |
if (g_aCameraInfo[camIndex].pMoniker == NULL) |
throw gcnew ArgumentException("There is no camera at index: " + camIndex.ToString()); |
if (g_pGraphBuilder != NULL) |
throw gcnew ArgumentException("Graph Builder was null"); |
// Setup up function callback -- through evil reflection on private members |
Type^ baseType = this->GetType(); |
FieldInfo^ field = baseType->GetField("<backing_store>OnImageCapture", BindingFlags::NonPublic | BindingFlags::Instance | BindingFlags::IgnoreCase); |
if (field != nullptr) |
{ |
Object^ obj = field->GetValue(this); |
if (obj != nullptr) |
{ |
CameraMethods::CaptureCallbackDelegate^ del = (CameraMethods::CaptureCallbackDelegate^)field->GetValue(this); |
if (del != nullptr) |
{ |
ppCaptureCallback = GCHandle::Alloc(del); |
g_pfnCaptureCallback = |
static_cast<PFN_CaptureCallback>(Marshal::GetFunctionPointerForDelegate(del).ToPointer()); |
} |
} |
} |
bool result = false; |
IMoniker *pMoniker = g_aCameraInfo[camIndex].pMoniker; |
pMoniker->AddRef(); |
HRESULT hr = S_OK; |
// Build all the necessary interfaces to start the capture |
if (SUCCEEDED(hr)) |
{ |
hr = CoCreateInstance(CLSID_FilterGraph, |
NULL, |
CLSCTX_INPROC, |
IID_IGraphBuilder, |
(LPVOID*)&g_pGraphBuilder); |
} |
if (SUCCEEDED(hr)) |
{ |
hr = g_pGraphBuilder->QueryInterface(IID_IMediaControl, (LPVOID*)&g_pMediaControl); |
} |
if (SUCCEEDED(hr)) |
{ |
hr = CoCreateInstance(CLSID_CaptureGraphBuilder2, |
NULL, |
CLSCTX_INPROC, |
IID_ICaptureGraphBuilder2, |
(LPVOID*)&g_pCaptureGraphBuilder); |
} |
// Setup the filter graph |
if (SUCCEEDED(hr)) |
{ |
hr = g_pCaptureGraphBuilder->SetFiltergraph(g_pGraphBuilder); |
} |
// Build the camera from the moniker |
if (SUCCEEDED(hr)) |
{ |
hr = pMoniker->BindToObject(NULL, NULL, IID_IBaseFilter, (LPVOID*)&g_pIBaseFilterCam); |
} |
// Add the camera to the filter graph |
if (SUCCEEDED(hr)) |
{ |
hr = g_pGraphBuilder->AddFilter(g_pIBaseFilterCam, L"WebCam"); |
} |
// Set the resolution |
if (SUCCEEDED(hr)) { |
hr = SetCaptureFormat(g_pIBaseFilterCam, *width, *height, *bpp); |
} |
// Create a SampleGrabber |
if (SUCCEEDED(hr)) |
{ |
hr = CoCreateInstance(CLSID_SampleGrabber, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)&g_pIBaseFilterSampleGrabber); |
} |
// Configure the Sample Grabber |
if (SUCCEEDED(hr)) |
{ |
hr = ConfigureSampleGrabber(g_pIBaseFilterSampleGrabber); |
} |
// Add Sample Grabber to the filter graph |
if (SUCCEEDED(hr)) |
{ |
hr = g_pGraphBuilder->AddFilter(g_pIBaseFilterSampleGrabber, L"SampleGrabber"); |
} |
// Create the NullRender |
if (SUCCEEDED(hr)) |
{ |
hr = CoCreateInstance(CLSID_NullRenderer, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)&g_pIBaseFilterNullRenderer); |
} |
// Add the Null Render to the filter graph |
if (SUCCEEDED(hr)) |
{ |
hr = g_pGraphBuilder->AddFilter(g_pIBaseFilterNullRenderer, L"NullRenderer"); |
} |
// Configure the render stream |
if (SUCCEEDED(hr)) |
{ |
hr = g_pCaptureGraphBuilder->RenderStream(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, g_pIBaseFilterCam, g_pIBaseFilterSampleGrabber, g_pIBaseFilterNullRenderer); |
} |
// Grab the capture width and height |
if (SUCCEEDED(hr)) |
{ |
ISampleGrabber* pGrabber = NULL; |
hr = g_pIBaseFilterSampleGrabber->QueryInterface(IID_ISampleGrabber, (LPVOID*)&pGrabber); |
if (SUCCEEDED(hr)) |
{ |
AM_MEDIA_TYPE mt; |
hr = pGrabber->GetConnectedMediaType(&mt); |
if (SUCCEEDED(hr)) |
{ |
VIDEOINFOHEADER *pVih; |
if ((mt.formattype == FORMAT_VideoInfo) && |
(mt.cbFormat >= sizeof(VIDEOINFOHEADER)) && |
(mt.pbFormat != NULL) ) |
{ |
pVih = (VIDEOINFOHEADER*)mt.pbFormat; |
*width = pVih->bmiHeader.biWidth; |
*height = pVih->bmiHeader.biHeight; |
*bpp = pVih->bmiHeader.biBitCount; |
} |
else |
{ |
hr = E_FAIL; // Wrong format |
} |
// FreeMediaType(mt); (from MSDN) |
if (mt.cbFormat != 0) |
{ |
CoTaskMemFree((PVOID)mt.pbFormat); |
mt.cbFormat = 0; |
mt.pbFormat = NULL; |
} |
if (mt.pUnk != NULL) |
{ |
// Unecessary because pUnk should not be used, but safest. |
mt.pUnk->Release(); |
mt.pUnk = NULL; |
} |
} |
} |
if (pGrabber != NULL) |
{ |
pGrabber->Release(); |
pGrabber = NULL; |
} |
} |
// Start the capture |
if (SUCCEEDED(hr)) |
{ |
hr = g_pMediaControl->Run(); |
} |
// If init fails then ensure that you cleanup |
if (FAILED(hr)) |
{ |
StopCamera(); |
} |
else |
{ |
hr = S_OK; // Make sure we return S_OK for success |
} |
// Cleanup |
if (pMoniker != NULL) |
{ |
pMoniker->Release(); |
pMoniker = NULL; |
} |
if( result = SUCCEEDED( hr ) ) |
this->activeCameraIndex = camIndex; |
return result; |
} |
#pragma region Camera Property Support |
inline void CameraMethods::IsPropertySupported( CameraProperty prop, interior_ptr<bool> result ) |
{ |
*result = IsPropertySupported( prop ); |
} |
inline bool CameraMethods::IsPropertySupported( CameraProperty prop ) |
{ |
bool result = false; |
if( IsCameraControlProperty( prop ) ) |
result = IsPropertySupported( GetCameraControlProperty( prop ) ); |
else if( IsVideoProcAmpProperty( prop ) ) |
result = IsPropertySupported( GetVideoProcAmpProperty( prop ) ); |
return result; |
} |
bool CameraMethods::IsPropertySupported( WebCamLib::CameraControlProperty prop ) |
{ |
bool result = false; |
IAMCameraControl * cameraControl = NULL; |
HRESULT hr = g_pIBaseFilterCam->QueryInterface(IID_IAMCameraControl, (void**)&cameraControl); |
if(SUCCEEDED(hr)) |
{ |
long lProperty = static_cast< long >( prop ); |
long value, captureFlags; |
hr = cameraControl->Get(lProperty, &value, &captureFlags); |
result = SUCCEEDED(hr); |
} |
//else |
// throw gcnew InvalidOperationException( "Unable to determine if the property is supported." ); |
return result; |
} |
bool CameraMethods::IsPropertySupported( WebCamLib::VideoProcAmpProperty prop ) |
{ |
bool result = false; |
IAMVideoProcAmp * pProcAmp = NULL; |
HRESULT hr = g_pIBaseFilterCam->QueryInterface(IID_IAMVideoProcAmp, (void**)&pProcAmp); |
if(SUCCEEDED(hr)) |
{ |
long lProperty = static_cast< long >( prop ); |
long value, captureFlags; |
hr = pProcAmp->Get(lProperty, &value, &captureFlags); |
result = SUCCEEDED(hr); |
} |
else |
throw gcnew InvalidOperationException( "Unable to determine if the property is supported." ); |
return result; |
} |
inline bool CameraMethods::IsCameraControlProperty( CameraProperty prop ) |
{ |
return IsPropertyMaskEqual( prop, PropertyTypeMask::CameraControlPropertyMask ); |
} |
inline bool CameraMethods::IsVideoProcAmpProperty( CameraProperty prop ) |
{ |
return IsPropertyMaskEqual( prop, PropertyTypeMask::VideoProcAmpPropertyMask ); |
} |
inline bool CameraMethods::IsPropertyMaskEqual( CameraProperty prop, PropertyTypeMask mask ) |
{ |
return ( static_cast< int >( prop ) & static_cast< int >( mask ) ) != 0; |
} |
inline void CameraMethods::GetProperty( CameraProperty prop, bool isValue, interior_ptr<long> value, interior_ptr<bool> bAuto, interior_ptr<bool> successful ) |
{ |
*successful = GetProperty( prop, isValue, value, bAuto ); |
} |
inline bool CameraMethods::GetProperty( CameraProperty prop, bool isValue, interior_ptr<long> value, interior_ptr<bool> bAuto ) |
{ |
bool result; |
if( isValue ) |
result = GetProperty_value( prop, value, bAuto ); |
else // is a percentage value |
result = GetProperty_percentage( prop, value, bAuto ); |
return result; |
} |
inline WebCamLib::CameraControlProperty CameraMethods::GetCameraControlProperty( CameraProperty prop ) |
{ |
if( IsCameraControlProperty( prop ) ) |
{ |
int value = static_cast< int >( prop ); |
int mask = static_cast< int >( PropertyTypeMask::CameraControlPropertyMask ); |
value &= ~mask; |
return static_cast< WebCamLib::CameraControlProperty >( value ); |
} |
else |
throw gcnew OverflowException( "Property is not a camera property." ); |
} |
inline WebCamLib::VideoProcAmpProperty CameraMethods::GetVideoProcAmpProperty( CameraProperty prop ) |
{ |
if( IsVideoProcAmpProperty( prop ) ) |
{ |
int value = static_cast< int >( prop ); |
int mask = static_cast< int >( PropertyTypeMask::VideoProcAmpPropertyMask ); |
value &= ~mask; |
return static_cast< WebCamLib::VideoProcAmpProperty >( value ); |
} |
else |
throw gcnew OverflowException( "Property is not a camera property." ); |
} |
inline void CameraMethods::GetProperty_value( CameraProperty prop, interior_ptr<long> value, interior_ptr<bool> bAuto, interior_ptr<bool> successful) |
{ |
*successful = GetProperty_value( prop, value, bAuto ); |
} |
inline bool CameraMethods::GetProperty_value( CameraProperty prop, interior_ptr<long> value, interior_ptr<bool> bAuto) |
{ |
bool result = false; |
if( IsCameraControlProperty( prop ) ) |
result = GetProperty_value( GetCameraControlProperty( prop ), value, bAuto ); |
else if( IsVideoProcAmpProperty( prop ) ) |
result = GetProperty_value( GetVideoProcAmpProperty( prop ), value, bAuto ); |
return result; |
} |
inline void CameraMethods::GetProperty_percentage( CameraProperty prop, interior_ptr<long> percentage, interior_ptr<bool> bAuto, interior_ptr<bool> successful) |
{ |
*successful = GetProperty_percentage( prop, percentage, bAuto ); |
} |
bool CameraMethods::GetProperty_percentage( CameraProperty prop, interior_ptr<long> percentage, interior_ptr<bool> bAuto) |
{ |
bool result; |
long value; |
if( result = GetProperty_value( prop, &value, bAuto ) ) |
{ |
long min, max, steppingDelta, defaults; |
bool placeHolder; |
if( result = GetPropertyRange( prop, &min, &max, &steppingDelta, &defaults, &placeHolder ) ) |
*percentage = ( ( value - min ) * 100 ) / ( max - min + 1 ); |
} |
return result; |
} |
inline void CameraMethods::SetProperty( CameraProperty prop, bool isValue, long value, bool bAuto, interior_ptr<bool> successful ) |
{ |
*successful = SetProperty( prop, isValue, value, bAuto ); |
} |
inline bool CameraMethods::SetProperty( CameraProperty prop, bool isValue, long value, bool bAuto ) |
{ |
bool result; |
if( isValue ) |
result = SetProperty_value( prop, value, bAuto ); |
else // is a percentage value |
result = SetProperty_percentage( prop, value, bAuto ); |
return result; |
} |
inline void CameraMethods::SetProperty_value(CameraProperty prop, long value, bool bAuto, interior_ptr<bool> successful) |
{ |
*successful = SetProperty_value( prop, value, bAuto ); |
} |
inline bool CameraMethods::SetProperty_value(CameraProperty prop, long value, bool bAuto) |
{ |
return SetProperty_value( prop, value, bAuto, true ); |
} |
inline void CameraMethods::SetProperty_value( CameraProperty prop, long value, bool bAuto, bool throwValidationError, interior_ptr<bool> successful ) |
{ |
*successful = SetProperty_value( prop, value, bAuto, throwValidationError ); |
} |
inline bool CameraMethods::SetProperty_value( CameraProperty prop, long value, bool bAuto, bool throwValidationError ) |
{ |
bool result = false; |
if( ValidatePropertyValue( prop, value ) ) |
{ |
if( IsCameraControlProperty( prop ) ) |
result = SetProperty_value( GetCameraControlProperty( prop ), value, bAuto ); |
else if( IsVideoProcAmpProperty( prop ) ) |
result = SetProperty_value( GetVideoProcAmpProperty( prop ), value, bAuto ); |
} |
else if( throwValidationError ) |
throw gcnew ArgumentOutOfRangeException( "Property value is outside of its defined range." ); |
return result; |
} |
inline void CameraMethods::SetProperty_percentage(CameraProperty prop, long percentage, bool bAuto, interior_ptr<bool> successful) |
{ |
*successful = SetProperty_percentage( prop, percentage, bAuto ); |
} |
bool CameraMethods::SetProperty_percentage(CameraProperty prop, long percentage, bool bAuto) |
{ |
if( !IsPropertySupported( prop ) ) |
throw gcnew ArgumentException( "Property is not supported." ); |
else if( percentage >= 0 && percentage <= 100 ) |
{ |
bool result; |
long min, max, steppingDelta, defaults; |
bool placeHolder; |
if( result = GetPropertyRange( prop, &min, &max, &steppingDelta, &defaults, &placeHolder ) ) |
{ |
long value = ( ( max - min ) * percentage ) / 100 + min; |
result = SetProperty_value( prop, value, bAuto ); |
} |
return result; |
} |
else |
throw gcnew ArgumentOutOfRangeException( "Percentage is not valid." ); |
} |
inline void CameraMethods::GetPropertyRange( CameraProperty prop, interior_ptr<long> min, interior_ptr<long> max, interior_ptr<long> steppingDelta, interior_ptr<long> defaults, interior_ptr<bool> bAuto, interior_ptr<bool> successful) |
{ |
*successful = GetPropertyRange( prop, min, max, steppingDelta, defaults, bAuto ); |
} |
inline bool CameraMethods::GetPropertyRange( CameraProperty prop, interior_ptr<long> min, interior_ptr<long> max, interior_ptr<long> steppingDelta, interior_ptr<long> defaults, interior_ptr<bool> bAuto) |
{ |
bool result = false; |
if( IsCameraControlProperty( prop ) ) |
result = GetPropertyRange( GetCameraControlProperty( prop ), min, max, steppingDelta, defaults, bAuto ); |
else if( IsVideoProcAmpProperty( prop ) ) |
result = GetPropertyRange( GetVideoProcAmpProperty( prop ), min, max, steppingDelta, defaults, bAuto ); |
return result; |
} |
bool CameraMethods::GetPropertyRange( WebCamLib::CameraControlProperty prop, interior_ptr<long> min, interior_ptr<long> max, interior_ptr<long> steppingDelta, interior_ptr<long> defaults, interior_ptr<bool> bAuto ) |
{ |
bool result = false; |
IAMCameraControl * cameraControl = NULL; |
HRESULT hr = g_pIBaseFilterCam->QueryInterface(IID_IAMCameraControl, (void**)&cameraControl); |
if( SUCCEEDED( hr ) ) |
{ |
long lProperty = static_cast< long >( prop ); |
long minimum, maximum, step, default_value, flags; |
hr = cameraControl->GetRange( lProperty, &minimum, &maximum, &step, &default_value, &flags ); |
if( SUCCEEDED( hr ) ) |
{ |
*min = minimum; |
*max = maximum; |
*steppingDelta = step; |
*defaults = default_value; |
*bAuto = flags == CameraControl_Flags_Auto; |
result = SUCCEEDED(hr); |
} |
} |
return result; |
} |
bool CameraMethods::GetPropertyRange( WebCamLib::VideoProcAmpProperty prop, interior_ptr<long> min, interior_ptr<long> max, interior_ptr<long> steppingDelta, interior_ptr<long> defaults, interior_ptr<bool> bAuto ) |
{ |
bool result = false; |
IAMVideoProcAmp * pProcAmp = NULL; |
HRESULT hr = g_pIBaseFilterCam->QueryInterface(IID_IAMVideoProcAmp, (void**)&pProcAmp); |
if( SUCCEEDED( hr ) ) |
{ |
long lProperty = static_cast< long >( prop ); |
long minimum, maximum, step, default_value, flags; |
hr = pProcAmp->GetRange( lProperty, &minimum, &maximum, &step, &default_value, &flags ); |
if( SUCCEEDED( hr ) ) |
{ |
*min = minimum; |
*max = maximum; |
*steppingDelta = step; |
*defaults = default_value; |
*bAuto = flags == CameraControl_Flags_Auto; |
result = SUCCEEDED(hr); |
} |
} |
return result; |
} |
bool CameraMethods::GetProperty_value( WebCamLib::CameraControlProperty prop, interior_ptr<long> value, interior_ptr<bool> bAuto ) |
{ |
if( g_pIBaseFilterCam == NULL ) |
throw gcnew InvalidOperationException( "No camera started." ); |
bool result = false; |
IAMCameraControl * cameraControl = NULL; |
HRESULT hr = g_pIBaseFilterCam->QueryInterface(IID_IAMCameraControl, (void**)&cameraControl); |
if( SUCCEEDED( hr ) ) |
{ |
long lProperty = static_cast< long >( prop ); |
long lValue, captureFlags; |
hr = cameraControl->Get(lProperty, &lValue, &captureFlags); |
if( result = SUCCEEDED( hr ) ) |
{ |
*value = lValue; |
*bAuto = captureFlags == CameraControl_Flags_Auto; |
} |
} |
return result; |
} |
bool CameraMethods::GetProperty_value( WebCamLib::VideoProcAmpProperty prop, interior_ptr<long> value, interior_ptr<bool> bAuto ) |
{ |
if( g_pIBaseFilterCam == NULL ) |
throw gcnew InvalidOperationException( "No camera started." ); |
bool result = false; |
IAMVideoProcAmp * pProcAmp = NULL; |
HRESULT hr = g_pIBaseFilterCam->QueryInterface(IID_IAMVideoProcAmp, (void**)&pProcAmp); |
if( SUCCEEDED( hr ) ) |
{ |
long lProperty = static_cast< long >( prop ); |
long lValue, captureFlags; |
hr = pProcAmp->Get(lProperty, &lValue, &captureFlags); |
if( result = SUCCEEDED( hr ) ) |
{ |
*value = lValue; |
*bAuto = captureFlags == VideoProcAmp_Flags_Auto; |
} |
} |
return result; |
} |
bool CameraMethods::SetProperty_value( WebCamLib::CameraControlProperty prop, long value, bool bAuto ) |
{ |
if( g_pIBaseFilterCam == NULL ) |
throw gcnew InvalidOperationException( "No camera started." ); |
bool result = false; |
// Query the capture filter for the IAMCameraControl interface. |
IAMCameraControl * cameraControl = NULL; |
HRESULT hr = g_pIBaseFilterCam->QueryInterface(IID_IAMCameraControl, (void**)&cameraControl); |
if( SUCCEEDED( hr ) ) |
{ |
long lProperty = static_cast< long >( prop ); |
hr = cameraControl->Set(lProperty, value, bAuto ? CameraControl_Flags_Auto : CameraControl_Flags_Manual); |
result = SUCCEEDED( hr ); |
} |
return result; |
} |
bool CameraMethods::SetProperty_value( WebCamLib::VideoProcAmpProperty prop, long value, bool bAuto ) |
{ |
if( g_pIBaseFilterCam == NULL ) |
throw gcnew InvalidOperationException( "No camera started." ); |
bool result = false; |
// Query the capture filter for the IAMVideoProcAmp interface. |
IAMVideoProcAmp * pProcAmp = NULL; |
HRESULT hr = g_pIBaseFilterCam->QueryInterface(IID_IAMVideoProcAmp, (void**)&pProcAmp); |
if( SUCCEEDED( hr ) ) |
{ |
long lProperty = static_cast< long >( prop ); |
hr = pProcAmp->Set(lProperty, value, bAuto ? VideoProcAmp_Flags_Auto : VideoProcAmp_Flags_Manual); |
result = SUCCEEDED( hr ); |
} |
return result; |
} |
void CameraMethods::PropertyHasRange( CameraProperty prop, interior_ptr<bool> successful ) |
{ |
*successful = PropertyHasRange( prop ); |
} |
bool CameraMethods::PropertyHasRange( CameraProperty prop ) |
{ |
bool result = prop != CameraProperty::WhiteBalance && prop != CameraProperty::Gain; |
return result; |
} |
inline void CameraMethods::ValidatePropertyValue( CameraProperty prop, long value, interior_ptr<bool> successful ) |
{ |
*successful = ValidatePropertyValue( prop, value ); |
} |
bool CameraMethods::ValidatePropertyValue( CameraProperty prop, long value ) |
{ |
bool result = true; |
if( PropertyHasRange( prop ) ) |
{ |
long min, max, steppingDelta, defaults; |
bool bAuto; |
GetPropertyRange( prop, &min, &max, &steppingDelta, &defaults, &bAuto ); |
result = value >= min && value <= max; |
} |
return result; |
} |
CameraPropertyCapabilities^ CameraMethods::GetPropertyCapability( CameraProperty prop ) |
{ |
long value; |
bool isAuto; |
bool propertyHasRange = PropertyHasRange( prop ); |
bool isSetSupported; |
bool isGetSupported = GetProperty_value( prop, &value, &isAuto ); |
if( isGetSupported ) |
isSetSupported = SetProperty_value( prop, value, isAuto ); |
else |
isSetSupported = false; |
CameraPropertyCapabilities^ result = gcnew CameraPropertyCapabilities( ActiveCameraIndex, prop, isGetSupported, isSetSupported, propertyHasRange ); |
return result; |
} |
IDictionary<CameraProperty, CameraPropertyCapabilities^> ^ CameraMethods::PropertyCapabilities::get() |
{ |
Array^ propertyValues = Enum::GetValues( CameraProperty::typeid ); |
IDictionary<CameraProperty, CameraPropertyCapabilities^> ^ result = gcnew Dictionary<CameraProperty, CameraPropertyCapabilities^>( propertyValues->Length ); |
for( Int32 i = 0; i < propertyValues->Length; ++i ) |
{ |
CameraProperty prop = static_cast<CameraProperty>( propertyValues->GetValue( i ) ); |
result->Add( prop, GetPropertyCapability( prop ) ); |
} |
return result; |
} |
#pragma endregion |
/// <summary> |
/// Closes any open webcam and releases all unmanaged resources |
/// </summary> |
void CameraMethods::Cleanup() |
{ |
StopCamera(); |
CleanupCameraInfo(); |
// Clean up pinned pointer to callback delegate |
if (ppCaptureCallback.IsAllocated) |
{ |
ppCaptureCallback.Free(); |
} |
} |
/// <summary> |
/// Stops the current open webcam |
/// </summary> |
void CameraMethods::StopCamera() |
{ |
//HRESULT hr = g_pGraphBuilder->QueryInterface(IID_IMediaSeeking, (void**)&m_pMediaSeek); |
g_pfnCaptureCallback = NULL; |
if (g_pIBaseFilterNullRenderer != NULL) |
{ |
g_pIBaseFilterNullRenderer->Release(); |
g_pIBaseFilterNullRenderer = NULL; |
} |
if (g_pIBaseFilterSampleGrabber != NULL) |
{ |
g_pIBaseFilterSampleGrabber->Release(); |
g_pIBaseFilterSampleGrabber = NULL; |
} |
if (g_pIBaseFilterCam != NULL) |
{ |
g_pIBaseFilterCam->Release(); |
g_pIBaseFilterCam = NULL; |
} |
if (g_pGraphBuilder != NULL) |
{ |
g_pGraphBuilder->Release(); |
g_pGraphBuilder = NULL; |
} |
if (g_pCaptureGraphBuilder != NULL) |
{ |
g_pCaptureGraphBuilder->Release(); |
g_pCaptureGraphBuilder = NULL; |
} |
if (g_pMediaControl != NULL) |
{ |
g_pMediaControl->Pause(); |
//try |
//{ |
g_pMediaControl->GetState(1000, NULL); |
// long long m_pStart = 0; |
// if (m_pMediaSeek != NULL) |
// { |
// m_pMediaSeek->SetPositions(&m_pStart, AM_SEEKING_AbsolutePositioning, NULL, AM_SEEKING_NoPositioning); |
// } |
//// g_pMediaControl->Run(); |
// hr = g_pMediaControl->GetState(1000, NULL); |
g_pMediaControl->Stop(); |
// g_pMediaControl->GetState(1000, NULL); |
//} |
//catch (const int e) |
//{ |
//} |
//finally |
{ |
g_pMediaControl->Release(); |
g_pMediaControl = NULL; |
} |
} |
this->activeCameraIndex = -1; |
} |
/// <summary> |
/// Show the properties dialog for the specified webcam |
/// </summary> |
void CameraMethods::DisplayCameraPropertiesDialog(int camIndex) |
{ |
if (camIndex >= Count) |
throw gcnew ArgumentException("Camera index is out of bounds: " + Count.ToString()); |
if (g_aCameraInfo[camIndex].pMoniker == NULL) |
throw gcnew ArgumentException("There is no camera at index: " + camIndex.ToString()); |
HRESULT hr = S_OK; |
IBaseFilter *pFilter = NULL; |
ISpecifyPropertyPages *pProp = NULL; |
IMoniker *pMoniker = g_aCameraInfo[camIndex].pMoniker; |
pMoniker->AddRef(); |
// Create a filter graph for the moniker |
if (SUCCEEDED(hr)) |
{ |
hr = pMoniker->BindToObject(NULL, NULL, IID_IBaseFilter, (LPVOID*)&pFilter); |
} |
// See if it implements a property page |
if (SUCCEEDED(hr)) |
{ |
hr = pFilter->QueryInterface(IID_ISpecifyPropertyPages, (LPVOID*)&pProp); |
} |
// Show the property page |
if (SUCCEEDED(hr)) |
{ |
FILTER_INFO filterinfo; |
hr = pFilter->QueryFilterInfo(&filterinfo); |
IUnknown *pFilterUnk = NULL; |
if (SUCCEEDED(hr)) |
{ |
hr = pFilter->QueryInterface(IID_IUnknown, (LPVOID*)&pFilterUnk); |
} |
if (SUCCEEDED(hr)) |
{ |
CAUUID caGUID; |
pProp->GetPages(&caGUID); |
OleCreatePropertyFrame( |
NULL, // Parent window |
0, 0, // Reserved |
filterinfo.achName, // Caption for the dialog box |
1, // Number of objects (just the filter) |
&pFilterUnk, // Array of object pointers. |
caGUID.cElems, // Number of property pages |
caGUID.pElems, // Array of property page CLSIDs |
0, // Locale identifier |
0, NULL // Reserved |
); |
} |
if (pFilterUnk != NULL) |
{ |
pFilterUnk->Release(); |
pFilterUnk = NULL; |
} |
} |
if (pProp != NULL) |
{ |
pProp->Release(); |
pProp = NULL; |
} |
if (pMoniker != NULL) |
{ |
pMoniker->Release(); |
pMoniker = NULL; |
} |
if (pFilter != NULL) |
{ |
pFilter->Release(); |
pFilter = NULL; |
} |
//if (!SUCCEEDED(hr)) |
// throw gcnew COMException("Error displaying camera properties dialog", hr); |
} |
/// <summary> |
/// Releases all unmanaged resources |
/// </summary> |
void CameraMethods::CleanupCameraInfo() |
{ |
for (int n = 0; n < MAX_CAMERAS; n++) |
{ |
SysFreeString(g_aCameraInfo[n].bstrName); |
g_aCameraInfo[n].bstrName = NULL; |
if (g_aCameraInfo[n].pMoniker != NULL) |
{ |
g_aCameraInfo[n].pMoniker->Release(); |
g_aCameraInfo[n].pMoniker = NULL; |
} |
} |
} |
/// <summary> |
/// Setup the callback functionality for DirectShow |
/// </summary> |
HRESULT CameraMethods::ConfigureSampleGrabber(IBaseFilter *pIBaseFilter) |
{ |
HRESULT hr = S_OK; |
ISampleGrabber *pGrabber = NULL; |
hr = pIBaseFilter->QueryInterface(IID_ISampleGrabber, (void**)&pGrabber); |
if (SUCCEEDED(hr)) |
{ |
AM_MEDIA_TYPE mt; |
ZeroMemory(&mt, sizeof(AM_MEDIA_TYPE)); |
mt.majortype = MEDIATYPE_Video; |
mt.subtype = MEDIASUBTYPE_RGB24; |
mt.formattype = FORMAT_VideoInfo; |
hr = pGrabber->SetMediaType(&mt); |
} |
if (SUCCEEDED(hr)) |
{ |
hr = pGrabber->SetCallback(new SampleGrabberCB(), 1); |
} |
if (pGrabber != NULL) |
{ |
pGrabber->Release(); |
pGrabber = NULL; |
} |
return hr; |
} |
void CameraMethods::GetCaptureSizes(int index, IList<Tuple<int,int,int>^> ^ sizes) |
{ |
sizes->Clear(); |
HRESULT hr = S_OK; |
if (index >= Count) |
throw gcnew ArgumentException("Camera index is out of bounds: " + Count.ToString()); |
if (g_aCameraInfo[index].pMoniker == NULL) |
throw gcnew ArgumentException("There is no camera at index: " + index.ToString()); |
if (g_pGraphBuilder != NULL) |
throw gcnew ArgumentException("Graph Builder was null"); |
IMoniker *pMoniker = g_aCameraInfo[index].pMoniker; |
pMoniker->AddRef(); |
IBaseFilter* pCap = NULL; |
// Build the camera from the moniker |
if (SUCCEEDED(hr)) |
hr = pMoniker->BindToObject(NULL, NULL, IID_IBaseFilter, (LPVOID*)&pCap); |
ICaptureGraphBuilder2* captureGraphBuilder = NULL; |
if (SUCCEEDED(hr)) |
{ |
hr = CoCreateInstance(CLSID_CaptureGraphBuilder2, |
NULL, |
CLSCTX_INPROC, |
IID_ICaptureGraphBuilder2, |
(LPVOID*)&captureGraphBuilder); |
} |
IAMStreamConfig *pConfig = NULL; |
if(SUCCEEDED(hr)) |
hr = captureGraphBuilder->FindInterface( |
&PIN_CATEGORY_CAPTURE, |
&MEDIATYPE_Video, |
pCap, // Pointer to the capture filter. |
IID_IAMStreamConfig, (void**)&pConfig); |
int iCount = 0, iSize = 0; |
if(SUCCEEDED(hr)) |
hr = pConfig->GetNumberOfCapabilities(&iCount, &iSize); |
// Check the size to make sure we pass in the correct structure. |
if (SUCCEEDED(hr) && iSize == sizeof(VIDEO_STREAM_CONFIG_CAPS)) |
{ |
// Use the video capabilities structure. |
for (int iFormat = 0; iFormat < iCount; iFormat++) |
{ |
VIDEO_STREAM_CONFIG_CAPS scc; |
AM_MEDIA_TYPE *pmt; |
/* Note: Use of the VIDEO_STREAM_CONFIG_CAPS structure to configure a video device is |
deprecated. Although the caller must allocate the buffer, it should ignore the |
contents after the method returns. The capture device will return its supported |
formats through the pmt parameter. */ |
hr = pConfig->GetStreamCaps(iFormat, &pmt, (BYTE*)&scc); |
if (SUCCEEDED(hr)) |
{ |
/* Examine the format, and possibly use it. */ |
if (pmt->formattype == FORMAT_VideoInfo) { |
// Check the buffer size. |
if (pmt->cbFormat >= sizeof(VIDEOINFOHEADER)) |
{ |
VIDEOINFOHEADER *pVih = reinterpret_cast<VIDEOINFOHEADER*>(pmt->pbFormat); |
BITMAPINFOHEADER *bmiHeader = &pVih->bmiHeader; |
int width = bmiHeader->biWidth; |
int height = bmiHeader->biHeight; |
int bitCount = bmiHeader->biBitCount; |
sizes->Add( gcnew Tuple<int,int,int>( width, height, bitCount ) ); |
} |
} |
// Delete the media type when you are done. |
MyDeleteMediaType(pmt); |
} |
} |
} |
// Cleanup |
if (pMoniker != NULL) |
{ |
pMoniker->Release(); |
pMoniker = NULL; |
} |
} |
IList<Tuple<int,int,int>^> ^ CameraMethods::CaptureSizes::get() |
{ |
IList<Tuple<int,int,int>^> ^ result = gcnew List<Tuple<int,int,int>^>(); |
GetCaptureSizes( ActiveCameraIndex, result ); |
return result; |
} |
// If bpp is -1, the first format matching the width and height is selected. |
// based on http://stackoverflow.com/questions/7383372/cant-make-iamstreamconfig-setformat-to-work-with-lifecam-studio |
HRESULT CameraMethods::SetCaptureFormat(IBaseFilter* pCap, int width, int height, int bpp) |
{ |
HRESULT hr = S_OK; |
IAMStreamConfig *pConfig = NULL; |
hr = g_pCaptureGraphBuilder->FindInterface( |
&PIN_CATEGORY_CAPTURE, |
&MEDIATYPE_Video, |
pCap, // Pointer to the capture filter. |
IID_IAMStreamConfig, (void**)&pConfig); |
if (!SUCCEEDED(hr)) return hr; |
int iCount = 0, iSize = 0; |
hr = pConfig->GetNumberOfCapabilities(&iCount, &iSize); |
if (!SUCCEEDED(hr)) return hr; |
// Check the size to make sure we pass in the correct structure. |
if (iSize == sizeof(VIDEO_STREAM_CONFIG_CAPS)) |
{ |
// Use the video capabilities structure. |
for (int iFormat = 0; iFormat < iCount; iFormat++) |
{ |
VIDEO_STREAM_CONFIG_CAPS scc; |
AM_MEDIA_TYPE *pmt; |
/* Note: Use of the VIDEO_STREAM_CONFIG_CAPS structure to configure a video device is |
deprecated. Although the caller must allocate the buffer, it should ignore the |
contents after the method returns. The capture device will return its supported |
formats through the pmt parameter. */ |
hr = pConfig->GetStreamCaps(iFormat, &pmt, (BYTE*)&scc); |
if (SUCCEEDED(hr)) |
{ |
/* Examine the format, and possibly use it. */ |
if (pmt->formattype == FORMAT_VideoInfo) { |
// Check the buffer size. |
if (pmt->cbFormat >= sizeof(VIDEOINFOHEADER)) |
{ |
VIDEOINFOHEADER *pVih = reinterpret_cast<VIDEOINFOHEADER*>(pmt->pbFormat); |
BITMAPINFOHEADER *bmiHeader = &pVih->bmiHeader; |
/* Access VIDEOINFOHEADER members through pVih. */ |
if( bmiHeader->biWidth == width && bmiHeader->biHeight == height && ( bmiHeader->biBitCount == -1 || bmiHeader->biBitCount == bpp) ) |
{ |
hr = pConfig->SetFormat(pmt); |
break; |
} |
} |
} |
// Delete the media type when you are done. |
MyDeleteMediaType(pmt); |
} |
} |
} |
return hr; |
} |
/MKLiveView/v1.0/Source/WebCamLib/WebCamLib.h |
---|
0,0 → 1,407 |
//***************************************************************************************** |
// File: WebCamLib.h |
// Project: WebcamLib |
// Author(s): John Conwell |
// Gary Caldwell |
// |
// Declares the webcam DirectShow wrapper used by TouchlessLib |
//***************************************************************************************** |
#pragma once |
using namespace System; |
using namespace System::Collections::Generic; |
using namespace System::Runtime::InteropServices; |
namespace WebCamLib |
{ |
/// <summary> |
/// Store webcam name, index |
/// </summary> |
public ref class CameraInfo |
{ |
public: |
CameraInfo( int index, String^ name ); |
property int Index |
{ |
int get(); |
private: void set( int value ); |
} |
property String^ Name |
{ |
String^ get(); |
private: void set( String^ value ); |
} |
private: |
int index; |
String^ name; |
}; |
public enum class PropertyTypeMask : int |
{ |
CameraControlPropertyMask = 0x01000, |
VideoProcAmpPropertyMask = 0x02000, |
}; |
// Source: https://msdn.microsoft.com/en-us/library/aa925325.aspx |
public enum class CameraControlProperty : int |
{ |
Pan_degrees, |
Tilt_degrees, |
Roll_degrees, |
Zoom_mm, |
Exposure_lgSec, |
Iris_10f, |
FocalLength_mm, |
Flash, |
}; |
// Source: https://msdn.microsoft.com/en-us/library/aa920611.aspx |
public enum class VideoProcAmpProperty : int |
{ |
Brightness, |
Contrast, |
Hue, |
Saturation, |
Sharpness, |
Gamma, |
ColorEnable, |
WhiteBalance, |
BacklightCompensation, |
Gain, |
}; |
public enum class CameraProperty : int |
{ |
Pan_degrees = WebCamLib::CameraControlProperty::Pan_degrees | PropertyTypeMask::CameraControlPropertyMask, |
Tilt_degrees = WebCamLib::CameraControlProperty::Tilt_degrees | PropertyTypeMask::CameraControlPropertyMask, |
Roll_degrees = WebCamLib::CameraControlProperty::Roll_degrees | PropertyTypeMask::CameraControlPropertyMask, |
Zoom_mm = WebCamLib::CameraControlProperty::Zoom_mm | PropertyTypeMask::CameraControlPropertyMask, |
Exposure_lgSec = WebCamLib::CameraControlProperty::Exposure_lgSec | PropertyTypeMask::CameraControlPropertyMask, |
Iris_10f = WebCamLib::CameraControlProperty::Iris_10f | PropertyTypeMask::CameraControlPropertyMask, |
FocalLength_mm = WebCamLib::CameraControlProperty::FocalLength_mm | PropertyTypeMask::CameraControlPropertyMask, |
Flash = WebCamLib::CameraControlProperty::Flash | PropertyTypeMask::CameraControlPropertyMask, |
Brightness = WebCamLib::VideoProcAmpProperty::Brightness | PropertyTypeMask::VideoProcAmpPropertyMask, |
Contrast = WebCamLib::VideoProcAmpProperty::Contrast | PropertyTypeMask::VideoProcAmpPropertyMask, |
Hue = WebCamLib::VideoProcAmpProperty::Hue | PropertyTypeMask::VideoProcAmpPropertyMask, |
Saturation = WebCamLib::VideoProcAmpProperty::Saturation | PropertyTypeMask::VideoProcAmpPropertyMask, |
Sharpness = WebCamLib::VideoProcAmpProperty::Sharpness | PropertyTypeMask::VideoProcAmpPropertyMask, |
Gamma = WebCamLib::VideoProcAmpProperty::Gamma | PropertyTypeMask::VideoProcAmpPropertyMask, |
ColorEnable = WebCamLib::VideoProcAmpProperty::ColorEnable | PropertyTypeMask::VideoProcAmpPropertyMask, |
WhiteBalance = WebCamLib::VideoProcAmpProperty::WhiteBalance | PropertyTypeMask::VideoProcAmpPropertyMask, |
BacklightCompensation = WebCamLib::VideoProcAmpProperty::BacklightCompensation | PropertyTypeMask::VideoProcAmpPropertyMask, |
Gain = WebCamLib::VideoProcAmpProperty::Gain | PropertyTypeMask::VideoProcAmpPropertyMask, |
}; |
public ref class CameraPropertyCapabilities |
{ |
public: |
CameraPropertyCapabilities( int cameraIndex, CameraProperty prop, bool isGetSupported, bool isSetSupported, bool isGetRangeSupported ); |
property int CameraIndex |
{ |
int get(); |
private: void set( int cameraIndex ); |
} |
property CameraProperty Property |
{ |
CameraProperty get(); |
private: void set( CameraProperty value ); |
} |
property bool IsGetSupported |
{ |
bool get(); |
private: void set( bool value ); |
} |
property bool IsSetSupported |
{ |
bool get(); |
private: void set( bool value ); |
} |
property bool IsGetRangeSupported |
{ |
bool get(); |
private: void set( bool value ); |
} |
property bool IsSupported |
{ |
bool get(); |
} |
property bool IsFullySupported |
{ |
bool get(); |
} |
private: |
int cameraIndex; |
CameraProperty prop; |
bool isGetSupported, isSetSupported, isGetRangeSupported; |
}; |
/// <summary> |
/// DirectShow wrapper around a web cam, used for image capture |
/// </summary> |
public ref class CameraMethods |
{ |
public: |
/// <summary> |
/// Initializes information about all web cams connected to machine |
/// </summary> |
CameraMethods(); |
/// <summary> |
/// Delegate used by DirectShow to pass back captured images from webcam |
/// </summary> |
delegate void CaptureCallbackDelegate( |
int dwSize, |
[MarshalAsAttribute(UnmanagedType::LPArray, ArraySubType = UnmanagedType::I1, SizeParamIndex = 0)] array<System::Byte>^ abData); |
/// <summary> |
/// Event callback to capture images from webcam |
/// </summary> |
event CaptureCallbackDelegate^ OnImageCapture; |
/// <summary> |
/// Retrieve information about a specific camera |
/// Use the count property to determine valid indicies to pass in |
/// </summary> |
CameraInfo^ GetCameraInfo(int camIndex); |
/// <summary> |
/// Start the camera associated with the input handle |
/// </summary> |
bool StartCamera(int camIndex, interior_ptr<int> width, interior_ptr<int> height, interior_ptr<int> bpp); |
/// <summary> |
/// Start the camera associated with the input handle |
/// </summary> |
void StartCamera(int camIndex, interior_ptr<int> width, interior_ptr<int> height, interior_ptr<int> bpp, interior_ptr<bool> successful); |
#pragma region Camera Property Support |
void IsPropertySupported( CameraProperty prop, interior_ptr<bool> result ); |
bool IsPropertySupported( CameraProperty prop ); |
void GetProperty( CameraProperty prop, bool isValue, interior_ptr<long> value, interior_ptr<bool> bAuto, interior_ptr<bool> successful ); |
bool GetProperty( CameraProperty prop, bool isValue, interior_ptr<long> value, interior_ptr<bool> bAuto ); |
void GetProperty_value( CameraProperty prop, interior_ptr<long> value, interior_ptr<bool> bAuto, interior_ptr<bool> successful ); |
bool GetProperty_value( CameraProperty prop, interior_ptr<long> value, interior_ptr<bool> bAuto ); |
void GetProperty_percentage( CameraProperty prop, interior_ptr<long> percentage, interior_ptr<bool> bAuto, interior_ptr<bool> successful); |
bool GetProperty_percentage( CameraProperty prop, interior_ptr<long> percentage, interior_ptr<bool> bAuto ); |
void SetProperty( CameraProperty prop, bool isValue, long value, bool bAuto, interior_ptr<bool> successful ); |
bool SetProperty( CameraProperty prop, bool isValue, long value, bool bAuto ); |
void SetProperty_value( CameraProperty prop, long value, bool bAuto, interior_ptr<bool> successful ); |
bool SetProperty_value( CameraProperty prop, long value, bool bAuto ); |
void SetProperty_value( CameraProperty prop, long value, bool bAuto, bool throwValidationError, interior_ptr<bool> successful ); |
bool SetProperty_value( CameraProperty prop, long value, bool bAuto, bool throwValidationError ); |
void SetProperty_percentage( CameraProperty prop, long percentage, bool bAuto, interior_ptr<bool> successful ); |
bool SetProperty_percentage( CameraProperty prop, long percentage, bool bAuto ); |
void PropertyHasRange( CameraProperty prop, interior_ptr<bool> successful ); |
bool PropertyHasRange( CameraProperty prop ); |
void GetPropertyRange( CameraProperty prop, interior_ptr<long> min, interior_ptr<long> max, interior_ptr<long> steppingDelta, interior_ptr<long> defaults, interior_ptr<bool> bAuto, interior_ptr<bool> successful ); |
bool GetPropertyRange( CameraProperty prop, interior_ptr<long> min, interior_ptr<long> max, interior_ptr<long> steppingDelta, interior_ptr<long> defaults, interior_ptr<bool> bAuto ); |
void ValidatePropertyValue( CameraProperty prop, long value, interior_ptr<bool> successful ); |
bool ValidatePropertyValue( CameraProperty prop, long value ); |
CameraPropertyCapabilities^ GetPropertyCapability( CameraProperty prop ); |
property IDictionary<CameraProperty, CameraPropertyCapabilities^> ^ PropertyCapabilities |
{ |
IDictionary<CameraProperty, CameraPropertyCapabilities^> ^ get(); |
} |
#pragma endregion |
void GetCaptureSizes(int index, IList<Tuple<int,int,int>^> ^ sizes); |
property IList<Tuple<int,int,int>^> ^ CaptureSizes |
{ |
IList<Tuple<int,int,int>^> ^ get(); |
} |
/// <summary> |
/// Stops the currently running camera and cleans up any global resources |
/// </summary> |
void Cleanup(); |
/// <summary> |
/// Stops the currently running camera |
/// </summary> |
void StopCamera(); |
/// <summary> |
/// Show the properties dialog for the specified webcam |
/// </summary> |
void DisplayCameraPropertiesDialog(int camIndex); |
/// <summary> |
/// Count of the number of cameras installed |
/// </summary> |
property int Count; |
/// <summary> |
/// Queries which camera is currently running via StartCamera(), -1 for none |
/// </summary> |
property int ActiveCameraIndex |
{ |
int get() |
{ |
return activeCameraIndex; |
} |
} |
/// <summary> |
/// IDisposable |
/// </summary> |
~CameraMethods(); |
protected: |
/// <summary> |
/// Finalizer |
/// </summary> |
!CameraMethods(); |
#pragma region Camera Property Support |
bool IsCameraControlProperty( CameraProperty prop ); |
bool IsVideoProcAmpProperty( CameraProperty prop ); |
bool IsPropertyMaskEqual( CameraProperty prop, PropertyTypeMask mask ); |
WebCamLib::CameraControlProperty GetCameraControlProperty( CameraProperty prop ); |
WebCamLib::VideoProcAmpProperty GetVideoProcAmpProperty( CameraProperty prop ); |
bool IsPropertySupported( WebCamLib::CameraControlProperty prop ); |
bool IsPropertySupported( WebCamLib::VideoProcAmpProperty prop ); |
bool GetPropertyRange( WebCamLib::CameraControlProperty prop, interior_ptr<long> min, interior_ptr<long> max, interior_ptr<long> steppingDelta, interior_ptr<long> defaults, interior_ptr<bool> bAuto ); |
bool GetPropertyRange( WebCamLib::VideoProcAmpProperty prop, interior_ptr<long> min, interior_ptr<long> max, interior_ptr<long> steppingDelta, interior_ptr<long> defaults, interior_ptr<bool> bAuto ); |
bool GetProperty_value( WebCamLib::CameraControlProperty prop, interior_ptr<long> value, interior_ptr<bool> bAuto ); |
bool GetProperty_value( WebCamLib::VideoProcAmpProperty prop, interior_ptr<long> value, interior_ptr<bool> bAuto ); |
bool SetProperty_value( WebCamLib::CameraControlProperty prop, long value, bool bAuto ); |
bool SetProperty_value( WebCamLib::VideoProcAmpProperty prop, long value, bool bAuto ); |
#pragma endregion |
private: |
/// <summary> |
/// Pinned pointer to delegate for CaptureCallbackDelegate |
/// Keeps the delegate instance in one spot |
/// </summary> |
GCHandle ppCaptureCallback; |
/// <summary> |
/// Initialize information about webcams installed on machine |
/// </summary> |
void RefreshCameraList(); |
/// <summary> |
/// Has dispose already happened? |
/// </summary> |
bool disposed; |
/// <summary> |
/// Which camera is running? -1 for none |
/// </summary> |
int activeCameraIndex; |
/// <summary> |
/// Releases all unmanaged resources |
/// </summary> |
void CleanupCameraInfo(); |
/// <summary> |
/// Setup the callback functionality for DirectShow |
/// </summary> |
HRESULT ConfigureSampleGrabber(IBaseFilter *pIBaseFilter); |
HRESULT SetCaptureFormat(IBaseFilter* pCap, int width, int height, int bpp ); |
}; |
// Forward declarations of callbacks |
typedef void (__stdcall *PFN_CaptureCallback)(DWORD dwSize, BYTE* pbData); |
PFN_CaptureCallback g_pfnCaptureCallback = NULL; |
/// <summary> |
/// Lightweight SampleGrabber callback interface |
/// </summary> |
class SampleGrabberCB : public ISampleGrabberCB |
{ |
public: |
SampleGrabberCB() |
{ |
m_nRefCount = 0; |
} |
virtual HRESULT STDMETHODCALLTYPE SampleCB(double SampleTime, IMediaSample *pSample) |
{ |
return E_FAIL; |
} |
virtual HRESULT STDMETHODCALLTYPE BufferCB(double SampleTime, BYTE *pBuffer, long BufferLen) |
{ |
if (g_pfnCaptureCallback != NULL) |
{ |
g_pfnCaptureCallback(BufferLen, pBuffer); |
} |
return S_OK; |
} |
virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject) |
{ |
return E_FAIL; // Not a very accurate implementation |
} |
virtual ULONG STDMETHODCALLTYPE AddRef() |
{ |
return ++m_nRefCount; |
} |
virtual ULONG STDMETHODCALLTYPE Release() |
{ |
int n = --m_nRefCount; |
if (n <= 0) |
{ |
delete this; |
} |
return n; |
} |
private: |
int m_nRefCount; |
}; |
} |
/MKLiveView/v1.0/Source/WebCamLib/WebCamLib.sln |
---|
0,0 → 1,20 |
|
Microsoft Visual Studio Solution File, Format Version 11.00 |
# Visual C++ Express 2010 |
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WebCamLib", "WebCamLib.vcxproj", "{FD48314A-9615-4BA6-913A-03787FB2DD30}" |
EndProject |
Global |
GlobalSection(SolutionConfigurationPlatforms) = preSolution |
Debug|Win32 = Debug|Win32 |
Release|Win32 = Release|Win32 |
EndGlobalSection |
GlobalSection(ProjectConfigurationPlatforms) = postSolution |
{FD48314A-9615-4BA6-913A-03787FB2DD30}.Debug|Win32.ActiveCfg = Debug|Win32 |
{FD48314A-9615-4BA6-913A-03787FB2DD30}.Debug|Win32.Build.0 = Debug|Win32 |
{FD48314A-9615-4BA6-913A-03787FB2DD30}.Release|Win32.ActiveCfg = Release|Win32 |
{FD48314A-9615-4BA6-913A-03787FB2DD30}.Release|Win32.Build.0 = Release|Win32 |
EndGlobalSection |
GlobalSection(SolutionProperties) = preSolution |
HideSolutionNode = FALSE |
EndGlobalSection |
EndGlobal |
/MKLiveView/v1.0/Source/WebCamLib/WebCamLib.vcproj |
---|
0,0 → 1,364 |
<?xml version="1.0" encoding="Windows-1252"?> |
<VisualStudioProject |
ProjectType="Visual C++" |
Version="9.00" |
Name="WebCamLib" |
ProjectGUID="{FD48314A-9615-4BA6-913A-03787FB2DD30}" |
RootNamespace="WebCamLib" |
Keyword="ManagedCProj" |
TargetFrameworkVersion="131072" |
> |
<Platforms> |
<Platform |
Name="Win32" |
/> |
<Platform |
Name="x64" |
/> |
</Platforms> |
<ToolFiles> |
</ToolFiles> |
<Configurations> |
<Configuration |
Name="Debug|Win32" |
OutputDirectory="$(SolutionDir)bin\$(ConfigurationName)" |
IntermediateDirectory="bin\$(ConfigurationName)" |
ConfigurationType="2" |
CharacterSet="1" |
ManagedExtensions="1" |
> |
<Tool |
Name="VCPreBuildEventTool" |
/> |
<Tool |
Name="VCCustomBuildTool" |
/> |
<Tool |
Name="VCXMLDataGeneratorTool" |
/> |
<Tool |
Name="VCWebServiceProxyGeneratorTool" |
/> |
<Tool |
Name="VCMIDLTool" |
/> |
<Tool |
Name="VCCLCompilerTool" |
Optimization="0" |
PreprocessorDefinitions="WIN32;_DEBUG" |
RuntimeLibrary="3" |
UsePrecompiledHeader="0" |
WarningLevel="3" |
DebugInformationFormat="3" |
/> |
<Tool |
Name="VCManagedResourceCompilerTool" |
/> |
<Tool |
Name="VCResourceCompilerTool" |
/> |
<Tool |
Name="VCPreLinkEventTool" |
/> |
<Tool |
Name="VCLinkerTool" |
AdditionalDependencies="Strmiids.lib" |
OutputFile="bin\$(ConfigurationName)\$(ProjectName).dll" |
LinkIncremental="2" |
GenerateDebugInformation="true" |
AssemblyDebug="1" |
RandomizedBaseAddress="1" |
DataExecutionPrevention="0" |
TargetMachine="1" |
/> |
<Tool |
Name="VCALinkTool" |
/> |
<Tool |
Name="VCManifestTool" |
/> |
<Tool |
Name="VCXDCMakeTool" |
/> |
<Tool |
Name="VCBscMakeTool" |
/> |
<Tool |
Name="VCFxCopTool" |
/> |
<Tool |
Name="VCAppVerifierTool" |
/> |
<Tool |
Name="VCPostBuildEventTool" |
CommandLine="" |
/> |
</Configuration> |
<Configuration |
Name="Release|Win32" |
OutputDirectory="$(ProjectDir)bin\$(ConfigurationName)" |
IntermediateDirectory="$(ProjectDir)bin\$(ConfigurationName)" |
ConfigurationType="2" |
CharacterSet="1" |
ManagedExtensions="1" |
WholeProgramOptimization="1" |
> |
<Tool |
Name="VCPreBuildEventTool" |
/> |
<Tool |
Name="VCCustomBuildTool" |
/> |
<Tool |
Name="VCXMLDataGeneratorTool" |
/> |
<Tool |
Name="VCWebServiceProxyGeneratorTool" |
/> |
<Tool |
Name="VCMIDLTool" |
/> |
<Tool |
Name="VCCLCompilerTool" |
PreprocessorDefinitions="WIN32;NDEBUG" |
RuntimeLibrary="2" |
UsePrecompiledHeader="0" |
WarningLevel="4" |
DebugInformationFormat="3" |
/> |
<Tool |
Name="VCManagedResourceCompilerTool" |
/> |
<Tool |
Name="VCResourceCompilerTool" |
/> |
<Tool |
Name="VCPreLinkEventTool" |
/> |
<Tool |
Name="VCLinkerTool" |
AdditionalDependencies="Strmiids.lib" |
LinkIncremental="1" |
GenerateDebugInformation="true" |
RandomizedBaseAddress="1" |
DataExecutionPrevention="0" |
TargetMachine="1" |
/> |
<Tool |
Name="VCALinkTool" |
/> |
<Tool |
Name="VCManifestTool" |
/> |
<Tool |
Name="VCXDCMakeTool" |
/> |
<Tool |
Name="VCBscMakeTool" |
/> |
<Tool |
Name="VCFxCopTool" |
/> |
<Tool |
Name="VCAppVerifierTool" |
/> |
<Tool |
Name="VCPostBuildEventTool" |
/> |
</Configuration> |
<Configuration |
Name="Debug|x64" |
OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)" |
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)" |
ConfigurationType="2" |
CharacterSet="1" |
ManagedExtensions="1" |
> |
<Tool |
Name="VCPreBuildEventTool" |
/> |
<Tool |
Name="VCCustomBuildTool" |
/> |
<Tool |
Name="VCXMLDataGeneratorTool" |
/> |
<Tool |
Name="VCWebServiceProxyGeneratorTool" |
/> |
<Tool |
Name="VCMIDLTool" |
TargetEnvironment="3" |
/> |
<Tool |
Name="VCCLCompilerTool" |
Optimization="0" |
PreprocessorDefinitions="WIN32;_DEBUG" |
RuntimeLibrary="3" |
UsePrecompiledHeader="0" |
WarningLevel="3" |
DebugInformationFormat="3" |
/> |
<Tool |
Name="VCManagedResourceCompilerTool" |
/> |
<Tool |
Name="VCResourceCompilerTool" |
/> |
<Tool |
Name="VCPreLinkEventTool" |
/> |
<Tool |
Name="VCLinkerTool" |
AdditionalDependencies="Strmiids.lib" |
OutputFile="bin\$(ConfigurationName)\$(ProjectName).dll" |
LinkIncremental="2" |
GenerateDebugInformation="true" |
AssemblyDebug="1" |
RandomizedBaseAddress="1" |
DataExecutionPrevention="0" |
TargetMachine="17" |
/> |
<Tool |
Name="VCALinkTool" |
/> |
<Tool |
Name="VCManifestTool" |
/> |
<Tool |
Name="VCXDCMakeTool" |
/> |
<Tool |
Name="VCBscMakeTool" |
/> |
<Tool |
Name="VCFxCopTool" |
/> |
<Tool |
Name="VCAppVerifierTool" |
/> |
<Tool |
Name="VCPostBuildEventTool" |
CommandLine="" |
/> |
</Configuration> |
<Configuration |
Name="Release|x64" |
OutputDirectory="$(ProjectDir)bin\$(ConfigurationName)" |
IntermediateDirectory="$(ProjectDir)bin\$(ConfigurationName)" |
ConfigurationType="2" |
CharacterSet="1" |
ManagedExtensions="1" |
WholeProgramOptimization="1" |
> |
<Tool |
Name="VCPreBuildEventTool" |
/> |
<Tool |
Name="VCCustomBuildTool" |
/> |
<Tool |
Name="VCXMLDataGeneratorTool" |
/> |
<Tool |
Name="VCWebServiceProxyGeneratorTool" |
/> |
<Tool |
Name="VCMIDLTool" |
TargetEnvironment="3" |
/> |
<Tool |
Name="VCCLCompilerTool" |
PreprocessorDefinitions="WIN32;NDEBUG" |
RuntimeLibrary="2" |
UsePrecompiledHeader="0" |
WarningLevel="4" |
DebugInformationFormat="3" |
/> |
<Tool |
Name="VCManagedResourceCompilerTool" |
/> |
<Tool |
Name="VCResourceCompilerTool" |
/> |
<Tool |
Name="VCPreLinkEventTool" |
/> |
<Tool |
Name="VCLinkerTool" |
AdditionalDependencies="Strmiids.lib" |
LinkIncremental="1" |
GenerateDebugInformation="true" |
RandomizedBaseAddress="1" |
DataExecutionPrevention="0" |
TargetMachine="17" |
/> |
<Tool |
Name="VCALinkTool" |
/> |
<Tool |
Name="VCManifestTool" |
/> |
<Tool |
Name="VCXDCMakeTool" |
/> |
<Tool |
Name="VCBscMakeTool" |
/> |
<Tool |
Name="VCFxCopTool" |
/> |
<Tool |
Name="VCAppVerifierTool" |
/> |
<Tool |
Name="VCPostBuildEventTool" |
/> |
</Configuration> |
</Configurations> |
<References> |
<AssemblyReference |
RelativePath="System.dll" |
AssemblyName="System, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL" |
MinFrameworkVersion="131072" |
/> |
<AssemblyReference |
RelativePath="System.Data.dll" |
AssemblyName="System.Data, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=x86" |
MinFrameworkVersion="131072" |
/> |
<AssemblyReference |
RelativePath="System.XML.dll" |
AssemblyName="System.Xml, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL" |
MinFrameworkVersion="131072" |
/> |
</References> |
<Files> |
<Filter |
Name="Source Files" |
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" |
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" |
> |
<File |
RelativePath=".\WebCamLib.cpp" |
> |
</File> |
</Filter> |
<Filter |
Name="Header Files" |
Filter="h;hpp;hxx;hm;inl;inc;xsd" |
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" |
> |
<File |
RelativePath=".\WebCamLib.h" |
> |
</File> |
</Filter> |
<Filter |
Name="Resource Files" |
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav" |
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}" |
> |
</Filter> |
</Files> |
</VisualStudioProject> |
/MKLiveView/v1.0/Source/WebCamLib/WebCamLib.vcxproj |
---|
0,0 → 1,234 |
<?xml version="1.0" encoding="utf-8"?> |
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
<ItemGroup Label="ProjectConfigurations"> |
<ProjectConfiguration Include="Debug|Win32"> |
<Configuration>Debug</Configuration> |
<Platform>Win32</Platform> |
</ProjectConfiguration> |
<ProjectConfiguration Include="Debug|x64"> |
<Configuration>Debug</Configuration> |
<Platform>x64</Platform> |
</ProjectConfiguration> |
<ProjectConfiguration Include="Release|Win32"> |
<Configuration>Release</Configuration> |
<Platform>Win32</Platform> |
</ProjectConfiguration> |
<ProjectConfiguration Include="Release|x64"> |
<Configuration>Release</Configuration> |
<Platform>x64</Platform> |
</ProjectConfiguration> |
</ItemGroup> |
<PropertyGroup Label="Globals"> |
<ProjectGuid>{FD48314A-9615-4BA6-913A-03787FB2DD30}</ProjectGuid> |
<RootNamespace>WebCamLib</RootNamespace> |
<Keyword>ManagedCProj</Keyword> |
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion> |
</PropertyGroup> |
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> |
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> |
<ConfigurationType>DynamicLibrary</ConfigurationType> |
<CharacterSet>Unicode</CharacterSet> |
<CLRSupport>true</CLRSupport> |
<WholeProgramOptimization>true</WholeProgramOptimization> |
<PlatformToolset>v140</PlatformToolset> |
<UseOfMfc>false</UseOfMfc> |
</PropertyGroup> |
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> |
<ConfigurationType>DynamicLibrary</ConfigurationType> |
<CharacterSet>Unicode</CharacterSet> |
<CLRSupport>true</CLRSupport> |
<PlatformToolset>v140</PlatformToolset> |
<UseOfMfc>false</UseOfMfc> |
</PropertyGroup> |
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> |
<ConfigurationType>DynamicLibrary</ConfigurationType> |
<CharacterSet>Unicode</CharacterSet> |
<CLRSupport>true</CLRSupport> |
<WholeProgramOptimization>true</WholeProgramOptimization> |
<PlatformToolset>v140</PlatformToolset> |
</PropertyGroup> |
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> |
<ConfigurationType>DynamicLibrary</ConfigurationType> |
<CharacterSet>Unicode</CharacterSet> |
<CLRSupport>true</CLRSupport> |
<PlatformToolset>v140</PlatformToolset> |
</PropertyGroup> |
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> |
<ImportGroup Label="ExtensionSettings"> |
</ImportGroup> |
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets"> |
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> |
</ImportGroup> |
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets"> |
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> |
</ImportGroup> |
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets"> |
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> |
</ImportGroup> |
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets"> |
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> |
</ImportGroup> |
<PropertyGroup Label="UserMacros" /> |
<PropertyGroup> |
<_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion> |
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir)bin\$(Configuration)\$(Platform)\</OutDir> |
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir)obj\$(Configuration)\$(Platform)\</IntDir> |
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental> |
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir)bin\$(Configuration)\$(Platform)\</OutDir> |
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir)obj\$(Configuration)\$(Platform)\</IntDir> |
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental> |
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectDir)bin\$(Configuration)\$(Platform)\</OutDir> |
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectDir)obj\$(Configuration)\$(Platform)\</IntDir> |
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental> |
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectDir)bin\$(Configuration)\$(Platform)\</OutDir> |
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectDir)obj\$(Configuration)\$(Platform)\</IntDir> |
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental> |
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet> |
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" /> |
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" /> |
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">AllRules.ruleset</CodeAnalysisRuleSet> |
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" /> |
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" /> |
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet> |
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" /> |
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" /> |
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|x64'">AllRules.ruleset</CodeAnalysisRuleSet> |
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|x64'" /> |
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|x64'" /> |
<TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectName)</TargetName> |
<TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectName)</TargetName> |
<TargetName Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectName)</TargetName> |
<RunCodeAnalysis Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</RunCodeAnalysis> |
<RunCodeAnalysis Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</RunCodeAnalysis> |
</PropertyGroup> |
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> |
<RunCodeAnalysis>true</RunCodeAnalysis> |
</PropertyGroup> |
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> |
<RunCodeAnalysis>true</RunCodeAnalysis> |
</PropertyGroup> |
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> |
<ClCompile> |
<Optimization>Disabled</Optimization> |
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> |
<PrecompiledHeader> |
</PrecompiledHeader> |
<WarningLevel>Level4</WarningLevel> |
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat> |
</ClCompile> |
<Link> |
<AdditionalDependencies>Strmiids.lib;%(AdditionalDependencies)</AdditionalDependencies> |
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile> |
<GenerateDebugInformation>true</GenerateDebugInformation> |
<AssemblyDebug>true</AssemblyDebug> |
<RandomizedBaseAddress>false</RandomizedBaseAddress> |
<DataExecutionPrevention> |
</DataExecutionPrevention> |
<TargetMachine>MachineX86</TargetMachine> |
</Link> |
<PostBuildEvent> |
<Command> |
</Command> |
</PostBuildEvent> |
</ItemDefinitionGroup> |
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> |
<ClCompile> |
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> |
<PrecompiledHeader> |
</PrecompiledHeader> |
<WarningLevel>Level4</WarningLevel> |
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat> |
</ClCompile> |
<Link> |
<AdditionalDependencies>Strmiids.lib;%(AdditionalDependencies)</AdditionalDependencies> |
<GenerateDebugInformation>true</GenerateDebugInformation> |
<RandomizedBaseAddress>false</RandomizedBaseAddress> |
<DataExecutionPrevention> |
</DataExecutionPrevention> |
<TargetMachine>MachineX86</TargetMachine> |
</Link> |
</ItemDefinitionGroup> |
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> |
<Midl> |
<TargetEnvironment>X64</TargetEnvironment> |
</Midl> |
<ClCompile> |
<Optimization>Disabled</Optimization> |
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> |
<PrecompiledHeader> |
</PrecompiledHeader> |
<WarningLevel>Level3</WarningLevel> |
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat> |
<EnablePREfast>true</EnablePREfast> |
</ClCompile> |
<Link> |
<AdditionalDependencies>Strmiids.lib;%(AdditionalDependencies)</AdditionalDependencies> |
<OutputFile>$(ProjectDir)bin\$(Configuration)\$(Platform)\$(TargetFileName)</OutputFile> |
<GenerateDebugInformation>true</GenerateDebugInformation> |
<AssemblyDebug>true</AssemblyDebug> |
<RandomizedBaseAddress>false</RandomizedBaseAddress> |
<DataExecutionPrevention> |
</DataExecutionPrevention> |
<TargetMachine>MachineX64</TargetMachine> |
<ShowProgress>LinkVerbose</ShowProgress> |
</Link> |
<PostBuildEvent> |
<Command> |
</Command> |
</PostBuildEvent> |
</ItemDefinitionGroup> |
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> |
<Midl> |
<TargetEnvironment>X64</TargetEnvironment> |
</Midl> |
<ClCompile> |
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> |
<PrecompiledHeader> |
</PrecompiledHeader> |
<WarningLevel>Level4</WarningLevel> |
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat> |
<EnablePREfast>true</EnablePREfast> |
</ClCompile> |
<Link> |
<AdditionalDependencies>Strmiids.lib;%(AdditionalDependencies)</AdditionalDependencies> |
<GenerateDebugInformation>true</GenerateDebugInformation> |
<RandomizedBaseAddress>false</RandomizedBaseAddress> |
<DataExecutionPrevention> |
</DataExecutionPrevention> |
<TargetMachine>MachineX64</TargetMachine> |
<ShowProgress>LinkVerbose</ShowProgress> |
<OutputFile>$(ProjectDir)bin\$(Configuration)\$(Platform)\$(TargetFileName)</OutputFile> |
</Link> |
</ItemDefinitionGroup> |
<ItemGroup> |
<Reference Include="System"> |
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies> |
<ReferenceOutputAssembly>true</ReferenceOutputAssembly> |
</Reference> |
<Reference Include="System.Data"> |
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies> |
<ReferenceOutputAssembly>true</ReferenceOutputAssembly> |
</Reference> |
<Reference Include="System.Xml"> |
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies> |
<ReferenceOutputAssembly>true</ReferenceOutputAssembly> |
</Reference> |
</ItemGroup> |
<ItemGroup> |
<ClCompile Include="WebCamLib.cpp" /> |
</ItemGroup> |
<ItemGroup> |
<ClInclude Include="qedit.h" /> |
<ClInclude Include="WebCamLib.h" /> |
</ItemGroup> |
<ItemGroup> |
<None Include="ClassDiagram.cd" /> |
</ItemGroup> |
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> |
<ImportGroup Label="ExtensionTargets"> |
</ImportGroup> |
</Project> |
/MKLiveView/v1.0/Source/WebCamLib/WebCamLib.vcxproj.filters |
---|
0,0 → 1,33 |
<?xml version="1.0" encoding="utf-8"?> |
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
<ItemGroup> |
<Filter Include="Source Files"> |
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> |
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions> |
</Filter> |
<Filter Include="Header Files"> |
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier> |
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions> |
</Filter> |
<Filter Include="Header Files\Resource Files"> |
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier> |
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions> |
</Filter> |
</ItemGroup> |
<ItemGroup> |
<ClCompile Include="WebCamLib.cpp"> |
<Filter>Source Files</Filter> |
</ClCompile> |
</ItemGroup> |
<ItemGroup> |
<ClInclude Include="WebCamLib.h"> |
<Filter>Header Files</Filter> |
</ClInclude> |
<ClInclude Include="qedit.h"> |
<Filter>Header Files</Filter> |
</ClInclude> |
</ItemGroup> |
<ItemGroup> |
<None Include="ClassDiagram.cd" /> |
</ItemGroup> |
</Project> |
/MKLiveView/v1.0/Source/WebCamLib/WebCamLib.vcxproj.user |
---|
0,0 → 1,4 |
<?xml version="1.0" encoding="utf-8"?> |
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
<PropertyGroup /> |
</Project> |
/MKLiveView/v1.0/Source/WebCamLib/qedit.h |
---|
0,0 → 1,89 |
/////////////////////////////////////////////////////////////////////////////////// |
#ifndef __qedit_h__ |
#define __qedit_h__ |
/////////////////////////////////////////////////////////////////////////////////// |
#pragma once |
/////////////////////////////////////////////////////////////////////////////////// |
interface |
ISampleGrabberCB |
: |
public IUnknown |
{ |
virtual STDMETHODIMP SampleCB( double SampleTime, IMediaSample *pSample ) = 0; |
virtual STDMETHODIMP BufferCB( double SampleTime, BYTE *pBuffer, long BufferLen ) = 0; |
}; |
/////////////////////////////////////////////////////////////////////////////////// |
static |
const |
IID IID_ISampleGrabberCB = { 0x0579154A, 0x2B53, 0x4994, { 0xB0, 0xD0, 0xE7, 0x73, 0x14, 0x8E, 0xFF, 0x85 } }; |
/////////////////////////////////////////////////////////////////////////////////// |
interface |
ISampleGrabber |
: |
public IUnknown |
{ |
virtual HRESULT STDMETHODCALLTYPE SetOneShot( BOOL OneShot ) = 0; |
virtual HRESULT STDMETHODCALLTYPE SetMediaType( const AM_MEDIA_TYPE *pType ) = 0; |
virtual HRESULT STDMETHODCALLTYPE GetConnectedMediaType( AM_MEDIA_TYPE *pType ) = 0; |
virtual HRESULT STDMETHODCALLTYPE SetBufferSamples( BOOL BufferThem ) = 0; |
virtual HRESULT STDMETHODCALLTYPE GetCurrentBuffer( long *pBufferSize, long *pBuffer ) = 0; |
virtual HRESULT STDMETHODCALLTYPE GetCurrentSample( IMediaSample **ppSample ) = 0; |
virtual HRESULT STDMETHODCALLTYPE SetCallback( ISampleGrabberCB *pCallback, long WhichMethodToCallback ) = 0; |
}; |
/////////////////////////////////////////////////////////////////////////////////// |
static |
const |
IID IID_ISampleGrabber = { 0x6B652FFF, 0x11FE, 0x4fce, { 0x92, 0xAD, 0x02, 0x66, 0xB5, 0xD7, 0xC7, 0x8F } }; |
/////////////////////////////////////////////////////////////////////////////////// |
static |
const |
CLSID CLSID_SampleGrabber = { 0xC1F400A0, 0x3F08, 0x11d3, { 0x9F, 0x0B, 0x00, 0x60, 0x08, 0x03, 0x9E, 0x37 } }; |
/////////////////////////////////////////////////////////////////////////////////// |
static |
const |
CLSID CLSID_NullRenderer = { 0xC1F400A4, 0x3F08, 0x11d3, { 0x9F, 0x0B, 0x00, 0x60, 0x08, 0x03, 0x9E, 0x37 } }; |
/////////////////////////////////////////////////////////////////////////////////// |
static |
const |
CLSID CLSID_VideoEffects1Category = { 0xcc7bfb42, 0xf175, 0x11d1, { 0xa3, 0x92, 0x0, 0xe0, 0x29, 0x1f, 0x39, 0x59 } }; |
/////////////////////////////////////////////////////////////////////////////////// |
static |
const |
CLSID CLSID_VideoEffects2Category = { 0xcc7bfb43, 0xf175, 0x11d1, { 0xa3, 0x92, 0x0, 0xe0, 0x29, 0x1f, 0x39, 0x59 } }; |
/////////////////////////////////////////////////////////////////////////////////// |
static |
const |
CLSID CLSID_AudioEffects1Category = { 0xcc7bfb44, 0xf175, 0x11d1, { 0xa3, 0x92, 0x0, 0xe0, 0x29, 0x1f, 0x39, 0x59 } }; |
/////////////////////////////////////////////////////////////////////////////////// |
static |
const |
CLSID CLSID_AudioEffects2Category = { 0xcc7bfb45, 0xf175, 0x11d1, { 0xa3, 0x92, 0x0, 0xe0, 0x29, 0x1f, 0x39, 0x59 } }; |
/////////////////////////////////////////////////////////////////////////////////// |
#endif |
/////////////////////////////////////////////////////////////////////////////////// |