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/video/capture/win/video_capture_device_win.h" | 5 #include "media/video/capture/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 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
307 SetErrorState("Failed to GetNumberOfCapabilities"); | 307 SetErrorState("Failed to GetNumberOfCapabilities"); |
308 return; | 308 return; |
309 } | 309 } |
310 | 310 |
311 scoped_ptr<BYTE[]> caps(new BYTE[size]); | 311 scoped_ptr<BYTE[]> caps(new BYTE[size]); |
312 ScopedMediaType media_type; | 312 ScopedMediaType media_type; |
313 | 313 |
314 // Get the windows capability from the capture device. | 314 // Get the windows capability from the capture device. |
315 hr = stream_config->GetStreamCaps( | 315 hr = stream_config->GetStreamCaps( |
316 found_capability.stream_index, media_type.Receive(), caps.get()); | 316 found_capability.stream_index, media_type.Receive(), caps.get()); |
317 if (SUCCEEDED(hr)) { | 317 if (FAILED(hr)) { |
mcasas
2014/08/19 08:23:36
Hmm, I might be overzealous but there's this ratio
Henrik Grunell
2014/08/19 08:50:53
Done.
| |
318 SetErrorState("Failed to get capture device capabilities"); | |
Henrik Grunell
2014/08/19 08:50:53
Note my previous question (repeating here):
Shoul
mcasas
2014/08/19 11:20:32
IMHO we should add a return here for coherence rea
Henrik Grunell
2014/08/19 11:39:47
Added in both places.
I would though say it shoul
| |
319 } else { | |
318 if (media_type->formattype == FORMAT_VideoInfo) { | 320 if (media_type->formattype == FORMAT_VideoInfo) { |
319 VIDEOINFOHEADER* h = | 321 VIDEOINFOHEADER* h = |
320 reinterpret_cast<VIDEOINFOHEADER*>(media_type->pbFormat); | 322 reinterpret_cast<VIDEOINFOHEADER*>(media_type->pbFormat); |
321 if (format.frame_rate > 0) | 323 if (format.frame_rate > 0) |
322 h->AvgTimePerFrame = kSecondsToReferenceTime / format.frame_rate; | 324 h->AvgTimePerFrame = kSecondsToReferenceTime / format.frame_rate; |
323 } | 325 } |
324 // Set the sink filter to request this format. | 326 // Set the sink filter to request this format. |
325 sink_filter_->SetRequestedMediaFormat(format); | 327 sink_filter_->SetRequestedMediaFormat(format); |
326 // Order the capture device to use this format. | 328 // Order the capture device to use this format. |
327 hr = stream_config->SetFormat(media_type.get()); | 329 hr = stream_config->SetFormat(media_type.get()); |
330 if (FAILED(hr)) | |
331 SetErrorState("Failed to set capture device output format"); | |
mcasas
2014/08/19 08:23:36
Suggestion: Use SystemErrorCodeToString() [0] to
p
Henrik Grunell
2014/08/19 08:50:53
Are you sure that works for this case? I'd prefer
mcasas
2014/08/19 11:20:32
The method FormatMessageA() underlying
SystemErro
Henrik Grunell
2014/08/19 11:39:47
OK.
| |
328 } | 332 } |
329 | 333 |
330 if (FAILED(hr)) | |
331 SetErrorState("Failed to set capture device output format"); | |
332 | |
333 if (format.pixel_format == PIXEL_FORMAT_MJPEG && !mjpg_filter_.get()) { | 334 if (format.pixel_format == PIXEL_FORMAT_MJPEG && !mjpg_filter_.get()) { |
334 // Create MJPG filter if we need it. | 335 // Create MJPG filter if we need it. |
335 hr = mjpg_filter_.CreateInstance(CLSID_MjpegDec, NULL, CLSCTX_INPROC); | 336 hr = mjpg_filter_.CreateInstance(CLSID_MjpegDec, NULL, CLSCTX_INPROC); |
336 | 337 |
337 if (SUCCEEDED(hr)) { | 338 if (SUCCEEDED(hr)) { |
338 input_mjpg_pin_ = GetPin(mjpg_filter_, PINDIR_INPUT, GUID_NULL); | 339 input_mjpg_pin_ = GetPin(mjpg_filter_, PINDIR_INPUT, GUID_NULL); |
339 output_mjpg_pin_ = GetPin(mjpg_filter_, PINDIR_OUTPUT, GUID_NULL); | 340 output_mjpg_pin_ = GetPin(mjpg_filter_, PINDIR_OUTPUT, GUID_NULL); |
340 hr = graph_builder_->AddFilter(mjpg_filter_, NULL); | 341 hr = graph_builder_->AddFilter(mjpg_filter_, NULL); |
341 } | 342 } |
342 | 343 |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
544 } | 545 } |
545 } | 546 } |
546 | 547 |
547 void VideoCaptureDeviceWin::SetErrorState(const std::string& reason) { | 548 void VideoCaptureDeviceWin::SetErrorState(const std::string& reason) { |
548 DCHECK(CalledOnValidThread()); | 549 DCHECK(CalledOnValidThread()); |
549 DVLOG(1) << reason; | 550 DVLOG(1) << reason; |
550 state_ = kError; | 551 state_ = kError; |
551 client_->OnError(reason); | 552 client_->OnError(reason); |
552 } | 553 } |
553 } // namespace media | 554 } // namespace media |
OLD | NEW |