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

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

Issue 2365653004: AudioCodingModule: Specify decoders using SdpAudioFormat (Closed)
Patch Set: 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
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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 int RegisterReceiveCodec( 125 int RegisterReceiveCodec(
126 const CodecInst& receive_codec, 126 const CodecInst& receive_codec,
127 rtc::FunctionView<std::unique_ptr<AudioDecoder>()> isac_factory) override; 127 rtc::FunctionView<std::unique_ptr<AudioDecoder>()> isac_factory) override;
128 128
129 int RegisterExternalReceiveCodec(int rtp_payload_type, 129 int RegisterExternalReceiveCodec(int rtp_payload_type,
130 AudioDecoder* external_decoder, 130 AudioDecoder* external_decoder,
131 int sample_rate_hz, 131 int sample_rate_hz,
132 int num_channels, 132 int num_channels,
133 const std::string& name) override; 133 const std::string& name) override;
134 134
135 bool RegisterReceiveCodec(int rtp_payload_type,
136 const SdpAudioFormat& audio_format) override;
137
135 // Get current received codec. 138 // Get current received codec.
136 int ReceiveCodec(CodecInst* current_codec) const override; 139 int ReceiveCodec(CodecInst* current_codec) const override;
137 140
138 // Incoming packet from network parsed and ready for decode. 141 // Incoming packet from network parsed and ready for decode.
139 int IncomingPacket(const uint8_t* incoming_payload, 142 int IncomingPacket(const uint8_t* incoming_payload,
140 const size_t payload_length, 143 const size_t payload_length,
141 const WebRtcRTPHeader& rtp_info) override; 144 const WebRtcRTPHeader& rtp_info) override;
142 145
143 // Incoming payloads, without rtp-info, the rtp-info will be created in ACM. 146 // Incoming payloads, without rtp-info, the rtp-info will be created in ACM.
144 // One usage for this API is when pre-encoded files are pushed in ACM. 147 // One usage for this API is when pre-encoded files are pushed in ACM.
(...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after
1056 if (!acm2::RentACodec::IsPayloadTypeValid(rtp_payload_type)) { 1059 if (!acm2::RentACodec::IsPayloadTypeValid(rtp_payload_type)) {
1057 LOG_F(LS_ERROR) << "Invalid payload-type " << rtp_payload_type 1060 LOG_F(LS_ERROR) << "Invalid payload-type " << rtp_payload_type
1058 << " for external decoder."; 1061 << " for external decoder.";
1059 return -1; 1062 return -1;
1060 } 1063 }
1061 1064
1062 return receiver_.AddCodec(-1 /* external */, rtp_payload_type, num_channels, 1065 return receiver_.AddCodec(-1 /* external */, rtp_payload_type, num_channels,
1063 sample_rate_hz, external_decoder, name); 1066 sample_rate_hz, external_decoder, name);
1064 } 1067 }
1065 1068
1069 bool AudioCodingModuleImpl::RegisterReceiveCodec(
1070 int rtp_payload_type,
1071 const SdpAudioFormat& audio_format) {
1072 rtc::CritScope lock(&acm_crit_sect_);
1073 RTC_DCHECK(receiver_initialized_);
1074
1075 if (!acm2::RentACodec::IsPayloadTypeValid(rtp_payload_type)) {
1076 LOG_F(LS_ERROR) << "Invalid payload-type " << rtp_payload_type
1077 << " for external decoder.";
ossu 2016/09/28 14:12:28 Why distinguish "external decoder" here?
kwiberg-webrtc 2016/09/29 12:38:34 Because I cribbed this code from RegisterExternalR
1078 return false;
1079 }
1080
1081 return receiver_.AddCodec(rtp_payload_type, audio_format);
1082 }
1083
1066 // Get current received codec. 1084 // Get current received codec.
1067 int AudioCodingModuleImpl::ReceiveCodec(CodecInst* current_codec) const { 1085 int AudioCodingModuleImpl::ReceiveCodec(CodecInst* current_codec) const {
1068 rtc::CritScope lock(&acm_crit_sect_); 1086 rtc::CritScope lock(&acm_crit_sect_);
1069 return receiver_.LastAudioCodec(current_codec); 1087 return receiver_.LastAudioCodec(current_codec);
1070 } 1088 }
1071 1089
1072 // Incoming packet from network parsed and ready for decode. 1090 // Incoming packet from network parsed and ready for decode.
1073 int AudioCodingModuleImpl::IncomingPacket(const uint8_t* incoming_payload, 1091 int AudioCodingModuleImpl::IncomingPacket(const uint8_t* incoming_payload,
1074 const size_t payload_length, 1092 const size_t payload_length,
1075 const WebRtcRTPHeader& rtp_header) { 1093 const WebRtcRTPHeader& rtp_header) {
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
1356 // Checks the validity of the parameters of the given codec 1374 // Checks the validity of the parameters of the given codec
1357 bool AudioCodingModule::IsCodecValid(const CodecInst& codec) { 1375 bool AudioCodingModule::IsCodecValid(const CodecInst& codec) {
1358 bool valid = acm2::RentACodec::IsCodecValid(codec); 1376 bool valid = acm2::RentACodec::IsCodecValid(codec);
1359 if (!valid) 1377 if (!valid)
1360 WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, -1, 1378 WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, -1,
1361 "Invalid codec setting"); 1379 "Invalid codec setting");
1362 return valid; 1380 return valid;
1363 } 1381 }
1364 1382
1365 } // namespace webrtc 1383 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698