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

Side by Side Diff: webrtc/sdk/objc/Framework/Classes/RTCSessionDescription.mm

Issue 2890733003: Reland of Split iOS sdk in to separate targets (Closed)
Patch Set: Created 3 years, 7 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 2015 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 "RTCSessionDescription+Private.h"
12
13 #import "NSString+StdString.h"
14 #import "WebRTC/RTCLogging.h"
15
16 #include "webrtc/base/checks.h"
17
18 @implementation RTCSessionDescription
19
20 @synthesize type = _type;
21 @synthesize sdp = _sdp;
22
23 + (NSString *)stringForType:(RTCSdpType)type {
24 std::string string = [[self class] stdStringForType:type];
25 return [NSString stringForStdString:string];
26 }
27
28 + (RTCSdpType)typeForString:(NSString *)string {
29 std::string typeString = string.stdString;
30 return [[self class] typeForStdString:typeString];
31 }
32
33 - (instancetype)initWithType:(RTCSdpType)type sdp:(NSString *)sdp {
34 NSParameterAssert(sdp.length);
35 if (self = [super init]) {
36 _type = type;
37 _sdp = [sdp copy];
38 }
39 return self;
40 }
41
42 - (NSString *)description {
43 return [NSString stringWithFormat:@"RTCSessionDescription:\n%@\n%@",
44 [[self class] stringForType:_type],
45 _sdp];
46 }
47
48 #pragma mark - Private
49
50 - (webrtc::SessionDescriptionInterface *)nativeDescription {
51 webrtc::SdpParseError error;
52
53 webrtc::SessionDescriptionInterface *description =
54 webrtc::CreateSessionDescription([[self class] stdStringForType:_type],
55 _sdp.stdString,
56 &error);
57
58 if (!description) {
59 RTCLogError(@"Failed to create session description: %s\nline: %s",
60 error.description.c_str(),
61 error.line.c_str());
62 }
63
64 return description;
65 }
66
67 - (instancetype)initWithNativeDescription:
68 (const webrtc::SessionDescriptionInterface *)nativeDescription {
69 NSParameterAssert(nativeDescription);
70 std::string sdp;
71 nativeDescription->ToString(&sdp);
72 RTCSdpType type = [[self class] typeForStdString:nativeDescription->type()];
73
74 return [self initWithType:type
75 sdp:[NSString stringForStdString:sdp]];
76 }
77
78 + (std::string)stdStringForType:(RTCSdpType)type {
79 switch (type) {
80 case RTCSdpTypeOffer:
81 return webrtc::SessionDescriptionInterface::kOffer;
82 case RTCSdpTypePrAnswer:
83 return webrtc::SessionDescriptionInterface::kPrAnswer;
84 case RTCSdpTypeAnswer:
85 return webrtc::SessionDescriptionInterface::kAnswer;
86 }
87 }
88
89 + (RTCSdpType)typeForStdString:(const std::string &)string {
90 if (string == webrtc::SessionDescriptionInterface::kOffer) {
91 return RTCSdpTypeOffer;
92 } else if (string == webrtc::SessionDescriptionInterface::kPrAnswer) {
93 return RTCSdpTypePrAnswer;
94 } else if (string == webrtc::SessionDescriptionInterface::kAnswer) {
95 return RTCSdpTypeAnswer;
96 } else {
97 RTC_NOTREACHED();
98 return RTCSdpTypeOffer;
99 }
100 }
101
102 @end
OLDNEW
« no previous file with comments | « webrtc/sdk/objc/Framework/Classes/RTCSSLAdapter.mm ('k') | webrtc/sdk/objc/Framework/Classes/RTCSessionDescription+Private.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698