Revert "An RTCSessionDescription will now return nil from its initializer if the SDP passed to it is invalid."
This reverts commit 48cd9dbc5067f266b07541d2eebfb4b88fe455d4. Reason for revert: Breaks downstream project. Original change's description: > An RTCSessionDescription will now return nil from its initializer if the SDP passed to it is invalid. > > Bug: webrtc:13022 > Change-Id: I2f2ad96884cf2f43f5ea95c1210470dd6aa5c919 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/226980 > Commit-Queue: Jake Bromberg <jakebromberg@google.com> > Reviewed-by: Harald Alvestrand <hta@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#34607} TBR=peah@webrtc.org,hta@webrtc.org,webrtc-scoped@luci-project-accounts.iam.gserviceaccount.com,jakebromberg@google.com Change-Id: Iee05f747e472208f8776944df15d9206485b167e No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:13022 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/227341 Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#34615}
This commit is contained in:
committed by
WebRTC LUCI CQ
parent
e0df4314ac
commit
f48d3cfbab
@ -36,10 +36,8 @@ RTC_OBJC_EXPORT
|
||||
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
/** Initialize a session description with a type and SDP string. Returns nil if the sdp is invalid.
|
||||
*/
|
||||
- (nullable instancetype)initWithType:(RTCSdpType)type
|
||||
sdp:(NSString *)sdp NS_DESIGNATED_INITIALIZER;
|
||||
/** Initialize a session description with a type and SDP string. */
|
||||
- (instancetype)initWithType:(RTCSdpType)type sdp:(NSString *)sdp NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
+ (NSString *)stringForType:(RTCSdpType)type;
|
||||
|
||||
|
||||
@ -17,45 +17,23 @@
|
||||
|
||||
@implementation RTC_OBJC_TYPE (RTCSessionDescription)
|
||||
|
||||
@synthesize nativeDescription = _nativeDescription;
|
||||
@synthesize type = _type;
|
||||
@synthesize sdp = _sdp;
|
||||
|
||||
+ (NSString *)stringForType:(RTCSdpType)type {
|
||||
std::string string = [self stdStringForType:type];
|
||||
std::string string = [[self class] stdStringForType:type];
|
||||
return [NSString stringForStdString:string];
|
||||
}
|
||||
|
||||
+ (RTCSdpType)typeForString:(NSString *)string {
|
||||
std::string typeString = string.stdString;
|
||||
return [self typeForStdString:typeString];
|
||||
return [[self class] typeForStdString:typeString];
|
||||
}
|
||||
|
||||
+ (webrtc::SessionDescriptionInterface *)nativeDescriptionForString:(NSString *)sdp
|
||||
type:(RTCSdpType)type {
|
||||
webrtc::SdpParseError error;
|
||||
|
||||
webrtc::SessionDescriptionInterface *description =
|
||||
webrtc::CreateSessionDescription([self stdStringForType:type], sdp.stdString, &error);
|
||||
|
||||
if (!description) {
|
||||
RTCLogError(@"Failed to create session description: %s\nline: %s",
|
||||
error.description.c_str(),
|
||||
error.line.c_str());
|
||||
}
|
||||
|
||||
return description;
|
||||
}
|
||||
|
||||
- (nullable instancetype)initWithType:(RTCSdpType)type sdp:(NSString *)sdp {
|
||||
- (instancetype)initWithType:(RTCSdpType)type sdp:(NSString *)sdp {
|
||||
if (self = [super init]) {
|
||||
_type = type;
|
||||
_sdp = [sdp copy];
|
||||
_nativeDescription = [[self class] nativeDescriptionForString:_sdp type:_type];
|
||||
|
||||
if (_nativeDescription == nil) {
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@ -68,6 +46,23 @@
|
||||
|
||||
#pragma mark - Private
|
||||
|
||||
- (webrtc::SessionDescriptionInterface *)nativeDescription {
|
||||
webrtc::SdpParseError error;
|
||||
|
||||
webrtc::SessionDescriptionInterface *description =
|
||||
webrtc::CreateSessionDescription([[self class] stdStringForType:_type],
|
||||
_sdp.stdString,
|
||||
&error);
|
||||
|
||||
if (!description) {
|
||||
RTCLogError(@"Failed to create session description: %s\nline: %s",
|
||||
error.description.c_str(),
|
||||
error.line.c_str());
|
||||
}
|
||||
|
||||
return description;
|
||||
}
|
||||
|
||||
- (instancetype)initWithNativeDescription:
|
||||
(const webrtc::SessionDescriptionInterface *)nativeDescription {
|
||||
NSParameterAssert(nativeDescription);
|
||||
|
||||
@ -42,13 +42,6 @@
|
||||
EXPECT_EQ([self sdp].stdString, sdp);
|
||||
}
|
||||
|
||||
- (void)testInvalidSessionDescriptionConversion {
|
||||
RTC_OBJC_TYPE(RTCSessionDescription) *description =
|
||||
[[RTC_OBJC_TYPE(RTCSessionDescription) alloc] initWithType:RTCSdpTypeAnswer sdp:@"invalid"];
|
||||
|
||||
EXPECT_EQ(nil, description);
|
||||
}
|
||||
|
||||
- (void)testInitFromNativeSessionDescription {
|
||||
webrtc::SessionDescriptionInterface *nativeDescription;
|
||||
|
||||
@ -142,13 +135,6 @@ TEST(RTCSessionDescriptionTest, SessionDescriptionConversionTest) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST(RTCSessionDescriptionTest, InvalidSessionDescriptionConversionTest) {
|
||||
@autoreleasepool {
|
||||
RTCSessionDescriptionTest *test = [[RTCSessionDescriptionTest alloc] init];
|
||||
[test testInvalidSessionDescriptionConversion];
|
||||
}
|
||||
}
|
||||
|
||||
TEST(RTCSessionDescriptionTest, InitFromSessionDescriptionTest) {
|
||||
@autoreleasepool {
|
||||
RTCSessionDescriptionTest *test = [[RTCSessionDescriptionTest alloc] init];
|
||||
|
||||
Reference in New Issue
Block a user