From 3518e7bea490fb74cf52c5e37aa0a7c8fda8630e Mon Sep 17 00:00:00 2001 From: Zhi Huang Date: Tue, 30 Jan 2018 13:20:35 -0800 Subject: [PATCH] Add the rejected TransportInfo when creating an answer. Previously, if a media section is rejected by the answerer, the TransportInfo of that section will not be added to the answer but when answer SDP is deserialized by the offerer, the rejected TransportInfo will be added. This CL fixes this inconsistency by adding the TransportInfo of all the m= sections including the rejected ones. Bug: webrtc:8818 Change-Id: I3b163245979c4ac4df31db39262e499f1c4901c4 Reviewed-on: https://webrtc-review.googlesource.com/46380 Reviewed-by: Taylor Brandstetter Commit-Queue: Zhi Huang Cr-Commit-Position: refs/heads/master@{#21815} --- pc/mediasession.cc | 28 ++++++++++++++++------------ pc/mediasession_unittest.cc | 4 ++++ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/pc/mediasession.cc b/pc/mediasession.cc index b20bf5fa86..3f750d18ba 100644 --- a/pc/mediasession.cc +++ b/pc/mediasession.cc @@ -2082,10 +2082,12 @@ bool MediaSessionDescriptionFactory::AddAudioContentForAnswer( offer_content->rejected || !IsMediaProtocolSupported(MEDIA_TYPE_AUDIO, audio_answer->protocol(), secure); - if (!rejected) { - AddTransportAnswer(media_description_options.mid, *(audio_transport.get()), - answer); - } else { + if (!AddTransportAnswer(media_description_options.mid, + *(audio_transport.get()), answer)) { + return false; + } + + if (rejected) { RTC_LOG(LS_INFO) << "Audio m= section '" << media_description_options.mid << "' being rejected in answer."; } @@ -2164,11 +2166,12 @@ bool MediaSessionDescriptionFactory::AddVideoContentForAnswer( offer_content->rejected || !IsMediaProtocolSupported(MEDIA_TYPE_VIDEO, video_answer->protocol(), secure); + if (!AddTransportAnswer(media_description_options.mid, + *(video_transport.get()), answer)) { + return false; + } + if (!rejected) { - if (!AddTransportAnswer(media_description_options.mid, - *(video_transport.get()), answer)) { - return false; - } video_answer->set_bandwidth(kAutoBandwidth); } else { RTC_LOG(LS_INFO) << "Video m= section '" << media_description_options.mid @@ -2228,12 +2231,13 @@ bool MediaSessionDescriptionFactory::AddDataContentForAnswer( offer_content->rejected || !IsMediaProtocolSupported(MEDIA_TYPE_DATA, data_answer->protocol(), secure); + if (!AddTransportAnswer(media_description_options.mid, + *(data_transport.get()), answer)) { + return false; + } + if (!rejected) { data_answer->set_bandwidth(kDataMaxBandwidth); - if (!AddTransportAnswer(media_description_options.mid, - *(data_transport.get()), answer)) { - return false; - } } else { // RFC 3264 // The answer MUST contain the same number of m-lines as the offer. diff --git a/pc/mediasession_unittest.cc b/pc/mediasession_unittest.cc index 4176e0e76e..971e568889 100644 --- a/pc/mediasession_unittest.cc +++ b/pc/mediasession_unittest.cc @@ -3196,6 +3196,10 @@ TEST_F(MediaSessionDescriptionFactoryTest, ASSERT_EQ(2u, answer->contents().size()); EXPECT_FALSE(answer->contents()[0].rejected); EXPECT_TRUE(answer->contents()[1].rejected); + + // The TransportInfo of the rejected m= section is expected to be added in the + // answer. + EXPECT_EQ(offer->transport_infos().size(), answer->transport_infos().size()); } // Test the generated media sections has the same order of the