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:

committed by
Commit Bot

parent
5a3d87d122
commit
01cee079dc
@ -21,12 +21,12 @@
|
|||||||
@property(nonatomic, readonly) rtc::scoped_refptr<webrtc::AudioSourceInterface> nativeAudioSource;
|
@property(nonatomic, readonly) rtc::scoped_refptr<webrtc::AudioSourceInterface> nativeAudioSource;
|
||||||
|
|
||||||
/** Initialize an RTCAudioSource from a native AudioSourceInterface. */
|
/** Initialize an RTCAudioSource from a native AudioSourceInterface. */
|
||||||
- (instancetype)initWithNativeAudioSource:
|
- (instancetype)initWithFactory:(RTCPeerConnectionFactory*)factory
|
||||||
(rtc::scoped_refptr<webrtc::AudioSourceInterface>)nativeAudioSource
|
nativeAudioSource:(rtc::scoped_refptr<webrtc::AudioSourceInterface>)nativeAudioSource
|
||||||
NS_DESIGNATED_INITIALIZER;
|
NS_DESIGNATED_INITIALIZER;
|
||||||
|
|
||||||
- (instancetype)initWithNativeMediaSource:
|
- (instancetype)initWithFactory:(RTCPeerConnectionFactory*)factory
|
||||||
(rtc::scoped_refptr<webrtc::MediaSourceInterface>)nativeMediaSource
|
nativeMediaSource:(rtc::scoped_refptr<webrtc::MediaSourceInterface>)nativeMediaSource
|
||||||
type:(RTCMediaSourceType)type NS_UNAVAILABLE;
|
type:(RTCMediaSourceType)type NS_UNAVAILABLE;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -18,19 +18,23 @@
|
|||||||
@synthesize volume = _volume;
|
@synthesize volume = _volume;
|
||||||
@synthesize nativeAudioSource = _nativeAudioSource;
|
@synthesize nativeAudioSource = _nativeAudioSource;
|
||||||
|
|
||||||
- (instancetype)initWithNativeAudioSource:
|
- (instancetype)initWithFactory:(RTCPeerConnectionFactory *)factory
|
||||||
(rtc::scoped_refptr<webrtc::AudioSourceInterface>)nativeAudioSource {
|
nativeAudioSource:
|
||||||
|
(rtc::scoped_refptr<webrtc::AudioSourceInterface>)nativeAudioSource {
|
||||||
|
RTC_DCHECK(factory);
|
||||||
RTC_DCHECK(nativeAudioSource);
|
RTC_DCHECK(nativeAudioSource);
|
||||||
if (self = [super initWithNativeMediaSource:nativeAudioSource
|
|
||||||
type:RTCMediaSourceTypeAudio]) {
|
if (self = [super initWithFactory:factory
|
||||||
|
nativeMediaSource:nativeAudioSource
|
||||||
|
type:RTCMediaSourceTypeAudio]) {
|
||||||
_nativeAudioSource = nativeAudioSource;
|
_nativeAudioSource = nativeAudioSource;
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (instancetype)initWithNativeMediaSource:
|
- (instancetype)initWithFactory:(RTCPeerConnectionFactory *)factory
|
||||||
(rtc::scoped_refptr<webrtc::MediaSourceInterface>)nativeMediaSource
|
nativeMediaSource:(rtc::scoped_refptr<webrtc::MediaSourceInterface>)nativeMediaSource
|
||||||
type:(RTCMediaSourceType)type {
|
type:(RTCMediaSourceType)type {
|
||||||
RTC_NOTREACHED();
|
RTC_NOTREACHED();
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
@ -31,18 +31,19 @@
|
|||||||
std::string nativeId = [NSString stdStringForString:trackId];
|
std::string nativeId = [NSString stdStringForString:trackId];
|
||||||
rtc::scoped_refptr<webrtc::AudioTrackInterface> track =
|
rtc::scoped_refptr<webrtc::AudioTrackInterface> track =
|
||||||
factory.nativeFactory->CreateAudioTrack(nativeId, source.nativeAudioSource);
|
factory.nativeFactory->CreateAudioTrack(nativeId, source.nativeAudioSource);
|
||||||
if (self = [self initWithNativeTrack:track type:RTCMediaStreamTrackTypeAudio]) {
|
if (self = [self initWithFactory:factory nativeTrack:track type:RTCMediaStreamTrackTypeAudio]) {
|
||||||
_source = source;
|
_source = source;
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (instancetype)initWithNativeTrack:
|
- (instancetype)initWithFactory:(RTCPeerConnectionFactory *)factory
|
||||||
(rtc::scoped_refptr<webrtc::MediaStreamTrackInterface>)nativeTrack
|
nativeTrack:(rtc::scoped_refptr<webrtc::MediaStreamTrackInterface>)nativeTrack
|
||||||
type:(RTCMediaStreamTrackType)type {
|
type:(RTCMediaStreamTrackType)type {
|
||||||
|
NSParameterAssert(factory);
|
||||||
NSParameterAssert(nativeTrack);
|
NSParameterAssert(nativeTrack);
|
||||||
NSParameterAssert(type == RTCMediaStreamTrackTypeAudio);
|
NSParameterAssert(type == RTCMediaStreamTrackTypeAudio);
|
||||||
return [super initWithNativeTrack:nativeTrack type:type];
|
return [super initWithFactory:factory nativeTrack:nativeTrack type:type];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -51,7 +52,8 @@
|
|||||||
rtc::scoped_refptr<webrtc::AudioSourceInterface> source =
|
rtc::scoped_refptr<webrtc::AudioSourceInterface> source =
|
||||||
self.nativeAudioTrack->GetSource();
|
self.nativeAudioTrack->GetSource();
|
||||||
if (source) {
|
if (source) {
|
||||||
_source = [[RTCAudioSource alloc] initWithNativeAudioSource:source.get()];
|
_source =
|
||||||
|
[[RTCAudioSource alloc] initWithFactory:self.factory nativeAudioSource:source.get()];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return _source;
|
return _source;
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
NS_ASSUME_NONNULL_BEGIN
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
@class RTCPeerConnectionFactory;
|
||||||
|
|
||||||
typedef NS_ENUM(NSInteger, RTCMediaSourceType) {
|
typedef NS_ENUM(NSInteger, RTCMediaSourceType) {
|
||||||
RTCMediaSourceTypeAudio,
|
RTCMediaSourceTypeAudio,
|
||||||
RTCMediaSourceTypeVideo,
|
RTCMediaSourceTypeVideo,
|
||||||
@ -23,9 +25,9 @@ typedef NS_ENUM(NSInteger, RTCMediaSourceType) {
|
|||||||
|
|
||||||
@property(nonatomic, readonly) rtc::scoped_refptr<webrtc::MediaSourceInterface> nativeMediaSource;
|
@property(nonatomic, readonly) rtc::scoped_refptr<webrtc::MediaSourceInterface> nativeMediaSource;
|
||||||
|
|
||||||
- (instancetype)initWithNativeMediaSource:
|
- (instancetype)initWithFactory:(RTCPeerConnectionFactory *)factory
|
||||||
(rtc::scoped_refptr<webrtc::MediaSourceInterface>)nativeMediaSource
|
nativeMediaSource:(rtc::scoped_refptr<webrtc::MediaSourceInterface>)nativeMediaSource
|
||||||
type:(RTCMediaSourceType)type NS_DESIGNATED_INITIALIZER;
|
type:(RTCMediaSourceType)type NS_DESIGNATED_INITIALIZER;
|
||||||
|
|
||||||
+ (webrtc::MediaSourceInterface::SourceState)nativeSourceStateForState:(RTCSourceState)state;
|
+ (webrtc::MediaSourceInterface::SourceState)nativeSourceStateForState:(RTCSourceState)state;
|
||||||
|
|
||||||
|
@ -13,16 +13,19 @@
|
|||||||
#include "rtc_base/checks.h"
|
#include "rtc_base/checks.h"
|
||||||
|
|
||||||
@implementation RTCMediaSource {
|
@implementation RTCMediaSource {
|
||||||
|
RTCPeerConnectionFactory *_factory;
|
||||||
RTCMediaSourceType _type;
|
RTCMediaSourceType _type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@synthesize nativeMediaSource = _nativeMediaSource;
|
@synthesize nativeMediaSource = _nativeMediaSource;
|
||||||
|
|
||||||
- (instancetype)initWithNativeMediaSource:
|
- (instancetype)initWithFactory:(RTCPeerConnectionFactory *)factory
|
||||||
(rtc::scoped_refptr<webrtc::MediaSourceInterface>)nativeMediaSource
|
nativeMediaSource:(rtc::scoped_refptr<webrtc::MediaSourceInterface>)nativeMediaSource
|
||||||
type:(RTCMediaSourceType)type {
|
type:(RTCMediaSourceType)type {
|
||||||
|
RTC_DCHECK(factory);
|
||||||
RTC_DCHECK(nativeMediaSource);
|
RTC_DCHECK(nativeMediaSource);
|
||||||
if (self = [super init]) {
|
if (self = [super init]) {
|
||||||
|
_factory = factory;
|
||||||
_nativeMediaSource = nativeMediaSource;
|
_nativeMediaSource = nativeMediaSource;
|
||||||
_type = type;
|
_type = type;
|
||||||
}
|
}
|
||||||
|
@ -109,14 +109,14 @@
|
|||||||
for (auto &track : audioTracks) {
|
for (auto &track : audioTracks) {
|
||||||
RTCMediaStreamTrackType type = RTCMediaStreamTrackTypeAudio;
|
RTCMediaStreamTrackType type = RTCMediaStreamTrackTypeAudio;
|
||||||
RTCAudioTrack *audioTrack =
|
RTCAudioTrack *audioTrack =
|
||||||
[[RTCAudioTrack alloc] initWithNativeTrack:track type:type];
|
[[RTCAudioTrack alloc] initWithFactory:_factory nativeTrack:track type:type];
|
||||||
[_audioTracks addObject:audioTrack];
|
[_audioTracks addObject:audioTrack];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto &track : videoTracks) {
|
for (auto &track : videoTracks) {
|
||||||
RTCMediaStreamTrackType type = RTCMediaStreamTrackTypeVideo;
|
RTCMediaStreamTrackType type = RTCMediaStreamTrackTypeVideo;
|
||||||
RTCVideoTrack *videoTrack =
|
RTCVideoTrack *videoTrack =
|
||||||
[[RTCVideoTrack alloc] initWithNativeTrack:track type:type];
|
[[RTCVideoTrack alloc] initWithFactory:_factory nativeTrack:track type:type];
|
||||||
[_videoTracks addObject:videoTrack];
|
[_videoTracks addObject:videoTrack];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,12 @@ typedef NS_ENUM(NSInteger, RTCMediaStreamTrackType) {
|
|||||||
|
|
||||||
NS_ASSUME_NONNULL_BEGIN
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
@class RTCPeerConnectionFactory;
|
||||||
|
|
||||||
@interface RTCMediaStreamTrack ()
|
@interface RTCMediaStreamTrack ()
|
||||||
|
|
||||||
|
@property(nonatomic, readonly) RTCPeerConnectionFactory *factory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The native MediaStreamTrackInterface passed in or created during
|
* The native MediaStreamTrackInterface passed in or created during
|
||||||
* construction.
|
* construction.
|
||||||
@ -30,12 +34,12 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
/**
|
/**
|
||||||
* Initialize an RTCMediaStreamTrack from a native MediaStreamTrackInterface.
|
* Initialize an RTCMediaStreamTrack from a native MediaStreamTrackInterface.
|
||||||
*/
|
*/
|
||||||
- (instancetype)initWithNativeTrack:
|
- (instancetype)initWithFactory:(RTCPeerConnectionFactory *)factory
|
||||||
(rtc::scoped_refptr<webrtc::MediaStreamTrackInterface>)nativeTrack
|
nativeTrack:(rtc::scoped_refptr<webrtc::MediaStreamTrackInterface>)nativeTrack
|
||||||
type:(RTCMediaStreamTrackType)type NS_DESIGNATED_INITIALIZER;
|
type:(RTCMediaStreamTrackType)type NS_DESIGNATED_INITIALIZER;
|
||||||
|
|
||||||
- (instancetype)initWithNativeTrack:
|
- (instancetype)initWithFactory:(RTCPeerConnectionFactory *)factory
|
||||||
(rtc::scoped_refptr<webrtc::MediaStreamTrackInterface>)nativeTrack;
|
nativeTrack:(rtc::scoped_refptr<webrtc::MediaStreamTrackInterface>)nativeTrack;
|
||||||
|
|
||||||
- (BOOL)isEqualToTrack:(RTCMediaStreamTrack *)track;
|
- (BOOL)isEqualToTrack:(RTCMediaStreamTrack *)track;
|
||||||
|
|
||||||
@ -48,7 +52,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
+ (NSString *)stringForState:(RTCMediaStreamTrackState)state;
|
+ (NSString *)stringForState:(RTCMediaStreamTrackState)state;
|
||||||
|
|
||||||
+ (RTCMediaStreamTrack *)mediaTrackForNativeTrack:
|
+ (RTCMediaStreamTrack *)mediaTrackForNativeTrack:
|
||||||
(rtc::scoped_refptr<webrtc::MediaStreamTrackInterface>)nativeTrack;
|
(rtc::scoped_refptr<webrtc::MediaStreamTrackInterface>)nativeTrack
|
||||||
|
factory:(RTCPeerConnectionFactory *)factory;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ NSString * const kRTCMediaStreamTrackKindVideo =
|
|||||||
@(webrtc::MediaStreamTrackInterface::kVideoKind);
|
@(webrtc::MediaStreamTrackInterface::kVideoKind);
|
||||||
|
|
||||||
@implementation RTCMediaStreamTrack {
|
@implementation RTCMediaStreamTrack {
|
||||||
|
RTCPeerConnectionFactory *_factory;
|
||||||
rtc::scoped_refptr<webrtc::MediaStreamTrackInterface> _nativeTrack;
|
rtc::scoped_refptr<webrtc::MediaStreamTrackInterface> _nativeTrack;
|
||||||
RTCMediaStreamTrackType _type;
|
RTCMediaStreamTrackType _type;
|
||||||
}
|
}
|
||||||
@ -73,29 +74,31 @@ NSString * const kRTCMediaStreamTrackKindVideo =
|
|||||||
return _nativeTrack;
|
return _nativeTrack;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (instancetype)initWithNativeTrack:
|
@synthesize factory = _factory;
|
||||||
(rtc::scoped_refptr<webrtc::MediaStreamTrackInterface>)nativeTrack
|
|
||||||
type:(RTCMediaStreamTrackType)type {
|
- (instancetype)initWithFactory:(RTCPeerConnectionFactory *)factory
|
||||||
|
nativeTrack:(rtc::scoped_refptr<webrtc::MediaStreamTrackInterface>)nativeTrack
|
||||||
|
type:(RTCMediaStreamTrackType)type {
|
||||||
NSParameterAssert(nativeTrack);
|
NSParameterAssert(nativeTrack);
|
||||||
|
NSParameterAssert(factory);
|
||||||
if (self = [super init]) {
|
if (self = [super init]) {
|
||||||
|
_factory = factory;
|
||||||
_nativeTrack = nativeTrack;
|
_nativeTrack = nativeTrack;
|
||||||
_type = type;
|
_type = type;
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (instancetype)initWithNativeTrack:
|
- (instancetype)initWithFactory:(RTCPeerConnectionFactory *)factory
|
||||||
(rtc::scoped_refptr<webrtc::MediaStreamTrackInterface>)nativeTrack {
|
nativeTrack:(rtc::scoped_refptr<webrtc::MediaStreamTrackInterface>)nativeTrack {
|
||||||
NSParameterAssert(nativeTrack);
|
NSParameterAssert(nativeTrack);
|
||||||
if (nativeTrack->kind() ==
|
if (nativeTrack->kind() ==
|
||||||
std::string(webrtc::MediaStreamTrackInterface::kAudioKind)) {
|
std::string(webrtc::MediaStreamTrackInterface::kAudioKind)) {
|
||||||
return [self initWithNativeTrack:nativeTrack
|
return [self initWithFactory:factory nativeTrack:nativeTrack type:RTCMediaStreamTrackTypeAudio];
|
||||||
type:RTCMediaStreamTrackTypeAudio];
|
|
||||||
}
|
}
|
||||||
if (nativeTrack->kind() ==
|
if (nativeTrack->kind() ==
|
||||||
std::string(webrtc::MediaStreamTrackInterface::kVideoKind)) {
|
std::string(webrtc::MediaStreamTrackInterface::kVideoKind)) {
|
||||||
return [self initWithNativeTrack:nativeTrack
|
return [self initWithFactory:factory nativeTrack:nativeTrack type:RTCMediaStreamTrackTypeVideo];
|
||||||
type:RTCMediaStreamTrackTypeVideo];
|
|
||||||
}
|
}
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
@ -137,16 +140,20 @@ NSString * const kRTCMediaStreamTrackKindVideo =
|
|||||||
}
|
}
|
||||||
|
|
||||||
+ (RTCMediaStreamTrack *)mediaTrackForNativeTrack:
|
+ (RTCMediaStreamTrack *)mediaTrackForNativeTrack:
|
||||||
(rtc::scoped_refptr<webrtc::MediaStreamTrackInterface>)nativeTrack {
|
(rtc::scoped_refptr<webrtc::MediaStreamTrackInterface>)nativeTrack
|
||||||
|
factory:(RTCPeerConnectionFactory *)factory {
|
||||||
NSParameterAssert(nativeTrack);
|
NSParameterAssert(nativeTrack);
|
||||||
|
NSParameterAssert(factory);
|
||||||
if (nativeTrack->kind() == webrtc::MediaStreamTrackInterface::kAudioKind) {
|
if (nativeTrack->kind() == webrtc::MediaStreamTrackInterface::kAudioKind) {
|
||||||
return
|
return [[RTCAudioTrack alloc] initWithFactory:factory
|
||||||
[[RTCAudioTrack alloc] initWithNativeTrack:nativeTrack type:RTCMediaStreamTrackTypeAudio];
|
nativeTrack:nativeTrack
|
||||||
|
type:RTCMediaStreamTrackTypeAudio];
|
||||||
} else if (nativeTrack->kind() == webrtc::MediaStreamTrackInterface::kVideoKind) {
|
} else if (nativeTrack->kind() == webrtc::MediaStreamTrackInterface::kVideoKind) {
|
||||||
return
|
return [[RTCVideoTrack alloc] initWithFactory:factory
|
||||||
[[RTCVideoTrack alloc] initWithNativeTrack:nativeTrack type:RTCMediaStreamTrackTypeVideo];
|
nativeTrack:nativeTrack
|
||||||
|
type:RTCMediaStreamTrackTypeVideo];
|
||||||
} else {
|
} else {
|
||||||
return [[RTCMediaStreamTrack alloc] initWithNativeTrack:nativeTrack];
|
return [[RTCMediaStreamTrack alloc] initWithFactory:factory nativeTrack:nativeTrack];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,7 +180,7 @@
|
|||||||
|
|
||||||
rtc::scoped_refptr<webrtc::AudioSourceInterface> source =
|
rtc::scoped_refptr<webrtc::AudioSourceInterface> source =
|
||||||
_nativeFactory->CreateAudioSource(options);
|
_nativeFactory->CreateAudioSource(options);
|
||||||
return [[RTCAudioSource alloc] initWithNativeAudioSource:source];
|
return [[RTCAudioSource alloc] initWithFactory:self nativeAudioSource:source];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (RTCAudioTrack *)audioTrackWithTrackId:(NSString *)trackId {
|
- (RTCAudioTrack *)audioTrackWithTrackId:(NSString *)trackId {
|
||||||
@ -196,8 +196,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (RTCVideoSource *)videoSource {
|
- (RTCVideoSource *)videoSource {
|
||||||
return [[RTCVideoSource alloc] initWithSignalingThread:_signalingThread.get()
|
return [[RTCVideoSource alloc] initWithFactory:self
|
||||||
workerThread:_workerThread.get()];
|
signalingThread:_signalingThread.get()
|
||||||
|
workerThread:_workerThread.get()];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (RTCVideoTrack *)videoTrackWithSource:(RTCVideoSource *)source
|
- (RTCVideoTrack *)videoTrackWithSource:(RTCVideoSource *)source
|
||||||
|
@ -63,7 +63,7 @@ void RtpReceiverDelegateAdapter::OnFirstPacketReceived(
|
|||||||
rtc::scoped_refptr<webrtc::MediaStreamTrackInterface> nativeTrack(
|
rtc::scoped_refptr<webrtc::MediaStreamTrackInterface> nativeTrack(
|
||||||
_nativeRtpReceiver->track());
|
_nativeRtpReceiver->track());
|
||||||
if (nativeTrack) {
|
if (nativeTrack) {
|
||||||
return [RTCMediaStreamTrack mediaTrackForNativeTrack:nativeTrack];
|
return [RTCMediaStreamTrack mediaTrackForNativeTrack:nativeTrack factory:_factory];
|
||||||
}
|
}
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@
|
|||||||
rtc::scoped_refptr<webrtc::MediaStreamTrackInterface> nativeTrack(
|
rtc::scoped_refptr<webrtc::MediaStreamTrackInterface> nativeTrack(
|
||||||
_nativeRtpSender->track());
|
_nativeRtpSender->track());
|
||||||
if (nativeTrack) {
|
if (nativeTrack) {
|
||||||
return [RTCMediaStreamTrack mediaTrackForNativeTrack:nativeTrack];
|
return [RTCMediaStreamTrack mediaTrackForNativeTrack:nativeTrack factory:_factory];
|
||||||
}
|
}
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
@ -26,16 +26,18 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
nativeVideoSource;
|
nativeVideoSource;
|
||||||
|
|
||||||
/** Initialize an RTCVideoSource from a native VideoTrackSourceInterface. */
|
/** Initialize an RTCVideoSource from a native VideoTrackSourceInterface. */
|
||||||
- (instancetype)initWithNativeVideoSource:
|
- (instancetype)initWithFactory:(RTCPeerConnectionFactory *)factory
|
||||||
(rtc::scoped_refptr<webrtc::VideoTrackSourceInterface>)nativeVideoSource
|
nativeVideoSource:
|
||||||
|
(rtc::scoped_refptr<webrtc::VideoTrackSourceInterface>)nativeVideoSource
|
||||||
NS_DESIGNATED_INITIALIZER;
|
NS_DESIGNATED_INITIALIZER;
|
||||||
|
|
||||||
- (instancetype)initWithNativeMediaSource:
|
- (instancetype)initWithFactory:(RTCPeerConnectionFactory *)factory
|
||||||
(rtc::scoped_refptr<webrtc::MediaSourceInterface>)nativeMediaSource
|
nativeMediaSource:(rtc::scoped_refptr<webrtc::MediaSourceInterface>)nativeMediaSource
|
||||||
type:(RTCMediaSourceType)type NS_UNAVAILABLE;
|
type:(RTCMediaSourceType)type NS_UNAVAILABLE;
|
||||||
|
|
||||||
- (instancetype)initWithSignalingThread:(rtc::Thread *)signalingThread
|
- (instancetype)initWithFactory:(RTCPeerConnectionFactory *)factory
|
||||||
workerThread:(rtc::Thread *)workerThread;
|
signalingThread:(rtc::Thread *)signalingThread
|
||||||
|
workerThread:(rtc::Thread *)workerThread;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@ -28,30 +28,35 @@ static webrtc::ObjCVideoTrackSource *getObjCVideoSource(
|
|||||||
rtc::scoped_refptr<webrtc::VideoTrackSourceInterface> _nativeVideoSource;
|
rtc::scoped_refptr<webrtc::VideoTrackSourceInterface> _nativeVideoSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (instancetype)initWithNativeVideoSource:
|
- (instancetype)initWithFactory:(RTCPeerConnectionFactory *)factory
|
||||||
(rtc::scoped_refptr<webrtc::VideoTrackSourceInterface>)nativeVideoSource {
|
nativeVideoSource:
|
||||||
|
(rtc::scoped_refptr<webrtc::VideoTrackSourceInterface>)nativeVideoSource {
|
||||||
|
RTC_DCHECK(factory);
|
||||||
RTC_DCHECK(nativeVideoSource);
|
RTC_DCHECK(nativeVideoSource);
|
||||||
if (self = [super initWithNativeMediaSource:nativeVideoSource
|
if (self = [super initWithFactory:factory
|
||||||
type:RTCMediaSourceTypeVideo]) {
|
nativeMediaSource:nativeVideoSource
|
||||||
|
type:RTCMediaSourceTypeVideo]) {
|
||||||
_nativeVideoSource = nativeVideoSource;
|
_nativeVideoSource = nativeVideoSource;
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (instancetype)initWithNativeMediaSource:
|
- (instancetype)initWithFactory:(RTCPeerConnectionFactory *)factory
|
||||||
(rtc::scoped_refptr<webrtc::MediaSourceInterface>)nativeMediaSource
|
nativeMediaSource:(rtc::scoped_refptr<webrtc::MediaSourceInterface>)nativeMediaSource
|
||||||
type:(RTCMediaSourceType)type {
|
type:(RTCMediaSourceType)type {
|
||||||
RTC_NOTREACHED();
|
RTC_NOTREACHED();
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (instancetype)initWithSignalingThread:(rtc::Thread *)signalingThread
|
- (instancetype)initWithFactory:(RTCPeerConnectionFactory *)factory
|
||||||
workerThread:(rtc::Thread *)workerThread {
|
signalingThread:(rtc::Thread *)signalingThread
|
||||||
|
workerThread:(rtc::Thread *)workerThread {
|
||||||
rtc::scoped_refptr<webrtc::ObjCVideoTrackSource> objCVideoTrackSource(
|
rtc::scoped_refptr<webrtc::ObjCVideoTrackSource> objCVideoTrackSource(
|
||||||
new rtc::RefCountedObject<webrtc::ObjCVideoTrackSource>());
|
new rtc::RefCountedObject<webrtc::ObjCVideoTrackSource>());
|
||||||
|
|
||||||
return [self initWithNativeVideoSource:webrtc::VideoTrackSourceProxy::Create(
|
return [self initWithFactory:factory
|
||||||
signalingThread, workerThread, objCVideoTrackSource)];
|
nativeVideoSource:webrtc::VideoTrackSourceProxy::Create(
|
||||||
|
signalingThread, workerThread, objCVideoTrackSource)];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *)description {
|
- (NSString *)description {
|
||||||
|
@ -32,18 +32,20 @@
|
|||||||
rtc::scoped_refptr<webrtc::VideoTrackInterface> track =
|
rtc::scoped_refptr<webrtc::VideoTrackInterface> track =
|
||||||
factory.nativeFactory->CreateVideoTrack(nativeId,
|
factory.nativeFactory->CreateVideoTrack(nativeId,
|
||||||
source.nativeVideoSource);
|
source.nativeVideoSource);
|
||||||
if (self = [self initWithNativeTrack:track type:RTCMediaStreamTrackTypeVideo]) {
|
if (self = [self initWithFactory:factory nativeTrack:track type:RTCMediaStreamTrackTypeVideo]) {
|
||||||
_source = source;
|
_source = source;
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (instancetype)initWithNativeTrack:
|
- (instancetype)initWithFactory:(RTCPeerConnectionFactory *)factory
|
||||||
(rtc::scoped_refptr<webrtc::MediaStreamTrackInterface>)nativeMediaTrack
|
nativeTrack:
|
||||||
type:(RTCMediaStreamTrackType)type {
|
(rtc::scoped_refptr<webrtc::MediaStreamTrackInterface>)nativeMediaTrack
|
||||||
|
type:(RTCMediaStreamTrackType)type {
|
||||||
|
NSParameterAssert(factory);
|
||||||
NSParameterAssert(nativeMediaTrack);
|
NSParameterAssert(nativeMediaTrack);
|
||||||
NSParameterAssert(type == RTCMediaStreamTrackTypeVideo);
|
NSParameterAssert(type == RTCMediaStreamTrackTypeVideo);
|
||||||
if (self = [super initWithNativeTrack:nativeMediaTrack type:type]) {
|
if (self = [super initWithFactory:factory nativeTrack:nativeMediaTrack type:type]) {
|
||||||
_adapters = [NSMutableArray array];
|
_adapters = [NSMutableArray array];
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
@ -60,7 +62,8 @@
|
|||||||
rtc::scoped_refptr<webrtc::VideoTrackSourceInterface> source =
|
rtc::scoped_refptr<webrtc::VideoTrackSourceInterface> source =
|
||||||
self.nativeVideoTrack->GetSource();
|
self.nativeVideoTrack->GetSource();
|
||||||
if (source) {
|
if (source) {
|
||||||
_source = [[RTCVideoSource alloc] initWithNativeVideoSource:source.get()];
|
_source =
|
||||||
|
[[RTCVideoSource alloc] initWithFactory:self.factory nativeVideoSource:source.get()];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return _source;
|
return _source;
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
* be found in the AUTHORS file in the root of the source tree.
|
* be found in the AUTHORS file in the root of the source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#import <WebRTC/RTCAudioSource.h>
|
||||||
#import <WebRTC/RTCConfiguration.h>
|
#import <WebRTC/RTCConfiguration.h>
|
||||||
#import <WebRTC/RTCDataChannel.h>
|
#import <WebRTC/RTCDataChannel.h>
|
||||||
#import <WebRTC/RTCDataChannelConfiguration.h>
|
#import <WebRTC/RTCDataChannelConfiguration.h>
|
||||||
@ -18,6 +19,7 @@
|
|||||||
#import <WebRTC/RTCRtpReceiver.h>
|
#import <WebRTC/RTCRtpReceiver.h>
|
||||||
#import <WebRTC/RTCRtpSender.h>
|
#import <WebRTC/RTCRtpSender.h>
|
||||||
#import <WebRTC/RTCRtpTransceiver.h>
|
#import <WebRTC/RTCRtpTransceiver.h>
|
||||||
|
#import <WebRTC/RTCVideoSource.h>
|
||||||
|
|
||||||
#import <XCTest/XCTest.h>
|
#import <XCTest/XCTest.h>
|
||||||
|
|
||||||
@ -193,6 +195,74 @@
|
|||||||
XCTAssertTrue(true, "Expect test does not crash");
|
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
|
- (bool)negotiatePeerConnection:(RTCPeerConnection *)pc1
|
||||||
withPeerConnection:(RTCPeerConnection *)pc2
|
withPeerConnection:(RTCPeerConnection *)pc2
|
||||||
negotiationTimeout:(NSTimeInterval)timeout {
|
negotiationTimeout:(NSTimeInterval)timeout {
|
||||||
|
Reference in New Issue
Block a user