Remove dependency on content from remoting_host.
[chromium-blink-merge.git] / remoting / host / shaped_desktop_capturer.cc
blob8cfbcbcf7bc87baf8b387a6989567b6606ddd29f
1 // Copyright 2014 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/shaped_desktop_capturer.h"
7 #include "base/logging.h"
8 #include "remoting/host/desktop_shape_tracker.h"
9 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h"
11 namespace remoting {
13 ShapedDesktopCapturer::ShapedDesktopCapturer(
14 scoped_ptr<webrtc::DesktopCapturer> desktop_capturer,
15 scoped_ptr<DesktopShapeTracker> shape_tracker)
16 : desktop_capturer_(desktop_capturer.Pass()),
17 shape_tracker_(shape_tracker.Pass()),
18 callback_(nullptr) {
21 ShapedDesktopCapturer::~ShapedDesktopCapturer() {}
23 void ShapedDesktopCapturer::Start(webrtc::DesktopCapturer::Callback* callback) {
24 callback_ = callback;
25 desktop_capturer_->Start(this);
28 void ShapedDesktopCapturer::Capture(const webrtc::DesktopRegion& region) {
29 desktop_capturer_->Capture(region);
32 webrtc::SharedMemory* ShapedDesktopCapturer::CreateSharedMemory(size_t size) {
33 return callback_->CreateSharedMemory(size);
36 void ShapedDesktopCapturer::OnCaptureCompleted(webrtc::DesktopFrame* frame) {
37 shape_tracker_->RefreshDesktopShape();
38 frame->set_shape(new webrtc::DesktopRegion(shape_tracker_->desktop_shape()));
39 callback_->OnCaptureCompleted(frame);
42 } // namespace remoting