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

Side by Side Diff: webrtc/modules/audio_coding/neteq/tools/neteq_rtpplay.cc

Issue 1424083002: Make an enum class out of NetEqDecoder, and hide the neteq_decoders_ table (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase Created 5 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
« no previous file with comments | « webrtc/modules/audio_coding/neteq/tools/neteq_quality_test.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 DEFINE_string(ssrc, 140 DEFINE_string(ssrc,
141 "", 141 "",
142 "Only use packets with this SSRC (decimal or hex, the latter " 142 "Only use packets with this SSRC (decimal or hex, the latter "
143 "starting with 0x)"); 143 "starting with 0x)");
144 const bool hex_ssrc_dummy = 144 const bool hex_ssrc_dummy =
145 google::RegisterFlagValidator(&FLAGS_ssrc, &ValidateSsrcValue); 145 google::RegisterFlagValidator(&FLAGS_ssrc, &ValidateSsrcValue);
146 146
147 // Maps a codec type to a printable name string. 147 // Maps a codec type to a printable name string.
148 std::string CodecName(webrtc::NetEqDecoder codec) { 148 std::string CodecName(webrtc::NetEqDecoder codec) {
149 switch (codec) { 149 switch (codec) {
150 case webrtc::kDecoderPCMu: 150 case webrtc::NetEqDecoder::kDecoderPCMu:
151 return "PCM-u"; 151 return "PCM-u";
152 case webrtc::kDecoderPCMa: 152 case webrtc::NetEqDecoder::kDecoderPCMa:
153 return "PCM-a"; 153 return "PCM-a";
154 case webrtc::kDecoderILBC: 154 case webrtc::NetEqDecoder::kDecoderILBC:
155 return "iLBC"; 155 return "iLBC";
156 case webrtc::kDecoderISAC: 156 case webrtc::NetEqDecoder::kDecoderISAC:
157 return "iSAC"; 157 return "iSAC";
158 case webrtc::kDecoderISACswb: 158 case webrtc::NetEqDecoder::kDecoderISACswb:
159 return "iSAC-swb (32 kHz)"; 159 return "iSAC-swb (32 kHz)";
160 case webrtc::kDecoderOpus: 160 case webrtc::NetEqDecoder::kDecoderOpus:
161 return "Opus"; 161 return "Opus";
162 case webrtc::kDecoderPCM16B: 162 case webrtc::NetEqDecoder::kDecoderPCM16B:
163 return "PCM16b-nb (8 kHz)"; 163 return "PCM16b-nb (8 kHz)";
164 case webrtc::kDecoderPCM16Bwb: 164 case webrtc::NetEqDecoder::kDecoderPCM16Bwb:
165 return "PCM16b-wb (16 kHz)"; 165 return "PCM16b-wb (16 kHz)";
166 case webrtc::kDecoderPCM16Bswb32kHz: 166 case webrtc::NetEqDecoder::kDecoderPCM16Bswb32kHz:
167 return "PCM16b-swb32 (32 kHz)"; 167 return "PCM16b-swb32 (32 kHz)";
168 case webrtc::kDecoderPCM16Bswb48kHz: 168 case webrtc::NetEqDecoder::kDecoderPCM16Bswb48kHz:
169 return "PCM16b-swb48 (48 kHz)"; 169 return "PCM16b-swb48 (48 kHz)";
170 case webrtc::kDecoderG722: 170 case webrtc::NetEqDecoder::kDecoderG722:
171 return "G.722"; 171 return "G.722";
172 case webrtc::kDecoderRED: 172 case webrtc::NetEqDecoder::kDecoderRED:
173 return "redundant audio (RED)"; 173 return "redundant audio (RED)";
174 case webrtc::kDecoderAVT: 174 case webrtc::NetEqDecoder::kDecoderAVT:
175 return "AVT/DTMF"; 175 return "AVT/DTMF";
176 case webrtc::kDecoderCNGnb: 176 case webrtc::NetEqDecoder::kDecoderCNGnb:
177 return "comfort noise (8 kHz)"; 177 return "comfort noise (8 kHz)";
178 case webrtc::kDecoderCNGwb: 178 case webrtc::NetEqDecoder::kDecoderCNGwb:
179 return "comfort noise (16 kHz)"; 179 return "comfort noise (16 kHz)";
180 case webrtc::kDecoderCNGswb32kHz: 180 case webrtc::NetEqDecoder::kDecoderCNGswb32kHz:
181 return "comfort noise (32 kHz)"; 181 return "comfort noise (32 kHz)";
182 case webrtc::kDecoderCNGswb48kHz: 182 case webrtc::NetEqDecoder::kDecoderCNGswb48kHz:
183 return "comfort noise (48 kHz)"; 183 return "comfort noise (48 kHz)";
184 default: 184 default:
185 assert(false); 185 assert(false);
186 return "undefined"; 186 return "undefined";
187 } 187 }
188 } 188 }
189 189
190 void RegisterPayloadType(NetEq* neteq, 190 void RegisterPayloadType(NetEq* neteq,
191 webrtc::NetEqDecoder codec, 191 webrtc::NetEqDecoder codec,
192 google::int32 flag) { 192 google::int32 flag) {
193 if (neteq->RegisterPayloadType(codec, static_cast<uint8_t>(flag))) { 193 if (neteq->RegisterPayloadType(codec, static_cast<uint8_t>(flag))) {
194 std::cerr << "Cannot register payload type " << flag << " as " 194 std::cerr << "Cannot register payload type " << flag << " as "
195 << CodecName(codec) << std::endl; 195 << CodecName(codec) << std::endl;
196 exit(1); 196 exit(1);
197 } 197 }
198 } 198 }
199 199
200 // Registers all decoders in |neteq|. 200 // Registers all decoders in |neteq|.
201 void RegisterPayloadTypes(NetEq* neteq) { 201 void RegisterPayloadTypes(NetEq* neteq) {
202 assert(neteq); 202 assert(neteq);
203 RegisterPayloadType(neteq, webrtc::kDecoderPCMu, FLAGS_pcmu); 203 RegisterPayloadType(neteq, webrtc::NetEqDecoder::kDecoderPCMu, FLAGS_pcmu);
204 RegisterPayloadType(neteq, webrtc::kDecoderPCMa, FLAGS_pcma); 204 RegisterPayloadType(neteq, webrtc::NetEqDecoder::kDecoderPCMa, FLAGS_pcma);
205 RegisterPayloadType(neteq, webrtc::kDecoderILBC, FLAGS_ilbc); 205 RegisterPayloadType(neteq, webrtc::NetEqDecoder::kDecoderILBC, FLAGS_ilbc);
206 RegisterPayloadType(neteq, webrtc::kDecoderISAC, FLAGS_isac); 206 RegisterPayloadType(neteq, webrtc::NetEqDecoder::kDecoderISAC, FLAGS_isac);
207 RegisterPayloadType(neteq, webrtc::kDecoderISACswb, FLAGS_isac_swb); 207 RegisterPayloadType(neteq, webrtc::NetEqDecoder::kDecoderISACswb,
208 RegisterPayloadType(neteq, webrtc::kDecoderOpus, FLAGS_opus); 208 FLAGS_isac_swb);
209 RegisterPayloadType(neteq, webrtc::kDecoderPCM16B, FLAGS_pcm16b); 209 RegisterPayloadType(neteq, webrtc::NetEqDecoder::kDecoderOpus, FLAGS_opus);
210 RegisterPayloadType(neteq, webrtc::kDecoderPCM16Bwb, FLAGS_pcm16b_wb); 210 RegisterPayloadType(neteq, webrtc::NetEqDecoder::kDecoderPCM16B,
211 RegisterPayloadType(neteq, webrtc::kDecoderPCM16Bswb32kHz, 211 FLAGS_pcm16b);
212 RegisterPayloadType(neteq, webrtc::NetEqDecoder::kDecoderPCM16Bwb,
213 FLAGS_pcm16b_wb);
214 RegisterPayloadType(neteq, webrtc::NetEqDecoder::kDecoderPCM16Bswb32kHz,
212 FLAGS_pcm16b_swb32); 215 FLAGS_pcm16b_swb32);
213 RegisterPayloadType(neteq, webrtc::kDecoderPCM16Bswb48kHz, 216 RegisterPayloadType(neteq, webrtc::NetEqDecoder::kDecoderPCM16Bswb48kHz,
214 FLAGS_pcm16b_swb48); 217 FLAGS_pcm16b_swb48);
215 RegisterPayloadType(neteq, webrtc::kDecoderG722, FLAGS_g722); 218 RegisterPayloadType(neteq, webrtc::NetEqDecoder::kDecoderG722, FLAGS_g722);
216 RegisterPayloadType(neteq, webrtc::kDecoderAVT, FLAGS_avt); 219 RegisterPayloadType(neteq, webrtc::NetEqDecoder::kDecoderAVT, FLAGS_avt);
217 RegisterPayloadType(neteq, webrtc::kDecoderRED, FLAGS_red); 220 RegisterPayloadType(neteq, webrtc::NetEqDecoder::kDecoderRED, FLAGS_red);
218 RegisterPayloadType(neteq, webrtc::kDecoderCNGnb, FLAGS_cn_nb); 221 RegisterPayloadType(neteq, webrtc::NetEqDecoder::kDecoderCNGnb, FLAGS_cn_nb);
219 RegisterPayloadType(neteq, webrtc::kDecoderCNGwb, FLAGS_cn_wb); 222 RegisterPayloadType(neteq, webrtc::NetEqDecoder::kDecoderCNGwb, FLAGS_cn_wb);
220 RegisterPayloadType(neteq, webrtc::kDecoderCNGswb32kHz, FLAGS_cn_swb32); 223 RegisterPayloadType(neteq, webrtc::NetEqDecoder::kDecoderCNGswb32kHz,
221 RegisterPayloadType(neteq, webrtc::kDecoderCNGswb48kHz, FLAGS_cn_swb48); 224 FLAGS_cn_swb32);
225 RegisterPayloadType(neteq, webrtc::NetEqDecoder::kDecoderCNGswb48kHz,
226 FLAGS_cn_swb48);
222 } 227 }
223 228
224 void PrintCodecMappingEntry(webrtc::NetEqDecoder codec, google::int32 flag) { 229 void PrintCodecMappingEntry(webrtc::NetEqDecoder codec, google::int32 flag) {
225 std::cout << CodecName(codec) << ": " << flag << std::endl; 230 std::cout << CodecName(codec) << ": " << flag << std::endl;
226 } 231 }
227 232
228 void PrintCodecMapping() { 233 void PrintCodecMapping() {
229 PrintCodecMappingEntry(webrtc::kDecoderPCMu, FLAGS_pcmu); 234 PrintCodecMappingEntry(webrtc::NetEqDecoder::kDecoderPCMu, FLAGS_pcmu);
230 PrintCodecMappingEntry(webrtc::kDecoderPCMa, FLAGS_pcma); 235 PrintCodecMappingEntry(webrtc::NetEqDecoder::kDecoderPCMa, FLAGS_pcma);
231 PrintCodecMappingEntry(webrtc::kDecoderILBC, FLAGS_ilbc); 236 PrintCodecMappingEntry(webrtc::NetEqDecoder::kDecoderILBC, FLAGS_ilbc);
232 PrintCodecMappingEntry(webrtc::kDecoderISAC, FLAGS_isac); 237 PrintCodecMappingEntry(webrtc::NetEqDecoder::kDecoderISAC, FLAGS_isac);
233 PrintCodecMappingEntry(webrtc::kDecoderISACswb, FLAGS_isac_swb); 238 PrintCodecMappingEntry(webrtc::NetEqDecoder::kDecoderISACswb, FLAGS_isac_swb);
234 PrintCodecMappingEntry(webrtc::kDecoderOpus, FLAGS_opus); 239 PrintCodecMappingEntry(webrtc::NetEqDecoder::kDecoderOpus, FLAGS_opus);
235 PrintCodecMappingEntry(webrtc::kDecoderPCM16B, FLAGS_pcm16b); 240 PrintCodecMappingEntry(webrtc::NetEqDecoder::kDecoderPCM16B, FLAGS_pcm16b);
236 PrintCodecMappingEntry(webrtc::kDecoderPCM16Bwb, FLAGS_pcm16b_wb); 241 PrintCodecMappingEntry(webrtc::NetEqDecoder::kDecoderPCM16Bwb,
237 PrintCodecMappingEntry(webrtc::kDecoderPCM16Bswb32kHz, FLAGS_pcm16b_swb32); 242 FLAGS_pcm16b_wb);
238 PrintCodecMappingEntry(webrtc::kDecoderPCM16Bswb48kHz, FLAGS_pcm16b_swb48); 243 PrintCodecMappingEntry(webrtc::NetEqDecoder::kDecoderPCM16Bswb32kHz,
239 PrintCodecMappingEntry(webrtc::kDecoderG722, FLAGS_g722); 244 FLAGS_pcm16b_swb32);
240 PrintCodecMappingEntry(webrtc::kDecoderAVT, FLAGS_avt); 245 PrintCodecMappingEntry(webrtc::NetEqDecoder::kDecoderPCM16Bswb48kHz,
241 PrintCodecMappingEntry(webrtc::kDecoderRED, FLAGS_red); 246 FLAGS_pcm16b_swb48);
242 PrintCodecMappingEntry(webrtc::kDecoderCNGnb, FLAGS_cn_nb); 247 PrintCodecMappingEntry(webrtc::NetEqDecoder::kDecoderG722, FLAGS_g722);
243 PrintCodecMappingEntry(webrtc::kDecoderCNGwb, FLAGS_cn_wb); 248 PrintCodecMappingEntry(webrtc::NetEqDecoder::kDecoderAVT, FLAGS_avt);
244 PrintCodecMappingEntry(webrtc::kDecoderCNGswb32kHz, FLAGS_cn_swb32); 249 PrintCodecMappingEntry(webrtc::NetEqDecoder::kDecoderRED, FLAGS_red);
245 PrintCodecMappingEntry(webrtc::kDecoderCNGswb48kHz, FLAGS_cn_swb48); 250 PrintCodecMappingEntry(webrtc::NetEqDecoder::kDecoderCNGnb, FLAGS_cn_nb);
251 PrintCodecMappingEntry(webrtc::NetEqDecoder::kDecoderCNGwb, FLAGS_cn_wb);
252 PrintCodecMappingEntry(webrtc::NetEqDecoder::kDecoderCNGswb32kHz,
253 FLAGS_cn_swb32);
254 PrintCodecMappingEntry(webrtc::NetEqDecoder::kDecoderCNGswb48kHz,
255 FLAGS_cn_swb48);
246 } 256 }
247 257
248 bool IsComfortNoise(uint8_t payload_type) { 258 bool IsComfortNoise(uint8_t payload_type) {
249 return payload_type == FLAGS_cn_nb || payload_type == FLAGS_cn_wb || 259 return payload_type == FLAGS_cn_nb || payload_type == FLAGS_cn_wb ||
250 payload_type == FLAGS_cn_swb32 || payload_type == FLAGS_cn_swb48; 260 payload_type == FLAGS_cn_swb32 || payload_type == FLAGS_cn_swb48;
251 } 261 }
252 262
253 int CodecSampleRate(uint8_t payload_type) { 263 int CodecSampleRate(uint8_t payload_type) {
254 if (payload_type == FLAGS_pcmu || payload_type == FLAGS_pcma || 264 if (payload_type == FLAGS_pcmu || payload_type == FLAGS_pcma ||
255 payload_type == FLAGS_ilbc || payload_type == FLAGS_pcm16b || 265 payload_type == FLAGS_ilbc || payload_type == FLAGS_pcm16b ||
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 } 642 }
633 } 643 }
634 printf("Simulation done\n"); 644 printf("Simulation done\n");
635 printf("Produced %i ms of audio\n", 645 printf("Produced %i ms of audio\n",
636 static_cast<int>(time_now_ms - start_time_ms)); 646 static_cast<int>(time_now_ms - start_time_ms));
637 647
638 delete neteq; 648 delete neteq;
639 webrtc::Trace::ReturnTrace(); 649 webrtc::Trace::ReturnTrace();
640 return 0; 650 return 0;
641 } 651 }
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/neteq/tools/neteq_quality_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698