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 26 matching lines...) Expand all Loading... | |
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, const std::string& nm); |
45 DecoderInfo(NetEqDecoder ct, | 45 DecoderInfo(NetEqDecoder ct, |
46 const std::string& nm, | 46 const std::string& nm, |
47 int sample_rate_hz, | |
48 AudioDecoder* ext_dec); | 47 AudioDecoder* ext_dec); |
49 DecoderInfo(DecoderInfo&&); | 48 DecoderInfo(DecoderInfo&&); |
50 ~DecoderInfo(); | 49 ~DecoderInfo(); |
51 | 50 |
52 // Get the AudioDecoder object, creating it first if necessary. | 51 // Get the AudioDecoder object, creating it first if necessary. |
53 AudioDecoder* GetDecoder(AudioDecoderFactory* factory); | 52 AudioDecoder* GetDecoder(AudioDecoderFactory* factory); |
54 | 53 |
55 // Delete the AudioDecoder object, unless it's external. (This means we can | 54 // Delete the AudioDecoder object, unless it's external. (This means we can |
56 // always recreate it later if we need it.) | 55 // always recreate it later if we need it.) |
57 void DropDecoder() { decoder_.reset(); } | 56 void DropDecoder() { decoder_.reset(); } |
58 | 57 |
59 int SampleRateHz() const { | 58 int SampleRateHz() const { |
60 RTC_DCHECK_EQ(1, !!decoder_ + !!external_decoder + !!cng_decoder_); | 59 RTC_DCHECK_EQ(1, !!decoder_ + !!external_decoder_ + !!cng_decoder_); |
61 return decoder_ ? decoder_->SampleRateHz() | 60 return decoder_ ? decoder_->SampleRateHz() |
62 : external_decoder ? external_decoder->sample_rate_hz | 61 : external_decoder_ ? external_decoder_->SampleRateHz() |
63 : cng_decoder_->sample_rate_hz; | 62 : cng_decoder_->sample_rate_hz; |
64 } | 63 } |
65 | 64 |
66 const NetEqDecoder codec_type; | 65 const NetEqDecoder codec_type; |
67 const std::string name; | 66 const std::string name; |
68 | 67 |
69 private: | 68 private: |
70 const rtc::Optional<SdpAudioFormat> audio_format_; | 69 const rtc::Optional<SdpAudioFormat> audio_format_; |
71 std::unique_ptr<AudioDecoder> decoder_; | 70 std::unique_ptr<AudioDecoder> decoder_; |
72 | 71 |
73 // Set iff this is an external decoder. | 72 // Set iff this is an external decoder. |
74 struct ExternalDecoder { | 73 AudioDecoder* const external_decoder_; |
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; | |
hlundin-webrtc
2016/06/01 13:49:21
What?! No trailing underscore on the member variab
kwiberg-webrtc
2016/06/01 13:55:33
It appears to have been written and reviewed by tw
| |
81 | 74 |
82 // Set iff this is a comfort noise decoder. | 75 // Set iff this is a comfort noise decoder. |
83 struct CngDecoder { | 76 struct CngDecoder { |
84 static rtc::Optional<CngDecoder> Create(NetEqDecoder ct); | 77 static rtc::Optional<CngDecoder> Create(NetEqDecoder ct); |
85 int sample_rate_hz; | 78 int sample_rate_hz; |
86 }; | 79 }; |
87 const rtc::Optional<CngDecoder> cng_decoder_; | 80 const rtc::Optional<CngDecoder> cng_decoder_; |
88 }; | 81 }; |
89 | 82 |
90 // Maximum value for 8 bits, and an invalid RTP payload type (since it is | 83 // Maximum value for 8 bits, and an invalid RTP payload type (since it is |
(...skipping 22 matching lines...) Expand all Loading... | |
113 // otherwise an error code. | 106 // otherwise an error code. |
114 virtual int RegisterPayload(uint8_t rtp_payload_type, | 107 virtual int RegisterPayload(uint8_t rtp_payload_type, |
115 NetEqDecoder codec_type, | 108 NetEqDecoder codec_type, |
116 const std::string& name); | 109 const std::string& name); |
117 | 110 |
118 // Registers an externally created AudioDecoder object, and associates it | 111 // Registers an externally created AudioDecoder object, and associates it |
119 // as a decoder of type |codec_type| with |rtp_payload_type|. | 112 // as a decoder of type |codec_type| with |rtp_payload_type|. |
120 virtual int InsertExternal(uint8_t rtp_payload_type, | 113 virtual int InsertExternal(uint8_t rtp_payload_type, |
121 NetEqDecoder codec_type, | 114 NetEqDecoder codec_type, |
122 const std::string& codec_name, | 115 const std::string& codec_name, |
123 int fs_hz, | |
124 AudioDecoder* decoder); | 116 AudioDecoder* decoder); |
125 | 117 |
126 // Removes the entry for |rtp_payload_type| from the database. | 118 // Removes the entry for |rtp_payload_type| from the database. |
127 // Returns kDecoderNotFound or kOK depending on the outcome of the operation. | 119 // Returns kDecoderNotFound or kOK depending on the outcome of the operation. |
128 virtual int Remove(uint8_t rtp_payload_type); | 120 virtual int Remove(uint8_t rtp_payload_type); |
129 | 121 |
130 // Returns a pointer to the DecoderInfo struct for |rtp_payload_type|. If | 122 // Returns a pointer to the DecoderInfo struct for |rtp_payload_type|. If |
131 // no decoder is registered with that |rtp_payload_type|, NULL is returned. | 123 // no decoder is registered with that |rtp_payload_type|, NULL is returned. |
132 virtual const DecoderInfo* GetDecoderInfo(uint8_t rtp_payload_type) const; | 124 virtual const DecoderInfo* GetDecoderInfo(uint8_t rtp_payload_type) const; |
133 | 125 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
183 int active_decoder_type_; | 175 int active_decoder_type_; |
184 int active_cng_decoder_type_; | 176 int active_cng_decoder_type_; |
185 std::unique_ptr<ComfortNoiseDecoder> active_cng_decoder_; | 177 std::unique_ptr<ComfortNoiseDecoder> active_cng_decoder_; |
186 rtc::scoped_refptr<AudioDecoderFactory> decoder_factory_; | 178 rtc::scoped_refptr<AudioDecoderFactory> decoder_factory_; |
187 | 179 |
188 RTC_DISALLOW_COPY_AND_ASSIGN(DecoderDatabase); | 180 RTC_DISALLOW_COPY_AND_ASSIGN(DecoderDatabase); |
189 }; | 181 }; |
190 | 182 |
191 } // namespace webrtc | 183 } // namespace webrtc |
192 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_DECODER_DATABASE_H_ | 184 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_DECODER_DATABASE_H_ |
OLD | NEW |