Fixed crash when PCF is destroyed before RTCRtpReceiver in ObjC
Bug: webrtc:9231 Change-Id: Ic532b7661bb8765f0fc2309d2ad530f664ccfd14 Reviewed-on: https://webrtc-review.googlesource.com/87840 Reviewed-by: Kári Helgason <kthelgason@webrtc.org> Commit-Queue: Kári Helgason <kthelgason@webrtc.org> Cr-Commit-Position: refs/heads/master@{#23931}
This commit is contained in:
committed by
Commit Bot
parent
cd8f382557
commit
7a16c54571
@ -231,7 +231,8 @@ void PeerConnectionDelegateAdapter::OnAddTrack(
|
||||
nativeMediaStream:nativeStream];
|
||||
[mediaStreams addObject:mediaStream];
|
||||
}
|
||||
RTCRtpReceiver *rtpReceiver = [[RTCRtpReceiver alloc] initWithNativeRtpReceiver:receiver];
|
||||
RTCRtpReceiver *rtpReceiver =
|
||||
[[RTCRtpReceiver alloc] initWithFactory:peer_connection.factory nativeRtpReceiver:receiver];
|
||||
|
||||
[peer_connection.delegate peerConnection:peer_connection
|
||||
didAddReceiver:rtpReceiver
|
||||
@ -545,7 +546,7 @@ void PeerConnectionDelegateAdapter::OnAddTrack(
|
||||
NSMutableArray *receivers = [[NSMutableArray alloc] init];
|
||||
for (const auto &nativeReceiver : nativeReceivers) {
|
||||
RTCRtpReceiver *receiver =
|
||||
[[RTCRtpReceiver alloc] initWithNativeRtpReceiver:nativeReceiver];
|
||||
[[RTCRtpReceiver alloc] initWithFactory:self.factory nativeRtpReceiver:nativeReceiver];
|
||||
[receivers addObject:receiver];
|
||||
}
|
||||
return receivers;
|
||||
|
||||
@ -14,6 +14,8 @@
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class RTCPeerConnectionFactory;
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class RtpReceiverDelegateAdapter : public RtpReceiverObserverInterface {
|
||||
@ -33,8 +35,8 @@ class RtpReceiverDelegateAdapter : public RtpReceiverObserverInterface {
|
||||
@property(nonatomic, readonly) rtc::scoped_refptr<webrtc::RtpReceiverInterface> nativeRtpReceiver;
|
||||
|
||||
/** Initialize an RTCRtpReceiver with a native RtpReceiverInterface. */
|
||||
- (instancetype)initWithNativeRtpReceiver:
|
||||
(rtc::scoped_refptr<webrtc::RtpReceiverInterface>)nativeRtpReceiver
|
||||
- (instancetype)initWithFactory:(RTCPeerConnectionFactory*)factory
|
||||
nativeRtpReceiver:(rtc::scoped_refptr<webrtc::RtpReceiverInterface>)nativeRtpReceiver
|
||||
NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
+ (RTCRtpMediaType)mediaTypeForNativeMediaType:(cricket::MediaType)nativeMediaType;
|
||||
|
||||
@ -36,6 +36,7 @@ void RtpReceiverDelegateAdapter::OnFirstPacketReceived(
|
||||
} // namespace webrtc
|
||||
|
||||
@implementation RTCRtpReceiver {
|
||||
RTCPeerConnectionFactory *_factory;
|
||||
rtc::scoped_refptr<webrtc::RtpReceiverInterface> _nativeRtpReceiver;
|
||||
std::unique_ptr<webrtc::RtpReceiverDelegateAdapter> _observer;
|
||||
}
|
||||
@ -102,9 +103,11 @@ void RtpReceiverDelegateAdapter::OnFirstPacketReceived(
|
||||
return _nativeRtpReceiver;
|
||||
}
|
||||
|
||||
- (instancetype)initWithNativeRtpReceiver:
|
||||
(rtc::scoped_refptr<webrtc::RtpReceiverInterface>)nativeRtpReceiver {
|
||||
- (instancetype)initWithFactory:(RTCPeerConnectionFactory *)factory
|
||||
nativeRtpReceiver:
|
||||
(rtc::scoped_refptr<webrtc::RtpReceiverInterface>)nativeRtpReceiver {
|
||||
if (self = [super init]) {
|
||||
_factory = factory;
|
||||
_nativeRtpReceiver = nativeRtpReceiver;
|
||||
RTCLogInfo(
|
||||
@"RTCRtpReceiver(%p): created receiver: %@", self, self.description);
|
||||
|
||||
@ -131,7 +131,8 @@
|
||||
_nativeRtpTransceiver = nativeRtpTransceiver;
|
||||
_sender = [[RTCRtpSender alloc] initWithFactory:_factory
|
||||
nativeRtpSender:nativeRtpTransceiver->sender()];
|
||||
_receiver = [[RTCRtpReceiver alloc] initWithNativeRtpReceiver:nativeRtpTransceiver->receiver()];
|
||||
_receiver = [[RTCRtpReceiver alloc] initWithFactory:_factory
|
||||
nativeRtpReceiver:nativeRtpTransceiver->receiver()];
|
||||
RTCLogInfo(@"RTCRtpTransceiver(%p): created transceiver: %@", self, self.description);
|
||||
}
|
||||
return self;
|
||||
|
||||
Reference in New Issue
Block a user