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 | |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame^] | 17 | @implementation RTC_OBJC_TYPE (RTCPeerConnection) |
| 18 | (DataChannel) |
hjon | f396f60 | 2016-02-11 16:19:06 -0800 | [diff] [blame] | 19 | |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame^] | 20 | - (nullable RTC_OBJC_TYPE(RTCDataChannel) *)dataChannelForLabel |
| 21 | : (NSString *)label configuration |
| 22 | : (RTC_OBJC_TYPE(RTCDataChannelConfiguration) *)configuration { |
hjon | f396f60 | 2016-02-11 16:19:06 -0800 | [diff] [blame] | 23 | std::string labelString = [NSString stdStringForString:label]; |
| 24 | const webrtc::DataChannelInit nativeInit = |
| 25 | configuration.nativeDataChannelInit; |
| 26 | rtc::scoped_refptr<webrtc::DataChannelInterface> dataChannel = |
| 27 | self.nativePeerConnection->CreateDataChannel(labelString, |
| 28 | &nativeInit); |
deadbeef | 299c8e0 | 2017-05-05 10:00:18 -0700 | [diff] [blame] | 29 | if (!dataChannel) { |
| 30 | return nil; |
| 31 | } |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame^] | 32 | return [[RTC_OBJC_TYPE(RTCDataChannel) alloc] initWithFactory:self.factory |
| 33 | nativeDataChannel:dataChannel]; |
hjon | f396f60 | 2016-02-11 16:19:06 -0800 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | @end |