OLD | NEW |
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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 config.voice_engine = voe_wrapper->engine(); | 243 config.voice_engine = voe_wrapper->engine(); |
244 return config; | 244 return config; |
245 } | 245 } |
246 | 246 |
247 class WebRtcVoiceCodecs final { | 247 class WebRtcVoiceCodecs final { |
248 public: | 248 public: |
249 // TODO(solenberg): Do this filtering once off-line, add a simple AudioCodec | 249 // TODO(solenberg): Do this filtering once off-line, add a simple AudioCodec |
250 // list and add a test which verifies VoE supports the listed codecs. | 250 // list and add a test which verifies VoE supports the listed codecs. |
251 static std::vector<AudioCodec> SupportedCodecs() { | 251 static std::vector<AudioCodec> SupportedCodecs() { |
252 std::vector<AudioCodec> result; | 252 std::vector<AudioCodec> result; |
253 for (webrtc::CodecInst voe_codec : webrtc::acm2::RentACodec::Database()) { | 253 // Iterate first over our preferred codecs list, so that the results are |
254 // Change the sample rate of G722 to 8000 to match SDP. | 254 // added in order of preference. |
255 MaybeFixupG722(&voe_codec, 8000); | 255 for (size_t i = 0; i < arraysize(kCodecPrefs); ++i) { |
256 // Skip uncompressed formats. | 256 const CodecPref* pref = &kCodecPrefs[i]; |
257 if (IsCodec(voe_codec, kL16CodecName)) { | 257 for (webrtc::CodecInst voe_codec : webrtc::acm2::RentACodec::Database()) { |
258 continue; | 258 // Change the sample rate of G722 to 8000 to match SDP. |
259 } | 259 MaybeFixupG722(&voe_codec, 8000); |
| 260 // Skip uncompressed formats. |
| 261 if (IsCodec(voe_codec, kL16CodecName)) { |
| 262 continue; |
| 263 } |
260 | 264 |
261 const CodecPref* pref = NULL; | 265 if (!IsCodec(voe_codec, pref->name) || |
262 for (size_t j = 0; j < arraysize(kCodecPrefs); ++j) { | 266 pref->clockrate != voe_codec.plfreq || |
263 if (IsCodec(voe_codec, kCodecPrefs[j].name) && | 267 pref->channels != voe_codec.channels) { |
264 kCodecPrefs[j].clockrate == voe_codec.plfreq && | 268 // Not a match. |
265 kCodecPrefs[j].channels == voe_codec.channels) { | 269 continue; |
266 pref = &kCodecPrefs[j]; | |
267 break; | |
268 } | 270 } |
269 } | |
270 | 271 |
271 if (pref) { | 272 AudioCodec codec(pref->payload_type, voe_codec.plname, voe_codec.plfreq, |
272 // Use the payload type that we've configured in our pref table; | 273 voe_codec.rate, voe_codec.channels); |
273 // use the offset in our pref table to determine the sort order. | 274 LOG(LS_INFO) << "Adding supported codec: " << ToString(codec); |
274 AudioCodec codec( | |
275 pref->payload_type, voe_codec.plname, voe_codec.plfreq, | |
276 voe_codec.rate, voe_codec.channels, | |
277 static_cast<int>(arraysize(kCodecPrefs)) - (pref - kCodecPrefs)); | |
278 if (IsCodec(codec, kIsacCodecName)) { | 275 if (IsCodec(codec, kIsacCodecName)) { |
279 // Indicate auto-bitrate in signaling. | 276 // Indicate auto-bitrate in signaling. |
280 codec.bitrate = 0; | 277 codec.bitrate = 0; |
281 } | 278 } |
282 if (IsCodec(codec, kOpusCodecName)) { | 279 if (IsCodec(codec, kOpusCodecName)) { |
283 // Only add fmtp parameters that differ from the spec. | 280 // Only add fmtp parameters that differ from the spec. |
284 if (kPreferredMinPTime != kOpusDefaultMinPTime) { | 281 if (kPreferredMinPTime != kOpusDefaultMinPTime) { |
285 codec.params[kCodecParamMinPTime] = | 282 codec.params[kCodecParamMinPTime] = |
286 rtc::ToString(kPreferredMinPTime); | 283 rtc::ToString(kPreferredMinPTime); |
287 } | 284 } |
288 if (kPreferredMaxPTime != kOpusDefaultMaxPTime) { | 285 if (kPreferredMaxPTime != kOpusDefaultMaxPTime) { |
289 codec.params[kCodecParamMaxPTime] = | 286 codec.params[kCodecParamMaxPTime] = |
290 rtc::ToString(kPreferredMaxPTime); | 287 rtc::ToString(kPreferredMaxPTime); |
291 } | 288 } |
292 codec.SetParam(kCodecParamUseInbandFec, 1); | 289 codec.SetParam(kCodecParamUseInbandFec, 1); |
293 codec.AddFeedbackParam( | 290 codec.AddFeedbackParam( |
294 FeedbackParam(kRtcpFbParamTransportCc, kParamValueEmpty)); | 291 FeedbackParam(kRtcpFbParamTransportCc, kParamValueEmpty)); |
295 | 292 |
296 // TODO(hellner): Add ptime, sprop-stereo, and stereo | 293 // TODO(hellner): Add ptime, sprop-stereo, and stereo |
297 // when they can be set to values other than the default. | 294 // when they can be set to values other than the default. |
298 } | 295 } |
299 result.push_back(codec); | 296 result.push_back(codec); |
300 } else { | |
301 LOG(LS_INFO) << "[Unused] " << ToString(voe_codec); | |
302 } | 297 } |
303 } | 298 } |
304 // Make sure they are in local preference order. | |
305 std::sort(result.begin(), result.end(), &AudioCodec::Preferable); | |
306 return result; | 299 return result; |
307 } | 300 } |
308 | 301 |
309 static bool ToCodecInst(const AudioCodec& in, | 302 static bool ToCodecInst(const AudioCodec& in, |
310 webrtc::CodecInst* out) { | 303 webrtc::CodecInst* out) { |
311 for (webrtc::CodecInst voe_codec : webrtc::acm2::RentACodec::Database()) { | 304 for (webrtc::CodecInst voe_codec : webrtc::acm2::RentACodec::Database()) { |
312 // Change the sample rate of G722 to 8000 to match SDP. | 305 // Change the sample rate of G722 to 8000 to match SDP. |
313 MaybeFixupG722(&voe_codec, 8000); | 306 MaybeFixupG722(&voe_codec, 8000); |
314 AudioCodec codec(voe_codec.pltype, voe_codec.plname, voe_codec.plfreq, | 307 AudioCodec codec(voe_codec.pltype, voe_codec.plname, voe_codec.plfreq, |
315 voe_codec.rate, voe_codec.channels, 0); | 308 voe_codec.rate, voe_codec.channels); |
316 bool multi_rate = IsCodecMultiRate(voe_codec); | 309 bool multi_rate = IsCodecMultiRate(voe_codec); |
317 // Allow arbitrary rates for ISAC to be specified. | 310 // Allow arbitrary rates for ISAC to be specified. |
318 if (multi_rate) { | 311 if (multi_rate) { |
319 // Set codec.bitrate to 0 so the check for codec.Matches() passes. | 312 // Set codec.bitrate to 0 so the check for codec.Matches() passes. |
320 codec.bitrate = 0; | 313 codec.bitrate = 0; |
321 } | 314 } |
322 if (codec.Matches(in)) { | 315 if (codec.Matches(in)) { |
323 if (out) { | 316 if (out) { |
324 // Fixup the payload type. | 317 // Fixup the payload type. |
325 voe_codec.pltype = in.id; | 318 voe_codec.pltype = in.id; |
(...skipping 2236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2562 } | 2555 } |
2563 } else { | 2556 } else { |
2564 LOG(LS_INFO) << "Stopping playout for channel #" << channel; | 2557 LOG(LS_INFO) << "Stopping playout for channel #" << channel; |
2565 engine()->voe()->base()->StopPlayout(channel); | 2558 engine()->voe()->base()->StopPlayout(channel); |
2566 } | 2559 } |
2567 return true; | 2560 return true; |
2568 } | 2561 } |
2569 } // namespace cricket | 2562 } // namespace cricket |
2570 | 2563 |
2571 #endif // HAVE_WEBRTC_VOICE | 2564 #endif // HAVE_WEBRTC_VOICE |
OLD | NEW |