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

Unified Diff: webrtc/examples/objc/AppRTCDemo/RTCSessionDescription+JSON.m

Issue 1690313002: Update iOS AppRTCDemo to use the updated Objective-C API. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 10 months 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/examples/objc/AppRTCDemo/RTCSessionDescription+JSON.m
diff --git a/webrtc/examples/objc/AppRTCDemo/RTCSessionDescription+JSON.m b/webrtc/examples/objc/AppRTCDemo/RTCSessionDescription+JSON.m
index b5655e0e8224d129672d4886616896acd37d7b74..9a7bb5142463ea22e89fcf15439f20052b452934 100644
--- a/webrtc/examples/objc/AppRTCDemo/RTCSessionDescription+JSON.m
+++ b/webrtc/examples/objc/AppRTCDemo/RTCSessionDescription+JSON.m
@@ -15,17 +15,42 @@ static NSString const *kRTCSessionDescriptionSdpKey = @"sdp";
@implementation RTCSessionDescription (JSON)
++ (NSString *)stringForType:(RTCSdpType)type {
hjon_webrtc 2016/02/12 17:34:56 Both this class and ARDSignalingMessage currently
+ switch (type) {
+ case RTCSdpTypeOffer:
+ return @"offer";
+ case RTCSdpTypePrAnswer:
+ return @"pranswer";
+ case RTCSdpTypeAnswer:
+ return @"answer";
+ }
+}
+
++ (RTCSdpType)typeForString:(NSString *)string {
+ if ([string isEqualToString:@"offer"]) {
+ return RTCSdpTypeOffer;
+ } else if ([string isEqualToString:@"pranswer"]) {
+ return RTCSdpTypePrAnswer;
+ } else if ([string isEqualToString:@"answer"]) {
+ return RTCSdpTypeAnswer;
+ } else {
+ return RTCSdpTypeOffer;
+ }
+}
+
+ (RTCSessionDescription *)descriptionFromJSONDictionary:
(NSDictionary *)dictionary {
- NSString *type = dictionary[kRTCSessionDescriptionTypeKey];
+ NSString *typeString = dictionary[kRTCSessionDescriptionTypeKey];
+ RTCSdpType type = [[self class] typeForString:typeString];
NSString *sdp = dictionary[kRTCSessionDescriptionSdpKey];
return [[RTCSessionDescription alloc] initWithType:type sdp:sdp];
}
- (NSData *)JSONData {
+ NSString *type = [[self class] stringForType:self.type];
NSDictionary *json = @{
- kRTCSessionDescriptionTypeKey : self.type,
- kRTCSessionDescriptionSdpKey : self.description
+ kRTCSessionDescriptionTypeKey : type,
+ kRTCSessionDescriptionSdpKey : self.sdp
};
return [NSJSONSerialization dataWithJSONObject:json options:0 error:nil];
}

Powered by Google App Engine
This is Rietveld 408576698