From 0a5fe77d23303b6683d4f40d66598569ec61c327 Mon Sep 17 00:00:00 2001 From: philipel Date: Tue, 19 Jun 2018 16:18:31 +0200 Subject: [PATCH] Clean up in module_common_types.h by removing the unused struct RTPAudioHeader. By removing it we can in turn (next CL) get rid of RTPTypeHeader, which is a union that cause some problems. Bug: none Change-Id: I9246ecbfe2c8b7eda27497cccbc5f438958b64bf Reviewed-on: https://webrtc-review.googlesource.com/83985 Reviewed-by: Stefan Holmer Reviewed-by: Henrik Lundin Commit-Queue: Philip Eliasson Cr-Commit-Position: refs/heads/master@{#23666} --- modules/audio_coding/acm2/acm_receive_test.cc | 1 - .../acm2/acm_receiver_unittest.cc | 5 --- .../acm2/audio_coding_module_unittest.cc | 2 - modules/audio_coding/test/Channel.cc | 8 ---- modules/audio_coding/test/RTPFile.cc | 2 - modules/audio_coding/test/TestAllCodecs.cc | 7 +--- modules/audio_coding/test/TestStereo.cc | 7 ---- .../test/target_delay_unittest.cc | 2 - modules/include/module_common_types.h | 8 ---- modules/rtp_rtcp/include/rtp_receiver.h | 3 -- modules/rtp_rtcp/source/rtp_receiver_audio.cc | 37 +------------------ modules/rtp_rtcp/source/rtp_receiver_audio.h | 5 --- modules/rtp_rtcp/source/rtp_receiver_impl.cc | 4 -- modules/rtp_rtcp/source/rtp_receiver_impl.h | 2 - .../rtp_rtcp/source/rtp_receiver_strategy.cc | 4 -- .../rtp_rtcp/source/rtp_receiver_strategy.h | 2 - .../rtp_rtcp/test/testAPI/test_api_audio.cc | 13 +------ 17 files changed, 3 insertions(+), 109 deletions(-) diff --git a/modules/audio_coding/acm2/acm_receive_test.cc b/modules/audio_coding/acm2/acm_receive_test.cc index 6afc161efa..ba8937e6ea 100644 --- a/modules/audio_coding/acm2/acm_receive_test.cc +++ b/modules/audio_coding/acm2/acm_receive_test.cc @@ -199,7 +199,6 @@ void AcmReceiveTestOldApi::Run() { WebRtcRTPHeader header; header.header = packet->header(); header.frameType = kAudioFrameSpeech; - memset(&header.type.Audio, 0, sizeof(RTPAudioHeader)); EXPECT_EQ(0, acm_->IncomingPacket( packet->payload(), diff --git a/modules/audio_coding/acm2/acm_receiver_unittest.cc b/modules/audio_coding/acm2/acm_receiver_unittest.cc index 350183bf3a..d1cff235c2 100644 --- a/modules/audio_coding/acm2/acm_receiver_unittest.cc +++ b/modules/audio_coding/acm2/acm_receiver_unittest.cc @@ -82,7 +82,6 @@ class AcmReceiverTestOldApi : public AudioPacketizationCallback, rtp_header_.header.numCSRCs = 0; rtp_header_.header.payloadType = 0; rtp_header_.frameType = kAudioFrameSpeech; - rtp_header_.type.Audio.isCNG = false; } void TearDown() override {} @@ -135,10 +134,6 @@ class AcmReceiverTestOldApi : public AudioPacketizationCallback, rtp_header_.header.payloadType = payload_type; rtp_header_.frameType = frame_type; - if (frame_type == kAudioFrameSpeech) - rtp_header_.type.Audio.isCNG = false; - else - rtp_header_.type.Audio.isCNG = true; rtp_header_.header.timestamp = timestamp; int ret_val = receiver_->InsertPacket( diff --git a/modules/audio_coding/acm2/audio_coding_module_unittest.cc b/modules/audio_coding/acm2/audio_coding_module_unittest.cc index 7592300e10..ce2832a875 100644 --- a/modules/audio_coding/acm2/audio_coding_module_unittest.cc +++ b/modules/audio_coding/acm2/audio_coding_module_unittest.cc @@ -78,8 +78,6 @@ class RtpUtility { rtp_header->frameType = kAudioFrameSpeech; rtp_header->header.payload_type_frequency = kSampleRateHz; - rtp_header->type.Audio.channel = 1; - rtp_header->type.Audio.isCNG = false; } void Forward(WebRtcRTPHeader* rtp_header) { diff --git a/modules/audio_coding/test/Channel.cc b/modules/audio_coding/test/Channel.cc index 8fdb677f32..bb970c1d65 100644 --- a/modules/audio_coding/test/Channel.cc +++ b/modules/audio_coding/test/Channel.cc @@ -40,11 +40,6 @@ int32_t Channel::SendData(FrameType frameType, ? timeStamp : static_cast(external_send_timestamp_); - if (frameType == kAudioFrameCN) { - rtpInfo.type.Audio.isCNG = true; - } else { - rtpInfo.type.Audio.isCNG = false; - } if (frameType == kEmptyFrame) { // When frame is empty, we should not transmit it. The frame size of the // next non-empty frame will be based on the previous frame size. @@ -52,7 +47,6 @@ int32_t Channel::SendData(FrameType frameType, return 0; } - rtpInfo.type.Audio.channel = 1; // Treat fragmentation separately if (fragmentation != NULL) { // If silence for too long, send only new data. @@ -89,11 +83,9 @@ int32_t Channel::SendData(FrameType frameType, if (_leftChannel) { memcpy(&_rtpInfo, &rtpInfo, sizeof(WebRtcRTPHeader)); _leftChannel = false; - rtpInfo.type.Audio.channel = 1; } else { memcpy(&rtpInfo, &_rtpInfo, sizeof(WebRtcRTPHeader)); _leftChannel = true; - rtpInfo.type.Audio.channel = 2; } } } diff --git a/modules/audio_coding/test/RTPFile.cc b/modules/audio_coding/test/RTPFile.cc index a1329e77bc..d058384cb6 100644 --- a/modules/audio_coding/test/RTPFile.cc +++ b/modules/audio_coding/test/RTPFile.cc @@ -222,8 +222,6 @@ size_t RTPFile::Read(WebRtcRTPHeader* rtpInfo, EXPECT_EQ(1u, fread(rtpHeader, 12, 1, _rtpFile)); ParseRTPHeader(rtpInfo, rtpHeader); - rtpInfo->type.Audio.isCNG = false; - rtpInfo->type.Audio.channel = 1; EXPECT_EQ(lengthBytes, plen + 8); if (plen == 0) { diff --git a/modules/audio_coding/test/TestAllCodecs.cc b/modules/audio_coding/test/TestAllCodecs.cc index df9c731742..74de1d9f22 100644 --- a/modules/audio_coding/test/TestAllCodecs.cc +++ b/modules/audio_coding/test/TestAllCodecs.cc @@ -69,18 +69,13 @@ int32_t TestPack::SendData(FrameType frame_type, rtp_info.header.sequenceNumber = sequence_number_++; rtp_info.header.payloadType = payload_type; rtp_info.header.timestamp = timestamp; - if (frame_type == kAudioFrameCN) { - rtp_info.type.Audio.isCNG = true; - } else { - rtp_info.type.Audio.isCNG = false; - } + if (frame_type == kEmptyFrame) { // Skip this frame. return 0; } // Only run mono for all test cases. - rtp_info.type.Audio.channel = 1; memcpy(payload_data_, payload_data, payload_size); status = receiver_acm_->IncomingPacket(payload_data_, payload_size, rtp_info); diff --git a/modules/audio_coding/test/TestStereo.cc b/modules/audio_coding/test/TestStereo.cc index 2704d3d892..31b1d073ea 100644 --- a/modules/audio_coding/test/TestStereo.cc +++ b/modules/audio_coding/test/TestStereo.cc @@ -63,13 +63,6 @@ int32_t TestPackStereo::SendData(const FrameType frame_type, } if (lost_packet_ == false) { - if (frame_type != kAudioFrameCN) { - rtp_info.type.Audio.isCNG = false; - rtp_info.type.Audio.channel = static_cast(codec_mode_); - } else { - rtp_info.type.Audio.isCNG = true; - rtp_info.type.Audio.channel = static_cast(kMono); - } status = receiver_acm_->IncomingPacket(payload_data, payload_size, rtp_info); diff --git a/modules/audio_coding/test/target_delay_unittest.cc b/modules/audio_coding/test/target_delay_unittest.cc index 7579d62fe5..3b129ea280 100644 --- a/modules/audio_coding/test/target_delay_unittest.cc +++ b/modules/audio_coding/test/target_delay_unittest.cc @@ -43,8 +43,6 @@ class TargetDelayTest : public ::testing::Test { rtp_info_.header.ssrc = 0x12345678; rtp_info_.header.markerBit = false; rtp_info_.header.sequenceNumber = 0; - rtp_info_.type.Audio.channel = 1; - rtp_info_.type.Audio.isCNG = false; rtp_info_.frameType = kAudioFrameSpeech; int16_t audio[kFrameSizeSamples]; diff --git a/modules/include/module_common_types.h b/modules/include/module_common_types.h index 08b36d1015..6554adb1f9 100644 --- a/modules/include/module_common_types.h +++ b/modules/include/module_common_types.h @@ -35,13 +35,6 @@ namespace webrtc { -struct RTPAudioHeader { - uint8_t numEnergy; // number of valid entries in arrOfEnergy - uint8_t arrOfEnergy[kRtpCsrcSize]; // one energy byte (0-9) per channel - bool isCNG; // is this CNG - size_t channel; // number of channels 2 = stereo -}; - // TODO(nisse): Deprecated, use webrtc::VideoCodecType instead. using RtpVideoCodecTypes = VideoCodecType; @@ -71,7 +64,6 @@ struct RTPVideoHeader { RTPVideoTypeHeader codecHeader; }; union RTPTypeHeader { - RTPAudioHeader Audio; RTPVideoHeader Video; }; diff --git a/modules/rtp_rtcp/include/rtp_receiver.h b/modules/rtp_rtcp/include/rtp_receiver.h index 52062a0978..d2d73b41eb 100644 --- a/modules/rtp_rtcp/include/rtp_receiver.h +++ b/modules/rtp_rtcp/include/rtp_receiver.h @@ -101,9 +101,6 @@ class RtpReceiver { // Returns the current remote CSRCs. virtual int32_t CSRCs(uint32_t array_of_csrc[kRtpCsrcSize]) const = 0; - // Returns the current energy of the RTP stream received. - virtual int32_t Energy(uint8_t array_of_energy[kRtpCsrcSize]) const = 0; - virtual std::vector GetSources() const = 0; }; } // namespace webrtc diff --git a/modules/rtp_rtcp/source/rtp_receiver_audio.cc b/modules/rtp_rtcp/source/rtp_receiver_audio.cc index 3db5ef5c9d..ac571382f5 100644 --- a/modules/rtp_rtcp/source/rtp_receiver_audio.cc +++ b/modules/rtp_rtcp/source/rtp_receiver_audio.cc @@ -32,11 +32,7 @@ RTPReceiverAudio::RTPReceiverAudio(RtpData* data_callback) cng_nb_payload_type_(-1), cng_wb_payload_type_(-1), cng_swb_payload_type_(-1), - cng_fb_payload_type_(-1), - num_energy_(0), - current_remote_energy_() { - memset(current_remote_energy_, 0, sizeof(current_remote_energy_)); -} + cng_fb_payload_type_(-1) {} RTPReceiverAudio::~RTPReceiverAudio() = default; @@ -134,14 +130,6 @@ int32_t RTPReceiverAudio::ParseRtpPacket(WebRtcRTPHeader* rtp_header, const uint8_t* payload, size_t payload_length, int64_t timestamp_ms) { - rtp_header->type.Audio.numEnergy = rtp_header->header.numCSRCs; - num_energy_ = rtp_header->type.Audio.numEnergy; - if (rtp_header->type.Audio.numEnergy > 0 && - rtp_header->type.Audio.numEnergy <= kRtpCsrcSize) { - memcpy(current_remote_energy_, rtp_header->type.Audio.arrOfEnergy, - rtp_header->type.Audio.numEnergy); - } - if (first_packet_received_()) { RTC_LOG(LS_INFO) << "Received first audio RTP packet"; } @@ -168,18 +156,6 @@ void RTPReceiverAudio::CheckPayloadChanged(int8_t payload_type, TelephoneEventPayloadType(payload_type) || CNGPayloadType(payload_type); } -int RTPReceiverAudio::Energy(uint8_t array_of_energy[kRtpCsrcSize]) const { - rtc::CritScope cs(&crit_sect_); - - assert(num_energy_ <= kRtpCsrcSize); - - if (num_energy_ > 0) { - memcpy(array_of_energy, current_remote_energy_, - sizeof(uint8_t) * num_energy_); - } - return num_energy_; -} - // We are not allowed to have any critsects when calling data_callback. int32_t RTPReceiverAudio::ParseAudioCodecSpecific( WebRtcRTPHeader* rtp_header, @@ -190,7 +166,6 @@ int32_t RTPReceiverAudio::ParseAudioCodecSpecific( const size_t payload_data_length = payload_length - rtp_header->header.paddingLength; if (payload_data_length == 0) { - rtp_header->type.Audio.isCNG = false; rtp_header->frameType = kEmptyFrame; return data_callback_->OnReceivedPayloadData(nullptr, 0, rtp_header); } @@ -246,15 +221,6 @@ int32_t RTPReceiverAudio::ParseAudioCodecSpecific( { rtc::CritScope lock(&crit_sect_); - // Check if this is a CNG packet, receiver might want to know - if (CNGPayloadType(rtp_header->header.payloadType)) { - rtp_header->type.Audio.isCNG = true; - rtp_header->frameType = kAudioFrameCN; - } else { - rtp_header->frameType = kAudioFrameSpeech; - rtp_header->type.Audio.isCNG = false; - } - // check if it's a DTMF event, hence something we can playout if (telephone_event_packet) { if (!telephone_event_forward_to_decoder_) { @@ -269,7 +235,6 @@ int32_t RTPReceiverAudio::ParseAudioCodecSpecific( } } - rtp_header->type.Audio.channel = audio_specific.format.num_channels; return data_callback_->OnReceivedPayloadData(payload_data, payload_data_length, rtp_header); } diff --git a/modules/rtp_rtcp/source/rtp_receiver_audio.h b/modules/rtp_rtcp/source/rtp_receiver_audio.h index ded9d42426..d88acfd2e0 100644 --- a/modules/rtp_rtcp/source/rtp_receiver_audio.h +++ b/modules/rtp_rtcp/source/rtp_receiver_audio.h @@ -61,8 +61,6 @@ class RTPReceiverAudio : public RTPReceiverStrategy, PayloadUnion* specific_payload, bool* should_discard_changes) override; - int Energy(uint8_t array_of_energy[kRtpCsrcSize]) const override; - private: int32_t ParseAudioCodecSpecific(WebRtcRTPHeader* rtp_header, const uint8_t* payload_data, @@ -78,9 +76,6 @@ class RTPReceiverAudio : public RTPReceiverStrategy, int8_t cng_swb_payload_type_; int8_t cng_fb_payload_type_; - uint8_t num_energy_; - uint8_t current_remote_energy_[kRtpCsrcSize]; - ThreadUnsafeOneTimeEvent first_packet_received_; }; } // namespace webrtc diff --git a/modules/rtp_rtcp/source/rtp_receiver_impl.cc b/modules/rtp_rtcp/source/rtp_receiver_impl.cc index a0d201ae8b..7fa1d3774e 100644 --- a/modules/rtp_rtcp/source/rtp_receiver_impl.cc +++ b/modules/rtp_rtcp/source/rtp_receiver_impl.cc @@ -143,10 +143,6 @@ int32_t RtpReceiverImpl::CSRCs(uint32_t array_of_csrcs[kRtpCsrcSize]) const { return num_csrcs_; } -int32_t RtpReceiverImpl::Energy(uint8_t array_of_energy[kRtpCsrcSize]) const { - return rtp_media_receiver_->Energy(array_of_energy); -} - bool RtpReceiverImpl::IncomingRtpPacket(const RTPHeader& rtp_header, const uint8_t* payload, size_t payload_length, diff --git a/modules/rtp_rtcp/source/rtp_receiver_impl.h b/modules/rtp_rtcp/source/rtp_receiver_impl.h index 70d7a2ea4c..ec218d3127 100644 --- a/modules/rtp_rtcp/source/rtp_receiver_impl.h +++ b/modules/rtp_rtcp/source/rtp_receiver_impl.h @@ -54,8 +54,6 @@ class RtpReceiverImpl : public RtpReceiver { int32_t CSRCs(uint32_t array_of_csrc[kRtpCsrcSize]) const override; - int32_t Energy(uint8_t array_of_energy[kRtpCsrcSize]) const override; - TelephoneEventHandler* GetTelephoneEventHandler() override; std::vector GetSources() const override; diff --git a/modules/rtp_rtcp/source/rtp_receiver_strategy.cc b/modules/rtp_rtcp/source/rtp_receiver_strategy.cc index 1404273865..bcce3e3907 100644 --- a/modules/rtp_rtcp/source/rtp_receiver_strategy.cc +++ b/modules/rtp_rtcp/source/rtp_receiver_strategy.cc @@ -26,8 +26,4 @@ void RTPReceiverStrategy::CheckPayloadChanged(int8_t payload_type, *should_discard_changes = false; } -int RTPReceiverStrategy::Energy(uint8_t array_of_energy[kRtpCsrcSize]) const { - return -1; -} - } // namespace webrtc diff --git a/modules/rtp_rtcp/source/rtp_receiver_strategy.h b/modules/rtp_rtcp/source/rtp_receiver_strategy.h index 52cb5935fc..8b13f186ff 100644 --- a/modules/rtp_rtcp/source/rtp_receiver_strategy.h +++ b/modules/rtp_rtcp/source/rtp_receiver_strategy.h @@ -61,8 +61,6 @@ class RTPReceiverStrategy { PayloadUnion* specific_payload, bool* should_discard_changes); - virtual int Energy(uint8_t array_of_energy[kRtpCsrcSize]) const; - protected: // The data callback is where we should send received payload data. // See ParseRtpPacket. This class does not claim ownership of the callback. diff --git a/modules/rtp_rtcp/test/testAPI/test_api_audio.cc b/modules/rtp_rtcp/test/testAPI/test_api_audio.cc index d64440f79d..abda7b2120 100644 --- a/modules/rtp_rtcp/test/testAPI/test_api_audio.cc +++ b/modules/rtp_rtcp/test/testAPI/test_api_audio.cc @@ -39,14 +39,6 @@ const CngCodecSpec kCngCodecs[] = {{13, 8000}, {104, 32000}, {105, 48000}}; -bool IsComfortNoisePayload(uint8_t payload_type) { - for (const auto& c : kCngCodecs) { - if (c.payload_type == payload_type) - return true; - } - - return false; -} class VerifyingAudioReceiver : public RtpData { public: @@ -60,11 +52,8 @@ class VerifyingAudioReceiver : public RtpData { // All our test vectors for PCMU and DTMF are equal to |kTestPayload|. const size_t min_size = std::min(sizeof(kTestPayload), payloadSize); EXPECT_EQ(0, memcmp(payloadData, kTestPayload, min_size)); - } else if (IsComfortNoisePayload(payload_type)) { - // CNG types should be recognized properly. - EXPECT_EQ(kAudioFrameCN, rtpHeader->frameType); - EXPECT_TRUE(rtpHeader->type.Audio.isCNG); } + return 0; } };