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/interface/audio_encoder_ilbc.h
" | 11 #include "webrtc/modules/audio_coding/codecs/ilbc/interface/audio_encoder_ilbc.h
" |
12 | 12 |
13 #include <cstring> | 13 #include <cstring> |
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/interface/ilbc.h" | 17 #include "webrtc/modules/audio_coding/codecs/ilbc/interface/ilbc.h" |
18 | 18 |
19 namespace webrtc { | 19 namespace webrtc { |
20 | 20 |
21 namespace { | 21 namespace { |
22 | 22 |
23 const int kSampleRateHz = 8000; | 23 const int kSampleRateHz = 8000; |
24 | 24 |
25 } // namespace | 25 } // namespace |
26 | 26 |
27 bool AudioEncoderIlbc::Config::IsOk() const { | 27 bool AudioEncoderIlbc::Config::IsOk() const { |
28 if (!(frame_size_ms == 20 || frame_size_ms == 30 || frame_size_ms == 40 || | 28 return (frame_size_ms == 20 || frame_size_ms == 30 || frame_size_ms == 40 || |
29 frame_size_ms == 60)) | 29 frame_size_ms == 60) && |
30 return false; | 30 (kSampleRateHz / 100 * (frame_size_ms / 10)) <= kMaxSamplesPerPacket; |
31 if (kSampleRateHz / 100 * (frame_size_ms / 10) > kMaxSamplesPerPacket) | |
32 return false; | |
33 return true; | |
34 } | 31 } |
35 | 32 |
36 AudioEncoderIlbc::AudioEncoderIlbc(const Config& config) | 33 AudioEncoderIlbc::AudioEncoderIlbc(const Config& config) |
37 : payload_type_(config.payload_type), | 34 : payload_type_(config.payload_type), |
38 num_10ms_frames_per_packet_(config.frame_size_ms / 10), | 35 num_10ms_frames_per_packet_(config.frame_size_ms / 10), |
39 num_10ms_frames_buffered_(0) { | 36 num_10ms_frames_buffered_(0) { |
40 CHECK(config.IsOk()); | 37 CHECK(config.IsOk()); |
41 CHECK_EQ(0, WebRtcIlbcfix_EncoderCreate(&encoder_)); | 38 CHECK_EQ(0, WebRtcIlbcfix_EncoderCreate(&encoder_)); |
42 const int encoder_frame_size_ms = config.frame_size_ms > 30 | 39 const int encoder_frame_size_ms = config.frame_size_ms > 30 |
43 ? config.frame_size_ms / 2 | 40 ? config.frame_size_ms / 2 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 config.payload_type = codec_inst.pltype; | 122 config.payload_type = codec_inst.pltype; |
126 return config; | 123 return config; |
127 } | 124 } |
128 } // namespace | 125 } // namespace |
129 | 126 |
130 AudioEncoderMutableIlbc::AudioEncoderMutableIlbc(const CodecInst& codec_inst) | 127 AudioEncoderMutableIlbc::AudioEncoderMutableIlbc(const CodecInst& codec_inst) |
131 : AudioEncoderMutableImpl<AudioEncoderIlbc>(CreateConfig(codec_inst)) { | 128 : AudioEncoderMutableImpl<AudioEncoderIlbc>(CreateConfig(codec_inst)) { |
132 } | 129 } |
133 | 130 |
134 } // namespace webrtc | 131 } // namespace webrtc |
OLD | NEW |