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

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: 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 <vector>
15 15
16 #include "webrtc/base/array_view.h" 16 #include "webrtc/base/array_view.h"
17 #include "webrtc/base/buffer.h" 17 #include "webrtc/base/buffer.h"
18 #include "webrtc/base/constructormagic.h" 18 #include "webrtc/base/constructormagic.h"
19 #include "webrtc/base/optional.h" 19 #include "webrtc/base/optional.h"
20 #include "webrtc/typedefs.h" 20 #include "webrtc/typedefs.h"
21 21
22 namespace webrtc { 22 namespace webrtc {
23 23
24 // This is the interface class for decoders in NetEQ. Each codec type will have 24 // This is the interface class for decoders in NetEQ. Each codec type will have
25 // and implementation of this class. 25 // and implementation of this class.
26 class AudioDecoder { 26 class AudioDecoder {
27 public: 27 public:
28 enum SpeechType { 28 enum SpeechType {
29 kSpeech = 1, 29 kSpeech = 1,
30 kComfortNoise = 2 30 kComfortNoise = 2
31 }; 31 };
32 32
33 // Used by PacketDuration below. Save the value -1 for errors. 33 // Used by PacketDuration below. Save the value -1 for errors.
34 enum { kNotImplemented = -2 }; 34 enum { kNotImplemented = -2 };
35 35
36 struct PacketSplit {
37 size_t byte_offset;
38 size_t num_bytes;
39 size_t timestamp_offset;
40 };
41
36 AudioDecoder() = default; 42 AudioDecoder() = default;
37 virtual ~AudioDecoder() = default; 43 virtual ~AudioDecoder() = default;
38 44
39 class Frame { 45 class Frame {
40 public: 46 public:
41 struct DecodeResult { 47 struct DecodeResult {
42 size_t num_decoded_samples; 48 size_t num_decoded_samples;
43 SpeechType speech_type; 49 SpeechType speech_type;
44 }; 50 };
45 51
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 // Resets the decoder state (empty buffers etc.). 117 // Resets the decoder state (empty buffers etc.).
112 virtual void Reset() = 0; 118 virtual void Reset() = 0;
113 119
114 // Notifies the decoder of an incoming packet to NetEQ. 120 // Notifies the decoder of an incoming packet to NetEQ.
115 virtual int IncomingPacket(const uint8_t* payload, 121 virtual int IncomingPacket(const uint8_t* payload,
116 size_t payload_len, 122 size_t payload_len,
117 uint16_t rtp_sequence_number, 123 uint16_t rtp_sequence_number,
118 uint32_t rtp_timestamp, 124 uint32_t rtp_timestamp,
119 uint32_t arrival_timestamp); 125 uint32_t arrival_timestamp);
120 126
127 // This method is experimental and should not be overriden by external codecs.
128 // It calculates positions where the packet can be split, and the respective
129 // timestamps of those positions. It is part of the work to separate codec
130 // specific functionality from NetEq and will likely be removed soon in favor
131 // of something much better.
132 virtual std::vector<PacketSplit> SplitPacket(
133 rtc::ArrayView<const uint8_t> payload) const;
kwiberg-webrtc 2016/09/12 02:11:01 If you turned the return value into an output argu
ossu 2016/09/12 11:26:37 I've addressed this in the comment on SplitBySampl
134
121 // Returns the last error code from the decoder. 135 // Returns the last error code from the decoder.
122 virtual int ErrorCode(); 136 virtual int ErrorCode();
123 137
124 // Returns the duration in samples-per-channel of the payload in |encoded| 138 // Returns the duration in samples-per-channel of the payload in |encoded|
125 // which is |encoded_len| bytes long. Returns kNotImplemented if no duration 139 // which is |encoded_len| bytes long. Returns kNotImplemented if no duration
126 // estimate is available, or -1 in case of an error. 140 // estimate is available, or -1 in case of an error.
127 virtual int PacketDuration(const uint8_t* encoded, size_t encoded_len) const; 141 virtual int PacketDuration(const uint8_t* encoded, size_t encoded_len) const;
128 142
129 // Returns the duration in samples-per-channel of the redandant payload in 143 // Returns the duration in samples-per-channel of the redandant payload in
130 // |encoded| which is |encoded_len| bytes long. Returns kNotImplemented if no 144 // |encoded| which is |encoded_len| bytes long. Returns kNotImplemented if no
(...skipping 28 matching lines...) Expand all
159 int sample_rate_hz, 173 int sample_rate_hz,
160 int16_t* decoded, 174 int16_t* decoded,
161 SpeechType* speech_type); 175 SpeechType* speech_type);
162 176
163 private: 177 private:
164 RTC_DISALLOW_COPY_AND_ASSIGN(AudioDecoder); 178 RTC_DISALLOW_COPY_AND_ASSIGN(AudioDecoder);
165 }; 179 };
166 180
167 } // namespace webrtc 181 } // namespace webrtc
168 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_INCLUDE_AUDIO_DECODER_H_ 182 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_INCLUDE_AUDIO_DECODER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698