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/client/frame_consumer_proxy.h"
8 #include "base/location.h"
9 #include "base/single_thread_task_runner.h"
10 #include "base/thread_task_runner_handle.h"
11 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h"
12 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h"
13 #include "third_party/webrtc/modules/desktop_capture/desktop_region.h"
17 FrameConsumerProxy::FrameConsumerProxy(
18 const base::WeakPtr
<FrameConsumer
>& frame_consumer
)
19 : frame_consumer_(frame_consumer
),
20 task_runner_(base::ThreadTaskRunnerHandle::Get()) {
21 pixel_format_
= frame_consumer_
->GetPixelFormat();
24 static void DoApplyBuffer(base::WeakPtr
<FrameConsumer
> frame_consumer
,
25 const webrtc::DesktopSize
& view_size
,
26 const webrtc::DesktopRect
& clip_area
,
27 webrtc::DesktopFrame
* buffer
,
28 const webrtc::DesktopRegion
& region
,
29 scoped_ptr
<webrtc::DesktopRegion
> shape
) {
33 frame_consumer
->ApplyBuffer(view_size
, clip_area
, buffer
, region
,
37 void FrameConsumerProxy::ApplyBuffer(const webrtc::DesktopSize
& view_size
,
38 const webrtc::DesktopRect
& clip_area
,
39 webrtc::DesktopFrame
* buffer
,
40 const webrtc::DesktopRegion
& region
,
41 const webrtc::DesktopRegion
* shape
) {
42 scoped_ptr
<webrtc::DesktopRegion
> shape_ptr
;
44 shape_ptr
= make_scoped_ptr(new webrtc::DesktopRegion(*shape
));
45 task_runner_
->PostTask(
47 base::Bind(DoApplyBuffer
, frame_consumer_
, view_size
, clip_area
, buffer
,
48 region
, base::Passed(&shape_ptr
)));
51 void FrameConsumerProxy::ReturnBuffer(webrtc::DesktopFrame
* buffer
) {
52 task_runner_
->PostTask(FROM_HERE
, base::Bind(&FrameConsumer::ReturnBuffer
,
53 frame_consumer_
, buffer
));
56 void FrameConsumerProxy::SetSourceSize(
57 const webrtc::DesktopSize
& source_size
,
58 const webrtc::DesktopVector
& source_dpi
) {
59 task_runner_
->PostTask(
60 FROM_HERE
, base::Bind(&FrameConsumer::SetSourceSize
, frame_consumer_
,
61 source_size
, source_dpi
));
64 FrameConsumer::PixelFormat
FrameConsumerProxy::GetPixelFormat() {
68 FrameConsumerProxy::~FrameConsumerProxy() {
71 } // namespace remoting