Reland "red: remove special-casing of no-redundancy"
This is a reland of 320c57b7c6bf68d8612a4f135f44b3d29e802113 Original change's description: > 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} Bug: webrtc:11640 Change-Id: I5e5687be575183ee16d74df4a8170e4fedad739f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/228422 Commit-Queue: Henrik Lundin <henrik.lundin@webrtc.org> Reviewed-by: Henrik Lundin <henrik.lundin@webrtc.org> Cr-Commit-Position: refs/heads/master@{#34713}
This commit is contained in:
committed by
WebRTC LUCI CQ
parent
d7b7ea6106
commit
e9655736e5
@ -122,12 +122,7 @@ AudioEncoder::EncodedInfo AudioEncoderCopyRed::EncodeImpl(
|
|||||||
header_length_bytes += kRedHeaderLength;
|
header_length_bytes += kRedHeaderLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allocate room for RFC 2198 header if there is redundant data.
|
// Allocate room for RFC 2198 header.
|
||||||
// Otherwise this will send the primary payload type without
|
|
||||||
// wrapping in RED.
|
|
||||||
if (header_length_bytes == kRedLastHeaderLength) {
|
|
||||||
header_length_bytes = 0;
|
|
||||||
}
|
|
||||||
encoded->SetSize(header_length_bytes);
|
encoded->SetSize(header_length_bytes);
|
||||||
|
|
||||||
// Iterate backwards and append the data.
|
// Iterate backwards and append the data.
|
||||||
@ -148,17 +143,15 @@ AudioEncoder::EncodedInfo AudioEncoderCopyRed::EncodeImpl(
|
|||||||
// `info` will be implicitly cast to an EncodedInfoLeaf struct, effectively
|
// `info` will be implicitly cast to an EncodedInfoLeaf struct, effectively
|
||||||
// discarding the (empty) vector of redundant information. This is
|
// discarding the (empty) vector of redundant information. This is
|
||||||
// intentional.
|
// intentional.
|
||||||
if (header_length_bytes > 0) {
|
if (header_length_bytes > kRedHeaderLength) {
|
||||||
info.redundant.push_back(info);
|
info.redundant.push_back(info);
|
||||||
RTC_DCHECK_EQ(info.speech,
|
RTC_DCHECK_EQ(info.speech,
|
||||||
info.redundant[info.redundant.size() - 1].speech);
|
info.redundant[info.redundant.size() - 1].speech);
|
||||||
}
|
}
|
||||||
|
|
||||||
encoded->AppendData(primary_encoded_);
|
encoded->AppendData(primary_encoded_);
|
||||||
if (header_length_bytes > 0) {
|
|
||||||
RTC_DCHECK_EQ(header_offset, header_length_bytes - 1);
|
RTC_DCHECK_EQ(header_offset, header_length_bytes - 1);
|
||||||
encoded->data()[header_offset] = info.payload_type;
|
encoded->data()[header_offset] = info.payload_type;
|
||||||
}
|
|
||||||
|
|
||||||
// Shift the redundant encodings.
|
// Shift the redundant encodings.
|
||||||
auto rit = redundant_encodings_.rbegin();
|
auto rit = redundant_encodings_.rbegin();
|
||||||
@ -172,9 +165,7 @@ AudioEncoder::EncodedInfo AudioEncoderCopyRed::EncodeImpl(
|
|||||||
it->second.SetData(primary_encoded_);
|
it->second.SetData(primary_encoded_);
|
||||||
|
|
||||||
// Update main EncodedInfo.
|
// 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();
|
info.encoded_bytes = encoded->size();
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,6 +34,8 @@ namespace webrtc {
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
static const size_t kMaxNumSamples = 48 * 10 * 2; // 10 ms @ 48 kHz stereo.
|
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 {
|
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
|
// First call is a special case, since it does not include a secondary
|
||||||
// payload.
|
// payload.
|
||||||
EXPECT_EQ(0u, encoded_info_.redundant.size());
|
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.
|
// Next call to the speech encoder will not produce any output.
|
||||||
Encode();
|
Encode();
|
||||||
@ -190,7 +192,7 @@ TEST_F(AudioEncoderCopyRedTest, CheckPayloadSizesSingle) {
|
|||||||
// payload.
|
// payload.
|
||||||
Encode();
|
Encode();
|
||||||
EXPECT_EQ(0u, encoded_info_.redundant.size());
|
EXPECT_EQ(0u, encoded_info_.redundant.size());
|
||||||
EXPECT_EQ(1u, encoded_info_.encoded_bytes);
|
EXPECT_EQ(kRedLastHeaderLength + 1u, encoded_info_.encoded_bytes);
|
||||||
|
|
||||||
for (size_t i = 2; i <= kNumPackets; ++i) {
|
for (size_t i = 2; i <= kNumPackets; ++i) {
|
||||||
Encode();
|
Encode();
|
||||||
@ -217,7 +219,7 @@ TEST_F(AudioEncoderCopyRedTest, CheckPayloadSizes) {
|
|||||||
// payload.
|
// payload.
|
||||||
Encode();
|
Encode();
|
||||||
EXPECT_EQ(0u, encoded_info_.redundant.size());
|
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
|
// Second call is also special since it does not include a tertiary
|
||||||
// payload.
|
// payload.
|
||||||
@ -259,7 +261,7 @@ TEST_F(AudioEncoderCopyRedTest, CheckPayloadSizesTriple) {
|
|||||||
// payload.
|
// payload.
|
||||||
Encode();
|
Encode();
|
||||||
EXPECT_EQ(0u, encoded_info_.redundant.size());
|
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
|
// Second call is also special since it does not include a tertiary
|
||||||
// payload.
|
// payload.
|
||||||
@ -329,9 +331,10 @@ TEST_F(AudioEncoderCopyRedTest, CheckPayloads) {
|
|||||||
// First call is a special case, since it does not include a secondary
|
// First call is a special case, since it does not include a secondary
|
||||||
// payload.
|
// payload.
|
||||||
Encode();
|
Encode();
|
||||||
EXPECT_EQ(kPayloadLenBytes, encoded_info_.encoded_bytes);
|
EXPECT_EQ(kRedLastHeaderLength + kPayloadLenBytes,
|
||||||
|
encoded_info_.encoded_bytes);
|
||||||
for (size_t i = 0; i < kPayloadLenBytes; ++i) {
|
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) {
|
for (int j = 0; j < 1; ++j) {
|
||||||
|
|||||||
Reference in New Issue
Block a user