diff --git a/dshowcapture.hpp b/dshowcapture.hpp index a294023..f5ba680 100644 --- a/dshowcapture.hpp +++ b/dshowcapture.hpp @@ -210,6 +210,16 @@ struct AudioConfig : Config { AudioMode mode = AudioMode::Capture; }; +struct VideoDeviceProperty { + long property; + long flags; + long val; + long min; + long max; + long step; + long def; +}; + class DSHOWCAPTURE_EXPORT Device { HDevice *context; @@ -224,6 +234,10 @@ class DSHOWCAPTURE_EXPORT Device { bool SetVideoConfig(VideoConfig *config); bool SetAudioConfig(AudioConfig *config); + bool SetCameraControlProperties( + std::vector *properties); + bool + SetVideoProcAmpProperties(std::vector *properties); /** * Connects all the configured filters together. @@ -237,6 +251,10 @@ class DSHOWCAPTURE_EXPORT Device { bool GetVideoConfig(VideoConfig &config) const; bool GetAudioConfig(AudioConfig &config) const; + bool GetCameraControlProperties( + std::vector &properties) const; + bool GetVideoProcAmpProperties( + std::vector &properties) const; bool GetVideoDeviceId(DeviceId &id) const; bool GetAudioDeviceId(DeviceId &id) const; diff --git a/source/device.cpp b/source/device.cpp index e78549f..79ee2b6 100644 --- a/source/device.cpp +++ b/source/device.cpp @@ -427,6 +427,91 @@ bool HDevice::SetVideoConfig(VideoConfig *config) return true; } +bool HDevice::SetCameraControlProperties( + std::vector *properties) +{ + if (videoFilter == nullptr) + return false; + + ComQIPtr pCameraControl = videoFilter; + if (!pCameraControl) + return false; + + for (const auto &prop : *properties) { + pCameraControl->Set(prop.property, prop.val, prop.flags); + } + return true; +} + +bool HDevice::SetVideoProcAmpProperties( + std::vector *properties) +{ + if (videoFilter == nullptr) + return false; + + ComQIPtr pVideoProcAmp = videoFilter; + if (!pVideoProcAmp) + return false; + + for (const auto &prop : *properties) { + pVideoProcAmp->Set(prop.property, prop.val, prop.flags); + } + return true; +} + +bool HDevice::GetCameraControlProperties( + std::vector &properties) const +{ + + if (videoFilter == nullptr) + return false; + + ComQIPtr pCameraControl = videoFilter; + if (!pCameraControl) + return false; + + for (long i = 0; i < 256; i++) { + long flags, val; + auto hr = pCameraControl->Get(i, &val, &flags); + if (FAILED(hr)) + continue; + VideoDeviceProperty p{}; + p.property = i; + p.flags = flags; + p.val = val; + hr = pCameraControl->GetRange(i, &p.min, &p.max, &p.step, + &p.def, &flags); + properties.push_back(p); + } + return true; +} + +bool HDevice::GetVideoProcAmpProperties( + std::vector &properties) const +{ + if (videoFilter == nullptr) + return false; + + ComQIPtr pVideoProcAmp = videoFilter; + if (!pVideoProcAmp) + return false; + + for (long i = 0; i < 256; i++) { + long flags, val; + auto hr = pVideoProcAmp->Get(i, &val, &flags); + if (FAILED(hr)) + continue; + VideoDeviceProperty p{}; + p.property = i; + p.flags = flags; + p.val = val; + hr = pVideoProcAmp->GetRange(i, &p.min, &p.max, &p.step, &p.def, + &flags); + properties.push_back(p); + } + return true; +} + bool HDevice::SetupExceptionAudioCapture(IPin *pin) { ComPtr enumMediaTypes; diff --git a/source/device.hpp b/source/device.hpp index 4767f25..f82a5e8 100644 --- a/source/device.hpp +++ b/source/device.hpp @@ -103,6 +103,14 @@ struct HDevice { bool SetVideoConfig(VideoConfig *config); bool SetAudioConfig(AudioConfig *config); + bool SetCameraControlProperties( + std::vector *properties); + bool + SetVideoProcAmpProperties(std::vector *properties); + bool GetCameraControlProperties( + std::vector &properties) const; + bool GetVideoProcAmpProperties( + std::vector &properties) const; bool CreateGraph(); bool FindCrossbar(IBaseFilter *filter, IBaseFilter **crossbar); diff --git a/source/dshowcapture.cpp b/source/dshowcapture.cpp index 7087c3c..801c6e9 100644 --- a/source/dshowcapture.cpp +++ b/source/dshowcapture.cpp @@ -69,6 +69,17 @@ bool Device::SetAudioConfig(AudioConfig *config) return context->SetAudioConfig(config); } +bool Device::SetCameraControlProperties( + std::vector *properties) +{ + return context->SetCameraControlProperties(properties); +} +bool Device::SetVideoProcAmpProperties( + std::vector *properties) +{ + return context->SetVideoProcAmpProperties(properties); +} + bool Device::ConnectFilters() { return context->ConnectFilters(); @@ -93,6 +104,18 @@ bool Device::GetVideoConfig(VideoConfig &config) const return true; } +bool Device::GetCameraControlProperties( + std::vector &properties) const +{ + return context->GetCameraControlProperties(properties); +} + +bool Device::GetVideoProcAmpProperties( + std::vector &properties) const +{ + return context->GetVideoProcAmpProperties(properties); +} + bool Device::GetAudioConfig(AudioConfig &config) const { if (context->audioCapture == NULL)