Fixed crash when PCF is destroyed before PC in ObjC
Bug: webrtc:9231 Change-Id: Iaf18257b8f38fa786d462bca5f860f9a7b1cc2d0 Reviewed-on: https://webrtc-review.googlesource.com/78800 Commit-Queue: Kári Helgason <kthelgason@webrtc.org> Reviewed-by: Kári Helgason <kthelgason@webrtc.org> Cr-Commit-Position: refs/heads/master@{#23674}
This commit is contained in:
committed by
Commit Bot
parent
f04148c810
commit
5297bd21b1
@ -240,6 +240,7 @@ void PeerConnectionDelegateAdapter::OnAddTrack(
|
||||
|
||||
|
||||
@implementation RTCPeerConnection {
|
||||
RTCPeerConnectionFactory *_factory;
|
||||
NSMutableArray<RTCMediaStream *> *_localStreams;
|
||||
std::unique_ptr<webrtc::PeerConnectionDelegateAdapter> _observer;
|
||||
rtc::scoped_refptr<webrtc::PeerConnectionInterface> _peerConnection;
|
||||
@ -272,6 +273,7 @@ void PeerConnectionDelegateAdapter::OnAddTrack(
|
||||
if (!_peerConnection) {
|
||||
return nil;
|
||||
}
|
||||
_factory = factory;
|
||||
_localStreams = [[NSMutableArray alloc] init];
|
||||
_delegate = delegate;
|
||||
}
|
||||
|
||||
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright 2018 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.
|
||||
*/
|
||||
|
||||
#import <WebRTC/RTCConfiguration.h>
|
||||
#import <WebRTC/RTCMediaConstraints.h>
|
||||
#import <WebRTC/RTCPeerConnection.h>
|
||||
#import <WebRTC/RTCPeerConnectionFactory.h>
|
||||
|
||||
#import <XCTest/XCTest.h>
|
||||
|
||||
@interface RTCPeerConnectionFactoryTests : XCTestCase
|
||||
- (void)testPeerConnectionLifetime;
|
||||
@end
|
||||
|
||||
@implementation RTCPeerConnectionFactoryTests
|
||||
|
||||
- (void)testPeerConnectionLifetime {
|
||||
@autoreleasepool {
|
||||
RTCConfiguration *config = [[RTCConfiguration alloc] init];
|
||||
|
||||
RTCMediaConstraints *contraints =
|
||||
[[RTCMediaConstraints alloc] initWithMandatoryConstraints:@{} optionalConstraints:nil];
|
||||
|
||||
RTCPeerConnectionFactory *factory = [[RTCPeerConnectionFactory alloc] init];
|
||||
|
||||
RTCPeerConnection *peerConnection =
|
||||
[factory peerConnectionWithConfiguration:config constraints:contraints delegate:nil];
|
||||
|
||||
[peerConnection close];
|
||||
|
||||
factory = nil;
|
||||
peerConnection = nil;
|
||||
}
|
||||
|
||||
XCTAssertTrue(true, @"Expect test does not crash");
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user