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