OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #ifndef REMOTING_IOS_BRIDGE_FRAME_CONSUMER_BRIDGE_H_ | |
6 #define REMOTING_IOS_BRIDGE_FRAME_CONSUMER_BRIDGE_H_ | |
7 | |
8 #include <list> | |
9 | |
10 #include "base/callback.h" | |
11 #include "base/compiler_specific.h" | |
12 #include "base/memory/scoped_vector.h" | |
13 #include "base/memory/weak_ptr.h" | |
14 #include "remoting/client/frame_consumer.h" | |
15 #include "remoting/client/frame_producer.h" | |
16 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" | |
17 | |
18 namespace remoting { | |
19 | |
20 class FrameConsumerBridge : public base::SupportsWeakPtr<FrameConsumerBridge>, | |
21 public FrameConsumer { | |
22 public: | |
23 typedef base::Callback<void(const webrtc::DesktopSize& view_size, | |
24 webrtc::DesktopFrame* buffer, | |
25 const webrtc::DesktopRegion& region)> | |
26 OnFrameCallback; | |
27 | |
28 // A callback is provided to return frame updates asynchronously. | |
29 explicit FrameConsumerBridge(OnFrameCallback callback); | |
30 | |
31 virtual ~FrameConsumerBridge(); | |
32 // This must be called before any other functional use. | |
33 void Initialize(FrameProducer* producer); | |
34 | |
35 // FrameConsumer implementation. | |
36 virtual void ApplyBuffer(const webrtc::DesktopSize& view_size, | |
37 const webrtc::DesktopRect& clip_area, | |
38 webrtc::DesktopFrame* buffer, | |
39 const webrtc::DesktopRegion& region, | |
40 const webrtc::DesktopRegion& shape) OVERRIDE; | |
41 virtual void ReturnBuffer(webrtc::DesktopFrame* buffer) OVERRIDE; | |
42 virtual void SetSourceSize(const webrtc::DesktopSize& source_size, | |
43 const webrtc::DesktopVector& dpi) OVERRIDE; | |
44 virtual PixelFormat GetPixelFormat() OVERRIDE; | |
45 | |
46 private: | |
47 // Allocates a new buffer of |view_size_|, and tells the producer to draw onto | |
48 // it. This can be called as soon as the producer is known, but is not | |
49 // required until ready to receive frames. | |
50 void DrawWithNewBuffer(); | |
51 | |
52 OnFrameCallback callback_; | |
53 | |
54 FrameProducer* frame_producer_; | |
55 webrtc::DesktopSize view_size_; | |
56 | |
57 // List of allocated image buffers. | |
58 ScopedVector<webrtc::DesktopFrame> buffers_; | |
59 | |
60 DISALLOW_COPY_AND_ASSIGN(FrameConsumerBridge); | |
61 }; | |
62 | |
63 } // namespace remoting | |
64 | |
65 #endif // REMOTING_IOS_BRIDGE_FRAME_CONSUMER_BRIDGE_H_ | |
OLD | NEW |