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

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

Issue 2326953003: Added a ParsePayload method to AudioDecoder. (Closed)
Patch Set: Clarifications. Cleanups. 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..ab87b005b34a5d11b93e5aaf7dcf95c553061c15 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,55 @@ 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|.
+ // |decoded| will be large enough for 120 ms of audio at the decoder's
+ // sample rate. On success, returns an rtc::Optional containing the total
kwiberg-webrtc 2016/09/16 00:14:07 Might it be better to simply state that |decoded|
ossu 2016/09/16 11:24:16 I've incorporated the phrasing changes suggested i
+ // number of samples across all channels, as well as whether the decoder
+ // produced comfort noise or speech. On failure, returns an empty
+ // rtc::Optional. Decode must be called at most once per frame object.
kwiberg-webrtc 2016/09/16 00:14:07 My sometimes reliable sense of English suggests s/
ossu 2016/09/16 11:24:16 I believe you're right.
+ 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 and should never be shorter
+ // than 10 ms. The caller must ensure that the AudioDecoder object outlives
kwiberg-webrtc 2016/09/16 00:14:07 This use of "must" and "should" gives the sense th
hlundin-webrtc 2016/09/16 07:40:45 They need not be an integer multiple of 10.
kwiberg-webrtc 2016/09/16 07:51:57 Are there no restrictions whatsoever, except the u
hlundin-webrtc 2016/09/16 08:25:02 In theory, no other restrictions. In practice I ca
ossu 2016/09/16 11:24:16 Acknowledged.
+ // any frame objects returned by this call. The decoder is free to swap or
+ // move the data from the |payload| buffer. |timestamp| is the input
+ // timestamp, in samples, corresponding to the start of the payload.
+ virtual std::vector<ParseResult> ParsePayload(rtc::Buffer&& payload,
+ uint32_t timestamp,
+ bool is_primary);
+
// 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
« no previous file with comments | « no previous file | webrtc/modules/audio_coding/codecs/audio_decoder.cc » ('j') | webrtc/modules/audio_coding/neteq/neteq_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698