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 // FrameConsumerProxy is used to allow a FrameConsumer on the UI thread to be
6 // invoked by a Decoder on the decoder thread. The Detach() method is used by
7 // the proxy's owner before tearing down the FrameConsumer, to prevent any
8 // further invokations reaching it.
10 #ifndef REMOTING_CLIENT_FRAME_CONSUMER_PROXY_H_
11 #define REMOTING_CLIENT_FRAME_CONSUMER_PROXY_H_
13 #include "base/memory/ref_counted.h"
14 #include "base/memory/weak_ptr.h"
15 #include "remoting/client/frame_consumer.h"
18 class SingleThreadTaskRunner
;
23 class FrameConsumerProxy
24 : public base::RefCountedThreadSafe
<FrameConsumerProxy
>,
25 public FrameConsumer
{
27 // Constructs a proxy for |frame_consumer| which will trampoline invocations
28 // to |frame_consumer_message_loop|.
29 FrameConsumerProxy(scoped_refptr
<base::SingleThreadTaskRunner
> task_runner
,
30 const base::WeakPtr
<FrameConsumer
>& frame_consumer
);
32 // FrameConsumer implementation.
33 virtual void ApplyBuffer(const webrtc::DesktopSize
& view_size
,
34 const webrtc::DesktopRect
& clip_area
,
35 webrtc::DesktopFrame
* buffer
,
36 const webrtc::DesktopRegion
& region
,
37 const webrtc::DesktopRegion
& shape
) OVERRIDE
;
38 virtual void ReturnBuffer(webrtc::DesktopFrame
* buffer
) OVERRIDE
;
39 virtual void SetSourceSize(const webrtc::DesktopSize
& source_size
,
40 const webrtc::DesktopVector
& dpi
) OVERRIDE
;
41 virtual PixelFormat
GetPixelFormat() OVERRIDE
;
44 friend class base::RefCountedThreadSafe
<FrameConsumerProxy
>;
45 virtual ~FrameConsumerProxy();
47 base::WeakPtr
<FrameConsumer
> frame_consumer_
;
48 scoped_refptr
<base::SingleThreadTaskRunner
> task_runner_
;
50 PixelFormat pixel_format_
;
52 DISALLOW_COPY_AND_ASSIGN(FrameConsumerProxy
);
55 } // namespace remoting
57 #endif // REMOTING_CLIENT_FRAME_CONSUMER_PROXY_H_