From 93a2febe737a5bfc25f3e9d443764e57de259d39 Mon Sep 17 00:00:00 2001 From: kwiberg Date: Thu, 5 Nov 2015 07:39:37 -0800 Subject: [PATCH] Move ACMCodecDB::ValidPayloadType to RentACodec BUG=webrtc:5028 Review URL: https://codereview.webrtc.org/1430043003 Cr-Commit-Position: refs/heads/master@{#10525} --- .../audio_coding/main/acm2/acm_codec_database.cc | 7 +------ .../audio_coding/main/acm2/acm_codec_database.h | 6 ------ .../main/acm2/audio_coding_module_impl.cc | 4 ++-- .../modules/audio_coding/main/acm2/codec_manager.cc | 12 +----------- webrtc/modules/audio_coding/main/acm2/rent_a_codec.h | 5 +++++ 5 files changed, 9 insertions(+), 25 deletions(-) diff --git a/webrtc/modules/audio_coding/main/acm2/acm_codec_database.cc b/webrtc/modules/audio_coding/main/acm2/acm_codec_database.cc index 59bb233eef..b69f5457c1 100644 --- a/webrtc/modules/audio_coding/main/acm2/acm_codec_database.cc +++ b/webrtc/modules/audio_coding/main/acm2/acm_codec_database.cc @@ -244,7 +244,7 @@ int ACMCodecDB::CodecNumber(const CodecInst& codec_inst) { } // Checks the validity of payload type - if (!ValidPayloadType(codec_inst.pltype)) { + if (!RentACodec::IsPayloadTypeValid(codec_inst.pltype)) { return kInvalidPayloadtype; } @@ -348,11 +348,6 @@ int ACMCodecDB::CodecFreq(int codec_id) { return i < db.size() ? db[i].plfreq : -1; } -// Checks if the payload type is in the valid range. -bool ACMCodecDB::ValidPayloadType(int payload_type) { - return (payload_type >= 0) && (payload_type <= 127); -} - } // namespace acm2 } // namespace webrtc diff --git a/webrtc/modules/audio_coding/main/acm2/acm_codec_database.h b/webrtc/modules/audio_coding/main/acm2/acm_codec_database.h index 885d106b43..ede0e6bccd 100644 --- a/webrtc/modules/audio_coding/main/acm2/acm_codec_database.h +++ b/webrtc/modules/audio_coding/main/acm2/acm_codec_database.h @@ -85,12 +85,6 @@ class ACMCodecDB { // codec sampling frequency if successful, otherwise -1. static int CodecFreq(int codec_id); - // Check if the payload type is valid, meaning that it is in the valid range - // of 0 to 127. - // Input: - // [payload_type] - payload type. - static bool ValidPayloadType(int payload_type); - private: // Databases with information about the supported codecs // database_ - stored information about all codecs: payload type, name, diff --git a/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.cc b/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.cc index aea64c9133..260f8a8e67 100644 --- a/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.cc +++ b/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.cc @@ -563,7 +563,7 @@ int AudioCodingModuleImpl::RegisterReceiveCodec(const CodecInst& codec) { RTC_CHECK(codec_index) << "Invalid codec ID: " << static_cast(*codec_id); // Check if the payload-type is valid. - if (!ACMCodecDB::ValidPayloadType(codec.pltype)) { + if (!RentACodec::IsPayloadTypeValid(codec.pltype)) { LOG_F(LS_ERROR) << "Invalid payload type " << codec.pltype << " for " << codec.plname; return -1; @@ -589,7 +589,7 @@ int AudioCodingModuleImpl::RegisterExternalReceiveCodec( } // Check if the payload-type is valid. - if (!ACMCodecDB::ValidPayloadType(rtp_payload_type)) { + if (!RentACodec::IsPayloadTypeValid(rtp_payload_type)) { LOG_F(LS_ERROR) << "Invalid payload-type " << rtp_payload_type << " for external decoder."; return -1; diff --git a/webrtc/modules/audio_coding/main/acm2/codec_manager.cc b/webrtc/modules/audio_coding/main/acm2/codec_manager.cc index a1303262cd..4d245055f9 100644 --- a/webrtc/modules/audio_coding/main/acm2/codec_manager.cc +++ b/webrtc/modules/audio_coding/main/acm2/codec_manager.cc @@ -46,16 +46,6 @@ int IsValidSendCodec(const CodecInst& send_codec, bool is_primary_encoder) { return -1; } - // TODO(tlegrand): Remove this check. Already taken care of in - // ACMCodecDB::CodecNumber(). - // Check if the payload-type is valid - if (!ACMCodecDB::ValidPayloadType(send_codec.pltype)) { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, dummy_id, - "Invalid payload-type %d for %s.", send_codec.pltype, - send_codec.plname); - return -1; - } - // Telephone-event cannot be a send codec. if (!STR_CASE_CMP(send_codec.plname, "telephone-event")) { WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, dummy_id, @@ -198,7 +188,7 @@ int CodecManager::RegisterEncoder(const CodecInst& send_codec) { // TODO(tlegrand): Remove this check. Already taken care of in // ACMCodecDB::CodecNumber(). // Check if the payload-type is valid - if (!ACMCodecDB::ValidPayloadType(send_codec.pltype)) { + if (!RentACodec::IsPayloadTypeValid(send_codec.pltype)) { WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, dummy_id, "Invalid payload-type %d for %s.", send_codec.pltype, send_codec.plname); diff --git a/webrtc/modules/audio_coding/main/acm2/rent_a_codec.h b/webrtc/modules/audio_coding/main/acm2/rent_a_codec.h index 50d8c54ab4..98052e7bda 100644 --- a/webrtc/modules/audio_coding/main/acm2/rent_a_codec.h +++ b/webrtc/modules/audio_coding/main/acm2/rent_a_codec.h @@ -152,6 +152,11 @@ class RentACodec { int sampling_freq_hz, int channels); static bool IsCodecValid(const CodecInst& codec_inst); + + static inline bool IsPayloadTypeValid(int payload_type) { + return payload_type >= 0 && payload_type <= 127; + } + static rtc::ArrayView Database(); static rtc::Maybe IsSupportedNumChannels(CodecId codec_id,