NetEq: Change member variables for current RTP types to rtc::Optionals

With this change, the value 0xFF is no longer used to flag that the RTP
type is unknown. Instead, an empty value for the rtc::Optional is used.

Review-Url: https://codereview.webrtc.org/2290153002
Cr-Commit-Position: refs/heads/master@{#13989}
This commit is contained in:
henrik.lundin
2016-08-31 03:14:11 -07:00
committed by Commit bot
parent 9e4a3040ed
commit da8bbf6e3c
7 changed files with 51 additions and 43 deletions

View File

@ -174,16 +174,17 @@ TEST(PacketBuffer, InsertPacketList) {
}
MockDecoderDatabase decoder_database;
uint8_t current_pt = 0xFF;
uint8_t current_cng_pt = 0xFF;
rtc::Optional<uint8_t> current_pt;
rtc::Optional<uint8_t> current_cng_pt;
EXPECT_EQ(PacketBuffer::kOK, buffer.InsertPacketList(&list,
decoder_database,
&current_pt,
&current_cng_pt));
EXPECT_TRUE(list.empty()); // The PacketBuffer should have depleted the list.
EXPECT_EQ(10u, buffer.NumPacketsInBuffer());
EXPECT_EQ(0, current_pt); // Current payload type changed to 0.
EXPECT_EQ(0xFF, current_cng_pt); // CNG payload type not changed.
EXPECT_EQ(rtc::Optional<uint8_t>(0),
current_pt); // Current payload type changed to 0.
EXPECT_FALSE(current_cng_pt); // CNG payload type not changed.
buffer.Flush(); // Clean up.
@ -212,16 +213,17 @@ TEST(PacketBuffer, InsertPacketListChangePayloadType) {
MockDecoderDatabase decoder_database;
uint8_t current_pt = 0xFF;
uint8_t current_cng_pt = 0xFF;
rtc::Optional<uint8_t> current_pt;
rtc::Optional<uint8_t> current_cng_pt;
EXPECT_EQ(PacketBuffer::kFlushed, buffer.InsertPacketList(&list,
decoder_database,
&current_pt,
&current_cng_pt));
EXPECT_TRUE(list.empty()); // The PacketBuffer should have depleted the list.
EXPECT_EQ(1u, buffer.NumPacketsInBuffer()); // Only the last packet.
EXPECT_EQ(1, current_pt); // Current payload type changed to 0.
EXPECT_EQ(0xFF, current_cng_pt); // CNG payload type not changed.
EXPECT_EQ(rtc::Optional<uint8_t>(1),
current_pt); // Current payload type changed to 1.
EXPECT_FALSE(current_cng_pt); // CNG payload type not changed.
buffer.Flush(); // Clean up.
@ -341,8 +343,8 @@ TEST(PacketBuffer, Reordering) {
}
MockDecoderDatabase decoder_database;
uint8_t current_pt = 0xFF;
uint8_t current_cng_pt = 0xFF;
rtc::Optional<uint8_t> current_pt;
rtc::Optional<uint8_t> current_cng_pt;
EXPECT_EQ(PacketBuffer::kOK, buffer.InsertPacketList(&list,
decoder_database,
@ -412,8 +414,8 @@ TEST(PacketBuffer, Failures) {
list.push_back(packet);
list.push_back(gen.NextPacket(payload_len)); // Valid packet.
MockDecoderDatabase decoder_database;
uint8_t current_pt = 0xFF;
uint8_t current_cng_pt = 0xFF;
rtc::Optional<uint8_t> current_pt;
rtc::Optional<uint8_t> current_cng_pt;
EXPECT_EQ(PacketBuffer::kInvalidPacket,
buffer->InsertPacketList(&list,
decoder_database,