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

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

Issue 2669583002: Added a flag to AudioCodecSpec to indicate adaptive bitrate support. (Closed)
Patch Set: int -> size_t to avoid unsigned/signed mismatch warnings on Windows. Created 3 years, 10 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 1148 matching lines...) Expand 10 before | Expand all | Expand 10 after
1159 // Only generate CN payload types for these clockrates: 1159 // Only generate CN payload types for these clockrates:
1160 std::map<int, bool, std::greater<int>> generate_cn = {{ 8000, false }, 1160 std::map<int, bool, std::greater<int>> generate_cn = {{ 8000, false },
1161 { 16000, false }, 1161 { 16000, false },
1162 { 32000, false }}; 1162 { 32000, false }};
1163 // Only generate telephone-event payload types for these clockrates: 1163 // Only generate telephone-event payload types for these clockrates:
1164 std::map<int, bool, std::greater<int>> generate_dtmf = {{ 8000, false }, 1164 std::map<int, bool, std::greater<int>> generate_dtmf = {{ 8000, false },
1165 { 16000, false }, 1165 { 16000, false },
1166 { 32000, false }, 1166 { 32000, false },
1167 { 48000, false }}; 1167 { 48000, false }};
1168 1168
1169 auto map_format = [&mapper, &out] (const webrtc::SdpAudioFormat& format) { 1169 auto map_format = [&mapper](const webrtc::SdpAudioFormat& format,
1170 AudioCodecs* out) {
1170 rtc::Optional<AudioCodec> opt_codec = mapper.ToAudioCodec(format); 1171 rtc::Optional<AudioCodec> opt_codec = mapper.ToAudioCodec(format);
1171 if (!opt_codec) { 1172 if (opt_codec) {
1173 if (out) {
1174 out->push_back(*opt_codec);
1175 }
1176 } else {
1172 LOG(LS_ERROR) << "Unable to assign payload type to format: " << format; 1177 LOG(LS_ERROR) << "Unable to assign payload type to format: " << format;
1173 return false;
1174 } 1178 }
1175 1179
1176 auto& codec = *opt_codec; 1180 return opt_codec;
1177 if (IsCodec(codec, kOpusCodecName)) {
1178 // TODO(ossu): Set this specifically for Opus for now, until we have a
1179 // better way of dealing with rtcp-fb parameters.
1180 codec.AddFeedbackParam(
1181 FeedbackParam(kRtcpFbParamTransportCc, kParamValueEmpty));
1182 }
1183 out.push_back(codec);
1184 return true;
1185 }; 1181 };
1186 1182
1187 for (const auto& spec : specs) { 1183 for (const auto& spec : specs) {
1188 if (map_format(spec.format)) { 1184 // We need to do some extra stuff before adding the main codecs to out.
1185 rtc::Optional<AudioCodec> opt_codec = map_format(spec.format, nullptr);
1186 if (opt_codec) {
1187 AudioCodec& codec = *opt_codec;
1188 if (spec.supports_network_adaption) {
1189 codec.AddFeedbackParam(
1190 FeedbackParam(kRtcpFbParamTransportCc, kParamValueEmpty));
1191 }
1192
1189 if (spec.allow_comfort_noise) { 1193 if (spec.allow_comfort_noise) {
1190 // Generate a CN entry if the decoder allows it and we support the 1194 // Generate a CN entry if the decoder allows it and we support the
1191 // clockrate. 1195 // clockrate.
1192 auto cn = generate_cn.find(spec.format.clockrate_hz); 1196 auto cn = generate_cn.find(spec.format.clockrate_hz);
1193 if (cn != generate_cn.end()) { 1197 if (cn != generate_cn.end()) {
1194 cn->second = true; 1198 cn->second = true;
1195 } 1199 }
1196 } 1200 }
1197 1201
1198 // Generate a telephone-event entry if we support the clockrate. 1202 // Generate a telephone-event entry if we support the clockrate.
1199 auto dtmf = generate_dtmf.find(spec.format.clockrate_hz); 1203 auto dtmf = generate_dtmf.find(spec.format.clockrate_hz);
1200 if (dtmf != generate_dtmf.end()) { 1204 if (dtmf != generate_dtmf.end()) {
1201 dtmf->second = true; 1205 dtmf->second = true;
1202 } 1206 }
1207
1208 out.push_back(codec);
1203 } 1209 }
1204 } 1210 }
1205 1211
1206 // Add CN codecs after "proper" audio codecs. 1212 // Add CN codecs after "proper" audio codecs.
1207 for (const auto& cn : generate_cn) { 1213 for (const auto& cn : generate_cn) {
1208 if (cn.second) { 1214 if (cn.second) {
1209 map_format({kCnCodecName, cn.first, 1}); 1215 map_format({kCnCodecName, cn.first, 1}, &out);
1210 } 1216 }
1211 } 1217 }
1212 1218
1213 // Add telephone-event codecs last. 1219 // Add telephone-event codecs last.
1214 for (const auto& dtmf : generate_dtmf) { 1220 for (const auto& dtmf : generate_dtmf) {
1215 if (dtmf.second) { 1221 if (dtmf.second) {
1216 map_format({kDtmfCodecName, dtmf.first, 1}); 1222 map_format({kDtmfCodecName, dtmf.first, 1}, &out);
1217 } 1223 }
1218 } 1224 }
1219 1225
1220 return out; 1226 return out;
1221 } 1227 }
1222 1228
1223 class WebRtcVoiceMediaChannel::WebRtcAudioSendStream 1229 class WebRtcVoiceMediaChannel::WebRtcAudioSendStream
1224 : public AudioSource::Sink { 1230 : public AudioSource::Sink {
1225 public: 1231 public:
1226 WebRtcAudioSendStream( 1232 WebRtcAudioSendStream(
(...skipping 1492 matching lines...) Expand 10 before | Expand all | Expand 10 after
2719 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 2725 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
2720 const auto it = send_streams_.find(ssrc); 2726 const auto it = send_streams_.find(ssrc);
2721 if (it != send_streams_.end()) { 2727 if (it != send_streams_.end()) {
2722 return it->second->channel(); 2728 return it->second->channel();
2723 } 2729 }
2724 return -1; 2730 return -1;
2725 } 2731 }
2726 } // namespace cricket 2732 } // namespace cricket
2727 2733
2728 #endif // HAVE_WEBRTC_VOICE 2734 #endif // HAVE_WEBRTC_VOICE
OLDNEW
« no previous file with comments | « no previous file | webrtc/media/engine/webrtcvoiceengine_unittest.cc » ('j') | webrtc/media/engine/webrtcvoiceengine_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698