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

Side by Side Diff: webrtc/modules/audio_coding/codecs/audio_decoder.h

Issue 2326003002: Moved codec-specific audio packet splitting into decoders. (Closed)
Patch Set: Reworked packet splitting. Renamed SplitBySamples and AudioCodingUtils. 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #ifndef WEBRTC_MODULES_AUDIO_CODING_NETEQ_INCLUDE_AUDIO_DECODER_H_ 11 #ifndef WEBRTC_MODULES_AUDIO_CODING_NETEQ_INCLUDE_AUDIO_DECODER_H_
12 #define WEBRTC_MODULES_AUDIO_CODING_NETEQ_INCLUDE_AUDIO_DECODER_H_ 12 #define WEBRTC_MODULES_AUDIO_CODING_NETEQ_INCLUDE_AUDIO_DECODER_H_
13 13
14 #include <stdlib.h> // NULL 14 #include <memory>
15 #include <vector>
15 16
16 #include "webrtc/base/array_view.h" 17 #include "webrtc/base/array_view.h"
17 #include "webrtc/base/buffer.h" 18 #include "webrtc/base/buffer.h"
18 #include "webrtc/base/constructormagic.h" 19 #include "webrtc/base/constructormagic.h"
19 #include "webrtc/base/optional.h" 20 #include "webrtc/base/optional.h"
20 #include "webrtc/typedefs.h" 21 #include "webrtc/typedefs.h"
21 22
22 namespace webrtc { 23 namespace webrtc {
23 24
24 // This is the interface class for decoders in NetEQ. Each codec type will have 25 // This is the interface class for decoders in NetEQ. Each codec type will have
25 // and implementation of this class. 26 // and implementation of this class.
26 class AudioDecoder { 27 class AudioDecoder {
27 public: 28 public:
28 enum SpeechType { 29 enum SpeechType {
29 kSpeech = 1, 30 kSpeech = 1,
30 kComfortNoise = 2 31 kComfortNoise = 2
31 }; 32 };
32 33
33 // Used by PacketDuration below. Save the value -1 for errors. 34 // Used by PacketDuration below. Save the value -1 for errors.
34 enum { kNotImplemented = -2 }; 35 enum { kNotImplemented = -2 };
35 36
36 AudioDecoder() = default; 37 AudioDecoder() = default;
37 virtual ~AudioDecoder() = default; 38 virtual ~AudioDecoder() = default;
38 39
39 class EncodedAudioFrame { 40 class EncodedAudioFrame {
kwiberg-webrtc 2016/09/15 13:01:25 You don't have to change this, but to me this name
ossu 2016/09/15 14:41:05 I'd argue that it isn't a decoder, but a frame tha
kwiberg-webrtc 2016/09/16 00:48:07 Acknowledged.
40 public: 41 public:
41 struct DecodeResult { 42 struct DecodeResult {
42 size_t num_decoded_samples; 43 size_t num_decoded_samples;
43 SpeechType speech_type; 44 SpeechType speech_type;
44 }; 45 };
45 46
46 virtual ~EncodedAudioFrame() = default; 47 virtual ~EncodedAudioFrame() = default;
47 48
48 // Returns the duration in samples-per-channel of this audio frame. 49 // Returns the duration in samples-per-channel of this audio frame.
49 // If no duration can be ascertained, returns zero. 50 // If no duration can be ascertained, returns zero.
50 virtual size_t Duration() const = 0; 51 virtual size_t Duration() const = 0;
51 52
52 // Decodes this frame of audio and writes the result in |decoded|. 53 // Decodes this frame of audio and writes the result in |decoded|.
53 // Returns rtc::Optional containing the total number of samples across all 54 // Returns rtc::Optional containing the total number of samples across all
54 // channels, as well as whether the decoder produced comfort noise or 55 // channels, as well as whether the decoder produced comfort noise or
55 // speech. Decode must only be called once per frame object. 56 // speech. Decode must only be called once per frame object.
kwiberg-webrtc 2016/09/15 13:01:24 Even more specifically: 0 or 1 times.
ossu 2016/09/15 14:41:05 Took care of that in an update to a previous CL.
kwiberg-webrtc 2016/09/16 00:48:07 Acknowledged.
56 virtual rtc::Optional<DecodeResult> Decode( 57 virtual rtc::Optional<DecodeResult> Decode(
57 rtc::ArrayView<int16_t> decoded) const = 0; 58 rtc::ArrayView<int16_t> decoded) const = 0;
58 }; 59 };
59 60
60 struct ParseResult { 61 struct ParseResult {
61 ParseResult(); 62 ParseResult();
62 ParseResult(uint32_t timestamp, 63 ParseResult(uint32_t timestamp,
63 bool primary, 64 bool primary,
64 std::unique_ptr<EncodedAudioFrame> frame); 65 std::unique_ptr<EncodedAudioFrame> frame);
65 ParseResult(ParseResult&& b); 66 ParseResult(ParseResult&& b);
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 int sample_rate_hz, 163 int sample_rate_hz,
163 int16_t* decoded, 164 int16_t* decoded,
164 SpeechType* speech_type); 165 SpeechType* speech_type);
165 166
166 private: 167 private:
167 RTC_DISALLOW_COPY_AND_ASSIGN(AudioDecoder); 168 RTC_DISALLOW_COPY_AND_ASSIGN(AudioDecoder);
168 }; 169 };
169 170
170 } // namespace webrtc 171 } // namespace webrtc
171 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_INCLUDE_AUDIO_DECODER_H_ 172 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_INCLUDE_AUDIO_DECODER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698