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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 | 58 |
59 int SampleRateHz() const { | 59 int SampleRateHz() const { |
60 const AudioDecoder* decoder = GetDecoder(); | 60 const AudioDecoder* decoder = GetDecoder(); |
61 RTC_DCHECK_EQ(1, !!decoder + !!cng_decoder_); | 61 RTC_DCHECK_EQ(1, !!decoder + !!cng_decoder_); |
62 return decoder ? decoder->SampleRateHz() : cng_decoder_->sample_rate_hz; | 62 return decoder ? decoder->SampleRateHz() : cng_decoder_->sample_rate_hz; |
63 } | 63 } |
64 | 64 |
65 const SdpAudioFormat& GetFormat() const { return audio_format_; } | 65 const SdpAudioFormat& GetFormat() const { return audio_format_; } |
66 | 66 |
67 // Returns true if the decoder's format is comfort noise. | 67 // Returns true if the decoder's format is comfort noise. |
68 bool IsComfortNoise() const; | 68 bool IsComfortNoise() const { |
| 69 RTC_DCHECK_EQ(!!cng_decoder_, subtype_ == Subtype::kComfortNoise); |
| 70 return subtype_ == Subtype::kComfortNoise; |
| 71 } |
69 | 72 |
70 // Returns true if the decoder's format is DTMF. | 73 // Returns true if the decoder's format is DTMF. |
71 bool IsDtmf() const; | 74 bool IsDtmf() const { |
| 75 return subtype_ == Subtype::kDtmf; |
| 76 } |
72 | 77 |
73 // Returns true if the decoder's format is RED. | 78 // Returns true if the decoder's format is RED. |
74 bool IsRed() const; | 79 bool IsRed() const { |
| 80 return subtype_ == Subtype::kRed; |
| 81 } |
75 | 82 |
76 // Returns true if the decoder's format is named |name|. | 83 // Returns true if the decoder's format is named |name|. |
77 bool IsType(const char* name) const; | 84 bool IsType(const char* name) const; |
78 // Returns true if the decoder's format is named |name|. | 85 // Returns true if the decoder's format is named |name|. |
79 bool IsType(const std::string& name) const; | 86 bool IsType(const std::string& name) const; |
80 | 87 |
81 // TODO(ossu): |name| is kept here while we retain the old external decoder | 88 // TODO(ossu): |name| is kept here while we retain the old external decoder |
82 // interface. Remove this once using an AudioDecoderFactory has | 89 // interface. Remove this once using an AudioDecoderFactory has |
83 // supplanted the old functionality. | 90 // supplanted the old functionality. |
84 std::string name; | 91 std::string name; |
85 | 92 |
86 private: | 93 private: |
87 const SdpAudioFormat audio_format_; | 94 const SdpAudioFormat audio_format_; |
88 AudioDecoderFactory* const factory_; | 95 AudioDecoderFactory* const factory_; |
89 mutable std::unique_ptr<AudioDecoder> decoder_; | 96 mutable std::unique_ptr<AudioDecoder> decoder_; |
90 | 97 |
91 // Set iff this is an external decoder. | 98 // Set iff this is an external decoder. |
92 AudioDecoder* const external_decoder_; | 99 AudioDecoder* const external_decoder_; |
93 | 100 |
94 // Set iff this is a comfort noise decoder. | 101 // Set iff this is a comfort noise decoder. |
95 struct CngDecoder { | 102 struct CngDecoder { |
96 static rtc::Optional<CngDecoder> Create(const SdpAudioFormat& format); | 103 static rtc::Optional<CngDecoder> Create(const SdpAudioFormat& format); |
97 int sample_rate_hz; | 104 int sample_rate_hz; |
98 }; | 105 }; |
99 const rtc::Optional<CngDecoder> cng_decoder_; | 106 const rtc::Optional<CngDecoder> cng_decoder_; |
| 107 |
| 108 enum class Subtype : int8_t { |
| 109 kNormal, |
| 110 kComfortNoise, |
| 111 kDtmf, |
| 112 kRed |
| 113 }; |
| 114 |
| 115 static Subtype SubtypeFromFormat(const SdpAudioFormat& format); |
| 116 |
| 117 const Subtype subtype_; |
100 }; | 118 }; |
101 | 119 |
102 // Maximum value for 8 bits, and an invalid RTP payload type (since it is | 120 // Maximum value for 8 bits, and an invalid RTP payload type (since it is |
103 // only 7 bits). | 121 // only 7 bits). |
104 static const uint8_t kRtpPayloadTypeError = 0xFF; | 122 static const uint8_t kRtpPayloadTypeError = 0xFF; |
105 | 123 |
106 DecoderDatabase( | 124 DecoderDatabase( |
107 const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory); | 125 const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory); |
108 | 126 |
109 virtual ~DecoderDatabase(); | 127 virtual ~DecoderDatabase(); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 int active_decoder_type_; | 215 int active_decoder_type_; |
198 int active_cng_decoder_type_; | 216 int active_cng_decoder_type_; |
199 mutable std::unique_ptr<ComfortNoiseDecoder> active_cng_decoder_; | 217 mutable std::unique_ptr<ComfortNoiseDecoder> active_cng_decoder_; |
200 rtc::scoped_refptr<AudioDecoderFactory> decoder_factory_; | 218 rtc::scoped_refptr<AudioDecoderFactory> decoder_factory_; |
201 | 219 |
202 RTC_DISALLOW_COPY_AND_ASSIGN(DecoderDatabase); | 220 RTC_DISALLOW_COPY_AND_ASSIGN(DecoderDatabase); |
203 }; | 221 }; |
204 | 222 |
205 } // namespace webrtc | 223 } // namespace webrtc |
206 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_DECODER_DATABASE_H_ | 224 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_DECODER_DATABASE_H_ |
OLD | NEW |