2017-06-04 12 views
2

WebTRC IOSライブラリを試しています。 試しましたhttps://cocoapods.org/pods/webrtc-frameworkhttps://cocoapods.org/pods/WebRTCRTCPeerConnectionFactory.peerConnectionWithConfigurationによりIOSシミュレータがクラッシュする

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" 

は私のコードに何か問題はありますか?

ありがとうございます!

+1

インスタンス変数としてファクトリを保持してください。 –

+0

それはどういう意味ですか? – Ian

答えて

3

工場オブジェクトを生きたままにしてください。

@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 
+0

ありがとう!それはわたしを助ける – AlKozin

関連する問題