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

Unified Diff: webrtc/video/stream_synchronization.cc

Issue 2216533002: Move RTP for synchroninzation and rename classes, files and variables. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Indentation + rebase. Created 4 years, 4 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
« no previous file with comments | « webrtc/video/stream_synchronization.h ('k') | webrtc/video/video_receive_stream.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/video/stream_synchronization.cc
diff --git a/webrtc/video/stream_synchronization.cc b/webrtc/video/stream_synchronization.cc
index 3727f8fdb53e5934c6a884e507ac79f52161e8da..ff389736f4bd09883ac89d188a3d334e27c3545b 100644
--- a/webrtc/video/stream_synchronization.cc
+++ b/webrtc/video/stream_synchronization.cc
@@ -26,35 +26,14 @@ static const int kFilterLength = 4;
// Minimum difference between audio and video to warrant a change.
static const int kMinDeltaMs = 30;
-struct ViESyncDelay {
- ViESyncDelay() {
- extra_video_delay_ms = 0;
- last_video_delay_ms = 0;
- extra_audio_delay_ms = 0;
- last_audio_delay_ms = 0;
- network_delay = 120;
- }
-
- int extra_video_delay_ms;
- int last_video_delay_ms;
- int extra_audio_delay_ms;
- int last_audio_delay_ms;
- int network_delay;
-};
-
StreamSynchronization::StreamSynchronization(uint32_t video_primary_ssrc,
int audio_channel_id)
- : channel_delay_(new ViESyncDelay),
- video_primary_ssrc_(video_primary_ssrc),
+ : video_primary_ssrc_(video_primary_ssrc),
audio_channel_id_(audio_channel_id),
base_target_delay_ms_(0),
avg_diff_ms_(0) {
}
-StreamSynchronization::~StreamSynchronization() {
- delete channel_delay_;
-}
-
bool StreamSynchronization::ComputeRelativeDelay(
const Measurements& audio_measurement,
const Measurements& video_measurement,
@@ -94,7 +73,6 @@ bool StreamSynchronization::ComputeDelays(int relative_delay_ms,
int current_video_delay_ms = *total_video_delay_target_ms;
LOG(LS_VERBOSE) << "Audio delay: " << current_audio_delay_ms
- << ", network delay diff: " << channel_delay_->network_delay
<< " current diff: " << relative_delay_ms
<< " for channel " << audio_channel_id_;
// Calculate the difference between the lowest possible video delay and
@@ -120,78 +98,78 @@ bool StreamSynchronization::ComputeDelays(int relative_delay_ms,
if (diff_ms > 0) {
// The minimum video delay is longer than the current audio delay.
// We need to decrease extra video delay, or add extra audio delay.
- if (channel_delay_->extra_video_delay_ms > base_target_delay_ms_) {
+ if (channel_delay_.extra_video_delay_ms > base_target_delay_ms_) {
// We have extra delay added to ViE. Reduce this delay before adding
// extra delay to VoE.
- channel_delay_->extra_video_delay_ms -= diff_ms;
- channel_delay_->extra_audio_delay_ms = base_target_delay_ms_;
- } else { // channel_delay_->extra_video_delay_ms > 0
+ channel_delay_.extra_video_delay_ms -= diff_ms;
+ channel_delay_.extra_audio_delay_ms = base_target_delay_ms_;
+ } else { // channel_delay_.extra_video_delay_ms > 0
// We have no extra video delay to remove, increase the audio delay.
- channel_delay_->extra_audio_delay_ms += diff_ms;
- channel_delay_->extra_video_delay_ms = base_target_delay_ms_;
+ channel_delay_.extra_audio_delay_ms += diff_ms;
+ channel_delay_.extra_video_delay_ms = base_target_delay_ms_;
}
} else { // if (diff_ms > 0)
// The video delay is lower than the current audio delay.
// We need to decrease extra audio delay, or add extra video delay.
- if (channel_delay_->extra_audio_delay_ms > base_target_delay_ms_) {
+ if (channel_delay_.extra_audio_delay_ms > base_target_delay_ms_) {
// We have extra delay in VoiceEngine.
// Start with decreasing the voice delay.
// Note: diff_ms is negative; add the negative difference.
- channel_delay_->extra_audio_delay_ms += diff_ms;
- channel_delay_->extra_video_delay_ms = base_target_delay_ms_;
- } else { // channel_delay_->extra_audio_delay_ms > base_target_delay_ms_
+ channel_delay_.extra_audio_delay_ms += diff_ms;
+ channel_delay_.extra_video_delay_ms = base_target_delay_ms_;
+ } else { // channel_delay_.extra_audio_delay_ms > base_target_delay_ms_
// We have no extra delay in VoiceEngine, increase the video delay.
// Note: diff_ms is negative; subtract the negative difference.
- channel_delay_->extra_video_delay_ms -= diff_ms; // X - (-Y) = X + Y.
- channel_delay_->extra_audio_delay_ms = base_target_delay_ms_;
+ channel_delay_.extra_video_delay_ms -= diff_ms; // X - (-Y) = X + Y.
+ channel_delay_.extra_audio_delay_ms = base_target_delay_ms_;
}
}
// Make sure that video is never below our target.
- channel_delay_->extra_video_delay_ms = std::max(
- channel_delay_->extra_video_delay_ms, base_target_delay_ms_);
+ channel_delay_.extra_video_delay_ms = std::max(
+ channel_delay_.extra_video_delay_ms, base_target_delay_ms_);
int new_video_delay_ms;
- if (channel_delay_->extra_video_delay_ms > base_target_delay_ms_) {
- new_video_delay_ms = channel_delay_->extra_video_delay_ms;
+ if (channel_delay_.extra_video_delay_ms > base_target_delay_ms_) {
+ new_video_delay_ms = channel_delay_.extra_video_delay_ms;
} else {
// No change to the extra video delay. We are changing audio and we only
// allow to change one at the time.
- new_video_delay_ms = channel_delay_->last_video_delay_ms;
+ new_video_delay_ms = channel_delay_.last_video_delay_ms;
}
// Make sure that we don't go below the extra video delay.
new_video_delay_ms = std::max(
- new_video_delay_ms, channel_delay_->extra_video_delay_ms);
+ new_video_delay_ms, channel_delay_.extra_video_delay_ms);
// Verify we don't go above the maximum allowed video delay.
new_video_delay_ms =
std::min(new_video_delay_ms, base_target_delay_ms_ + kMaxDeltaDelayMs);
int new_audio_delay_ms;
- if (channel_delay_->extra_audio_delay_ms > base_target_delay_ms_) {
- new_audio_delay_ms = channel_delay_->extra_audio_delay_ms;
+ if (channel_delay_.extra_audio_delay_ms > base_target_delay_ms_) {
+ new_audio_delay_ms = channel_delay_.extra_audio_delay_ms;
} else {
// No change to the audio delay. We are changing video and we only
// allow to change one at the time.
- new_audio_delay_ms = channel_delay_->last_audio_delay_ms;
+ new_audio_delay_ms = channel_delay_.last_audio_delay_ms;
}
// Make sure that we don't go below the extra audio delay.
new_audio_delay_ms = std::max(
- new_audio_delay_ms, channel_delay_->extra_audio_delay_ms);
+ new_audio_delay_ms, channel_delay_.extra_audio_delay_ms);
// Verify we don't go above the maximum allowed audio delay.
new_audio_delay_ms =
std::min(new_audio_delay_ms, base_target_delay_ms_ + kMaxDeltaDelayMs);
// Remember our last audio and video delays.
- channel_delay_->last_video_delay_ms = new_video_delay_ms;
- channel_delay_->last_audio_delay_ms = new_audio_delay_ms;
+ channel_delay_.last_video_delay_ms = new_video_delay_ms;
+ channel_delay_.last_audio_delay_ms = new_audio_delay_ms;
LOG(LS_VERBOSE) << "Sync video delay " << new_video_delay_ms
<< " for video primary SSRC " << video_primary_ssrc_
- << " and audio delay " << channel_delay_->extra_audio_delay_ms
+ << " and audio delay " << channel_delay_.extra_audio_delay_ms
<< " for audio channel " << audio_channel_id_;
// Return values.
@@ -202,17 +180,17 @@ bool StreamSynchronization::ComputeDelays(int relative_delay_ms,
void StreamSynchronization::SetTargetBufferingDelay(int target_delay_ms) {
// Initial extra delay for audio (accounting for existing extra delay).
- channel_delay_->extra_audio_delay_ms +=
+ channel_delay_.extra_audio_delay_ms +=
target_delay_ms - base_target_delay_ms_;
- channel_delay_->last_audio_delay_ms +=
+ channel_delay_.last_audio_delay_ms +=
target_delay_ms - base_target_delay_ms_;
// The video delay is compared to the last value (and how much we can update
// is limited by that as well).
- channel_delay_->last_video_delay_ms +=
+ channel_delay_.last_video_delay_ms +=
target_delay_ms - base_target_delay_ms_;
- channel_delay_->extra_video_delay_ms +=
+ channel_delay_.extra_video_delay_ms +=
target_delay_ms - base_target_delay_ms_;
// Video is already delayed by the desired amount.
« no previous file with comments | « webrtc/video/stream_synchronization.h ('k') | webrtc/video/video_receive_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698