| 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 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 ScopedMediaType media_type; | 344 ScopedMediaType media_type; |
| 345 | 345 |
| 346 // Get the windows capability from the capture device. | 346 // Get the windows capability from the capture device. |
| 347 // GetStreamCaps can return S_FALSE which we consider an error. Therefore the | 347 // GetStreamCaps can return S_FALSE which we consider an error. Therefore the |
| 348 // FAILED macro can't be used. | 348 // FAILED macro can't be used. |
| 349 hr = stream_config->GetStreamCaps( | 349 hr = stream_config->GetStreamCaps( |
| 350 found_capability.stream_index, media_type.Receive(), caps.get()); | 350 found_capability.stream_index, media_type.Receive(), caps.get()); |
| 351 if (hr != S_OK) { | 351 if (hr != S_OK) { |
| 352 SetErrorState("Failed to get capture device capabilities"); | 352 SetErrorState("Failed to get capture device capabilities"); |
| 353 return; | 353 return; |
| 354 } else { | 354 } |
| 355 if (media_type->formattype == FORMAT_VideoInfo) { | 355 if (media_type->formattype == FORMAT_VideoInfo) { |
| 356 VIDEOINFOHEADER* h = | 356 VIDEOINFOHEADER* h = |
| 357 reinterpret_cast<VIDEOINFOHEADER*>(media_type->pbFormat); | 357 reinterpret_cast<VIDEOINFOHEADER*>(media_type->pbFormat); |
| 358 if (format.frame_rate > 0) | 358 if (format.frame_rate > 0) |
| 359 h->AvgTimePerFrame = kSecondsToReferenceTime / format.frame_rate; | 359 h->AvgTimePerFrame = kSecondsToReferenceTime / format.frame_rate; |
| 360 } | 360 } |
| 361 // Set the sink filter to request this format. | 361 // Set the sink filter to request this format. |
| 362 sink_filter_->SetRequestedMediaFormat(format); | 362 sink_filter_->SetRequestedMediaFormat(format); |
| 363 // Order the capture device to use this format. | 363 // Order the capture device to use this format. |
| 364 hr = stream_config->SetFormat(media_type.get()); | 364 hr = stream_config->SetFormat(media_type.get()); |
| 365 if (FAILED(hr)) { | 365 if (FAILED(hr)) { |
| 366 // TODO(grunell): Log the error. http://crbug.com/405016. | 366 // TODO(grunell): Log the error. http://crbug.com/405016. |
| 367 SetErrorState("Failed to set capture device output format"); | 367 SetErrorState("Failed to set capture device output format"); |
| 368 return; | 368 return; |
| 369 } | |
| 370 } | 369 } |
| 371 | 370 |
| 372 SetAntiFlickerInCaptureFilter(); | 371 SetAntiFlickerInCaptureFilter(); |
| 373 | 372 |
| 374 if (media_type->subtype == kMediaSubTypeHDYC) { | 373 if (media_type->subtype == kMediaSubTypeHDYC) { |
| 375 // HDYC pixel format, used by the DeckLink capture card, needs an AVI | 374 // HDYC pixel format, used by the DeckLink capture card, needs an AVI |
| 376 // decompressor filter after source, let |graph_builder_| add it. | 375 // decompressor filter after source, let |graph_builder_| add it. |
| 377 hr = graph_builder_->Connect(output_capture_pin_.get(), | 376 hr = graph_builder_->Connect(output_capture_pin_.get(), |
| 378 input_sink_pin_.get()); | 377 input_sink_pin_.get()); |
| 379 } else { | 378 } else { |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 612 return E_FAIL; | 611 return E_FAIL; |
| 613 return S_OK; | 612 return S_OK; |
| 614 } | 613 } |
| 615 | 614 |
| 616 void VideoCaptureDeviceWin::SetErrorState(const std::string& reason) { | 615 void VideoCaptureDeviceWin::SetErrorState(const std::string& reason) { |
| 617 DCHECK(CalledOnValidThread()); | 616 DCHECK(CalledOnValidThread()); |
| 618 state_ = kError; | 617 state_ = kError; |
| 619 client_->OnError(reason); | 618 client_->OnError(reason); |
| 620 } | 619 } |
| 621 } // namespace media | 620 } // namespace media |
| OLD | NEW |