OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 26 matching lines...) Expand all Loading... | |
37 size_t encoded_len, | 37 size_t encoded_len, |
38 int sample_rate_hz, | 38 int sample_rate_hz, |
39 int16_t* decoded, | 39 int16_t* decoded, |
40 SpeechType* speech_type) { | 40 SpeechType* speech_type) { |
41 RTC_DCHECK_EQ(sample_rate_hz_, sample_rate_hz); | 41 RTC_DCHECK_EQ(sample_rate_hz_, sample_rate_hz); |
42 size_t ret = WebRtcPcm16b_Decode(encoded, encoded_len, decoded); | 42 size_t ret = WebRtcPcm16b_Decode(encoded, encoded_len, decoded); |
43 *speech_type = ConvertSpeechType(1); | 43 *speech_type = ConvertSpeechType(1); |
44 return static_cast<int>(ret); | 44 return static_cast<int>(ret); |
45 } | 45 } |
46 | 46 |
47 AudioDecoder::PacketSplits AudioDecoderPcm16B::SplitPacket( | |
48 const uint8_t* payload, | |
49 size_t payload_len) const { | |
50 // TODO(ossu): Investigate if we can ever get 44.1KHz audio here, in which | |
51 // case rounding will break. Consider replacing with | |
52 // CheckedDivExact to catch that happening. | |
kwiberg-webrtc
2016/08/26 12:39:25
Could you handle that by letting SplitBySamples wo
| |
53 return SplitBySamples(payload, payload_len, | |
54 sample_rate_hz_ * 2 * num_channels_ / 1000, | |
55 sample_rate_hz_ / 1000); | |
56 } | |
57 | |
47 int AudioDecoderPcm16B::PacketDuration(const uint8_t* encoded, | 58 int AudioDecoderPcm16B::PacketDuration(const uint8_t* encoded, |
48 size_t encoded_len) const { | 59 size_t encoded_len) const { |
49 // Two encoded byte per sample per channel. | 60 // Two encoded byte per sample per channel. |
50 return static_cast<int>(encoded_len / (2 * Channels())); | 61 return static_cast<int>(encoded_len / (2 * Channels())); |
51 } | 62 } |
52 | 63 |
53 } // namespace webrtc | 64 } // namespace webrtc |
OLD | NEW |