| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <list> | 8 #include <list> |
| 9 | 9 |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 | 326 |
| 327 void VideoCaptureDeviceWin::Allocate( | 327 void VideoCaptureDeviceWin::Allocate( |
| 328 int width, | 328 int width, |
| 329 int height, | 329 int height, |
| 330 int frame_rate, | 330 int frame_rate, |
| 331 VideoCaptureDevice::EventHandler* observer) { | 331 VideoCaptureDevice::EventHandler* observer) { |
| 332 if (state_ != kIdle) | 332 if (state_ != kIdle) |
| 333 return; | 333 return; |
| 334 | 334 |
| 335 observer_ = observer; | 335 observer_ = observer; |
| 336 observer_->OnDeviceState(true); |
| 337 |
| 336 // Get the camera capability that best match the requested resolution. | 338 // Get the camera capability that best match the requested resolution. |
| 337 const int capability_index = GetBestMatchedCapability(width, height, | 339 const int capability_index = GetBestMatchedCapability(width, height, |
| 338 frame_rate); | 340 frame_rate); |
| 339 Capability capability = capabilities_[capability_index]; | 341 Capability capability = capabilities_[capability_index]; |
| 340 | 342 |
| 341 // Reduce the frame rate if the requested frame rate is lower | 343 // Reduce the frame rate if the requested frame rate is lower |
| 342 // than the capability. | 344 // than the capability. |
| 343 if (capability.frame_rate > frame_rate) | 345 if (capability.frame_rate > frame_rate) |
| 344 capability.frame_rate = frame_rate; | 346 capability.frame_rate = frame_rate; |
| 345 | 347 |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 if (mjpg_filter_) { | 461 if (mjpg_filter_) { |
| 460 graph_builder_->Disconnect(input_mjpg_pin_); | 462 graph_builder_->Disconnect(input_mjpg_pin_); |
| 461 graph_builder_->Disconnect(output_mjpg_pin_); | 463 graph_builder_->Disconnect(output_mjpg_pin_); |
| 462 } | 464 } |
| 463 | 465 |
| 464 if (FAILED(hr)) { | 466 if (FAILED(hr)) { |
| 465 SetErrorState("Failed to Stop the Capture device"); | 467 SetErrorState("Failed to Stop the Capture device"); |
| 466 return; | 468 return; |
| 467 } | 469 } |
| 468 | 470 |
| 471 observer_->OnDeviceState(false); |
| 469 state_ = kIdle; | 472 state_ = kIdle; |
| 470 } | 473 } |
| 471 | 474 |
| 472 const VideoCaptureDevice::Name& VideoCaptureDeviceWin::device_name() { | 475 const VideoCaptureDevice::Name& VideoCaptureDeviceWin::device_name() { |
| 473 return device_name_; | 476 return device_name_; |
| 474 } | 477 } |
| 475 | 478 |
| 476 // Implements SinkFilterObserver::SinkFilterObserver. | 479 // Implements SinkFilterObserver::SinkFilterObserver. |
| 477 void VideoCaptureDeviceWin::FrameReceived(const uint8* buffer, | 480 void VideoCaptureDeviceWin::FrameReceived(const uint8* buffer, |
| 478 int length) { | 481 int length) { |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 return diff_list.front().capability_index; | 650 return diff_list.front().capability_index; |
| 648 } | 651 } |
| 649 | 652 |
| 650 void VideoCaptureDeviceWin::SetErrorState(const char* reason) { | 653 void VideoCaptureDeviceWin::SetErrorState(const char* reason) { |
| 651 DLOG(ERROR) << reason; | 654 DLOG(ERROR) << reason; |
| 652 state_ = kError; | 655 state_ = kError; |
| 653 observer_->OnError(); | 656 observer_->OnError(); |
| 654 } | 657 } |
| 655 | 658 |
| 656 } // namespace media | 659 } // namespace media |
| OLD | NEW |