Update ACM to use RTPHeader instead of WebRtcRTPHeader
Bug: webrtc:5876
Change-Id: Id3311dcf508cca34495349197eeac2edf8783772
Reviewed-on: https://webrtc-review.googlesource.com/c/123188
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26729}
diff --git a/modules/audio_coding/acm2/acm_receive_test.cc b/modules/audio_coding/acm2/acm_receive_test.cc
index 76b0506..078c991 100644
--- a/modules/audio_coding/acm2/acm_receive_test.cc
+++ b/modules/audio_coding/acm2/acm_receive_test.cc
@@ -120,18 +120,15 @@
AfterGetAudio();
}
- // Insert packet after converting from RTPHeader to WebRtcRTPHeader.
- WebRtcRTPHeader header;
- header.header = packet->header();
- header.frameType = kAudioFrameSpeech;
- EXPECT_EQ(0,
- acm_->IncomingPacket(
- packet->payload(),
- static_cast<int32_t>(packet->payload_length_bytes()), header))
+ EXPECT_EQ(0, acm_->IncomingPacket(
+ packet->payload(),
+ static_cast<int32_t>(packet->payload_length_bytes()),
+ packet->header()))
<< "Failure when inserting packet:" << std::endl
- << " PT = " << static_cast<int>(header.header.payloadType) << std::endl
- << " TS = " << header.header.timestamp << std::endl
- << " SN = " << header.header.sequenceNumber;
+ << " PT = " << static_cast<int>(packet->header().payloadType)
+ << std::endl
+ << " TS = " << packet->header().timestamp << std::endl
+ << " SN = " << packet->header().sequenceNumber;
}
}
diff --git a/modules/audio_coding/acm2/acm_receiver.cc b/modules/audio_coding/acm2/acm_receiver.cc
index 9eb59ec..d296a57 100644
--- a/modules/audio_coding/acm2/acm_receiver.cc
+++ b/modules/audio_coding/acm2/acm_receiver.cc
@@ -78,15 +78,14 @@
return neteq_->last_output_sample_rate_hz();
}
-int AcmReceiver::InsertPacket(const WebRtcRTPHeader& rtp_header,
+int AcmReceiver::InsertPacket(const RTPHeader& rtp_header,
rtc::ArrayView<const uint8_t> incoming_payload) {
if (incoming_payload.empty()) {
- neteq_->InsertEmptyPacket(rtp_header.header);
+ neteq_->InsertEmptyPacket(rtp_header);
return 0;
}
- const RTPHeader& header = rtp_header.header; // Just a shorthand.
- int payload_type = header.payloadType;
+ int payload_type = rtp_header.payloadType;
auto format = neteq_->GetDecoderFormat(payload_type);
if (format && absl::EqualsIgnoreCase(format->name, "red")) {
// This is a RED packet. Get the format of the audio codec.
@@ -115,9 +114,10 @@
} // |crit_sect_| is released.
uint32_t receive_timestamp = NowInTimestamp(format->clockrate_hz);
- if (neteq_->InsertPacket(header, incoming_payload, receive_timestamp) < 0) {
+ if (neteq_->InsertPacket(rtp_header, incoming_payload, receive_timestamp) <
+ 0) {
RTC_LOG(LERROR) << "AcmReceiver::InsertPacket "
- << static_cast<int>(header.payloadType)
+ << static_cast<int>(rtp_header.payloadType)
<< " Failed to insert packet";
return -1;
}
diff --git a/modules/audio_coding/acm2/acm_receiver.h b/modules/audio_coding/acm2/acm_receiver.h
index 3e30b86..1f449a3 100644
--- a/modules/audio_coding/acm2/acm_receiver.h
+++ b/modules/audio_coding/acm2/acm_receiver.h
@@ -33,7 +33,6 @@
class Clock;
class NetEq;
struct RTPHeader;
-struct WebRtcRTPHeader;
namespace acm2 {
@@ -58,7 +57,7 @@
// Return value : 0 if OK.
// <0 if NetEq returned an error.
//
- int InsertPacket(const WebRtcRTPHeader& rtp_header,
+ int InsertPacket(const RTPHeader& rtp_header,
rtc::ArrayView<const uint8_t> incoming_payload);
//
diff --git a/modules/audio_coding/acm2/acm_receiver_unittest.cc b/modules/audio_coding/acm2/acm_receiver_unittest.cc
index d5392dc..e5a7684 100644
--- a/modules/audio_coding/acm2/acm_receiver_unittest.cc
+++ b/modules/audio_coding/acm2/acm_receiver_unittest.cc
@@ -50,13 +50,12 @@
acm_->InitializeReceiver();
acm_->RegisterTransportCallback(this);
- rtp_header_.header.sequenceNumber = 0;
- rtp_header_.header.timestamp = 0;
- rtp_header_.header.markerBit = false;
- rtp_header_.header.ssrc = 0x12345678; // Arbitrary.
- rtp_header_.header.numCSRCs = 0;
- rtp_header_.header.payloadType = 0;
- rtp_header_.frameType = kAudioFrameSpeech;
+ rtp_header_.sequenceNumber = 0;
+ rtp_header_.timestamp = 0;
+ rtp_header_.markerBit = false;
+ rtp_header_.ssrc = 0x12345678; // Arbitrary.
+ rtp_header_.numCSRCs = 0;
+ rtp_header_.payloadType = 0;
}
void TearDown() override {}
@@ -113,9 +112,8 @@
if (frame_type == kEmptyFrame)
return 0;
- rtp_header_.header.payloadType = payload_type;
- rtp_header_.frameType = frame_type;
- rtp_header_.header.timestamp = timestamp;
+ rtp_header_.payloadType = payload_type;
+ rtp_header_.timestamp = timestamp;
int ret_val = receiver_->InsertPacket(
rtp_header_,
@@ -124,7 +122,7 @@
assert(false);
return -1;
}
- rtp_header_.header.sequenceNumber++;
+ rtp_header_.sequenceNumber++;
packet_sent_ = true;
last_frame_type_ = frame_type;
return 0;
@@ -137,7 +135,7 @@
AudioCodingModule::Config config_;
std::unique_ptr<AcmReceiver> receiver_;
std::unique_ptr<AudioCodingModule> acm_;
- WebRtcRTPHeader rtp_header_;
+ RTPHeader rtp_header_;
uint32_t timestamp_;
bool packet_sent_; // Set when SendData is called reset when inserting audio.
uint32_t last_packet_send_timestamp_;
diff --git a/modules/audio_coding/acm2/audio_coding_module.cc b/modules/audio_coding/acm2/audio_coding_module.cc
index 9e4ac89..014aede 100644
--- a/modules/audio_coding/acm2/audio_coding_module.cc
+++ b/modules/audio_coding/acm2/audio_coding_module.cc
@@ -92,7 +92,7 @@
// Incoming packet from network parsed and ready for decode.
int IncomingPacket(const uint8_t* incoming_payload,
const size_t payload_length,
- const WebRtcRTPHeader& rtp_info) override;
+ const RTPHeader& rtp_info) override;
// Minimum playout delay.
int SetMinimumPlayoutDelay(int time_ms) override;
@@ -688,7 +688,7 @@
// Incoming packet from network parsed and ready for decode.
int AudioCodingModuleImpl::IncomingPacket(const uint8_t* incoming_payload,
const size_t payload_length,
- const WebRtcRTPHeader& rtp_header) {
+ const RTPHeader& rtp_header) {
RTC_DCHECK_EQ(payload_length == 0, incoming_payload == nullptr);
return receiver_.InsertPacket(
rtp_header,
diff --git a/modules/audio_coding/acm2/audio_coding_module_unittest.cc b/modules/audio_coding/acm2/audio_coding_module_unittest.cc
index 5037bc6..c9a03a1 100644
--- a/modules/audio_coding/acm2/audio_coding_module_unittest.cc
+++ b/modules/audio_coding/acm2/audio_coding_module_unittest.cc
@@ -71,21 +71,20 @@
virtual ~RtpUtility() {}
- void Populate(WebRtcRTPHeader* rtp_header) {
- rtp_header->header.sequenceNumber = 0xABCD;
- rtp_header->header.timestamp = 0xABCDEF01;
- rtp_header->header.payloadType = payload_type_;
- rtp_header->header.markerBit = false;
- rtp_header->header.ssrc = 0x1234;
- rtp_header->header.numCSRCs = 0;
- rtp_header->frameType = kAudioFrameSpeech;
+ void Populate(RTPHeader* rtp_header) {
+ rtp_header->sequenceNumber = 0xABCD;
+ rtp_header->timestamp = 0xABCDEF01;
+ rtp_header->payloadType = payload_type_;
+ rtp_header->markerBit = false;
+ rtp_header->ssrc = 0x1234;
+ rtp_header->numCSRCs = 0;
- rtp_header->header.payload_type_frequency = kSampleRateHz;
+ rtp_header->payload_type_frequency = kSampleRateHz;
}
- void Forward(WebRtcRTPHeader* rtp_header) {
- ++rtp_header->header.sequenceNumber;
- rtp_header->header.timestamp += samples_per_packet_;
+ void Forward(RTPHeader* rtp_header) {
+ ++rtp_header->sequenceNumber;
+ rtp_header->timestamp += samples_per_packet_;
}
private:
@@ -237,7 +236,7 @@
std::unique_ptr<RtpUtility> rtp_utility_;
std::unique_ptr<AudioCodingModule> acm_;
PacketizationCallbackStubOldApi packet_cb_;
- WebRtcRTPHeader rtp_header_;
+ RTPHeader rtp_header_;
AudioFrame input_frame_;
absl::optional<SdpAudioFormat> audio_format_;
@@ -792,16 +791,15 @@
++receive_packet_count_;
// Encode new frame.
- uint32_t input_timestamp = rtp_header_.header.timestamp;
+ uint32_t input_timestamp = rtp_header_.timestamp;
while (info.encoded_bytes == 0) {
info = isac_encoder_->Encode(input_timestamp,
audio_loop_.GetNextBlock(), &encoded);
input_timestamp += 160; // 10 ms at 16 kHz.
}
- EXPECT_EQ(rtp_header_.header.timestamp + kPacketSizeSamples,
- input_timestamp);
- EXPECT_EQ(rtp_header_.header.timestamp, info.encoded_timestamp);
- EXPECT_EQ(rtp_header_.header.payloadType, info.payload_type);
+ EXPECT_EQ(rtp_header_.timestamp + kPacketSizeSamples, input_timestamp);
+ EXPECT_EQ(rtp_header_.timestamp, info.encoded_timestamp);
+ EXPECT_EQ(rtp_header_.payloadType, info.payload_type);
}
// Now we're not holding the crit sect when calling ACM.