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 |
11 #include "webrtc/modules/audio_coding/codecs/g711/audio_decoder_pcm.h" | 11 #include "webrtc/modules/audio_coding/codecs/g711/audio_decoder_pcm.h" |
12 | 12 |
13 #include "webrtc/modules/audio_coding/codecs/legacy_encoded_audio_frame.h" | 13 #include "webrtc/modules/audio_coding/codecs/legacy_encoded_audio_frame.h" |
14 #include "webrtc/modules/audio_coding/codecs/g711/g711_interface.h" | 14 #include "webrtc/modules/audio_coding/codecs/g711/g711_interface.h" |
15 | 15 |
16 namespace webrtc { | 16 namespace webrtc { |
17 | 17 |
18 void AudioDecoderPcmU::Reset() {} | 18 void AudioDecoderPcmU::Reset() {} |
19 | 19 |
20 std::vector<AudioDecoder::ParseResult> AudioDecoderPcmU::ParsePayload( | 20 std::vector<AudioDecoder::ParseResult> AudioDecoderPcmU::ParsePayload( |
21 rtc::Buffer&& payload, | 21 rtc::Buffer&& payload, |
22 uint32_t timestamp, | 22 uint32_t timestamp) { |
23 bool is_primary) { | |
24 return LegacyEncodedAudioFrame::SplitBySamples( | 23 return LegacyEncodedAudioFrame::SplitBySamples( |
25 this, std::move(payload), timestamp, is_primary, 8 * num_channels_, 8); | 24 this, std::move(payload), timestamp, 8 * num_channels_, 8); |
26 } | 25 } |
27 | 26 |
28 int AudioDecoderPcmU::SampleRateHz() const { | 27 int AudioDecoderPcmU::SampleRateHz() const { |
29 return 8000; | 28 return 8000; |
30 } | 29 } |
31 | 30 |
32 size_t AudioDecoderPcmU::Channels() const { | 31 size_t AudioDecoderPcmU::Channels() const { |
33 return num_channels_; | 32 return num_channels_; |
34 } | 33 } |
35 | 34 |
(...skipping 12 matching lines...) Expand all Loading... |
48 int AudioDecoderPcmU::PacketDuration(const uint8_t* encoded, | 47 int AudioDecoderPcmU::PacketDuration(const uint8_t* encoded, |
49 size_t encoded_len) const { | 48 size_t encoded_len) const { |
50 // One encoded byte per sample per channel. | 49 // One encoded byte per sample per channel. |
51 return static_cast<int>(encoded_len / Channels()); | 50 return static_cast<int>(encoded_len / Channels()); |
52 } | 51 } |
53 | 52 |
54 void AudioDecoderPcmA::Reset() {} | 53 void AudioDecoderPcmA::Reset() {} |
55 | 54 |
56 std::vector<AudioDecoder::ParseResult> AudioDecoderPcmA::ParsePayload( | 55 std::vector<AudioDecoder::ParseResult> AudioDecoderPcmA::ParsePayload( |
57 rtc::Buffer&& payload, | 56 rtc::Buffer&& payload, |
58 uint32_t timestamp, | 57 uint32_t timestamp) { |
59 bool is_primary) { | |
60 return LegacyEncodedAudioFrame::SplitBySamples( | 58 return LegacyEncodedAudioFrame::SplitBySamples( |
61 this, std::move(payload), timestamp, is_primary, 8 * num_channels_, 8); | 59 this, std::move(payload), timestamp, 8 * num_channels_, 8); |
62 } | 60 } |
63 | 61 |
64 int AudioDecoderPcmA::SampleRateHz() const { | 62 int AudioDecoderPcmA::SampleRateHz() const { |
65 return 8000; | 63 return 8000; |
66 } | 64 } |
67 | 65 |
68 size_t AudioDecoderPcmA::Channels() const { | 66 size_t AudioDecoderPcmA::Channels() const { |
69 return num_channels_; | 67 return num_channels_; |
70 } | 68 } |
71 | 69 |
72 int AudioDecoderPcmA::DecodeInternal(const uint8_t* encoded, | 70 int AudioDecoderPcmA::DecodeInternal(const uint8_t* encoded, |
73 size_t encoded_len, | 71 size_t encoded_len, |
74 int sample_rate_hz, | 72 int sample_rate_hz, |
75 int16_t* decoded, | 73 int16_t* decoded, |
76 SpeechType* speech_type) { | 74 SpeechType* speech_type) { |
77 RTC_DCHECK_EQ(SampleRateHz(), sample_rate_hz); | 75 RTC_DCHECK_EQ(SampleRateHz(), sample_rate_hz); |
78 int16_t temp_type = 1; // Default is speech. | 76 int16_t temp_type = 1; // Default is speech. |
79 size_t ret = WebRtcG711_DecodeA(encoded, encoded_len, decoded, &temp_type); | 77 size_t ret = WebRtcG711_DecodeA(encoded, encoded_len, decoded, &temp_type); |
80 *speech_type = ConvertSpeechType(temp_type); | 78 *speech_type = ConvertSpeechType(temp_type); |
81 return static_cast<int>(ret); | 79 return static_cast<int>(ret); |
82 } | 80 } |
83 | 81 |
84 int AudioDecoderPcmA::PacketDuration(const uint8_t* encoded, | 82 int AudioDecoderPcmA::PacketDuration(const uint8_t* encoded, |
85 size_t encoded_len) const { | 83 size_t encoded_len) const { |
86 // One encoded byte per sample per channel. | 84 // One encoded byte per sample per channel. |
87 return static_cast<int>(encoded_len / Channels()); | 85 return static_cast<int>(encoded_len / Channels()); |
88 } | 86 } |
89 | 87 |
90 } // namespace webrtc | 88 } // namespace webrtc |
OLD | NEW |