hjon | f396f60 | 2016-02-11 16:19:06 -0800 | [diff] [blame] | 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 | |
tkchin | 9eeb624 | 2016-04-27 01:54:20 -0700 | [diff] [blame] | 11 | #import "RTCPeerConnection+Private.h" |
hjon | f396f60 | 2016-02-11 16:19:06 -0800 | [diff] [blame] | 12 | |
tkchin | 9eeb624 | 2016-04-27 01:54:20 -0700 | [diff] [blame] | 13 | #import "RTCDataChannel+Private.h" |
| 14 | #import "RTCDataChannelConfiguration+Private.h" |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 15 | #import "helpers/NSString+StdString.h" |
hjon | f396f60 | 2016-02-11 16:19:06 -0800 | [diff] [blame] | 16 | |
| 17 | @implementation RTCPeerConnection (DataChannel) |
| 18 | |
Peter Hanspers | d9b64cd | 2018-01-12 16:16:18 +0100 | [diff] [blame] | 19 | - (nullable RTCDataChannel *)dataChannelForLabel:(NSString *)label |
| 20 | configuration:(RTCDataChannelConfiguration *)configuration { |
hjon | f396f60 | 2016-02-11 16:19:06 -0800 | [diff] [blame] | 21 | std::string labelString = [NSString stdStringForString:label]; |
| 22 | const webrtc::DataChannelInit nativeInit = |
| 23 | configuration.nativeDataChannelInit; |
| 24 | rtc::scoped_refptr<webrtc::DataChannelInterface> dataChannel = |
| 25 | self.nativePeerConnection->CreateDataChannel(labelString, |
| 26 | &nativeInit); |
deadbeef | 299c8e0 | 2017-05-05 10:00:18 -0700 | [diff] [blame] | 27 | if (!dataChannel) { |
| 28 | return nil; |
| 29 | } |
Yura Yaroshevich | c75b35a | 2018-06-27 17:09:14 +0300 | [diff] [blame] | 30 | return [[RTCDataChannel alloc] initWithFactory:self.factory nativeDataChannel:dataChannel]; |
hjon | f396f60 | 2016-02-11 16:19:06 -0800 | [diff] [blame] | 31 | } |
| 32 | |
| 33 | @end |