--- a/media/webrtc/signaling/gtest/jsep_session_unittest.cpp
+++ b/media/webrtc/signaling/gtest/jsep_session_unittest.cpp
@@ -446,17 +446,17 @@ protected:
if ((*i)->GetMediaType() == type) {
++result;
}
}
return result;
}
UniquePtr<Sdp> GetParsedLocalDescription(const JsepSessionImpl& side) const {
- return Parse(side.GetLocalDescription());
+ return Parse(side.GetLocalDescription(kJsepDescriptionCurrent));
}
SdpMediaSection* GetMsection(Sdp& sdp,
SdpMediaSection::MediaType type,
size_t index) const {
for (size_t i = 0; i < sdp.GetMediaSectionCount(); ++i) {
auto& msection = sdp.GetMediaSection(i);
if (msection.GetMediaType() != type) {
@@ -2487,17 +2487,18 @@ TEST_P(JsepSessionTest, ParseRejectsBadM
TEST_P(JsepSessionTest, FullCallWithCandidates)
{
AddTracks(*mSessionOff);
std::string offer = CreateOffer();
SetLocalOffer(offer);
mOffCandidates->Gather(*mSessionOff, types);
- UniquePtr<Sdp> localOffer(Parse(mSessionOff->GetLocalDescription()));
+ UniquePtr<Sdp> localOffer(Parse(
+ mSessionOff->GetLocalDescription(kJsepDescriptionCurrent)));
for (size_t i = 0; i < localOffer->GetMediaSectionCount(); ++i) {
mOffCandidates->CheckRtpCandidates(
true, localOffer->GetMediaSection(i), i,
"Local offer after gathering should have RTP candidates.");
mOffCandidates->CheckDefaultRtpCandidate(
true, localOffer->GetMediaSection(i), i,
"Local offer after gathering should have a default RTP candidate.");
mOffCandidates->CheckRtcpCandidates(
@@ -2512,17 +2513,18 @@ TEST_P(JsepSessionTest, FullCallWithCand
"(unless m=application)");
CheckEndOfCandidates(true, localOffer->GetMediaSection(i),
"Local offer after gathering should have an end-of-candidates.");
}
SetRemoteOffer(offer);
mOffCandidates->Trickle(*mSessionAns);
- UniquePtr<Sdp> remoteOffer(Parse(mSessionAns->GetRemoteDescription()));
+ UniquePtr<Sdp> remoteOffer(Parse(
+ mSessionAns->GetRemoteDescription(kJsepDescriptionCurrent)));
for (size_t i = 0; i < remoteOffer->GetMediaSectionCount(); ++i) {
mOffCandidates->CheckRtpCandidates(
true, remoteOffer->GetMediaSection(i), i,
"Remote offer after trickle should have RTP candidates.");
mOffCandidates->CheckDefaultRtpCandidate(
false, remoteOffer->GetMediaSection(i), i,
"Initial remote offer should not have a default RTP candidate.");
mOffCandidates->CheckRtcpCandidates(
@@ -2539,17 +2541,18 @@ TEST_P(JsepSessionTest, FullCallWithCand
AddTracks(*mSessionAns);
std::string answer = CreateAnswer();
SetLocalAnswer(answer);
// This will gather candidates that mSessionAns knows it doesn't need.
// They should not be present in the SDP.
mAnsCandidates->Gather(*mSessionAns, types);
- UniquePtr<Sdp> localAnswer(Parse(mSessionAns->GetLocalDescription()));
+ UniquePtr<Sdp> localAnswer(Parse(
+ mSessionAns->GetLocalDescription(kJsepDescriptionCurrent)));
for (size_t i = 0; i < localAnswer->GetMediaSectionCount(); ++i) {
mAnsCandidates->CheckRtpCandidates(
i == 0, localAnswer->GetMediaSection(i), i,
"Local answer after gathering should have RTP candidates on level 0.");
mAnsCandidates->CheckDefaultRtpCandidate(
true, localAnswer->GetMediaSection(i), 0,
"Local answer after gathering should have a default RTP candidate "
"on all levels that matches transport level 0.");
@@ -2564,17 +2567,18 @@ TEST_P(JsepSessionTest, FullCallWithCand
CheckEndOfCandidates(i == 0, localAnswer->GetMediaSection(i),
"Local answer after gathering should have an end-of-candidates only for"
" level 0.");
}
SetRemoteAnswer(answer);
mAnsCandidates->Trickle(*mSessionOff);
- UniquePtr<Sdp> remoteAnswer(Parse(mSessionOff->GetRemoteDescription()));
+ UniquePtr<Sdp> remoteAnswer(Parse(
+ mSessionOff->GetRemoteDescription(kJsepDescriptionCurrent)));
for (size_t i = 0; i < remoteAnswer->GetMediaSectionCount(); ++i) {
mAnsCandidates->CheckRtpCandidates(
i == 0, remoteAnswer->GetMediaSection(i), i,
"Remote answer after trickle should have RTP candidates on level 0.");
mAnsCandidates->CheckDefaultRtpCandidate(
false, remoteAnswer->GetMediaSection(i), i,
"Remote answer after trickle should not have a default RTP candidate.");
mAnsCandidates->CheckRtcpCandidates(
@@ -2673,17 +2677,18 @@ TEST_P(JsepSessionTest, RenegotiationWit
if (types[level] != SdpMediaSection::kApplication) {
mOffCandidates->Gather(*mSessionOff, level, RTCP);
}
}
mOffCandidates->FinishGathering(*mSessionOff);
mOffCandidates->Trickle(*mSessionAns);
- UniquePtr<Sdp> localOffer(Parse(mSessionOff->GetLocalDescription()));
+ UniquePtr<Sdp> localOffer(Parse(
+ mSessionOff->GetLocalDescription(kJsepDescriptionCurrent)));
for (size_t i = 0; i < localOffer->GetMediaSectionCount(); ++i) {
mOffCandidates->CheckRtpCandidates(
true, localOffer->GetMediaSection(i), i,
"Local reoffer after gathering should have RTP candidates.");
mOffCandidates->CheckDefaultRtpCandidate(
true, localOffer->GetMediaSection(i), i,
"Local reoffer after gathering should have a default RTP candidate.");
mOffCandidates->CheckRtcpCandidates(
@@ -2695,17 +2700,18 @@ TEST_P(JsepSessionTest, RenegotiationWit
types[i] != SdpMediaSection::kApplication,
localOffer->GetMediaSection(i), i,
"Local reoffer after gathering should have a default RTCP candidate "
"(unless m=application)");
CheckEndOfCandidates(true, localOffer->GetMediaSection(i),
"Local reoffer after gathering should have an end-of-candidates.");
}
- UniquePtr<Sdp> remoteOffer(Parse(mSessionAns->GetRemoteDescription()));
+ UniquePtr<Sdp> remoteOffer(Parse(
+ mSessionAns->GetRemoteDescription(kJsepDescriptionCurrent)));
for (size_t i = 0; i < remoteOffer->GetMediaSectionCount(); ++i) {
mOffCandidates->CheckRtpCandidates(
true, remoteOffer->GetMediaSection(i), i,
"Remote reoffer after trickle should have RTP candidates.");
mOffCandidates->CheckDefaultRtpCandidate(
i == 0, remoteOffer->GetMediaSection(i), i,
"Remote reoffer should have a default RTP candidate on level 0 "
"(because it was gathered last offer/answer).");
@@ -2722,17 +2728,18 @@ TEST_P(JsepSessionTest, RenegotiationWit
answer = CreateAnswer();
SetLocalAnswer(answer);
SetRemoteAnswer(answer);
// No candidates should be gathered at the answerer, but default candidates
// should be set.
mAnsCandidates->FinishGathering(*mSessionAns);
- UniquePtr<Sdp> localAnswer(Parse(mSessionAns->GetLocalDescription()));
+ UniquePtr<Sdp> localAnswer(Parse(
+ mSessionAns->GetLocalDescription(kJsepDescriptionCurrent)));
for (size_t i = 0; i < localAnswer->GetMediaSectionCount(); ++i) {
mAnsCandidates->CheckRtpCandidates(
i == 0, localAnswer->GetMediaSection(i), i,
"Local reanswer after gathering should have RTP candidates on level "
"0.");
mAnsCandidates->CheckDefaultRtpCandidate(
true, localAnswer->GetMediaSection(i), 0,
"Local reanswer after gathering should have a default RTP candidate "
@@ -2745,17 +2752,18 @@ TEST_P(JsepSessionTest, RenegotiationWit
false, localAnswer->GetMediaSection(i), i,
"Local reanswer after gathering should not have a default RTCP "
"candidate (because we're reanswering with rtcp-mux)");
CheckEndOfCandidates(i == 0, localAnswer->GetMediaSection(i),
"Local reanswer after gathering should have an end-of-candidates only "
"for level 0.");
}
- UniquePtr<Sdp> remoteAnswer(Parse(mSessionOff->GetRemoteDescription()));
+ UniquePtr<Sdp> remoteAnswer(Parse(
+ mSessionOff->GetRemoteDescription(kJsepDescriptionCurrent)));
for (size_t i = 0; i < localAnswer->GetMediaSectionCount(); ++i) {
mAnsCandidates->CheckRtpCandidates(
i == 0, remoteAnswer->GetMediaSection(i), i,
"Remote reanswer after trickle should have RTP candidates on level 0.");
mAnsCandidates->CheckDefaultRtpCandidate(
i == 0, remoteAnswer->GetMediaSection(i), i,
"Remote reanswer should have a default RTP candidate on level 0 "
"(because it was gathered last offer/answer).");
@@ -3001,49 +3009,53 @@ TEST_F(JsepSessionTest, OfferAnswerSendO
TEST_F(JsepSessionTest, OfferToReceiveAudioNotUsed)
{
JsepOfferOptions options;
options.mOfferToReceiveAudio = Some<size_t>(1);
OfferAnswer(CHECK_SUCCESS, Some(options));
- UniquePtr<Sdp> offer(Parse(mSessionOff->GetLocalDescription()));
+ UniquePtr<Sdp> offer(Parse(
+ mSessionOff->GetLocalDescription(kJsepDescriptionCurrent)));
ASSERT_TRUE(offer.get());
ASSERT_EQ(1U, offer->GetMediaSectionCount());
ASSERT_EQ(SdpMediaSection::kAudio,
offer->GetMediaSection(0).GetMediaType());
ASSERT_EQ(SdpDirectionAttribute::kRecvonly,
offer->GetMediaSection(0).GetAttributeList().GetDirection());
- UniquePtr<Sdp> answer(Parse(mSessionAns->GetLocalDescription()));
+ UniquePtr<Sdp> answer(Parse(
+ mSessionAns->GetLocalDescription(kJsepDescriptionCurrent)));
ASSERT_TRUE(answer.get());
ASSERT_EQ(1U, answer->GetMediaSectionCount());
ASSERT_EQ(SdpMediaSection::kAudio,
answer->GetMediaSection(0).GetMediaType());
ASSERT_EQ(SdpDirectionAttribute::kInactive,
answer->GetMediaSection(0).GetAttributeList().GetDirection());
}
TEST_F(JsepSessionTest, OfferToReceiveVideoNotUsed)
{
JsepOfferOptions options;
options.mOfferToReceiveVideo = Some<size_t>(1);
OfferAnswer(CHECK_SUCCESS, Some(options));
- UniquePtr<Sdp> offer(Parse(mSessionOff->GetLocalDescription()));
+ UniquePtr<Sdp> offer(Parse(
+ mSessionOff->GetLocalDescription(kJsepDescriptionCurrent)));
ASSERT_TRUE(offer.get());
ASSERT_EQ(1U, offer->GetMediaSectionCount());
ASSERT_EQ(SdpMediaSection::kVideo,
offer->GetMediaSection(0).GetMediaType());
ASSERT_EQ(SdpDirectionAttribute::kRecvonly,
offer->GetMediaSection(0).GetAttributeList().GetDirection());
- UniquePtr<Sdp> answer(Parse(mSessionAns->GetLocalDescription()));
+ UniquePtr<Sdp> answer(Parse(
+ mSessionAns->GetLocalDescription(kJsepDescriptionCurrent)));
ASSERT_TRUE(answer.get());
ASSERT_EQ(1U, answer->GetMediaSectionCount());
ASSERT_EQ(SdpMediaSection::kVideo,
answer->GetMediaSection(0).GetMediaType());
ASSERT_EQ(SdpDirectionAttribute::kInactive,
answer->GetMediaSection(0).GetAttributeList().GetDirection());
}
@@ -4403,17 +4415,17 @@ TEST_P(JsepSessionTest, TestBalancedBund
TEST_P(JsepSessionTest, TestMaxBundle)
{
AddTracks(*mSessionOff);
AddTracks(*mSessionAns);
mSessionOff->SetBundlePolicy(kBundleMaxBundle);
OfferAnswer();
- std::string offer = mSessionOff->GetLocalDescription();
+ std::string offer = mSessionOff->GetLocalDescription(kJsepDescriptionCurrent);
SipccSdpParser parser;
UniquePtr<Sdp> parsedOffer = parser.Parse(offer);
ASSERT_TRUE(parsedOffer.get());
ASSERT_FALSE(
parsedOffer->GetMediaSection(0).GetAttributeList().HasAttribute(
SdpAttribute::kBundleOnlyAttribute));
ASSERT_NE(0U, parsedOffer->GetMediaSection(0).GetPort());
@@ -4833,19 +4845,21 @@ TEST_F(JsepSessionTest, AudioOnlyG722Onl
std::size_t pos = offer.find(audio);
ASSERT_NE(pos, std::string::npos);
offer.replace(pos, audio.length(),
"m=audio 65375 UDP/TLS/RTP/SAVPF 9\r\n");
SetRemoteOffer(offer);
std::string answer = CreateAnswer();
SetLocalAnswer(answer);
- ASSERT_NE(mSessionAns->GetLocalDescription().find("UDP/TLS/RTP/SAVPF 9\r"),
+ ASSERT_NE(mSessionAns->GetLocalDescription(kJsepDescriptionCurrent)
+ .find("UDP/TLS/RTP/SAVPF 9\r"),
std::string::npos);
- ASSERT_NE(mSessionAns->GetLocalDescription().find("a=rtpmap:9 G722/8000"),
+ ASSERT_NE(mSessionAns->GetLocalDescription(kJsepDescriptionCurrent)
+ .find("a=rtpmap:9 G722/8000"),
std::string::npos);
}
TEST_F(JsepSessionTest, AudioOnlyG722Rejected)
{
types.push_back(SdpMediaSection::kAudio);
AddTracks(*mSessionOff, "audio");
AddTracks(*mSessionAns, "audio");
@@ -4859,22 +4873,27 @@ TEST_F(JsepSessionTest, AudioOnlyG722Rej
"m=audio 65375 UDP/TLS/RTP/SAVPF 0 8\r\n");
SetRemoteOffer(offer);
std::string answer = CreateAnswer();
SetLocalAnswer(answer);
SetRemoteAnswer(answer);
// TODO(bug 814227): Use commented out code instead.
- ASSERT_NE(mSessionAns->GetLocalDescription().find("UDP/TLS/RTP/SAVPF 0\r"),
+ ASSERT_NE(mSessionAns->GetLocalDescription(kJsepDescriptionCurrent)
+ .find("UDP/TLS/RTP/SAVPF 0\r"),
std::string::npos);
- // ASSERT_NE(mSessionAns->GetLocalDescription().find("UDP/TLS/RTP/SAVPF 0 8\r"), std::string::npos);
- ASSERT_NE(mSessionAns->GetLocalDescription().find("a=rtpmap:0 PCMU/8000"), std::string::npos);
- ASSERT_EQ(mSessionAns->GetLocalDescription().find("a=rtpmap:109 opus/48000/2"), std::string::npos);
- ASSERT_EQ(mSessionAns->GetLocalDescription().find("a=rtpmap:9 G722/8000"), std::string::npos);
+ // ASSERT_NE(mSessionAns->GetLocalDescription(kJsepDescriptionCurrent)
+ // .find("UDP/TLS/RTP/SAVPF 0 8\r"), std::string::npos);
+ ASSERT_NE(mSessionAns->GetLocalDescription(kJsepDescriptionCurrent)
+ .find("a=rtpmap:0 PCMU/8000"), std::string::npos);
+ ASSERT_EQ(mSessionAns->GetLocalDescription(kJsepDescriptionCurrent)
+ .find("a=rtpmap:109 opus/48000/2"), std::string::npos);
+ ASSERT_EQ(mSessionAns->GetLocalDescription(kJsepDescriptionCurrent)
+ .find("a=rtpmap:9 G722/8000"), std::string::npos);
}
// This test doesn't make sense for bundle
TEST_F(JsepSessionTest, DISABLED_FullCallAudioNoMuxVideoMux)
{
types.push_back(SdpMediaSection::kAudio);
AddTracks(*mSessionOff, "audio,video");
AddTracks(*mSessionAns, "audio,video");
@@ -4882,19 +4901,21 @@ TEST_F(JsepSessionTest, DISABLED_FullCal
SetLocalOffer(offer);
std::string rtcp_mux = "a=rtcp-mux\r\n";
std::size_t pos = offer.find(rtcp_mux);
ASSERT_NE(pos, std::string::npos);
offer.replace(pos, rtcp_mux.length(), "");
SetRemoteOffer(offer);
std::string answer = CreateAnswer();
- size_t match = mSessionAns->GetLocalDescription().find("\r\na=rtcp-mux");
+ size_t match = mSessionAns->GetLocalDescription(kJsepDescriptionCurrent)
+ .find("\r\na=rtcp-mux");
ASSERT_NE(match, std::string::npos);
- match = mSessionAns->GetLocalDescription().find("\r\na=rtcp-mux", match + 1);
+ match = mSessionAns->GetLocalDescription(kJsepDescriptionCurrent)
+ .find("\r\na=rtcp-mux", match + 1);
ASSERT_EQ(match, std::string::npos);
}
// Disabled pending resolution of bug 818640.
// Actually, this test is completely broken; you can't just call
// SetRemote/CreateAnswer over and over again.
TEST_F(JsepSessionTest, DISABLED_OfferAllDynamicTypes)
{
--- a/media/webrtc/signaling/src/jsep/JsepSessionImpl.cpp
+++ b/media/webrtc/signaling/src/jsep/JsepSessionImpl.cpp
@@ -767,31 +767,31 @@ JsepSessionImpl::CreateOffer(const JsepO
*offer = sdp->ToString();
mGeneratedLocalDescription = Move(sdp);
++mSessionVersion;
return NS_OK;
}
std::string
-JsepSessionImpl::GetLocalDescription() const
+JsepSessionImpl::GetLocalDescription(JsepDescriptionPendingOrCurrent type) const
{
std::ostringstream os;
- mozilla::Sdp* sdp = GetParsedLocalDescription();
+ mozilla::Sdp* sdp = GetParsedLocalDescription(type);
if (sdp) {
sdp->Serialize(os);
}
return os.str();
}
std::string
-JsepSessionImpl::GetRemoteDescription() const
+JsepSessionImpl::GetRemoteDescription(JsepDescriptionPendingOrCurrent type) const
{
std::ostringstream os;
- mozilla::Sdp* sdp = GetParsedRemoteDescription();
+ mozilla::Sdp* sdp = GetParsedRemoteDescription(type);
if (sdp) {
sdp->Serialize(os);
}
return os.str();
}
void
JsepSessionImpl::AddExtmap(SdpMediaSection* msection) const
@@ -2405,17 +2405,17 @@ JsepSessionImpl::SetState(JsepSignalingS
nsresult
JsepSessionImpl::AddRemoteIceCandidate(const std::string& candidate,
const std::string& mid,
uint16_t level)
{
mLastError.clear();
- mozilla::Sdp* sdp = GetParsedRemoteDescription();
+ mozilla::Sdp* sdp = GetParsedRemoteDescription(kJsepDescriptionPendingOrCurrent);
if (!sdp) {
JSEP_SET_ERROR("Cannot add ICE candidate in state " << GetStateStr(mState));
return NS_ERROR_UNEXPECTED;
}
return mSdpHelper.AddCandidateToSdp(sdp, candidate, mid, level);
}
@@ -2423,17 +2423,17 @@ JsepSessionImpl::AddRemoteIceCandidate(c
nsresult
JsepSessionImpl::AddLocalIceCandidate(const std::string& candidate,
uint16_t level,
std::string* mid,
bool* skipped)
{
mLastError.clear();
- mozilla::Sdp* sdp = GetParsedLocalDescription();
+ mozilla::Sdp* sdp = GetParsedLocalDescription(kJsepDescriptionPendingOrCurrent);
if (!sdp) {
JSEP_SET_ERROR("Cannot add ICE candidate in state " << GetStateStr(mState));
return NS_ERROR_UNEXPECTED;
}
if (sdp->GetMediaSectionCount() <= level) {
// mainly here to make some testing less complicated, but also just in case
@@ -2466,17 +2466,17 @@ JsepSessionImpl::UpdateDefaultCandidate(
const std::string& defaultCandidateAddr,
uint16_t defaultCandidatePort,
const std::string& defaultRtcpCandidateAddr,
uint16_t defaultRtcpCandidatePort,
uint16_t level)
{
mLastError.clear();
- mozilla::Sdp* sdp = GetParsedLocalDescription();
+ mozilla::Sdp* sdp = GetParsedLocalDescription(kJsepDescriptionPendingOrCurrent);
if (!sdp) {
JSEP_SET_ERROR("Cannot add ICE candidate in state " << GetStateStr(mState));
return NS_ERROR_UNEXPECTED;
}
if (level >= sdp->GetMediaSectionCount()) {
return NS_OK;
@@ -2513,17 +2513,17 @@ JsepSessionImpl::UpdateDefaultCandidate(
return NS_OK;
}
nsresult
JsepSessionImpl::EndOfLocalCandidates(uint16_t level)
{
mLastError.clear();
- mozilla::Sdp* sdp = GetParsedLocalDescription();
+ mozilla::Sdp* sdp = GetParsedLocalDescription(kJsepDescriptionPendingOrCurrent);
if (!sdp) {
JSEP_SET_ERROR("Cannot mark end of local ICE candidates in state "
<< GetStateStr(mState));
return NS_ERROR_UNEXPECTED;
}
if (level >= sdp->GetMediaSectionCount()) {
@@ -2589,28 +2589,34 @@ JsepSessionImpl::EnableOfferMsection(Sdp
std::ostringstream osMid;
osMid << "sdparta_" << msection->GetLevel();
AddMid(osMid.str(), msection);
return NS_OK;
}
mozilla::Sdp*
-JsepSessionImpl::GetParsedLocalDescription() const
+JsepSessionImpl::GetParsedLocalDescription(JsepDescriptionPendingOrCurrent type) const
{
- if (mPendingLocalDescription) {
+ if (type == kJsepDescriptionPending) {
+ return mPendingLocalDescription.get();
+ } else if (mPendingLocalDescription &&
+ type == kJsepDescriptionPendingOrCurrent) {
return mPendingLocalDescription.get();
}
return mCurrentLocalDescription.get();
}
mozilla::Sdp*
-JsepSessionImpl::GetParsedRemoteDescription() const
+JsepSessionImpl::GetParsedRemoteDescription(JsepDescriptionPendingOrCurrent type) const
{
- if (mPendingRemoteDescription) {
+ if (type == kJsepDescriptionPending) {
+ return mPendingRemoteDescription.get();
+ } else if (mPendingRemoteDescription &&
+ type == kJsepDescriptionPendingOrCurrent) {
return mPendingRemoteDescription.get();
}
return mCurrentRemoteDescription.get();
}
const Sdp*
JsepSessionImpl::GetAnswer() const
{