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..7abd86c87fad0b4793e24c1150ad8a2c42fbd57e 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,47 @@ class AudioDecoder { |
AudioDecoder() = default; |
virtual ~AudioDecoder() = default; |
+ class Frame { |
hlundin-webrtc
2016/09/09 12:11:50
Frame is too general, and already claimed for too
ossu
2016/09/12 10:31:37
I agree - EncodedFrame is better. EncodedAudioFram
ossu
2016/09/13 13:37:46
I've gone with EncodedAudioFrame. It makes more se
|
+ public: |
+ struct DecodeResult { |
+ size_t num_decoded_samples; |
+ SpeechType speech_type; |
+ }; |
+ |
+ virtual ~Frame() = 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|. |
hlundin-webrtc
2016/09/09 12:11:49
What can be expected of the state of the Frame aft
ossu
2016/09/12 10:31:36
I'm not sure. Practically, it currently acts as if
ossu
2016/09/13 13:37:46
I've clarified that Decode should only be called o
hlundin-webrtc
2016/09/15 08:12:16
Acknowledged.
|
+ // Returns rtc::Optional containing the total number of samples across all |
+ // channels, as well as whether the decoder produced comfort noise or |
+ // speech. |
+ virtual rtc::Optional<DecodeResult> Decode( |
hlundin-webrtc
2016/09/09 12:11:50
How will error codes from the decoder be handled?
ossu
2016/09/12 10:31:36
No idea! You tell me! :) Are these the error codes
ossu
2016/09/12 12:37:35
From what I can see, the decoder error code is fre
hlundin-webrtc
2016/09/15 08:12:16
Right. Since no production code seems to care abou
|
+ rtc::ArrayView<int16_t> decoded) const = 0; |
+ }; |
+ |
+ struct ParseResult { |
+ ParseResult(); |
+ ParseResult(uint32_t timestamp, bool primary, std::unique_ptr<Frame> frame); |
+ ParseResult(ParseResult&& b); |
+ ~ParseResult(); |
+ |
+ ParseResult& operator=(ParseResult&& b); |
+ |
+ uint32_t timestamp; |
hlundin-webrtc
2016/09/09 12:11:50
rtp_timestamp? Or timestamp_in_samples? G.722...
ossu
2016/09/12 10:31:36
I think it should be in samples, however I'm reall
ossu
2016/09/13 13:37:46
I've looked through the calling code and the times
hlundin-webrtc
2016/09/15 08:12:16
Acknowledged.
|
+ bool primary; |
+ std::unique_ptr<Frame> frame; |
+ }; |
kwiberg-webrtc
2016/09/10 07:34:59
Why do you need ParseResult and Frame to be two di
ossu
2016/09/12 10:31:36
Also, the stuff in ParseResult is used to create n
|
+ |
+ // Let the decoder parse this payload and prepare zero or more decodable |
+ // frames. The decoder is free to steal the contents of the payload and retain |
+ // them for as long as necessary. |
+ virtual std::vector<ParseResult> ParsePayload(rtc::Buffer* payload, |
+ uint32_t timestamp, |
+ bool is_primary); |
kwiberg-webrtc
2016/09/10 07:34:59
"and retain them for as long as necessary" is redu
ossu
2016/09/12 10:31:37
Yeah, I'll change it to something more specific.
ossu
2016/09/13 13:37:46
Also tried to address the contract of EncodedAudio
hlundin-webrtc
2016/09/15 08:12:16
kMaxFrameSize in neteq_impl.h defines that 120 ms
|
+ |
// 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 |