Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Unified Diff: media/capture/video/win/video_capture_device_win.cc

Issue 2962613002: [Merge to 3141] Revert "Image Capture win: initialize camera controls lazily" (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/capture/video/win/video_capture_device_win.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/capture/video/win/video_capture_device_win.cc
diff --git a/media/capture/video/win/video_capture_device_win.cc b/media/capture/video/win/video_capture_device_win.cc
index 962ac0156685bf962bb2d3ba9c7acd4fcb0a6cde..ce27a07cc34893b889c01c3a88ec051c3e00236e 100644
--- a/media/capture/video/win/video_capture_device_win.cc
+++ b/media/capture/video/win/video_capture_device_win.cc
@@ -465,6 +465,44 @@ void VideoCaptureDeviceWin::AllocateAndStart(
client_->OnStarted();
state_ = kCapturing;
+
+ base::win::ScopedComPtr<IKsTopologyInfo> info;
+ hr = capture_filter_.CopyTo(info.GetAddressOf());
+ if (FAILED(hr)) {
+ SetErrorState(FROM_HERE, "Failed to obtain the topology info.", hr);
+ return;
+ }
+
+ DWORD num_nodes = 0;
+ hr = info->get_NumNodes(&num_nodes);
+ if (FAILED(hr)) {
+ SetErrorState(FROM_HERE, "Failed to obtain the number of nodes.", hr);
+ return;
+ }
+
+ // Every UVC camera is expected to have a single ICameraControl and a single
+ // IVideoProcAmp nodes, and both are needed; ignore any unlikely later ones.
+ GUID node_type;
+ for (size_t i = 0; i < num_nodes; i++) {
+ info->get_NodeType(i, &node_type);
+ if (IsEqualGUID(node_type, KSNODETYPE_VIDEO_CAMERA_TERMINAL)) {
+ hr = info->CreateNodeInstance(i, IID_PPV_ARGS(&camera_control_));
+ if (SUCCEEDED(hr))
+ break;
+ SetErrorState(FROM_HERE, "Failed to retrieve the ICameraControl.", hr);
+ return;
+ }
+ }
+ for (size_t i = 0; i < num_nodes; i++) {
+ info->get_NodeType(i, &node_type);
+ if (IsEqualGUID(node_type, KSNODETYPE_VIDEO_PROCESSING)) {
+ hr = info->CreateNodeInstance(i, IID_PPV_ARGS(&video_control_));
+ if (SUCCEEDED(hr))
+ break;
+ SetErrorState(FROM_HERE, "Failed to retrieve the IVideoProcAmp.", hr);
+ return;
+ }
+ }
}
void VideoCaptureDeviceWin::StopAndDeAllocate() {
@@ -498,7 +536,7 @@ void VideoCaptureDeviceWin::GetPhotoState(GetPhotoStateCallback callback) {
DCHECK(thread_checker_.CalledOnValidThread());
if (!camera_control_ || !video_control_)
- InitializeVideoAndCameraControls();
+ return;
auto photo_capabilities = mojom::PhotoState::New();
@@ -590,7 +628,7 @@ void VideoCaptureDeviceWin::SetPhotoOptions(
DCHECK(thread_checker_.CalledOnValidThread());
if (!camera_control_ || !video_control_)
- InitializeVideoAndCameraControls();
+ return;
HRESULT hr;
@@ -672,47 +710,6 @@ void VideoCaptureDeviceWin::SetPhotoOptions(
callback.Run(true);
}
-
-void VideoCaptureDeviceWin::InitializeVideoAndCameraControls() {
- base::win::ScopedComPtr<IKsTopologyInfo> info;
- HRESULT hr = capture_filter_.CopyTo(info.GetAddressOf());
- if (FAILED(hr)) {
- SetErrorState(FROM_HERE, "Failed to obtain the topology info.", hr);
- return;
- }
-
- DWORD num_nodes = 0;
- hr = info->get_NumNodes(&num_nodes);
- if (FAILED(hr)) {
- SetErrorState(FROM_HERE, "Failed to obtain the number of nodes.", hr);
- return;
- }
-
- // Every UVC camera is expected to have a single ICameraControl and a single
- // IVideoProcAmp nodes, and both are needed; ignore any unlikely later ones.
- GUID node_type;
- for (size_t i = 0; i < num_nodes; i++) {
- info->get_NodeType(i, &node_type);
- if (IsEqualGUID(node_type, KSNODETYPE_VIDEO_CAMERA_TERMINAL)) {
- hr = info->CreateNodeInstance(i, IID_PPV_ARGS(&camera_control_));
- if (SUCCEEDED(hr))
- break;
- SetErrorState(FROM_HERE, "Failed to retrieve the ICameraControl.", hr);
- return;
- }
- }
- for (size_t i = 0; i < num_nodes; i++) {
- info->get_NodeType(i, &node_type);
- if (IsEqualGUID(node_type, KSNODETYPE_VIDEO_PROCESSING)) {
- hr = info->CreateNodeInstance(i, IID_PPV_ARGS(&video_control_));
- if (SUCCEEDED(hr))
- break;
- SetErrorState(FROM_HERE, "Failed to retrieve the IVideoProcAmp.", hr);
- return;
- }
- }
-}
-
// Implements SinkFilterObserver::SinkFilterObserver.
void VideoCaptureDeviceWin::FrameReceived(const uint8_t* buffer,
int length,
« no previous file with comments | « media/capture/video/win/video_capture_device_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698