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