1/* 2 * Copyright 2017 The WebRTC Project Authors. All rights reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11#import "RTCDefaultVideoDecoderFactory.h" 12 13#import "RTCH264ProfileLevelId.h" 14#import "RTCVideoDecoderH264.h" 15#import "api/video_codec/RTCVideoCodecConstants.h" 16#import "api/video_codec/RTCVideoDecoderVP8.h" 17#import "base/RTCVideoCodecInfo.h" 18#if defined(RTC_ENABLE_VP9) 19#import "api/video_codec/RTCVideoDecoderVP9.h" 20#endif 21 22@implementation RTC_OBJC_TYPE (RTCDefaultVideoDecoderFactory) 23 24- (NSArray<RTC_OBJC_TYPE(RTCVideoCodecInfo) *> *)supportedCodecs { 25 NSDictionary<NSString *, NSString *> *constrainedHighParams = @{ 26 @"profile-level-id" : kRTCMaxSupportedH264ProfileLevelConstrainedHigh, 27 @"level-asymmetry-allowed" : @"1", 28 @"packetization-mode" : @"1", 29 }; 30 RTC_OBJC_TYPE(RTCVideoCodecInfo) *constrainedHighInfo = 31 [[RTC_OBJC_TYPE(RTCVideoCodecInfo) alloc] initWithName:kRTCVideoCodecH264Name 32 parameters:constrainedHighParams]; 33 34 NSDictionary<NSString *, NSString *> *constrainedBaselineParams = @{ 35 @"profile-level-id" : kRTCMaxSupportedH264ProfileLevelConstrainedBaseline, 36 @"level-asymmetry-allowed" : @"1", 37 @"packetization-mode" : @"1", 38 }; 39 RTC_OBJC_TYPE(RTCVideoCodecInfo) *constrainedBaselineInfo = 40 [[RTC_OBJC_TYPE(RTCVideoCodecInfo) alloc] initWithName:kRTCVideoCodecH264Name 41 parameters:constrainedBaselineParams]; 42 43 RTC_OBJC_TYPE(RTCVideoCodecInfo) *vp8Info = 44 [[RTC_OBJC_TYPE(RTCVideoCodecInfo) alloc] initWithName:kRTCVideoCodecVp8Name]; 45 46#if defined(RTC_ENABLE_VP9) 47 RTC_OBJC_TYPE(RTCVideoCodecInfo) *vp9Info = 48 [[RTC_OBJC_TYPE(RTCVideoCodecInfo) alloc] initWithName:kRTCVideoCodecVp9Name]; 49#endif 50 51 return @[ 52 constrainedHighInfo, 53 constrainedBaselineInfo, 54 vp8Info, 55#if defined(RTC_ENABLE_VP9) 56 vp9Info, 57#endif 58 ]; 59} 60 61- (id<RTC_OBJC_TYPE(RTCVideoDecoder)>)createDecoder:(RTC_OBJC_TYPE(RTCVideoCodecInfo) *)info { 62 if ([info.name isEqualToString:kRTCVideoCodecH264Name]) { 63 return [[RTC_OBJC_TYPE(RTCVideoDecoderH264) alloc] init]; 64 } else if ([info.name isEqualToString:kRTCVideoCodecVp8Name]) { 65 return [RTC_OBJC_TYPE(RTCVideoDecoderVP8) vp8Decoder]; 66#if defined(RTC_ENABLE_VP9) 67 } else if ([info.name isEqualToString:kRTCVideoCodecVp9Name]) { 68 return [RTC_OBJC_TYPE(RTCVideoDecoderVP9) vp9Decoder]; 69#endif 70 } 71 72 return nil; 73} 74 75@end 76