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

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

Issue 1484343003: NetEq: Add codec name and RTP timestamp rate to DecoderInfo (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years 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 <assert.h> 13 #include <assert.h>
14 #include <utility> // pair 14 #include <utility> // pair
15 15
16 #include "webrtc/base/checks.h"
16 #include "webrtc/base/logging.h" 17 #include "webrtc/base/logging.h"
17 #include "webrtc/modules/audio_coding/codecs/audio_decoder.h" 18 #include "webrtc/modules/audio_coding/codecs/audio_decoder.h"
18 19
19 namespace webrtc { 20 namespace webrtc {
21 namespace {
22 // The codec names are taken from ACMCodecDB::database_.
23 std::string CodecName(NetEqDecoder codec_type) {
24 switch (codec_type) {
25 case NetEqDecoder::kDecoderPCMu:
26 case NetEqDecoder::kDecoderPCMu_2ch:
27 return "PCMU";
28 case NetEqDecoder::kDecoderPCMa:
29 case NetEqDecoder::kDecoderPCMa_2ch:
30 return "PCMA";
31 case NetEqDecoder::kDecoderPCM16B:
32 case NetEqDecoder::kDecoderPCM16B_2ch:
33 case NetEqDecoder::kDecoderPCM16B_5ch:
34 case NetEqDecoder::kDecoderPCM16Bwb:
35 case NetEqDecoder::kDecoderPCM16Bwb_2ch:
36 case NetEqDecoder::kDecoderPCM16Bswb32kHz:
37 case NetEqDecoder::kDecoderPCM16Bswb32kHz_2ch:
38 case NetEqDecoder::kDecoderPCM16Bswb48kHz:
39 case NetEqDecoder::kDecoderPCM16Bswb48kHz_2ch:
40 return "L16";
41 #ifdef WEBRTC_CODEC_G722
42 case NetEqDecoder::kDecoderG722:
43 case NetEqDecoder::kDecoderG722_2ch:
44 return "G722";
45 #endif
46 #ifdef WEBRTC_CODEC_ILBC
47 case NetEqDecoder::kDecoderILBC:
48 return "ILBC";
49 #endif
50 #if defined(WEBRTC_CODEC_ISACFX) || defined(WEBRTC_CODEC_ISAC)
51 case NetEqDecoder::kDecoderISAC:
52 #ifdef WEBRTC_CODEC_ISAC
53 case NetEqDecoder::kDecoderISACswb:
54 #endif
55 return "ISAC";
56 #endif
57 #ifdef WEBRTC_CODEC_OPUS
58 case NetEqDecoder::kDecoderOpus:
59 case NetEqDecoder::kDecoderOpus_2ch:
60 return "opus";
61 #endif
62 case NetEqDecoder::kDecoderCNGnb:
63 case NetEqDecoder::kDecoderCNGwb:
64 case NetEqDecoder::kDecoderCNGswb32kHz:
65 case NetEqDecoder::kDecoderCNGswb48kHz:
66 return "CN";
67 case NetEqDecoder::kDecoderRED:
68 return "red";
69 case NetEqDecoder::kDecoderAVT:
70 return "telephone-event";
71 case NetEqDecoder::kDecoderArbitrary:
72 return "arbitrary";
73 default:
74 RTC_NOTREACHED();
75 return "unknown";
76 }
77 }
78 } // namespace
kwiberg-webrtc 2015/12/02 09:50:42 Should we standardize on either lower- or uppercas
hlundin-webrtc 2015/12/02 16:19:24 Yes, we should. But no longer relevant for this CL
20 79
21 DecoderDatabase::DecoderDatabase() 80 DecoderDatabase::DecoderDatabase()
22 : active_decoder_(-1), active_cng_decoder_(-1) {} 81 : active_decoder_(-1), active_cng_decoder_(-1) {}
23 82
24 DecoderDatabase::~DecoderDatabase() {} 83 DecoderDatabase::~DecoderDatabase() {}
25 84
26 DecoderDatabase::DecoderInfo::~DecoderInfo() { 85 DecoderDatabase::DecoderInfo::~DecoderInfo() {
27 if (!external) delete decoder; 86 if (!external) delete decoder;
28 } 87 }
29 88
30 bool DecoderDatabase::Empty() const { return decoders_.empty(); } 89 bool DecoderDatabase::Empty() const { return decoders_.empty(); }
31 90
32 int DecoderDatabase::Size() const { return static_cast<int>(decoders_.size()); } 91 int DecoderDatabase::Size() const { return static_cast<int>(decoders_.size()); }
33 92
34 void DecoderDatabase::Reset() { 93 void DecoderDatabase::Reset() {
35 decoders_.clear(); 94 decoders_.clear();
36 active_decoder_ = -1; 95 active_decoder_ = -1;
37 active_cng_decoder_ = -1; 96 active_cng_decoder_ = -1;
38 } 97 }
39 98
40 int DecoderDatabase::RegisterPayload(uint8_t rtp_payload_type, 99 int DecoderDatabase::RegisterPayload(uint8_t rtp_payload_type,
41 NetEqDecoder codec_type) { 100 NetEqDecoder codec_type) {
42 if (rtp_payload_type > 0x7F) { 101 if (rtp_payload_type > 0x7F) {
43 return kInvalidRtpPayloadType; 102 return kInvalidRtpPayloadType;
44 } 103 }
45 if (!CodecSupported(codec_type)) { 104 if (!CodecSupported(codec_type)) {
46 return kCodecNotSupported; 105 return kCodecNotSupported;
47 } 106 }
48 int fs_hz = CodecSampleRateHz(codec_type); 107 const int fs_hz = CodecSampleRateHz(codec_type);
49 std::pair<DecoderMap::iterator, bool> ret; 108 const std::string name = CodecName(codec_type);
50 DecoderInfo info(codec_type, fs_hz, NULL, false); 109 DecoderInfo info(codec_type, name, fs_hz, NULL, false);
51 ret = decoders_.insert(std::make_pair(rtp_payload_type, info)); 110 auto ret = decoders_.insert(std::make_pair(rtp_payload_type, info));
52 if (ret.second == false) { 111 if (ret.second == false) {
53 // Database already contains a decoder with type |rtp_payload_type|. 112 // Database already contains a decoder with type |rtp_payload_type|.
54 return kDecoderExists; 113 return kDecoderExists;
55 } 114 }
56 return kOK; 115 return kOK;
57 } 116 }
58 117
59 int DecoderDatabase::InsertExternal(uint8_t rtp_payload_type, 118 int DecoderDatabase::InsertExternal(uint8_t rtp_payload_type,
60 NetEqDecoder codec_type, 119 NetEqDecoder codec_type,
120 const std::string& codec_name,
61 int fs_hz, 121 int fs_hz,
62 AudioDecoder* decoder) { 122 AudioDecoder* decoder) {
63 if (rtp_payload_type > 0x7F) { 123 if (rtp_payload_type > 0x7F) {
64 return kInvalidRtpPayloadType; 124 return kInvalidRtpPayloadType;
65 } 125 }
66 if (!CodecSupported(codec_type)) { 126 if (!CodecSupported(codec_type)) {
67 return kCodecNotSupported; 127 return kCodecNotSupported;
68 } 128 }
69 if (fs_hz != 8000 && fs_hz != 16000 && fs_hz != 32000 && fs_hz != 48000) { 129 if (fs_hz != 8000 && fs_hz != 16000 && fs_hz != 32000 && fs_hz != 48000) {
70 return kInvalidSampleRate; 130 return kInvalidSampleRate;
71 } 131 }
72 if (!decoder) { 132 if (!decoder) {
73 return kInvalidPointer; 133 return kInvalidPointer;
74 } 134 }
75 std::pair<DecoderMap::iterator, bool> ret; 135 std::pair<DecoderMap::iterator, bool> ret;
76 DecoderInfo info(codec_type, fs_hz, decoder, true); 136 DecoderInfo info(codec_type, codec_name, fs_hz, decoder, true);
77 ret = decoders_.insert(std::make_pair(rtp_payload_type, info)); 137 ret = decoders_.insert(std::make_pair(rtp_payload_type, info));
78 if (ret.second == false) { 138 if (ret.second == false) {
79 // Database already contains a decoder with type |rtp_payload_type|. 139 // Database already contains a decoder with type |rtp_payload_type|.
80 return kDecoderExists; 140 return kDecoderExists;
81 } 141 }
82 return kOK; 142 return kOK;
83 } 143 }
84 144
85 int DecoderDatabase::Remove(uint8_t rtp_payload_type) { 145 int DecoderDatabase::Remove(uint8_t rtp_payload_type) {
86 if (decoders_.erase(rtp_payload_type) == 0) { 146 if (decoders_.erase(rtp_payload_type) == 0) {
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 LOG(LS_WARNING) << "CheckPayloadTypes: unknown RTP payload type " 311 LOG(LS_WARNING) << "CheckPayloadTypes: unknown RTP payload type "
252 << static_cast<int>((*it)->header.payloadType); 312 << static_cast<int>((*it)->header.payloadType);
253 return kDecoderNotFound; 313 return kDecoderNotFound;
254 } 314 }
255 } 315 }
256 return kOK; 316 return kOK;
257 } 317 }
258 318
259 319
260 } // namespace webrtc 320 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698