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 <stefan@webrtc.org>
Reviewed-by: Henrik Lundin <henrik.lundin@webrtc.org>
Commit-Queue: Philip Eliasson <philipel@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23666}
This commit is contained in:
philipel 2018-06-19 16:18:31 +02:00 committed by Commit Bot
parent 7e9a619599
commit 0a5fe77d23
17 changed files with 3 additions and 109 deletions

View File

@ -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(),

View File

@ -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(

View File

@ -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) {

View File

@ -40,11 +40,6 @@ int32_t Channel::SendData(FrameType frameType,
? timeStamp
: static_cast<uint32_t>(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;
}
}
}

View File

@ -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) {

View File

@ -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);

View File

@ -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<int>(codec_mode_);
} else {
rtp_info.type.Audio.isCNG = true;
rtp_info.type.Audio.channel = static_cast<int>(kMono);
}
status =
receiver_acm_->IncomingPacket(payload_data, payload_size, rtp_info);

View File

@ -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];

View File

@ -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;
};

View File

@ -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<RtpSource> GetSources() const = 0;
};
} // namespace webrtc

View File

@ -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);
}

View File

@ -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

View File

@ -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,

View File

@ -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<RtpSource> GetSources() const override;

View File

@ -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

View File

@ -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.

View File

@ -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;
}
};