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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 } | 122 } |
123 | 123 |
124 int AudioEncoderOpus::Num10MsFramesInNextPacket() const { | 124 int AudioEncoderOpus::Num10MsFramesInNextPacket() const { |
125 return num_10ms_frames_per_packet_; | 125 return num_10ms_frames_per_packet_; |
126 } | 126 } |
127 | 127 |
128 int AudioEncoderOpus::Max10MsFramesInAPacket() const { | 128 int AudioEncoderOpus::Max10MsFramesInAPacket() const { |
129 return num_10ms_frames_per_packet_; | 129 return num_10ms_frames_per_packet_; |
130 } | 130 } |
131 | 131 |
132 void AudioEncoderOpus::SetTargetBitrate(int bits_per_second) { | 132 int AudioEncoderOpus::SetTargetBitrate(int bits_per_second) { |
133 bitrate_bps_ = std::max(std::min(bits_per_second, kMaxBitrateBps), | 133 bitrate_bps_ = std::max(std::min(bits_per_second, kMaxBitrateBps), |
134 kMinBitrateBps); | 134 kMinBitrateBps); |
135 CHECK_EQ(WebRtcOpus_SetBitRate(inst_, bitrate_bps_), 0); | 135 CHECK_EQ(WebRtcOpus_SetBitRate(inst_, bitrate_bps_), 0); |
| 136 return bitrate_bps_; |
136 } | 137 } |
137 | 138 |
138 void AudioEncoderOpus::SetProjectedPacketLossRate(double fraction) { | 139 void AudioEncoderOpus::SetProjectedPacketLossRate(double fraction) { |
139 DCHECK_GE(fraction, 0.0); | 140 DCHECK_GE(fraction, 0.0); |
140 DCHECK_LE(fraction, 1.0); | 141 DCHECK_LE(fraction, 1.0); |
141 // Optimize the loss rate to configure Opus. Basically, optimized loss rate is | 142 // Optimize the loss rate to configure Opus. Basically, optimized loss rate is |
142 // the input loss rate rounded down to various levels, because a robustly good | 143 // the input loss rate rounded down to various levels, because a robustly good |
143 // audio quality is achieved by lowering the packet loss down. | 144 // audio quality is achieved by lowering the packet loss down. |
144 // Additionally, to prevent toggling, margins are used, i.e., when jumping to | 145 // Additionally, to prevent toggling, margins are used, i.e., when jumping to |
145 // a loss rate from below, a higher threshold is used than jumping to the same | 146 // a loss rate from below, a higher threshold is used than jumping to the same |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 return Reconstruct(conf); | 257 return Reconstruct(conf); |
257 } | 258 } |
258 | 259 |
259 bool AudioEncoderMutableOpus::SetMaxPlaybackRate(int frequency_hz) { | 260 bool AudioEncoderMutableOpus::SetMaxPlaybackRate(int frequency_hz) { |
260 auto conf = config(); | 261 auto conf = config(); |
261 conf.max_playback_rate_hz = frequency_hz; | 262 conf.max_playback_rate_hz = frequency_hz; |
262 return Reconstruct(conf); | 263 return Reconstruct(conf); |
263 } | 264 } |
264 | 265 |
265 } // namespace webrtc | 266 } // namespace webrtc |
OLD | NEW |