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..1eec6758ed3c82328460c7f6ff75c83c7e8ebed4 100644 |
--- a/webrtc/modules/audio_coding/codecs/ilbc/audio_decoder_ilbc.cc |
+++ b/webrtc/modules/audio_coding/codecs/ilbc/audio_decoder_ilbc.cc |
@@ -11,6 +11,7 @@ |
#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" |
namespace webrtc { |
@@ -49,6 +50,45 @@ void AudioDecoderIlbc::Reset() { |
WebRtcIlbcfix_Decoderinit30Ms(dec_state_); |
} |
+AudioDecoder::PacketSplits AudioDecoderIlbc::SplitPacket( |
+ const uint8_t* payload, |
+ size_t payload_len) const { |
+ PacketSplits splits; |
+ size_t bytes_per_frame; |
+ int timestamps_per_frame; |
+ if (payload_len >= 950) { |
kwiberg-webrtc
2016/08/26 12:39:25
It's probably best to name the constants:
const
|
+ LOG(LS_WARNING) << "AudioDecoderIlbc::SplitPacket: Payload too large"; |
+ return splits; |
+ } |
+ if (payload_len % 38 == 0) { |
+ // 20 ms frames. |
+ bytes_per_frame = 38; |
+ timestamps_per_frame = 160; |
+ } else if (payload_len % 50 == 0) { |
+ // 30 ms frames. |
+ bytes_per_frame = 50; |
+ timestamps_per_frame = 240; |
+ } else { |
+ LOG(LS_WARNING) << "AudioDecoderIlbc::SplitPacket: Invalid payload"; |
+ return splits; |
+ } |
+ |
+ if (payload_len == bytes_per_frame) { |
+ // Special case. Do not split the payload. |
+ return {PacketSplit{0, payload_len, 0}}; |
+ } |
kwiberg-webrtc
2016/08/26 12:39:25
Is this special case really needed? It looks like
ossu
2016/08/26 13:05:30
You're right. This shouldn't be necessary. I'll re
|
+ |
+ PacketSplit split = {0, bytes_per_frame, 0}; |
+ for (size_t len = payload_len; len > 0; len -= bytes_per_frame) { |
+ RTC_DCHECK(len >= bytes_per_frame); |
+ splits.push_back(split); |
+ split.byte_offset += bytes_per_frame; |
+ split.timestamp_offset += timestamps_per_frame; |
+ } |
+ |
+ return splits; |
+} |
+ |
int AudioDecoderIlbc::SampleRateHz() const { |
return 8000; |
} |