Chromium Code Reviews| Index: webrtc/modules/audio_coding/codecs/audio_decoder.cc |
| diff --git a/webrtc/modules/audio_coding/codecs/audio_decoder.cc b/webrtc/modules/audio_coding/codecs/audio_decoder.cc |
| index 89fc5d8d72cd35f67938af7eb74b76a21c65d660..b752e2ad1a97563c9206ee781c2170d8651dd50c 100644 |
| --- a/webrtc/modules/audio_coding/codecs/audio_decoder.cc |
| +++ b/webrtc/modules/audio_coding/codecs/audio_decoder.cc |
| @@ -11,61 +11,17 @@ |
| #include "webrtc/modules/audio_coding/codecs/audio_decoder.h" |
| #include <assert.h> |
| +#include <memory> |
| +#include <utility> |
| #include "webrtc/base/array_view.h" |
| #include "webrtc/base/checks.h" |
| #include "webrtc/base/sanitizer.h" |
| #include "webrtc/base/trace_event.h" |
| +#include "webrtc/modules/audio_coding/codecs/legacy_encoded_audio_frame.h" |
| namespace webrtc { |
| -namespace { |
| -class LegacyFrame : public AudioDecoder::EncodedAudioFrame { |
| - public: |
| - LegacyFrame(AudioDecoder* decoder, |
| - rtc::Buffer* payload, |
| - bool is_primary_payload) |
| - : decoder_(decoder), |
| - payload_(std::move(*payload)), |
| - is_primary_payload_(is_primary_payload) {} |
| - |
| - size_t Duration() const override { |
| - int ret; |
| - if (is_primary_payload_) { |
| - ret = decoder_->PacketDuration(payload_.data(), payload_.size()); |
| - } else { |
| - ret = decoder_->PacketDurationRedundant(payload_.data(), payload_.size()); |
| - } |
| - return (ret < 0) ? 0 : static_cast<size_t>(ret); |
| - } |
| - |
| - rtc::Optional<DecodeResult> Decode( |
| - rtc::ArrayView<int16_t> decoded) const override { |
| - AudioDecoder::SpeechType speech_type = AudioDecoder::kSpeech; |
| - int ret; |
| - if (is_primary_payload_) { |
| - ret = decoder_->Decode( |
| - payload_.data(), payload_.size(), decoder_->SampleRateHz(), |
| - decoded.size() * sizeof(int16_t), decoded.data(), &speech_type); |
| - } else { |
| - ret = decoder_->DecodeRedundant( |
| - payload_.data(), payload_.size(), decoder_->SampleRateHz(), |
| - decoded.size() * sizeof(int16_t), decoded.data(), &speech_type); |
| - } |
| - |
| - if (ret < 0) |
| - return rtc::Optional<DecodeResult>(); |
| - |
| - return rtc::Optional<DecodeResult>({static_cast<size_t>(ret), speech_type}); |
| - } |
| - |
| - private: |
| - AudioDecoder* const decoder_; |
| - const rtc::Buffer payload_; |
| - const bool is_primary_payload_; |
| -}; |
| -} |
| - |
| AudioDecoder::ParseResult::ParseResult() = default; |
| AudioDecoder::ParseResult::ParseResult(ParseResult&& b) = default; |
| AudioDecoder::ParseResult::ParseResult(uint32_t timestamp, |
| @@ -84,7 +40,7 @@ std::vector<AudioDecoder::ParseResult> AudioDecoder::ParsePayload( |
| bool is_primary) { |
| std::vector<ParseResult> results; |
| std::unique_ptr<EncodedAudioFrame> frame( |
| - new LegacyFrame(this, payload, is_primary)); |
| + new LegacyEncodedAudioFrame(this, payload, is_primary)); |
| results.emplace_back(timestamp, is_primary, std::move(frame)); |
| return results; |
|
kwiberg-webrtc
2016/09/15 13:01:24
Won't a construction along these lines work?
st
ossu
2016/09/15 14:41:05
Ideally that _should_ work but I can't get it to.
kwiberg-webrtc
2016/09/16 00:48:07
No, they're allowed now. Could it be that we're us
|
| } |