Inline NetLog IPv6 reachability events.
[chromium-blink-merge.git] / remoting / host / ipc_video_frame_capturer.cc
blobf022d8613aef175060b2c40942bd95dacfead7f6
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "remoting/host/ipc_video_frame_capturer.h"
7 #include "remoting/host/desktop_session_proxy.h"
8 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h"
10 namespace remoting {
12 IpcVideoFrameCapturer::IpcVideoFrameCapturer(
13 scoped_refptr<DesktopSessionProxy> desktop_session_proxy)
14 : callback_(nullptr),
15 desktop_session_proxy_(desktop_session_proxy),
16 capture_pending_(false),
17 weak_factory_(this) {
20 IpcVideoFrameCapturer::~IpcVideoFrameCapturer() {
23 void IpcVideoFrameCapturer::Start(Callback* callback) {
24 DCHECK(!callback_);
25 DCHECK(callback);
26 callback_ = callback;
27 desktop_session_proxy_->SetVideoCapturer(weak_factory_.GetWeakPtr());
30 void IpcVideoFrameCapturer::Capture(const webrtc::DesktopRegion& region) {
31 DCHECK(!capture_pending_);
32 capture_pending_ = true;
33 desktop_session_proxy_->CaptureFrame();
36 void IpcVideoFrameCapturer::OnCaptureCompleted(
37 scoped_ptr<webrtc::DesktopFrame> frame) {
38 DCHECK(capture_pending_);
39 capture_pending_ = false;
40 callback_->OnCaptureCompleted(frame.release());
43 } // namespace remoting