red: remove special-casing of no-redundancy
removes the special-casing of not sending a RED header when there is no redundant payload. This avoids switching back and forth between the primary and the red payload format (primarily at the start of the connection). BUG=webrtc:11640 Change-Id: I8e0044bef1ed7c4168d9527645522392db2ed068 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/220932 Reviewed-by: Jesus de Vicente Pena <devicentepena@webrtc.org> Reviewed-by: Henrik Lundin <henrik.lundin@webrtc.org> Commit-Queue: Henrik Lundin <henrik.lundin@webrtc.org> Cr-Commit-Position: refs/heads/master@{#34703}
This commit is contained in:

committed by
WebRTC LUCI CQ

parent
43f25e36f7
commit
320c57b7c6
@ -122,12 +122,7 @@ AudioEncoder::EncodedInfo AudioEncoderCopyRed::EncodeImpl(
|
||||
header_length_bytes += kRedHeaderLength;
|
||||
}
|
||||
|
||||
// Allocate room for RFC 2198 header if there is redundant data.
|
||||
// Otherwise this will send the primary payload type without
|
||||
// wrapping in RED.
|
||||
if (header_length_bytes == kRedLastHeaderLength) {
|
||||
header_length_bytes = 0;
|
||||
}
|
||||
// Allocate room for RFC 2198 header.
|
||||
encoded->SetSize(header_length_bytes);
|
||||
|
||||
// Iterate backwards and append the data.
|
||||
@ -148,17 +143,15 @@ AudioEncoder::EncodedInfo AudioEncoderCopyRed::EncodeImpl(
|
||||
// `info` will be implicitly cast to an EncodedInfoLeaf struct, effectively
|
||||
// discarding the (empty) vector of redundant information. This is
|
||||
// intentional.
|
||||
if (header_length_bytes > 0) {
|
||||
if (header_length_bytes > kRedHeaderLength) {
|
||||
info.redundant.push_back(info);
|
||||
RTC_DCHECK_EQ(info.speech,
|
||||
info.redundant[info.redundant.size() - 1].speech);
|
||||
}
|
||||
|
||||
encoded->AppendData(primary_encoded_);
|
||||
if (header_length_bytes > 0) {
|
||||
RTC_DCHECK_EQ(header_offset, header_length_bytes - 1);
|
||||
encoded->data()[header_offset] = info.payload_type;
|
||||
}
|
||||
RTC_DCHECK_EQ(header_offset, header_length_bytes - 1);
|
||||
encoded->data()[header_offset] = info.payload_type;
|
||||
|
||||
// Shift the redundant encodings.
|
||||
auto rit = redundant_encodings_.rbegin();
|
||||
@ -172,9 +165,7 @@ AudioEncoder::EncodedInfo AudioEncoderCopyRed::EncodeImpl(
|
||||
it->second.SetData(primary_encoded_);
|
||||
|
||||
// Update main EncodedInfo.
|
||||
if (header_length_bytes > 0) {
|
||||
info.payload_type = red_payload_type_;
|
||||
}
|
||||
info.payload_type = red_payload_type_;
|
||||
info.encoded_bytes = encoded->size();
|
||||
return info;
|
||||
}
|
||||
|
@ -34,6 +34,8 @@ namespace webrtc {
|
||||
|
||||
namespace {
|
||||
static const size_t kMaxNumSamples = 48 * 10 * 2; // 10 ms @ 48 kHz stereo.
|
||||
static const size_t kRedLastHeaderLength =
|
||||
1; // 1 byte RED header for the last element.
|
||||
}
|
||||
|
||||
class AudioEncoderCopyRedTest : public ::testing::Test {
|
||||
@ -154,7 +156,7 @@ TEST_F(AudioEncoderCopyRedTest, CheckNoOutput) {
|
||||
// First call is a special case, since it does not include a secondary
|
||||
// payload.
|
||||
EXPECT_EQ(0u, encoded_info_.redundant.size());
|
||||
EXPECT_EQ(kEncodedSize, encoded_info_.encoded_bytes);
|
||||
EXPECT_EQ(kEncodedSize + kRedLastHeaderLength, encoded_info_.encoded_bytes);
|
||||
|
||||
// Next call to the speech encoder will not produce any output.
|
||||
Encode();
|
||||
@ -217,7 +219,7 @@ TEST_F(AudioEncoderCopyRedTest, CheckPayloadSizes) {
|
||||
// payload.
|
||||
Encode();
|
||||
EXPECT_EQ(0u, encoded_info_.redundant.size());
|
||||
EXPECT_EQ(1u, encoded_info_.encoded_bytes);
|
||||
EXPECT_EQ(kRedLastHeaderLength + 1u, encoded_info_.encoded_bytes);
|
||||
|
||||
// Second call is also special since it does not include a tertiary
|
||||
// payload.
|
||||
@ -329,9 +331,10 @@ TEST_F(AudioEncoderCopyRedTest, CheckPayloads) {
|
||||
// First call is a special case, since it does not include a secondary
|
||||
// payload.
|
||||
Encode();
|
||||
EXPECT_EQ(kPayloadLenBytes, encoded_info_.encoded_bytes);
|
||||
EXPECT_EQ(kRedLastHeaderLength + kPayloadLenBytes,
|
||||
encoded_info_.encoded_bytes);
|
||||
for (size_t i = 0; i < kPayloadLenBytes; ++i) {
|
||||
EXPECT_EQ(i, encoded_.data()[i]);
|
||||
EXPECT_EQ(i, encoded_.data()[kRedLastHeaderLength + i]);
|
||||
}
|
||||
|
||||
for (int j = 0; j < 1; ++j) {
|
||||
|
Reference in New Issue
Block a user