| 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 "content/renderer/media/rtc_video_capturer.h" | 5 #include "content/renderer/media/rtc_video_capturer.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 9 | 9 |
| 10 namespace content { | 10 namespace content { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 } | 22 } |
| 23 | 23 |
| 24 cricket::CaptureState RtcVideoCapturer::Start( | 24 cricket::CaptureState RtcVideoCapturer::Start( |
| 25 const cricket::VideoFormat& capture_format) { | 25 const cricket::VideoFormat& capture_format) { |
| 26 DVLOG(3) << " RtcVideoCapturer::Start "; | 26 DVLOG(3) << " RtcVideoCapturer::Start "; |
| 27 if (state_ == VIDEO_CAPTURE_STATE_STARTED) { | 27 if (state_ == VIDEO_CAPTURE_STATE_STARTED) { |
| 28 DVLOG(1) << "Got a StartCapture when already started!!! "; | 28 DVLOG(1) << "Got a StartCapture when already started!!! "; |
| 29 return cricket::CS_FAILED; | 29 return cricket::CS_FAILED; |
| 30 } | 30 } |
| 31 | 31 |
| 32 media::VideoCaptureCapability cap; | 32 media::VideoCaptureParams request; |
| 33 cap.width = capture_format.width; | 33 request.requested_format = |
| 34 cap.height = capture_format.height; | 34 media::VideoCaptureFormat(capture_format.width, |
| 35 cap.frame_rate = capture_format.framerate(); | 35 capture_format.height, |
| 36 cap.color = media::PIXEL_FORMAT_I420; | 36 capture_format.framerate(), |
| 37 media::ConstantResolutionVideoCaptureDevice); |
| 37 | 38 |
| 38 SetCaptureFormat(&capture_format); | 39 SetCaptureFormat(&capture_format); |
| 39 | 40 |
| 40 state_ = VIDEO_CAPTURE_STATE_STARTED; | 41 state_ = VIDEO_CAPTURE_STATE_STARTED; |
| 41 first_frame_timestamp_ = media::kNoTimestamp(); | 42 first_frame_timestamp_ = media::kNoTimestamp(); |
| 42 delegate_->StartCapture( | 43 delegate_->StartCapture( |
| 43 cap, | 44 request, |
| 44 base::Bind(&RtcVideoCapturer::OnFrameCaptured, base::Unretained(this)), | 45 base::Bind(&RtcVideoCapturer::OnFrameCaptured, base::Unretained(this)), |
| 45 base::Bind(&RtcVideoCapturer::OnStateChange, base::Unretained(this))); | 46 base::Bind(&RtcVideoCapturer::OnStateChange, base::Unretained(this))); |
| 46 // Update the desired aspect ratio so that later the video frame can be | 47 // Update the desired aspect ratio so that later the video frame can be |
| 47 // cropped to meet the requirement if the camera returns a different | 48 // cropped to meet the requirement if the camera returns a different |
| 48 // resolution than the |cap|. | 49 // resolution than the |request|. |
| 49 UpdateAspectRatio(cap.width, cap.height); | 50 UpdateAspectRatio(capture_format.width, capture_format.height); |
| 50 return cricket::CS_STARTING; | 51 return cricket::CS_STARTING; |
| 51 } | 52 } |
| 52 | 53 |
| 53 void RtcVideoCapturer::Stop() { | 54 void RtcVideoCapturer::Stop() { |
| 54 DVLOG(3) << " RtcVideoCapturer::Stop "; | 55 DVLOG(3) << " RtcVideoCapturer::Stop "; |
| 55 if (state_ == VIDEO_CAPTURE_STATE_STOPPED) { | 56 if (state_ == VIDEO_CAPTURE_STATE_STOPPED) { |
| 56 DVLOG(1) << "Got a StopCapture while not started."; | 57 DVLOG(1) << "Got a StopCapture while not started."; |
| 57 return; | 58 return; |
| 58 } | 59 } |
| 59 | 60 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 converted_state = cricket::CS_FAILED; | 150 converted_state = cricket::CS_FAILED; |
| 150 break; | 151 break; |
| 151 default: | 152 default: |
| 152 NOTREACHED(); | 153 NOTREACHED(); |
| 153 break; | 154 break; |
| 154 } | 155 } |
| 155 SignalStateChange(this, converted_state); | 156 SignalStateChange(this, converted_state); |
| 156 } | 157 } |
| 157 | 158 |
| 158 } // namespace content | 159 } // namespace content |
| OLD | NEW |