blob: 6c84fa3f613a46430aec6549c55c52a3bbde0363 [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
17@implementation RTCPeerConnection (DataChannel)
18
Peter Hanspersd9b64cd2018-01-12 16:16:18 +010019- (nullable RTCDataChannel *)dataChannelForLabel:(NSString *)label
20 configuration:(RTCDataChannelConfiguration *)configuration {
hjonf396f602016-02-11 16:19:06 -080021 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);
deadbeef299c8e02017-05-05 10:00:18 -070027 if (!dataChannel) {
28 return nil;
29 }
Yura Yaroshevichc75b35a2018-06-27 17:09:14 +030030 return [[RTCDataChannel alloc] initWithFactory:self.factory nativeDataChannel:dataChannel];
hjonf396f602016-02-11 16:19:06 -080031}
32
33@end