| 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 12 matching lines...) Expand all  Loading... | 
| 23 | 23 | 
| 24   // Disable video adaptation since we don't intend to use it. | 24   // Disable video adaptation since we don't intend to use it. | 
| 25   set_enable_video_adapter(false); | 25   set_enable_video_adapter(false); | 
| 26 } | 26 } | 
| 27 | 27 | 
| 28 WebrtcVideoCapturerAdapter::~WebrtcVideoCapturerAdapter() { | 28 WebrtcVideoCapturerAdapter::~WebrtcVideoCapturerAdapter() { | 
| 29   DCHECK(!capture_timer_); | 29   DCHECK(!capture_timer_); | 
| 30 } | 30 } | 
| 31 | 31 | 
| 32 void WebrtcVideoCapturerAdapter::SetSizeCallback( | 32 void WebrtcVideoCapturerAdapter::SetSizeCallback( | 
| 33     const SizeCallback& size_callback) { | 33     const VideoStream::SizeCallback& size_callback) { | 
| 34   DCHECK(thread_checker_.CalledOnValidThread()); | 34   DCHECK(thread_checker_.CalledOnValidThread()); | 
| 35   size_callback_ = size_callback; | 35   size_callback_ = size_callback; | 
| 36 } | 36 } | 
| 37 | 37 | 
| 38 base::WeakPtr<WebrtcVideoCapturerAdapter> | 38 base::WeakPtr<WebrtcVideoCapturerAdapter> | 
| 39 WebrtcVideoCapturerAdapter::GetWeakPtr() { | 39 WebrtcVideoCapturerAdapter::GetWeakPtr() { | 
| 40   return weak_factory_.GetWeakPtr(); | 40   return weak_factory_.GetWeakPtr(); | 
| 41 } | 41 } | 
| 42 | 42 | 
| 43 bool WebrtcVideoCapturerAdapter::GetBestCaptureFormat( | 43 bool WebrtcVideoCapturerAdapter::GetBestCaptureFormat( | 
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 162   // nothing is changing on the screen. This is necessary because the video | 162   // nothing is changing on the screen. This is necessary because the video | 
| 163   // sender drops frames. Obviously this is a suboptimal. The sending code in | 163   // sender drops frames. Obviously this is a suboptimal. The sending code in | 
| 164   // WebRTC needs to have some mechanism to notify when the bandwidth is | 164   // WebRTC needs to have some mechanism to notify when the bandwidth is | 
| 165   // exceeded, so the capturer can adapt frame rate. | 165   // exceeded, so the capturer can adapt frame rate. | 
| 166 | 166 | 
| 167   size_t width = frame->size().width(); | 167   size_t width = frame->size().width(); | 
| 168   size_t height = frame->size().height(); | 168   size_t height = frame->size().height(); | 
| 169   if (!yuv_frame_ || yuv_frame_->GetWidth() != width || | 169   if (!yuv_frame_ || yuv_frame_->GetWidth() != width || | 
| 170       yuv_frame_->GetHeight() != height) { | 170       yuv_frame_->GetHeight() != height) { | 
| 171     if (!size_callback_.is_null()) | 171     if (!size_callback_.is_null()) | 
| 172       size_callback_.Run(frame->size()); | 172       size_callback_.Run(frame->size(), frame->dpi()); | 
| 173 | 173 | 
| 174     scoped_ptr<cricket::WebRtcVideoFrame> webrtc_frame( | 174     scoped_ptr<cricket::WebRtcVideoFrame> webrtc_frame( | 
| 175         new cricket::WebRtcVideoFrame()); | 175         new cricket::WebRtcVideoFrame()); | 
| 176     webrtc_frame->InitToEmptyBuffer(width, height, 0); | 176     webrtc_frame->InitToEmptyBuffer(width, height, 0); | 
| 177     yuv_frame_ = std::move(webrtc_frame); | 177     yuv_frame_ = std::move(webrtc_frame); | 
| 178 | 178 | 
| 179     // Set updated_region so the whole frame is converted to YUV below. | 179     // Set updated_region so the whole frame is converted to YUV below. | 
| 180     frame->mutable_updated_region()->SetRect( | 180     frame->mutable_updated_region()->SetRect( | 
| 181         webrtc::DesktopRect::MakeWH(width, height)); | 181         webrtc::DesktopRect::MakeWH(width, height)); | 
| 182   } | 182   } | 
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 222   DCHECK(thread_checker_.CalledOnValidThread()); | 222   DCHECK(thread_checker_.CalledOnValidThread()); | 
| 223 | 223 | 
| 224   if (capture_pending_) | 224   if (capture_pending_) | 
| 225     return; | 225     return; | 
| 226   capture_pending_ = true; | 226   capture_pending_ = true; | 
| 227   desktop_capturer_->Capture(webrtc::DesktopRegion()); | 227   desktop_capturer_->Capture(webrtc::DesktopRegion()); | 
| 228 } | 228 } | 
| 229 | 229 | 
| 230 }  // namespace protocol | 230 }  // namespace protocol | 
| 231 }  // namespace remoting | 231 }  // namespace remoting | 
| OLD | NEW | 
|---|