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}
diff --git a/sdk/objc/Framework/Classes/PeerConnection/RTCRtpTransceiver.mm b/sdk/objc/Framework/Classes/PeerConnection/RTCRtpTransceiver.mm
index 5fe7569..780fcd5 100644
--- a/sdk/objc/Framework/Classes/PeerConnection/RTCRtpTransceiver.mm
+++ b/sdk/objc/Framework/Classes/PeerConnection/RTCRtpTransceiver.mm
@@ -45,6 +45,7 @@
@end
@implementation RTCRtpTransceiver {
+ RTCPeerConnectionFactory *_factory;
rtc::scoped_refptr<webrtc::RtpTransceiverInterface> _nativeRtpTransceiver;
}
@@ -120,10 +121,13 @@
return _nativeRtpTransceiver;
}
-- (instancetype)initWithNativeRtpTransceiver:
- (rtc::scoped_refptr<webrtc::RtpTransceiverInterface>)nativeRtpTransceiver {
+- (instancetype)initWithFactory:(RTCPeerConnectionFactory *)factory
+ nativeRtpTransceiver:
+ (rtc::scoped_refptr<webrtc::RtpTransceiverInterface>)nativeRtpTransceiver {
+ NSParameterAssert(factory);
NSParameterAssert(nativeRtpTransceiver);
if (self = [super init]) {
+ _factory = factory;
_nativeRtpTransceiver = nativeRtpTransceiver;
_sender = [[RTCRtpSender alloc] initWithNativeRtpSender:nativeRtpTransceiver->sender()];
_receiver = [[RTCRtpReceiver alloc] initWithNativeRtpReceiver:nativeRtpTransceiver->receiver()];