Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(719)

Side by Side Diff: remoting/protocol/webrtc_video_capturer_adapter.cc

Issue 1571543002: Implement missing features in WebrtcVideoStream. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/libjingle/source/talk/media/webrtc/webrtcvideoframe.h" 9 #include "third_party/libjingle/source/talk/media/webrtc/webrtcvideoframe.h"
10 #include "third_party/libyuv/include/libyuv/convert.h" 10 #include "third_party/libyuv/include/libyuv/convert.h"
(...skipping 11 matching lines...) Expand all
22 DCHECK(desktop_capturer_); 22 DCHECK(desktop_capturer_);
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(
33 const SizeCallback& size_callback) {
34 DCHECK(thread_checker_.CalledOnValidThread());
35 size_callback_ = size_callback;
36 }
37
32 bool WebrtcVideoCapturerAdapter::GetBestCaptureFormat( 38 bool WebrtcVideoCapturerAdapter::GetBestCaptureFormat(
33 const cricket::VideoFormat& desired, 39 const cricket::VideoFormat& desired,
34 cricket::VideoFormat* best_format) { 40 cricket::VideoFormat* best_format) {
35 DCHECK(thread_checker_.CalledOnValidThread()); 41 DCHECK(thread_checker_.CalledOnValidThread());
36 42
37 // The |capture_format| passed to Start() is always ignored, so copy 43 // The |capture_format| passed to Start() is always ignored, so copy
38 // |best_format| to |desired_format|. 44 // |best_format| to |desired_format|.
39 *best_format = desired; 45 *best_format = desired;
40 return true; 46 return true;
41 } 47 }
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 scoped_ptr<webrtc::DesktopFrame> owned_frame(frame); 159 scoped_ptr<webrtc::DesktopFrame> owned_frame(frame);
154 160
155 // Drop the frame if there were no changes. 161 // Drop the frame if there were no changes.
156 if (!owned_frame || owned_frame->updated_region().is_empty()) 162 if (!owned_frame || owned_frame->updated_region().is_empty())
157 return; 163 return;
158 164
159 size_t width = frame->size().width(); 165 size_t width = frame->size().width();
160 size_t height = frame->size().height(); 166 size_t height = frame->size().height();
161 if (!yuv_frame_ || yuv_frame_->GetWidth() != width || 167 if (!yuv_frame_ || yuv_frame_->GetWidth() != width ||
162 yuv_frame_->GetHeight() != height) { 168 yuv_frame_->GetHeight() != height) {
169 if (!size_callback_.is_null())
170 size_callback_.Run(frame->size());
171
163 scoped_ptr<cricket::WebRtcVideoFrame> webrtc_frame( 172 scoped_ptr<cricket::WebRtcVideoFrame> webrtc_frame(
164 new cricket::WebRtcVideoFrame()); 173 new cricket::WebRtcVideoFrame());
165 webrtc_frame->InitToEmptyBuffer(width, height, 1, 1, 0); 174 webrtc_frame->InitToEmptyBuffer(width, height, 1, 1, 0);
166 yuv_frame_ = std::move(webrtc_frame); 175 yuv_frame_ = std::move(webrtc_frame);
167 176
168 // Set updated_region so the whole frame is converted to YUV below. 177 // Set updated_region so the whole frame is converted to YUV below.
169 frame->mutable_updated_region()->SetRect( 178 frame->mutable_updated_region()->SetRect(
170 webrtc::DesktopRect::MakeWH(width, height)); 179 webrtc::DesktopRect::MakeWH(width, height));
171 } 180 }
172 181
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 DCHECK(thread_checker_.CalledOnValidThread()); 222 DCHECK(thread_checker_.CalledOnValidThread());
214 223
215 if (capture_pending_) 224 if (capture_pending_)
216 return; 225 return;
217 capture_pending_ = true; 226 capture_pending_ = true;
218 desktop_capturer_->Capture(webrtc::DesktopRegion()); 227 desktop_capturer_->Capture(webrtc::DesktopRegion());
219 } 228 }
220 229
221 } // namespace protocol 230 } // namespace protocol
222 } // namespace remoting 231 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698