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

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: Rebase 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
« no previous file with comments | « no previous file | webrtc/modules/audio_coding/codecs/audio_decoder_factory.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) 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 1075 matching lines...) Expand 10 before | Expand all | Expand 10 after
1086 1086
1087 webrtc::AudioDeviceModule* WebRtcVoiceEngine::adm() { 1087 webrtc::AudioDeviceModule* WebRtcVoiceEngine::adm() {
1088 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1088 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1089 RTC_DCHECK(adm_); 1089 RTC_DCHECK(adm_);
1090 return adm_; 1090 return adm_;
1091 } 1091 }
1092 1092
1093 AudioCodecs WebRtcVoiceEngine::CollectRecvCodecs() const { 1093 AudioCodecs WebRtcVoiceEngine::CollectRecvCodecs() const {
1094 PayloadTypeMapper mapper; 1094 PayloadTypeMapper mapper;
1095 AudioCodecs out; 1095 AudioCodecs out;
1096 const std::vector<webrtc::SdpAudioFormat>& formats = 1096 const std::vector<webrtc::AudioCodecSpec>& specs =
1097 decoder_factory_->GetSupportedFormats(); 1097 decoder_factory_->GetSupportedDecoders();
1098 1098
1099 // Only generate CN payload types for these clockrates 1099 // Only generate CN payload types for these clockrates
1100 std::map<int, bool, std::greater<int>> generate_cn = {{ 8000, false }, 1100 std::map<int, bool, std::greater<int>> generate_cn = {{ 8000, false },
1101 { 16000, false }, 1101 { 16000, false },
1102 { 32000, false }}; 1102 { 32000, false }};
1103 1103
1104 auto map_format = [&mapper, &out] (const webrtc::SdpAudioFormat& format) { 1104 auto map_format = [&mapper, &out] (const webrtc::SdpAudioFormat& format) {
1105 rtc::Optional<AudioCodec> opt_codec = mapper.ToAudioCodec(format); 1105 rtc::Optional<AudioCodec> opt_codec = mapper.ToAudioCodec(format);
1106 if (!opt_codec) { 1106 if (!opt_codec) {
1107 LOG(LS_ERROR) << "Unable to assign payload type to format: " << format; 1107 LOG(LS_ERROR) << "Unable to assign payload type to format: " << format;
1108 return false; 1108 return false;
1109 } 1109 }
1110 1110
1111 auto& codec = *opt_codec; 1111 auto& codec = *opt_codec;
1112 if (IsCodec(codec, kOpusCodecName)) { 1112 if (IsCodec(codec, kOpusCodecName)) {
1113 // TODO(ossu): Set this specifically for Opus for now, until we have a 1113 // TODO(ossu): Set this specifically for Opus for now, until we have a
1114 // better way of dealing with rtcp-fb parameters. 1114 // better way of dealing with rtcp-fb parameters.
1115 codec.AddFeedbackParam( 1115 codec.AddFeedbackParam(
1116 FeedbackParam(kRtcpFbParamTransportCc, kParamValueEmpty)); 1116 FeedbackParam(kRtcpFbParamTransportCc, kParamValueEmpty));
1117 } 1117 }
1118 out.push_back(codec); 1118 out.push_back(codec);
1119 return true; 1119 return true;
1120 }; 1120 };
1121 1121
1122 for (const auto& format : formats) { 1122 for (const auto& spec : specs) {
1123 if (map_format(format)) { 1123 if (map_format(spec.format) && spec.allow_comfort_noise) {
1124 // TODO(ossu): We should get more than just a format from the factory, so 1124 // Generate a CN entry if the decoder allows it and we support the
1125 // we can determine if a format should be used with CN or not. For now, 1125 // clockrate.
1126 // generate a CN entry for each supported clock rate also used by a format 1126 auto cn = generate_cn.find(spec.format.clockrate_hz);
1127 // supported by the factory. 1127 if (cn != generate_cn.end()) {
1128 auto cn = generate_cn.find(format.clockrate_hz);
1129 if (cn != generate_cn.end() /* && format.allow_comfort_noise */) {
1130 cn->second = true; 1128 cn->second = true;
1131 } 1129 }
1132 } 1130 }
1133 } 1131 }
1134 1132
1135 // Add CN codecs after "proper" audio codecs 1133 // Add CN codecs after "proper" audio codecs
1136 for (const auto& cn : generate_cn) { 1134 for (const auto& cn : generate_cn) {
1137 if (cn.second) { 1135 if (cn.second) {
1138 map_format({kCnCodecName, cn.first, 1}); 1136 map_format({kCnCodecName, cn.first, 1});
1139 } 1137 }
(...skipping 1540 matching lines...) Expand 10 before | Expand all | Expand 10 after
2680 } 2678 }
2681 } else { 2679 } else {
2682 LOG(LS_INFO) << "Stopping playout for channel #" << channel; 2680 LOG(LS_INFO) << "Stopping playout for channel #" << channel;
2683 engine()->voe()->base()->StopPlayout(channel); 2681 engine()->voe()->base()->StopPlayout(channel);
2684 } 2682 }
2685 return true; 2683 return true;
2686 } 2684 }
2687 } // namespace cricket 2685 } // namespace cricket
2688 2686
2689 #endif // HAVE_WEBRTC_VOICE 2687 #endif // HAVE_WEBRTC_VOICE
OLDNEW
« no previous file with comments | « no previous file | webrtc/modules/audio_coding/codecs/audio_decoder_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698