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

Unified Diff: webrtc/modules/audio_coding/codecs/audio_decoder.h

Issue 2326953003: Added a ParsePayload method to AudioDecoder. (Closed)
Patch Set: Addressed comments 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/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

Powered by Google App Engine
This is Rietveld 408576698