ObjC SDK: Stop using built-in SW video codecs
This CL removes the use of default built-in SW in the ObjC layer. If a client want to depend on the video SW codecs, they must inject them explicitly. Bug: webrtc:7925 Change-Id: If752e7f02109ff768dc5ec38d935203de85987c2 Reviewed-on: https://webrtc-review.googlesource.com/69800 Commit-Queue: Magnus Jedvert <magjed@webrtc.org> Reviewed-by: Anders Carlsson <andersc@webrtc.org> Cr-Commit-Position: refs/heads/master@{#23073}
This commit is contained in:
committed by
Commit Bot
parent
be80681295
commit
8b4e92d0a5
@ -11,11 +11,9 @@
|
||||
#import "WebRTC/RTCVideoCodecFactory.h"
|
||||
|
||||
#import "WebRTC/RTCVideoCodecH264.h"
|
||||
#if defined(USE_BUILTIN_SW_CODECS)
|
||||
#import "WebRTC/RTCVideoDecoderVP8.h" // nogncheck
|
||||
#import "WebRTC/RTCVideoDecoderVP8.h"
|
||||
#if !defined(RTC_DISABLE_VP9)
|
||||
#import "WebRTC/RTCVideoDecoderVP9.h" // nogncheck
|
||||
#endif
|
||||
#import "WebRTC/RTCVideoDecoderVP9.h"
|
||||
#endif
|
||||
|
||||
@implementation RTCDefaultVideoDecoderFactory
|
||||
@ -23,13 +21,11 @@
|
||||
- (id<RTCVideoDecoder>)createDecoder:(RTCVideoCodecInfo *)info {
|
||||
if ([info.name isEqualToString:kRTCVideoCodecH264Name]) {
|
||||
return [[RTCVideoDecoderH264 alloc] init];
|
||||
#if defined(USE_BUILTIN_SW_CODECS)
|
||||
} else if ([info.name isEqualToString:kRTCVideoCodecVp8Name]) {
|
||||
return [RTCVideoDecoderVP8 vp8Decoder];
|
||||
#if !defined(RTC_DISABLE_VP9)
|
||||
} else if ([info.name isEqualToString:kRTCVideoCodecVp9Name]) {
|
||||
return [RTCVideoDecoderVP9 vp9Decoder];
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -39,11 +35,9 @@
|
||||
- (NSArray<RTCVideoCodecInfo *> *)supportedCodecs {
|
||||
return @[
|
||||
[[RTCVideoCodecInfo alloc] initWithName:kRTCVideoCodecH264Name],
|
||||
#if defined(USE_BUILTIN_SW_CODECS)
|
||||
[[RTCVideoCodecInfo alloc] initWithName:kRTCVideoCodecVp8Name],
|
||||
#if !defined(RTC_DISABLE_VP9)
|
||||
[[RTCVideoCodecInfo alloc] initWithName:kRTCVideoCodecVp9Name],
|
||||
#endif
|
||||
#endif
|
||||
];
|
||||
}
|
||||
|
||||
@ -12,11 +12,9 @@
|
||||
|
||||
#import "WebRTC/RTCVideoCodec.h"
|
||||
#import "WebRTC/RTCVideoCodecH264.h"
|
||||
#if defined(USE_BUILTIN_SW_CODECS)
|
||||
#import "WebRTC/RTCVideoEncoderVP8.h" // nogncheck
|
||||
#import "WebRTC/RTCVideoEncoderVP8.h"
|
||||
#if !defined(RTC_DISABLE_VP9)
|
||||
#import "WebRTC/RTCVideoEncoderVP9.h" // nogncheck
|
||||
#endif
|
||||
#import "WebRTC/RTCVideoEncoderVP9.h"
|
||||
#endif
|
||||
|
||||
@implementation RTCDefaultVideoEncoderFactory
|
||||
@ -42,22 +40,18 @@
|
||||
[[RTCVideoCodecInfo alloc] initWithName:kRTCVideoCodecH264Name
|
||||
parameters:constrainedBaselineParams];
|
||||
|
||||
#if defined(USE_BUILTIN_SW_CODECS)
|
||||
RTCVideoCodecInfo *vp8Info = [[RTCVideoCodecInfo alloc] initWithName:kRTCVideoCodecVp8Name];
|
||||
|
||||
#if !defined(RTC_DISABLE_VP9)
|
||||
RTCVideoCodecInfo *vp9Info = [[RTCVideoCodecInfo alloc] initWithName:kRTCVideoCodecVp9Name];
|
||||
#endif
|
||||
#endif
|
||||
|
||||
return @[
|
||||
constrainedHighInfo,
|
||||
constrainedBaselineInfo,
|
||||
#if defined(USE_BUILTIN_SW_CODECS)
|
||||
vp8Info,
|
||||
#if !defined(RTC_DISABLE_VP9)
|
||||
vp9Info,
|
||||
#endif
|
||||
#endif
|
||||
];
|
||||
}
|
||||
@ -65,13 +59,11 @@
|
||||
- (id<RTCVideoEncoder>)createEncoder:(RTCVideoCodecInfo *)info {
|
||||
if ([info.name isEqualToString:kRTCVideoCodecH264Name]) {
|
||||
return [[RTCVideoEncoderH264 alloc] initWithCodecInfo:info];
|
||||
#if defined(USE_BUILTIN_SW_CODECS)
|
||||
} else if ([info.name isEqualToString:kRTCVideoCodecVp8Name]) {
|
||||
return [RTCVideoEncoderVP8 vp8Encoder];
|
||||
#if !defined(RTC_DISABLE_VP9)
|
||||
} else if ([info.name isEqualToString:kRTCVideoCodecVp9Name]) {
|
||||
return [RTCVideoEncoderVP9 vp9Encoder];
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -23,15 +23,6 @@ class AudioProcessing;
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#if defined(USE_BUILTIN_SW_CODECS)
|
||||
namespace cricket {
|
||||
|
||||
class WebRtcVideoEncoderFactory;
|
||||
class WebRtcVideoDecoderFactory;
|
||||
|
||||
} // namespace cricket
|
||||
#endif
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
@ -58,20 +49,6 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
audioProcessingModule:
|
||||
(rtc::scoped_refptr<webrtc::AudioProcessing>)audioProcessingModule;
|
||||
|
||||
#if defined(USE_BUILTIN_SW_CODECS)
|
||||
/* Initialize object with legacy injectable native audio/video encoder/decoder factories
|
||||
TODO(andersc): Remove this when backwards compatiblity is no longer needed.
|
||||
*/
|
||||
- (instancetype)
|
||||
initWithNativeAudioEncoderFactory:
|
||||
(rtc::scoped_refptr<webrtc::AudioEncoderFactory>)audioEncoderFactory
|
||||
nativeAudioDecoderFactory:
|
||||
(rtc::scoped_refptr<webrtc::AudioDecoderFactory>)audioDecoderFactory
|
||||
legacyNativeVideoEncoderFactory:(cricket::WebRtcVideoEncoderFactory*)videoEncoderFactory
|
||||
legacyNativeVideoDecoderFactory:(cricket::WebRtcVideoDecoderFactory*)videoDecoderFactory
|
||||
audioDeviceModule:(nullable webrtc::AudioDeviceModule *)audioDeviceModule;
|
||||
#endif
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@ -58,7 +58,7 @@
|
||||
- (instancetype)init {
|
||||
#ifdef HAVE_NO_MEDIA
|
||||
return [self initWithNoMedia];
|
||||
#elif !defined(USE_BUILTIN_SW_CODECS)
|
||||
#else
|
||||
return [self initWithNativeAudioEncoderFactory:webrtc::CreateBuiltinAudioEncoderFactory()
|
||||
nativeAudioDecoderFactory:webrtc::CreateBuiltinAudioDecoderFactory()
|
||||
nativeVideoEncoderFactory:webrtc::ObjCToNativeVideoEncoderFactory(
|
||||
@ -67,18 +67,6 @@
|
||||
[[RTCVideoDecoderFactoryH264 alloc] init])
|
||||
audioDeviceModule:nullptr
|
||||
audioProcessingModule:nullptr];
|
||||
#else
|
||||
// Here we construct webrtc::ObjCVideoEncoderFactory directly because we rely
|
||||
// on the fact that they inherit from both webrtc::VideoEncoderFactory and
|
||||
// cricket::WebRtcVideoEncoderFactory.
|
||||
return [self initWithNativeAudioEncoderFactory:webrtc::CreateBuiltinAudioEncoderFactory()
|
||||
nativeAudioDecoderFactory:webrtc::CreateBuiltinAudioDecoderFactory()
|
||||
legacyNativeVideoEncoderFactory:new webrtc::ObjCVideoEncoderFactory(
|
||||
[[RTCVideoEncoderFactoryH264 alloc] init])
|
||||
legacyNativeVideoDecoderFactory:new webrtc::ObjCVideoDecoderFactory(
|
||||
[[RTCVideoDecoderFactoryH264 alloc] init])
|
||||
audioDeviceModule:nullptr];
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -151,18 +139,6 @@
|
||||
return [self initWithNoMedia];
|
||||
#else
|
||||
if (self = [self initNative]) {
|
||||
#if defined(USE_BUILTIN_SW_CODECS)
|
||||
if (!videoEncoderFactory) {
|
||||
auto legacy_video_encoder_factory = rtc::MakeUnique<webrtc::ObjCVideoEncoderFactory>(
|
||||
[[RTCVideoEncoderFactoryH264 alloc] init]);
|
||||
videoEncoderFactory = ConvertVideoEncoderFactory(std::move(legacy_video_encoder_factory));
|
||||
}
|
||||
if (!videoDecoderFactory) {
|
||||
auto legacy_video_decoder_factory = rtc::MakeUnique<webrtc::ObjCVideoDecoderFactory>(
|
||||
[[RTCVideoDecoderFactoryH264 alloc] init]);
|
||||
videoDecoderFactory = ConvertVideoDecoderFactory(std::move(legacy_video_decoder_factory));
|
||||
}
|
||||
#endif
|
||||
_nativeFactory = webrtc::CreatePeerConnectionFactory(_networkThread.get(),
|
||||
_workerThread.get(),
|
||||
_signalingThread.get(),
|
||||
@ -179,34 +155,6 @@
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(USE_BUILTIN_SW_CODECS)
|
||||
- (instancetype)
|
||||
initWithNativeAudioEncoderFactory:
|
||||
(rtc::scoped_refptr<webrtc::AudioEncoderFactory>)audioEncoderFactory
|
||||
nativeAudioDecoderFactory:
|
||||
(rtc::scoped_refptr<webrtc::AudioDecoderFactory>)audioDecoderFactory
|
||||
legacyNativeVideoEncoderFactory:(cricket::WebRtcVideoEncoderFactory *)videoEncoderFactory
|
||||
legacyNativeVideoDecoderFactory:(cricket::WebRtcVideoDecoderFactory *)videoDecoderFactory
|
||||
audioDeviceModule:(nullable webrtc::AudioDeviceModule *)audioDeviceModule {
|
||||
#ifdef HAVE_NO_MEDIA
|
||||
return [self initWithNoMedia];
|
||||
#else
|
||||
if (self = [self initNative]) {
|
||||
_nativeFactory = webrtc::CreatePeerConnectionFactory(_networkThread.get(),
|
||||
_workerThread.get(),
|
||||
_signalingThread.get(),
|
||||
audioDeviceModule,
|
||||
audioEncoderFactory,
|
||||
audioDecoderFactory,
|
||||
videoEncoderFactory,
|
||||
videoDecoderFactory);
|
||||
NSAssert(_nativeFactory, @"Failed to initialize PeerConnectionFactory!");
|
||||
}
|
||||
return self;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
- (RTCAudioSource *)audioSourceWithConstraints:(nullable RTCMediaConstraints *)constraints {
|
||||
std::unique_ptr<webrtc::MediaConstraints> nativeConstraints;
|
||||
if (constraints) {
|
||||
|
||||
@ -53,10 +53,6 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
- (instancetype)initWithNativeSdpVideoFormat:(webrtc::SdpVideoFormat)format;
|
||||
- (webrtc::SdpVideoFormat)nativeSdpVideoFormat;
|
||||
|
||||
/* TODO(andersc): These are deprecated, remove when no longer in use. */
|
||||
- (instancetype)initWithNativeVideoCodec:(cricket::VideoCodec)videoCodec;
|
||||
- (cricket::VideoCodec)nativeVideoCodec;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@ -105,11 +105,6 @@ NSString *MaxSupportedProfileLevelConstrainedHigh() {
|
||||
return [self initWithName:[NSString stringForStdString:format.name] parameters:params];
|
||||
}
|
||||
|
||||
- (instancetype)initWithNativeVideoCodec:(cricket::VideoCodec)videoCodec {
|
||||
return [self
|
||||
initWithNativeSdpVideoFormat:webrtc::SdpVideoFormat(videoCodec.name, videoCodec.params)];
|
||||
}
|
||||
|
||||
- (BOOL)isEqualToCodecInfo:(RTCVideoCodecInfo *)info {
|
||||
if (!info ||
|
||||
![self.name isEqualToString:info.name] ||
|
||||
@ -142,16 +137,6 @@ NSString *MaxSupportedProfileLevelConstrainedHigh() {
|
||||
return webrtc::SdpVideoFormat([NSString stdStringForString:_name], parameters);
|
||||
}
|
||||
|
||||
- (cricket::VideoCodec)nativeVideoCodec {
|
||||
cricket::VideoCodec codec([NSString stdStringForString:_name]);
|
||||
for (NSString *paramKey in _parameters.allKeys) {
|
||||
codec.SetParam([NSString stdStringForString:paramKey],
|
||||
[NSString stdStringForString:_parameters[paramKey]]);
|
||||
}
|
||||
|
||||
return codec;
|
||||
}
|
||||
|
||||
#pragma mark - NSCoding
|
||||
|
||||
- (instancetype)initWithCoder:(NSCoder *)decoder {
|
||||
|
||||
@ -167,8 +167,8 @@ void compressionOutputCallback(void *encoder,
|
||||
rotation:encodeParams->rotation];
|
||||
}
|
||||
|
||||
// Extract VideoToolbox profile out of the cricket::VideoCodec. If there is no
|
||||
// specific VideoToolbox profile for the specified level, AutoLevel will be
|
||||
// Extract VideoToolbox profile out of the webrtc::SdpVideoFormat. If there is
|
||||
// no specific VideoToolbox profile for the specified level, AutoLevel will be
|
||||
// returned. The user must initialize the encoder with a resolution and
|
||||
// framerate conforming to the selected H264 level regardless.
|
||||
CFStringRef ExtractProfile(webrtc::SdpVideoFormat videoFormat) {
|
||||
|
||||
Reference in New Issue
Block a user