OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 17 matching lines...) Expand all Loading... |
28 | 28 |
29 namespace { | 29 namespace { |
30 | 30 |
31 constexpr int kSampleRateHz = 48000; | 31 constexpr int kSampleRateHz = 48000; |
32 | 32 |
33 // Opus API allows a min bitrate of 500bps, but Opus documentation suggests | 33 // Opus API allows a min bitrate of 500bps, but Opus documentation suggests |
34 // a minimum bitrate of 6kbps. | 34 // a minimum bitrate of 6kbps. |
35 constexpr int kMinBitrateBps = 6000; | 35 constexpr int kMinBitrateBps = 6000; |
36 | 36 |
37 constexpr int kMaxBitrateBps = 512000; | 37 constexpr int kMaxBitrateBps = 512000; |
| 38 |
| 39 #if WEBRTC_OPUS_SUPPORT_120MS_PTIME |
| 40 constexpr int kSupportedFrameLengths[] = {20, 60, 120}; |
| 41 #else |
38 constexpr int kSupportedFrameLengths[] = {20, 60}; | 42 constexpr int kSupportedFrameLengths[] = {20, 60}; |
| 43 #endif |
39 | 44 |
40 // PacketLossFractionSmoother uses an exponential filter with a time constant | 45 // PacketLossFractionSmoother uses an exponential filter with a time constant |
41 // of -1.0 / ln(0.9999) = 10000 ms. | 46 // of -1.0 / ln(0.9999) = 10000 ms. |
42 constexpr float kAlphaForPacketLossFractionSmoother = 0.9999f; | 47 constexpr float kAlphaForPacketLossFractionSmoother = 0.9999f; |
43 | 48 |
44 AudioEncoderOpus::Config CreateConfig(const CodecInst& codec_inst) { | 49 AudioEncoderOpus::Config CreateConfig(const CodecInst& codec_inst) { |
45 AudioEncoderOpus::Config config; | 50 AudioEncoderOpus::Config config; |
46 config.frame_size_ms = rtc::CheckedDivExact(codec_inst.pacsize, 48); | 51 config.frame_size_ms = rtc::CheckedDivExact(codec_inst.pacsize, 48); |
47 config.num_channels = codec_inst.channels; | 52 config.num_channels = codec_inst.channels; |
48 config.bitrate_bps = rtc::Optional<int>(codec_inst.rate); | 53 config.bitrate_bps = rtc::Optional<int>(codec_inst.rate); |
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 config_.uplink_bandwidth_update_interval_ms) { | 560 config_.uplink_bandwidth_update_interval_ms) { |
556 rtc::Optional<float> smoothed_bitrate = bitrate_smoother_->GetAverage(); | 561 rtc::Optional<float> smoothed_bitrate = bitrate_smoother_->GetAverage(); |
557 if (smoothed_bitrate) | 562 if (smoothed_bitrate) |
558 audio_network_adaptor_->SetUplinkBandwidth(*smoothed_bitrate); | 563 audio_network_adaptor_->SetUplinkBandwidth(*smoothed_bitrate); |
559 bitrate_smoother_last_update_time_ = rtc::Optional<int64_t>(now_ms); | 564 bitrate_smoother_last_update_time_ = rtc::Optional<int64_t>(now_ms); |
560 } | 565 } |
561 } | 566 } |
562 } | 567 } |
563 | 568 |
564 } // namespace webrtc | 569 } // namespace webrtc |
OLD | NEW |