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

Unified Diff: webrtc/media/engine/webrtcvoiceengine.cc

Issue 1845673002: Removing `preference` field from `cricket::Codec`. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Adding back a unit test. Created 4 years, 8 months 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/media/engine/webrtcvoiceengine.cc
diff --git a/webrtc/media/engine/webrtcvoiceengine.cc b/webrtc/media/engine/webrtcvoiceengine.cc
index 6fe3d86fd98f086fe0622711c7769573d5276a1b..bd346f7c1db4985245237b89d1017e413436c1d0 100644
--- a/webrtc/media/engine/webrtcvoiceengine.cc
+++ b/webrtc/media/engine/webrtcvoiceengine.cc
@@ -251,32 +251,28 @@ class WebRtcVoiceCodecs final {
static std::vector<AudioCodec> SupportedCodecs() {
LOG(LS_INFO) << "WebRtc VoiceEngine codecs:";
std::vector<AudioCodec> result;
- for (webrtc::CodecInst voe_codec : webrtc::acm2::RentACodec::Database()) {
- // Change the sample rate of G722 to 8000 to match SDP.
- MaybeFixupG722(&voe_codec, 8000);
- // Skip uncompressed formats.
- if (IsCodec(voe_codec, kL16CodecName)) {
- continue;
- }
+ // Iterate first over our preferred codecs list, so that the results are
+ // added in order of preference.
+ for (size_t i = 0; i < arraysize(kCodecPrefs); ++i) {
+ const CodecPref* pref = &kCodecPrefs[i];
+ for (webrtc::CodecInst voe_codec : webrtc::acm2::RentACodec::Database()) {
+ // Change the sample rate of G722 to 8000 to match SDP.
+ MaybeFixupG722(&voe_codec, 8000);
+ // Skip uncompressed formats.
+ if (IsCodec(voe_codec, kL16CodecName)) {
+ continue;
+ }
- const CodecPref* pref = NULL;
- for (size_t j = 0; j < arraysize(kCodecPrefs); ++j) {
- if (IsCodec(voe_codec, kCodecPrefs[j].name) &&
- kCodecPrefs[j].clockrate == voe_codec.plfreq &&
- kCodecPrefs[j].channels == voe_codec.channels) {
- pref = &kCodecPrefs[j];
- break;
+ if (!IsCodec(voe_codec, pref->name) ||
+ pref->clockrate != voe_codec.plfreq ||
+ pref->channels != voe_codec.channels) {
+ // Not a match.
+ continue;
}
- }
- if (pref) {
- // Use the payload type that we've configured in our pref table;
- // use the offset in our pref table to determine the sort order.
- AudioCodec codec(
- pref->payload_type, voe_codec.plname, voe_codec.plfreq,
- voe_codec.rate, voe_codec.channels,
- static_cast<int>(arraysize(kCodecPrefs)) - (pref - kCodecPrefs));
- LOG(LS_INFO) << ToString(codec);
+ AudioCodec codec(pref->payload_type, voe_codec.plname, voe_codec.plfreq,
+ voe_codec.rate, voe_codec.channels);
+ LOG(LS_INFO) << "Adding supported codec: " << ToString(codec);
if (IsCodec(codec, kIsacCodecName)) {
// Indicate auto-bitrate in signaling.
codec.bitrate = 0;
@@ -299,12 +295,8 @@ class WebRtcVoiceCodecs final {
// when they can be set to values other than the default.
}
result.push_back(codec);
- } else {
- LOG(LS_WARNING) << "Unexpected codec: " << ToString(voe_codec);
}
}
- // Make sure they are in local preference order.
- std::sort(result.begin(), result.end(), &AudioCodec::Preferable);
return result;
}
@@ -314,7 +306,7 @@ class WebRtcVoiceCodecs final {
// Change the sample rate of G722 to 8000 to match SDP.
MaybeFixupG722(&voe_codec, 8000);
AudioCodec codec(voe_codec.pltype, voe_codec.plname, voe_codec.plfreq,
- voe_codec.rate, voe_codec.channels, 0);
+ voe_codec.rate, voe_codec.channels);
bool multi_rate = IsCodecMultiRate(voe_codec);
// Allow arbitrary rates for ISAC to be specified.
if (multi_rate) {

Powered by Google App Engine
This is Rietveld 408576698