OLD | NEW |
---|---|
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2014 Google Inc. | 3 * Copyright 2014 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
11 * this list of conditions and the following disclaimer in the documentation | 11 * this list of conditions and the following disclaimer in the documentation |
12 * and/or other materials provided with the distribution. | 12 * and/or other materials provided with the distribution. |
13 * 3. The name of the author may not be used to endorse or promote products | 13 * 3. The name of the author may not be used to endorse or promote products |
14 * derived from this software without specific prior written permission. | 14 * derived from this software without specific prior written permission. |
15 * | 15 * |
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED | 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO | 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; | 21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | 22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | 23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | 24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 */ | 26 */ |
27 | 27 |
28 #import "ARDSignalingMessage.h" | 28 #import "ARDSignalingMessage.h" |
29 | 29 |
30 #import "ARDLogging.h" | 30 #import "RTCLogging.h" |
Chuck
2015/07/23 18:21:45
Should this be grouped with the other RTC headers?
tkchin_webrtc
2015/07/23 18:30:00
No, the ones at the bottom are extensions added by
| |
31 | |
31 #import "ARDUtilities.h" | 32 #import "ARDUtilities.h" |
32 #import "RTCICECandidate+JSON.h" | 33 #import "RTCICECandidate+JSON.h" |
33 #import "RTCSessionDescription+JSON.h" | 34 #import "RTCSessionDescription+JSON.h" |
34 | 35 |
35 static NSString const *kARDSignalingMessageTypeKey = @"type"; | 36 static NSString const *kARDSignalingMessageTypeKey = @"type"; |
36 | 37 |
37 @implementation ARDSignalingMessage | 38 @implementation ARDSignalingMessage |
38 | 39 |
39 @synthesize type = _type; | 40 @synthesize type = _type; |
40 | 41 |
41 - (instancetype)initWithType:(ARDSignalingMessageType)type { | 42 - (instancetype)initWithType:(ARDSignalingMessageType)type { |
42 if (self = [super init]) { | 43 if (self = [super init]) { |
43 _type = type; | 44 _type = type; |
44 } | 45 } |
45 return self; | 46 return self; |
46 } | 47 } |
47 | 48 |
48 - (NSString *)description { | 49 - (NSString *)description { |
49 return [[NSString alloc] initWithData:[self JSONData] | 50 return [[NSString alloc] initWithData:[self JSONData] |
50 encoding:NSUTF8StringEncoding]; | 51 encoding:NSUTF8StringEncoding]; |
51 } | 52 } |
52 | 53 |
53 + (ARDSignalingMessage *)messageFromJSONString:(NSString *)jsonString { | 54 + (ARDSignalingMessage *)messageFromJSONString:(NSString *)jsonString { |
54 NSDictionary *values = [NSDictionary dictionaryWithJSONString:jsonString]; | 55 NSDictionary *values = [NSDictionary dictionaryWithJSONString:jsonString]; |
55 if (!values) { | 56 if (!values) { |
56 ARDLog(@"Error parsing signaling message JSON."); | 57 RTCLogError(@"Error parsing signaling message JSON."); |
57 return nil; | 58 return nil; |
58 } | 59 } |
59 | 60 |
60 NSString *typeString = values[kARDSignalingMessageTypeKey]; | 61 NSString *typeString = values[kARDSignalingMessageTypeKey]; |
61 ARDSignalingMessage *message = nil; | 62 ARDSignalingMessage *message = nil; |
62 if ([typeString isEqualToString:@"candidate"]) { | 63 if ([typeString isEqualToString:@"candidate"]) { |
63 RTCICECandidate *candidate = | 64 RTCICECandidate *candidate = |
64 [RTCICECandidate candidateFromJSONDictionary:values]; | 65 [RTCICECandidate candidateFromJSONDictionary:values]; |
65 message = [[ARDICECandidateMessage alloc] initWithCandidate:candidate]; | 66 message = [[ARDICECandidateMessage alloc] initWithCandidate:candidate]; |
66 } else if ([typeString isEqualToString:@"offer"] || | 67 } else if ([typeString isEqualToString:@"offer"] || |
67 [typeString isEqualToString:@"answer"]) { | 68 [typeString isEqualToString:@"answer"]) { |
68 RTCSessionDescription *description = | 69 RTCSessionDescription *description = |
69 [RTCSessionDescription descriptionFromJSONDictionary:values]; | 70 [RTCSessionDescription descriptionFromJSONDictionary:values]; |
70 message = | 71 message = |
71 [[ARDSessionDescriptionMessage alloc] initWithDescription:description]; | 72 [[ARDSessionDescriptionMessage alloc] initWithDescription:description]; |
72 } else if ([typeString isEqualToString:@"bye"]) { | 73 } else if ([typeString isEqualToString:@"bye"]) { |
73 message = [[ARDByeMessage alloc] init]; | 74 message = [[ARDByeMessage alloc] init]; |
74 } else { | 75 } else { |
75 ARDLog(@"Unexpected type: %@", typeString); | 76 RTCLogError(@"Unexpected type: %@", typeString); |
76 } | 77 } |
77 return message; | 78 return message; |
78 } | 79 } |
79 | 80 |
80 - (NSData *)JSONData { | 81 - (NSData *)JSONData { |
81 return nil; | 82 return nil; |
82 } | 83 } |
83 | 84 |
84 @end | 85 @end |
85 | 86 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
135 - (NSData *)JSONData { | 136 - (NSData *)JSONData { |
136 NSDictionary *message = @{ | 137 NSDictionary *message = @{ |
137 @"type": @"bye" | 138 @"type": @"bye" |
138 }; | 139 }; |
139 return [NSJSONSerialization dataWithJSONObject:message | 140 return [NSJSONSerialization dataWithJSONObject:message |
140 options:NSJSONWritingPrettyPrinted | 141 options:NSJSONWritingPrettyPrinted |
141 error:NULL]; | 142 error:NULL]; |
142 } | 143 } |
143 | 144 |
144 @end | 145 @end |
OLD | NEW |