Revert "Expose setHeaderExtensionsToNegotiate for iOS"
This reverts commit f88236066e65762f5543bf0ac141f23b76849126. Reason for revert: Thanks for the fix Karim ! Unfortunately this commit breaks some downstream projects. I'll work on a reland. Original change's description: > Expose setHeaderExtensionsToNegotiate for iOS > > Bug: webrtc:15766 > Change-Id: I56ec97ab272c14b4b70f6c3d7a3daedde11738c4 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/336100 > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > Reviewed-by: Peter Hanspers <peterhanspers@webrtc.org> > Auto-Submit: Karim Ham <karim@karhm.com> > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > Cr-Commit-Position: refs/heads/main@{#43121} Bug: webrtc:15766 Change-Id: Ie0ccf73bec192452e288b7421eb8a1ecdb0eda67 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/364284 Owners-Override: Jeremy Leconte <jleconte@webrtc.org> Commit-Queue: Jeremy Leconte <jleconte@webrtc.org> Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com> Cr-Commit-Position: refs/heads/main@{#43124}
This commit is contained in:
parent
bdb52e9767
commit
1fe80229cc
@ -12,8 +12,6 @@
|
||||
|
||||
#import "sdk/objc/base/RTCMacros.h"
|
||||
|
||||
typedef NS_ENUM(NSInteger, RTCRtpTransceiverDirection);
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
RTC_OBJC_EXPORT
|
||||
@ -28,9 +26,6 @@ RTC_OBJC_EXPORT
|
||||
/** Whether the header extension is encrypted or not. */
|
||||
@property(nonatomic, readonly, getter=isPreferredEncrypted) BOOL preferredEncrypted;
|
||||
|
||||
/** Direction of the header extension. */
|
||||
@property(nonatomic) RTCRtpTransceiverDirection direction;
|
||||
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
@end
|
||||
|
||||
@ -9,7 +9,6 @@
|
||||
*/
|
||||
|
||||
#import "RTCRtpHeaderExtensionCapability+Private.h"
|
||||
#import "RTCRtpTransceiver+Private.h"
|
||||
|
||||
#import "helpers/NSString+StdString.h"
|
||||
|
||||
@ -18,7 +17,6 @@
|
||||
@synthesize uri = _uri;
|
||||
@synthesize preferredId = _preferredId;
|
||||
@synthesize preferredEncrypted = _preferredEncrypted;
|
||||
@synthesize direction = _direction;
|
||||
|
||||
- (instancetype)init {
|
||||
webrtc::RtpHeaderExtensionCapability nativeRtpHeaderExtensionCapability;
|
||||
@ -34,8 +32,6 @@
|
||||
_preferredId = [NSNumber numberWithInt:*nativeRtpHeaderExtensionCapability.preferred_id];
|
||||
}
|
||||
_preferredEncrypted = nativeRtpHeaderExtensionCapability.preferred_encrypt;
|
||||
_direction = [RTCRtpTransceiver
|
||||
rtpTransceiverDirectionFromNativeDirection:nativeRtpHeaderExtensionCapability.direction];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@ -55,8 +51,6 @@
|
||||
rtpHeaderExtensionCapability.preferred_id = std::optional<int>(_preferredId.intValue);
|
||||
}
|
||||
rtpHeaderExtensionCapability.preferred_encrypt = _preferredEncrypted;
|
||||
rtpHeaderExtensionCapability.direction =
|
||||
[RTCRtpTransceiver nativeRtpTransceiverDirectionFromDirection:_direction];
|
||||
return rtpHeaderExtensionCapability;
|
||||
}
|
||||
|
||||
|
||||
@ -47,7 +47,6 @@ RTC_OBJC_EXPORT
|
||||
|
||||
@class RTC_OBJC_TYPE(RTCRtpTransceiver);
|
||||
@class RTC_OBJC_TYPE(RTCRtpCodecCapability);
|
||||
@class RTC_OBJC_TYPE(RTCRtpHeaderExtensionCapability);
|
||||
|
||||
/** The RTCRtpTransceiver maps to the RTCRtpTransceiver defined by the
|
||||
* WebRTC specification. A transceiver represents a combination of an RTCRtpSender
|
||||
@ -106,17 +105,6 @@ RTC_OBJC_EXPORT
|
||||
*/
|
||||
@property(nonatomic, readonly) RTCRtpTransceiverDirection direction;
|
||||
|
||||
/** It will contain all the RTP header extensions that are supported.
|
||||
* The direction attribute for all extensions that are mandatory to use MUST be initialized to an
|
||||
* appropriate value other than RTCRtpTransceiverDirectionStopped. The direction attribute for
|
||||
* extensions that will not be offered by default in an initial offer MUST be initialized to
|
||||
* RTCRtpTransceiverDirectionStopped.
|
||||
*/
|
||||
@property(nonatomic, readonly, copy)
|
||||
NSArray<RTC_OBJC_TYPE(RTCRtpHeaderExtensionCapability) *> *headerExtensionsToNegotiate;
|
||||
@property(nonatomic, readonly, copy)
|
||||
NSArray<RTC_OBJC_TYPE(RTCRtpHeaderExtensionCapability) *> *negotiatedHeaderExtensions;
|
||||
|
||||
/** The currentDirection attribute indicates the current direction negotiated
|
||||
* for this transceiver. If this transceiver has never been represented in an
|
||||
* offer/answer exchange, or if the transceiver is stopped, the value is not
|
||||
@ -142,14 +130,6 @@ RTC_OBJC_EXPORT
|
||||
- (void)setCodecPreferences:(NSArray<RTC_OBJC_TYPE(RTCRtpCodecCapability) *> *_Nullable)codecs
|
||||
RTC_OBJC_DEPRECATED("Use setCodecPreferences:error: instead.");
|
||||
|
||||
/** The setHeaderExtensionsToNegotiate method overrides the default header extensions used
|
||||
* by WebRTC for this transceiver.
|
||||
* https://w3c.github.io/webrtc-extensions/#ref-for-dom-rtcrtptransceiver-setheaderextensionstonegotiate
|
||||
*/
|
||||
- (BOOL)setHeaderExtensionsToNegotiate:
|
||||
(NSArray<RTC_OBJC_TYPE(RTCRtpHeaderExtensionCapability) *> *)extensions
|
||||
error:(NSError **)error;
|
||||
|
||||
/** An update of directionality does not take effect immediately. Instead,
|
||||
* future calls to createOffer and createAnswer mark the corresponding media
|
||||
* descriptions as sendrecv, sendonly, recvonly, or inactive.
|
||||
|
||||
@ -12,7 +12,6 @@
|
||||
|
||||
#import "RTCRtpCodecCapability+Private.h"
|
||||
#import "RTCRtpEncodingParameters+Private.h"
|
||||
#import "RTCRtpHeaderExtensionCapability+Private.h"
|
||||
#import "RTCRtpParameters+Private.h"
|
||||
#import "RTCRtpReceiver+Private.h"
|
||||
#import "RTCRtpSender+Private.h"
|
||||
@ -82,44 +81,17 @@ NSString *const kRTCRtpTransceiverErrorDomain = @"org.webrtc.RTCRtpTranceiver";
|
||||
rtpTransceiverDirectionFromNativeDirection:_nativeRtpTransceiver->direction()];
|
||||
}
|
||||
|
||||
- (NSArray<RTC_OBJC_TYPE(RTCRtpHeaderExtensionCapability) *> *)headerExtensionsToNegotiate {
|
||||
std::vector<webrtc::RtpHeaderExtensionCapability> nativeHeaderExtensions(
|
||||
_nativeRtpTransceiver->GetHeaderExtensionsToNegotiate());
|
||||
|
||||
NSMutableArray *headerExtensions =
|
||||
[NSMutableArray arrayWithCapacity:nativeHeaderExtensions.size()];
|
||||
for (const auto &headerExtension : nativeHeaderExtensions) {
|
||||
[headerExtensions addObject:[[RTC_OBJC_TYPE(RTCRtpHeaderExtensionCapability) alloc]
|
||||
initWithNativeRtpHeaderExtensionCapability:headerExtension]];
|
||||
}
|
||||
return headerExtensions;
|
||||
}
|
||||
|
||||
- (NSArray<RTC_OBJC_TYPE(RTCRtpHeaderExtensionCapability) *> *)negotiatedHeaderExtensions {
|
||||
std::vector<webrtc::RtpHeaderExtensionCapability> nativeHeaderExtensions(
|
||||
_nativeRtpTransceiver->GetNegotiatedHeaderExtensions());
|
||||
|
||||
NSMutableArray *headerExtensions =
|
||||
[NSMutableArray arrayWithCapacity:nativeHeaderExtensions.size()];
|
||||
for (const auto &headerExtension : nativeHeaderExtensions) {
|
||||
[headerExtensions addObject:[[RTC_OBJC_TYPE(RTCRtpHeaderExtensionCapability) alloc]
|
||||
initWithNativeRtpHeaderExtensionCapability:headerExtension]];
|
||||
}
|
||||
return headerExtensions;
|
||||
}
|
||||
|
||||
- (void)setDirection:(RTCRtpTransceiverDirection)direction error:(NSError **)error {
|
||||
webrtc::RTCError nativeError = _nativeRtpTransceiver->SetDirectionWithError(
|
||||
[RTC_OBJC_TYPE(RTCRtpTransceiver) nativeRtpTransceiverDirectionFromDirection:direction]);
|
||||
|
||||
if (!nativeError.ok() && error) {
|
||||
NSDictionary *userInfo =
|
||||
@{NSLocalizedDescriptionKey : [NSString stringWithCString:nativeError.message()
|
||||
encoding:NSUTF8StringEncoding]
|
||||
};
|
||||
*error = [NSError errorWithDomain:kRTCRtpTransceiverErrorDomain
|
||||
code:static_cast<int>(nativeError.type())
|
||||
userInfo:userInfo];
|
||||
userInfo:@{
|
||||
@"message" : [NSString stringWithCString:nativeError.message()
|
||||
encoding:NSUTF8StringEncoding]
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
@ -159,28 +131,6 @@ NSString *const kRTCRtpTransceiverErrorDomain = @"org.webrtc.RTCRtpTranceiver";
|
||||
[self setCodecPreferences:codecs error:nil];
|
||||
}
|
||||
|
||||
- (BOOL)setHeaderExtensionsToNegotiate:
|
||||
(NSArray<RTC_OBJC_TYPE(RTCRtpHeaderExtensionCapability) *> *)extensions
|
||||
error:(NSError **)error {
|
||||
std::vector<webrtc::RtpHeaderExtensionCapability> headerExtensionCapabilities;
|
||||
for (RTC_OBJC_TYPE(RTCRtpHeaderExtensionCapability) * extension in extensions) {
|
||||
headerExtensionCapabilities.push_back(extension.nativeRtpHeaderExtensionCapability);
|
||||
}
|
||||
webrtc::RTCError nativeError =
|
||||
_nativeRtpTransceiver->SetHeaderExtensionsToNegotiate(headerExtensionCapabilities);
|
||||
BOOL ok = nativeError.ok();
|
||||
if (!ok && error) {
|
||||
NSDictionary *userInfo =
|
||||
@{NSLocalizedDescriptionKey : [NSString stringWithCString:nativeError.message()
|
||||
encoding:NSUTF8StringEncoding]
|
||||
};
|
||||
*error = [NSError errorWithDomain:kRTCRtpTransceiverErrorDomain
|
||||
code:static_cast<int>(nativeError.type())
|
||||
userInfo:userInfo];
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
- (NSString *)description {
|
||||
return [NSString
|
||||
stringWithFormat:@"RTC_OBJC_TYPE(RTCRtpTransceiver) {\n sender: %@\n receiver: %@\n}",
|
||||
|
||||
@ -21,7 +21,6 @@
|
||||
#import "api/peerconnection/RTCPeerConnectionFactory.h"
|
||||
#import "api/peerconnection/RTCRtpCapabilities.h"
|
||||
#import "api/peerconnection/RTCRtpCodecCapability.h"
|
||||
#import "api/peerconnection/RTCRtpHeaderExtensionCapability.h"
|
||||
#import "api/peerconnection/RTCRtpReceiver.h"
|
||||
#import "api/peerconnection/RTCRtpSender.h"
|
||||
#import "api/peerconnection/RTCRtpTransceiver.h"
|
||||
@ -511,131 +510,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)testSetHeaderExtensionsToNegotiate {
|
||||
@autoreleasepool {
|
||||
RTC_OBJC_TYPE(RTCConfiguration) *config = [[RTC_OBJC_TYPE(RTCConfiguration) alloc] init];
|
||||
RTC_OBJC_TYPE(RTCMediaConstraints) *constraints =
|
||||
[[RTC_OBJC_TYPE(RTCMediaConstraints) alloc] initWithMandatoryConstraints:nil
|
||||
optionalConstraints:nil];
|
||||
RTC_OBJC_TYPE(RTCRtpTransceiverInit) *init =
|
||||
[[RTC_OBJC_TYPE(RTCRtpTransceiverInit) alloc] init];
|
||||
|
||||
RTC_OBJC_TYPE(RTCPeerConnectionFactory) * factory;
|
||||
RTC_OBJC_TYPE(RTCPeerConnection) * peerConnection;
|
||||
RTC_OBJC_TYPE(RTCRtpTransceiver) * tranceiver;
|
||||
factory = [[RTC_OBJC_TYPE(RTCPeerConnectionFactory) alloc] init];
|
||||
|
||||
peerConnection = [factory peerConnectionWithConfiguration:config
|
||||
constraints:constraints
|
||||
delegate:nil];
|
||||
tranceiver = [peerConnection addTransceiverOfType:RTCRtpMediaTypeVideo init:init];
|
||||
XCTAssertNotNil(tranceiver);
|
||||
|
||||
NSArray<RTC_OBJC_TYPE(RTCRtpHeaderExtensionCapability) *> *headerExtensionsToNegotiate =
|
||||
tranceiver.headerExtensionsToNegotiate;
|
||||
|
||||
__block RTC_OBJC_TYPE(RTCRtpHeaderExtensionCapability) *targetExtension = nil;
|
||||
[headerExtensionsToNegotiate
|
||||
enumerateObjectsUsingBlock:^(RTC_OBJC_TYPE(RTCRtpHeaderExtensionCapability) * extension,
|
||||
NSUInteger idx,
|
||||
BOOL * stop) {
|
||||
if ([extension.uri isEqualToString:@"urn:ietf:params:rtp-hdrext:sdes:mid"]) {
|
||||
targetExtension = extension;
|
||||
} else {
|
||||
extension.direction = RTCRtpTransceiverDirectionStopped;
|
||||
}
|
||||
}];
|
||||
|
||||
NSError *error = nil;
|
||||
BOOL isOK = [tranceiver setHeaderExtensionsToNegotiate:headerExtensionsToNegotiate
|
||||
error:&error];
|
||||
XCTAssertNil(error);
|
||||
XCTAssertTrue(isOK);
|
||||
|
||||
@autoreleasepool {
|
||||
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
|
||||
|
||||
__block BOOL completed = NO;
|
||||
[peerConnection offerForConstraints:constraints
|
||||
completionHandler:^(RTC_OBJC_TYPE(RTCSessionDescription) *_Nullable sdp,
|
||||
NSError *_Nullable error) {
|
||||
XCTAssertNil(error);
|
||||
XCTAssertNotNil(sdp);
|
||||
|
||||
NSArray<NSString *> *extMaps = [self extMapsFromSDP:sdp.sdp];
|
||||
XCTAssertEqual(1, extMaps.count);
|
||||
|
||||
XCTAssertNotNil(targetExtension);
|
||||
XCTAssertNotNil(targetExtension.preferredId);
|
||||
|
||||
NSString *expected =
|
||||
[NSString stringWithFormat:@"a=extmap:%i %@",
|
||||
targetExtension.preferredId.intValue,
|
||||
targetExtension.uri];
|
||||
|
||||
XCTAssertTrue([expected isEqualToString:extMaps[0]]);
|
||||
|
||||
completed = YES;
|
||||
dispatch_semaphore_signal(semaphore);
|
||||
}];
|
||||
|
||||
[peerConnection close];
|
||||
peerConnection = nil;
|
||||
factory = nil;
|
||||
tranceiver = nil;
|
||||
|
||||
dispatch_semaphore_wait(semaphore, dispatch_time(DISPATCH_TIME_NOW, 15.0 * NSEC_PER_SEC));
|
||||
XCTAssertTrue(completed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)testSetHeaderExtensionsToNegotiateError {
|
||||
@autoreleasepool {
|
||||
RTC_OBJC_TYPE(RTCConfiguration) *config = [[RTC_OBJC_TYPE(RTCConfiguration) alloc] init];
|
||||
RTC_OBJC_TYPE(RTCMediaConstraints) *constraints =
|
||||
[[RTC_OBJC_TYPE(RTCMediaConstraints) alloc] initWithMandatoryConstraints:nil
|
||||
optionalConstraints:nil];
|
||||
RTC_OBJC_TYPE(RTCRtpTransceiverInit) *init =
|
||||
[[RTC_OBJC_TYPE(RTCRtpTransceiverInit) alloc] init];
|
||||
|
||||
RTC_OBJC_TYPE(RTCPeerConnectionFactory) * factory;
|
||||
RTC_OBJC_TYPE(RTCPeerConnection) * peerConnection;
|
||||
RTC_OBJC_TYPE(RTCRtpTransceiver) * tranceiver;
|
||||
factory = [[RTC_OBJC_TYPE(RTCPeerConnectionFactory) alloc] init];
|
||||
|
||||
peerConnection = [factory peerConnectionWithConfiguration:config
|
||||
constraints:constraints
|
||||
delegate:nil];
|
||||
tranceiver = [peerConnection addTransceiverOfType:RTCRtpMediaTypeVideo init:init];
|
||||
XCTAssertNotNil(tranceiver);
|
||||
|
||||
NSArray<RTC_OBJC_TYPE(RTCRtpHeaderExtensionCapability) *> *headerExtensionsToNegotiate =
|
||||
tranceiver.headerExtensionsToNegotiate;
|
||||
|
||||
[headerExtensionsToNegotiate
|
||||
enumerateObjectsUsingBlock:^(RTC_OBJC_TYPE(RTCRtpHeaderExtensionCapability) * extension,
|
||||
NSUInteger idx,
|
||||
BOOL * stop) {
|
||||
if ([extension.uri isEqualToString:@"urn:ietf:params:rtp-hdrext:sdes:mid"]) {
|
||||
extension.direction = RTCRtpTransceiverDirectionStopped;
|
||||
}
|
||||
}];
|
||||
|
||||
// Stopping a mandatory extension should yield an error
|
||||
NSError *error = nil;
|
||||
BOOL isOK = [tranceiver setHeaderExtensionsToNegotiate:headerExtensionsToNegotiate
|
||||
error:&error];
|
||||
XCTAssertNotNil(error);
|
||||
XCTAssertFalse(isOK);
|
||||
|
||||
[peerConnection close];
|
||||
peerConnection = nil;
|
||||
factory = nil;
|
||||
tranceiver = nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (bool)negotiatePeerConnection:(RTC_OBJC_TYPE(RTCPeerConnection) *)pc1
|
||||
withPeerConnection:(RTC_OBJC_TYPE(RTCPeerConnection) *)pc2
|
||||
negotiationTimeout:(NSTimeInterval)timeout {
|
||||
@ -700,16 +574,4 @@
|
||||
return rtpMaps;
|
||||
}
|
||||
|
||||
- (NSArray<NSString *> *)extMapsFromSDP:(NSString *)sdp {
|
||||
NSMutableArray<NSString *> *extMaps = [NSMutableArray new];
|
||||
NSArray *sdpLines =
|
||||
[sdp componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]];
|
||||
for (NSString *line in sdpLines) {
|
||||
if ([line hasPrefix:@"a=extmap:"]) {
|
||||
[extMaps addObject:line];
|
||||
}
|
||||
}
|
||||
return extMaps;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user