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 |
11 #include "webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.h" | 11 #include "webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.h" |
12 | 12 |
13 #include <algorithm> | 13 #include <algorithm> |
14 | 14 |
15 #include "webrtc/base/checks.h" | 15 #include "webrtc/base/checks.h" |
16 #include "webrtc/base/safe_conversions.h" | 16 #include "webrtc/base/safe_conversions.h" |
17 #include "webrtc/common_types.h" | 17 #include "webrtc/common_types.h" |
18 #include "webrtc/modules/audio_coding/codecs/opus/opus_interface.h" | 18 #include "webrtc/modules/audio_coding/codecs/opus/opus_interface.h" |
19 #include "webrtc/modules/audio_coding/codecs/audio_encoder.h" | |
hlundin-webrtc
2016/05/13 09:54:23
Not needed.
| |
19 | 20 |
20 namespace webrtc { | 21 namespace webrtc { |
21 | 22 |
22 namespace { | 23 namespace { |
23 | 24 |
24 const int kSampleRateHz = 48000; | 25 const int kSampleRateHz = 48000; |
25 const int kMinBitrateBps = 500; | 26 const int kMinBitrateBps = 500; |
26 const int kMaxBitrateBps = 512000; | 27 const int kMaxBitrateBps = 512000; |
27 | 28 |
28 AudioEncoderOpus::Config CreateConfig(const CodecInst& codec_inst) { | 29 AudioEncoderOpus::Config CreateConfig(const CodecInst& codec_inst) { |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
205 RTC_CHECK_GE(status, 0); // Fails only if fed invalid data. | 206 RTC_CHECK_GE(status, 0); // Fails only if fed invalid data. |
206 | 207 |
207 return static_cast<size_t>(status); | 208 return static_cast<size_t>(status); |
208 }); | 209 }); |
209 input_buffer_.clear(); | 210 input_buffer_.clear(); |
210 | 211 |
211 info.encoded_timestamp = first_timestamp_in_buffer_; | 212 info.encoded_timestamp = first_timestamp_in_buffer_; |
212 info.payload_type = config_.payload_type; | 213 info.payload_type = config_.payload_type; |
213 info.send_even_if_empty = true; // Allows Opus to send empty packets. | 214 info.send_even_if_empty = true; // Allows Opus to send empty packets. |
214 info.speech = (info.encoded_bytes > 0); | 215 info.speech = (info.encoded_bytes > 0); |
216 info.encoder_type = AudioEncoder::CodecType::kOpus; | |
215 return info; | 217 return info; |
216 } | 218 } |
217 | 219 |
218 size_t AudioEncoderOpus::Num10msFramesPerPacket() const { | 220 size_t AudioEncoderOpus::Num10msFramesPerPacket() const { |
219 return static_cast<size_t>(rtc::CheckedDivExact(config_.frame_size_ms, 10)); | 221 return static_cast<size_t>(rtc::CheckedDivExact(config_.frame_size_ms, 10)); |
220 } | 222 } |
221 | 223 |
222 size_t AudioEncoderOpus::SamplesPer10msFrame() const { | 224 size_t AudioEncoderOpus::SamplesPer10msFrame() const { |
223 return rtc::CheckedDivExact(kSampleRateHz, 100) * config_.num_channels; | 225 return rtc::CheckedDivExact(kSampleRateHz, 100) * config_.num_channels; |
224 } | 226 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
260 RTC_CHECK_EQ(0, WebRtcOpus_DisableDtx(inst_)); | 262 RTC_CHECK_EQ(0, WebRtcOpus_DisableDtx(inst_)); |
261 } | 263 } |
262 RTC_CHECK_EQ(0, | 264 RTC_CHECK_EQ(0, |
263 WebRtcOpus_SetPacketLossRate( | 265 WebRtcOpus_SetPacketLossRate( |
264 inst_, static_cast<int32_t>(packet_loss_rate_ * 100 + .5))); | 266 inst_, static_cast<int32_t>(packet_loss_rate_ * 100 + .5))); |
265 config_ = config; | 267 config_ = config; |
266 return true; | 268 return true; |
267 } | 269 } |
268 | 270 |
269 } // namespace webrtc | 271 } // namespace webrtc |
OLD | NEW |