Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(29)

Unified Diff: webrtc/modules/rtp_rtcp/source/rtp_receiver_audio.cc

Issue 2383103002: RTPReceiverAudio: Removed frequency from CNGPayloadType and cleaned up (Closed)
Patch Set: Rebase Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/rtp_rtcp/source/rtp_receiver_audio.cc
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_receiver_audio.cc b/webrtc/modules/rtp_rtcp/source/rtp_receiver_audio.cc
index 38b2830b79cbe9c3e903044b8c3b2eb746d49fdb..082d2a8b18514f215d0192e2dcee57ac71299198 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_receiver_audio.cc
+++ b/webrtc/modules/rtp_rtcp/source/rtp_receiver_audio.cc
@@ -26,16 +26,12 @@ RTPReceiverStrategy* RTPReceiverStrategy::CreateAudioStrategy(
RTPReceiverAudio::RTPReceiverAudio(RtpData* data_callback)
: RTPReceiverStrategy(data_callback),
TelephoneEventHandler(),
- last_received_frequency_(8000),
telephone_event_forward_to_decoder_(false),
telephone_event_payload_type_(-1),
cng_nb_payload_type_(-1),
cng_wb_payload_type_(-1),
cng_swb_payload_type_(-1),
cng_fb_payload_type_(-1),
- cng_payload_type_(-1),
- g722_payload_type_(-1),
- last_received_g722_(false),
num_energy_(0),
current_remote_energy_() {
last_payload_.Audio.channels = 1;
@@ -61,53 +57,12 @@ bool RTPReceiverAudio::TelephoneEventPayloadType(
return telephone_event_payload_type_ == payload_type;
}
-bool RTPReceiverAudio::CNGPayloadType(int8_t payload_type,
- uint32_t* frequency,
- bool* cng_payload_type_has_changed) {
+bool RTPReceiverAudio::CNGPayloadType(int8_t payload_type) {
rtc::CritScope lock(&crit_sect_);
- *cng_payload_type_has_changed = false;
-
- // We can have four CNG on 8000Hz, 16000Hz, 32000Hz and 48000Hz.
- if (cng_nb_payload_type_ == payload_type) {
- *frequency = 8000;
- if (cng_payload_type_ != -1 && cng_payload_type_ != cng_nb_payload_type_)
- *cng_payload_type_has_changed = true;
-
- cng_payload_type_ = cng_nb_payload_type_;
- return true;
- } else if (cng_wb_payload_type_ == payload_type) {
- // if last received codec is G.722 we must use frequency 8000
- if (last_received_g722_) {
- *frequency = 8000;
- } else {
- *frequency = 16000;
- }
- if (cng_payload_type_ != -1 && cng_payload_type_ != cng_wb_payload_type_)
- *cng_payload_type_has_changed = true;
- cng_payload_type_ = cng_wb_payload_type_;
- return true;
- } else if (cng_swb_payload_type_ == payload_type) {
- *frequency = 32000;
- if ((cng_payload_type_ != -1) &&
- (cng_payload_type_ != cng_swb_payload_type_))
- *cng_payload_type_has_changed = true;
- cng_payload_type_ = cng_swb_payload_type_;
- return true;
- } else if (cng_fb_payload_type_ == payload_type) {
- *frequency = 48000;
- if (cng_payload_type_ != -1 && cng_payload_type_ != cng_fb_payload_type_)
- *cng_payload_type_has_changed = true;
- cng_payload_type_ = cng_fb_payload_type_;
- return true;
- } else {
- // not CNG
- if (g722_payload_type_ == payload_type) {
- last_received_g722_ = true;
- } else {
- last_received_g722_ = false;
- }
- }
- return false;
+ return payload_type == cng_nb_payload_type_ ||
+ payload_type == cng_wb_payload_type_ ||
+ payload_type == cng_swb_payload_type_ ||
+ payload_type == cng_fb_payload_type_;
}
bool RTPReceiverAudio::ShouldReportCsrcChanges(uint8_t payload_type) const {
@@ -157,7 +112,7 @@ int32_t RTPReceiverAudio::OnNewPayloadTypeCreated(
telephone_event_payload_type_ = payload_type;
}
if (RtpUtility::StringCompare(payload_name, "cn", 2)) {
- // we can have three CNG on 8000Hz, 16000Hz and 32000Hz
+ // We support comfort noise at four different frequencies.
if (frequency == 8000) {
cng_nb_payload_type_ = payload_type;
} else if (frequency == 16000) {
@@ -204,14 +159,6 @@ int32_t RTPReceiverAudio::ParseRtpPacket(WebRtcRTPHeader* rtp_header,
is_red);
}
-int RTPReceiverAudio::GetPayloadTypeFrequency() const {
- rtc::CritScope lock(&crit_sect_);
- if (last_received_g722_) {
- return 8000;
- }
- return last_received_frequency_;
-}
-
RTPAliveType RTPReceiverAudio::ProcessDeadOrAlive(
uint16_t last_payload_length) const {
@@ -225,26 +172,10 @@ RTPAliveType RTPReceiverAudio::ProcessDeadOrAlive(
}
void RTPReceiverAudio::CheckPayloadChanged(int8_t payload_type,
- PayloadUnion* specific_payload,
+ PayloadUnion* /* specific_payload */,
bool* should_discard_changes) {
- *should_discard_changes = false;
-
- if (TelephoneEventPayloadType(payload_type)) {
- // Don't do callbacks for DTMF packets.
- *should_discard_changes = true;
- return;
- }
- // frequency is updated for CNG
- bool cng_payload_type_has_changed = false;
- bool is_cng_payload_type = CNGPayloadType(payload_type,
- &specific_payload->Audio.frequency,
- &cng_payload_type_has_changed);
-
- if (is_cng_payload_type) {
- // Don't do callbacks for DTMF packets.
- *should_discard_changes = true;
- return;
- }
+ *should_discard_changes =
+ TelephoneEventPayloadType(payload_type) || CNGPayloadType(payload_type);
}
int RTPReceiverAudio::Energy(uint8_t array_of_energy[kRtpCsrcSize]) const {
@@ -337,16 +268,8 @@ int32_t RTPReceiverAudio::ParseAudioCodecSpecific(
{
rtc::CritScope lock(&crit_sect_);
- if (!telephone_event_packet) {
- last_received_frequency_ = audio_specific.frequency;
- }
-
// Check if this is a CNG packet, receiver might want to know
- uint32_t ignored;
- bool also_ignored;
- if (CNGPayloadType(rtp_header->header.payloadType,
- &ignored,
- &also_ignored)) {
+ if (CNGPayloadType(rtp_header->header.payloadType)) {
rtp_header->type.Audio.isCNG = true;
rtp_header->frameType = kAudioFrameCN;
} else {
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtp_receiver_audio.h ('k') | webrtc/modules/rtp_rtcp/source/rtp_receiver_strategy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698