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. | |
Sergey Ulanov
2016/06/29 23:02:12
Remove it in this CL?
Yuwei
2016/06/29 23:38:02
Not sure whether we can do it... Looks like the iO
| |
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 // client_context.decode_task_runner() will be used to decode the video | |
62 // packets. | |
63 // |perf_tracker| may be nullptr, performance tracking is disabled in that | |
64 // case. | |
Sergey Ulanov
2016/06/29 23:02:12
Don't need to duplicate documentation when impleme
Yuwei
2016/06/29 23:38:02
Done.
| |
65 bool Initialize(const ClientContext& client_context, | |
66 protocol::PerformanceTracker* perf_tracker) override; | |
54 void OnSessionConfig(const protocol::SessionConfig& config) override; | 67 void OnSessionConfig(const protocol::SessionConfig& config) override; |
55 protocol::VideoStub* GetVideoStub() override; | 68 protocol::VideoStub* GetVideoStub() override; |
56 protocol::FrameConsumer* GetFrameConsumer() override; | 69 protocol::FrameConsumer* GetFrameConsumer() override; |
57 | 70 |
58 // protocol::VideoStub interface. | 71 // protocol::VideoStub interface. |
59 void ProcessVideoPacket(std::unique_ptr<VideoPacket> packet, | 72 void ProcessVideoPacket(std::unique_ptr<VideoPacket> packet, |
60 const base::Closure& done) override; | 73 const base::Closure& done) override; |
61 | 74 |
62 private: | 75 private: |
63 void RenderFrame(std::unique_ptr<protocol::FrameStats> stats, | 76 void RenderFrame(std::unique_ptr<protocol::FrameStats> stats, |
64 const base::Closure& done, | 77 const base::Closure& done, |
65 std::unique_ptr<webrtc::DesktopFrame> frame); | 78 std::unique_ptr<webrtc::DesktopFrame> frame); |
66 void OnFrameRendered(std::unique_ptr<protocol::FrameStats> stats, | 79 void OnFrameRendered(std::unique_ptr<protocol::FrameStats> stats, |
67 const base::Closure& done); | 80 const base::Closure& done); |
68 | 81 |
69 scoped_refptr<base::SingleThreadTaskRunner> decode_task_runner_; | 82 scoped_refptr<base::SingleThreadTaskRunner> decode_task_runner_; |
70 protocol::FrameConsumer* consumer_; | 83 protocol::FrameConsumer* consumer_; |
71 protocol::PerformanceTracker* perf_tracker_; | 84 protocol::PerformanceTracker* perf_tracker_ = nullptr; |
72 | 85 |
73 std::unique_ptr<VideoDecoder> decoder_; | 86 std::unique_ptr<VideoDecoder> decoder_; |
74 | 87 |
75 webrtc::DesktopSize source_size_; | 88 webrtc::DesktopSize source_size_; |
76 webrtc::DesktopVector source_dpi_; | 89 webrtc::DesktopVector source_dpi_; |
77 | 90 |
78 base::ThreadChecker thread_checker_; | 91 base::ThreadChecker thread_checker_; |
79 | 92 |
80 base::WeakPtrFactory<SoftwareVideoRenderer> weak_factory_; | 93 base::WeakPtrFactory<SoftwareVideoRenderer> weak_factory_; |
81 | 94 |
82 DISALLOW_COPY_AND_ASSIGN(SoftwareVideoRenderer); | 95 DISALLOW_COPY_AND_ASSIGN(SoftwareVideoRenderer); |
83 }; | 96 }; |
84 | 97 |
85 } // namespace remoting | 98 } // namespace remoting |
86 | 99 |
87 #endif // REMOTING_CLIENT_SOFTWARE_VIDEO_RENDERER_H_ | 100 #endif // REMOTING_CLIENT_SOFTWARE_VIDEO_RENDERER_H_ |
OLD | NEW |