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