Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(195)

Side by Side Diff: remoting/client/dual_buffer_frame_consumer.h

Issue 2156713002: [Chromoting] Implement DualBufferFrameConsumer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove deprecated SoftwareVideoRenderer ctor Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 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_CLIENT_DUAL_BUFFER_FRAME_CONSUMER_H_
6 #define REMOTING_CLIENT_DUAL_BUFFER_FRAME_CONSUMER_H_
7
8 #include "base/callback.h"
9 #include "base/macros.h"
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/weak_ptr.h"
12 #include "base/single_thread_task_runner.h"
13 #include "base/threading/thread_checker.h"
14 #include "remoting/protocol/frame_consumer.h"
15 #include "third_party/webrtc/modules/desktop_capture/desktop_region.h"
16
17 namespace webrtc {
18 class SharedDesktopFrame;
19 } // namespace webrtc
20
21 namespace remoting {
22
23 // This class continuously uses two BasicDesktopFrame as buffer for decoding
24 // updated regions until the resolution is changed.
25 // This class should be used and destroyed on the same thread. If |task_runner|
26 // is null |callback| will be run directly upon the stack of DrawFrame,
27 // otherwise a task will be posted to feed the callback on the thread of
28 // |task_runner|.
29 // Only areas bound by updated_region() on the buffer are considered valid to
30 // |callback|. Please use RequestFullDesktopFrame() if you want to get a full
31 // desktop frame.
32 class DualBufferFrameConsumer : public protocol::FrameConsumer {
33 public:
34 DualBufferFrameConsumer(
35 base::Callback<void(std::unique_ptr<webrtc::DesktopFrame>)> callback,
36 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
37 PixelFormat format);
38 ~DualBufferFrameConsumer() override;
39
40 // Feeds the callback on the right thread with a BasicDesktopFrame that merges
41 // updates from buffer_[0] and buffer_[1]. Do nothing if no updates have
42 // received yet.
43 void RequestFullDesktopFrame();
44
45 // FrameConsumer interface.
46 std::unique_ptr<webrtc::DesktopFrame> AllocateFrame(
47 const webrtc::DesktopSize& size) override;
48 void DrawFrame(std::unique_ptr<webrtc::DesktopFrame> frame,
49 const base::Closure& done) override;
50 PixelFormat GetPixelFormat() override;
51
52 base::WeakPtr<DualBufferFrameConsumer> GetWeakPtr();
53
54 private:
55 void RunRenderCallback(std::unique_ptr<webrtc::DesktopFrame> frame,
56 const base::Closure& done);
57 void OnFrameRendered(const base::Closure& done);
58
59 std::unique_ptr<webrtc::SharedDesktopFrame> buffers_[2];
60 webrtc::DesktopRegion buffer_1_mask_;
Yuwei 2016/07/21 19:00:32 I'll add some comment here.
Yuwei 2016/07/22 03:38:22 Done.
61 int current_buffer_ = 0;
62
63 base::Callback<void(std::unique_ptr<webrtc::DesktopFrame>)> callback_;
64 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
65 PixelFormat pixel_format_;
66 base::ThreadChecker thread_checker_;
67 base::WeakPtr<DualBufferFrameConsumer> weak_ptr_;
68 base::WeakPtrFactory<DualBufferFrameConsumer> weak_factory_;
69
70 DISALLOW_COPY_AND_ASSIGN(DualBufferFrameConsumer);
71 };
72
73 } // namespace remoting
74 #endif // REMOTING_CLIENT_DUAL_BUFFER_FRAME_CONSUMER_H_
OLDNEW
« no previous file with comments | « no previous file | remoting/client/dual_buffer_frame_consumer.cc » ('j') | remoting/client/dual_buffer_frame_consumer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698