From 766c80b2564b8af82f9f500e2825f2bc6e5b2d5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Bostr=C3=B6m?= Date: Wed, 12 Jan 2022 17:46:03 +0100 Subject: [PATCH] [ObjC] Change default sdpSemantics to NotSpecified. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The default value of sdpSemantics is about to change from PlanB to UnifiedPlan. In order not to cause subtle bugs by applications that depend on the default value being PlanB, we are temporarily making the default NotSpecified. Constructing with NotSpecified causes the C++ layer to crash (https://webrtc-review.googlesource.com/c/src/+/242968). This is in accordance to the publically announced plans: https://groups.google.com/u/1/g/discuss-webrtc/c/SdoVP02eUIk Bug: webrtc:11121 Change-Id: Idbb8fd0f5c224311cf1f25ac2832800124ed14d4 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/246060 Reviewed-by: Peter Hanspers Commit-Queue: Henrik Boström Cr-Commit-Position: refs/heads/main@{#35678} --- .../api/peerconnection/RTCConfiguration.h | 30 +++++++++++++------ .../api/peerconnection/RTCConfiguration.mm | 9 ++++-- sdk/objc/unittests/RTCPeerConnectionTest.mm | 4 +++ 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/sdk/objc/api/peerconnection/RTCConfiguration.h b/sdk/objc/api/peerconnection/RTCConfiguration.h index 4356b8d494..c7a20533a3 100644 --- a/sdk/objc/api/peerconnection/RTCConfiguration.h +++ b/sdk/objc/api/peerconnection/RTCConfiguration.h @@ -63,8 +63,15 @@ typedef NS_ENUM(NSInteger, RTCEncryptionKeyType) { /** Represents the chosen SDP semantics for the RTCPeerConnection. */ typedef NS_ENUM(NSInteger, RTCSdpSemantics) { + // TODO(https://crbug.com/webrtc/13528): Remove support for Plan B. RTCSdpSemanticsPlanB, RTCSdpSemanticsUnifiedPlan, + // The default sdpSemantics value is about to change to Unified Plan. During + // a short transition period, NotSpecified is used to ensure clients that + // don't set sdpSemantics are aware of the change by CHECK-crashing. + // TODO(https://crbug.com/webrtc/11121): When the default has changed to + // UnifiedPlan, delete NotSpecified. + RTCSdpSemanticsNotSpecified, }; NS_ASSUME_NONNULL_BEGIN @@ -161,9 +168,10 @@ RTC_OBJC_EXPORT */ @property(nonatomic, copy, nullable) NSNumber *iceCheckMinInterval; -/** Configure the SDP semantics used by this PeerConnection. Note that the - * WebRTC 1.0 specification requires UnifiedPlan semantics. The - * RTCRtpTransceiver API is only available with UnifiedPlan semantics. +/** Configure the SDP semantics used by this PeerConnection. The WebRTC 1.0 + * specification requires RTCSdpSemanticsUnifiedPlan semantics and the + * RtpTransceiver API is only available in Unified Plan. RTCSdpSemanticsPlanB + * is being deprecated and will be removed at a future date. * * PlanB will cause RTCPeerConnection to create offers and answers with at * most one audio and one video m= section with multiple RTCRtpSenders and @@ -174,14 +182,18 @@ RTC_OBJC_EXPORT * UnifiedPlan will cause RTCPeerConnection to create offers and answers with * multiple m= sections where each m= section maps to one RTCRtpSender and one * RTCRtpReceiver (an RTCRtpTransceiver), either both audio or both - * video. This will also cause RTCPeerConnection) to ignore all but the first a=ssrc - * lines that form a Plan B stream. + * video. This will also cause RTCPeerConnection) to ignore all but the first + * a=ssrc lines that form a Plan B stream. * - * For users who wish to send multiple audio/video streams and need to stay - * interoperable with legacy WebRTC implementations or use legacy APIs, - * specify PlanB. + * For users who have to interwork with legacy WebRTC implementations, it + * is possible to specify PlanB until the code is finally removed + * (https://crbug.com/webrtc/13528). * - * For all other users, specify UnifiedPlan. + * The default SdpSemantics value is about to change to UnifiedPlan. During a + * short transition period, NotSpecified is used to ensure clients that don't + * set SdpSemantics are aware of the change by CHECK-crashing. + * TODO(https://crbug.com/webrtc/11121): When the default has changed to + * UnifiedPlan, delete NotSpecified. */ @property(nonatomic, assign) RTCSdpSemantics sdpSemantics; diff --git a/sdk/objc/api/peerconnection/RTCConfiguration.mm b/sdk/objc/api/peerconnection/RTCConfiguration.mm index 0885e96f4e..9e9bca7745 100644 --- a/sdk/objc/api/peerconnection/RTCConfiguration.mm +++ b/sdk/objc/api/peerconnection/RTCConfiguration.mm @@ -68,7 +68,7 @@ - (instancetype)init { // Copy defaults. webrtc::PeerConnectionInterface::RTCConfiguration config; - config.sdp_semantics = webrtc::SdpSemantics::kPlanB_DEPRECATED; + config.sdp_semantics = webrtc::SdpSemantics::kNotSpecified; return [self initWithNativeConfiguration:config]; } @@ -525,6 +525,8 @@ return webrtc::SdpSemantics::kPlanB_DEPRECATED; case RTCSdpSemanticsUnifiedPlan: return webrtc::SdpSemantics::kUnifiedPlan; + case RTCSdpSemanticsNotSpecified: + return webrtc::SdpSemantics::kNotSpecified; } } @@ -535,8 +537,7 @@ case webrtc::SdpSemantics::kUnifiedPlan: return RTCSdpSemanticsUnifiedPlan; case webrtc::SdpSemantics::kNotSpecified: - RTC_DCHECK_NOTREACHED(); - return RTCSdpSemanticsUnifiedPlan; + return RTCSdpSemanticsNotSpecified; } } @@ -546,6 +547,8 @@ return @"PLAN_B"; case RTCSdpSemanticsUnifiedPlan: return @"UNIFIED_PLAN"; + case RTCSdpSemanticsNotSpecified: + return @"NOT_SPECIFIED"; } } diff --git a/sdk/objc/unittests/RTCPeerConnectionTest.mm b/sdk/objc/unittests/RTCPeerConnectionTest.mm index 19b3c8e69f..8ebe6271ab 100644 --- a/sdk/objc/unittests/RTCPeerConnectionTest.mm +++ b/sdk/objc/unittests/RTCPeerConnectionTest.mm @@ -42,6 +42,7 @@ [[RTC_OBJC_TYPE(RTCIceServer) alloc] initWithURLStrings:urlStrings]; RTC_OBJC_TYPE(RTCConfiguration) *config = [[RTC_OBJC_TYPE(RTCConfiguration) alloc] init]; + config.sdpSemantics = RTCSdpSemanticsUnifiedPlan; config.iceServers = @[ server ]; config.iceTransportPolicy = RTCIceTransportPolicyRelay; config.bundlePolicy = RTCBundlePolicyMaxBundle; @@ -121,6 +122,7 @@ [[RTC_OBJC_TYPE(RTCIceServer) alloc] initWithURLStrings:urlStrings]; RTC_OBJC_TYPE(RTCConfiguration) *config = [[RTC_OBJC_TYPE(RTCConfiguration) alloc] init]; + config.sdpSemantics = RTCSdpSemanticsUnifiedPlan; config.iceServers = @[ server ]; RTC_OBJC_TYPE(RTCMediaConstraints) *contraints = [[RTC_OBJC_TYPE(RTCMediaConstraints) alloc] initWithMandatoryConstraints:@{} @@ -145,6 +147,7 @@ [[RTC_OBJC_TYPE(RTCPeerConnectionFactory) alloc] init]; RTC_OBJC_TYPE(RTCConfiguration) *config = [[RTC_OBJC_TYPE(RTCConfiguration) alloc] init]; + config.sdpSemantics = RTCSdpSemanticsUnifiedPlan; RTC_OBJC_TYPE(RTCMediaConstraints) *contraints = [[RTC_OBJC_TYPE(RTCMediaConstraints) alloc] initWithMandatoryConstraints:@{} optionalConstraints:nil]; @@ -175,6 +178,7 @@ [[RTC_OBJC_TYPE(RTCPeerConnectionFactory) alloc] init]; RTC_OBJC_TYPE(RTCConfiguration) *config = [[RTC_OBJC_TYPE(RTCConfiguration) alloc] init]; + config.sdpSemantics = RTCSdpSemanticsUnifiedPlan; RTC_OBJC_TYPE(RTCMediaConstraints) *contraints = [[RTC_OBJC_TYPE(RTCMediaConstraints) alloc] initWithMandatoryConstraints:@{} optionalConstraints:nil];