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 14 matching lines...) Expand all Loading... |
25 class DesktopFrame; | 25 class DesktopFrame; |
26 } // namespace webrtc | 26 } // namespace webrtc |
27 | 27 |
28 namespace remoting { | 28 namespace remoting { |
29 | 29 |
30 class VideoDecoder; | 30 class VideoDecoder; |
31 | 31 |
32 namespace protocol { | 32 namespace protocol { |
33 class FrameConsumer; | 33 class FrameConsumer; |
34 struct FrameStats; | 34 struct FrameStats; |
35 class PerformanceTracker; | 35 class FrameStatsConsumer; |
36 } // namespace protocol | 36 } // namespace protocol |
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 SoftwareVideoRenderer(protocol::FrameConsumer* consumer); | 45 explicit SoftwareVideoRenderer(protocol::FrameConsumer* consumer); |
46 | 46 |
47 // Deprecated constructor. TODO(yuweih): remove. | 47 // Deprecated constructor. TODO(yuweih): remove. |
48 // Constructs the renderer and initializes it immediately. Caller should not | 48 // Constructs the renderer and initializes it immediately. Caller should not |
49 // call Initialize() after using this constructor. | 49 // call Initialize() after using this constructor. |
50 // All methods must be called on the same thread the renderer is created. The | 50 // 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. |perf_tracker| | 51 // |decode_task_runner_| is used to decode the video packets. |consumer| and |
52 // must outlive the renderer. |perf_tracker| may be nullptr, performance | 52 // |stats_consumer| must outlive the renderer. |stats_consumer| may be |
53 // tracking is disabled in that case. | 53 // nullptr, performance tracking is disabled in that case. |
54 SoftwareVideoRenderer( | 54 SoftwareVideoRenderer( |
55 scoped_refptr<base::SingleThreadTaskRunner> decode_task_runner, | 55 scoped_refptr<base::SingleThreadTaskRunner> decode_task_runner, |
56 protocol::FrameConsumer* consumer, | 56 protocol::FrameConsumer* consumer, |
57 protocol::PerformanceTracker* perf_tracker); | 57 protocol::FrameStatsConsumer* stats_consumer); |
58 ~SoftwareVideoRenderer() override; | 58 ~SoftwareVideoRenderer() override; |
59 | 59 |
60 // VideoRenderer interface. | 60 // VideoRenderer interface. |
61 bool Initialize(const ClientContext& client_context, | 61 bool Initialize(const ClientContext& client_context, |
62 protocol::PerformanceTracker* perf_tracker) override; | 62 protocol::FrameStatsConsumer* stats_consumer) override; |
63 void OnSessionConfig(const protocol::SessionConfig& config) override; | 63 void OnSessionConfig(const protocol::SessionConfig& config) override; |
64 protocol::VideoStub* GetVideoStub() override; | 64 protocol::VideoStub* GetVideoStub() override; |
65 protocol::FrameConsumer* GetFrameConsumer() override; | 65 protocol::FrameConsumer* GetFrameConsumer() override; |
| 66 protocol::FrameStatsConsumer* GetFrameStatsConsumer() override; |
66 | 67 |
67 // protocol::VideoStub interface. | 68 // protocol::VideoStub interface. |
68 void ProcessVideoPacket(std::unique_ptr<VideoPacket> packet, | 69 void ProcessVideoPacket(std::unique_ptr<VideoPacket> packet, |
69 const base::Closure& done) override; | 70 const base::Closure& done) override; |
70 | 71 |
71 private: | 72 private: |
72 void RenderFrame(std::unique_ptr<protocol::FrameStats> stats, | 73 void RenderFrame(std::unique_ptr<protocol::FrameStats> stats, |
73 const base::Closure& done, | 74 const base::Closure& done, |
74 std::unique_ptr<webrtc::DesktopFrame> frame); | 75 std::unique_ptr<webrtc::DesktopFrame> frame); |
75 void OnFrameRendered(std::unique_ptr<protocol::FrameStats> stats, | 76 void OnFrameRendered(std::unique_ptr<protocol::FrameStats> stats, |
76 const base::Closure& done); | 77 const base::Closure& done); |
77 | 78 |
78 scoped_refptr<base::SingleThreadTaskRunner> decode_task_runner_; | 79 scoped_refptr<base::SingleThreadTaskRunner> decode_task_runner_; |
79 protocol::FrameConsumer* consumer_; | 80 protocol::FrameConsumer* const consumer_; |
80 protocol::PerformanceTracker* perf_tracker_ = nullptr; | 81 protocol::FrameStatsConsumer* stats_consumer_ = nullptr; |
81 | 82 |
82 std::unique_ptr<VideoDecoder> decoder_; | 83 std::unique_ptr<VideoDecoder> decoder_; |
83 | 84 |
84 webrtc::DesktopSize source_size_; | 85 webrtc::DesktopSize source_size_; |
85 webrtc::DesktopVector source_dpi_; | 86 webrtc::DesktopVector source_dpi_; |
86 | 87 |
87 base::ThreadChecker thread_checker_; | 88 base::ThreadChecker thread_checker_; |
88 | 89 |
89 base::WeakPtrFactory<SoftwareVideoRenderer> weak_factory_; | 90 base::WeakPtrFactory<SoftwareVideoRenderer> weak_factory_; |
90 | 91 |
91 DISALLOW_COPY_AND_ASSIGN(SoftwareVideoRenderer); | 92 DISALLOW_COPY_AND_ASSIGN(SoftwareVideoRenderer); |
92 }; | 93 }; |
93 | 94 |
94 } // namespace remoting | 95 } // namespace remoting |
95 | 96 |
96 #endif // REMOTING_CLIENT_SOFTWARE_VIDEO_RENDERER_H_ | 97 #endif // REMOTING_CLIENT_SOFTWARE_VIDEO_RENDERER_H_ |
OLD | NEW |