Moved codec-specific audio packet splitting into decoders.

There's still some code run specifically for Opus w/ FEC. It will be
addressed in a separate CL.

BUG=webrtc:5805

Review-Url: https://codereview.webrtc.org/2326003002
Cr-Commit-Position: refs/heads/master@{#14319}
This commit is contained in:
ossu
2016-09-21 01:57:31 -07:00
committed by Commit bot
parent 3442579fd7
commit 0d526d558b
26 changed files with 571 additions and 685 deletions

View File

@ -13,6 +13,7 @@
#include <string.h>
#include "webrtc/base/checks.h"
#include "webrtc/modules/audio_coding/codecs/legacy_encoded_audio_frame.h"
#include "webrtc/modules/audio_coding/codecs/g722/g722_interface.h"
namespace webrtc {
@ -47,6 +48,14 @@ void AudioDecoderG722::Reset() {
WebRtcG722_DecoderInit(dec_state_);
}
std::vector<AudioDecoder::ParseResult> AudioDecoderG722::ParsePayload(
rtc::Buffer&& payload,
uint32_t timestamp,
bool is_primary) {
return LegacyEncodedAudioFrame::SplitBySamples(this, std::move(payload),
timestamp, is_primary, 8, 16);
}
int AudioDecoderG722::PacketDuration(const uint8_t* encoded,
size_t encoded_len) const {
// 1/2 encoded byte per sample per channel.
@ -117,6 +126,14 @@ void AudioDecoderG722Stereo::Reset() {
WebRtcG722_DecoderInit(dec_state_right_);
}
std::vector<AudioDecoder::ParseResult> AudioDecoderG722Stereo::ParsePayload(
rtc::Buffer&& payload,
uint32_t timestamp,
bool is_primary) {
return LegacyEncodedAudioFrame::SplitBySamples(
this, std::move(payload), timestamp, is_primary, 2 * 8, 16);
}
// Split the stereo packet and place left and right channel after each other
// in the output array.
void AudioDecoderG722Stereo::SplitStereoPacket(const uint8_t* encoded,

View File

@ -24,6 +24,9 @@ class AudioDecoderG722 final : public AudioDecoder {
~AudioDecoderG722() override;
bool HasDecodePlc() const override;
void Reset() override;
std::vector<ParseResult> ParsePayload(rtc::Buffer&& payload,
uint32_t timestamp,
bool is_primary) override;
int PacketDuration(const uint8_t* encoded, size_t encoded_len) const override;
int SampleRateHz() const override;
size_t Channels() const override;
@ -45,6 +48,9 @@ class AudioDecoderG722Stereo final : public AudioDecoder {
AudioDecoderG722Stereo();
~AudioDecoderG722Stereo() override;
void Reset() override;
std::vector<ParseResult> ParsePayload(rtc::Buffer&& payload,
uint32_t timestamp,
bool is_primary) override;
int SampleRateHz() const override;
size_t Channels() const override;

View File

@ -12,6 +12,8 @@
'type': 'static_library',
'dependencies': [
'audio_encoder_interface',
'audio_decoder_interface',
'legacy_encoded_audio_frame',
],
'sources': [
'audio_decoder_g722.cc',