diff --git a/webrtc/modules/audio_coding/neteq/neteq_external_decoder_unittest.cc b/webrtc/modules/audio_coding/neteq/neteq_external_decoder_unittest.cc index 0ccba6d774..cc1374f00a 100644 --- a/webrtc/modules/audio_coding/neteq/neteq_external_decoder_unittest.cc +++ b/webrtc/modules/audio_coding/neteq/neteq_external_decoder_unittest.cc @@ -13,6 +13,7 @@ #include #include "webrtc/api/audio_codecs/builtin_audio_decoder_factory.h" +#include "webrtc/common_types.h" #include "webrtc/modules/audio_coding/neteq/mock/mock_external_decoder_pcm16b.h" #include "webrtc/modules/audio_coding/neteq/tools/input_audio_file.h" #include "webrtc/modules/audio_coding/neteq/tools/neteq_external_decoder_test.h" @@ -130,13 +131,12 @@ class NetEqExternalDecoderUnitTest : public test::NetEqExternalDecoderTest { } } - void InsertPacket(WebRtcRTPHeader rtp_header, + void InsertPacket(RTPHeader rtp_header, rtc::ArrayView payload, uint32_t receive_timestamp) override { - EXPECT_CALL( - *external_decoder_, - IncomingPacket(_, payload.size(), rtp_header.header.sequenceNumber, - rtp_header.header.timestamp, receive_timestamp)); + EXPECT_CALL(*external_decoder_, + IncomingPacket(_, payload.size(), rtp_header.sequenceNumber, + rtp_header.timestamp, receive_timestamp)); NetEqExternalDecoderTest::InsertPacket(rtp_header, payload, receive_timestamp); } @@ -159,7 +159,7 @@ class NetEqExternalDecoderUnitTest : public test::NetEqExternalDecoderTest { uint32_t last_send_time_; uint32_t last_arrival_time_; std::unique_ptr input_file_; - WebRtcRTPHeader rtp_header_; + RTPHeader rtp_header_; }; // This test encodes a few packets of PCM16b 32 kHz data and inserts it into two @@ -206,12 +206,12 @@ class NetEqExternalVsInternalDecoderTest : public NetEqExternalDecoderUnitTest, } } - void InsertPacket(WebRtcRTPHeader rtp_header, + void InsertPacket(RTPHeader rtp_header, rtc::ArrayView payload, uint32_t receive_timestamp) override { // Insert packet in internal decoder. - ASSERT_EQ(NetEq::kOK, neteq_internal_->InsertPacket( - rtp_header.header, payload, receive_timestamp)); + ASSERT_EQ(NetEq::kOK, neteq_internal_->InsertPacket(rtp_header, payload, + receive_timestamp)); // Insert packet in external decoder instance. NetEqExternalDecoderUnitTest::InsertPacket(rtp_header, payload, diff --git a/webrtc/modules/audio_coding/neteq/neteq_impl_unittest.cc b/webrtc/modules/audio_coding/neteq/neteq_impl_unittest.cc index 9897f691af..4e110a612d 100644 --- a/webrtc/modules/audio_coding/neteq/neteq_impl_unittest.cc +++ b/webrtc/modules/audio_coding/neteq/neteq_impl_unittest.cc @@ -12,6 +12,7 @@ #include "webrtc/api/audio_codecs/builtin_audio_decoder_factory.h" #include "webrtc/base/safe_conversions.h" +#include "webrtc/common_types.h" #include "webrtc/modules/audio_coding/neteq/accelerate.h" #include "webrtc/modules/audio_coding/neteq/expand.h" #include "webrtc/modules/audio_coding/neteq/include/neteq.h" @@ -182,18 +183,18 @@ class NetEqImplTest : public ::testing::Test { CreateInstance(); // Event: 2, E bit, Volume: 17, Length: 4336. uint8_t payload[kPayloadLength] = { 0x02, 0x80 + 0x11, 0x10, 0xF0 }; - WebRtcRTPHeader rtp_header; - rtp_header.header.payloadType = kPayloadType; - rtp_header.header.sequenceNumber = 0x1234; - rtp_header.header.timestamp = 0x12345678; - rtp_header.header.ssrc = 0x87654321; + RTPHeader rtp_header; + rtp_header.payloadType = kPayloadType; + rtp_header.sequenceNumber = 0x1234; + rtp_header.timestamp = 0x12345678; + rtp_header.ssrc = 0x87654321; EXPECT_EQ(NetEq::kOK, neteq_->RegisterPayloadType( decoder_type, "telephone-event", kPayloadType)); // Insert first packet. EXPECT_EQ(NetEq::kOK, - neteq_->InsertPacket(rtp_header.header, payload, kReceiveTime)); + neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); // Pull audio once. const size_t kMaxOutputSize = @@ -299,11 +300,11 @@ TEST_F(NetEqImplTest, InsertPacket) { const uint32_t kSsrc = 0x87654321; const uint32_t kFirstReceiveTime = 17; uint8_t payload[kPayloadLength] = {0}; - WebRtcRTPHeader rtp_header; - rtp_header.header.payloadType = kPayloadType; - rtp_header.header.sequenceNumber = kFirstSequenceNumber; - rtp_header.header.timestamp = kFirstTimestamp; - rtp_header.header.ssrc = kSsrc; + RTPHeader rtp_header; + rtp_header.payloadType = kPayloadType; + rtp_header.sequenceNumber = kFirstSequenceNumber; + rtp_header.timestamp = kFirstTimestamp; + rtp_header.ssrc = kSsrc; Packet fake_packet; fake_packet.payload_type = kPayloadType; fake_packet.sequence_number = kFirstSequenceNumber; @@ -384,12 +385,12 @@ TEST_F(NetEqImplTest, InsertPacket) { } // Insert first packet. - neteq_->InsertPacket(rtp_header.header, payload, kFirstReceiveTime); + neteq_->InsertPacket(rtp_header, payload, kFirstReceiveTime); // Insert second packet. - rtp_header.header.timestamp += 160; - rtp_header.header.sequenceNumber += 1; - neteq_->InsertPacket(rtp_header.header, payload, kFirstReceiveTime + 155); + rtp_header.timestamp += 160; + rtp_header.sequenceNumber += 1; + neteq_->InsertPacket(rtp_header, payload, kFirstReceiveTime + 155); } TEST_F(NetEqImplTest, InsertPacketsUntilBufferIsFull) { @@ -401,11 +402,11 @@ TEST_F(NetEqImplTest, InsertPacketsUntilBufferIsFull) { const uint8_t kPayloadType = 17; // Just an arbitrary number. const uint32_t kReceiveTime = 17; // Value doesn't matter for this test. uint8_t payload[kPayloadLengthBytes] = {0}; - WebRtcRTPHeader rtp_header; - rtp_header.header.payloadType = kPayloadType; - rtp_header.header.sequenceNumber = 0x1234; - rtp_header.header.timestamp = 0x12345678; - rtp_header.header.ssrc = 0x87654321; + RTPHeader rtp_header; + rtp_header.payloadType = kPayloadType; + rtp_header.sequenceNumber = 0x1234; + rtp_header.timestamp = 0x12345678; + rtp_header.ssrc = 0x87654321; EXPECT_EQ(NetEq::kOK, neteq_->RegisterPayloadType( NetEqDecoder::kDecoderPCM16B, "", kPayloadType)); @@ -413,20 +414,20 @@ TEST_F(NetEqImplTest, InsertPacketsUntilBufferIsFull) { // Insert packets. The buffer should not flush. for (size_t i = 1; i <= config_.max_packets_in_buffer; ++i) { EXPECT_EQ(NetEq::kOK, - neteq_->InsertPacket(rtp_header.header, payload, kReceiveTime)); - rtp_header.header.timestamp += kPayloadLengthSamples; - rtp_header.header.sequenceNumber += 1; + neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); + rtp_header.timestamp += kPayloadLengthSamples; + rtp_header.sequenceNumber += 1; EXPECT_EQ(i, packet_buffer_->NumPacketsInBuffer()); } // Insert one more packet and make sure the buffer got flushed. That is, it // should only hold one single packet. EXPECT_EQ(NetEq::kOK, - neteq_->InsertPacket(rtp_header.header, payload, kReceiveTime)); + neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); EXPECT_EQ(1u, packet_buffer_->NumPacketsInBuffer()); const Packet* test_packet = packet_buffer_->PeekNextPacket(); - EXPECT_EQ(rtp_header.header.timestamp, test_packet->timestamp); - EXPECT_EQ(rtp_header.header.sequenceNumber, test_packet->sequence_number); + EXPECT_EQ(rtp_header.timestamp, test_packet->timestamp); + EXPECT_EQ(rtp_header.sequenceNumber, test_packet->sequence_number); } TEST_F(NetEqImplTest, TestDtmfPacketAVT) { @@ -458,11 +459,11 @@ TEST_F(NetEqImplTest, VerifyTimestampPropagation) { static_cast(10 * kSampleRateHz / 1000); // 10 ms. const size_t kPayloadLengthBytes = kPayloadLengthSamples; uint8_t payload[kPayloadLengthBytes] = {0}; - WebRtcRTPHeader rtp_header; - rtp_header.header.payloadType = kPayloadType; - rtp_header.header.sequenceNumber = 0x1234; - rtp_header.header.timestamp = 0x12345678; - rtp_header.header.ssrc = 0x87654321; + RTPHeader rtp_header; + rtp_header.payloadType = kPayloadType; + rtp_header.sequenceNumber = 0x1234; + rtp_header.timestamp = 0x12345678; + rtp_header.ssrc = 0x87654321; // This is a dummy decoder that produces as many output samples as the input // has bytes. The output is an increasing series, starting at 1 for the first @@ -502,7 +503,7 @@ TEST_F(NetEqImplTest, VerifyTimestampPropagation) { // Insert one packet. EXPECT_EQ(NetEq::kOK, - neteq_->InsertPacket(rtp_header.header, payload, kReceiveTime)); + neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); // Pull audio once. const size_t kMaxOutputSize = static_cast(10 * kSampleRateHz / 1000); @@ -523,7 +524,7 @@ TEST_F(NetEqImplTest, VerifyTimestampPropagation) { // timestamp should match the playout timestamp. // Wrap the expected value in an rtc::Optional to compare them as such. EXPECT_EQ( - rtc::Optional(rtp_header.header.timestamp + + rtc::Optional(rtp_header.timestamp + output.data_[output.samples_per_channel_ - 1]), neteq_->GetPlayoutTimestamp()); @@ -531,7 +532,7 @@ TEST_F(NetEqImplTest, VerifyTimestampPropagation) { // be one full frame length ahead of the RTP timestamp. const SyncBuffer* sync_buffer = neteq_->sync_buffer_for_test(); ASSERT_TRUE(sync_buffer != NULL); - EXPECT_EQ(rtp_header.header.timestamp + kPayloadLengthSamples, + EXPECT_EQ(rtp_header.timestamp + kPayloadLengthSamples, sync_buffer->end_timestamp()); // Check that the number of samples still to play from the sync buffer add @@ -552,11 +553,11 @@ TEST_F(NetEqImplTest, ReorderedPacket) { static_cast(10 * kSampleRateHz / 1000); // 10 ms. const size_t kPayloadLengthBytes = kPayloadLengthSamples; uint8_t payload[kPayloadLengthBytes] = {0}; - WebRtcRTPHeader rtp_header; - rtp_header.header.payloadType = kPayloadType; - rtp_header.header.sequenceNumber = 0x1234; - rtp_header.header.timestamp = 0x12345678; - rtp_header.header.ssrc = 0x87654321; + RTPHeader rtp_header; + rtp_header.payloadType = kPayloadType; + rtp_header.sequenceNumber = 0x1234; + rtp_header.timestamp = 0x12345678; + rtp_header.ssrc = 0x87654321; // Create a mock decoder object. MockAudioDecoder mock_decoder; @@ -583,7 +584,7 @@ TEST_F(NetEqImplTest, ReorderedPacket) { // Insert one packet. EXPECT_EQ(NetEq::kOK, - neteq_->InsertPacket(rtp_header.header, payload, kReceiveTime)); + neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); // Pull audio once. const size_t kMaxOutputSize = static_cast(10 * kSampleRateHz / 1000); @@ -596,16 +597,16 @@ TEST_F(NetEqImplTest, ReorderedPacket) { // Insert two more packets. The first one is out of order, and is already too // old, the second one is the expected next packet. - rtp_header.header.sequenceNumber -= 1; - rtp_header.header.timestamp -= kPayloadLengthSamples; + rtp_header.sequenceNumber -= 1; + rtp_header.timestamp -= kPayloadLengthSamples; payload[0] = 1; EXPECT_EQ(NetEq::kOK, - neteq_->InsertPacket(rtp_header.header, payload, kReceiveTime)); - rtp_header.header.sequenceNumber += 2; - rtp_header.header.timestamp += 2 * kPayloadLengthSamples; + neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); + rtp_header.sequenceNumber += 2; + rtp_header.timestamp += 2 * kPayloadLengthSamples; payload[0] = 2; EXPECT_EQ(NetEq::kOK, - neteq_->InsertPacket(rtp_header.header, payload, kReceiveTime)); + neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); // Expect only the second packet to be decoded (the one with "2" as the first // payload byte). @@ -642,16 +643,16 @@ TEST_F(NetEqImplTest, FirstPacketUnknown) { static_cast(10 * kSampleRateHz / 1000); // 10 ms. const size_t kPayloadLengthBytes = kPayloadLengthSamples * 2; uint8_t payload[kPayloadLengthBytes] = {0}; - WebRtcRTPHeader rtp_header; - rtp_header.header.payloadType = kPayloadType; - rtp_header.header.sequenceNumber = 0x1234; - rtp_header.header.timestamp = 0x12345678; - rtp_header.header.ssrc = 0x87654321; + RTPHeader rtp_header; + rtp_header.payloadType = kPayloadType; + rtp_header.sequenceNumber = 0x1234; + rtp_header.timestamp = 0x12345678; + rtp_header.ssrc = 0x87654321; // Insert one packet. Note that we have not registered any payload type, so // this packet will be rejected. EXPECT_EQ(NetEq::kFail, - neteq_->InsertPacket(rtp_header.header, payload, kReceiveTime)); + neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); EXPECT_EQ(NetEq::kUnknownRtpPayloadType, neteq_->LastError()); // Pull audio once. @@ -670,10 +671,10 @@ TEST_F(NetEqImplTest, FirstPacketUnknown) { // Insert 10 packets. for (size_t i = 0; i < 10; ++i) { - rtp_header.header.sequenceNumber++; - rtp_header.header.timestamp += kPayloadLengthSamples; + rtp_header.sequenceNumber++; + rtp_header.timestamp += kPayloadLengthSamples; EXPECT_EQ(NetEq::kOK, - neteq_->InsertPacket(rtp_header.header, payload, kReceiveTime)); + neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); EXPECT_EQ(i + 1, packet_buffer_->NumPacketsInBuffer()); } @@ -703,11 +704,11 @@ TEST_F(NetEqImplTest, CodecInternalCng) { uint8_t payload[kPayloadLengthBytes] = {0}; int16_t dummy_output[kPayloadLengthSamples] = {0}; - WebRtcRTPHeader rtp_header; - rtp_header.header.payloadType = kPayloadType; - rtp_header.header.sequenceNumber = 0x1234; - rtp_header.header.timestamp = 0x12345678; - rtp_header.header.ssrc = 0x87654321; + RTPHeader rtp_header; + rtp_header.payloadType = kPayloadType; + rtp_header.sequenceNumber = 0x1234; + rtp_header.timestamp = 0x12345678; + rtp_header.ssrc = 0x87654321; // Create a mock decoder object. MockAudioDecoder mock_decoder; @@ -760,14 +761,14 @@ TEST_F(NetEqImplTest, CodecInternalCng) { // Insert one packet (decoder will return speech). EXPECT_EQ(NetEq::kOK, - neteq_->InsertPacket(rtp_header.header, payload, kReceiveTime)); + neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); // Insert second packet (decoder will return CNG). payload[0] = 1; - rtp_header.header.sequenceNumber++; - rtp_header.header.timestamp += kPayloadLengthSamples; + rtp_header.sequenceNumber++; + rtp_header.timestamp += kPayloadLengthSamples; EXPECT_EQ(NetEq::kOK, - neteq_->InsertPacket(rtp_header.header, payload, kReceiveTime)); + neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); const size_t kMaxOutputSize = static_cast(10 * kSampleRateKhz); AudioFrame output; @@ -815,10 +816,10 @@ TEST_F(NetEqImplTest, CodecInternalCng) { // Insert third packet, which leaves a gap from last packet. payload[0] = 2; - rtp_header.header.sequenceNumber += 2; - rtp_header.header.timestamp += 2 * kPayloadLengthSamples; + rtp_header.sequenceNumber += 2; + rtp_header.timestamp += 2 * kPayloadLengthSamples; EXPECT_EQ(NetEq::kOK, - neteq_->InsertPacket(rtp_header.header, payload, kReceiveTime)); + neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); for (size_t i = 6; i < 8; ++i) { ASSERT_EQ(kMaxOutputSize, output.samples_per_channel_); @@ -850,11 +851,11 @@ TEST_F(NetEqImplTest, UnsupportedDecoder) { const size_t kPayloadLengthBytes = 1; uint8_t payload[kPayloadLengthBytes] = {0}; int16_t dummy_output[kPayloadLengthSamples * kChannels] = {0}; - WebRtcRTPHeader rtp_header; - rtp_header.header.payloadType = kPayloadType; - rtp_header.header.sequenceNumber = 0x1234; - rtp_header.header.timestamp = 0x12345678; - rtp_header.header.ssrc = 0x87654321; + RTPHeader rtp_header; + rtp_header.payloadType = kPayloadType; + rtp_header.sequenceNumber = 0x1234; + rtp_header.timestamp = 0x12345678; + rtp_header.ssrc = 0x87654321; ::testing::NiceMock decoder; @@ -896,16 +897,16 @@ TEST_F(NetEqImplTest, UnsupportedDecoder) { // Insert one packet. payload[0] = kFirstPayloadValue; // This will make Decode() fail. EXPECT_EQ(NetEq::kOK, - neteq_->InsertPacket(rtp_header.header, payload, kReceiveTime)); + neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); // Insert another packet. payload[0] = kSecondPayloadValue; // This will make Decode() successful. - rtp_header.header.sequenceNumber++; + rtp_header.sequenceNumber++; // The second timestamp needs to be at least 30 ms after the first to make // the second packet get decoded. - rtp_header.header.timestamp += 3 * kPayloadLengthSamples; + rtp_header.timestamp += 3 * kPayloadLengthSamples; EXPECT_EQ(NetEq::kOK, - neteq_->InsertPacket(rtp_header.header, payload, kReceiveTime)); + neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); AudioFrame output; bool muted; @@ -944,11 +945,11 @@ TEST_F(NetEqImplTest, FloodBufferAndGetNetworkStats) { const uint8_t kPayloadType = 17; // Just an arbitrary number. const uint32_t kReceiveTime = 17; // Value doesn't matter for this test. uint8_t payload[kPayloadLengthBytes] = {0}; - WebRtcRTPHeader rtp_header; - rtp_header.header.payloadType = kPayloadType; - rtp_header.header.sequenceNumber = 0x1234; - rtp_header.header.timestamp = 0x12345678; - rtp_header.header.ssrc = 0x87654321; + RTPHeader rtp_header; + rtp_header.payloadType = kPayloadType; + rtp_header.sequenceNumber = 0x1234; + rtp_header.timestamp = 0x12345678; + rtp_header.ssrc = 0x87654321; EXPECT_EQ(NetEq::kOK, neteq_->RegisterPayloadType( NetEqDecoder::kDecoderPCM16B, "", kPayloadType)); @@ -957,10 +958,9 @@ TEST_F(NetEqImplTest, FloodBufferAndGetNetworkStats) { for (size_t i = 0; i <= config_.max_packets_in_buffer; ++i) { EXPECT_EQ(i, packet_buffer_->NumPacketsInBuffer()); EXPECT_EQ(NetEq::kOK, - neteq_->InsertPacket(rtp_header.header, payload, kReceiveTime)); - rtp_header.header.timestamp += - rtc::checked_cast(kPayloadLengthSamples); - ++rtp_header.header.sequenceNumber; + neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); + rtp_header.timestamp += rtc::checked_cast(kPayloadLengthSamples); + ++rtp_header.sequenceNumber; } EXPECT_EQ(1u, packet_buffer_->NumPacketsInBuffer()); @@ -980,11 +980,11 @@ TEST_F(NetEqImplTest, DecodedPayloadTooShort) { static_cast(10 * kSampleRateHz / 1000); // 10 ms. const size_t kPayloadLengthBytes = 2 * kPayloadLengthSamples; uint8_t payload[kPayloadLengthBytes] = {0}; - WebRtcRTPHeader rtp_header; - rtp_header.header.payloadType = kPayloadType; - rtp_header.header.sequenceNumber = 0x1234; - rtp_header.header.timestamp = 0x12345678; - rtp_header.header.ssrc = 0x87654321; + RTPHeader rtp_header; + rtp_header.payloadType = kPayloadType; + rtp_header.sequenceNumber = 0x1234; + rtp_header.timestamp = 0x12345678; + rtp_header.ssrc = 0x87654321; // Create a mock decoder object. MockAudioDecoder mock_decoder; @@ -1013,7 +1013,7 @@ TEST_F(NetEqImplTest, DecodedPayloadTooShort) { // Insert one packet. EXPECT_EQ(NetEq::kOK, - neteq_->InsertPacket(rtp_header.header, payload, kReceiveTime)); + neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); EXPECT_EQ(5u, neteq_->sync_buffer_for_test()->FutureLength()); @@ -1047,11 +1047,11 @@ TEST_F(NetEqImplTest, DecodingError) { uint8_t payload[kPayloadLengthBytes] = {0}; - WebRtcRTPHeader rtp_header; - rtp_header.header.payloadType = kPayloadType; - rtp_header.header.sequenceNumber = 0x1234; - rtp_header.header.timestamp = 0x12345678; - rtp_header.header.ssrc = 0x87654321; + RTPHeader rtp_header; + rtp_header.payloadType = kPayloadType; + rtp_header.sequenceNumber = 0x1234; + rtp_header.timestamp = 0x12345678; + rtp_header.ssrc = 0x87654321; // Create a mock decoder object. MockAudioDecoder mock_decoder; @@ -1106,10 +1106,10 @@ TEST_F(NetEqImplTest, DecodingError) { // Insert packets. for (int i = 0; i < 6; ++i) { - rtp_header.header.sequenceNumber += 1; - rtp_header.header.timestamp += kFrameLengthSamples; + rtp_header.sequenceNumber += 1; + rtp_header.timestamp += kFrameLengthSamples; EXPECT_EQ(NetEq::kOK, - neteq_->InsertPacket(rtp_header.header, payload, kReceiveTime)); + neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); } // Pull audio. @@ -1163,11 +1163,11 @@ TEST_F(NetEqImplTest, DecodingErrorDuringInternalCng) { uint8_t payload[kPayloadLengthBytes] = {0}; - WebRtcRTPHeader rtp_header; - rtp_header.header.payloadType = kPayloadType; - rtp_header.header.sequenceNumber = 0x1234; - rtp_header.header.timestamp = 0x12345678; - rtp_header.header.ssrc = 0x87654321; + RTPHeader rtp_header; + rtp_header.payloadType = kPayloadType; + rtp_header.sequenceNumber = 0x1234; + rtp_header.timestamp = 0x12345678; + rtp_header.ssrc = 0x87654321; // Create a mock decoder object. MockAudioDecoder mock_decoder; @@ -1218,10 +1218,10 @@ TEST_F(NetEqImplTest, DecodingErrorDuringInternalCng) { // Insert 2 packets. This will make netEq into codec internal CNG mode. for (int i = 0; i < 2; ++i) { - rtp_header.header.sequenceNumber += 1; - rtp_header.header.timestamp += kFrameLengthSamples; + rtp_header.sequenceNumber += 1; + rtp_header.timestamp += kFrameLengthSamples; EXPECT_EQ(NetEq::kOK, - neteq_->InsertPacket(rtp_header.header, payload, kReceiveTime)); + neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); } // Pull audio. @@ -1334,14 +1334,14 @@ class NetEqImplTest120ms : public NetEqImplTest { } void InsertPacket(uint32_t timestamp) { - WebRtcRTPHeader rtp_header; - rtp_header.header.payloadType = kPayloadType; - rtp_header.header.sequenceNumber = sequence_number_; - rtp_header.header.timestamp = timestamp; - rtp_header.header.ssrc = 15; + RTPHeader rtp_header; + rtp_header.payloadType = kPayloadType; + rtp_header.sequenceNumber = sequence_number_; + rtp_header.timestamp = timestamp; + rtp_header.ssrc = 15; const size_t kPayloadLengthBytes = 1; // This can be arbitrary. uint8_t payload[kPayloadLengthBytes] = {0}; - EXPECT_EQ(NetEq::kOK, neteq_->InsertPacket(rtp_header.header, payload, 10)); + EXPECT_EQ(NetEq::kOK, neteq_->InsertPacket(rtp_header, payload, 10)); sequence_number_++; } diff --git a/webrtc/modules/audio_coding/neteq/neteq_network_stats_unittest.cc b/webrtc/modules/audio_coding/neteq/neteq_network_stats_unittest.cc index 82269bc8fb..c244a97355 100644 --- a/webrtc/modules/audio_coding/neteq/neteq_network_stats_unittest.cc +++ b/webrtc/modules/audio_coding/neteq/neteq_network_stats_unittest.cc @@ -10,6 +10,7 @@ #include +#include "webrtc/common_types.h" #include "webrtc/modules/audio_coding/neteq/tools/neteq_external_decoder_test.h" #include "webrtc/modules/audio_coding/neteq/tools/rtp_generator.h" #include "webrtc/modules/include/module_common_types.h" @@ -304,7 +305,7 @@ NetEqNetworkStatsTest(NetEqDecoder codec, const int samples_per_ms_; const size_t frame_size_samples_; std::unique_ptr rtp_generator_; - WebRtcRTPHeader rtp_header_; + RTPHeader rtp_header_; uint32_t last_lost_time_; uint32_t packet_loss_interval_; AudioFrame output_frame_; diff --git a/webrtc/modules/audio_coding/neteq/neteq_stereo_unittest.cc b/webrtc/modules/audio_coding/neteq/neteq_stereo_unittest.cc index 73c25a4570..37a078308c 100644 --- a/webrtc/modules/audio_coding/neteq/neteq_stereo_unittest.cc +++ b/webrtc/modules/audio_coding/neteq/neteq_stereo_unittest.cc @@ -16,6 +16,7 @@ #include #include "webrtc/api/audio_codecs/builtin_audio_decoder_factory.h" +#include "webrtc/common_types.h" #include "webrtc/modules/audio_coding/codecs/pcm16b/pcm16b.h" #include "webrtc/modules/audio_coding/neteq/include/neteq.h" #include "webrtc/modules/audio_coding/neteq/tools/input_audio_file.h" @@ -197,14 +198,14 @@ class NetEqStereoTest : public ::testing::TestWithParam { while (time_now >= next_arrival_time) { // Insert packet in mono instance. ASSERT_EQ(NetEq::kOK, - neteq_mono_->InsertPacket(rtp_header_mono_.header, + neteq_mono_->InsertPacket(rtp_header_mono_, rtc::ArrayView( encoded_, payload_size_bytes_), next_arrival_time)); // Insert packet in multi-channel instance. ASSERT_EQ(NetEq::kOK, neteq_->InsertPacket( - rtp_header_.header, + rtp_header_, rtc::ArrayView(encoded_multi_channel_, multi_payload_size_bytes_), next_arrival_time)); @@ -253,8 +254,8 @@ class NetEqStereoTest : public ::testing::TestWithParam { uint8_t* encoded_multi_channel_; AudioFrame output_; AudioFrame output_multi_channel_; - WebRtcRTPHeader rtp_header_mono_; - WebRtcRTPHeader rtp_header_; + RTPHeader rtp_header_mono_; + RTPHeader rtp_header_; size_t payload_size_bytes_; size_t multi_payload_size_bytes_; int last_send_time_; diff --git a/webrtc/modules/audio_coding/neteq/neteq_unittest.cc b/webrtc/modules/audio_coding/neteq/neteq_unittest.cc index 1a54c54c39..68a4921147 100644 --- a/webrtc/modules/audio_coding/neteq/neteq_unittest.cc +++ b/webrtc/modules/audio_coding/neteq/neteq_unittest.cc @@ -23,9 +23,10 @@ #include "gflags/gflags.h" #include "webrtc/api/audio_codecs/builtin_audio_decoder_factory.h" #include "webrtc/base/ignore_wundef.h" +#include "webrtc/base/protobuf_utils.h" #include "webrtc/base/sha1digest.h" #include "webrtc/base/stringencode.h" -#include "webrtc/base/protobuf_utils.h" +#include "webrtc/common_types.h" #include "webrtc/modules/audio_coding/codecs/pcm16b/pcm16b.h" #include "webrtc/modules/audio_coding/neteq/tools/audio_loop.h" #include "webrtc/modules/audio_coding/neteq/tools/rtp_file_source.h" @@ -250,10 +251,10 @@ class NetEqDecodingTest : public ::testing::Test { static void PopulateRtpInfo(int frame_index, int timestamp, - WebRtcRTPHeader* rtp_info); + RTPHeader* rtp_info); static void PopulateCng(int frame_index, int timestamp, - WebRtcRTPHeader* rtp_info, + RTPHeader* rtp_info, uint8_t* payload, size_t* payload_len); @@ -318,15 +319,13 @@ void NetEqDecodingTest::Process() { // Check if time to receive. while (packet_ && sim_clock_ >= packet_->time_ms()) { if (packet_->payload_length_bytes() > 0) { - WebRtcRTPHeader rtp_header; - packet_->ConvertHeader(&rtp_header); #ifndef WEBRTC_CODEC_ISAC // Ignore payload type 104 (iSAC-swb) if ISAC is not supported. - if (rtp_header.header.payloadType != 104) + if (packet_->header().payloadType != 104) #endif ASSERT_EQ(0, neteq_->InsertPacket( - rtp_header.header, + packet_->header(), rtc::ArrayView( packet_->payload(), packet_->payload_length_bytes()), static_cast(packet_->time_ms() * @@ -409,24 +408,24 @@ void NetEqDecodingTest::DecodeAndCompare( void NetEqDecodingTest::PopulateRtpInfo(int frame_index, int timestamp, - WebRtcRTPHeader* rtp_info) { - rtp_info->header.sequenceNumber = frame_index; - rtp_info->header.timestamp = timestamp; - rtp_info->header.ssrc = 0x1234; // Just an arbitrary SSRC. - rtp_info->header.payloadType = 94; // PCM16b WB codec. - rtp_info->header.markerBit = 0; + RTPHeader* rtp_info) { + rtp_info->sequenceNumber = frame_index; + rtp_info->timestamp = timestamp; + rtp_info->ssrc = 0x1234; // Just an arbitrary SSRC. + rtp_info->payloadType = 94; // PCM16b WB codec. + rtp_info->markerBit = 0; } void NetEqDecodingTest::PopulateCng(int frame_index, int timestamp, - WebRtcRTPHeader* rtp_info, + RTPHeader* rtp_info, uint8_t* payload, size_t* payload_len) { - rtp_info->header.sequenceNumber = frame_index; - rtp_info->header.timestamp = timestamp; - rtp_info->header.ssrc = 0x1234; // Just an arbitrary SSRC. - rtp_info->header.payloadType = 98; // WB CNG. - rtp_info->header.markerBit = 0; + rtp_info->sequenceNumber = frame_index; + rtp_info->timestamp = timestamp; + rtp_info->ssrc = 0x1234; // Just an arbitrary SSRC. + rtp_info->payloadType = 98; // WB CNG. + rtp_info->markerBit = 0; payload[0] = 64; // Noise level -64 dBov, quite arbitrarily chosen. *payload_len = 1; // Only noise level, no spectral parameters. } @@ -521,13 +520,13 @@ TEST_F(NetEqDecodingTestFaxMode, TestFrameWaitingTimeStatistics) { const size_t kPayloadBytes = kSamples * 2; for (size_t i = 0; i < num_frames; ++i) { const uint8_t payload[kPayloadBytes] = {0}; - WebRtcRTPHeader rtp_info; - rtp_info.header.sequenceNumber = i; - rtp_info.header.timestamp = i * kSamples; - rtp_info.header.ssrc = 0x1234; // Just an arbitrary SSRC. - rtp_info.header.payloadType = 94; // PCM16b WB codec. - rtp_info.header.markerBit = 0; - ASSERT_EQ(0, neteq_->InsertPacket(rtp_info.header, payload, 0)); + RTPHeader rtp_info; + rtp_info.sequenceNumber = i; + rtp_info.timestamp = i * kSamples; + rtp_info.ssrc = 0x1234; // Just an arbitrary SSRC. + rtp_info.payloadType = 94; // PCM16b WB codec. + rtp_info.markerBit = 0; + ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); } // Pull out all data. for (size_t i = 0; i < num_frames; ++i) { @@ -566,9 +565,9 @@ TEST_F(NetEqDecodingTest, TestAverageInterArrivalTimeNegative) { int num_packets = (frame_index % 10 == 0 ? 2 : 1); for (int n = 0; n < num_packets; ++n) { uint8_t payload[kPayloadBytes] = {0}; - WebRtcRTPHeader rtp_info; + RTPHeader rtp_info; PopulateRtpInfo(frame_index, frame_index * kSamples, &rtp_info); - ASSERT_EQ(0, neteq_->InsertPacket(rtp_info.header, payload, 0)); + ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); ++frame_index; } @@ -594,9 +593,9 @@ TEST_F(NetEqDecodingTest, TestAverageInterArrivalTimePositive) { int num_packets = (i % 10 == 9 ? 0 : 1); for (int n = 0; n < num_packets; ++n) { uint8_t payload[kPayloadBytes] = {0}; - WebRtcRTPHeader rtp_info; + RTPHeader rtp_info; PopulateRtpInfo(frame_index, frame_index * kSamples, &rtp_info); - ASSERT_EQ(0, neteq_->InsertPacket(rtp_info.header, payload, 0)); + ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); ++frame_index; } @@ -632,9 +631,9 @@ void NetEqDecodingTest::LongCngWithClockDrift(double drift_factor, while (next_input_time_ms <= t_ms) { // Insert one 30 ms speech frame. uint8_t payload[kPayloadBytes] = {0}; - WebRtcRTPHeader rtp_info; + RTPHeader rtp_info; PopulateRtpInfo(seq_no, timestamp, &rtp_info); - ASSERT_EQ(0, neteq_->InsertPacket(rtp_info.header, payload, 0)); + ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); ++seq_no; timestamp += kSamples; next_input_time_ms += static_cast(kFrameSizeMs) * drift_factor; @@ -659,10 +658,10 @@ void NetEqDecodingTest::LongCngWithClockDrift(double drift_factor, // Insert one CNG frame each 100 ms. uint8_t payload[kPayloadBytes]; size_t payload_len; - WebRtcRTPHeader rtp_info; + RTPHeader rtp_info; PopulateCng(seq_no, timestamp, &rtp_info, payload, &payload_len); ASSERT_EQ(0, neteq_->InsertPacket( - rtp_info.header, + rtp_info, rtc::ArrayView(payload, payload_len), 0)); ++seq_no; timestamp += kCngPeriodSamples; @@ -702,10 +701,10 @@ void NetEqDecodingTest::LongCngWithClockDrift(double drift_factor, // Insert one CNG frame each 100 ms. uint8_t payload[kPayloadBytes]; size_t payload_len; - WebRtcRTPHeader rtp_info; + RTPHeader rtp_info; PopulateCng(seq_no, timestamp, &rtp_info, payload, &payload_len); ASSERT_EQ(0, neteq_->InsertPacket( - rtp_info.header, + rtp_info, rtc::ArrayView(payload, payload_len), 0)); ++seq_no; timestamp += kCngPeriodSamples; @@ -720,9 +719,9 @@ void NetEqDecodingTest::LongCngWithClockDrift(double drift_factor, while (next_input_time_ms <= t_ms) { // Insert one 30 ms speech frame. uint8_t payload[kPayloadBytes] = {0}; - WebRtcRTPHeader rtp_info; + RTPHeader rtp_info; PopulateRtpInfo(seq_no, timestamp, &rtp_info); - ASSERT_EQ(0, neteq_->InsertPacket(rtp_info.header, payload, 0)); + ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); ++seq_no; timestamp += kSamples; next_input_time_ms += kFrameSizeMs * drift_factor; @@ -831,10 +830,10 @@ TEST_F(NetEqDecodingTest, LongCngWithoutClockDrift) { TEST_F(NetEqDecodingTest, UnknownPayloadType) { const size_t kPayloadBytes = 100; uint8_t payload[kPayloadBytes] = {0}; - WebRtcRTPHeader rtp_info; + RTPHeader rtp_info; PopulateRtpInfo(0, 0, &rtp_info); - rtp_info.header.payloadType = 1; // Not registered as a decoder. - EXPECT_EQ(NetEq::kFail, neteq_->InsertPacket(rtp_info.header, payload, 0)); + rtp_info.payloadType = 1; // Not registered as a decoder. + EXPECT_EQ(NetEq::kFail, neteq_->InsertPacket(rtp_info, payload, 0)); EXPECT_EQ(NetEq::kUnknownRtpPayloadType, neteq_->LastError()); } @@ -847,10 +846,10 @@ TEST_F(NetEqDecodingTest, UnknownPayloadType) { TEST_F(NetEqDecodingTest, MAYBE_DecoderError) { const size_t kPayloadBytes = 100; uint8_t payload[kPayloadBytes] = {0}; - WebRtcRTPHeader rtp_info; + RTPHeader rtp_info; PopulateRtpInfo(0, 0, &rtp_info); - rtp_info.header.payloadType = 103; // iSAC, but the payload is invalid. - EXPECT_EQ(0, neteq_->InsertPacket(rtp_info.header, payload, 0)); + rtp_info.payloadType = 103; // iSAC, but the payload is invalid. + EXPECT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); // Set all of |out_data_| to 1, and verify that it was set to 0 by the call // to GetAudio. for (size_t i = 0; i < AudioFrame::kMaxDataSizeSamples; ++i) { @@ -944,9 +943,9 @@ class NetEqBgnTest : public NetEqDecodingTest { // Payload of 10 ms of PCM16 32 kHz. uint8_t payload[kBlockSize32kHz * sizeof(int16_t)]; - WebRtcRTPHeader rtp_info; + RTPHeader rtp_info; PopulateRtpInfo(0, 0, &rtp_info); - rtp_info.header.payloadType = payload_type; + rtp_info.payloadType = payload_type; uint32_t receive_timestamp = 0; bool muted; @@ -958,7 +957,7 @@ class NetEqBgnTest : public NetEqDecodingTest { ASSERT_EQ(enc_len_bytes, expected_samples_per_channel * 2); ASSERT_EQ(0, neteq_->InsertPacket( - rtp_info.header, + rtp_info, rtc::ArrayView(payload, enc_len_bytes), receive_timestamp)); output.Reset(); @@ -968,8 +967,8 @@ class NetEqBgnTest : public NetEqDecodingTest { ASSERT_EQ(AudioFrame::kNormalSpeech, output.speech_type_); // Next packet. - rtp_info.header.timestamp += expected_samples_per_channel; - rtp_info.header.sequenceNumber++; + rtp_info.timestamp += expected_samples_per_channel; + rtp_info.sequenceNumber++; receive_timestamp += expected_samples_per_channel; } @@ -1090,12 +1089,12 @@ void NetEqDecodingTest::WrapTest(uint16_t start_seq_no, while (next_input_time_ms <= t_ms) { // Insert one 30 ms speech frame. uint8_t payload[kPayloadBytes] = {0}; - WebRtcRTPHeader rtp_info; + RTPHeader rtp_info; PopulateRtpInfo(seq_no, timestamp, &rtp_info); if (drop_seq_numbers.find(seq_no) == drop_seq_numbers.end()) { // This sequence number was not in the set to drop. Insert it. - ASSERT_EQ(0, neteq_->InsertPacket(rtp_info.header, payload, - receive_timestamp)); + ASSERT_EQ(0, + neteq_->InsertPacket(rtp_info, payload, receive_timestamp)); ++packets_inserted; } NetEqNetworkStatistics network_stats; @@ -1179,11 +1178,11 @@ void NetEqDecodingTest::DuplicateCng() { // Insert three speech packets. Three are needed to get the frame length // correct. uint8_t payload[kPayloadBytes] = {0}; - WebRtcRTPHeader rtp_info; + RTPHeader rtp_info; bool muted; for (int i = 0; i < 3; ++i) { PopulateRtpInfo(seq_no, timestamp, &rtp_info); - ASSERT_EQ(0, neteq_->InsertPacket(rtp_info.header, payload, 0)); + ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); ++seq_no; timestamp += kSamples; @@ -1200,9 +1199,9 @@ void NetEqDecodingTest::DuplicateCng() { size_t payload_len; PopulateCng(seq_no, timestamp, &rtp_info, payload, &payload_len); // This is the first time this CNG packet is inserted. - ASSERT_EQ(0, neteq_->InsertPacket( - rtp_info.header, - rtc::ArrayView(payload, payload_len), 0)); + ASSERT_EQ( + 0, neteq_->InsertPacket( + rtp_info, rtc::ArrayView(payload, payload_len), 0)); // Pull audio once and make sure CNG is played. ASSERT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); @@ -1214,9 +1213,9 @@ void NetEqDecodingTest::DuplicateCng() { // Insert the same CNG packet again. Note that at this point it is old, since // we have already decoded the first copy of it. - ASSERT_EQ(0, neteq_->InsertPacket( - rtp_info.header, - rtc::ArrayView(payload, payload_len), 0)); + ASSERT_EQ( + 0, neteq_->InsertPacket( + rtp_info, rtc::ArrayView(payload, payload_len), 0)); // Pull audio until we have played |kCngPeriodMs| of CNG. Start at 10 ms since // we have already pulled out CNG once. @@ -1233,7 +1232,7 @@ void NetEqDecodingTest::DuplicateCng() { ++seq_no; timestamp += kCngPeriodSamples; PopulateRtpInfo(seq_no, timestamp, &rtp_info); - ASSERT_EQ(0, neteq_->InsertPacket(rtp_info.header, payload, 0)); + ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); // Pull audio once and verify that the output is speech again. ASSERT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); @@ -1263,13 +1262,13 @@ TEST_F(NetEqDecodingTest, CngFirst) { size_t payload_len; uint8_t payload[kPayloadBytes] = {0}; - WebRtcRTPHeader rtp_info; + RTPHeader rtp_info; PopulateCng(seq_no, timestamp, &rtp_info, payload, &payload_len); - ASSERT_EQ(NetEq::kOK, - neteq_->InsertPacket( - rtp_info.header, - rtc::ArrayView(payload, payload_len), 0)); + ASSERT_EQ( + NetEq::kOK, + neteq_->InsertPacket( + rtp_info, rtc::ArrayView(payload, payload_len), 0)); ++seq_no; timestamp += kCngPeriodSamples; @@ -1285,7 +1284,7 @@ TEST_F(NetEqDecodingTest, CngFirst) { do { ASSERT_LT(timeout_counter++, 20) << "Test timed out"; PopulateRtpInfo(seq_no, timestamp, &rtp_info); - ASSERT_EQ(0, neteq_->InsertPacket(rtp_info.header, payload, 0)); + ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); ++seq_no; timestamp += kSamples; @@ -1309,20 +1308,20 @@ class NetEqDecodingTestWithMutedState : public NetEqDecodingTest { void InsertPacket(uint32_t rtp_timestamp) { uint8_t payload[kPayloadBytes] = {0}; - WebRtcRTPHeader rtp_info; + RTPHeader rtp_info; PopulateRtpInfo(0, rtp_timestamp, &rtp_info); - EXPECT_EQ(0, neteq_->InsertPacket(rtp_info.header, payload, 0)); + EXPECT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); } void InsertCngPacket(uint32_t rtp_timestamp) { uint8_t payload[kPayloadBytes] = {0}; - WebRtcRTPHeader rtp_info; + RTPHeader rtp_info; size_t payload_len; PopulateCng(0, rtp_timestamp, &rtp_info, payload, &payload_len); - EXPECT_EQ(NetEq::kOK, - neteq_->InsertPacket( - rtp_info.header, - rtc::ArrayView(payload, payload_len), 0)); + EXPECT_EQ( + NetEq::kOK, + neteq_->InsertPacket( + rtp_info, rtc::ArrayView(payload, payload_len), 0)); } bool GetAudioReturnMuted() { @@ -1545,10 +1544,10 @@ TEST_F(NetEqDecodingTestTwoInstances, CompareMutedStateOnOff) { const size_t kSamples = 10 * 16; const size_t kPayloadBytes = kSamples * 2; uint8_t payload[kPayloadBytes] = {0}; - WebRtcRTPHeader rtp_info; + RTPHeader rtp_info; PopulateRtpInfo(0, 0, &rtp_info); - EXPECT_EQ(0, neteq_->InsertPacket(rtp_info.header, payload, 0)); - EXPECT_EQ(0, neteq2_->InsertPacket(rtp_info.header, payload, 0)); + EXPECT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); + EXPECT_EQ(0, neteq2_->InsertPacket(rtp_info, payload, 0)); AudioFrame out_frame1, out_frame2; bool muted; @@ -1570,8 +1569,8 @@ TEST_F(NetEqDecodingTestTwoInstances, CompareMutedStateOnOff) { // Insert new data. Timestamp is corrected for the time elapsed since the last // packet. PopulateRtpInfo(0, kSamples * 1000, &rtp_info); - EXPECT_EQ(0, neteq_->InsertPacket(rtp_info.header, payload, 0)); - EXPECT_EQ(0, neteq2_->InsertPacket(rtp_info.header, payload, 0)); + EXPECT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); + EXPECT_EQ(0, neteq2_->InsertPacket(rtp_info, payload, 0)); int counter = 0; while (out_frame1.speech_type_ != AudioFrame::kNormalSpeech) { diff --git a/webrtc/modules/audio_coding/neteq/tools/encode_neteq_input.cc b/webrtc/modules/audio_coding/neteq/tools/encode_neteq_input.cc index f837ad6362..5fabb6f492 100644 --- a/webrtc/modules/audio_coding/neteq/tools/encode_neteq_input.cc +++ b/webrtc/modules/audio_coding/neteq/tools/encode_neteq_input.cc @@ -52,7 +52,7 @@ void EncodeNetEqInput::AdvanceOutputEvent() { rtc::Optional EncodeNetEqInput::NextHeader() const { RTC_DCHECK(packet_data_); - return rtc::Optional(packet_data_->header.header); + return rtc::Optional(packet_data_->header); } void EncodeNetEqInput::CreatePacket() { @@ -77,9 +77,9 @@ void EncodeNetEqInput::CreatePacket() { encoder_->SampleRateHz()); ++num_blocks; } - packet_data_->header.header.timestamp = info.encoded_timestamp; - packet_data_->header.header.payloadType = info.payload_type; - packet_data_->header.header.sequenceNumber = sequence_number_++; + packet_data_->header.timestamp = info.encoded_timestamp; + packet_data_->header.payloadType = info.payload_type; + packet_data_->header.sequenceNumber = sequence_number_++; packet_data_->time_ms = next_packet_time_ms_; next_packet_time_ms_ += num_blocks * kOutputPeriodMs; } diff --git a/webrtc/modules/audio_coding/neteq/tools/neteq_external_decoder_test.cc b/webrtc/modules/audio_coding/neteq/tools/neteq_external_decoder_test.cc index 95fdb04b44..8b7ca0910c 100644 --- a/webrtc/modules/audio_coding/neteq/tools/neteq_external_decoder_test.cc +++ b/webrtc/modules/audio_coding/neteq/tools/neteq_external_decoder_test.cc @@ -37,11 +37,11 @@ void NetEqExternalDecoderTest::Init() { } void NetEqExternalDecoderTest::InsertPacket( - WebRtcRTPHeader rtp_header, + RTPHeader rtp_header, rtc::ArrayView payload, uint32_t receive_timestamp) { - ASSERT_EQ(NetEq::kOK, neteq_->InsertPacket(rtp_header.header, payload, - receive_timestamp)); + ASSERT_EQ(NetEq::kOK, + neteq_->InsertPacket(rtp_header, payload, receive_timestamp)); } void NetEqExternalDecoderTest::GetOutputAudio(AudioFrame* output) { diff --git a/webrtc/modules/audio_coding/neteq/tools/neteq_external_decoder_test.h b/webrtc/modules/audio_coding/neteq/tools/neteq_external_decoder_test.h index 208d8dacd1..fc66c0f989 100644 --- a/webrtc/modules/audio_coding/neteq/tools/neteq_external_decoder_test.h +++ b/webrtc/modules/audio_coding/neteq/tools/neteq_external_decoder_test.h @@ -15,6 +15,7 @@ #include #include "webrtc/api/audio_codecs/audio_decoder.h" +#include "webrtc/common_types.h" #include "webrtc/modules/audio_coding/neteq/include/neteq.h" #include "webrtc/modules/include/module_common_types.h" @@ -40,7 +41,7 @@ class NetEqExternalDecoderTest { // |payload_size_bytes| bytes. The |receive_timestamp| is an indication // of the time when the packet was received, and should be measured with // the same tick rate as the RTP timestamp of the current payload. - virtual void InsertPacket(WebRtcRTPHeader rtp_header, + virtual void InsertPacket(RTPHeader rtp_header, rtc::ArrayView payload, uint32_t receive_timestamp); diff --git a/webrtc/modules/audio_coding/neteq/tools/neteq_input.h b/webrtc/modules/audio_coding/neteq/tools/neteq_input.h index be08a791a8..3bb64a6ca0 100644 --- a/webrtc/modules/audio_coding/neteq/tools/neteq_input.h +++ b/webrtc/modules/audio_coding/neteq/tools/neteq_input.h @@ -16,9 +16,9 @@ #include "webrtc/base/buffer.h" #include "webrtc/base/optional.h" +#include "webrtc/common_types.h" #include "webrtc/modules/audio_coding/neteq/tools/packet.h" #include "webrtc/modules/audio_coding/neteq/tools/packet_source.h" -#include "webrtc/modules/include/module_common_types.h" namespace webrtc { namespace test { @@ -27,7 +27,7 @@ namespace test { class NetEqInput { public: struct PacketData { - WebRtcRTPHeader header; + RTPHeader header; rtc::Buffer payload; double time_ms; }; diff --git a/webrtc/modules/audio_coding/neteq/tools/neteq_packet_source_input.cc b/webrtc/modules/audio_coding/neteq/tools/neteq_packet_source_input.cc index 5fa60dc993..7d5aa3bd62 100644 --- a/webrtc/modules/audio_coding/neteq/tools/neteq_packet_source_input.cc +++ b/webrtc/modules/audio_coding/neteq/tools/neteq_packet_source_input.cc @@ -42,7 +42,7 @@ std::unique_ptr NetEqPacketSourceInput::PopPacket() { return std::unique_ptr(); } std::unique_ptr packet_data(new PacketData); - packet_->ConvertHeader(&packet_data->header); + packet_data->header = packet_->header(); if (packet_->payload_length_bytes() == 0 && packet_->virtual_payload_length_bytes() > 0) { // This is a header-only "dummy" packet. Set the payload to all zeros, with diff --git a/webrtc/modules/audio_coding/neteq/tools/neteq_performance_test.cc b/webrtc/modules/audio_coding/neteq/tools/neteq_performance_test.cc index df14081feb..77787d87bd 100644 --- a/webrtc/modules/audio_coding/neteq/tools/neteq_performance_test.cc +++ b/webrtc/modules/audio_coding/neteq/tools/neteq_performance_test.cc @@ -12,6 +12,7 @@ #include "webrtc/api/audio_codecs/builtin_audio_decoder_factory.h" #include "webrtc/base/checks.h" +#include "webrtc/common_types.h" #include "webrtc/modules/audio_coding/codecs/pcm16b/pcm16b.h" #include "webrtc/modules/audio_coding/neteq/include/neteq.h" #include "webrtc/modules/audio_coding/neteq/tools/audio_loop.h" @@ -24,7 +25,6 @@ using webrtc::NetEq; using webrtc::test::AudioLoop; using webrtc::test::RtpGenerator; -using webrtc::WebRtcRTPHeader; namespace webrtc { namespace test { @@ -59,7 +59,7 @@ int64_t NetEqPerformanceTest::Run(int runtime_ms, int32_t time_now_ms = 0; // Get first input packet. - WebRtcRTPHeader rtp_header; + RTPHeader rtp_header; RtpGenerator rtp_gen(kSampRateHz / 1000); // Start with positive drift first half of simulation. rtp_gen.set_drift_factor(drift_factor); @@ -83,12 +83,12 @@ int64_t NetEqPerformanceTest::Run(int runtime_ms, // Drop every N packets, where N = FLAGS_lossrate. bool lost = false; if (lossrate > 0) { - lost = ((rtp_header.header.sequenceNumber - 1) % lossrate) == 0; + lost = ((rtp_header.sequenceNumber - 1) % lossrate) == 0; } if (!lost) { // Insert packet. int error = - neteq->InsertPacket(rtp_header.header, input_payload, + neteq->InsertPacket(rtp_header, input_payload, packet_input_time_ms * kSampRateHz / 1000); if (error != NetEq::kOK) return -1; diff --git a/webrtc/modules/audio_coding/neteq/tools/neteq_quality_test.cc b/webrtc/modules/audio_coding/neteq/tools/neteq_quality_test.cc index 732c7b8c8e..7b3a35b676 100644 --- a/webrtc/modules/audio_coding/neteq/tools/neteq_quality_test.cc +++ b/webrtc/modules/audio_coding/neteq/tools/neteq_quality_test.cc @@ -380,7 +380,7 @@ int NetEqQualityTest::Transmit() { if (payload_size_bytes_ > 0) { if (!PacketLost()) { int ret = neteq_->InsertPacket( - rtp_header_.header, + rtp_header_, rtc::ArrayView(payload_.data(), payload_size_bytes_), packet_input_time_ms * in_sampling_khz_); if (ret != NetEq::kOK) diff --git a/webrtc/modules/audio_coding/neteq/tools/neteq_quality_test.h b/webrtc/modules/audio_coding/neteq/tools/neteq_quality_test.h index 0ed7dfb0e7..731a7c9229 100644 --- a/webrtc/modules/audio_coding/neteq/tools/neteq_quality_test.h +++ b/webrtc/modules/audio_coding/neteq/tools/neteq_quality_test.h @@ -15,6 +15,7 @@ #include #include +#include "webrtc/common_types.h" #include "webrtc/modules/audio_coding/neteq/include/neteq.h" #include "webrtc/modules/audio_coding/neteq/tools/audio_sink.h" #include "webrtc/modules/audio_coding/neteq/tools/input_audio_file.h" @@ -130,7 +131,7 @@ class NetEqQualityTest : public ::testing::Test { std::unique_ptr in_data_; rtc::Buffer payload_; AudioFrame out_frame_; - WebRtcRTPHeader rtp_header_; + RTPHeader rtp_header_; size_t total_payload_size_bytes_; }; diff --git a/webrtc/modules/audio_coding/neteq/tools/neteq_replacement_input.cc b/webrtc/modules/audio_coding/neteq/tools/neteq_replacement_input.cc index dd10649625..9b550cbb2b 100644 --- a/webrtc/modules/audio_coding/neteq/tools/neteq_replacement_input.cc +++ b/webrtc/modules/audio_coding/neteq/tools/neteq_replacement_input.cc @@ -70,12 +70,12 @@ void NetEqReplacementInput::ReplacePacket() { RTC_DCHECK(packet_); - RTC_CHECK_EQ(forbidden_types_.count(packet_->header.header.payloadType), 0) - << "Payload type " << static_cast(packet_->header.header.payloadType) + RTC_CHECK_EQ(forbidden_types_.count(packet_->header.payloadType), 0) + << "Payload type " << static_cast(packet_->header.payloadType) << " is forbidden."; // Check if this packet is comfort noise. - if (comfort_noise_types_.count(packet_->header.header.payloadType) != 0) { + if (comfort_noise_types_.count(packet_->header.payloadType) != 0) { // If CNG, simply insert a zero-energy one-byte payload. uint8_t cng_payload[1] = {127}; // Max attenuation of CNG. packet_->payload.SetData(cng_payload); @@ -86,17 +86,17 @@ void NetEqReplacementInput::ReplacePacket() { RTC_DCHECK(next_hdr); uint8_t payload[12]; uint32_t input_frame_size_timestamps = last_frame_size_timestamps_; - if (next_hdr->sequenceNumber == packet_->header.header.sequenceNumber + 1) { + if (next_hdr->sequenceNumber == packet_->header.sequenceNumber + 1) { // Packets are in order. input_frame_size_timestamps = - next_hdr->timestamp - packet_->header.header.timestamp; + next_hdr->timestamp - packet_->header.timestamp; last_frame_size_timestamps_ = input_frame_size_timestamps; } - FakeDecodeFromFile::PrepareEncoded(packet_->header.header.timestamp, + FakeDecodeFromFile::PrepareEncoded(packet_->header.timestamp, input_frame_size_timestamps, packet_->payload.size(), payload); packet_->payload.SetData(payload); - packet_->header.header.payloadType = replacement_payload_type_; + packet_->header.payloadType = replacement_payload_type_; return; } diff --git a/webrtc/modules/audio_coding/neteq/tools/neteq_rtpplay.cc b/webrtc/modules/audio_coding/neteq/tools/neteq_rtpplay.cc index 47edc334f5..2266cd4de4 100644 --- a/webrtc/modules/audio_coding/neteq/tools/neteq_rtpplay.cc +++ b/webrtc/modules/audio_coding/neteq/tools/neteq_rtpplay.cc @@ -281,8 +281,7 @@ class FilterSsrcInput : public NetEqInput { // the desired SSRC. std::unique_ptr PopPacket() override { std::unique_ptr packet_to_return = source_->PopPacket(); - RTC_DCHECK(!packet_to_return || - packet_to_return->header.header.ssrc == ssrc_); + RTC_DCHECK(!packet_to_return || packet_to_return->header.ssrc == ssrc_); // Pre-fetch the next packet with correct SSRC. Hence, |source_| will always // be have a valid packet (or empty if no more packets are available) when // this method returns. diff --git a/webrtc/modules/audio_coding/neteq/tools/neteq_test.cc b/webrtc/modules/audio_coding/neteq/tools/neteq_test.cc index 13b11e8c7f..fb000252bc 100644 --- a/webrtc/modules/audio_coding/neteq/tools/neteq_test.cc +++ b/webrtc/modules/audio_coding/neteq/tools/neteq_test.cc @@ -22,15 +22,15 @@ void DefaultNetEqTestErrorCallback::OnInsertPacketError( const NetEqInput::PacketData& packet) { if (error_code == NetEq::kUnknownRtpPayloadType) { std::cerr << "RTP Payload type " - << static_cast(packet.header.header.payloadType) - << " is unknown." << std::endl; + << static_cast(packet.header.payloadType) << " is unknown." + << std::endl; } else { std::cerr << "InsertPacket returned error code " << error_code << std::endl; std::cerr << "Header data:" << std::endl; - std::cerr << " PT = " << static_cast(packet.header.header.payloadType) + std::cerr << " PT = " << static_cast(packet.header.payloadType) << std::endl; - std::cerr << " SN = " << packet.header.header.sequenceNumber << std::endl; - std::cerr << " TS = " << packet.header.header.timestamp << std::endl; + std::cerr << " SN = " << packet.header.sequenceNumber << std::endl; + std::cerr << " TS = " << packet.header.timestamp << std::endl; } FATAL(); } @@ -70,7 +70,7 @@ int64_t NetEqTest::Run() { std::unique_ptr packet_data = input_->PopPacket(); RTC_CHECK(packet_data); int error = neteq_->InsertPacket( - packet_data->header.header, + packet_data->header, rtc::ArrayView(packet_data->payload), static_cast(packet_data->time_ms * sample_rate_hz_ / 1000)); if (error != NetEq::kOK && error_callback_) { diff --git a/webrtc/modules/audio_coding/neteq/tools/packet.cc b/webrtc/modules/audio_coding/neteq/tools/packet.cc index 0ed1be1b02..0430933824 100644 --- a/webrtc/modules/audio_coding/neteq/tools/packet.cc +++ b/webrtc/modules/audio_coding/neteq/tools/packet.cc @@ -126,14 +126,6 @@ void Packet::DeleteRedHeaders(std::list* headers) { } } -void Packet::ConvertHeader(WebRtcRTPHeader* copy_to) const { - memcpy(©_to->header, &header_, sizeof(header_)); - copy_to->frameType = kAudioFrameSpeech; - copy_to->type.Audio.numEnergy = 0; - copy_to->type.Audio.channel = 1; - copy_to->type.Audio.isCNG = false; -} - bool Packet::ParseHeader(const RtpHeaderParser& parser) { bool valid_header = parser.Parse( payload_memory_.get(), static_cast(packet_length_bytes_), &header_); diff --git a/webrtc/modules/audio_coding/neteq/tools/packet.h b/webrtc/modules/audio_coding/neteq/tools/packet.h index d150805579..5d78ffa8f5 100644 --- a/webrtc/modules/audio_coding/neteq/tools/packet.h +++ b/webrtc/modules/audio_coding/neteq/tools/packet.h @@ -21,7 +21,6 @@ namespace webrtc { class RtpHeaderParser; -struct WebRtcRTPHeader; namespace test { @@ -90,10 +89,6 @@ class Packet { const RTPHeader& header() const { return header_; } - // Copies the packet header information, converting from the native RTPHeader - // type to WebRtcRTPHeader. - void ConvertHeader(WebRtcRTPHeader* copy_to) const; - void set_time_ms(double time) { time_ms_ = time; } double time_ms() const { return time_ms_; } bool valid_header() const { return valid_header_; } diff --git a/webrtc/modules/audio_coding/neteq/tools/rtp_generator.cc b/webrtc/modules/audio_coding/neteq/tools/rtp_generator.cc index db9988d904..a6e883dccf 100644 --- a/webrtc/modules/audio_coding/neteq/tools/rtp_generator.cc +++ b/webrtc/modules/audio_coding/neteq/tools/rtp_generator.cc @@ -17,19 +17,18 @@ namespace test { uint32_t RtpGenerator::GetRtpHeader(uint8_t payload_type, size_t payload_length_samples, - WebRtcRTPHeader* rtp_header) { + RTPHeader* rtp_header) { assert(rtp_header); if (!rtp_header) { return 0; } - rtp_header->header.sequenceNumber = seq_number_++; - rtp_header->header.timestamp = timestamp_; + rtp_header->sequenceNumber = seq_number_++; + rtp_header->timestamp = timestamp_; timestamp_ += static_cast(payload_length_samples); - rtp_header->header.payloadType = payload_type; - rtp_header->header.markerBit = false; - rtp_header->header.ssrc = ssrc_; - rtp_header->header.numCSRCs = 0; - rtp_header->frameType = kAudioFrameSpeech; + rtp_header->payloadType = payload_type; + rtp_header->markerBit = false; + rtp_header->ssrc = ssrc_; + rtp_header->numCSRCs = 0; uint32_t this_send_time = next_send_time_ms_; assert(samples_per_ms_ > 0); @@ -46,7 +45,7 @@ void RtpGenerator::set_drift_factor(double factor) { uint32_t TimestampJumpRtpGenerator::GetRtpHeader(uint8_t payload_type, size_t payload_length_samples, - WebRtcRTPHeader* rtp_header) { + RTPHeader* rtp_header) { uint32_t ret = RtpGenerator::GetRtpHeader( payload_type, payload_length_samples, rtp_header); if (timestamp_ - static_cast(payload_length_samples) <= diff --git a/webrtc/modules/audio_coding/neteq/tools/rtp_generator.h b/webrtc/modules/audio_coding/neteq/tools/rtp_generator.h index 53371be8f6..c733fff563 100644 --- a/webrtc/modules/audio_coding/neteq/tools/rtp_generator.h +++ b/webrtc/modules/audio_coding/neteq/tools/rtp_generator.h @@ -12,7 +12,7 @@ #define WEBRTC_MODULES_AUDIO_CODING_NETEQ_TOOLS_RTP_GENERATOR_H_ #include "webrtc/base/constructormagic.h" -#include "webrtc/modules/include/module_common_types.h" +#include "webrtc/common_types.h" #include "webrtc/typedefs.h" namespace webrtc { @@ -41,7 +41,7 @@ class RtpGenerator { // |payload_length_samples| determines the send time for the next packet. virtual uint32_t GetRtpHeader(uint8_t payload_type, size_t payload_length_samples, - WebRtcRTPHeader* rtp_header); + RTPHeader* rtp_header); void set_drift_factor(double factor); @@ -70,7 +70,7 @@ class TimestampJumpRtpGenerator : public RtpGenerator { uint32_t GetRtpHeader(uint8_t payload_type, size_t payload_length_samples, - WebRtcRTPHeader* rtp_header) override; + RTPHeader* rtp_header) override; private: uint32_t jump_from_timestamp_; diff --git a/webrtc/test/fuzzers/neteq_rtp_fuzzer.cc b/webrtc/test/fuzzers/neteq_rtp_fuzzer.cc index c0f250aeb6..f6271206fd 100644 --- a/webrtc/test/fuzzers/neteq_rtp_fuzzer.cc +++ b/webrtc/test/fuzzers/neteq_rtp_fuzzer.cc @@ -87,7 +87,7 @@ class FuzzRtpInput : public NetEqInput { rtc::Optional NextHeader() const override { RTC_DCHECK(packet_); - return rtc::Optional(packet_->header.header); + return rtc::Optional(packet_->header); } private: @@ -99,17 +99,17 @@ class FuzzRtpInput : public NetEqInput { } RTC_DCHECK(packet_); const size_t start_ix = data_ix_; - packet_->header.header.payloadType = + packet_->header.payloadType = ByteReader::ReadLittleEndian(&data_[data_ix_]); - packet_->header.header.payloadType &= 0x7F; + packet_->header.payloadType &= 0x7F; data_ix_ += sizeof(uint8_t); - packet_->header.header.sequenceNumber = + packet_->header.sequenceNumber = ByteReader::ReadLittleEndian(&data_[data_ix_]); data_ix_ += sizeof(uint16_t); - packet_->header.header.timestamp = + packet_->header.timestamp = ByteReader::ReadLittleEndian(&data_[data_ix_]); data_ix_ += sizeof(uint32_t); - packet_->header.header.ssrc = + packet_->header.ssrc = ByteReader::ReadLittleEndian(&data_[data_ix_]); data_ix_ += sizeof(uint32_t); RTC_CHECK_EQ(data_ix_ - start_ix, kNumBytesToFuzz);