OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 } | 46 } |
47 | 47 |
48 | 48 |
49 @implementation RTCDataBuffer { | 49 @implementation RTCDataBuffer { |
50 rtc::scoped_ptr<webrtc::DataBuffer> _dataBuffer; | 50 rtc::scoped_ptr<webrtc::DataBuffer> _dataBuffer; |
51 } | 51 } |
52 | 52 |
53 - (instancetype)initWithData:(NSData *)data isBinary:(BOOL)isBinary { | 53 - (instancetype)initWithData:(NSData *)data isBinary:(BOOL)isBinary { |
54 NSParameterAssert(data); | 54 NSParameterAssert(data); |
55 if (self = [super init]) { | 55 if (self = [super init]) { |
56 rtc::Buffer buffer(reinterpret_cast<const uint8_t*>(data.bytes), | 56 rtc::CopyOnWriteBuffer buffer( |
57 data.length); | 57 reinterpret_cast<const uint8_t*>(data.bytes), data.length); |
58 _dataBuffer.reset(new webrtc::DataBuffer(buffer, isBinary)); | 58 _dataBuffer.reset(new webrtc::DataBuffer(buffer, isBinary)); |
59 } | 59 } |
60 return self; | 60 return self; |
61 } | 61 } |
62 | 62 |
63 - (NSData *)data { | 63 - (NSData *)data { |
64 return [NSData dataWithBytes:_dataBuffer->data.data() | 64 return [NSData dataWithBytes:_dataBuffer->data.data() |
65 length:_dataBuffer->data.size()]; | 65 length:_dataBuffer->data.size()]; |
66 } | 66 } |
67 | 67 |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 case RTCDataChannelStateOpen: | 214 case RTCDataChannelStateOpen: |
215 return @"Open"; | 215 return @"Open"; |
216 case RTCDataChannelStateClosing: | 216 case RTCDataChannelStateClosing: |
217 return @"Closing"; | 217 return @"Closing"; |
218 case RTCDataChannelStateClosed: | 218 case RTCDataChannelStateClosed: |
219 return @"Closed"; | 219 return @"Closed"; |
220 } | 220 } |
221 } | 221 } |
222 | 222 |
223 @end | 223 @end |
OLD | NEW |