Index: remoting/protocol/webrtc_video_capturer_adapter.cc |
diff --git a/remoting/protocol/webrtc_video_capturer_adapter.cc b/remoting/protocol/webrtc_video_capturer_adapter.cc |
index fcf7972ca44e40dc828080a2a69146866156b2bb..5f735c379d78c95fab7096dca8137e92fc3f10b4 100644 |
--- a/remoting/protocol/webrtc_video_capturer_adapter.cc |
+++ b/remoting/protocol/webrtc_video_capturer_adapter.cc |
@@ -18,7 +18,7 @@ const int kFramesPerSec = 30; |
WebrtcVideoCapturerAdapter::WebrtcVideoCapturerAdapter( |
scoped_ptr<webrtc::DesktopCapturer> capturer) |
- : desktop_capturer_(std::move(capturer)) { |
+ : desktop_capturer_(std::move(capturer)), weak_factory_(this) { |
DCHECK(desktop_capturer_); |
// Disable video adaptation since we don't intend to use it. |
@@ -29,6 +29,17 @@ WebrtcVideoCapturerAdapter::~WebrtcVideoCapturerAdapter() { |
DCHECK(!capture_timer_); |
} |
+void WebrtcVideoCapturerAdapter::SetSizeCallback( |
+ const SizeCallback& size_callback) { |
+ DCHECK(thread_checker_.CalledOnValidThread()); |
+ size_callback_ = size_callback; |
+} |
+ |
+base::WeakPtr<WebrtcVideoCapturerAdapter> |
+WebrtcVideoCapturerAdapter::GetWeakPtr() { |
+ return weak_factory_.GetWeakPtr(); |
+} |
+ |
bool WebrtcVideoCapturerAdapter::GetBestCaptureFormat( |
const cricket::VideoFormat& desired, |
cricket::VideoFormat* best_format) { |
@@ -160,6 +171,9 @@ void WebrtcVideoCapturerAdapter::OnCaptureCompleted( |
size_t height = frame->size().height(); |
if (!yuv_frame_ || yuv_frame_->GetWidth() != width || |
yuv_frame_->GetHeight() != height) { |
+ if (!size_callback_.is_null()) |
+ size_callback_.Run(frame->size()); |
+ |
scoped_ptr<cricket::WebRtcVideoFrame> webrtc_frame( |
new cricket::WebRtcVideoFrame()); |
webrtc_frame->InitToEmptyBuffer(width, height, 1, 1, 0); |