OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_PROTOCOL_WEBRTC_VIDEO_STREAM_H_ | 5 #ifndef REMOTING_PROTOCOL_WEBRTC_VIDEO_STREAM_H_ |
6 #define REMOTING_PROTOCOL_WEBRTC_VIDEO_STREAM_H_ | 6 #define REMOTING_PROTOCOL_WEBRTC_VIDEO_STREAM_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 | 45 |
46 // VideoStream interface. | 46 // VideoStream interface. |
47 void SetEventTimestampsSource(scoped_refptr<InputEventTimestampsSource> | 47 void SetEventTimestampsSource(scoped_refptr<InputEventTimestampsSource> |
48 event_timestamps_source) override; | 48 event_timestamps_source) override; |
49 void Pause(bool pause) override; | 49 void Pause(bool pause) override; |
50 void SetLosslessEncode(bool want_lossless) override; | 50 void SetLosslessEncode(bool want_lossless) override; |
51 void SetLosslessColor(bool want_lossless) override; | 51 void SetLosslessColor(bool want_lossless) override; |
52 void SetObserver(Observer* observer) override; | 52 void SetObserver(Observer* observer) override; |
53 | 53 |
54 private: | 54 private: |
55 struct FrameTimestamps; | 55 struct FrameStats; |
56 struct EncodedFrameWithTimestamps; | 56 struct EncodedFrameWithStats; |
57 | 57 |
58 // webrtc::DesktopCapturer::Callback interface. | 58 // webrtc::DesktopCapturer::Callback interface. |
59 void OnCaptureResult(webrtc::DesktopCapturer::Result result, | 59 void OnCaptureResult(webrtc::DesktopCapturer::Result result, |
60 std::unique_ptr<webrtc::DesktopFrame> frame) override; | 60 std::unique_ptr<webrtc::DesktopFrame> frame) override; |
61 | 61 |
62 // HostVideoStatsDispatcher::EventHandler interface. | 62 // HostVideoStatsDispatcher::EventHandler interface. |
63 void OnChannelInitialized(ChannelDispatcherBase* channel_dispatcher) override; | 63 void OnChannelInitialized(ChannelDispatcherBase* channel_dispatcher) override; |
64 void OnChannelClosed(ChannelDispatcherBase* channel_dispatcher) override; | 64 void OnChannelClosed(ChannelDispatcherBase* channel_dispatcher) override; |
65 | 65 |
66 // Called by the |scheduler_|. | 66 // Called by the |scheduler_|. |
67 void CaptureNextFrame(); | 67 void CaptureNextFrame(); |
68 | 68 |
69 // Task running on the encoder thread to encode the |frame|. | 69 // Task running on the encoder thread to encode the |frame|. |
70 static EncodedFrameWithTimestamps EncodeFrame( | 70 static EncodedFrameWithStats EncodeFrame( |
71 WebrtcVideoEncoder* encoder, | 71 WebrtcVideoEncoder* encoder, |
72 std::unique_ptr<webrtc::DesktopFrame> frame, | 72 std::unique_ptr<webrtc::DesktopFrame> frame, |
73 WebrtcVideoEncoder::FrameParams params, | 73 WebrtcVideoEncoder::FrameParams params, |
74 std::unique_ptr<WebrtcVideoStream::FrameTimestamps> timestamps); | 74 std::unique_ptr<WebrtcVideoStream::FrameStats> stats); |
75 void OnFrameEncoded(EncodedFrameWithTimestamps frame); | 75 void OnFrameEncoded(EncodedFrameWithStats frame); |
76 | 76 |
77 // Capturer used to capture the screen. | 77 // Capturer used to capture the screen. |
78 std::unique_ptr<webrtc::DesktopCapturer> capturer_; | 78 std::unique_ptr<webrtc::DesktopCapturer> capturer_; |
79 // Used to send across encoded frames. | 79 // Used to send across encoded frames. |
80 WebrtcTransport* webrtc_transport_ = nullptr; | 80 WebrtcTransport* webrtc_transport_ = nullptr; |
81 // Task runner used to run |encoder_|. | 81 // Task runner used to run |encoder_|. |
82 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner_; | 82 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner_; |
83 // Used to encode captured frames. Always accessed on the encode thread. | 83 // Used to encode captured frames. Always accessed on the encode thread. |
84 std::unique_ptr<WebrtcVideoEncoder> encoder_; | 84 std::unique_ptr<WebrtcVideoEncoder> encoder_; |
85 | 85 |
86 scoped_refptr<InputEventTimestampsSource> event_timestamps_source_; | 86 scoped_refptr<InputEventTimestampsSource> event_timestamps_source_; |
87 | 87 |
88 scoped_refptr<webrtc::PeerConnectionInterface> peer_connection_; | 88 scoped_refptr<webrtc::PeerConnectionInterface> peer_connection_; |
89 scoped_refptr<webrtc::MediaStreamInterface> stream_; | 89 scoped_refptr<webrtc::MediaStreamInterface> stream_; |
90 | 90 |
91 HostVideoStatsDispatcher video_stats_dispatcher_; | 91 HostVideoStatsDispatcher video_stats_dispatcher_; |
92 | 92 |
93 // Timestamps for the frame that's being captured. | 93 // Stats of the frame that's being captured. |
94 std::unique_ptr<FrameTimestamps> captured_frame_timestamps_; | 94 std::unique_ptr<FrameStats> captured_frame_stats_; |
95 | 95 |
96 std::unique_ptr<WebrtcFrameScheduler> scheduler_; | 96 std::unique_ptr<WebrtcFrameScheduler> scheduler_; |
97 | 97 |
98 webrtc::DesktopSize frame_size_; | 98 webrtc::DesktopSize frame_size_; |
99 webrtc::DesktopVector frame_dpi_; | 99 webrtc::DesktopVector frame_dpi_; |
100 Observer* observer_ = nullptr; | 100 Observer* observer_ = nullptr; |
101 | 101 |
102 base::ThreadChecker thread_checker_; | 102 base::ThreadChecker thread_checker_; |
103 | 103 |
104 base::WeakPtrFactory<WebrtcVideoStream> weak_factory_; | 104 base::WeakPtrFactory<WebrtcVideoStream> weak_factory_; |
105 | 105 |
106 DISALLOW_COPY_AND_ASSIGN(WebrtcVideoStream); | 106 DISALLOW_COPY_AND_ASSIGN(WebrtcVideoStream); |
107 }; | 107 }; |
108 | 108 |
109 } // namespace protocol | 109 } // namespace protocol |
110 } // namespace remoting | 110 } // namespace remoting |
111 | 111 |
112 #endif // REMOTING_PROTOCOL_WEBRTC_VIDEO_STREAM_H_ | 112 #endif // REMOTING_PROTOCOL_WEBRTC_VIDEO_STREAM_H_ |
OLD | NEW |