Bug 1531803 - Part 3: Only set track id on JsepTrack if we're configured to emit track ids in SDP, and simplify some code. r=mjf

Differential Revision: https://phabricator.services.mozilla.com/D25796

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Byron Campen [:bwc] 2019-04-29 15:51:30 +00:00
parent ef7c16372d
commit 46627d3af8
4 changed files with 19 additions and 22 deletions

View File

@ -127,8 +127,8 @@ class JsepTrackTest : public ::testing::Test {
SdpMediaSection& GetAnswer() { return mAnswer->GetMediaSection(0); } SdpMediaSection& GetAnswer() { return mAnswer->GetMediaSection(0); }
void CreateOffer() { void CreateOffer() {
mSendOff.AddToOffer(mSsrcGenerator, true, &GetOffer()); mSendOff.AddToOffer(mSsrcGenerator, &GetOffer());
mRecvOff.AddToOffer(mSsrcGenerator, true, &GetOffer()); mRecvOff.AddToOffer(mSsrcGenerator, &GetOffer());
} }
void CreateAnswer() { void CreateAnswer() {
@ -136,8 +136,8 @@ class JsepTrackTest : public ::testing::Test {
mRecvAns.UpdateRecvTrack(*mOffer, GetOffer()); mRecvAns.UpdateRecvTrack(*mOffer, GetOffer());
} }
mSendAns.AddToAnswer(GetOffer(), mSsrcGenerator, true, &GetAnswer()); mSendAns.AddToAnswer(GetOffer(), mSsrcGenerator, &GetAnswer());
mRecvAns.AddToAnswer(GetOffer(), mSsrcGenerator, true, &GetAnswer()); mRecvAns.AddToAnswer(GetOffer(), mSsrcGenerator, &GetAnswer());
} }
void Negotiate() { void Negotiate() {

View File

@ -107,7 +107,7 @@ nsresult JsepSessionImpl::AddTransceiver(RefPtr<JsepTransceiver> transceiver) {
// Make sure we have identifiers for send track, just in case. // Make sure we have identifiers for send track, just in case.
// (man I hate this) // (man I hate this)
if (transceiver->mSendTrack.GetTrackId().empty()) { if (mEncodeTrackId) {
std::string trackId; std::string trackId;
if (!mUuidGen->Generate(&trackId)) { if (!mUuidGen->Generate(&trackId)) {
JSEP_SET_ERROR("Failed to generate UUID for JsepTrack"); JSEP_SET_ERROR("Failed to generate UUID for JsepTrack");
@ -257,8 +257,8 @@ nsresult JsepSessionImpl::CreateOfferMsection(const JsepOfferOptions& options,
nsresult rv = AddTransportAttributes(msection, SdpSetupAttribute::kActpass); nsresult rv = AddTransportAttributes(msection, SdpSetupAttribute::kActpass);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
transceiver.mSendTrack.AddToOffer(mSsrcGenerator, mEncodeTrackId, msection); transceiver.mSendTrack.AddToOffer(mSsrcGenerator, msection);
transceiver.mRecvTrack.AddToOffer(mSsrcGenerator, mEncodeTrackId, msection); transceiver.mRecvTrack.AddToOffer(mSsrcGenerator, msection);
AddExtmap(msection); AddExtmap(msection);
@ -538,10 +538,8 @@ nsresult JsepSessionImpl::CreateAnswerMsection(
rv = AddTransportAttributes(&msection, role); rv = AddTransportAttributes(&msection, role);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
transceiver.mSendTrack.AddToAnswer(remoteMsection, mSsrcGenerator, transceiver.mSendTrack.AddToAnswer(remoteMsection, mSsrcGenerator, &msection);
mEncodeTrackId, &msection); transceiver.mRecvTrack.AddToAnswer(remoteMsection, mSsrcGenerator, &msection);
transceiver.mRecvTrack.AddToAnswer(remoteMsection, mSsrcGenerator,
mEncodeTrackId, &msection);
// Add extmap attributes. This logic will probably be moved to the track, // Add extmap attributes. This logic will probably be moved to the track,
// since it can be specified on a per-sender basis in JS. // since it can be specified on a per-sender basis in JS.

View File

@ -106,9 +106,9 @@ void JsepTrack::PopulateCodecs(
EnsureNoDuplicatePayloadTypes(&mPrototypeCodecs); EnsureNoDuplicatePayloadTypes(&mPrototypeCodecs);
} }
void JsepTrack::AddToOffer(SsrcGenerator& ssrcGenerator, bool encodeTrackId, void JsepTrack::AddToOffer(SsrcGenerator& ssrcGenerator,
SdpMediaSection* offer) { SdpMediaSection* offer) {
AddToMsection(mPrototypeCodecs, encodeTrackId, offer); AddToMsection(mPrototypeCodecs, offer);
if (mDirection == sdp::kSend) { if (mDirection == sdp::kSend) {
std::vector<JsConstraints> constraints; std::vector<JsConstraints> constraints;
@ -120,7 +120,7 @@ void JsepTrack::AddToOffer(SsrcGenerator& ssrcGenerator, bool encodeTrackId,
} }
void JsepTrack::AddToAnswer(const SdpMediaSection& offer, void JsepTrack::AddToAnswer(const SdpMediaSection& offer,
SsrcGenerator& ssrcGenerator, bool encodeTrackId, SsrcGenerator& ssrcGenerator,
SdpMediaSection* answer) { SdpMediaSection* answer) {
// We do not modify mPrototypeCodecs here, since we're only creating an // We do not modify mPrototypeCodecs here, since we're only creating an
// answer. Once offer/answer concludes, we will update mPrototypeCodecs. // answer. Once offer/answer concludes, we will update mPrototypeCodecs.
@ -130,7 +130,7 @@ void JsepTrack::AddToAnswer(const SdpMediaSection& offer,
return; return;
} }
AddToMsection(codecs, encodeTrackId, answer); AddToMsection(codecs, answer);
if (mDirection == sdp::kSend) { if (mDirection == sdp::kSend) {
std::vector<JsConstraints> constraints; std::vector<JsConstraints> constraints;
@ -169,7 +169,7 @@ bool JsepTrack::SetJsConstraints(
void JsepTrack::AddToMsection( void JsepTrack::AddToMsection(
const std::vector<UniquePtr<JsepCodecDescription>>& codecs, const std::vector<UniquePtr<JsepCodecDescription>>& codecs,
bool encodeTrackId, SdpMediaSection* msection) { SdpMediaSection* msection) {
MOZ_ASSERT(msection->GetMediaType() == mType); MOZ_ASSERT(msection->GetMediaType() == mType);
MOZ_ASSERT(!codecs.empty()); MOZ_ASSERT(!codecs.empty());
@ -180,10 +180,10 @@ void JsepTrack::AddToMsection(
if ((mDirection == sdp::kSend) && (mType != SdpMediaSection::kApplication) && if ((mDirection == sdp::kSend) && (mType != SdpMediaSection::kApplication) &&
msection->IsSending()) { msection->IsSending()) {
if (mStreamIds.empty()) { if (mStreamIds.empty()) {
msection->AddMsid("-", encodeTrackId ? mTrackId : ""); msection->AddMsid("-", mTrackId);
} else { } else {
for (const std::string& streamId : mStreamIds) { for (const std::string& streamId : mStreamIds) {
msection->AddMsid(streamId, encodeTrackId ? mTrackId : ""); msection->AddMsid(streamId, mTrackId);
} }
} }
} }

View File

@ -186,10 +186,9 @@ class JsepTrack {
} }
// These two are non-const because this is where ssrcs are chosen. // These two are non-const because this is where ssrcs are chosen.
virtual void AddToOffer(SsrcGenerator& ssrcGenerator, bool encodeTrackId, virtual void AddToOffer(SsrcGenerator& ssrcGenerator, SdpMediaSection* offer);
SdpMediaSection* offer);
virtual void AddToAnswer(const SdpMediaSection& offer, virtual void AddToAnswer(const SdpMediaSection& offer,
SsrcGenerator& ssrcGenerator, bool encodeTrackId, SsrcGenerator& ssrcGenerator,
SdpMediaSection* answer); SdpMediaSection* answer);
virtual void Negotiate(const SdpMediaSection& answer, virtual void Negotiate(const SdpMediaSection& answer,
@ -243,7 +242,7 @@ class JsepTrack {
const std::vector<UniquePtr<JsepCodecDescription>>& codecs, const std::vector<UniquePtr<JsepCodecDescription>>& codecs,
std::vector<uint16_t>* pts); std::vector<uint16_t>* pts);
void AddToMsection(const std::vector<UniquePtr<JsepCodecDescription>>& codecs, void AddToMsection(const std::vector<UniquePtr<JsepCodecDescription>>& codecs,
bool encodeTrackId, SdpMediaSection* msection); SdpMediaSection* msection);
void GetRids(const SdpMediaSection& msection, sdp::Direction direction, void GetRids(const SdpMediaSection& msection, sdp::Direction direction,
std::vector<SdpRidAttributeList::Rid>* rids) const; std::vector<SdpRidAttributeList::Rid>* rids) const;
void CreateEncodings( void CreateEncodings(