Chromium Code Reviews| 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_HOST_VIDEO_FRAME_PUMP_H_ | 5 #ifndef REMOTING_HOST_VIDEO_FRAME_PUMP_H_ |
| 6 #define REMOTING_HOST_VIDEO_FRAME_PUMP_H_ | 6 #define REMOTING_HOST_VIDEO_FRAME_PUMP_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/threading/thread_checker.h" | 11 #include "base/threading/thread_checker.h" |
| 12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 13 #include "base/timer/timer.h" | 13 #include "base/timer/timer.h" |
| 14 #include "remoting/codec/video_encoder.h" | 14 #include "remoting/codec/video_encoder.h" |
| 15 #include "remoting/host/capture_scheduler.h" | 15 #include "remoting/host/capture_scheduler.h" |
| 16 #include "remoting/proto/video.pb.h" | 16 #include "remoting/proto/video.pb.h" |
| 17 #include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h" | 17 #include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h" |
| 18 | 18 |
| 19 namespace base { | 19 namespace base { |
| 20 class SingleThreadTaskRunner; | 20 class SingleThreadTaskRunner; |
| 21 } // namespace base | 21 } // namespace base |
| 22 | 22 |
| 23 namespace remoting { | 23 namespace remoting { |
| 24 | 24 |
| 25 namespace protocol { | 25 namespace protocol { |
| 26 class VideoFeedbackStub; | |
| 26 class VideoStub; | 27 class VideoStub; |
| 27 } // namespace protocol | 28 } // namespace protocol |
| 28 | 29 |
| 29 // Class responsible for scheduling frame captures from a screen capturer., | 30 // Class responsible for scheduling frame captures from a screen capturer., |
| 30 // delivering them to a VideoEncoder to encode, and | 31 // delivering them to a VideoEncoder to encode, and |
| 31 // finally passing the encoded video packets to the specified VideoStub to send | 32 // finally passing the encoded video packets to the specified VideoStub to send |
| 32 // on the network. | 33 // on the network. |
| 33 // | 34 // |
| 34 // THREADING | 35 // THREADING |
| 35 // | 36 // |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 83 | 84 |
| 84 // Updates event timestamp from the last event received from the client. This | 85 // Updates event timestamp from the last event received from the client. This |
| 85 // value is sent back to the client for roundtrip latency estimates. | 86 // value is sent back to the client for roundtrip latency estimates. |
| 86 void SetLatestEventTimestamp(int64 latest_event_timestamp); | 87 void SetLatestEventTimestamp(int64 latest_event_timestamp); |
| 87 | 88 |
| 88 // Sets whether the video encoder should be requested to encode losslessly, | 89 // Sets whether the video encoder should be requested to encode losslessly, |
| 89 // or to use a lossless color space (typically requiring higher bandwidth). | 90 // or to use a lossless color space (typically requiring higher bandwidth). |
| 90 void SetLosslessEncode(bool want_lossless); | 91 void SetLosslessEncode(bool want_lossless); |
| 91 void SetLosslessColor(bool want_lossless); | 92 void SetLosslessColor(bool want_lossless); |
| 92 | 93 |
| 94 protocol::VideoFeedbackStub* video_feedback_stub() { | |
| 95 return &capture_scheduler_; | |
| 96 } | |
| 97 | |
| 93 private: | 98 private: |
| 94 // webrtc::DesktopCapturer::Callback interface. | 99 // webrtc::DesktopCapturer::Callback interface. |
| 95 webrtc::SharedMemory* CreateSharedMemory(size_t size) override; | 100 webrtc::SharedMemory* CreateSharedMemory(size_t size) override; |
| 96 void OnCaptureCompleted(webrtc::DesktopFrame* frame) override; | 101 void OnCaptureCompleted(webrtc::DesktopFrame* frame) override; |
| 97 | 102 |
| 98 // Callback for CaptureScheduler. | 103 // Callback for CaptureScheduler. |
| 99 void CaptureNextFrame(); | 104 void CaptureNextFrame(); |
| 100 | 105 |
| 101 // Sends encoded frame | 106 // Sends encoded frame |
| 102 void SendEncodedFrame(int64 latest_event_timestamp, | 107 void SendEncodedFrame(int64 latest_event_timestamp, |
| 103 base::TimeTicks timestamp, | 108 base::TimeTicks timestamp, |
| 104 scoped_ptr<VideoPacket> packet); | 109 scoped_ptr<VideoPacket> packet); |
| 105 | 110 |
| 106 // Callback passed to |video_stub_| for the last packet in each frame, to | 111 // Callback passed to |video_stub_|. |
| 107 // rate-limit frame captures to network throughput. | |
| 108 void OnVideoPacketSent(); | 112 void OnVideoPacketSent(); |
| 109 | 113 |
| 110 // Called by |keep_alive_timer_|. | 114 // Called by |keep_alive_timer_|. |
| 111 void SendKeepAlivePacket(); | 115 void SendKeepAlivePacket(); |
| 112 | 116 |
| 113 // Callback for |video_stub_| called after a keep-alive packet is sent. | 117 // Callback for |video_stub_| called after a keep-alive packet is sent. |
| 114 void OnKeepAlivePacketSent(); | 118 void OnKeepAlivePacketSent(); |
| 115 | 119 |
| 116 base::ThreadChecker thread_checker_; | 120 base::ThreadChecker thread_checker_; |
|
Wez
2015/02/21 03:12:02
nit: I'd suggest putting this just before the Weak
Sergey Ulanov
2015/02/23 17:35:38
Done.
| |
| 117 | 121 |
| 118 // Task runner used to run |encoder_|. | 122 // Task runner used to run |encoder_|. |
| 119 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner_; | 123 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner_; |
| 120 | 124 |
| 121 // Capturer used to capture the screen. | 125 // Capturer used to capture the screen. |
| 122 scoped_ptr<webrtc::DesktopCapturer> capturer_; | 126 scoped_ptr<webrtc::DesktopCapturer> capturer_; |
| 123 | 127 |
| 124 // Used to encode captured frames. Always accessed on the encode thread. | 128 // Used to encode captured frames. Always accessed on the encode thread. |
| 125 scoped_ptr<VideoEncoder> encoder_; | 129 scoped_ptr<VideoEncoder> encoder_; |
| 126 | 130 |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 139 int64 latest_event_timestamp_; | 143 int64 latest_event_timestamp_; |
| 140 | 144 |
| 141 base::WeakPtrFactory<VideoFramePump> weak_factory_; | 145 base::WeakPtrFactory<VideoFramePump> weak_factory_; |
| 142 | 146 |
| 143 DISALLOW_COPY_AND_ASSIGN(VideoFramePump); | 147 DISALLOW_COPY_AND_ASSIGN(VideoFramePump); |
| 144 }; | 148 }; |
| 145 | 149 |
| 146 } // namespace remoting | 150 } // namespace remoting |
| 147 | 151 |
| 148 #endif // REMOTING_HOST_VIDEO_FRAME_PUMP_H_ | 152 #endif // REMOTING_HOST_VIDEO_FRAME_PUMP_H_ |
| OLD | NEW |