OLD | NEW |
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_CODECS_AUDIO_DECODER_H_ |
12 #define WEBRTC_MODULES_AUDIO_CODING_NETEQ_INCLUDE_AUDIO_DECODER_H_ | 12 #define WEBRTC_MODULES_AUDIO_CODING_CODECS_AUDIO_DECODER_H_ |
13 | 13 |
14 #include <memory> | 14 #include <memory> |
15 #include <vector> | 15 #include <vector> |
16 | |
17 #include <memory> | |
18 #include <vector> | |
19 | 16 |
20 #include "webrtc/base/array_view.h" | 17 #include "webrtc/base/array_view.h" |
21 #include "webrtc/base/buffer.h" | 18 #include "webrtc/base/buffer.h" |
22 #include "webrtc/base/constructormagic.h" | 19 #include "webrtc/base/constructormagic.h" |
23 #include "webrtc/base/optional.h" | 20 #include "webrtc/base/optional.h" |
24 #include "webrtc/typedefs.h" | 21 #include "webrtc/typedefs.h" |
25 | 22 |
26 namespace webrtc { | 23 namespace webrtc { |
27 | 24 |
28 // 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 |
(...skipping 30 matching lines...) Expand all Loading... |
59 // total number of samples across all channels, as well as whether the | 56 // total number of samples across all channels, as well as whether the |
60 // decoder produced comfort noise or speech. On failure, returns an empty | 57 // decoder produced comfort noise or speech. On failure, returns an empty |
61 // rtc::Optional. Decode may be called at most once per frame object. | 58 // rtc::Optional. Decode may be called at most once per frame object. |
62 virtual rtc::Optional<DecodeResult> Decode( | 59 virtual rtc::Optional<DecodeResult> Decode( |
63 rtc::ArrayView<int16_t> decoded) const = 0; | 60 rtc::ArrayView<int16_t> decoded) const = 0; |
64 }; | 61 }; |
65 | 62 |
66 struct ParseResult { | 63 struct ParseResult { |
67 ParseResult(); | 64 ParseResult(); |
68 ParseResult(uint32_t timestamp, | 65 ParseResult(uint32_t timestamp, |
69 bool primary, | 66 int priority, |
70 std::unique_ptr<EncodedAudioFrame> frame); | 67 std::unique_ptr<EncodedAudioFrame> frame); |
71 ParseResult(ParseResult&& b); | 68 ParseResult(ParseResult&& b); |
72 ~ParseResult(); | 69 ~ParseResult(); |
73 | 70 |
74 ParseResult& operator=(ParseResult&& b); | 71 ParseResult& operator=(ParseResult&& b); |
75 | 72 |
76 // The timestamp of the frame is in samples per channel. | 73 // The timestamp of the frame is in samples per channel. |
77 uint32_t timestamp; | 74 uint32_t timestamp; |
78 bool primary; | 75 // The relative priority of the frame compared to other frames of the same |
| 76 // payload and the same timeframe. A higher value means a lower priority. |
| 77 // The highest priority is zero - negative values are not allowed. |
| 78 int priority; |
79 std::unique_ptr<EncodedAudioFrame> frame; | 79 std::unique_ptr<EncodedAudioFrame> frame; |
80 }; | 80 }; |
81 | 81 |
82 // Let the decoder parse this payload and prepare zero or more decodable | 82 // Let the decoder parse this payload and prepare zero or more decodable |
83 // frames. Each frame must be between 10 ms and 120 ms long. The caller must | 83 // frames. Each frame must be between 10 ms and 120 ms long. The caller must |
84 // ensure that the AudioDecoder object outlives any frame objects returned by | 84 // ensure that the AudioDecoder object outlives any frame objects returned by |
85 // this call. The decoder is free to swap or move the data from the |payload| | 85 // this call. The decoder is free to swap or move the data from the |payload| |
86 // buffer. |timestamp| is the input timestamp, in samples, corresponding to | 86 // buffer. |timestamp| is the input timestamp, in samples, corresponding to |
87 // the start of the payload. | 87 // the start of the payload. |
88 virtual std::vector<ParseResult> ParsePayload(rtc::Buffer&& payload, | 88 virtual std::vector<ParseResult> ParsePayload(rtc::Buffer&& payload, |
89 uint32_t timestamp, | 89 uint32_t timestamp); |
90 bool is_primary); | |
91 | 90 |
92 // Decodes |encode_len| bytes from |encoded| and writes the result in | 91 // Decodes |encode_len| bytes from |encoded| and writes the result in |
93 // |decoded|. The maximum bytes allowed to be written into |decoded| is | 92 // |decoded|. The maximum bytes allowed to be written into |decoded| is |
94 // |max_decoded_bytes|. Returns the total number of samples across all | 93 // |max_decoded_bytes|. Returns the total number of samples across all |
95 // channels. If the decoder produced comfort noise, |speech_type| | 94 // channels. If the decoder produced comfort noise, |speech_type| |
96 // is set to kComfortNoise, otherwise it is kSpeech. The desired output | 95 // is set to kComfortNoise, otherwise it is kSpeech. The desired output |
97 // sample rate is provided in |sample_rate_hz|, which must be valid for the | 96 // sample rate is provided in |sample_rate_hz|, which must be valid for the |
98 // codec at hand. | 97 // codec at hand. |
99 int Decode(const uint8_t* encoded, | 98 int Decode(const uint8_t* encoded, |
100 size_t encoded_len, | 99 size_t encoded_len, |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 size_t encoded_len, | 169 size_t encoded_len, |
171 int sample_rate_hz, | 170 int sample_rate_hz, |
172 int16_t* decoded, | 171 int16_t* decoded, |
173 SpeechType* speech_type); | 172 SpeechType* speech_type); |
174 | 173 |
175 private: | 174 private: |
176 RTC_DISALLOW_COPY_AND_ASSIGN(AudioDecoder); | 175 RTC_DISALLOW_COPY_AND_ASSIGN(AudioDecoder); |
177 }; | 176 }; |
178 | 177 |
179 } // namespace webrtc | 178 } // namespace webrtc |
180 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_INCLUDE_AUDIO_DECODER_H_ | 179 #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_AUDIO_DECODER_H_ |
OLD | NEW |