gpt4 book ai didi

ios - RTCPeerConnectionFactory.peerConnectionWithConfiguration 导致IOS模拟器崩溃

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:54:27 29 4
gpt4 key购买 nike

我正在试验 WebTRC IOS 库。我试过了 https://cocoapods.org/pods/webrtc-frameworkhttps://cocoapods.org/pods/WebRTC

每当我尝试初始化 RTCPeerConnection 并将其分配给局部变量时,应用程序就会崩溃。带有 EXC_BAD_ACCESS 错误代码。

这是我的代码:

@interface WebRTCDelegate ()

@property (nonatomic, strong) SRWebSocket* webSocket;
@property(nonatomic) RTCPeerConnection *peerConnection;

@end

@implementation WebRTCDelegate
...
- (void)initRTCPeerConnection
{
NSArray<RTCIceServer *> *iceServers = [NSArray arrayWithObjects:[[RTCIceServer alloc] initWithURLStrings:[NSArray arrayWithObjects:@"stun:stun.services.mozilla.com", nil]], [[RTCIceServer alloc] initWithURLStrings:[NSArray arrayWithObjects:@"stun:stun.l.google.com:19302", nil]] , nil];

RTCConfiguration *config = [[RTCConfiguration alloc] init];
[config setIceServers:iceServers];

NSDictionary *mandatoryConstraints = @{
@"OfferToReceiveAudio" : @"true",
@"OfferToReceiveVideo" : @"true",
};
RTCMediaConstraints* constraints = [[RTCMediaConstraints alloc] initWithMandatoryConstraints:mandatoryConstraints optionalConstraints:nil];

RTCPeerConnectionFactory *pcFactory = [[RTCPeerConnectionFactory alloc] init];
_peerConnection = [pcFactory peerConnectionWithConfiguration:config constraints:constraints delegate:self];
}

...

@end

这是错误:

0x108895cbd <+115>: movq   0x38(%rax), %r13
0x108895cc1 <+119>: leaq 0x4f1891(%rip), %rsi ; "OnMessage"
0x108895cc8 <+126>: leaq 0x4f1894(%rip), %rdx ; "../../webrtc/base/rtccertificategenerator.cc:69"

我的代码有什么问题吗?

谢谢!

最佳答案

尽量使工厂对象保持事件状态。

@interface WebRTCDelegate ()

@property (nonatomic) SRWebSocket *webSocket;
@property (nonatomic) RTCPeerConnectionFactory *factory;
@property (nonatomic) RTCPeerConnection *peerConnection;

@end

@implementation WebRTCDelegate

...

- (id)init
{
self = [super init];
if (self != nil)
{
factory = [[RTCPeerConnectionFactory alloc] init];
}
return self;
}

- (void)initRTCPeerConnection
{
NSArray<RTCIceServer *> *iceServers = [NSArray arrayWithObjects:[[RTCIceServer alloc] initWithURLStrings:[NSArray arrayWithObjects:@"stun:stun.services.mozilla.com", nil]], [[RTCIceServer alloc] initWithURLStrings:[NSArray arrayWithObjects:@"stun:stun.l.google.com:19302", nil]] , nil];

RTCConfiguration *config = [[RTCConfiguration alloc] init];
[config setIceServers:iceServers];

NSDictionary *mandatoryConstraints = @{
@"OfferToReceiveAudio" : @"true",
@"OfferToReceiveVideo" : @"true",
};
RTCMediaConstraints* constraints = [[RTCMediaConstraints alloc] initWithMandatoryConstraints:mandatoryConstraints optionalConstraints:nil];
_peerConnection = [_factory peerConnectionWithConfiguration:config constraints:constraints delegate:self];
}

...

@end

关于ios - RTCPeerConnectionFactory.peerConnectionWithConfiguration 导致IOS模拟器崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44350199/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com