Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "remoting/protocol/webrtc_video_capturer_adapter.h" | 5 #include "remoting/protocol/webrtc_video_capturer_adapter.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "third_party/libyuv/include/libyuv/convert.h" | 9 #include "third_party/libyuv/include/libyuv/convert.h" |
| 10 #include "third_party/webrtc/media/engine/webrtcvideoframe.h" | 10 #include "third_party/webrtc/media/engine/webrtcvideoframe.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 64 desktop_capturer_->Start(this); | 64 desktop_capturer_->Start(this); |
| 65 | 65 |
| 66 capture_timer_.reset(new base::RepeatingTimer()); | 66 capture_timer_.reset(new base::RepeatingTimer()); |
| 67 capture_timer_->Start(FROM_HERE, | 67 capture_timer_->Start(FROM_HERE, |
| 68 base::TimeDelta::FromSeconds(1) / kFramesPerSec, this, | 68 base::TimeDelta::FromSeconds(1) / kFramesPerSec, this, |
| 69 &WebrtcVideoCapturerAdapter::CaptureNextFrame); | 69 &WebrtcVideoCapturerAdapter::CaptureNextFrame); |
| 70 | 70 |
| 71 return cricket::CS_RUNNING; | 71 return cricket::CS_RUNNING; |
| 72 } | 72 } |
| 73 | 73 |
| 74 // Similar to the base class implementation with some important differences: | 74 // Similar to the base class implementation with some important differences: |
|
Sergey Ulanov
2016/03/23 18:08:03
remove this comment please.
perkj_chrome
2016/03/23 20:11:45
Done.
| |
| 75 // 1. Does not call either Stop() or Start(), as those would affect the state of | 75 // 1. Does not call either Stop() or Start(), as those would affect the state of |
| 76 // |desktop_capturer_|. | 76 // |desktop_capturer_|. |
| 77 // 2. Does not support unpausing after stopping the capturer. It is unclear | 77 // 2. Does not support unpausing after stopping the capturer. It is unclear |
| 78 // if that flow needs to be supported. | 78 // if that flow needs to be supported. |
| 79 bool WebrtcVideoCapturerAdapter::Pause(bool pause) { | 79 bool WebrtcVideoCapturerAdapter::PauseCapturer(bool pause) { |
| 80 DCHECK(thread_checker_.CalledOnValidThread()); | 80 DCHECK(thread_checker_.CalledOnValidThread()); |
| 81 | 81 |
| 82 if (pause) { | 82 if (pause) { |
| 83 if (capture_state() == cricket::CS_PAUSED) | 83 if (capture_state() == cricket::CS_PAUSED) |
|
Sergey Ulanov
2016/03/23 18:08:03
do we still have capture_state() in CapturerAdapte
perkj_chrome
2016/03/23 20:11:45
I should remove PAUSED as well. Thanks for pointin
| |
| 84 return true; | 84 return true; |
| 85 | 85 |
| 86 bool running = capture_state() == cricket::CS_STARTING || | 86 bool running = capture_state() == cricket::CS_STARTING || |
| 87 capture_state() == cricket::CS_RUNNING; | 87 capture_state() == cricket::CS_RUNNING; |
| 88 | 88 |
| 89 DCHECK_EQ(running, IsRunning()); | 89 DCHECK_EQ(running, IsRunning()); |
| 90 | 90 |
| 91 if (!running) { | 91 if (!running) { |
| 92 LOG(ERROR) | 92 LOG(ERROR) |
| 93 << "Cannot pause WebrtcVideoCapturerAdapter."; | 93 << "Cannot pause WebrtcVideoCapturerAdapter."; |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 216 left * webrtc::DesktopFrame::kBytesPerPixel, | 216 left * webrtc::DesktopFrame::kBytesPerPixel, |
| 217 frame->stride(), | 217 frame->stride(), |
| 218 yuv_frame_->GetYPlane() + yuv_frame_->GetYPitch() * top + left, | 218 yuv_frame_->GetYPlane() + yuv_frame_->GetYPitch() * top + left, |
| 219 yuv_frame_->GetYPitch(), | 219 yuv_frame_->GetYPitch(), |
| 220 yuv_frame_->GetUPlane() + yuv_frame_->GetUPitch() * top / 2 + left / 2, | 220 yuv_frame_->GetUPlane() + yuv_frame_->GetUPitch() * top / 2 + left / 2, |
| 221 yuv_frame_->GetUPitch(), | 221 yuv_frame_->GetUPitch(), |
| 222 yuv_frame_->GetVPlane() + yuv_frame_->GetVPitch() * top / 2 + left / 2, | 222 yuv_frame_->GetVPlane() + yuv_frame_->GetVPitch() * top / 2 + left / 2, |
| 223 yuv_frame_->GetVPitch(), width, height); | 223 yuv_frame_->GetVPitch(), width, height); |
| 224 } | 224 } |
| 225 | 225 |
| 226 SignalVideoFrame(this, yuv_frame_.get()); | 226 OnFrame(this, yuv_frame_.get()); |
| 227 } | 227 } |
| 228 | 228 |
| 229 void WebrtcVideoCapturerAdapter::CaptureNextFrame() { | 229 void WebrtcVideoCapturerAdapter::CaptureNextFrame() { |
| 230 DCHECK(thread_checker_.CalledOnValidThread()); | 230 DCHECK(thread_checker_.CalledOnValidThread()); |
| 231 | 231 |
| 232 if (capture_pending_) | 232 if (capture_pending_) |
| 233 return; | 233 return; |
| 234 capture_pending_ = true; | 234 capture_pending_ = true; |
| 235 desktop_capturer_->Capture(webrtc::DesktopRegion()); | 235 desktop_capturer_->Capture(webrtc::DesktopRegion()); |
| 236 } | 236 } |
| 237 | 237 |
| 238 } // namespace protocol | 238 } // namespace protocol |
| 239 } // namespace remoting | 239 } // namespace remoting |
| OLD | NEW |