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

Side by Side Diff: webrtc/media/engine/webrtcvoiceengine.cc

Issue 2123923004: Updated AudioDecoderFactory to list AudioCodecSpecs instead of SdpAudioFormats. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@audio-decoder-factory-usage
Patch Set: Created 4 years, 5 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) 2004 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2004 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 1065 matching lines...) Expand 10 before | Expand all | Expand 10 after
1076 1076
1077 webrtc::AudioDeviceModule* WebRtcVoiceEngine::adm() { 1077 webrtc::AudioDeviceModule* WebRtcVoiceEngine::adm() {
1078 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1078 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1079 RTC_DCHECK(adm_); 1079 RTC_DCHECK(adm_);
1080 return adm_; 1080 return adm_;
1081 } 1081 }
1082 1082
1083 AudioCodecs WebRtcVoiceEngine::CollectRecvCodecs() const { 1083 AudioCodecs WebRtcVoiceEngine::CollectRecvCodecs() const {
1084 PayloadTypeMapper mapper; 1084 PayloadTypeMapper mapper;
1085 AudioCodecs out; 1085 AudioCodecs out;
1086 const std::vector<webrtc::SdpAudioFormat>& formats = 1086 const std::vector<webrtc::AudioCodecSpec>& specs =
1087 decoder_factory_->GetSupportedFormats(); 1087 decoder_factory_->GetSupportedDecoders();
1088 1088
1089 // Only generate CN payload types for these clockrates 1089 // Only generate CN payload types for these clockrates
1090 std::vector<int> cn_clockrates = { 8000, 16000, 32000 }; 1090 std::vector<int> cn_clockrates = { 8000, 16000, 32000 };
1091 1091
1092 auto map_format = [&mapper, &out] (const webrtc::SdpAudioFormat& format) { 1092 auto map_format = [&mapper, &out] (const webrtc::SdpAudioFormat& format) {
1093 rtc::Optional<AudioCodec> opt_codec = mapper.ToAudioCodec(format); 1093 rtc::Optional<AudioCodec> opt_codec = mapper.ToAudioCodec(format);
1094 if (opt_codec) { 1094 if (opt_codec) {
1095 out.push_back(*opt_codec); 1095 out.push_back(*opt_codec);
1096 } else { 1096 } else {
1097 LOG(LS_ERROR) << "Unable to assign payload type to format: " << format; 1097 LOG(LS_ERROR) << "Unable to assign payload type to format: " << format;
1098 } 1098 }
1099 }; 1099 };
1100 1100
1101 for (const auto& format : formats) { 1101 for (const auto& spec : specs) {
1102 rtc::Optional<AudioCodec> opt_codec = mapper.ToAudioCodec(format); 1102 rtc::Optional<AudioCodec> opt_codec = mapper.ToAudioCodec(spec.format);
1103 if (opt_codec) { 1103 if (opt_codec) {
1104 auto& codec = *opt_codec; 1104 auto& codec = *opt_codec;
1105 1105
1106 if (IsCodec(codec, kOpusCodecName)) { 1106 if (IsCodec(codec, kOpusCodecName)) {
1107 // TODO(ossu): Should we set this specifically for just this codec? 1107 // TODO(ossu): Investigate if this can be replaced by a wildcard rtcp-fb
1108 // If not, this can be replaced with a call to map_format. 1108 // param.
1109 codec.AddFeedbackParam( 1109 codec.AddFeedbackParam(
1110 FeedbackParam(kRtcpFbParamTransportCc, kParamValueEmpty)); 1110 FeedbackParam(kRtcpFbParamTransportCc, kParamValueEmpty));
1111 } 1111 }
1112 out.push_back(codec); 1112 out.push_back(codec);
1113 1113
1114 // TODO(ossu): We should get more than just a format from the factory, so 1114 if (spec.allow_comfort_noise) {
1115 // we can determine if a format should be used with CN or not. For now, 1115 auto cn = std::find(cn_clockrates.begin(), cn_clockrates.end(),
1116 // generate a CN entry for each supported clock rate also used by a format 1116 spec.format.clockrate_hz);
1117 // supported by the factory. 1117 if (cn != cn_clockrates.end()) {
1118 auto cn = std::find(cn_clockrates.begin(), cn_clockrates.end(), 1118 map_format({kCnCodecName, spec.format.clockrate_hz, 1});
1119 format.clockrate_hz); 1119 *cn = cn_clockrates.back();
1120 if (cn != cn_clockrates.end() /* && format.allow_comfort_noise */) { 1120 cn_clockrates.pop_back();
1121 map_format({kCnCodecName, format.clockrate_hz, 1}); 1121 }
1122 *cn = cn_clockrates.back();
1123 cn_clockrates.pop_back();
1124 } 1122 }
1125 } else { 1123 } else {
1126 LOG(LS_ERROR) << "Unable to assign payload type to format: " << format; 1124 LOG(LS_ERROR) << "Unable to assign payload type to format: "
1125 << spec.format;
1127 } 1126 }
1128 } 1127 }
1129 1128
1130 // Add telephone-event codec 1129 // Add telephone-event codec
1131 map_format({kDtmfCodecName, 8000, 1}); 1130 map_format({kDtmfCodecName, 8000, 1});
1132 1131
1133 return out; 1132 return out;
1134 } 1133 }
1135 1134
1136 class WebRtcVoiceMediaChannel::WebRtcAudioSendStream 1135 class WebRtcVoiceMediaChannel::WebRtcAudioSendStream
(...skipping 1531 matching lines...) Expand 10 before | Expand all | Expand 10 after
2668 } 2667 }
2669 } else { 2668 } else {
2670 LOG(LS_INFO) << "Stopping playout for channel #" << channel; 2669 LOG(LS_INFO) << "Stopping playout for channel #" << channel;
2671 engine()->voe()->base()->StopPlayout(channel); 2670 engine()->voe()->base()->StopPlayout(channel);
2672 } 2671 }
2673 return true; 2672 return true;
2674 } 2673 }
2675 } // namespace cricket 2674 } // namespace cricket
2676 2675
2677 #endif // HAVE_WEBRTC_VOICE 2676 #endif // HAVE_WEBRTC_VOICE
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698