Index: webrtc/modules/audio_coding/codecs/audio_decoder.h |
diff --git a/webrtc/modules/audio_coding/codecs/audio_decoder.h b/webrtc/modules/audio_coding/codecs/audio_decoder.h |
index 13581bc247705a740b04e1d9a1cac73e454b3fa3..125302ecd3adf1522db0308c40388d34710419e8 100644 |
--- a/webrtc/modules/audio_coding/codecs/audio_decoder.h |
+++ b/webrtc/modules/audio_coding/codecs/audio_decoder.h |
@@ -13,7 +13,10 @@ |
#include <stdlib.h> // NULL |
+#include "webrtc/base/array_view.h" |
+#include "webrtc/base/buffer.h" |
#include "webrtc/base/constructormagic.h" |
+#include "webrtc/base/optional.h" |
#include "webrtc/typedefs.h" |
namespace webrtc { |
@@ -33,6 +36,50 @@ class AudioDecoder { |
AudioDecoder() = default; |
virtual ~AudioDecoder() = default; |
+ class EncodedAudioFrame { |
+ public: |
+ struct DecodeResult { |
+ size_t num_decoded_samples; |
+ SpeechType speech_type; |
+ }; |
+ |
+ virtual ~EncodedAudioFrame() = default; |
+ |
+ // Returns the duration in samples-per-channel of this audio frame. |
+ // If no duration can be ascertained, returns zero. |
+ virtual size_t Duration() const = 0; |
+ |
+ // Decodes this frame of audio and writes the result in |decoded|. |
+ // Returns rtc::Optional containing the total number of samples across all |
+ // channels, as well as whether the decoder produced comfort noise or |
+ // speech. Decode must only be called once per frame object. |
kwiberg-webrtc
2016/09/15 12:00:59
You don't say under what circumstances the return
ossu
2016/09/15 13:07:54
I'd really prefer it if this method were handed a
kwiberg-webrtc
2016/09/16 00:14:07
IOW, it's supposed to be at least as large as nece
|
+ virtual rtc::Optional<DecodeResult> Decode( |
+ rtc::ArrayView<int16_t> decoded) const = 0; |
+ }; |
+ |
+ struct ParseResult { |
+ ParseResult(); |
+ ParseResult(uint32_t timestamp, |
+ bool primary, |
+ std::unique_ptr<EncodedAudioFrame> frame); |
+ ParseResult(ParseResult&& b); |
+ ~ParseResult(); |
+ |
+ ParseResult& operator=(ParseResult&& b); |
+ |
+ // The timestamp of the frame is in samples per channel. |
+ uint32_t timestamp; |
+ bool primary; |
+ std::unique_ptr<EncodedAudioFrame> frame; |
+ }; |
+ |
+ // Let the decoder parse this payload and prepare zero or more decodable |
+ // frames. Each frame must be at most 120 ms long. The decoder is free to swap |
+ // or move the data from the |payload| buffer. |
+ virtual std::vector<ParseResult> ParsePayload(rtc::Buffer* payload, |
+ uint32_t timestamp, |
+ bool is_primary); |
kwiberg-webrtc
2016/09/15 12:00:59
Do you intend for this to be a sink for the payloa
ossu
2016/09/15 13:07:54
It's a sink. I'll clarify the AudioDecoder's lifet
kwiberg-webrtc
2016/09/16 00:14:07
Acknowledged.
|
+ |
// Decodes |encode_len| bytes from |encoded| and writes the result in |
// |decoded|. The maximum bytes allowed to be written into |decoded| is |
// |max_decoded_bytes|. Returns the total number of samples across all |