OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef REMOTING_CLIENT_SOFTWARE_VIDEO_RENDERER_H_ | 5 #ifndef REMOTING_CLIENT_SOFTWARE_VIDEO_RENDERER_H_ |
6 #define REMOTING_CLIENT_SOFTWARE_VIDEO_RENDERER_H_ | 6 #define REMOTING_CLIENT_SOFTWARE_VIDEO_RENDERER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 26 matching lines...) Expand all Loading... | |
37 | 37 |
38 // Implementation of VideoRenderer interface that decodes frame on CPU (on a | 38 // Implementation of VideoRenderer interface that decodes frame on CPU (on a |
39 // decode thread) and then passes decoded frames to a FrameConsumer. | 39 // decode thread) and then passes decoded frames to a FrameConsumer. |
40 class SoftwareVideoRenderer : public protocol::VideoRenderer, | 40 class SoftwareVideoRenderer : public protocol::VideoRenderer, |
41 public protocol::VideoStub { | 41 public protocol::VideoStub { |
42 public: | 42 public: |
43 // The renderer can be created on any thread but afterwards all methods must | 43 // The renderer can be created on any thread but afterwards all methods must |
44 // be called on the same thread. | 44 // be called on the same thread. |
45 explicit SoftwareVideoRenderer(protocol::FrameConsumer* consumer); | 45 explicit SoftwareVideoRenderer(protocol::FrameConsumer* consumer); |
46 | 46 |
47 // std::unique_ptr version constructor that owns the consumer. | |
Sergey Ulanov
2016/07/20 18:39:26
Suggest rewording: "Same as above, but takes owner
Yuwei
2016/07/21 00:07:32
Done.
| |
48 explicit SoftwareVideoRenderer( | |
49 std::unique_ptr<protocol::FrameConsumer> consumer); | |
50 | |
47 // Deprecated constructor. TODO(yuweih): remove. | 51 // Deprecated constructor. TODO(yuweih): remove. |
48 // Constructs the renderer and initializes it immediately. Caller should not | 52 // Constructs the renderer and initializes it immediately. Caller should not |
49 // call Initialize() after using this constructor. | 53 // call Initialize() after using this constructor. |
50 // All methods must be called on the same thread the renderer is created. The | 54 // All methods must be called on the same thread the renderer is created. The |
51 // |decode_task_runner_| is used to decode the video packets. |consumer| and | 55 // |decode_task_runner_| is used to decode the video packets. |consumer| and |
52 // |stats_consumer| must outlive the renderer. |stats_consumer| may be | 56 // |stats_consumer| must outlive the renderer. |stats_consumer| may be |
53 // nullptr, performance tracking is disabled in that case. | 57 // nullptr, performance tracking is disabled in that case. |
54 SoftwareVideoRenderer( | 58 SoftwareVideoRenderer( |
Sergey Ulanov
2016/07/20 18:39:26
Please remove this constructor. It's used only in
Yuwei
2016/07/21 00:07:32
Done.
| |
55 scoped_refptr<base::SingleThreadTaskRunner> decode_task_runner, | 59 scoped_refptr<base::SingleThreadTaskRunner> decode_task_runner, |
56 protocol::FrameConsumer* consumer, | 60 protocol::FrameConsumer* consumer, |
57 protocol::FrameStatsConsumer* stats_consumer); | 61 protocol::FrameStatsConsumer* stats_consumer); |
58 ~SoftwareVideoRenderer() override; | 62 ~SoftwareVideoRenderer() override; |
59 | 63 |
60 // VideoRenderer interface. | 64 // VideoRenderer interface. |
61 bool Initialize(const ClientContext& client_context, | 65 bool Initialize(const ClientContext& client_context, |
62 protocol::FrameStatsConsumer* stats_consumer) override; | 66 protocol::FrameStatsConsumer* stats_consumer) override; |
63 void OnSessionConfig(const protocol::SessionConfig& config) override; | 67 void OnSessionConfig(const protocol::SessionConfig& config) override; |
64 protocol::VideoStub* GetVideoStub() override; | 68 protocol::VideoStub* GetVideoStub() override; |
65 protocol::FrameConsumer* GetFrameConsumer() override; | 69 protocol::FrameConsumer* GetFrameConsumer() override; |
66 protocol::FrameStatsConsumer* GetFrameStatsConsumer() override; | 70 protocol::FrameStatsConsumer* GetFrameStatsConsumer() override; |
67 | 71 |
68 // protocol::VideoStub interface. | 72 // protocol::VideoStub interface. |
69 void ProcessVideoPacket(std::unique_ptr<VideoPacket> packet, | 73 void ProcessVideoPacket(std::unique_ptr<VideoPacket> packet, |
70 const base::Closure& done) override; | 74 const base::Closure& done) override; |
71 | 75 |
72 private: | 76 private: |
73 void RenderFrame(std::unique_ptr<protocol::FrameStats> stats, | 77 void RenderFrame(std::unique_ptr<protocol::FrameStats> stats, |
74 const base::Closure& done, | 78 const base::Closure& done, |
75 std::unique_ptr<webrtc::DesktopFrame> frame); | 79 std::unique_ptr<webrtc::DesktopFrame> frame); |
76 void OnFrameRendered(std::unique_ptr<protocol::FrameStats> stats, | 80 void OnFrameRendered(std::unique_ptr<protocol::FrameStats> stats, |
77 const base::Closure& done); | 81 const base::Closure& done); |
78 | 82 |
79 scoped_refptr<base::SingleThreadTaskRunner> decode_task_runner_; | 83 scoped_refptr<base::SingleThreadTaskRunner> decode_task_runner_; |
84 | |
85 // |owned_consumer_| and |consumer_| should refer to the same object if | |
86 // |owned_consumer_| is not null. | |
87 std::unique_ptr<protocol::FrameConsumer> owned_consumer_; | |
80 protocol::FrameConsumer* const consumer_; | 88 protocol::FrameConsumer* const consumer_; |
89 | |
81 protocol::FrameStatsConsumer* stats_consumer_ = nullptr; | 90 protocol::FrameStatsConsumer* stats_consumer_ = nullptr; |
82 | 91 |
83 std::unique_ptr<VideoDecoder> decoder_; | 92 std::unique_ptr<VideoDecoder> decoder_; |
84 | 93 |
85 webrtc::DesktopSize source_size_; | 94 webrtc::DesktopSize source_size_; |
86 webrtc::DesktopVector source_dpi_; | 95 webrtc::DesktopVector source_dpi_; |
87 | 96 |
88 base::ThreadChecker thread_checker_; | 97 base::ThreadChecker thread_checker_; |
89 | 98 |
90 base::WeakPtrFactory<SoftwareVideoRenderer> weak_factory_; | 99 base::WeakPtrFactory<SoftwareVideoRenderer> weak_factory_; |
91 | 100 |
92 DISALLOW_COPY_AND_ASSIGN(SoftwareVideoRenderer); | 101 DISALLOW_COPY_AND_ASSIGN(SoftwareVideoRenderer); |
93 }; | 102 }; |
94 | 103 |
95 } // namespace remoting | 104 } // namespace remoting |
96 | 105 |
97 #endif // REMOTING_CLIENT_SOFTWARE_VIDEO_RENDERER_H_ | 106 #endif // REMOTING_CLIENT_SOFTWARE_VIDEO_RENDERER_H_ |
OLD | NEW |