Fixed crash when PCF is destroyed before MediaSource/Track in ObjC

Bug: webrtc:9231
Change-Id: I31b86aa560f4ad230c9a94fedebebf320e0370a4
Reviewed-on: https://webrtc-review.googlesource.com/88221
Reviewed-by: Kári Helgason <kthelgason@webrtc.org>
Commit-Queue: Kári Helgason <kthelgason@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23981}
This commit is contained in:
Yura Yaroshevich
2018-07-11 15:35:40 +03:00
committed by Commit Bot
parent 5a3d87d122
commit 01cee079dc
15 changed files with 180 additions and 76 deletions

View File

@ -8,6 +8,7 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#import <WebRTC/RTCAudioSource.h>
#import <WebRTC/RTCConfiguration.h>
#import <WebRTC/RTCDataChannel.h>
#import <WebRTC/RTCDataChannelConfiguration.h>
@ -18,6 +19,7 @@
#import <WebRTC/RTCRtpReceiver.h>
#import <WebRTC/RTCRtpSender.h>
#import <WebRTC/RTCRtpTransceiver.h>
#import <WebRTC/RTCVideoSource.h>
#import <XCTest/XCTest.h>
@ -193,6 +195,74 @@
XCTAssertTrue(true, "Expect test does not crash");
}
- (void)testAudioSourceLifetime {
@autoreleasepool {
RTCPeerConnectionFactory *factory;
RTCAudioSource *audioSource;
@autoreleasepool {
factory = [[RTCPeerConnectionFactory alloc] init];
audioSource = [factory audioSourceWithConstraints:nil];
XCTAssertNotNil(audioSource);
factory = nil;
}
audioSource = nil;
}
XCTAssertTrue(true, "Expect test does not crash");
}
- (void)testVideoSourceLifetime {
@autoreleasepool {
RTCPeerConnectionFactory *factory;
RTCVideoSource *videoSource;
@autoreleasepool {
factory = [[RTCPeerConnectionFactory alloc] init];
videoSource = [factory videoSource];
XCTAssertNotNil(videoSource);
factory = nil;
}
videoSource = nil;
}
XCTAssertTrue(true, "Expect test does not crash");
}
- (void)testAudioTrackLifetime {
@autoreleasepool {
RTCPeerConnectionFactory *factory;
RTCAudioTrack *audioTrack;
@autoreleasepool {
factory = [[RTCPeerConnectionFactory alloc] init];
audioTrack = [factory audioTrackWithTrackId:@"audioTrack"];
XCTAssertNotNil(audioTrack);
factory = nil;
}
audioTrack = nil;
}
XCTAssertTrue(true, "Expect test does not crash");
}
- (void)testVideoTrackLifetime {
@autoreleasepool {
RTCPeerConnectionFactory *factory;
RTCVideoTrack *videoTrack;
@autoreleasepool {
factory = [[RTCPeerConnectionFactory alloc] init];
videoTrack = [factory videoTrackWithSource:[factory videoSource] trackId:@"videoTrack"];
XCTAssertNotNil(videoTrack);
factory = nil;
}
videoTrack = nil;
}
XCTAssertTrue(true, "Expect test does not crash");
}
- (bool)negotiatePeerConnection:(RTCPeerConnection *)pc1
withPeerConnection:(RTCPeerConnection *)pc2
negotiationTimeout:(NSTimeInterval)timeout {