forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathframe_consumer_proxy.cc
69 lines (56 loc) · 2.13 KB
/
frame_consumer_proxy.cc
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
// 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/message_loop.h"
namespace remoting {
FrameConsumerProxy::FrameConsumerProxy(
FrameConsumer* frame_consumer,
base::MessageLoopProxy* frame_consumer_message_loop)
: frame_consumer_(frame_consumer),
frame_consumer_message_loop_(frame_consumer_message_loop) {
}
FrameConsumerProxy::~FrameConsumerProxy() {
}
void FrameConsumerProxy::AllocateFrame(
media::VideoFrame::Format format,
const SkISize& size,
scoped_refptr<media::VideoFrame>* frame_out,
const base::Closure& done) {
if (!frame_consumer_message_loop_->BelongsToCurrentThread()) {
frame_consumer_message_loop_->PostTask(FROM_HERE, base::Bind(
&FrameConsumerProxy::AllocateFrame, this, format, size, frame_out,
done));
return;
}
if (frame_consumer_) {
frame_consumer_->AllocateFrame(format, size, frame_out, done);
}
}
void FrameConsumerProxy::ReleaseFrame(media::VideoFrame* frame) {
if (!frame_consumer_message_loop_->BelongsToCurrentThread()) {
frame_consumer_message_loop_->PostTask(FROM_HERE, base::Bind(
&FrameConsumerProxy::ReleaseFrame, this, make_scoped_refptr(frame)));
return;
}
if (frame_consumer_)
frame_consumer_->ReleaseFrame(frame);
}
void FrameConsumerProxy::OnPartialFrameOutput(media::VideoFrame* frame,
SkRegion* region,
const base::Closure& done) {
if (!frame_consumer_message_loop_->BelongsToCurrentThread()) {
frame_consumer_message_loop_->PostTask(FROM_HERE, base::Bind(
&FrameConsumerProxy::OnPartialFrameOutput, this,
make_scoped_refptr(frame), region, done));
return;
}
if (frame_consumer_)
frame_consumer_->OnPartialFrameOutput(frame, region, done);
}
void FrameConsumerProxy::Detach() {
DCHECK(frame_consumer_message_loop_->BelongsToCurrentThread());
frame_consumer_ = NULL;
}
} // namespace remoting