Bug 1165129: Allow JS to reorder codecs in a local answer. Also means that we'll take the ordering more seriously when we see multiple codecs in a remote answer. r=jesup

This commit is contained in:
Byron Campen [:bwc] 2015-05-14 16:05:36 -07:00
parent 8e3eedd8da
commit 73667e8f17
2 changed files with 24 additions and 11 deletions

View File

@ -903,11 +903,12 @@ CompareCodec(const JsepCodecDescription* lhs, const JsepCodecDescription* rhs)
}
PtrVector<JsepCodecDescription>
JsepSessionImpl::GetCommonCodecs(const SdpMediaSection& remoteMsection)
JsepSessionImpl::GetCommonCodecs(const SdpMediaSection& offerMsection)
{
MOZ_ASSERT(!mIsOfferer);
PtrVector<JsepCodecDescription> matchingCodecs;
for (const std::string& fmt : remoteMsection.GetFormats()) {
JsepCodecDescription* codec = FindMatchingCodec(fmt, remoteMsection);
for (const std::string& fmt : offerMsection.GetFormats()) {
JsepCodecDescription* codec = FindMatchingCodec(fmt, offerMsection);
if (codec) {
codec->mDefaultPt = fmt; // Remember the other side's PT
matchingCodecs.values.push_back(codec->Clone());
@ -1715,11 +1716,25 @@ JsepSessionImpl::NegotiateTrack(const SdpMediaSection& remoteMsection,
MakeUnique<JsepTrackNegotiatedDetailsImpl>();
negotiatedDetails->mProtocol = remoteMsection.GetProtocol();
// Insert all the codecs we jointly support.
PtrVector<JsepCodecDescription> commonCodecs(
GetCommonCodecs(remoteMsection));
auto& answerMsection = mIsOfferer ? remoteMsection : localMsection;
for (auto& format : answerMsection.GetFormats()) {
JsepCodecDescription* origCodec = FindMatchingCodec(format, answerMsection);
if (!origCodec) {
continue;
}
// Make sure codec->mDefaultPt is consistent with what is in the remote
// msection, since the following logic needs to look stuff up there.
for (auto& remoteFormat : remoteMsection.GetFormats()) {
if (origCodec->Matches(remoteFormat, remoteMsection)) {
origCodec->mDefaultPt = remoteFormat;
break;
}
}
UniquePtr<JsepCodecDescription> codec(origCodec->Clone());
for (JsepCodecDescription* codec : commonCodecs.values) {
bool sending = (direction == JsepTrack::kJsepTrackSending);
// Everywhere else in JsepSessionImpl, a JsepCodecDescription describes
@ -1751,7 +1766,7 @@ JsepSessionImpl::NegotiateTrack(const SdpMediaSection& remoteMsection,
}
}
negotiatedDetails->mCodecs.values.push_back(codec->Clone());
negotiatedDetails->mCodecs.values.push_back(codec.release());
break;
}
@ -1760,8 +1775,6 @@ JsepSessionImpl::NegotiateTrack(const SdpMediaSection& remoteMsection,
return NS_ERROR_INVALID_ARG;
}
auto& answerMsection = mIsOfferer ? remoteMsection : localMsection;
if (answerMsection.GetAttributeList().HasAttribute(
SdpAttribute::kExtmapAttribute)) {
auto& extmap = answerMsection.GetAttributeList().GetExtmap().mExtmaps;

View File

@ -187,7 +187,7 @@ private:
SdpMediaSection::MediaType type) const;
PtrVector<JsepCodecDescription> GetCommonCodecs(
const SdpMediaSection& remoteMsection);
const SdpMediaSection& offerMsection);
void AddCommonExtmaps(const SdpMediaSection& remoteMsection,
SdpMediaSection* msection);
nsresult SetupIds();