Add sender controlled playout delay limits

This CL adds support for an extension on RTP frames to allow the sender
to specify the minimum and maximum playout delay limits.

The receiver makes a best-effort attempt to keep the capture-to-render delay
within this range. This allows different types of application to specify
different end-to-end delay goals. For example gaming can support rendering
of frames as soon as received on receiver to minimize delay. A movie playback
application can specify a minimum playout delay to allow fixed buffering
in presence of network jitter.

There are no tests at this time and most of testing is done with chromium
webrtc prototype.

On chromoting performance tests, this extension helps bring down end-to-end
delay by about 150 ms on small frames.

BUG=webrtc:5895

Review-Url: https://codereview.webrtc.org/2007743003
Cr-Commit-Position: refs/heads/master@{#13059}
This commit is contained in:
isheriff
2016-06-08 00:24:21 -07:00
committed by Commit bot
parent 5d910286e1
commit 6b4b5f3770
41 changed files with 859 additions and 407 deletions

View File

@ -35,14 +35,23 @@ class VCMTiming {
void ResetDecodeTime();
// Set the amount of time needed to render an image. Defaults to 10 ms.
void set_render_delay(uint32_t render_delay_ms);
void set_render_delay(int render_delay_ms);
// Set the minimum time the video must be delayed on the receiver to
// get the desired jitter buffer level.
void SetJitterDelay(uint32_t required_delay_ms);
void SetJitterDelay(int required_delay_ms);
// Set the minimum playout delay required to sync video with audio.
void set_min_playout_delay(uint32_t min_playout_delay);
// Set the minimum playout delay from capture to render in ms.
void set_min_playout_delay(int min_playout_delay_ms);
// Returns the minimum playout delay from capture to render in ms.
int min_playout_delay();
// Set the maximum playout delay from capture to render in ms.
void set_max_playout_delay(int max_playout_delay_ms);
// Returns the maximum playout delay from capture to render in ms.
int max_playout_delay();
// Increases or decreases the current delay to get closer to the target delay.
// Calculates how long it has been since the previous call to this function,
@ -77,7 +86,7 @@ class VCMTiming {
// Returns the current target delay which is required delay + decode time +
// render delay.
uint32_t TargetVideoDelay() const;
int TargetVideoDelay() const;
// Calculates whether or not there is enough time to decode a frame given a
// certain amount of processing time.
@ -96,11 +105,10 @@ class VCMTiming {
enum { kDelayMaxChangeMsPerS = 100 };
protected:
int64_t RequiredDecodeTimeMs() const
EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
int RequiredDecodeTimeMs() const EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
int64_t RenderTimeMsInternal(uint32_t frame_timestamp, int64_t now_ms) const
EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
uint32_t TargetDelayInternal() const EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
int TargetDelayInternal() const EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
private:
void UpdateHistograms() const;
@ -110,10 +118,16 @@ class VCMTiming {
bool master_ GUARDED_BY(crit_sect_);
TimestampExtrapolator* ts_extrapolator_ GUARDED_BY(crit_sect_);
std::unique_ptr<VCMCodecTimer> codec_timer_ GUARDED_BY(crit_sect_);
uint32_t render_delay_ms_ GUARDED_BY(crit_sect_);
uint32_t min_playout_delay_ms_ GUARDED_BY(crit_sect_);
uint32_t jitter_delay_ms_ GUARDED_BY(crit_sect_);
uint32_t current_delay_ms_ GUARDED_BY(crit_sect_);
int render_delay_ms_ GUARDED_BY(crit_sect_);
// Best-effort playout delay range for frames from capture to render.
// The receiver tries to keep the delay between |min_playout_delay_ms_|
// and |max_playout_delay_ms_| taking the network jitter into account.
// A special case is where min_playout_delay_ms_ = max_playout_delay_ms_ = 0,
// in which case the receiver tries to play the frames as they arrive.
int min_playout_delay_ms_ GUARDED_BY(crit_sect_);
int max_playout_delay_ms_ GUARDED_BY(crit_sect_);
int jitter_delay_ms_ GUARDED_BY(crit_sect_);
int current_delay_ms_ GUARDED_BY(crit_sect_);
int last_decode_ms_ GUARDED_BY(crit_sect_);
uint32_t prev_frame_timestamp_ GUARDED_BY(crit_sect_);