Add x-mt line to the offer.
We already support decoding of the x-mt line. This change adds the
a=x-mt line to the SDP offer. This is not a backward compatible change
for media transport (because of the changes in pre-shared key handling)
1) if media transport is enabled, and SDES is enabled, generate the
media transport offer.
2) if media transport generated the offer, add that offer to the x-mt
line.
3) in order to create media transport, require an x-mt line (backward incompatible).
The way it works is that
1) PeerConnection, on the offerer, asks jsep transport for the
configuration of the media transport.
2) Tentative media transport is created in JsepTransportController when
that happens.
3) SessionDescription will include configuration from this tentative
media transport.
4) When the LocalDescription is set on the offerer, the tentative media
transport is promoted to the real media transport.
Caveats:
- now we really only support MaxBundle. In the previous implementations,
two media transports were briefly created in some tests, and the second
one was destroyed shortly after instantiation.
- we, for now, enforce SDES. In the future, whether SDES is used will be
refactored out of the peer connection.
In the future (on the callee) we should ignore 'is_media_transport' setting. If
Offer contains x-mt, media transport should be used (if the factory is
present). However, we need to decide how to negotiate media transport
for data channels vs data transport for media (x-mt line at this point
doesn't differentiate the two, so we still need to use app setting).
This change also removes the negotation of pre-shared key from the
a=crypto line. Instead, media transport will have its own, 256bit key.
Such key should be transported in the x-mt line. This makes the code
much simpler, and simplifies the dependency / a=crypto lines parsing.
Also, adds a proper test for the connection re-offer (on both sides: callee and caller).
Before, it was possible that media transport could get recreated, based on the offer.
The tests we had didn't test this scenario, and the loopback media factory didn't allow for such test.
This change adds counts to that loopback media factory, and asserts that only 1 media transport is created, even
when there is a re-offer.
Bug: webrtc:9719
Change-Id: Ibd8739af90e914da40ab412454bba8e1529f5a01
Reviewed-on: https://webrtc-review.googlesource.com/c/125040
Reviewed-by: Bjorn Mellem <mellem@webrtc.org>
Reviewed-by: Steve Anton <steveanton@webrtc.org>
Commit-Queue: Peter Slatala <psla@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26933}
diff --git a/pc/peer_connection.cc b/pc/peer_connection.cc
index 44617dd..9c4461d 100644
--- a/pc/peer_connection.cc
+++ b/pc/peer_connection.cc
@@ -1001,6 +1001,23 @@
return false;
}
+ if (configuration.use_media_transport ||
+ configuration.use_media_transport_for_data_channels) {
+ // TODO(bugs.webrtc.org/9719): This check will eventually go away, when
+ // RTP media transport is introduced. But until then, we require SDES to
+ // be enabled.
+ if (configuration.enable_dtls_srtp.has_value() &&
+ configuration.enable_dtls_srtp.value()) {
+ RTC_LOG(LS_WARNING)
+ << "When media transport is used, SDES must be enabled. Set "
+ "configuration.enable_dtls_srtp to false. use_media_transport="
+ << configuration.use_media_transport
+ << ", use_media_transport_for_data_channels="
+ << configuration.use_media_transport_for_data_channels;
+ return false;
+ }
+ }
+
config.use_media_transport_for_media = configuration.use_media_transport;
config.use_media_transport_for_data_channels =
configuration.use_media_transport_for_data_channels;
@@ -4140,6 +4157,12 @@
port_allocator_.get()));
session_options->offer_extmap_allow_mixed =
configuration_.offer_extmap_allow_mixed;
+
+ if (configuration_.enable_dtls_srtp &&
+ !configuration_.enable_dtls_srtp.value()) {
+ session_options->media_transport_settings =
+ transport_controller_->GenerateOrGetLastMediaTransportOffer();
+ }
}
void PeerConnection::GetOptionsForPlanBOffer(
@@ -6352,7 +6375,8 @@
const std::string& mid) {
media_transport_ = transport_controller_->GetMediaTransport(mid);
if (!media_transport_) {
- RTC_LOG(LS_ERROR) << "Media transport is not available for data channels";
+ RTC_LOG(LS_ERROR)
+ << "Media transport is not available for data channels, mid=" << mid;
return false;
}