Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(236)

Unified Diff: webrtc/modules/audio_coding/codecs/ilbc/audio_decoder_ilbc.cc

Issue 2326003002: Moved codec-specific audio packet splitting into decoders. (Closed)
Patch Set: Fixed types in packet splitting (size_t vs. uint32_t) Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..b4bd59911f6439337c647093f0b358af52e3af98 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,53 @@ 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::ParsePayload: Payload too large";
+ 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::ParsePayload: Invalid payload";
+ return results;
+ }
+
+ RTC_DCHECK_EQ(0u, payload.size() % bytes_per_frame);
+ if (payload.size() == bytes_per_frame) {
+ std::unique_ptr<EncodedAudioFrame> frame(
+ new LegacyEncodedAudioFrame(this, std::move(payload), is_primary));
+ results.emplace_back(timestamp, is_primary, std::move(frame));
+ } else {
+ size_t byte_offset;
+ uint32_t timestamp_offset;
+ for (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, std::move(new_payload), is_primary));
+ results.emplace_back(timestamp + timestamp_offset, is_primary,
+ std::move(frame));
+ }
+ }
+
+ return results;
+}
+
int AudioDecoderIlbc::SampleRateHz() const {
return 8000;
}
« no previous file with comments | « webrtc/modules/audio_coding/codecs/ilbc/audio_decoder_ilbc.h ('k') | webrtc/modules/audio_coding/codecs/ilbc/ilbc_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698