| 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 #include "media/base/video_frame.h" |
| 9 | 10 |
| 10 namespace content { | 11 namespace content { |
| 11 | 12 |
| 12 RtcVideoCapturer::RtcVideoCapturer(const media::VideoCaptureSessionId id, | 13 RtcVideoCapturer::RtcVideoCapturer(const media::VideoCaptureSessionId id, |
| 13 VideoCaptureImplManager* vc_manager, | 14 VideoCaptureImplManager* vc_manager, |
| 14 bool is_screencast) | 15 bool is_screencast) |
| 15 : is_screencast_(is_screencast), | 16 : is_screencast_(is_screencast), |
| 16 delegate_(new RtcVideoCaptureDelegate(id, vc_manager)), | 17 delegate_(new RtcVideoCaptureDelegate(id, vc_manager)), |
| 17 state_(VIDEO_CAPTURE_STATE_STOPPED) {} | 18 state_(VIDEO_CAPTURE_STATE_STOPPED) {} |
| 18 | 19 |
| 19 RtcVideoCapturer::~RtcVideoCapturer() { | 20 RtcVideoCapturer::~RtcVideoCapturer() { |
| 20 DCHECK(VIDEO_CAPTURE_STATE_STOPPED); | 21 DCHECK(VIDEO_CAPTURE_STATE_STOPPED); |
| 21 DVLOG(3) << " RtcVideoCapturer::dtor"; | 22 DVLOG(3) << " RtcVideoCapturer::dtor"; |
| 22 } | 23 } |
| 23 | 24 |
| 24 cricket::CaptureState RtcVideoCapturer::Start( | 25 cricket::CaptureState RtcVideoCapturer::Start( |
| 25 const cricket::VideoFormat& capture_format) { | 26 const cricket::VideoFormat& capture_format) { |
| 26 DVLOG(3) << " RtcVideoCapturer::Start "; | 27 DVLOG(3) << " RtcVideoCapturer::Start "; |
| 27 if (state_ == VIDEO_CAPTURE_STATE_STARTED) { | 28 if (state_ == VIDEO_CAPTURE_STATE_STARTED) { |
| 28 DVLOG(1) << "Got a StartCapture when already started!!! "; | 29 DVLOG(1) << "Got a StartCapture when already started!!! "; |
| 29 return cricket::CS_FAILED; | 30 return cricket::CS_FAILED; |
| 30 } | 31 } |
| 31 | 32 |
| 32 media::VideoCaptureParams request; | 33 media::VideoCaptureParams request; |
| 33 request.requested_format = | 34 request.requested_format = media::VideoCaptureFormat( |
| 34 media::VideoCaptureFormat(capture_format.width, | 35 gfx::Size(capture_format.width, capture_format.height), |
| 35 capture_format.height, | 36 capture_format.framerate(), |
| 36 capture_format.framerate(), | 37 media::PIXEL_FORMAT_I420); |
| 37 media::ConstantResolutionVideoCaptureDevice); | |
| 38 | 38 |
| 39 SetCaptureFormat(&capture_format); | 39 SetCaptureFormat(&capture_format); |
| 40 | 40 |
| 41 state_ = VIDEO_CAPTURE_STATE_STARTED; | 41 state_ = VIDEO_CAPTURE_STATE_STARTED; |
| 42 first_frame_timestamp_ = media::kNoTimestamp(); | 42 first_frame_timestamp_ = media::kNoTimestamp(); |
| 43 delegate_->StartCapture( | 43 delegate_->StartCapture( |
| 44 request, | 44 request, |
| 45 base::Bind(&RtcVideoCapturer::OnFrameCaptured, base::Unretained(this)), | 45 base::Bind(&RtcVideoCapturer::OnFrameCaptured, base::Unretained(this)), |
| 46 base::Bind(&RtcVideoCapturer::OnStateChange, base::Unretained(this))); | 46 base::Bind(&RtcVideoCapturer::OnStateChange, base::Unretained(this))); |
| 47 // 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 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 converted_state = cricket::CS_FAILED; | 150 converted_state = cricket::CS_FAILED; |
| 151 break; | 151 break; |
| 152 default: | 152 default: |
| 153 NOTREACHED(); | 153 NOTREACHED(); |
| 154 break; | 154 break; |
| 155 } | 155 } |
| 156 SignalStateChange(this, converted_state); | 156 SignalStateChange(this, converted_state); |
| 157 } | 157 } |
| 158 | 158 |
| 159 } // namespace content | 159 } // namespace content |
| OLD | NEW |