Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Unified Diff: webrtc/api/objc/RTCSessionDescription.mm

Issue 1524303006: Update API for Objective-C RTCSessionDescription. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@updateRTCIceCandidate
Patch Set: Rebase and add tests Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/api/objc/RTCSessionDescription.mm
diff --git a/webrtc/api/objc/RTCSessionDescription.mm b/webrtc/api/objc/RTCSessionDescription.mm
new file mode 100644
index 0000000000000000000000000000000000000000..c4737c222e5190656e363dd0dfba29ec4c63c39f
--- /dev/null
+++ b/webrtc/api/objc/RTCSessionDescription.mm
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2015 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#import "RTCSessionDescription.h"
+
+#import "webrtc/api/objc/RTCSessionDescription+Private.h"
+#import "webrtc/base/objc/NSString+StdString.h"
+ #import "webrtc/base/objc/RTCLogging.h"
tkchin_webrtc 2016/01/05 16:29:18 remove space
hjon 2016/01/05 22:16:20 Done.
+
+@implementation RTCSessionDescription
+
+@synthesize type = _type;
+@synthesize sdp = _sdp;
+
+- (instancetype)initWithType:(NSString *)type sdp:(NSString *)sdp {
+ NSParameterAssert(type);
+ NSParameterAssert(sdp);
+ if (self = [super init]) {
+ _type = [type copy];
tkchin_webrtc 2016/01/05 16:29:19 indents
hjon 2016/01/05 22:16:20 Done.
+ _sdp = [sdp copy];
+ }
+ return self;
+}
+
+- (NSString *)description {
+ return [NSString stringWithFormat:@"RTCSessionDescription:\n%@\n%@",
+ _type,
+ _sdp];
+}
+
+#pragma mark - Private
+
+- (webrtc::SessionDescriptionInterface *)nativeDescription {
+ webrtc::SessionDescriptionInterface *description;
+ webrtc::SdpParseError error;
+
+ description = webrtc::CreateSessionDescription(_type.stdString,
tkchin_webrtc 2016/01/05 16:29:18 combine 41 and 44?
hjon 2016/01/05 22:16:20 Done.
+ _sdp.stdString,
+ &error);
+
+ if (!description) {
+ RTCLog(@"Failed to create session description: %s\nline: %s",
+ error.description.c_str(),
+ error.line.c_str());
+ }
+
+ return description;
+}
+
+- (instancetype)initWithDescription:(webrtc::SessionDescriptionInterface *)
tkchin_webrtc 2016/01/05 16:29:19 break after : instead of after *)
hjon 2016/01/05 22:16:20 Done.
+ description {
+ NSParameterAssert(description);
+ std::string sdp;
+ description->ToString(&sdp);
+
+ return [self initWithType:[NSString stringForStdString:description->type()]
tkchin_webrtc 2016/01/05 16:29:19 seems like initWithType:sdp: can be a designated i
hjon 2016/01/05 22:16:20 Done.
+ sdp:[NSString stringForStdString:sdp]];
+}
+
+@end

Powered by Google App Engine
This is Rietveld 408576698