blob: 1ded45d670b31377a6c65a102d7edb9138da699f [file] [log] [blame]
hjonf396f602016-02-11 16:19:06 -08001/*
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
tkchin9eeb6242016-04-27 01:54:20 -070011#import "RTCPeerConnection+Private.h"
hjonf396f602016-02-11 16:19:06 -080012
tkchin9eeb6242016-04-27 01:54:20 -070013#import "RTCDataChannel+Private.h"
14#import "RTCDataChannelConfiguration+Private.h"
Anders Carlsson7bca8ca2018-08-30 09:30:29 +020015#import "helpers/NSString+StdString.h"
hjonf396f602016-02-11 16:19:06 -080016
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020017@implementation RTC_OBJC_TYPE (RTCPeerConnection)
18(DataChannel)
hjonf396f602016-02-11 16:19:06 -080019
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020020 - (nullable RTC_OBJC_TYPE(RTCDataChannel) *)dataChannelForLabel
21 : (NSString *)label configuration
22 : (RTC_OBJC_TYPE(RTCDataChannelConfiguration) *)configuration {
hjonf396f602016-02-11 16:19:06 -080023 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);
deadbeef299c8e02017-05-05 10:00:18 -070029 if (!dataChannel) {
30 return nil;
31 }
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020032 return [[RTC_OBJC_TYPE(RTCDataChannel) alloc] initWithFactory:self.factory
33 nativeDataChannel:dataChannel];
hjonf396f602016-02-11 16:19:06 -080034}
35
36@end