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

@ -32,18 +32,20 @@
rtc::scoped_refptr<webrtc::VideoTrackInterface> track =
factory.nativeFactory->CreateVideoTrack(nativeId,
source.nativeVideoSource);
if (self = [self initWithNativeTrack:track type:RTCMediaStreamTrackTypeVideo]) {
if (self = [self initWithFactory:factory nativeTrack:track type:RTCMediaStreamTrackTypeVideo]) {
_source = source;
}
return self;
}
- (instancetype)initWithNativeTrack:
(rtc::scoped_refptr<webrtc::MediaStreamTrackInterface>)nativeMediaTrack
type:(RTCMediaStreamTrackType)type {
- (instancetype)initWithFactory:(RTCPeerConnectionFactory *)factory
nativeTrack:
(rtc::scoped_refptr<webrtc::MediaStreamTrackInterface>)nativeMediaTrack
type:(RTCMediaStreamTrackType)type {
NSParameterAssert(factory);
NSParameterAssert(nativeMediaTrack);
NSParameterAssert(type == RTCMediaStreamTrackTypeVideo);
if (self = [super initWithNativeTrack:nativeMediaTrack type:type]) {
if (self = [super initWithFactory:factory nativeTrack:nativeMediaTrack type:type]) {
_adapters = [NSMutableArray array];
}
return self;
@ -60,7 +62,8 @@
rtc::scoped_refptr<webrtc::VideoTrackSourceInterface> source =
self.nativeVideoTrack->GetSource();
if (source) {
_source = [[RTCVideoSource alloc] initWithNativeVideoSource:source.get()];
_source =
[[RTCVideoSource alloc] initWithFactory:self.factory nativeVideoSource:source.get()];
}
}
return _source;