Fixed crash when PCF is destroyed before RTCRtpTranceiver in ObjC

Bug: webrtc:9231
Change-Id: Icecc319eaf6edd2c4b7b05fda984660412cb0d40
Reviewed-on: https://webrtc-review.googlesource.com/87439
Reviewed-by: Kári Helgason <kthelgason@webrtc.org>
Commit-Queue: Kári Helgason <kthelgason@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23884}
This commit is contained in:
Yura Yaroshevich
2018-07-09 11:56:06 +03:00
committed by Commit Bot
parent 42a2fc9cba
commit 08f14dd388
4 changed files with 49 additions and 12 deletions

View File

@ -151,9 +151,10 @@ void PeerConnectionDelegateAdapter::OnRemoveStream(
void PeerConnectionDelegateAdapter::OnTrack(
rtc::scoped_refptr<RtpTransceiverInterface> nativeTransceiver) {
RTCRtpTransceiver *transceiver =
[[RTCRtpTransceiver alloc] initWithNativeRtpTransceiver:nativeTransceiver];
RTCPeerConnection *peer_connection = peer_connection_;
RTCRtpTransceiver *transceiver =
[[RTCRtpTransceiver alloc] initWithFactory:peer_connection.factory
nativeRtpTransceiver:nativeTransceiver];
if ([peer_connection.delegate
respondsToSelector:@selector(peerConnection:didStartReceivingOnTransceiver:)]) {
[peer_connection.delegate peerConnection:peer_connection
@ -409,8 +410,8 @@ void PeerConnectionDelegateAdapter::OnAddTrack(
@"Failed to add transceiver %@: %s", track, nativeTransceiverOrError.error().message());
return nil;
}
return
[[RTCRtpTransceiver alloc] initWithNativeRtpTransceiver:nativeTransceiverOrError.MoveValue()];
return [[RTCRtpTransceiver alloc] initWithFactory:self.factory
nativeRtpTransceiver:nativeTransceiverOrError.MoveValue()];
}
- (RTCRtpTransceiver *)addTransceiverOfType:(RTCRtpMediaType)mediaType {
@ -428,8 +429,8 @@ void PeerConnectionDelegateAdapter::OnAddTrack(
nativeTransceiverOrError.error().message());
return nil;
}
return
[[RTCRtpTransceiver alloc] initWithNativeRtpTransceiver:nativeTransceiverOrError.MoveValue()];
return [[RTCRtpTransceiver alloc] initWithFactory:self.factory
nativeRtpTransceiver:nativeTransceiverOrError.MoveValue()];
}
- (void)offerForConstraints:(RTCMediaConstraints *)constraints
@ -554,8 +555,8 @@ void PeerConnectionDelegateAdapter::OnAddTrack(
_peerConnection->GetTransceivers());
NSMutableArray *transceivers = [[NSMutableArray alloc] init];
for (auto nativeTransceiver : nativeTransceivers) {
RTCRtpTransceiver *transceiver =
[[RTCRtpTransceiver alloc] initWithNativeRtpTransceiver:nativeTransceiver];
RTCRtpTransceiver *transceiver = [[RTCRtpTransceiver alloc] initWithFactory:self.factory
nativeRtpTransceiver:nativeTransceiver];
[transceivers addObject:transceiver];
}
return transceivers;