Bug 1433005 - Simplify codec pruning in NegotiateCodecs; r=bwc

--HG--
extra : rebase_source : dd40820b009cb8dc3cff74bbaee9a1d3dbe2a0dc
This commit is contained in:
Dan Minor 2018-01-26 11:46:51 -05:00
Родитель bb6ba73484
Коммит 26329414af
1 изменённых файлов: 16 добавлений и 12 удалений

Просмотреть файл

@ -486,21 +486,25 @@ JsepTrack::NegotiateCodecs(
// TODO(bug 814227): Remove this once we're ready to put multiple codecs in an
// answer. For now, remove all but the first codec unless the red codec
// exists, and then we include the others per RFC 5109, section 14.2.
// Note: now allows keeping the telephone-event codec, if it appears, as the
// last codec in the list.
// exists, in which case we include the others per RFC 5109, section 14.2.
if (!codecs->empty() && !red) {
int newSize = dtmf ? 2 : 1;
for (size_t i = 1; i < codecs->size(); ++i) {
if (!dtmf || dtmf != (*codecs)[i]) {
delete (*codecs)[i];
(*codecs)[i] = nullptr;
std::vector<JsepCodecDescription*> codecsToKeep;
bool foundPreferredCodec = false;
for (auto codec: *codecs) {
if (codec == dtmf) {
codecsToKeep.push_back(codec);
} else if (codec == ulpfec) {
codecsToKeep.push_back(codec);
} else if (!foundPreferredCodec) {
codecsToKeep.insert(codecsToKeep.begin(), codec);
foundPreferredCodec = true;
} else {
delete codec;
}
}
if (dtmf) {
(*codecs)[newSize-1] = dtmf;
}
codecs->resize(newSize);
*codecs = codecsToKeep;
}
}