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

Side by Side Diff: talk/media/webrtc/webrtcvoiceengine.cc

Issue 1405023016: Convert usage of ARRAY_SIZE to arraysize. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: remove always true assertion 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
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2004 Google Inc. 3 * Copyright 2004 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 25 matching lines...) Expand all
36 #include <algorithm> 36 #include <algorithm>
37 #include <cstdio> 37 #include <cstdio>
38 #include <string> 38 #include <string>
39 #include <vector> 39 #include <vector>
40 40
41 #include "talk/media/base/audioframe.h" 41 #include "talk/media/base/audioframe.h"
42 #include "talk/media/base/audiorenderer.h" 42 #include "talk/media/base/audiorenderer.h"
43 #include "talk/media/base/constants.h" 43 #include "talk/media/base/constants.h"
44 #include "talk/media/base/streamparams.h" 44 #include "talk/media/base/streamparams.h"
45 #include "talk/media/webrtc/webrtcvoe.h" 45 #include "talk/media/webrtc/webrtcvoe.h"
46 #include "webrtc/base/arraysize.h"
46 #include "webrtc/base/base64.h" 47 #include "webrtc/base/base64.h"
47 #include "webrtc/base/byteorder.h" 48 #include "webrtc/base/byteorder.h"
48 #include "webrtc/base/common.h" 49 #include "webrtc/base/common.h"
49 #include "webrtc/base/helpers.h" 50 #include "webrtc/base/helpers.h"
50 #include "webrtc/base/logging.h" 51 #include "webrtc/base/logging.h"
51 #include "webrtc/base/stringencode.h" 52 #include "webrtc/base/stringencode.h"
52 #include "webrtc/base/stringutils.h" 53 #include "webrtc/base/stringutils.h"
53 #include "webrtc/call/rtc_event_log.h" 54 #include "webrtc/call/rtc_event_log.h"
54 #include "webrtc/common.h" 55 #include "webrtc/common.h"
55 #include "webrtc/modules/audio_processing/include/audio_processing.h" 56 #include "webrtc/modules/audio_processing/include/audio_processing.h"
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 206
206 bool IsCodec(const AudioCodec& codec, const char* ref_name) { 207 bool IsCodec(const AudioCodec& codec, const char* ref_name) {
207 return (_stricmp(codec.name.c_str(), ref_name) == 0); 208 return (_stricmp(codec.name.c_str(), ref_name) == 0);
208 } 209 }
209 210
210 bool IsCodec(const webrtc::CodecInst& codec, const char* ref_name) { 211 bool IsCodec(const webrtc::CodecInst& codec, const char* ref_name) {
211 return (_stricmp(codec.plname, ref_name) == 0); 212 return (_stricmp(codec.plname, ref_name) == 0);
212 } 213 }
213 214
214 bool IsCodecMultiRate(const webrtc::CodecInst& codec) { 215 bool IsCodecMultiRate(const webrtc::CodecInst& codec) {
215 for (size_t i = 0; i < ARRAY_SIZE(kCodecPrefs); ++i) { 216 for (size_t i = 0; i < arraysize(kCodecPrefs); ++i) {
216 if (IsCodec(codec, kCodecPrefs[i].name) && 217 if (IsCodec(codec, kCodecPrefs[i].name) &&
217 kCodecPrefs[i].clockrate == codec.plfreq) { 218 kCodecPrefs[i].clockrate == codec.plfreq) {
218 return kCodecPrefs[i].is_multi_rate; 219 return kCodecPrefs[i].is_multi_rate;
219 } 220 }
220 } 221 }
221 return false; 222 return false;
222 } 223 }
223 224
224 bool FindCodec(const std::vector<AudioCodec>& codecs, 225 bool FindCodec(const std::vector<AudioCodec>& codecs,
225 const AudioCodec& codec, 226 const AudioCodec& codec,
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 int ncodecs = voe_wrapper_->codec()->NumOfCodecs(); 447 int ncodecs = voe_wrapper_->codec()->NumOfCodecs();
447 for (int i = 0; i < ncodecs; ++i) { 448 for (int i = 0; i < ncodecs; ++i) {
448 webrtc::CodecInst voe_codec; 449 webrtc::CodecInst voe_codec;
449 if (GetVoeCodec(i, &voe_codec)) { 450 if (GetVoeCodec(i, &voe_codec)) {
450 // Skip uncompressed formats. 451 // Skip uncompressed formats.
451 if (IsCodec(voe_codec, kL16CodecName)) { 452 if (IsCodec(voe_codec, kL16CodecName)) {
452 continue; 453 continue;
453 } 454 }
454 455
455 const CodecPref* pref = NULL; 456 const CodecPref* pref = NULL;
456 for (size_t j = 0; j < ARRAY_SIZE(kCodecPrefs); ++j) { 457 for (size_t j = 0; j < arraysize(kCodecPrefs); ++j) {
457 if (IsCodec(voe_codec, kCodecPrefs[j].name) && 458 if (IsCodec(voe_codec, kCodecPrefs[j].name) &&
458 kCodecPrefs[j].clockrate == voe_codec.plfreq && 459 kCodecPrefs[j].clockrate == voe_codec.plfreq &&
459 kCodecPrefs[j].channels == voe_codec.channels) { 460 kCodecPrefs[j].channels == voe_codec.channels) {
460 pref = &kCodecPrefs[j]; 461 pref = &kCodecPrefs[j];
461 break; 462 break;
462 } 463 }
463 } 464 }
464 465
465 if (pref) { 466 if (pref) {
466 // Use the payload type that we've configured in our pref table; 467 // Use the payload type that we've configured in our pref table;
467 // use the offset in our pref table to determine the sort order. 468 // use the offset in our pref table to determine the sort order.
468 AudioCodec codec(pref->payload_type, voe_codec.plname, voe_codec.plfreq, 469 AudioCodec codec(pref->payload_type, voe_codec.plname, voe_codec.plfreq,
469 voe_codec.rate, voe_codec.channels, 470 voe_codec.rate, voe_codec.channels,
470 ARRAY_SIZE(kCodecPrefs) - (pref - kCodecPrefs)); 471 (int)arraysize(kCodecPrefs) - (pref - kCodecPrefs));
tommi (sloooow) - chröme 2015/11/06 22:33:25 use static_cast
tfarina 2015/11/10 23:02:45 Done.
471 LOG(LS_INFO) << ToString(codec); 472 LOG(LS_INFO) << ToString(codec);
472 if (IsCodec(codec, kIsacCodecName)) { 473 if (IsCodec(codec, kIsacCodecName)) {
473 // Indicate auto-bitrate in signaling. 474 // Indicate auto-bitrate in signaling.
474 codec.bitrate = 0; 475 codec.bitrate = 0;
475 } 476 }
476 if (IsCodec(codec, kOpusCodecName)) { 477 if (IsCodec(codec, kOpusCodecName)) {
477 // Only add fmtp parameters that differ from the spec. 478 // Only add fmtp parameters that differ from the spec.
478 if (kPreferredMinPTime != kOpusDefaultMinPTime) { 479 if (kPreferredMinPTime != kOpusDefaultMinPTime) {
479 codec.params[kCodecParamMinPTime] = 480 codec.params[kCodecParamMinPTime] =
480 rtc::ToString(kPreferredMinPTime); 481 rtc::ToString(kPreferredMinPTime);
(...skipping 2406 matching lines...) Expand 10 before | Expand all | Expand 10 after
2887 LOG(LS_WARNING) << "Unknown codec " << ToString(codec); 2888 LOG(LS_WARNING) << "Unknown codec " << ToString(codec);
2888 return false; 2889 return false;
2889 } 2890 }
2890 } 2891 }
2891 return true; 2892 return true;
2892 } 2893 }
2893 2894
2894 } // namespace cricket 2895 } // namespace cricket
2895 2896
2896 #endif // HAVE_WEBRTC_VOICE 2897 #endif // HAVE_WEBRTC_VOICE
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698