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

Unified Diff: remoting/protocol/webrtc_frame_scheduler.h

Issue 1908203002: Adapt encoder behavior to target bitrate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved webrtc encoder to its own file Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: remoting/protocol/webrtc_frame_scheduler.h
diff --git a/remoting/protocol/webrtc_frame_scheduler.h b/remoting/protocol/webrtc_frame_scheduler.h
index 0e9f3fce026fa22da3a288f7c79164fa724a0f07..475fd306f04006dc00e99648c766cb3a3bae98bc 100644
--- a/remoting/protocol/webrtc_frame_scheduler.h
+++ b/remoting/protocol/webrtc_frame_scheduler.h
@@ -14,6 +14,7 @@
#include "base/task/cancelable_task_tracker.h"
#include "base/threading/thread_checker.h"
#include "base/timer/timer.h"
+#include "media/capture/content/feedback_signal_accumulator.h"
#include "remoting/codec/video_encoder.h"
#include "remoting/protocol/video_stream.h"
#include "remoting/protocol/webrtc_transport.h"
@@ -23,6 +24,16 @@
namespace remoting {
namespace protocol {
+namespace {
+
+// Max Quantizer value.
+const int kMaxQuantizer = 63;
+
+// Default target bitrate in kbps
+const int kDefaultTargetBitrateKbps = 1000;
+
+} // namespace
+
// Class responsible for scheduling frames for encode and hand-over to
// WebRtc transport for sending across the network.
class WebRtcFrameScheduler : public webrtc::DesktopCapturer::Callback {
@@ -55,19 +66,32 @@ class WebRtcFrameScheduler : public webrtc::DesktopCapturer::Callback {
static std::unique_ptr<VideoPacket> EncodeFrame(
VideoEncoder* encoder,
std::unique_ptr<webrtc::DesktopFrame> frame,
- bool key_frame_request);
+ uint32_t target_bitrate,
+ int64_t frame_duration_us,
+ bool key_frame_request,
+ int64_t capture_time_ms);
void OnFrameEncoded(std::unique_ptr<VideoPacket> packet);
void SetKeyFrameRequest();
bool ClearAndGetKeyFrameRequest();
+ void SetTargetBitrate(uint32_t bitrate);
- // Protects |key_frame_request_|.
+ // Protects |key_frame_request_| and |target_bitrate_kbps_|.
base::Lock lock_;
bool key_frame_request_ = false;
+ uint32_t target_bitrate_kbps_ = kDefaultTargetBitrateKbps;
+ int last_quantizer_ = kMaxQuantizer;
bool capture_pending_ = false;
bool encode_pending_ = false;
+ // Accumulated frame duration.
+ media::FeedbackSignalAccumulator<base::TimeTicks> acc_frame_duration_;
+ // Last time capture was completed.
+ base::TimeTicks last_capture_completed_ticks_;
+ // Last time capture was started.
+ base::TimeTicks last_capture_started_ticks_;
+
webrtc::DesktopSize frame_size_;
webrtc::DesktopVector frame_dpi_;
VideoStream::SizeCallback size_callback_;
@@ -88,7 +112,6 @@ class WebRtcFrameScheduler : public webrtc::DesktopCapturer::Callback {
std::unique_ptr<VideoEncoder> encoder_;
base::ThreadChecker thread_checker_;
- base::TimeTicks last_capture_ticks_;
base::WeakPtrFactory<WebRtcFrameScheduler> weak_factory_;

Powered by Google App Engine
This is Rietveld 408576698