| 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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 return nullptr; | 154 return nullptr; |
| 155 } | 155 } |
| 156 | 156 |
| 157 void WebrtcVideoCapturerAdapter::OnCaptureCompleted( | 157 void WebrtcVideoCapturerAdapter::OnCaptureCompleted( |
| 158 webrtc::DesktopFrame* frame) { | 158 webrtc::DesktopFrame* frame) { |
| 159 DCHECK(thread_checker_.CalledOnValidThread()); | 159 DCHECK(thread_checker_.CalledOnValidThread()); |
| 160 | 160 |
| 161 DCHECK(capture_pending_); | 161 DCHECK(capture_pending_); |
| 162 capture_pending_ = false; | 162 capture_pending_ = false; |
| 163 | 163 |
| 164 if (!frame) |
| 165 return; |
| 166 |
| 164 scoped_ptr<webrtc::DesktopFrame> owned_frame(frame); | 167 scoped_ptr<webrtc::DesktopFrame> owned_frame(frame); |
| 165 | 168 |
| 166 // Drop the frame if there were no changes. | 169 // TODO(sergeyu): Currently the adapter keeps generating frames even when |
| 167 if (!owned_frame || owned_frame->updated_region().is_empty()) | 170 // nothing is changing on the screen. This is necessary because the video |
| 168 return; | 171 // sender drops frames. Obviously this is a suboptimal. The sending code in |
| 172 // WebRTC needs to have some mechanism to notify when the bandwidth is |
| 173 // exceeded, so the capturer can adapt frame rate. |
| 169 | 174 |
| 170 size_t width = frame->size().width(); | 175 size_t width = frame->size().width(); |
| 171 size_t height = frame->size().height(); | 176 size_t height = frame->size().height(); |
| 172 if (!yuv_frame_ || yuv_frame_->GetWidth() != width || | 177 if (!yuv_frame_ || yuv_frame_->GetWidth() != width || |
| 173 yuv_frame_->GetHeight() != height) { | 178 yuv_frame_->GetHeight() != height) { |
| 174 if (!size_callback_.is_null()) | 179 if (!size_callback_.is_null()) |
| 175 size_callback_.Run(frame->size()); | 180 size_callback_.Run(frame->size()); |
| 176 | 181 |
| 177 scoped_ptr<cricket::WebRtcVideoFrame> webrtc_frame( | 182 scoped_ptr<cricket::WebRtcVideoFrame> webrtc_frame( |
| 178 new cricket::WebRtcVideoFrame()); | 183 new cricket::WebRtcVideoFrame()); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 DCHECK(thread_checker_.CalledOnValidThread()); | 230 DCHECK(thread_checker_.CalledOnValidThread()); |
| 226 | 231 |
| 227 if (capture_pending_) | 232 if (capture_pending_) |
| 228 return; | 233 return; |
| 229 capture_pending_ = true; | 234 capture_pending_ = true; |
| 230 desktop_capturer_->Capture(webrtc::DesktopRegion()); | 235 desktop_capturer_->Capture(webrtc::DesktopRegion()); |
| 231 } | 236 } |
| 232 | 237 |
| 233 } // namespace protocol | 238 } // namespace protocol |
| 234 } // namespace remoting | 239 } // namespace remoting |
| OLD | NEW |