Commit c75f4719 authored by Guido Urdaneta's avatar Guido Urdaneta Committed by Commit Bot

Revert "[PTZ] Add mocking points to VideoCaptureDeviceFactoryWin"

This reverts commit 6536130a.

Reason for revert: crbug.com/1098633

Original change's description:
> [PTZ] Add mocking points to VideoCaptureDeviceFactoryWin
> 
> This CL refactors video capture device creation on Windows, removes some
> code duplications related to DirectShow device enumeration and adds
> mocking points for unit testing. This CL has no functional changes.
> 
> Bug: 934063
> Change-Id: I2df08b3a361ffd702761bd9d6b400f4418390c99
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2247797
> Commit-Queue: Eero Häkkinen <eero.hakkinen@intel.com>
> Auto-Submit: Eero Häkkinen <eero.hakkinen@intel.com>
> Reviewed-by: Guido Urdaneta <guidou@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#781357}

TBR=eero.hakkinen@intel.com,guidou@chromium.org

Change-Id: I967f2eccd57c9847d85201ad57d28ad804691fff
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 934063
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2263193Reviewed-by: default avatarGuido Urdaneta <guidou@chromium.org>
Commit-Queue: Guido Urdaneta <guidou@chromium.org>
Cr-Commit-Position: refs/heads/master@{#781804}
parent 32ff0a99
...@@ -7,9 +7,6 @@ ...@@ -7,9 +7,6 @@
#ifndef MEDIA_CAPTURE_VIDEO_WIN_VIDEO_CAPTURE_DEVICE_FACTORY_WIN_H_ #ifndef MEDIA_CAPTURE_VIDEO_WIN_VIDEO_CAPTURE_DEVICE_FACTORY_WIN_H_
#define MEDIA_CAPTURE_VIDEO_WIN_VIDEO_CAPTURE_DEVICE_FACTORY_WIN_H_ #define MEDIA_CAPTURE_VIDEO_WIN_VIDEO_CAPTURE_DEVICE_FACTORY_WIN_H_
// Avoid including strsafe.h via dshow as it will cause build warnings.
#define NO_DSHOW_STRSAFE
#include <dshow.h>
#include <mfidl.h> #include <mfidl.h>
#include <windows.devices.enumeration.h> #include <windows.devices.enumeration.h>
...@@ -33,6 +30,13 @@ class CAPTURE_EXPORT VideoCaptureDeviceFactoryWin ...@@ -33,6 +30,13 @@ class CAPTURE_EXPORT VideoCaptureDeviceFactoryWin
VideoCaptureDeviceFactoryWin(); VideoCaptureDeviceFactoryWin();
~VideoCaptureDeviceFactoryWin() override; ~VideoCaptureDeviceFactoryWin() override;
using MFEnumDeviceSourcesFunc = decltype(&MFEnumDeviceSources);
using DirectShowEnumDevicesFunc =
base::RepeatingCallback<HRESULT(IEnumMoniker**)>;
using GetSupportedFormatsFunc =
base::RepeatingCallback<void(const VideoCaptureDeviceDescriptor&,
VideoCaptureFormats*)>;
std::unique_ptr<VideoCaptureDevice> CreateDevice( std::unique_ptr<VideoCaptureDevice> CreateDevice(
const VideoCaptureDeviceDescriptor& device_descriptor) override; const VideoCaptureDeviceDescriptor& device_descriptor) override;
void GetDeviceDescriptors( void GetDeviceDescriptors(
...@@ -47,31 +51,22 @@ class CAPTURE_EXPORT VideoCaptureDeviceFactoryWin ...@@ -47,31 +51,22 @@ class CAPTURE_EXPORT VideoCaptureDeviceFactoryWin
void set_use_media_foundation_for_testing(bool use) { void set_use_media_foundation_for_testing(bool use) {
use_media_foundation_ = use; use_media_foundation_ = use;
} }
void set_mf_enum_device_sources_func_for_testing(
protected: MFEnumDeviceSourcesFunc func) {
// Protected and virtual for testing. mf_enum_device_sources_func_ = func;
virtual bool CreateDeviceEnumMonikerDirectShow(IEnumMoniker** enum_moniker); }
virtual bool CreateDeviceFilterDirectShow(const std::string& device_id, void set_direct_show_enum_devices_func_for_testing(
IBaseFilter** capture_filter); DirectShowEnumDevicesFunc func) {
virtual bool CreateDeviceFilterDirectShow( direct_show_enum_devices_func_ = func;
Microsoft::WRL::ComPtr<IMoniker> moniker, }
IBaseFilter** capture_filter); void set_mf_get_supported_formats_func_for_testing(
virtual bool CreateDeviceSourceMediaFoundation(const std::string& device_id, GetSupportedFormatsFunc func) {
VideoCaptureApi capture_api, mf_get_supported_formats_func_ = func;
IMFMediaSource** source); }
virtual bool CreateDeviceSourceMediaFoundation( void set_direct_show_get_supported_formats_func_for_testing(
Microsoft::WRL::ComPtr<IMFAttributes> attributes, GetSupportedFormatsFunc func) {
IMFMediaSource** source); direct_show_get_supported_formats_func_ = func;
virtual bool EnumerateDeviceSourcesMediaFoundation( }
Microsoft::WRL::ComPtr<IMFAttributes> attributes,
IMFActivate*** devices,
UINT32* count);
virtual void GetSupportedFormatsDirectShow(
const VideoCaptureDeviceDescriptor& device_descriptor,
VideoCaptureFormats* supported_formats);
virtual void GetSupportedFormatsMediaFoundation(
const VideoCaptureDeviceDescriptor& device_descriptor,
VideoCaptureFormats* supported_formats);
private: private:
void EnumerateDevicesUWP( void EnumerateDevicesUWP(
...@@ -88,6 +83,10 @@ class CAPTURE_EXPORT VideoCaptureDeviceFactoryWin ...@@ -88,6 +83,10 @@ class CAPTURE_EXPORT VideoCaptureDeviceFactoryWin
VideoCaptureDeviceDescriptors* device_descriptors); VideoCaptureDeviceDescriptors* device_descriptors);
void AugmentDescriptorListWithDirectShowOnlyDevices( void AugmentDescriptorListWithDirectShowOnlyDevices(
VideoCaptureDeviceDescriptors* device_descriptors); VideoCaptureDeviceDescriptors* device_descriptors);
bool EnumerateVideoDevicesMediaFoundation(
const std::vector<std::pair<GUID, GUID>>& attributes_data,
IMFActivate*** devices,
UINT32* count);
void GetDeviceDescriptorsDirectShow( void GetDeviceDescriptorsDirectShow(
VideoCaptureDeviceDescriptors* device_descriptors); VideoCaptureDeviceDescriptors* device_descriptors);
int GetNumberOfSupportedFormats(const VideoCaptureDeviceDescriptor& device); int GetNumberOfSupportedFormats(const VideoCaptureDeviceDescriptor& device);
...@@ -97,6 +96,14 @@ class CAPTURE_EXPORT VideoCaptureDeviceFactoryWin ...@@ -97,6 +96,14 @@ class CAPTURE_EXPORT VideoCaptureDeviceFactoryWin
bool use_media_foundation_; bool use_media_foundation_;
MFSessionLifetime session_; MFSessionLifetime session_;
// In production code, when Media Foundation libraries are available,
// |mf_enum_device_sources_func_| points to MFEnumDeviceSources. It enables
// mock of Media Foundation API in unit tests.
MFEnumDeviceSourcesFunc mf_enum_device_sources_func_ = nullptr;
DirectShowEnumDevicesFunc direct_show_enum_devices_func_;
GetSupportedFormatsFunc mf_get_supported_formats_func_;
GetSupportedFormatsFunc direct_show_get_supported_formats_func_;
// For calling WinRT methods on a COM initiated thread. // For calling WinRT methods on a COM initiated thread.
base::Thread com_thread_; base::Thread com_thread_;
......
...@@ -417,7 +417,7 @@ const CapabilityWin& GetBestMatchedPhotoCapability( ...@@ -417,7 +417,7 @@ const CapabilityWin& GetBestMatchedPhotoCapability(
HRESULT CreateCaptureEngine(IMFCaptureEngine** engine) { HRESULT CreateCaptureEngine(IMFCaptureEngine** engine) {
ComPtr<IMFCaptureEngineClassFactory> capture_engine_class_factory; ComPtr<IMFCaptureEngineClassFactory> capture_engine_class_factory;
HRESULT hr = CoCreateInstance(CLSID_MFCaptureEngineClassFactory, nullptr, HRESULT hr = CoCreateInstance(CLSID_MFCaptureEngineClassFactory, NULL,
CLSCTX_INPROC_SERVER, CLSCTX_INPROC_SERVER,
IID_PPV_ARGS(&capture_engine_class_factory)); IID_PPV_ARGS(&capture_engine_class_factory));
if (FAILED(hr)) if (FAILED(hr))
...@@ -863,7 +863,7 @@ void VideoCaptureDeviceMFWin::AllocateAndStart( ...@@ -863,7 +863,7 @@ void VideoCaptureDeviceMFWin::AllocateAndStart(
DWORD dw_sink_stream_index = 0; DWORD dw_sink_stream_index = 0;
hr = preview_sink->AddStream(best_match_video_capability.stream_index, hr = preview_sink->AddStream(best_match_video_capability.stream_index,
sink_video_media_type.Get(), nullptr, sink_video_media_type.Get(), NULL,
&dw_sink_stream_index); &dw_sink_stream_index);
if (FAILED(hr)) { if (FAILED(hr)) {
OnError(VideoCaptureError::kWinMediaFoundationSinkAddStreamFailed, OnError(VideoCaptureError::kWinMediaFoundationSinkAddStreamFailed,
...@@ -991,9 +991,9 @@ void VideoCaptureDeviceMFWin::TakePhoto(TakePhotoCallback callback) { ...@@ -991,9 +991,9 @@ void VideoCaptureDeviceMFWin::TakePhoto(TakePhotoCallback callback) {
} }
DWORD dw_sink_stream_index = 0; DWORD dw_sink_stream_index = 0;
hr = photo_sink->AddStream(selected_photo_capability_->stream_index, hr =
sink_media_type.Get(), nullptr, photo_sink->AddStream(selected_photo_capability_->stream_index,
&dw_sink_stream_index); sink_media_type.Get(), NULL, &dw_sink_stream_index);
if (FAILED(hr)) { if (FAILED(hr)) {
LogError(FROM_HERE, hr); LogError(FROM_HERE, hr);
return; return;
......
...@@ -51,7 +51,7 @@ bool PinMatchesCategory(IPin* pin, REFGUID category) { ...@@ -51,7 +51,7 @@ bool PinMatchesCategory(IPin* pin, REFGUID category) {
if (SUCCEEDED(hr)) { if (SUCCEEDED(hr)) {
GUID pin_category; GUID pin_category;
DWORD return_value; DWORD return_value;
hr = ks_property->Get(AMPROPSETID_Pin, AMPROPERTY_PIN_CATEGORY, nullptr, 0, hr = ks_property->Get(AMPROPSETID_Pin, AMPROPERTY_PIN_CATEGORY, NULL, 0,
&pin_category, sizeof(pin_category), &return_value); &pin_category, sizeof(pin_category), &return_value);
if (SUCCEEDED(hr) && (return_value == sizeof(pin_category))) { if (SUCCEEDED(hr) && (return_value == sizeof(pin_category))) {
found = (pin_category == category); found = (pin_category == category);
...@@ -70,9 +70,18 @@ bool PinMatchesMajorType(IPin* pin, REFGUID major_type) { ...@@ -70,9 +70,18 @@ bool PinMatchesMajorType(IPin* pin, REFGUID major_type) {
// static // static
void VideoCaptureDeviceWin::GetDeviceCapabilityList( void VideoCaptureDeviceWin::GetDeviceCapabilityList(
ComPtr<IBaseFilter> capture_filter, const std::string& device_id,
bool query_detailed_frame_rates, bool query_detailed_frame_rates,
CapabilityList* out_capability_list) { CapabilityList* out_capability_list) {
ComPtr<IBaseFilter> capture_filter;
HRESULT hr =
VideoCaptureDeviceWin::GetDeviceFilter(device_id, &capture_filter);
if (!capture_filter.Get()) {
DLOG(ERROR) << "Failed to create capture filter: "
<< logging::SystemErrorCodeToString(hr);
return;
}
ComPtr<IPin> output_capture_pin(VideoCaptureDeviceWin::GetPin( ComPtr<IPin> output_capture_pin(VideoCaptureDeviceWin::GetPin(
capture_filter.Get(), PINDIR_OUTPUT, PIN_CATEGORY_CAPTURE, GUID_NULL)); capture_filter.Get(), PINDIR_OUTPUT, PIN_CATEGORY_CAPTURE, GUID_NULL));
if (!output_capture_pin.Get()) { if (!output_capture_pin.Get()) {
...@@ -175,22 +184,81 @@ void VideoCaptureDeviceWin::GetPinCapabilityList( ...@@ -175,22 +184,81 @@ void VideoCaptureDeviceWin::GetPinCapabilityList(
} }
} }
// Finds and creates a DirectShow Video Capture filter matching the |device_id|.
// static
HRESULT VideoCaptureDeviceWin::GetDeviceFilter(const std::string& device_id,
IBaseFilter** filter) {
DCHECK(filter);
ComPtr<ICreateDevEnum> dev_enum;
HRESULT hr = ::CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC,
IID_PPV_ARGS(&dev_enum));
if (FAILED(hr))
return hr;
ComPtr<IEnumMoniker> enum_moniker;
hr = dev_enum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory,
&enum_moniker, 0);
// CreateClassEnumerator returns S_FALSE on some Windows OS
// when no camera exist. Therefore the FAILED macro can't be used.
if (hr != S_OK)
return hr;
ComPtr<IBaseFilter> capture_filter;
for (ComPtr<IMoniker> moniker; enum_moniker->Next(1, &moniker, NULL) == S_OK;
moniker.Reset()) {
ComPtr<IPropertyBag> prop_bag;
hr = moniker->BindToStorage(0, 0, IID_PPV_ARGS(&prop_bag));
if (FAILED(hr))
continue;
// Find |device_id| via DevicePath, Description or FriendlyName, whichever
// is available first and is a VT_BSTR (i.e. String) type.
static const wchar_t* kPropertyNames[] = {L"DevicePath", L"Description",
L"FriendlyName"};
ScopedVariant name;
for (const auto* property_name : kPropertyNames) {
prop_bag->Read(property_name, name.Receive(), 0);
if (name.type() == VT_BSTR)
break;
}
if (name.type() == VT_BSTR) {
const std::string device_path(base::SysWideToUTF8(V_BSTR(name.ptr())));
if (device_path.compare(device_id) == 0) {
// We have found the requested device
hr = moniker->BindToObject(0, 0, IID_PPV_ARGS(&capture_filter));
DLOG_IF(ERROR, FAILED(hr)) << "Failed to bind camera filter: "
<< logging::SystemErrorCodeToString(hr);
break;
}
}
}
*filter = capture_filter.Detach();
if (!*filter && SUCCEEDED(hr))
hr = HRESULT_FROM_WIN32(ERROR_NOT_FOUND);
return hr;
}
// Finds an IPin on an IBaseFilter given the direction, Category and/or Major // Finds an IPin on an IBaseFilter given the direction, Category and/or Major
// Type. If either |category| or |major_type| are GUID_NULL, they are ignored. // Type. If either |category| or |major_type| are GUID_NULL, they are ignored.
// static // static
ComPtr<IPin> VideoCaptureDeviceWin::GetPin(ComPtr<IBaseFilter> capture_filter, ComPtr<IPin> VideoCaptureDeviceWin::GetPin(IBaseFilter* filter,
PIN_DIRECTION pin_dir, PIN_DIRECTION pin_dir,
REFGUID category, REFGUID category,
REFGUID major_type) { REFGUID major_type) {
ComPtr<IPin> pin; ComPtr<IPin> pin;
ComPtr<IEnumPins> pin_enum; ComPtr<IEnumPins> pin_enum;
HRESULT hr = capture_filter->EnumPins(&pin_enum); HRESULT hr = filter->EnumPins(&pin_enum);
if (pin_enum.Get() == nullptr) if (pin_enum.Get() == NULL)
return pin; return pin;
// Get first unconnected pin. // Get first unconnected pin.
hr = pin_enum->Reset(); // set to first pin hr = pin_enum->Reset(); // set to first pin
while ((hr = pin_enum->Next(1, &pin, nullptr)) == S_OK) { while ((hr = pin_enum->Next(1, &pin, NULL)) == S_OK) {
PIN_DIRECTION this_pin_dir = static_cast<PIN_DIRECTION>(-1); PIN_DIRECTION this_pin_dir = static_cast<PIN_DIRECTION>(-1);
hr = pin->QueryDirection(&this_pin_dir); hr = pin->QueryDirection(&this_pin_dir);
if (pin_dir == this_pin_dir) { if (pin_dir == this_pin_dir) {
...@@ -241,7 +309,7 @@ void VideoCaptureDeviceWin::ScopedMediaType::Free() { ...@@ -241,7 +309,7 @@ void VideoCaptureDeviceWin::ScopedMediaType::Free() {
return; return;
DeleteMediaType(media_type_); DeleteMediaType(media_type_);
media_type_ = nullptr; media_type_ = NULL;
} }
AM_MEDIA_TYPE** VideoCaptureDeviceWin::ScopedMediaType::Receive() { AM_MEDIA_TYPE** VideoCaptureDeviceWin::ScopedMediaType::Receive() {
...@@ -255,13 +323,13 @@ void VideoCaptureDeviceWin::ScopedMediaType::FreeMediaType(AM_MEDIA_TYPE* mt) { ...@@ -255,13 +323,13 @@ void VideoCaptureDeviceWin::ScopedMediaType::FreeMediaType(AM_MEDIA_TYPE* mt) {
if (mt->cbFormat != 0) { if (mt->cbFormat != 0) {
CoTaskMemFree(mt->pbFormat); CoTaskMemFree(mt->pbFormat);
mt->cbFormat = 0; mt->cbFormat = 0;
mt->pbFormat = nullptr; mt->pbFormat = NULL;
} }
if (mt->pUnk != nullptr) { if (mt->pUnk != NULL) {
NOTREACHED(); NOTREACHED();
// pUnk should not be used. // pUnk should not be used.
mt->pUnk->Release(); mt->pUnk->Release();
mt->pUnk = nullptr; mt->pUnk = NULL;
} }
} }
...@@ -269,18 +337,16 @@ void VideoCaptureDeviceWin::ScopedMediaType::FreeMediaType(AM_MEDIA_TYPE* mt) { ...@@ -269,18 +337,16 @@ void VideoCaptureDeviceWin::ScopedMediaType::FreeMediaType(AM_MEDIA_TYPE* mt) {
// http://msdn.microsoft.com/en-us/library/dd375432(VS.85).aspx // http://msdn.microsoft.com/en-us/library/dd375432(VS.85).aspx
void VideoCaptureDeviceWin::ScopedMediaType::DeleteMediaType( void VideoCaptureDeviceWin::ScopedMediaType::DeleteMediaType(
AM_MEDIA_TYPE* mt) { AM_MEDIA_TYPE* mt) {
if (mt != nullptr) { if (mt != NULL) {
FreeMediaType(mt); FreeMediaType(mt);
CoTaskMemFree(mt); CoTaskMemFree(mt);
} }
} }
VideoCaptureDeviceWin::VideoCaptureDeviceWin( VideoCaptureDeviceWin::VideoCaptureDeviceWin(
const VideoCaptureDeviceDescriptor& device_descriptor, const VideoCaptureDeviceDescriptor& device_descriptor)
ComPtr<IBaseFilter> capture_filter)
: device_descriptor_(device_descriptor), : device_descriptor_(device_descriptor),
state_(kIdle), state_(kIdle),
capture_filter_(std::move(capture_filter)),
white_balance_mode_manual_(false), white_balance_mode_manual_(false),
exposure_mode_manual_(false), exposure_mode_manual_(false),
focus_mode_manual_(false), focus_mode_manual_(false),
...@@ -320,6 +386,11 @@ VideoCaptureDeviceWin::~VideoCaptureDeviceWin() { ...@@ -320,6 +386,11 @@ VideoCaptureDeviceWin::~VideoCaptureDeviceWin() {
bool VideoCaptureDeviceWin::Init() { bool VideoCaptureDeviceWin::Init() {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(thread_checker_.CalledOnValidThread());
HRESULT hr = GetDeviceFilter(device_descriptor_.device_id, &capture_filter_);
DLOG_IF_FAILED_WITH_HRESULT("Failed to create capture filter", hr);
if (!capture_filter_.Get())
return false;
output_capture_pin_ = GetPin(capture_filter_.Get(), PINDIR_OUTPUT, output_capture_pin_ = GetPin(capture_filter_.Get(), PINDIR_OUTPUT,
PIN_CATEGORY_CAPTURE, GUID_NULL); PIN_CATEGORY_CAPTURE, GUID_NULL);
if (!output_capture_pin_.Get()) { if (!output_capture_pin_.Get()) {
...@@ -329,21 +400,20 @@ bool VideoCaptureDeviceWin::Init() { ...@@ -329,21 +400,20 @@ bool VideoCaptureDeviceWin::Init() {
// Create the sink filter used for receiving Captured frames. // Create the sink filter used for receiving Captured frames.
sink_filter_ = new SinkFilter(this); sink_filter_ = new SinkFilter(this);
if (sink_filter_.get() == nullptr) { if (sink_filter_.get() == NULL) {
DLOG(ERROR) << "Failed to create sink filter"; DLOG(ERROR) << "Failed to create sink filter";
return false; return false;
} }
input_sink_pin_ = sink_filter_->GetPin(0); input_sink_pin_ = sink_filter_->GetPin(0);
HRESULT hr = hr = ::CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER,
::CoCreateInstance(CLSID_FilterGraph, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&graph_builder_));
IID_PPV_ARGS(&graph_builder_));
DLOG_IF_FAILED_WITH_HRESULT("Failed to create capture filter", hr); DLOG_IF_FAILED_WITH_HRESULT("Failed to create capture filter", hr);
if (FAILED(hr)) if (FAILED(hr))
return false; return false;
hr = ::CoCreateInstance(CLSID_CaptureGraphBuilder2, nullptr, CLSCTX_INPROC, hr = ::CoCreateInstance(CLSID_CaptureGraphBuilder2, NULL, CLSCTX_INPROC,
IID_PPV_ARGS(&capture_graph_builder_)); IID_PPV_ARGS(&capture_graph_builder_));
DLOG_IF_FAILED_WITH_HRESULT("Failed to create the Capture Graph Builder", hr); DLOG_IF_FAILED_WITH_HRESULT("Failed to create the Capture Graph Builder", hr);
if (FAILED(hr)) if (FAILED(hr))
...@@ -360,13 +430,13 @@ bool VideoCaptureDeviceWin::Init() { ...@@ -360,13 +430,13 @@ bool VideoCaptureDeviceWin::Init() {
if (FAILED(hr)) if (FAILED(hr))
return false; return false;
hr = graph_builder_->AddFilter(capture_filter_.Get(), nullptr); hr = graph_builder_->AddFilter(capture_filter_.Get(), NULL);
DLOG_IF_FAILED_WITH_HRESULT("Failed to add the capture device to the graph", DLOG_IF_FAILED_WITH_HRESULT("Failed to add the capture device to the graph",
hr); hr);
if (FAILED(hr)) if (FAILED(hr))
return false; return false;
hr = graph_builder_->AddFilter(sink_filter_.get(), nullptr); hr = graph_builder_->AddFilter(sink_filter_.get(), NULL);
DLOG_IF_FAILED_WITH_HRESULT("Failed to add the sink filter to the graph", hr); DLOG_IF_FAILED_WITH_HRESULT("Failed to add the sink filter to the graph", hr);
if (FAILED(hr)) if (FAILED(hr))
return false; return false;
...@@ -471,7 +541,7 @@ void VideoCaptureDeviceWin::AllocateAndStart( ...@@ -471,7 +541,7 @@ void VideoCaptureDeviceWin::AllocateAndStart(
input_sink_pin_.Get()); input_sink_pin_.Get());
} else { } else {
hr = graph_builder_->ConnectDirect(output_capture_pin_.Get(), hr = graph_builder_->ConnectDirect(output_capture_pin_.Get(),
input_sink_pin_.Get(), nullptr); input_sink_pin_.Get(), NULL);
} }
if (FAILED(hr)) { if (FAILED(hr)) {
......
...@@ -42,7 +42,7 @@ class VideoCaptureDeviceWin : public VideoCaptureDevice, ...@@ -42,7 +42,7 @@ class VideoCaptureDeviceWin : public VideoCaptureDevice,
// avoid memory leaks. // avoid memory leaks.
class ScopedMediaType { class ScopedMediaType {
public: public:
ScopedMediaType() : media_type_(nullptr) {} ScopedMediaType() : media_type_(NULL) {}
~ScopedMediaType() { Free(); } ~ScopedMediaType() { Free(); }
AM_MEDIA_TYPE* operator->() { return media_type_; } AM_MEDIA_TYPE* operator->() { return media_type_; }
...@@ -57,25 +57,25 @@ class VideoCaptureDeviceWin : public VideoCaptureDevice, ...@@ -57,25 +57,25 @@ class VideoCaptureDeviceWin : public VideoCaptureDevice,
AM_MEDIA_TYPE* media_type_; AM_MEDIA_TYPE* media_type_;
}; };
static void GetDeviceCapabilityList( static void GetDeviceCapabilityList(const std::string& device_id,
Microsoft::WRL::ComPtr<IBaseFilter> capture_filter, bool query_detailed_frame_rates,
bool query_detailed_frame_rates, CapabilityList* out_capability_list);
CapabilityList* out_capability_list);
static void GetPinCapabilityList( static void GetPinCapabilityList(
Microsoft::WRL::ComPtr<IBaseFilter> capture_filter, Microsoft::WRL::ComPtr<IBaseFilter> capture_filter,
Microsoft::WRL::ComPtr<IPin> output_capture_pin, Microsoft::WRL::ComPtr<IPin> output_capture_pin,
bool query_detailed_frame_rates, bool query_detailed_frame_rates,
CapabilityList* out_capability_list); CapabilityList* out_capability_list);
static Microsoft::WRL::ComPtr<IPin> GetPin( static HRESULT GetDeviceFilter(const std::string& device_id,
Microsoft::WRL::ComPtr<IBaseFilter> capture_filter, IBaseFilter** filter);
PIN_DIRECTION pin_dir, static Microsoft::WRL::ComPtr<IPin> GetPin(IBaseFilter* filter,
REFGUID category, PIN_DIRECTION pin_dir,
REFGUID major_type); REFGUID category,
REFGUID major_type);
static VideoPixelFormat TranslateMediaSubtypeToPixelFormat( static VideoPixelFormat TranslateMediaSubtypeToPixelFormat(
const GUID& sub_type); const GUID& sub_type);
VideoCaptureDeviceWin(const VideoCaptureDeviceDescriptor& device_descriptor, explicit VideoCaptureDeviceWin(
Microsoft::WRL::ComPtr<IBaseFilter> capture_filter); const VideoCaptureDeviceDescriptor& device_descriptor);
~VideoCaptureDeviceWin() override; ~VideoCaptureDeviceWin() override;
// Opens the device driver for this device. // Opens the device driver for this device.
bool Init(); bool Init();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment