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

Side by Side Diff: webrtc/modules/audio_coding/acm2/audio_coding_module.cc

Issue 2392743004: Remove old AudioCodingModule::RegisterReceiveCodec overloads
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 unified diff | Download patch
« no previous file with comments | « no previous file | webrtc/modules/audio_coding/include/audio_coding_module.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 117
118 // Get current receive frequency. 118 // Get current receive frequency.
119 int ReceiveFrequency() const override; 119 int ReceiveFrequency() const override;
120 120
121 // Get current playout frequency. 121 // Get current playout frequency.
122 int PlayoutFrequency() const override; 122 int PlayoutFrequency() const override;
123 123
124 bool RegisterReceiveCodec(int rtp_payload_type, 124 bool RegisterReceiveCodec(int rtp_payload_type,
125 const SdpAudioFormat& audio_format) override; 125 const SdpAudioFormat& audio_format) override;
126 126
127 int RegisterReceiveCodec(const CodecInst& receive_codec) override;
128 int RegisterReceiveCodec(
129 const CodecInst& receive_codec,
130 rtc::FunctionView<std::unique_ptr<AudioDecoder>()> isac_factory) override;
131
132 int RegisterExternalReceiveCodec(int rtp_payload_type,
133 AudioDecoder* external_decoder,
134 int sample_rate_hz,
135 int num_channels,
136 const std::string& name) override;
137
138 // Get current received codec. 127 // Get current received codec.
139 int ReceiveCodec(CodecInst* current_codec) const override; 128 int ReceiveCodec(CodecInst* current_codec) const override;
140 129
141 rtc::Optional<SdpAudioFormat> ReceiveFormat() const override; 130 rtc::Optional<SdpAudioFormat> ReceiveFormat() const override;
142 131
143 // Incoming packet from network parsed and ready for decode. 132 // Incoming packet from network parsed and ready for decode.
144 int IncomingPacket(const uint8_t* incoming_payload, 133 int IncomingPacket(const uint8_t* incoming_payload,
145 const size_t payload_length, 134 const size_t payload_length,
146 const WebRtcRTPHeader& rtp_info) override; 135 const WebRtcRTPHeader& rtp_info) override;
147 136
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 // Logs the new value if it is different from the last logged value, or if 209 // Logs the new value if it is different from the last logged value, or if
221 // this is the first call. 210 // this is the first call.
222 void MaybeLog(int value); 211 void MaybeLog(int value);
223 212
224 private: 213 private:
225 int last_value_ = 0; 214 int last_value_ = 0;
226 int first_time_ = true; 215 int first_time_ = true;
227 const std::string histogram_name_; 216 const std::string histogram_name_;
228 }; 217 };
229 218
230 int RegisterReceiveCodecUnlocked(
231 const CodecInst& codec,
232 rtc::FunctionView<std::unique_ptr<AudioDecoder>()> isac_factory)
233 EXCLUSIVE_LOCKS_REQUIRED(acm_crit_sect_);
234
235 int Add10MsDataInternal(const AudioFrame& audio_frame, InputData* input_data) 219 int Add10MsDataInternal(const AudioFrame& audio_frame, InputData* input_data)
236 EXCLUSIVE_LOCKS_REQUIRED(acm_crit_sect_); 220 EXCLUSIVE_LOCKS_REQUIRED(acm_crit_sect_);
237 int Encode(const InputData& input_data) 221 int Encode(const InputData& input_data)
238 EXCLUSIVE_LOCKS_REQUIRED(acm_crit_sect_); 222 EXCLUSIVE_LOCKS_REQUIRED(acm_crit_sect_);
239 223
240 int InitializeReceiverSafe() EXCLUSIVE_LOCKS_REQUIRED(acm_crit_sect_); 224 int InitializeReceiverSafe() EXCLUSIVE_LOCKS_REQUIRED(acm_crit_sect_);
241 225
242 bool HaveValidEncoder(const char* caller_name) const 226 bool HaveValidEncoder(const char* caller_name) const
243 EXCLUSIVE_LOCKS_REQUIRED(acm_crit_sect_); 227 EXCLUSIVE_LOCKS_REQUIRED(acm_crit_sect_);
244 228
(...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after
1000 984
1001 if (!acm2::RentACodec::IsPayloadTypeValid(rtp_payload_type)) { 985 if (!acm2::RentACodec::IsPayloadTypeValid(rtp_payload_type)) {
1002 LOG_F(LS_ERROR) << "Invalid payload-type " << rtp_payload_type 986 LOG_F(LS_ERROR) << "Invalid payload-type " << rtp_payload_type
1003 << " for decoder."; 987 << " for decoder.";
1004 return false; 988 return false;
1005 } 989 }
1006 990
1007 return receiver_.AddCodec(rtp_payload_type, audio_format); 991 return receiver_.AddCodec(rtp_payload_type, audio_format);
1008 } 992 }
1009 993
1010 int AudioCodingModuleImpl::RegisterReceiveCodec(const CodecInst& codec) {
1011 rtc::CritScope lock(&acm_crit_sect_);
1012 auto* ef = encoder_factory_.get();
1013 return RegisterReceiveCodecUnlocked(
1014 codec, [&] { return ef->rent_a_codec.RentIsacDecoder(codec.plfreq); });
1015 }
1016
1017 int AudioCodingModuleImpl::RegisterReceiveCodec(
1018 const CodecInst& codec,
1019 rtc::FunctionView<std::unique_ptr<AudioDecoder>()> isac_factory) {
1020 rtc::CritScope lock(&acm_crit_sect_);
1021 return RegisterReceiveCodecUnlocked(codec, isac_factory);
1022 }
1023
1024 int AudioCodingModuleImpl::RegisterReceiveCodecUnlocked(
1025 const CodecInst& codec,
1026 rtc::FunctionView<std::unique_ptr<AudioDecoder>()> isac_factory) {
1027 RTC_DCHECK(receiver_initialized_);
1028 if (codec.channels > 2) {
1029 LOG_F(LS_ERROR) << "Unsupported number of channels: " << codec.channels;
1030 return -1;
1031 }
1032
1033 auto codec_id = acm2::RentACodec::CodecIdByParams(codec.plname, codec.plfreq,
1034 codec.channels);
1035 if (!codec_id) {
1036 LOG_F(LS_ERROR) << "Wrong codec params to be registered as receive codec";
1037 return -1;
1038 }
1039 auto codec_index = acm2::RentACodec::CodecIndexFromId(*codec_id);
1040 RTC_CHECK(codec_index) << "Invalid codec ID: " << static_cast<int>(*codec_id);
1041
1042 // Check if the payload-type is valid.
1043 if (!acm2::RentACodec::IsPayloadTypeValid(codec.pltype)) {
1044 LOG_F(LS_ERROR) << "Invalid payload type " << codec.pltype << " for "
1045 << codec.plname;
1046 return -1;
1047 }
1048
1049 AudioDecoder* isac_decoder = nullptr;
1050 if (STR_CASE_CMP(codec.plname, "isac") == 0) {
1051 std::unique_ptr<AudioDecoder>& saved_isac_decoder =
1052 codec.plfreq == 16000 ? isac_decoder_16k_ : isac_decoder_32k_;
1053 if (!saved_isac_decoder) {
1054 saved_isac_decoder = isac_factory();
1055 }
1056 isac_decoder = saved_isac_decoder.get();
1057 }
1058 return receiver_.AddCodec(*codec_index, codec.pltype, codec.channels,
1059 codec.plfreq, isac_decoder, codec.plname);
1060 }
1061
1062 int AudioCodingModuleImpl::RegisterExternalReceiveCodec(
1063 int rtp_payload_type,
1064 AudioDecoder* external_decoder,
1065 int sample_rate_hz,
1066 int num_channels,
1067 const std::string& name) {
1068 rtc::CritScope lock(&acm_crit_sect_);
1069 RTC_DCHECK(receiver_initialized_);
1070 if (num_channels > 2 || num_channels < 0) {
1071 LOG_F(LS_ERROR) << "Unsupported number of channels: " << num_channels;
1072 return -1;
1073 }
1074
1075 // Check if the payload-type is valid.
1076 if (!acm2::RentACodec::IsPayloadTypeValid(rtp_payload_type)) {
1077 LOG_F(LS_ERROR) << "Invalid payload-type " << rtp_payload_type
1078 << " for external decoder.";
1079 return -1;
1080 }
1081
1082 return receiver_.AddCodec(-1 /* external */, rtp_payload_type, num_channels,
1083 sample_rate_hz, external_decoder, name);
1084 }
1085
1086 // Get current received codec. 994 // Get current received codec.
1087 int AudioCodingModuleImpl::ReceiveCodec(CodecInst* current_codec) const { 995 int AudioCodingModuleImpl::ReceiveCodec(CodecInst* current_codec) const {
1088 rtc::CritScope lock(&acm_crit_sect_); 996 rtc::CritScope lock(&acm_crit_sect_);
1089 return receiver_.LastAudioCodec(current_codec); 997 return receiver_.LastAudioCodec(current_codec);
1090 } 998 }
1091 999
1092 rtc::Optional<SdpAudioFormat> AudioCodingModuleImpl::ReceiveFormat() const { 1000 rtc::Optional<SdpAudioFormat> AudioCodingModuleImpl::ReceiveFormat() const {
1093 rtc::CritScope lock(&acm_crit_sect_); 1001 rtc::CritScope lock(&acm_crit_sect_);
1094 return receiver_.LastAudioFormat(); 1002 return receiver_.LastAudioFormat();
1095 } 1003 }
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
1381 // Checks the validity of the parameters of the given codec 1289 // Checks the validity of the parameters of the given codec
1382 bool AudioCodingModule::IsCodecValid(const CodecInst& codec) { 1290 bool AudioCodingModule::IsCodecValid(const CodecInst& codec) {
1383 bool valid = acm2::RentACodec::IsCodecValid(codec); 1291 bool valid = acm2::RentACodec::IsCodecValid(codec);
1384 if (!valid) 1292 if (!valid)
1385 WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, -1, 1293 WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, -1,
1386 "Invalid codec setting"); 1294 "Invalid codec setting");
1387 return valid; 1295 return valid;
1388 } 1296 }
1389 1297
1390 } // namespace webrtc 1298 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | webrtc/modules/audio_coding/include/audio_coding_module.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698