Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(181)

Side by Side Diff: webrtc/modules/audio_coding/neteq/decoder_database.cc

Issue 2472083002: NetEq: Don't forget to save the codec name (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "webrtc/modules/audio_coding/neteq/decoder_database.h" 11 #include "webrtc/modules/audio_coding/neteq/decoder_database.h"
12 12
13 #include <utility> // pair 13 #include <utility> // pair
14 14
15 #include "webrtc/base/checks.h" 15 #include "webrtc/base/checks.h"
16 #include "webrtc/base/logging.h" 16 #include "webrtc/base/logging.h"
17 #include "webrtc/modules/audio_coding/codecs/audio_decoder.h" 17 #include "webrtc/modules/audio_coding/codecs/audio_decoder.h"
18 18
19 namespace webrtc { 19 namespace webrtc {
20 20
21 DecoderDatabase::DecoderDatabase( 21 DecoderDatabase::DecoderDatabase(
22 const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory) 22 const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory)
23 : active_decoder_type_(-1), 23 : active_decoder_type_(-1),
24 active_cng_decoder_type_(-1), 24 active_cng_decoder_type_(-1),
25 decoder_factory_(decoder_factory) {} 25 decoder_factory_(decoder_factory) {}
26 26
27 DecoderDatabase::~DecoderDatabase() = default; 27 DecoderDatabase::~DecoderDatabase() = default;
28 28
29 DecoderDatabase::DecoderInfo::DecoderInfo(const SdpAudioFormat& audio_format, 29 DecoderDatabase::DecoderInfo::DecoderInfo(const SdpAudioFormat& audio_format,
30 AudioDecoderFactory* factory) 30 AudioDecoderFactory* factory,
31 : audio_format_(audio_format), 31 const std::string& codec_name)
32 : name_(codec_name),
33 audio_format_(audio_format),
32 factory_(factory), 34 factory_(factory),
33 external_decoder_(nullptr), 35 external_decoder_(nullptr),
34 cng_decoder_(CngDecoder::Create(audio_format)), 36 cng_decoder_(CngDecoder::Create(audio_format)),
35 subtype_(SubtypeFromFormat(audio_format)) {} 37 subtype_(SubtypeFromFormat(audio_format)) {}
36 38
39 DecoderDatabase::DecoderInfo::DecoderInfo(const SdpAudioFormat& audio_format,
40 AudioDecoderFactory* factory)
41 : DecoderInfo(audio_format, factory, audio_format.name) {}
kwiberg-webrtc 2016/11/03 12:02:58 The functional change is here; we actually fill in
42
37 DecoderDatabase::DecoderInfo::DecoderInfo(NetEqDecoder ct, 43 DecoderDatabase::DecoderInfo::DecoderInfo(NetEqDecoder ct,
38 AudioDecoderFactory* factory) 44 AudioDecoderFactory* factory)
39 : audio_format_(*acm2::RentACodec::NetEqDecoderToSdpAudioFormat(ct)), 45 : DecoderInfo(*acm2::RentACodec::NetEqDecoderToSdpAudioFormat(ct),
40 factory_(factory), 46 factory) {}
41 external_decoder_(nullptr),
42 cng_decoder_(CngDecoder::Create(audio_format_)),
43 subtype_(SubtypeFromFormat(audio_format_)) {}
44 47
45 DecoderDatabase::DecoderInfo::DecoderInfo(const SdpAudioFormat& audio_format, 48 DecoderDatabase::DecoderInfo::DecoderInfo(const SdpAudioFormat& audio_format,
46 AudioDecoder* ext_dec) 49 AudioDecoder* ext_dec,
47 : audio_format_(audio_format), 50 const std::string& codec_name)
51 : name_(codec_name),
52 audio_format_(audio_format),
48 factory_(nullptr), 53 factory_(nullptr),
49 external_decoder_(ext_dec), 54 external_decoder_(ext_dec),
50 subtype_(Subtype::kNormal) { 55 subtype_(Subtype::kNormal) {
51 RTC_CHECK(ext_dec); 56 RTC_CHECK(ext_dec);
52 } 57 }
53 58
54 DecoderDatabase::DecoderInfo::DecoderInfo(DecoderInfo&&) = default; 59 DecoderDatabase::DecoderInfo::DecoderInfo(DecoderInfo&&) = default;
55 DecoderDatabase::DecoderInfo::~DecoderInfo() = default; 60 DecoderDatabase::DecoderInfo::~DecoderInfo() = default;
56 61
57 AudioDecoder* DecoderDatabase::DecoderInfo::GetDecoder() const { 62 AudioDecoder* DecoderDatabase::DecoderInfo::GetDecoder() const {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 // kCodecArbitrary is only supported through InsertExternal. 133 // kCodecArbitrary is only supported through InsertExternal.
129 if (codec_type == NetEqDecoder::kDecoderArbitrary || 134 if (codec_type == NetEqDecoder::kDecoderArbitrary ||
130 !CodecSupported(codec_type)) { 135 !CodecSupported(codec_type)) {
131 return kCodecNotSupported; 136 return kCodecNotSupported;
132 } 137 }
133 const auto opt_format = 138 const auto opt_format =
134 acm2::RentACodec::NetEqDecoderToSdpAudioFormat(codec_type); 139 acm2::RentACodec::NetEqDecoderToSdpAudioFormat(codec_type);
135 if (!opt_format) { 140 if (!opt_format) {
136 return kCodecNotSupported; 141 return kCodecNotSupported;
137 } 142 }
138 DecoderInfo info(*opt_format, decoder_factory_); 143 DecoderInfo info(*opt_format, decoder_factory_, name);
139 info.name = name;
140 auto ret = 144 auto ret =
141 decoders_.insert(std::make_pair(rtp_payload_type, std::move(info))); 145 decoders_.insert(std::make_pair(rtp_payload_type, std::move(info)));
142 if (ret.second == false) { 146 if (ret.second == false) {
143 // Database already contains a decoder with type |rtp_payload_type|. 147 // Database already contains a decoder with type |rtp_payload_type|.
144 return kDecoderExists; 148 return kDecoderExists;
145 } 149 }
146 return kOK; 150 return kOK;
147 } 151 }
148 152
149 int DecoderDatabase::RegisterPayload(int rtp_payload_type, 153 int DecoderDatabase::RegisterPayload(int rtp_payload_type,
150 const SdpAudioFormat& audio_format) { 154 const SdpAudioFormat& audio_format) {
151 if (rtp_payload_type < 0 || rtp_payload_type > 0x7f) { 155 if (rtp_payload_type < 0 || rtp_payload_type > 0x7f) {
152 return kInvalidRtpPayloadType; 156 return kInvalidRtpPayloadType;
153 } 157 }
154 const auto ret = decoders_.insert(std::make_pair( 158 const auto ret = decoders_.insert(std::make_pair(
155 rtp_payload_type, DecoderInfo(audio_format, decoder_factory_.get()))); 159 rtp_payload_type, DecoderInfo(audio_format, decoder_factory_.get())));
ossu 2016/11/03 12:15:23 Oh, right, this should've had to be done manually
156 if (ret.second == false) { 160 if (ret.second == false) {
157 // Database already contains a decoder with type |rtp_payload_type|. 161 // Database already contains a decoder with type |rtp_payload_type|.
158 return kDecoderExists; 162 return kDecoderExists;
159 } 163 }
160 return kOK; 164 return kOK;
161 } 165 }
162 166
163 int DecoderDatabase::InsertExternal(uint8_t rtp_payload_type, 167 int DecoderDatabase::InsertExternal(uint8_t rtp_payload_type,
164 NetEqDecoder codec_type, 168 NetEqDecoder codec_type,
165 const std::string& codec_name, 169 const std::string& codec_name,
166 AudioDecoder* decoder) { 170 AudioDecoder* decoder) {
167 if (rtp_payload_type > 0x7F) { 171 if (rtp_payload_type > 0x7F) {
168 return kInvalidRtpPayloadType; 172 return kInvalidRtpPayloadType;
169 } 173 }
170 if (!decoder) { 174 if (!decoder) {
171 return kInvalidPointer; 175 return kInvalidPointer;
172 } 176 }
173 177
174 const auto opt_db_format = 178 const auto opt_db_format =
175 acm2::RentACodec::NetEqDecoderToSdpAudioFormat(codec_type); 179 acm2::RentACodec::NetEqDecoderToSdpAudioFormat(codec_type);
176 const SdpAudioFormat format = opt_db_format.value_or({"arbitrary", 0, 0}); 180 const SdpAudioFormat format = opt_db_format.value_or({"arbitrary", 0, 0});
177 181
178 std::pair<DecoderMap::iterator, bool> ret; 182 std::pair<DecoderMap::iterator, bool> ret;
179 DecoderInfo info(format, decoder); 183 DecoderInfo info(format, decoder, codec_name);
180 info.name = codec_name;
181 ret = decoders_.insert(std::make_pair(rtp_payload_type, std::move(info))); 184 ret = decoders_.insert(std::make_pair(rtp_payload_type, std::move(info)));
182 if (ret.second == false) { 185 if (ret.second == false) {
183 // Database already contains a decoder with type |rtp_payload_type|. 186 // Database already contains a decoder with type |rtp_payload_type|.
184 return kDecoderExists; 187 return kDecoderExists;
185 } 188 }
186 return kOK; 189 return kOK;
187 } 190 }
188 191
189 int DecoderDatabase::Remove(uint8_t rtp_payload_type) { 192 int DecoderDatabase::Remove(uint8_t rtp_payload_type) {
190 if (decoders_.erase(rtp_payload_type) == 0) { 193 if (decoders_.erase(rtp_payload_type) == 0) {
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 // Payload type is not found. 317 // Payload type is not found.
315 LOG(LS_WARNING) << "CheckPayloadTypes: unknown RTP payload type " 318 LOG(LS_WARNING) << "CheckPayloadTypes: unknown RTP payload type "
316 << static_cast<int>(it->payload_type); 319 << static_cast<int>(it->payload_type);
317 return kDecoderNotFound; 320 return kDecoderNotFound;
318 } 321 }
319 } 322 }
320 return kOK; 323 return kOK;
321 } 324 }
322 325
323 } // namespace webrtc 326 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/neteq/decoder_database.h ('k') | webrtc/modules/audio_coding/neteq/decoder_database_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698