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"
|
2022-05-13 14:46:42 +00:00
|
|
|
#import "helpers/NSString+StdString.h"
|
2016-02-11 16:19:06 -08:00
|
|
|
|
2020-05-04 16:14:32 +02:00
|
|
|
@implementation RTC_OBJC_TYPE (RTCPeerConnection)
|
|
|
|
|
(DataChannel)
|
2016-02-11 16:19:06 -08:00
|
|
|
|
2020-05-04 16:14:32 +02:00
|
|
|
- (nullable RTC_OBJC_TYPE(RTCDataChannel) *)dataChannelForLabel
|
|
|
|
|
: (NSString *)label configuration
|
|
|
|
|
: (RTC_OBJC_TYPE(RTCDataChannelConfiguration) *)configuration {
|
2022-05-13 14:46:42 +00:00
|
|
|
std::string labelString = [NSString stdStringForString:label];
|
2016-02-11 16:19:06 -08:00
|
|
|
const webrtc::DataChannelInit nativeInit =
|
|
|
|
|
configuration.nativeDataChannelInit;
|
2025-01-08 05:45:56 -08:00
|
|
|
auto result = self.nativePeerConnection->CreateDataChannelOrError(
|
|
|
|
|
labelString, &nativeInit);
|
2021-05-21 13:33:51 +00:00
|
|
|
if (!result.ok()) {
|
2017-05-05 10:00:18 -07:00
|
|
|
return nil;
|
|
|
|
|
}
|
2025-01-08 05:45:56 -08:00
|
|
|
return [[RTC_OBJC_TYPE(RTCDataChannel) alloc]
|
|
|
|
|
initWithFactory:self.factory
|
|
|
|
|
nativeDataChannel:result.MoveValue()];
|
2016-02-11 16:19:06 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@end
|