| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "media/capture/video/win/video_capture_device_win.h" | 5 #include "media/capture/video/win/video_capture_device_win.h" |
| 6 | 6 |
| 7 #include <ks.h> | 7 #include <ks.h> |
| 8 #include <ksmedia.h> | 8 #include <ksmedia.h> |
| 9 #include <objbase.h> | 9 #include <objbase.h> |
| 10 | 10 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 return control_range; | 101 return control_range; |
| 102 } | 102 } |
| 103 | 103 |
| 104 // Finds and creates a DirectShow Video Capture filter matching the |device_id|. | 104 // Finds and creates a DirectShow Video Capture filter matching the |device_id|. |
| 105 // static | 105 // static |
| 106 HRESULT VideoCaptureDeviceWin::GetDeviceFilter(const std::string& device_id, | 106 HRESULT VideoCaptureDeviceWin::GetDeviceFilter(const std::string& device_id, |
| 107 IBaseFilter** filter) { | 107 IBaseFilter** filter) { |
| 108 DCHECK(filter); | 108 DCHECK(filter); |
| 109 | 109 |
| 110 ScopedComPtr<ICreateDevEnum> dev_enum; | 110 ScopedComPtr<ICreateDevEnum> dev_enum; |
| 111 HRESULT hr = | 111 HRESULT hr = ::CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC, |
| 112 dev_enum.CreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC); | 112 IID_PPV_ARGS(&dev_enum)); |
| 113 if (FAILED(hr)) | 113 if (FAILED(hr)) |
| 114 return hr; | 114 return hr; |
| 115 | 115 |
| 116 ScopedComPtr<IEnumMoniker> enum_moniker; | 116 ScopedComPtr<IEnumMoniker> enum_moniker; |
| 117 hr = dev_enum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, | 117 hr = dev_enum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, |
| 118 enum_moniker.GetAddressOf(), 0); | 118 enum_moniker.GetAddressOf(), 0); |
| 119 // CreateClassEnumerator returns S_FALSE on some Windows OS | 119 // CreateClassEnumerator returns S_FALSE on some Windows OS |
| 120 // when no camera exist. Therefore the FAILED macro can't be used. | 120 // when no camera exist. Therefore the FAILED macro can't be used. |
| 121 if (hr != S_OK) | 121 if (hr != S_OK) |
| 122 return hr; | 122 return hr; |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 | 309 |
| 310 // Create the sink filter used for receiving Captured frames. | 310 // Create the sink filter used for receiving Captured frames. |
| 311 sink_filter_ = new SinkFilter(this); | 311 sink_filter_ = new SinkFilter(this); |
| 312 if (sink_filter_.get() == NULL) { | 312 if (sink_filter_.get() == NULL) { |
| 313 DLOG(ERROR) << "Failed to create sink filter"; | 313 DLOG(ERROR) << "Failed to create sink filter"; |
| 314 return false; | 314 return false; |
| 315 } | 315 } |
| 316 | 316 |
| 317 input_sink_pin_ = sink_filter_->GetPin(0); | 317 input_sink_pin_ = sink_filter_->GetPin(0); |
| 318 | 318 |
| 319 hr = graph_builder_.CreateInstance(CLSID_FilterGraph, NULL, | 319 hr = ::CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, |
| 320 CLSCTX_INPROC_SERVER); | 320 IID_PPV_ARGS(&graph_builder_)); |
| 321 DLOG_IF_FAILED_WITH_HRESULT("Failed to create capture filter", hr); | 321 DLOG_IF_FAILED_WITH_HRESULT("Failed to create capture filter", hr); |
| 322 if (FAILED(hr)) | 322 if (FAILED(hr)) |
| 323 return false; | 323 return false; |
| 324 | 324 |
| 325 hr = capture_graph_builder_.CreateInstance(CLSID_CaptureGraphBuilder2, NULL, | 325 hr = ::CoCreateInstance(CLSID_CaptureGraphBuilder2, NULL, CLSCTX_INPROC, |
| 326 CLSCTX_INPROC); | 326 IID_PPV_ARGS(&capture_graph_builder_)); |
| 327 DLOG_IF_FAILED_WITH_HRESULT("Failed to create the Capture Graph Builder", hr); | 327 DLOG_IF_FAILED_WITH_HRESULT("Failed to create the Capture Graph Builder", hr); |
| 328 if (FAILED(hr)) | 328 if (FAILED(hr)) |
| 329 return false; | 329 return false; |
| 330 | 330 |
| 331 hr = capture_graph_builder_->SetFiltergraph(graph_builder_.Get()); | 331 hr = capture_graph_builder_->SetFiltergraph(graph_builder_.Get()); |
| 332 DLOG_IF_FAILED_WITH_HRESULT("Failed to give graph to capture graph builder", | 332 DLOG_IF_FAILED_WITH_HRESULT("Failed to give graph to capture graph builder", |
| 333 hr); | 333 hr); |
| 334 if (FAILED(hr)) | 334 if (FAILED(hr)) |
| 335 return false; | 335 return false; |
| 336 | 336 |
| (...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 848 void VideoCaptureDeviceWin::SetErrorState( | 848 void VideoCaptureDeviceWin::SetErrorState( |
| 849 const tracked_objects::Location& from_here, | 849 const tracked_objects::Location& from_here, |
| 850 const std::string& reason, | 850 const std::string& reason, |
| 851 HRESULT hr) { | 851 HRESULT hr) { |
| 852 DCHECK(thread_checker_.CalledOnValidThread()); | 852 DCHECK(thread_checker_.CalledOnValidThread()); |
| 853 DLOG_IF_FAILED_WITH_HRESULT(reason, hr); | 853 DLOG_IF_FAILED_WITH_HRESULT(reason, hr); |
| 854 state_ = kError; | 854 state_ = kError; |
| 855 client_->OnError(from_here, reason); | 855 client_->OnError(from_here, reason); |
| 856 } | 856 } |
| 857 } // namespace media | 857 } // namespace media |
| OLD | NEW |