1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "remoting/client/frame_consumer_proxy.h"
#include "base/bind.h"
#include "base/location.h"
#include "base/single_thread_task_runner.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_frame.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_region.h"
namespace remoting {
FrameConsumerProxy::FrameConsumerProxy(
scoped_refptr<base::SingleThreadTaskRunner> task_runner)
: task_runner_(task_runner) {
}
void FrameConsumerProxy::ApplyBuffer(const webrtc::DesktopSize& view_size,
const webrtc::DesktopRect& clip_area,
webrtc::DesktopFrame* buffer,
const webrtc::DesktopRegion& region) {
if (!task_runner_->BelongsToCurrentThread()) {
task_runner_->PostTask(FROM_HERE, base::Bind(
&FrameConsumerProxy::ApplyBuffer, this,
view_size, clip_area, buffer, region));
return;
}
if (frame_consumer_.get())
frame_consumer_->ApplyBuffer(view_size, clip_area, buffer, region);
}
void FrameConsumerProxy::ReturnBuffer(webrtc::DesktopFrame* buffer) {
if (!task_runner_->BelongsToCurrentThread()) {
task_runner_->PostTask(FROM_HERE, base::Bind(
&FrameConsumerProxy::ReturnBuffer, this, buffer));
return;
}
if (frame_consumer_.get())
frame_consumer_->ReturnBuffer(buffer);
}
void FrameConsumerProxy::SetSourceSize(
const webrtc::DesktopSize& source_size,
const webrtc::DesktopVector& source_dpi) {
if (!task_runner_->BelongsToCurrentThread()) {
task_runner_->PostTask(FROM_HERE, base::Bind(
&FrameConsumerProxy::SetSourceSize, this, source_size, source_dpi));
return;
}
if (frame_consumer_.get())
frame_consumer_->SetSourceSize(source_size, source_dpi);
}
void FrameConsumerProxy::Attach(
const base::WeakPtr<FrameConsumer>& frame_consumer) {
DCHECK(task_runner_->BelongsToCurrentThread());
DCHECK(frame_consumer_.get() == NULL);
frame_consumer_ = frame_consumer;
}
FrameConsumerProxy::~FrameConsumerProxy() {
}
} // namespace remoting
|