Anders Carlsson | 7e04281 | 2017-10-05 14:55:38 | [diff] [blame] | 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 | |
Anders Carlsson | 7bca8ca | 2018-08-30 07:30:29 | [diff] [blame] | 11 | #import "RTCDefaultVideoDecoderFactory.h" |
Anders Carlsson | 7e04281 | 2017-10-05 14:55:38 | [diff] [blame] | 12 | |
Anders Carlsson | 7bca8ca | 2018-08-30 07:30:29 | [diff] [blame] | 13 | #import "RTCH264ProfileLevelId.h" |
| 14 | #import "RTCVideoDecoderH264.h" |
| 15 | #import "api/video_codec/RTCVideoCodecConstants.h" |
Anders Carlsson | 7bca8ca | 2018-08-30 07:30:29 | [diff] [blame] | 16 | #import "api/video_codec/RTCVideoDecoderVP8.h" |
Anders Carlsson | 7bca8ca | 2018-08-30 07:30:29 | [diff] [blame] | 17 | #import "api/video_codec/RTCVideoDecoderVP9.h" |
Yura Yaroshevich | 8cfb287 | 2021-03-03 09:29:42 | [diff] [blame] | 18 | #import "base/RTCVideoCodecInfo.h" |
Anders Carlsson | 7e04281 | 2017-10-05 14:55:38 | [diff] [blame] | 19 | |
philipel | d44badf | 2022-07-04 08:44:14 | [diff] [blame] | 20 | #if defined(RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY) |
| 21 | #import "api/video_codec/RTCVideoDecoderAV1.h" // nogncheck |
| 22 | #endif |
| 23 | |
Mirko Bonadei | a81e9c8 | 2020-05-04 14:14:32 | [diff] [blame] | 24 | @implementation RTC_OBJC_TYPE (RTCDefaultVideoDecoderFactory) |
Anders Carlsson | 7e04281 | 2017-10-05 14:55:38 | [diff] [blame] | 25 | |
Mirko Bonadei | a81e9c8 | 2020-05-04 14:14:32 | [diff] [blame] | 26 | - (NSArray<RTC_OBJC_TYPE(RTCVideoCodecInfo) *> *)supportedCodecs { |
Johannes Kron | 6a29eb1 | 2020-03-06 11:47:23 | [diff] [blame] | 27 | NSDictionary<NSString *, NSString *> *constrainedHighParams = @{ |
| 28 | @"profile-level-id" : kRTCMaxSupportedH264ProfileLevelConstrainedHigh, |
| 29 | @"level-asymmetry-allowed" : @"1", |
| 30 | @"packetization-mode" : @"1", |
| 31 | }; |
Mirko Bonadei | a81e9c8 | 2020-05-04 14:14:32 | [diff] [blame] | 32 | RTC_OBJC_TYPE(RTCVideoCodecInfo) *constrainedHighInfo = |
| 33 | [[RTC_OBJC_TYPE(RTCVideoCodecInfo) alloc] initWithName:kRTCVideoCodecH264Name |
| 34 | parameters:constrainedHighParams]; |
Johannes Kron | 6a29eb1 | 2020-03-06 11:47:23 | [diff] [blame] | 35 | |
| 36 | NSDictionary<NSString *, NSString *> *constrainedBaselineParams = @{ |
| 37 | @"profile-level-id" : kRTCMaxSupportedH264ProfileLevelConstrainedBaseline, |
| 38 | @"level-asymmetry-allowed" : @"1", |
| 39 | @"packetization-mode" : @"1", |
| 40 | }; |
Mirko Bonadei | a81e9c8 | 2020-05-04 14:14:32 | [diff] [blame] | 41 | RTC_OBJC_TYPE(RTCVideoCodecInfo) *constrainedBaselineInfo = |
| 42 | [[RTC_OBJC_TYPE(RTCVideoCodecInfo) alloc] initWithName:kRTCVideoCodecH264Name |
| 43 | parameters:constrainedBaselineParams]; |
Johannes Kron | 6a29eb1 | 2020-03-06 11:47:23 | [diff] [blame] | 44 | |
Mirko Bonadei | a81e9c8 | 2020-05-04 14:14:32 | [diff] [blame] | 45 | RTC_OBJC_TYPE(RTCVideoCodecInfo) *vp8Info = |
| 46 | [[RTC_OBJC_TYPE(RTCVideoCodecInfo) alloc] initWithName:kRTCVideoCodecVp8Name]; |
Johannes Kron | 6a29eb1 | 2020-03-06 11:47:23 | [diff] [blame] | 47 | |
Yura Yaroshevich | 8cfb287 | 2021-03-03 09:29:42 | [diff] [blame] | 48 | NSMutableArray<RTC_OBJC_TYPE(RTCVideoCodecInfo) *> *result = [@[ |
Johannes Kron | 6a29eb1 | 2020-03-06 11:47:23 | [diff] [blame] | 49 | constrainedHighInfo, |
| 50 | constrainedBaselineInfo, |
| 51 | vp8Info, |
Yura Yaroshevich | 8cfb287 | 2021-03-03 09:29:42 | [diff] [blame] | 52 | ] mutableCopy]; |
| 53 | |
| 54 | if ([RTC_OBJC_TYPE(RTCVideoDecoderVP9) isSupported]) { |
| 55 | [result |
| 56 | addObject:[[RTC_OBJC_TYPE(RTCVideoCodecInfo) alloc] initWithName:kRTCVideoCodecVp9Name]]; |
| 57 | } |
| 58 | |
philipel | d44badf | 2022-07-04 08:44:14 | [diff] [blame] | 59 | #if defined(RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY) |
| 60 | [result addObject:[[RTC_OBJC_TYPE(RTCVideoCodecInfo) alloc] initWithName:kRTCVideoCodecAv1Name]]; |
| 61 | #endif |
Yura Yaroshevich | 8cfb287 | 2021-03-03 09:29:42 | [diff] [blame] | 62 | |
| 63 | return result; |
Johannes Kron | 6a29eb1 | 2020-03-06 11:47:23 | [diff] [blame] | 64 | } |
| 65 | |
Mirko Bonadei | a81e9c8 | 2020-05-04 14:14:32 | [diff] [blame] | 66 | - (id<RTC_OBJC_TYPE(RTCVideoDecoder)>)createDecoder:(RTC_OBJC_TYPE(RTCVideoCodecInfo) *)info { |
Anders Carlsson | 1d4c152 | 2017-10-30 12:07:07 | [diff] [blame] | 67 | if ([info.name isEqualToString:kRTCVideoCodecH264Name]) { |
Mirko Bonadei | a81e9c8 | 2020-05-04 14:14:32 | [diff] [blame] | 68 | return [[RTC_OBJC_TYPE(RTCVideoDecoderH264) alloc] init]; |
Anders Carlsson | 1d4c152 | 2017-10-30 12:07:07 | [diff] [blame] | 69 | } else if ([info.name isEqualToString:kRTCVideoCodecVp8Name]) { |
Mirko Bonadei | a81e9c8 | 2020-05-04 14:14:32 | [diff] [blame] | 70 | return [RTC_OBJC_TYPE(RTCVideoDecoderVP8) vp8Decoder]; |
Yura Yaroshevich | 8cfb287 | 2021-03-03 09:29:42 | [diff] [blame] | 71 | } else if ([info.name isEqualToString:kRTCVideoCodecVp9Name] && |
| 72 | [RTC_OBJC_TYPE(RTCVideoDecoderVP9) isSupported]) { |
Mirko Bonadei | a81e9c8 | 2020-05-04 14:14:32 | [diff] [blame] | 73 | return [RTC_OBJC_TYPE(RTCVideoDecoderVP9) vp9Decoder]; |
philipel | d44badf | 2022-07-04 08:44:14 | [diff] [blame] | 74 | } |
| 75 | |
| 76 | #if defined(RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY) |
| 77 | if ([info.name isEqualToString:kRTCVideoCodecAv1Name]) { |
Yura Yaroshevich | 8cfb287 | 2021-03-03 09:29:42 | [diff] [blame] | 78 | return [RTC_OBJC_TYPE(RTCVideoDecoderAV1) av1Decoder]; |
Anders Carlsson | 7e04281 | 2017-10-05 14:55:38 | [diff] [blame] | 79 | } |
philipel | d44badf | 2022-07-04 08:44:14 | [diff] [blame] | 80 | #endif |
Anders Carlsson | 7e04281 | 2017-10-05 14:55:38 | [diff] [blame] | 81 | |
| 82 | return nil; |
| 83 | } |
| 84 | |
Anders Carlsson | 7e04281 | 2017-10-05 14:55:38 | [diff] [blame] | 85 | @end |