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 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 // Delete a media type structure that was allocated on the heap. | 203 // Delete a media type structure that was allocated on the heap. |
204 // http://msdn.microsoft.com/en-us/library/dd375432(VS.85).aspx | 204 // http://msdn.microsoft.com/en-us/library/dd375432(VS.85).aspx |
205 void VideoCaptureDeviceWin::ScopedMediaType::DeleteMediaType( | 205 void VideoCaptureDeviceWin::ScopedMediaType::DeleteMediaType( |
206 AM_MEDIA_TYPE* mt) { | 206 AM_MEDIA_TYPE* mt) { |
207 if (mt != NULL) { | 207 if (mt != NULL) { |
208 FreeMediaType(mt); | 208 FreeMediaType(mt); |
209 CoTaskMemFree(mt); | 209 CoTaskMemFree(mt); |
210 } | 210 } |
211 } | 211 } |
212 | 212 |
213 VideoCaptureDeviceWin::VideoCaptureDeviceWin(const Name& device_name) | 213 VideoCaptureDeviceWin::VideoCaptureDeviceWin( |
214 : device_name_(device_name), state_(kIdle) { | 214 const VideoCaptureDeviceDescriptor& device_descriptor) |
| 215 : device_descriptor_(device_descriptor), state_(kIdle) { |
215 // TODO(mcasas): Check that CoInitializeEx() has been called with the | 216 // TODO(mcasas): Check that CoInitializeEx() has been called with the |
216 // appropriate Apartment model, i.e., Single Threaded. | 217 // appropriate Apartment model, i.e., Single Threaded. |
217 } | 218 } |
218 | 219 |
219 VideoCaptureDeviceWin::~VideoCaptureDeviceWin() { | 220 VideoCaptureDeviceWin::~VideoCaptureDeviceWin() { |
220 DCHECK(thread_checker_.CalledOnValidThread()); | 221 DCHECK(thread_checker_.CalledOnValidThread()); |
221 if (media_control_.get()) | 222 if (media_control_.get()) |
222 media_control_->Stop(); | 223 media_control_->Stop(); |
223 | 224 |
224 if (graph_builder_.get()) { | 225 if (graph_builder_.get()) { |
225 if (sink_filter_.get()) { | 226 if (sink_filter_.get()) { |
226 graph_builder_->RemoveFilter(sink_filter_.get()); | 227 graph_builder_->RemoveFilter(sink_filter_.get()); |
227 sink_filter_ = NULL; | 228 sink_filter_ = NULL; |
228 } | 229 } |
229 | 230 |
230 if (capture_filter_.get()) | 231 if (capture_filter_.get()) |
231 graph_builder_->RemoveFilter(capture_filter_.get()); | 232 graph_builder_->RemoveFilter(capture_filter_.get()); |
232 } | 233 } |
233 | 234 |
234 if (capture_graph_builder_.get()) | 235 if (capture_graph_builder_.get()) |
235 capture_graph_builder_.Release(); | 236 capture_graph_builder_.Release(); |
236 } | 237 } |
237 | 238 |
238 bool VideoCaptureDeviceWin::Init() { | 239 bool VideoCaptureDeviceWin::Init() { |
239 DCHECK(thread_checker_.CalledOnValidThread()); | 240 DCHECK(thread_checker_.CalledOnValidThread()); |
240 HRESULT hr; | 241 HRESULT hr; |
241 | 242 |
242 hr = GetDeviceFilter(device_name_.id(), capture_filter_.Receive()); | 243 hr = GetDeviceFilter(device_descriptor_.device_id, capture_filter_.Receive()); |
243 | 244 |
244 if (!capture_filter_.get()) { | 245 if (!capture_filter_.get()) { |
245 DLOG(ERROR) << "Failed to create capture filter: " | 246 DLOG(ERROR) << "Failed to create capture filter: " |
246 << logging::SystemErrorCodeToString(hr); | 247 << logging::SystemErrorCodeToString(hr); |
247 return false; | 248 return false; |
248 } | 249 } |
249 | 250 |
250 output_capture_pin_ = GetPin(capture_filter_.get(), PINDIR_OUTPUT, | 251 output_capture_pin_ = GetPin(capture_filter_.get(), PINDIR_OUTPUT, |
251 PIN_CATEGORY_CAPTURE, GUID_NULL); | 252 PIN_CATEGORY_CAPTURE, GUID_NULL); |
252 if (!output_capture_pin_.get()) { | 253 if (!output_capture_pin_.get()) { |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 } | 585 } |
585 | 586 |
586 void VideoCaptureDeviceWin::SetErrorState( | 587 void VideoCaptureDeviceWin::SetErrorState( |
587 const tracked_objects::Location& from_here, | 588 const tracked_objects::Location& from_here, |
588 const std::string& reason) { | 589 const std::string& reason) { |
589 DCHECK(thread_checker_.CalledOnValidThread()); | 590 DCHECK(thread_checker_.CalledOnValidThread()); |
590 state_ = kError; | 591 state_ = kError; |
591 client_->OnError(from_here, reason); | 592 client_->OnError(from_here, reason); |
592 } | 593 } |
593 } // namespace media | 594 } // namespace media |
OLD | NEW |