From 9555e67db5ebca2ed875c92547bd9371d865e74c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A1ri=20Tristan=20Helgason?= Date: Fri, 1 Dec 2017 14:27:07 +0100 Subject: [PATCH] Don't create VP9 codec factories when building without VP9. This fixes a bug where AppRTCMobile would crash at runtime when built without VP9 support. Bug: webrtc:8602 Change-Id: Id2db79c3ff8136f06dc049afcc5197e9356fd25b Reviewed-on: https://webrtc-review.googlesource.com/27983 Reviewed-by: Oleh Prypin Reviewed-by: Magnus Jedvert Commit-Queue: Oleh Prypin Cr-Commit-Position: refs/heads/master@{#20982} --- .../PeerConnection/RTCDefaultVideoDecoderFactory.m | 6 ++++++ .../PeerConnection/RTCDefaultVideoEncoderFactory.m | 14 +++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/sdk/objc/Framework/Classes/PeerConnection/RTCDefaultVideoDecoderFactory.m b/sdk/objc/Framework/Classes/PeerConnection/RTCDefaultVideoDecoderFactory.m index 0ce0502cc0..ba27ad2b29 100644 --- a/sdk/objc/Framework/Classes/PeerConnection/RTCDefaultVideoDecoderFactory.m +++ b/sdk/objc/Framework/Classes/PeerConnection/RTCDefaultVideoDecoderFactory.m @@ -12,7 +12,9 @@ #import "WebRTC/RTCVideoCodecH264.h" #import "WebRTC/RTCVideoDecoderVP8.h" +#if !defined(RTC_DISABLE_VP9) #import "WebRTC/RTCVideoDecoderVP9.h" +#endif @implementation RTCDefaultVideoDecoderFactory @@ -21,8 +23,10 @@ return [[RTCVideoDecoderH264 alloc] init]; } else if ([info.name isEqualToString:kRTCVideoCodecVp8Name]) { return [RTCVideoDecoderVP8 vp8Decoder]; +#if !defined(RTC_DISABLE_VP9) } else if ([info.name isEqualToString:kRTCVideoCodecVp9Name]) { return [RTCVideoDecoderVP9 vp9Decoder]; +#endif } return nil; @@ -32,7 +36,9 @@ return @[ [[RTCVideoCodecInfo alloc] initWithName:kRTCVideoCodecH264Name], [[RTCVideoCodecInfo alloc] initWithName:kRTCVideoCodecVp8Name], +#if !defined(RTC_DISABLE_VP9) [[RTCVideoCodecInfo alloc] initWithName:kRTCVideoCodecVp9Name] +#endif ]; } diff --git a/sdk/objc/Framework/Classes/PeerConnection/RTCDefaultVideoEncoderFactory.m b/sdk/objc/Framework/Classes/PeerConnection/RTCDefaultVideoEncoderFactory.m index 71ffe2997a..154fac746b 100644 --- a/sdk/objc/Framework/Classes/PeerConnection/RTCDefaultVideoEncoderFactory.m +++ b/sdk/objc/Framework/Classes/PeerConnection/RTCDefaultVideoEncoderFactory.m @@ -13,7 +13,9 @@ #import "WebRTC/RTCVideoCodec.h" #import "WebRTC/RTCVideoCodecH264.h" #import "WebRTC/RTCVideoEncoderVP8.h" +#if !defined(RTC_DISABLE_VP9) #import "WebRTC/RTCVideoEncoderVP9.h" +#endif @implementation RTCDefaultVideoEncoderFactory @@ -40,9 +42,17 @@ RTCVideoCodecInfo *vp8Info = [[RTCVideoCodecInfo alloc] initWithName:kRTCVideoCodecVp8Name]; +#if !defined(RTC_DISABLE_VP9) RTCVideoCodecInfo *vp9Info = [[RTCVideoCodecInfo alloc] initWithName:kRTCVideoCodecVp9Name]; +#endif - return @[ constrainedHighInfo, constrainedBaselineInfo, vp8Info, vp9Info ]; + return @[ constrainedHighInfo, + constrainedBaselineInfo, + vp8Info, +#if !defined(RTC_DISABLE_VP9) + vp9Info +#endif + ]; } - (id)createEncoder:(RTCVideoCodecInfo *)info { @@ -50,8 +60,10 @@ return [[RTCVideoEncoderH264 alloc] initWithCodecInfo:info]; } else if ([info.name isEqualToString:kRTCVideoCodecVp8Name]) { return [RTCVideoEncoderVP8 vp8Encoder]; +#if !defined(RTC_DISABLE_VP9) } else if ([info.name isEqualToString:kRTCVideoCodecVp9Name]) { return [RTCVideoEncoderVP9 vp9Encoder]; +#endif } return nil;