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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 // 4 bits/sample, 16000 samples/s/channel. | 90 // 4 bits/sample, 16000 samples/s/channel. |
91 return static_cast<int>(64000 * NumChannels()); | 91 return static_cast<int>(64000 * NumChannels()); |
92 } | 92 } |
93 | 93 |
94 void AudioEncoderG722::Reset() { | 94 void AudioEncoderG722::Reset() { |
95 num_10ms_frames_buffered_ = 0; | 95 num_10ms_frames_buffered_ = 0; |
96 for (size_t i = 0; i < num_channels_; ++i) | 96 for (size_t i = 0; i < num_channels_; ++i) |
97 RTC_CHECK_EQ(0, WebRtcG722_EncoderInit(encoders_[i].encoder)); | 97 RTC_CHECK_EQ(0, WebRtcG722_EncoderInit(encoders_[i].encoder)); |
98 } | 98 } |
99 | 99 |
100 AudioEncoder::EncodedInfo AudioEncoderG722::EncodeInternal( | 100 AudioEncoder::EncodedInfo AudioEncoderG722::EncodeImpl( |
101 uint32_t rtp_timestamp, | 101 uint32_t rtp_timestamp, |
102 rtc::ArrayView<const int16_t> audio, | 102 rtc::ArrayView<const int16_t> audio, |
103 rtc::Buffer* encoded) { | 103 rtc::Buffer* encoded) { |
104 if (num_10ms_frames_buffered_ == 0) | 104 if (num_10ms_frames_buffered_ == 0) |
105 first_timestamp_in_buffer_ = rtp_timestamp; | 105 first_timestamp_in_buffer_ = rtp_timestamp; |
106 | 106 |
107 // Deinterleave samples and save them in each channel's buffer. | 107 // Deinterleave samples and save them in each channel's buffer. |
108 const size_t start = kSampleRateHz / 100 * num_10ms_frames_buffered_; | 108 const size_t start = kSampleRateHz / 100 * num_10ms_frames_buffered_; |
109 for (size_t i = 0; i < kSampleRateHz / 100; ++i) | 109 for (size_t i = 0; i < kSampleRateHz / 100; ++i) |
110 for (size_t j = 0; j < num_channels_; ++j) | 110 for (size_t j = 0; j < num_channels_; ++j) |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 | 158 |
159 AudioEncoderG722::EncoderState::~EncoderState() { | 159 AudioEncoderG722::EncoderState::~EncoderState() { |
160 RTC_CHECK_EQ(0, WebRtcG722_FreeEncoder(encoder)); | 160 RTC_CHECK_EQ(0, WebRtcG722_FreeEncoder(encoder)); |
161 } | 161 } |
162 | 162 |
163 size_t AudioEncoderG722::SamplesPerChannel() const { | 163 size_t AudioEncoderG722::SamplesPerChannel() const { |
164 return kSampleRateHz / 100 * num_10ms_frames_per_packet_; | 164 return kSampleRateHz / 100 * num_10ms_frames_per_packet_; |
165 } | 165 } |
166 | 166 |
167 } // namespace webrtc | 167 } // namespace webrtc |
OLD | NEW |