Adding a delay line to NetEq's output
This change adds an optional delay to NetEq's output. Note, this is not
equivalent to increasing the jitter buffer with the same extra length.
Bug: b/156734419
Change-Id: I8b70b6b3bffcfd3da296ccf29853864baa03d6bb
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/175110
Commit-Queue: Henrik Lundin <henrik.lundin@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Ivo Creusen <ivoc@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31343}
diff --git a/api/audio/audio_frame.cc b/api/audio/audio_frame.cc
index 47459ac..c6e5cf4 100644
--- a/api/audio/audio_frame.cc
+++ b/api/audio/audio_frame.cc
@@ -11,6 +11,8 @@
#include "api/audio/audio_frame.h"
#include <string.h>
+#include <algorithm>
+#include <utility>
#include "rtc_base/checks.h"
#include "rtc_base/time_utils.h"
@@ -22,6 +24,28 @@
static_assert(sizeof(data_) == kMaxDataSizeBytes, "kMaxDataSizeBytes");
}
+void swap(AudioFrame& a, AudioFrame& b) {
+ using std::swap;
+ swap(a.timestamp_, b.timestamp_);
+ swap(a.elapsed_time_ms_, b.elapsed_time_ms_);
+ swap(a.ntp_time_ms_, b.ntp_time_ms_);
+ swap(a.samples_per_channel_, b.samples_per_channel_);
+ swap(a.sample_rate_hz_, b.sample_rate_hz_);
+ swap(a.num_channels_, b.num_channels_);
+ swap(a.channel_layout_, b.channel_layout_);
+ swap(a.speech_type_, b.speech_type_);
+ swap(a.vad_activity_, b.vad_activity_);
+ swap(a.profile_timestamp_ms_, b.profile_timestamp_ms_);
+ swap(a.packet_infos_, b.packet_infos_);
+ const size_t length_a = a.samples_per_channel_ * a.num_channels_;
+ const size_t length_b = b.samples_per_channel_ * b.num_channels_;
+ RTC_DCHECK_LE(length_a, AudioFrame::kMaxDataSizeSamples);
+ RTC_DCHECK_LE(length_b, AudioFrame::kMaxDataSizeSamples);
+ std::swap_ranges(a.data_, a.data_ + std::max(length_a, length_b), b.data_);
+ swap(a.muted_, b.muted_);
+ swap(a.absolute_capture_timestamp_ms_, b.absolute_capture_timestamp_ms_);
+}
+
void AudioFrame::Reset() {
ResetWithoutMuting();
muted_ = true;