Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(837)

Side by Side Diff: remoting/protocol/webrtc_frame_scheduler_simple.h

Issue 2381153002: Pace outgoing frames in frame scheduler to match target bitrate. (Closed)
Patch Set: . Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « remoting/base/leaky_bucket.cc ('k') | remoting/protocol/webrtc_frame_scheduler_simple.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_FRAME_SCHEDULER_SIMPLE_H_ 5 #ifndef REMOTING_PROTOCOL_WEBRTC_FRAME_SCHEDULER_SIMPLE_H_
6 #define REMOTING_PROTOCOL_WEBRTC_FRAME_SCHEDULER_SIMPLE_H_ 6 #define REMOTING_PROTOCOL_WEBRTC_FRAME_SCHEDULER_SIMPLE_H_
7 7
8 #include "remoting/protocol/webrtc_frame_scheduler.h" 8 #include "remoting/protocol/webrtc_frame_scheduler.h"
9 9
10 #include "base/timer/timer.h" 10 #include "base/timer/timer.h"
11 #include "remoting/base/leaky_bucket.h"
11 #include "remoting/base/running_samples.h" 12 #include "remoting/base/running_samples.h"
12 13
13 namespace remoting { 14 namespace remoting {
14 namespace protocol { 15 namespace protocol {
15 16
16 // WebrtcFrameSchedulerSimple is a simple implementation of 17 // WebrtcFrameSchedulerSimple is a simple implementation of
17 // WebrtcFrameScheduler that always keeps only one frame in the pipeline. 18 // WebrtcFrameScheduler that always keeps only one frame in the pipeline.
18 // It schedules each frame after the previous one is expected to finish sending. 19 // It schedules each frame after the previous one is expected to finish sending.
19 class WebrtcFrameSchedulerSimple : public WebrtcFrameScheduler { 20 class WebrtcFrameSchedulerSimple : public WebrtcFrameScheduler {
20 public: 21 public:
21 WebrtcFrameSchedulerSimple(); 22 WebrtcFrameSchedulerSimple();
22 ~WebrtcFrameSchedulerSimple() override; 23 ~WebrtcFrameSchedulerSimple() override;
23 24
24 // WebrtcFrameScheduler implementation. 25 // WebrtcFrameScheduler implementation.
25 void Start(const base::Closure& capture_callback) override; 26 void Start(const base::Closure& capture_callback) override;
26 void Pause(bool pause) override; 27 void Pause(bool pause) override;
27 void SetKeyFrameRequest() override; 28 void SetKeyFrameRequest() override;
28 void SetTargetBitrate(int bitrate_kbps) override; 29 void SetTargetBitrate(int bitrate_kbps) override;
29 bool GetEncoderFrameParams( 30 bool GetEncoderFrameParams(
30 const webrtc::DesktopFrame& frame, 31 const webrtc::DesktopFrame& frame,
31 WebrtcVideoEncoder::FrameParams* params_out) override; 32 WebrtcVideoEncoder::FrameParams* params_out) override;
32 void OnFrameEncoded( 33 void OnFrameEncoded(
33 const WebrtcVideoEncoder::EncodedFrame& encoded_frame, 34 const WebrtcVideoEncoder::EncodedFrame& encoded_frame,
34 const webrtc::EncodedImageCallback::Result& send_result) override; 35 const webrtc::EncodedImageCallback::Result& send_result) override;
35 36
36 private: 37 private:
37 void ScheduleNextFrame(); 38 void ScheduleNextFrame(base::TimeTicks now);
38 void CaptureNextFrame(); 39 void CaptureNextFrame();
39 40
40 base::Closure capture_callback_; 41 base::Closure capture_callback_;
41 bool paused_ = false; 42 bool paused_ = false;
42 bool key_frame_request_ = false; 43 bool key_frame_request_ = false;
43 int target_bitrate_kbps_ = 1000; // Initial bitrate.
44 44
45 base::TimeTicks last_capture_started_time_; 45 base::TimeTicks last_capture_started_time_;
46 base::TimeTicks last_frame_send_finish_time_; 46
47 LeakyBucket pacing_bucket_;
47 48
48 // Set to true when encoding unchanged frames for top-off. 49 // Set to true when encoding unchanged frames for top-off.
49 bool top_off_is_active_ = false; 50 bool top_off_is_active_ = false;
50 51
51 // Accumulator for capture and encoder delay history. 52 // Accumulator for capture and encoder delay history.
52 RunningSamples frame_processing_delay_us_; 53 RunningSamples frame_processing_delay_us_;
53 54
54 base::OneShotTimer capture_timer_; 55 base::OneShotTimer capture_timer_;
55 }; 56 };
56 57
57 } // namespace protocol 58 } // namespace protocol
58 } // namespace remoting 59 } // namespace remoting
59 60
60 #endif // REMOTING_PROTOCOL_WEBRTC_FRAME_SCHEDULER_SIMPLE_H_ 61 #endif // REMOTING_PROTOCOL_WEBRTC_FRAME_SCHEDULER_SIMPLE_H_
OLDNEW
« no previous file with comments | « remoting/base/leaky_bucket.cc ('k') | remoting/protocol/webrtc_frame_scheduler_simple.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698