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

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: Change last_desktop_size_ only when it is changed. 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 }
Sergey Ulanov 2016/07/20 18:39:26 // namespace webrtc
Yuwei 2016/07/21 00:07:32 Done.
20
21 namespace remoting {
22
23 // This class uses dual BasicDesktopFrame buffer to decode all video frames
24 // using the underlying video renderer.
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 it will be run on the thread of |task_runner|.
28 class DualBufferFrameConsumer : public protocol::FrameConsumer {
29 public:
30 DualBufferFrameConsumer(
31 base::Callback<void(std::unique_ptr<webrtc::DesktopFrame>)> callback,
32 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
33 PixelFormat format);
34 ~DualBufferFrameConsumer() override;
35
36 // Feeds the callback on the right thread with a BasicDesktopFrame containing
37 // updates from |buffer_0_| and |buffer_1_|. Do nothing if no updates have
38 // received yet.
39 void RequestFullDesktopFrame();
40
41 // FrameConsumer interface.
42 std::unique_ptr<webrtc::DesktopFrame> AllocateFrame(
43 const webrtc::DesktopSize& size) override;
44 void DrawFrame(std::unique_ptr<webrtc::DesktopFrame> frame,
45 const base::Closure& done) override;
46 PixelFormat GetPixelFormat() override;
47
48 base::WeakPtr<DualBufferFrameConsumer> GetWeakPtr();
49
50 private:
51 void RunRenderCallback(std::unique_ptr<webrtc::DesktopFrame> frame,
52 const base::Closure& done);
53 void OnFrameRendered(const base::Closure& done);
54
55 std::unique_ptr<webrtc::SharedDesktopFrame> buffer_0_;
56 std::unique_ptr<webrtc::SharedDesktopFrame> buffer_1_;
57 webrtc::DesktopRegion buffer_1_mask_;
58 int next_buffer_ = 0;
59
60 base::Callback<void(std::unique_ptr<webrtc::DesktopFrame>)> callback_;
61 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
62 PixelFormat pixel_format_;
63 base::ThreadChecker thread_checker_;
64 base::WeakPtr<DualBufferFrameConsumer> weak_ptr_;
65 base::WeakPtrFactory<DualBufferFrameConsumer> weak_factory_;
66
67 DISALLOW_COPY_AND_ASSIGN(DualBufferFrameConsumer);
68 };
69
70 } // namespace remoting
71 #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