Enable building WebRTC without built-in software codecs
This CL adds a GN build flag to include builtin software codecs (enabled by default). When setting the flag to false, libvpx can also be excluded. The benefit is that the resulting binary is smaller. Replaces https://webrtc-review.googlesource.com/c/src/+/29203 Bug: webrtc:7925 Change-Id: Id330ea8a43169e449ee139eca18e4557cc932e10 Reviewed-on: https://webrtc-review.googlesource.com/36340 Commit-Queue: Anders Carlsson <andersc@webrtc.org> Reviewed-by: Patrik Höglund <phoglund@webrtc.org> Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org> Reviewed-by: Erik Språng <sprang@webrtc.org> Reviewed-by: Magnus Jedvert <magjed@webrtc.org> Cr-Commit-Position: refs/heads/master@{#21818}
This commit is contained in:
committed by
Commit Bot
parent
70294c8eab
commit
dd8c16574e
@ -11,21 +11,25 @@
|
||||
#import "WebRTC/RTCVideoCodecFactory.h"
|
||||
|
||||
#import "WebRTC/RTCVideoCodecH264.h"
|
||||
#if defined(USE_BUILTIN_SW_CODECS)
|
||||
#import "WebRTC/RTCVideoDecoderVP8.h"
|
||||
#if !defined(RTC_DISABLE_VP9)
|
||||
#import "WebRTC/RTCVideoDecoderVP9.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@implementation RTCDefaultVideoDecoderFactory
|
||||
|
||||
- (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
|
||||
}
|
||||
|
||||
@ -35,9 +39,11 @@
|
||||
- (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]
|
||||
[[RTCVideoCodecInfo alloc] initWithName:kRTCVideoCodecVp9Name],
|
||||
#endif
|
||||
#endif
|
||||
];
|
||||
}
|
||||
|
||||
@ -12,10 +12,12 @@
|
||||
|
||||
#import "WebRTC/RTCVideoCodec.h"
|
||||
#import "WebRTC/RTCVideoCodecH264.h"
|
||||
#if defined(USE_BUILTIN_SW_CODECS)
|
||||
#import "WebRTC/RTCVideoEncoderVP8.h"
|
||||
#if !defined(RTC_DISABLE_VP9)
|
||||
#import "WebRTC/RTCVideoEncoderVP9.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@implementation RTCDefaultVideoEncoderFactory
|
||||
|
||||
@ -40,29 +42,36 @@
|
||||
[[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
|
||||
|
||||
return @[ constrainedHighInfo,
|
||||
constrainedBaselineInfo,
|
||||
vp8Info,
|
||||
#if !defined(RTC_DISABLE_VP9)
|
||||
vp9Info
|
||||
#endif
|
||||
];
|
||||
|
||||
return @[
|
||||
constrainedHighInfo,
|
||||
constrainedBaselineInfo,
|
||||
#if defined(USE_BUILTIN_SW_CODECS)
|
||||
vp8Info,
|
||||
#if !defined(RTC_DISABLE_VP9)
|
||||
vp9Info,
|
||||
#endif
|
||||
#endif
|
||||
];
|
||||
}
|
||||
|
||||
- (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,12 +23,14 @@ class AudioProcessing;
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#if defined(USE_BUILTIN_SW_CODECS)
|
||||
namespace cricket {
|
||||
|
||||
class WebRtcVideoEncoderFactory;
|
||||
class WebRtcVideoDecoderFactory;
|
||||
|
||||
} // namespace cricket
|
||||
#endif
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@ -56,6 +58,7 @@ 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.
|
||||
*/
|
||||
@ -67,6 +70,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
legacyNativeVideoEncoderFactory:(cricket::WebRtcVideoEncoderFactory*)videoEncoderFactory
|
||||
legacyNativeVideoDecoderFactory:(cricket::WebRtcVideoDecoderFactory*)videoDecoderFactory
|
||||
audioDeviceModule:(nullable webrtc::AudioDeviceModule *)audioDeviceModule;
|
||||
#endif
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@ -58,6 +58,17 @@
|
||||
- (instancetype)init {
|
||||
#ifdef HAVE_NO_MEDIA
|
||||
return [self initWithNoMedia];
|
||||
#elif !defined(USE_BUILTIN_SW_CODECS)
|
||||
return [self initWithNativeAudioEncoderFactory:webrtc::CreateBuiltinAudioEncoderFactory()
|
||||
nativeAudioDecoderFactory:webrtc::CreateBuiltinAudioDecoderFactory()
|
||||
nativeVideoEncoderFactory:std::unique_ptr<webrtc::VideoEncoderFactory>(
|
||||
new webrtc::ObjCVideoEncoderFactory(
|
||||
[[RTCVideoEncoderFactoryH264 alloc] init]))
|
||||
nativeVideoDecoderFactory:std::unique_ptr<webrtc::VideoDecoderFactory>(
|
||||
new webrtc::ObjCVideoDecoderFactory(
|
||||
[[RTCVideoDecoderFactoryH264 alloc] init]))
|
||||
audioDeviceModule:nullptr
|
||||
audioProcessingModule:nullptr];
|
||||
#else
|
||||
return [self initWithNativeAudioEncoderFactory:webrtc::CreateBuiltinAudioEncoderFactory()
|
||||
nativeAudioDecoderFactory:webrtc::CreateBuiltinAudioDecoderFactory()
|
||||
@ -139,6 +150,7 @@
|
||||
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]);
|
||||
@ -149,6 +161,7 @@
|
||||
[[RTCVideoDecoderFactoryH264 alloc] init]);
|
||||
videoDecoderFactory = ConvertVideoDecoderFactory(std::move(legacy_video_decoder_factory));
|
||||
}
|
||||
#endif
|
||||
_nativeFactory = webrtc::CreatePeerConnectionFactory(_networkThread.get(),
|
||||
_workerThread.get(),
|
||||
_signalingThread.get(),
|
||||
@ -165,6 +178,7 @@
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(USE_BUILTIN_SW_CODECS)
|
||||
- (instancetype)
|
||||
initWithNativeAudioEncoderFactory:
|
||||
(rtc::scoped_refptr<webrtc::AudioEncoderFactory>)audioEncoderFactory
|
||||
@ -190,6 +204,7 @@
|
||||
return self;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
- (RTCAudioSource *)audioSourceWithConstraints:(nullable RTCMediaConstraints *)constraints {
|
||||
std::unique_ptr<webrtc::MediaConstraints> nativeConstraints;
|
||||
|
||||
Reference in New Issue
Block a user