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/ilbc/audio_encoder_ilbc.h" | 11 #include "webrtc/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.h" |
12 | 12 |
13 #include <algorithm> | 13 #include <algorithm> |
14 #include <limits> | 14 #include <limits> |
15 #include "webrtc/base/checks.h" | 15 #include "webrtc/base/checks.h" |
16 #include "webrtc/common_types.h" | 16 #include "webrtc/common_types.h" |
17 #include "webrtc/modules/audio_coding/codecs/ilbc/ilbc.h" | 17 #include "webrtc/modules/audio_coding/codecs/ilbc/ilbc.h" |
18 #include "webrtc/modules/audio_coding/codecs/audio_encoder.h" | |
hlundin-webrtc
2016/05/13 09:54:23
Not needed.
aleloi
2016/05/13 10:56:07
Done.
| |
18 | 19 |
19 namespace webrtc { | 20 namespace webrtc { |
20 | 21 |
21 namespace { | 22 namespace { |
22 | 23 |
23 const int kSampleRateHz = 8000; | 24 const int kSampleRateHz = 8000; |
24 | 25 |
25 AudioEncoderIlbc::Config CreateConfig(const CodecInst& codec_inst) { | 26 AudioEncoderIlbc::Config CreateConfig(const CodecInst& codec_inst) { |
26 AudioEncoderIlbc::Config config; | 27 AudioEncoderIlbc::Config config; |
27 config.frame_size_ms = codec_inst.pacsize / 8; | 28 config.frame_size_ms = codec_inst.pacsize / 8; |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
120 | 121 |
121 return static_cast<size_t>(r); | 122 return static_cast<size_t>(r); |
122 }); | 123 }); |
123 | 124 |
124 RTC_DCHECK_EQ(encoded_bytes, RequiredOutputSizeBytes()); | 125 RTC_DCHECK_EQ(encoded_bytes, RequiredOutputSizeBytes()); |
125 | 126 |
126 EncodedInfo info; | 127 EncodedInfo info; |
127 info.encoded_bytes = encoded_bytes; | 128 info.encoded_bytes = encoded_bytes; |
128 info.encoded_timestamp = first_timestamp_in_buffer_; | 129 info.encoded_timestamp = first_timestamp_in_buffer_; |
129 info.payload_type = config_.payload_type; | 130 info.payload_type = config_.payload_type; |
131 info.encoder_type = AudioEncoder::CodecType::kIlbc; | |
130 return info; | 132 return info; |
131 } | 133 } |
132 | 134 |
133 void AudioEncoderIlbc::Reset() { | 135 void AudioEncoderIlbc::Reset() { |
134 if (encoder_) | 136 if (encoder_) |
135 RTC_CHECK_EQ(0, WebRtcIlbcfix_EncoderFree(encoder_)); | 137 RTC_CHECK_EQ(0, WebRtcIlbcfix_EncoderFree(encoder_)); |
136 RTC_CHECK(config_.IsOk()); | 138 RTC_CHECK(config_.IsOk()); |
137 RTC_CHECK_EQ(0, WebRtcIlbcfix_EncoderCreate(&encoder_)); | 139 RTC_CHECK_EQ(0, WebRtcIlbcfix_EncoderCreate(&encoder_)); |
138 const int encoder_frame_size_ms = config_.frame_size_ms > 30 | 140 const int encoder_frame_size_ms = config_.frame_size_ms > 30 |
139 ? config_.frame_size_ms / 2 | 141 ? config_.frame_size_ms / 2 |
140 : config_.frame_size_ms; | 142 : config_.frame_size_ms; |
141 RTC_CHECK_EQ(0, WebRtcIlbcfix_EncoderInit(encoder_, encoder_frame_size_ms)); | 143 RTC_CHECK_EQ(0, WebRtcIlbcfix_EncoderInit(encoder_, encoder_frame_size_ms)); |
142 num_10ms_frames_buffered_ = 0; | 144 num_10ms_frames_buffered_ = 0; |
143 } | 145 } |
144 | 146 |
145 size_t AudioEncoderIlbc::RequiredOutputSizeBytes() const { | 147 size_t AudioEncoderIlbc::RequiredOutputSizeBytes() const { |
146 switch (num_10ms_frames_per_packet_) { | 148 switch (num_10ms_frames_per_packet_) { |
147 case 2: return 38; | 149 case 2: return 38; |
148 case 3: return 50; | 150 case 3: return 50; |
149 case 4: return 2 * 38; | 151 case 4: return 2 * 38; |
150 case 6: return 2 * 50; | 152 case 6: return 2 * 50; |
151 default: FATAL(); | 153 default: FATAL(); |
152 } | 154 } |
153 } | 155 } |
154 | 156 |
155 } // namespace webrtc | 157 } // namespace webrtc |
OLD | NEW |