2016-02-11 16:19:06 -08:00
|
|
|
/*
|
|
|
|
|
* Copyright 2015 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2016-04-27 01:54:20 -07:00
|
|
|
#import "RTCPeerConnection+Private.h"
|
2016-02-11 16:19:06 -08:00
|
|
|
|
2016-04-27 01:54:20 -07:00
|
|
|
#import "RTCDataChannel+Private.h"
|
|
|
|
|
#import "RTCDataChannelConfiguration+Private.h"
|
2018-08-30 09:30:29 +02:00
|
|
|
#import "helpers/NSString+StdString.h"
|
2016-02-11 16:19:06 -08:00
|
|
|
|
|
|
|
|
@implementation RTCPeerConnection (DataChannel)
|
|
|
|
|
|
2018-01-12 16:16:18 +01:00
|
|
|
- (nullable RTCDataChannel *)dataChannelForLabel:(NSString *)label
|
|
|
|
|
configuration:(RTCDataChannelConfiguration *)configuration {
|
2016-02-11 16:19:06 -08:00
|
|
|
std::string labelString = [NSString stdStringForString:label];
|
|
|
|
|
const webrtc::DataChannelInit nativeInit =
|
|
|
|
|
configuration.nativeDataChannelInit;
|
|
|
|
|
rtc::scoped_refptr<webrtc::DataChannelInterface> dataChannel =
|
|
|
|
|
self.nativePeerConnection->CreateDataChannel(labelString,
|
|
|
|
|
&nativeInit);
|
2017-05-05 10:00:18 -07:00
|
|
|
if (!dataChannel) {
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
2018-06-27 17:09:14 +03:00
|
|
|
return [[RTCDataChannel alloc] initWithFactory:self.factory nativeDataChannel:dataChannel];
|
2016-02-11 16:19:06 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@end
|