| 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 | 8 |
| 9 namespace content { | 9 namespace content { |
| 10 | 10 |
| 11 RtcVideoCapturer::RtcVideoCapturer( | 11 RtcVideoCapturer::RtcVideoCapturer( |
| 12 const media::VideoCaptureSessionId id, | 12 const media::VideoCaptureSessionId id, |
| 13 VideoCaptureImplManager* vc_manager, | 13 VideoCaptureImplManager* vc_manager, |
| 14 bool is_screencast) | 14 bool is_screencast) |
| 15 : is_screencast_(is_screencast), | 15 : is_screencast_(is_screencast), |
| 16 delegate_(new RtcVideoCaptureDelegate(id, vc_manager)), | 16 delegate_(new RtcVideoCaptureDelegate(id, vc_manager)), |
| 17 state_(video_capture::kStopped) { | 17 state_(VIDEO_CAPTURE_STATE_STOPPED) { |
| 18 } | 18 } |
| 19 | 19 |
| 20 RtcVideoCapturer::~RtcVideoCapturer() { | 20 RtcVideoCapturer::~RtcVideoCapturer() { |
| 21 DCHECK(video_capture::kStopped); | 21 DCHECK(VIDEO_CAPTURE_STATE_STOPPED); |
| 22 DVLOG(3) << " RtcVideoCapturer::dtor"; | 22 DVLOG(3) << " RtcVideoCapturer::dtor"; |
| 23 } | 23 } |
| 24 | 24 |
| 25 cricket::CaptureState RtcVideoCapturer::Start( | 25 cricket::CaptureState RtcVideoCapturer::Start( |
| 26 const cricket::VideoFormat& capture_format) { | 26 const cricket::VideoFormat& capture_format) { |
| 27 DVLOG(3) << " RtcVideoCapturer::Start "; | 27 DVLOG(3) << " RtcVideoCapturer::Start "; |
| 28 if (state_ == video_capture::kStarted) { | 28 if (state_ == VIDEO_CAPTURE_STATE_STARTED) { |
| 29 DVLOG(1) << "Got a StartCapture when already started!!! "; | 29 DVLOG(1) << "Got a StartCapture when already started!!! "; |
| 30 return cricket::CS_FAILED; | 30 return cricket::CS_FAILED; |
| 31 } | 31 } |
| 32 | 32 |
| 33 media::VideoCaptureCapability cap; | 33 media::VideoCaptureCapability cap; |
| 34 cap.width = capture_format.width; | 34 cap.width = capture_format.width; |
| 35 cap.height = capture_format.height; | 35 cap.height = capture_format.height; |
| 36 cap.frame_rate = capture_format.framerate(); | 36 cap.frame_rate = capture_format.framerate(); |
| 37 cap.color = media::VideoCaptureCapability::kI420; | 37 cap.color = media::VideoCaptureCapability::kI420; |
| 38 | 38 |
| 39 state_ = video_capture::kStarted; | 39 state_ = VIDEO_CAPTURE_STATE_STARTED; |
| 40 start_time_ = base::Time::Now(); | 40 start_time_ = base::Time::Now(); |
| 41 delegate_->StartCapture(cap, | 41 delegate_->StartCapture(cap, |
| 42 base::Bind(&RtcVideoCapturer::OnFrameCaptured, base::Unretained(this)), | 42 base::Bind(&RtcVideoCapturer::OnFrameCaptured, base::Unretained(this)), |
| 43 base::Bind(&RtcVideoCapturer::OnStateChange, base::Unretained(this))); | 43 base::Bind(&RtcVideoCapturer::OnStateChange, base::Unretained(this))); |
| 44 return cricket::CS_STARTING; | 44 return cricket::CS_STARTING; |
| 45 } | 45 } |
| 46 | 46 |
| 47 void RtcVideoCapturer::Stop() { | 47 void RtcVideoCapturer::Stop() { |
| 48 DVLOG(3) << " RtcVideoCapturer::Stop "; | 48 DVLOG(3) << " RtcVideoCapturer::Stop "; |
| 49 if (state_ == video_capture::kStopped) { | 49 if (state_ == VIDEO_CAPTURE_STATE_STOPPED) { |
| 50 DVLOG(1) << "Got a StopCapture while not started."; | 50 DVLOG(1) << "Got a StopCapture while not started."; |
| 51 return; | 51 return; |
| 52 } | 52 } |
| 53 state_ = video_capture::kStopped; | 53 state_ = VIDEO_CAPTURE_STATE_STOPPED; |
| 54 delegate_->StopCapture(); | 54 delegate_->StopCapture(); |
| 55 SignalStateChange(this, cricket::CS_STOPPED); | 55 SignalStateChange(this, cricket::CS_STOPPED); |
| 56 } | 56 } |
| 57 | 57 |
| 58 bool RtcVideoCapturer::IsRunning() { | 58 bool RtcVideoCapturer::IsRunning() { |
| 59 return state_ == video_capture::kStarted; | 59 return state_ == VIDEO_CAPTURE_STATE_STARTED; |
| 60 } | 60 } |
| 61 | 61 |
| 62 bool RtcVideoCapturer::GetPreferredFourccs(std::vector<uint32>* fourccs) { | 62 bool RtcVideoCapturer::GetPreferredFourccs(std::vector<uint32>* fourccs) { |
| 63 if (!fourccs) | 63 if (!fourccs) |
| 64 return false; | 64 return false; |
| 65 fourccs->push_back(cricket::FOURCC_I420); | 65 fourccs->push_back(cricket::FOURCC_I420); |
| 66 return true; | 66 return true; |
| 67 } | 67 } |
| 68 | 68 |
| 69 bool RtcVideoCapturer::IsScreencast() { | 69 bool RtcVideoCapturer::IsScreencast() { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 converted_state = cricket::CS_FAILED; | 120 converted_state = cricket::CS_FAILED; |
| 121 break; | 121 break; |
| 122 default: | 122 default: |
| 123 NOTREACHED(); | 123 NOTREACHED(); |
| 124 break; | 124 break; |
| 125 } | 125 } |
| 126 SignalStateChange(this, converted_state); | 126 SignalStateChange(this, converted_state); |
| 127 } | 127 } |
| 128 | 128 |
| 129 } // namespace content | 129 } // namespace content |
| OLD | NEW |