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

Side by Side Diff: webrtc/examples/objc/AppRTCDemo/RTCICECandidate+JSON.m

Issue 1235563006: Move talk/examples/* to webrtc/examples. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: 201508051337 Created 5 years, 4 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 unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright 2014 The WebRTC Project Authors. All rights reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #import "RTCICECandidate+JSON.h"
12
13 #import "RTCLogging.h"
14
15 static NSString const *kRTCICECandidateTypeKey = @"type";
16 static NSString const *kRTCICECandidateTypeValue = @"candidate";
17 static NSString const *kRTCICECandidateMidKey = @"id";
18 static NSString const *kRTCICECandidateMLineIndexKey = @"label";
19 static NSString const *kRTCICECandidateSdpKey = @"candidate";
20
21 @implementation RTCICECandidate (JSON)
22
23 + (RTCICECandidate *)candidateFromJSONDictionary:(NSDictionary *)dictionary {
24 NSString *mid = dictionary[kRTCICECandidateMidKey];
25 NSString *sdp = dictionary[kRTCICECandidateSdpKey];
26 NSNumber *num = dictionary[kRTCICECandidateMLineIndexKey];
27 NSInteger mLineIndex = [num integerValue];
28 return [[RTCICECandidate alloc] initWithMid:mid index:mLineIndex sdp:sdp];
29 }
30
31 - (NSData *)JSONData {
32 NSDictionary *json = @{
33 kRTCICECandidateTypeKey : kRTCICECandidateTypeValue,
34 kRTCICECandidateMLineIndexKey : @(self.sdpMLineIndex),
35 kRTCICECandidateMidKey : self.sdpMid,
36 kRTCICECandidateSdpKey : self.sdp
37 };
38 NSError *error = nil;
39 NSData *data =
40 [NSJSONSerialization dataWithJSONObject:json
41 options:NSJSONWritingPrettyPrinted
42 error:&error];
43 if (error) {
44 RTCLogError(@"Error serializing JSON: %@", error);
45 return nil;
46 }
47 return data;
48 }
49
50 @end
OLDNEW
« no previous file with comments | « webrtc/examples/objc/AppRTCDemo/RTCICECandidate+JSON.h ('k') | webrtc/examples/objc/AppRTCDemo/RTCICEServer+JSON.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698