Skip to content

Commit 7a2db8a

Browse files
Harald AlvestrandWebRTC LUCI CQ
authored andcommitted
Modify Bundle logic to not add & destroy extra transport at add-track
If a bundle is established, then per JSEP, the offerer is required to include the new track in the bundle, and per BUNDLE, the answerer has to either accept the track as part of the bundle or reject the track; it cannot move it out of the group. So we will never need the transport. Bug: webrtc:12837 Change-Id: I41cae74605fecf454900a958776b95607ccf3745 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/221601 Reviewed-by: Henrik Boström <[email protected]> Commit-Queue: Harald Alvestrand <[email protected]> Cr-Commit-Position: refs/heads/master@{#34290}
1 parent e4eb8af commit 7a2db8a

7 files changed

+70
-6
lines changed

pc/jsep_transport_controller.cc

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,18 @@ RTCError JsepTransportController::ApplyDescription_n(
574574
established_bundle_groups_by_mid, description);
575575
}
576576

577+
// Because the creation of transports depends on whether
578+
// certain mids are present, we have to process rejection
579+
// before we try to create transports.
580+
for (size_t i = 0; i < description->contents().size(); ++i) {
581+
const cricket::ContentInfo& content_info = description->contents()[i];
582+
if (content_info.rejected) {
583+
// This may cause groups to be removed from |bundles_.bundle_groups()| and
584+
// |established_bundle_groups_by_mid|.
585+
HandleRejectedContent(content_info, established_bundle_groups_by_mid);
586+
}
587+
}
588+
577589
for (const cricket::ContentInfo& content_info : description->contents()) {
578590
// Don't create transports for rejected m-lines and bundled m-lines.
579591
if (content_info.rejected ||
@@ -593,10 +605,8 @@ RTCError JsepTransportController::ApplyDescription_n(
593605
const cricket::ContentInfo& content_info = description->contents()[i];
594606
const cricket::TransportInfo& transport_info =
595607
description->transport_infos()[i];
608+
596609
if (content_info.rejected) {
597-
// This may cause groups to be removed from |bundles_.bundle_groups()| and
598-
// |established_bundle_groups_by_mid|.
599-
HandleRejectedContent(content_info, established_bundle_groups_by_mid);
600610
continue;
601611
}
602612

@@ -1011,7 +1021,21 @@ RTCError JsepTransportController::MaybeCreateJsepTransport(
10111021
if (transport) {
10121022
return RTCError::OK();
10131023
}
1014-
1024+
// If we have agreed to a bundle, the new mid will be added to the bundle
1025+
// according to JSEP, and the responder can't move it out of the group
1026+
// according to BUNDLE. So don't create a transport.
1027+
// The MID will be added to the bundle elsewhere in the code.
1028+
if (bundles_.bundle_groups().size() > 0) {
1029+
const auto& default_bundle_group = bundles_.bundle_groups()[0];
1030+
if (default_bundle_group->content_names().size() > 0) {
1031+
auto bundle_transport =
1032+
GetJsepTransportByName(default_bundle_group->content_names()[0]);
1033+
if (bundle_transport) {
1034+
transports_.SetTransportForMid(content_info.name, bundle_transport);
1035+
return RTCError::OK();
1036+
}
1037+
}
1038+
}
10151039
const cricket::MediaContentDescription* content_desc =
10161040
content_info.media_description();
10171041
if (certificate_ && !content_desc->cryptos().empty()) {

pc/jsep_transport_controller_unittest.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2051,7 +2051,6 @@ TEST_F(JsepTransportControllerTest, ChangeTaggedMediaSectionMaxBundle) {
20512051
EXPECT_TRUE(transport_controller_
20522052
->SetLocalDescription(SdpType::kOffer, local_reoffer.get())
20532053
.ok());
2054-
20552054
std::unique_ptr<cricket::SessionDescription> remote_reanswer(
20562055
local_reoffer->Clone());
20572056
EXPECT_TRUE(

pc/peer_connection_integrationtest.cc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3639,6 +3639,20 @@ TEST_P(PeerConnectionIntegrationInteropTest,
36393639
ASSERT_TRUE(ExpectNewFrames(media_expectations));
36403640
}
36413641

3642+
TEST_P(PeerConnectionIntegrationTest, NewTracksDoNotCauseNewCandidates) {
3643+
ASSERT_TRUE(CreatePeerConnectionWrappers());
3644+
ConnectFakeSignaling();
3645+
caller()->AddAudioVideoTracks();
3646+
caller()->CreateAndSetAndSignalOffer();
3647+
ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
3648+
ASSERT_TRUE_WAIT(DtlsConnected(), kDefaultTimeout);
3649+
caller()->ExpectCandidates(0);
3650+
callee()->ExpectCandidates(0);
3651+
caller()->AddAudioTrack();
3652+
caller()->CreateAndSetAndSignalOffer();
3653+
ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
3654+
}
3655+
36423656
INSTANTIATE_TEST_SUITE_P(
36433657
PeerConnectionIntegrationTest,
36443658
PeerConnectionIntegrationInteropTest,

pc/rtcp_mux_filter.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ bool RtcpMuxFilter::SetAnswer(bool answer_enable, ContentSource src) {
9191
}
9292

9393
if (!ExpectAnswer(src)) {
94-
RTC_LOG(LS_ERROR) << "Invalid state for RTCP mux answer";
94+
RTC_LOG(LS_ERROR) << "Invalid state for RTCP mux answer, state is "
95+
<< state_ << ", source is " << src;
9596
return false;
9697
}
9798

pc/session_description.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,18 @@ bool ContentGroup::RemoveContentName(const std::string& content_name) {
8585
return true;
8686
}
8787

88+
std::string ContentGroup::ToString() const {
89+
rtc::StringBuilder acc;
90+
acc << semantics_ << "(";
91+
if (!content_names_.empty()) {
92+
for (const auto& name : content_names_) {
93+
acc << name << " ";
94+
}
95+
}
96+
acc << ")";
97+
return acc.Release();
98+
}
99+
88100
SessionDescription::SessionDescription() = default;
89101
SessionDescription::SessionDescription(const SessionDescription&) = default;
90102

pc/session_description.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,8 @@ class ContentGroup {
488488
bool HasContentName(const std::string& content_name) const;
489489
void AddContentName(const std::string& content_name);
490490
bool RemoveContentName(const std::string& content_name);
491+
// for debugging
492+
std::string ToString() const;
491493

492494
private:
493495
std::string semantics_;

pc/test/integration_test_helpers.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#include <algorithm>
1919
#include <functional>
20+
#include <limits>
2021
#include <list>
2122
#include <map>
2223
#include <memory>
@@ -704,6 +705,11 @@ class PeerConnectionIntegrationWrapper : public webrtc::PeerConnectionObserver,
704705
audio_concealed_stat_ = *track_stats->concealed_samples;
705706
}
706707

708+
// Sets number of candidates expected
709+
void ExpectCandidates(int candidate_count) {
710+
candidates_expected_ = candidate_count;
711+
}
712+
707713
private:
708714
explicit PeerConnectionIntegrationWrapper(const std::string& debug_name)
709715
: debug_name_(debug_name) {}
@@ -1089,6 +1095,9 @@ class PeerConnectionIntegrationWrapper : public webrtc::PeerConnectionObserver,
10891095
}
10901096
}
10911097

1098+
// Check if we expected to have a candidate.
1099+
EXPECT_GT(candidates_expected_, 1);
1100+
candidates_expected_--;
10921101
std::string ice_sdp;
10931102
EXPECT_TRUE(candidate->ToString(&ice_sdp));
10941103
if (signaling_message_receiver_ == nullptr || !signal_ice_candidates_) {
@@ -1172,6 +1181,9 @@ class PeerConnectionIntegrationWrapper : public webrtc::PeerConnectionObserver,
11721181
peer_connection_signaling_state_history_;
11731182
webrtc::FakeRtcEventLogFactory* event_log_factory_;
11741183

1184+
// Number of ICE candidates expected. The default is no limit.
1185+
int candidates_expected_ = std::numeric_limits<int>::max();
1186+
11751187
// Variables for tracking delay stats on an audio track
11761188
int audio_packets_stat_ = 0;
11771189
double audio_delay_stat_ = 0.0;

0 commit comments

Comments
 (0)