Chromium Code Reviews| Index: webrtc/modules/audio_coding/codecs/ilbc/audio_decoder_ilbc.cc |
| diff --git a/webrtc/modules/audio_coding/codecs/ilbc/audio_decoder_ilbc.cc b/webrtc/modules/audio_coding/codecs/ilbc/audio_decoder_ilbc.cc |
| index dab5805f98afcc41eaa714d49e4cd8baec5ebe59..9eacfc0ff0ac24fa8d221c2759eebda2bcf65c0b 100644 |
| --- a/webrtc/modules/audio_coding/codecs/ilbc/audio_decoder_ilbc.cc |
| +++ b/webrtc/modules/audio_coding/codecs/ilbc/audio_decoder_ilbc.cc |
| @@ -11,7 +11,9 @@ |
| #include "webrtc/modules/audio_coding/codecs/ilbc/audio_decoder_ilbc.h" |
| #include "webrtc/base/checks.h" |
| +#include "webrtc/base/logging.h" |
| #include "webrtc/modules/audio_coding/codecs/ilbc/ilbc.h" |
| +#include "webrtc/modules/audio_coding/codecs/legacy_encoded_audio_frame.h" |
| namespace webrtc { |
| @@ -49,6 +51,51 @@ void AudioDecoderIlbc::Reset() { |
| WebRtcIlbcfix_Decoderinit30Ms(dec_state_); |
| } |
| +std::vector<AudioDecoder::ParseResult> AudioDecoderIlbc::ParsePayload( |
| + rtc::Buffer* payload, |
| + uint32_t timestamp, |
| + bool is_primary) { |
| + std::vector<ParseResult> results; |
| + size_t bytes_per_frame; |
| + int timestamps_per_frame; |
| + if (payload->size() >= 950) { |
| + LOG(LS_WARNING) << "AudioDecoderIlbc::SplitPacket: Payload too large"; |
|
ossu
2016/09/13 14:25:55
This comment should say ParsePayload and not Split
|
| + return results; |
| + } |
| + if (payload->size() % 38 == 0) { |
| + // 20 ms frames. |
| + bytes_per_frame = 38; |
| + timestamps_per_frame = 160; |
| + } else if (payload->size() % 50 == 0) { |
| + // 30 ms frames. |
| + bytes_per_frame = 50; |
| + timestamps_per_frame = 240; |
| + } else { |
| + LOG(LS_WARNING) << "AudioDecoderIlbc::SplitPacket: Invalid payload"; |
|
ossu
2016/09/13 14:25:55
This comment should say ParsePayload and not Split
|
| + return results; |
| + } |
| + |
| + RTC_DCHECK(payload->size() % bytes_per_frame == 0); |
|
hlundin-webrtc
2016/09/15 08:49:14
RTC_DCHECK_EQ
ossu
2016/09/15 08:58:11
I did that initially, but the RTC_DHECK_EQ macro b
hlundin-webrtc
2016/09/15 09:43:38
I hate it when that happens, but I prefer the nice
kwiberg-webrtc
2016/09/15 13:01:25
+1. It's annoying, but since a "u" suffix will sol
|
| + if (payload->size() == bytes_per_frame) { |
| + std::unique_ptr<EncodedAudioFrame> frame( |
| + new LegacyEncodedAudioFrame(this, payload, is_primary)); |
| + results.emplace_back(timestamp, is_primary, std::move(frame)); |
| + } else { |
| + for (size_t byte_offset = 0, timestamp_offset = 0; |
| + byte_offset < payload->size(); |
| + byte_offset += bytes_per_frame, |
| + timestamp_offset += timestamps_per_frame) { |
| + rtc::Buffer new_payload(payload->data() + byte_offset, bytes_per_frame); |
| + std::unique_ptr<EncodedAudioFrame> frame( |
| + new LegacyEncodedAudioFrame(this, &new_payload, is_primary)); |
| + results.emplace_back(timestamp + timestamp_offset, is_primary, |
| + std::move(frame)); |
| + } |
| + } |
| + |
| + return results; |
| +} |
| + |
| int AudioDecoderIlbc::SampleRateHz() const { |
| return 8000; |
| } |