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 |
(...skipping 23 matching lines...) Expand all Loading... |
34 kCodecNotSupported = -2, | 34 kCodecNotSupported = -2, |
35 kInvalidSampleRate = -3, | 35 kInvalidSampleRate = -3, |
36 kDecoderExists = -4, | 36 kDecoderExists = -4, |
37 kDecoderNotFound = -5, | 37 kDecoderNotFound = -5, |
38 kInvalidPointer = -6 | 38 kInvalidPointer = -6 |
39 }; | 39 }; |
40 | 40 |
41 // Class that stores decoder info in the database. | 41 // Class that stores decoder info in the database. |
42 class DecoderInfo { | 42 class DecoderInfo { |
43 public: | 43 public: |
| 44 DecoderInfo(NetEqDecoder ct, const std::string& nm); |
44 DecoderInfo(NetEqDecoder ct, | 45 DecoderInfo(NetEqDecoder ct, |
45 const std::string& nm, | 46 const std::string& nm, |
46 int fs, | 47 int sample_rate_hz, |
47 AudioDecoder* ext_dec); | 48 AudioDecoder* ext_dec); |
48 DecoderInfo(DecoderInfo&&); | 49 DecoderInfo(DecoderInfo&&); |
49 ~DecoderInfo(); | 50 ~DecoderInfo(); |
50 | 51 |
51 // Get the AudioDecoder object, creating it first if necessary. | 52 // Get the AudioDecoder object, creating it first if necessary. |
52 AudioDecoder* GetDecoder(AudioDecoderFactory* factory); | 53 AudioDecoder* GetDecoder(AudioDecoderFactory* factory); |
53 | 54 |
54 // Delete the AudioDecoder object, unless it's external. (This means we can | 55 // Delete the AudioDecoder object, unless it's external. (This means we can |
55 // always recreate it later if we need it.) | 56 // always recreate it later if we need it.) |
56 void DropDecoder() { decoder_.reset(); } | 57 void DropDecoder() { decoder_.reset(); } |
57 | 58 |
| 59 int SampleRateHz() const { |
| 60 RTC_DCHECK_EQ(1, !!decoder_ + !!external_decoder + !!cng_decoder_); |
| 61 return decoder_ ? decoder_->SampleRateHz() |
| 62 : external_decoder ? external_decoder->sample_rate_hz |
| 63 : cng_decoder_->sample_rate_hz; |
| 64 } |
| 65 |
58 const NetEqDecoder codec_type; | 66 const NetEqDecoder codec_type; |
59 const std::string name; | 67 const std::string name; |
60 const int fs_hz; | |
61 AudioDecoder* const external_decoder; | |
62 | 68 |
63 private: | 69 private: |
64 const rtc::Optional<SdpAudioFormat> audio_format_; | 70 const rtc::Optional<SdpAudioFormat> audio_format_; |
65 std::unique_ptr<AudioDecoder> decoder_; | 71 std::unique_ptr<AudioDecoder> decoder_; |
| 72 |
| 73 // Set iff this is an external decoder. |
| 74 struct ExternalDecoder { |
| 75 // TODO(kwiberg): Remove sample_rate_hz once we can trust all decoders to |
| 76 // implement SampleRateHz(). |
| 77 int sample_rate_hz; |
| 78 AudioDecoder* decoder; |
| 79 }; |
| 80 const rtc::Optional<ExternalDecoder> external_decoder; |
| 81 |
| 82 // Set iff this is a comfort noise decoder. |
| 83 struct CngDecoder { |
| 84 static rtc::Optional<CngDecoder> Create(NetEqDecoder ct); |
| 85 int sample_rate_hz; |
| 86 }; |
| 87 const rtc::Optional<CngDecoder> cng_decoder_; |
66 }; | 88 }; |
67 | 89 |
68 // Maximum value for 8 bits, and an invalid RTP payload type (since it is | 90 // Maximum value for 8 bits, and an invalid RTP payload type (since it is |
69 // only 7 bits). | 91 // only 7 bits). |
70 static const uint8_t kRtpPayloadTypeError = 0xFF; | 92 static const uint8_t kRtpPayloadTypeError = 0xFF; |
71 | 93 |
72 DecoderDatabase( | 94 DecoderDatabase( |
73 const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory); | 95 const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory); |
74 | 96 |
75 virtual ~DecoderDatabase(); | 97 virtual ~DecoderDatabase(); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 int active_decoder_type_; | 183 int active_decoder_type_; |
162 int active_cng_decoder_type_; | 184 int active_cng_decoder_type_; |
163 std::unique_ptr<ComfortNoiseDecoder> active_cng_decoder_; | 185 std::unique_ptr<ComfortNoiseDecoder> active_cng_decoder_; |
164 rtc::scoped_refptr<AudioDecoderFactory> decoder_factory_; | 186 rtc::scoped_refptr<AudioDecoderFactory> decoder_factory_; |
165 | 187 |
166 RTC_DISALLOW_COPY_AND_ASSIGN(DecoderDatabase); | 188 RTC_DISALLOW_COPY_AND_ASSIGN(DecoderDatabase); |
167 }; | 189 }; |
168 | 190 |
169 } // namespace webrtc | 191 } // namespace webrtc |
170 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_DECODER_DATABASE_H_ | 192 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_DECODER_DATABASE_H_ |
OLD | NEW |