OLD | NEW |
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 Loading... |
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 Loading... |
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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 int ncodecs = voe_wrapper_->codec()->NumOfCodecs(); | 449 int ncodecs = voe_wrapper_->codec()->NumOfCodecs(); |
449 for (int i = 0; i < ncodecs; ++i) { | 450 for (int i = 0; i < ncodecs; ++i) { |
450 webrtc::CodecInst voe_codec; | 451 webrtc::CodecInst voe_codec; |
451 if (GetVoeCodec(i, &voe_codec)) { | 452 if (GetVoeCodec(i, &voe_codec)) { |
452 // Skip uncompressed formats. | 453 // Skip uncompressed formats. |
453 if (IsCodec(voe_codec, kL16CodecName)) { | 454 if (IsCodec(voe_codec, kL16CodecName)) { |
454 continue; | 455 continue; |
455 } | 456 } |
456 | 457 |
457 const CodecPref* pref = NULL; | 458 const CodecPref* pref = NULL; |
458 for (size_t j = 0; j < ARRAY_SIZE(kCodecPrefs); ++j) { | 459 for (size_t j = 0; j < arraysize(kCodecPrefs); ++j) { |
459 if (IsCodec(voe_codec, kCodecPrefs[j].name) && | 460 if (IsCodec(voe_codec, kCodecPrefs[j].name) && |
460 kCodecPrefs[j].clockrate == voe_codec.plfreq && | 461 kCodecPrefs[j].clockrate == voe_codec.plfreq && |
461 kCodecPrefs[j].channels == voe_codec.channels) { | 462 kCodecPrefs[j].channels == voe_codec.channels) { |
462 pref = &kCodecPrefs[j]; | 463 pref = &kCodecPrefs[j]; |
463 break; | 464 break; |
464 } | 465 } |
465 } | 466 } |
466 | 467 |
467 if (pref) { | 468 if (pref) { |
468 // Use the payload type that we've configured in our pref table; | 469 // Use the payload type that we've configured in our pref table; |
469 // use the offset in our pref table to determine the sort order. | 470 // use the offset in our pref table to determine the sort order. |
470 AudioCodec codec(pref->payload_type, voe_codec.plname, voe_codec.plfreq, | 471 AudioCodec codec( |
471 voe_codec.rate, voe_codec.channels, | 472 pref->payload_type, voe_codec.plname, voe_codec.plfreq, |
472 ARRAY_SIZE(kCodecPrefs) - (pref - kCodecPrefs)); | 473 voe_codec.rate, voe_codec.channels, |
| 474 static_cast<int>(arraysize(kCodecPrefs)) - (pref - kCodecPrefs)); |
473 LOG(LS_INFO) << ToString(codec); | 475 LOG(LS_INFO) << ToString(codec); |
474 if (IsCodec(codec, kIsacCodecName)) { | 476 if (IsCodec(codec, kIsacCodecName)) { |
475 // Indicate auto-bitrate in signaling. | 477 // Indicate auto-bitrate in signaling. |
476 codec.bitrate = 0; | 478 codec.bitrate = 0; |
477 } | 479 } |
478 if (IsCodec(codec, kOpusCodecName)) { | 480 if (IsCodec(codec, kOpusCodecName)) { |
479 // Only add fmtp parameters that differ from the spec. | 481 // Only add fmtp parameters that differ from the spec. |
480 if (kPreferredMinPTime != kOpusDefaultMinPTime) { | 482 if (kPreferredMinPTime != kOpusDefaultMinPTime) { |
481 codec.params[kCodecParamMinPTime] = | 483 codec.params[kCodecParamMinPTime] = |
482 rtc::ToString(kPreferredMinPTime); | 484 rtc::ToString(kPreferredMinPTime); |
(...skipping 2373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2856 LOG(LS_WARNING) << "Unknown codec " << ToString(codec); | 2858 LOG(LS_WARNING) << "Unknown codec " << ToString(codec); |
2857 return false; | 2859 return false; |
2858 } | 2860 } |
2859 } | 2861 } |
2860 return true; | 2862 return true; |
2861 } | 2863 } |
2862 | 2864 |
2863 } // namespace cricket | 2865 } // namespace cricket |
2864 | 2866 |
2865 #endif // HAVE_WEBRTC_VOICE | 2867 #endif // HAVE_WEBRTC_VOICE |
OLD | NEW |