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, |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 | 146 |
147 @end | 147 @end |
148 | 148 |
149 @implementation RTCDataBuffer { | 149 @implementation RTCDataBuffer { |
150 std::unique_ptr<webrtc::DataBuffer> _dataBuffer; | 150 std::unique_ptr<webrtc::DataBuffer> _dataBuffer; |
151 } | 151 } |
152 | 152 |
153 - (instancetype)initWithData:(NSData*)data isBinary:(BOOL)isBinary { | 153 - (instancetype)initWithData:(NSData*)data isBinary:(BOOL)isBinary { |
154 NSAssert(data, @"data cannot be nil"); | 154 NSAssert(data, @"data cannot be nil"); |
155 if (self = [super init]) { | 155 if (self = [super init]) { |
156 rtc::Buffer buffer(reinterpret_cast<const uint8_t*>([data bytes]), | 156 rtc::CopyOnWriteBuffer buffer( |
157 [data length]); | 157 reinterpret_cast<const uint8_t*>([data bytes]), [data length]); |
158 _dataBuffer.reset(new webrtc::DataBuffer(buffer, isBinary)); | 158 _dataBuffer.reset(new webrtc::DataBuffer(buffer, isBinary)); |
159 } | 159 } |
160 return self; | 160 return self; |
161 } | 161 } |
162 | 162 |
163 - (NSData*)data { | 163 - (NSData*)data { |
164 return [NSData dataWithBytes:_dataBuffer->data.data() | 164 return [NSData dataWithBytes:_dataBuffer->data.data() |
165 length:_dataBuffer->data.size()]; | 165 length:_dataBuffer->data.size()]; |
166 } | 166 } |
167 | 167 |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 _observer.reset(new webrtc::RTCDataChannelObserver(self)); | 283 _observer.reset(new webrtc::RTCDataChannelObserver(self)); |
284 } | 284 } |
285 return self; | 285 return self; |
286 } | 286 } |
287 | 287 |
288 - (rtc::scoped_refptr<webrtc::DataChannelInterface>)dataChannel { | 288 - (rtc::scoped_refptr<webrtc::DataChannelInterface>)dataChannel { |
289 return _dataChannel; | 289 return _dataChannel; |
290 } | 290 } |
291 | 291 |
292 @end | 292 @end |
OLD | NEW |