Anders Carlsson | 7e04281 | 2017-10-05 16:55:38 +0200 | [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 09:30:29 +0200 | [diff] [blame] | 11 | #import "RTCDefaultVideoDecoderFactory.h" |
Anders Carlsson | 7e04281 | 2017-10-05 16:55:38 +0200 | [diff] [blame] | 12 | |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 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" |
Mirko Bonadei | 8ef5793 | 2018-11-16 14:38:03 +0100 | [diff] [blame] | 18 | #if defined(RTC_ENABLE_VP9) |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 19 | #import "api/video_codec/RTCVideoDecoderVP9.h" |
Anders Carlsson | dd8c165 | 2018-01-30 10:32:13 +0100 | [diff] [blame] | 20 | #endif |
Anders Carlsson | 7e04281 | 2017-10-05 16:55:38 +0200 | [diff] [blame] | 21 | |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame^] | 22 | @implementation RTC_OBJC_TYPE (RTCDefaultVideoDecoderFactory) |
Anders Carlsson | 7e04281 | 2017-10-05 16:55:38 +0200 | [diff] [blame] | 23 | |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame^] | 24 | - (NSArray<RTC_OBJC_TYPE(RTCVideoCodecInfo) *> *)supportedCodecs { |
Johannes Kron | 6a29eb1 | 2020-03-06 12:47:23 +0100 | [diff] [blame] | 25 | NSDictionary<NSString *, NSString *> *constrainedHighParams = @{ |
| 26 | @"profile-level-id" : kRTCMaxSupportedH264ProfileLevelConstrainedHigh, |
| 27 | @"level-asymmetry-allowed" : @"1", |
| 28 | @"packetization-mode" : @"1", |
| 29 | }; |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame^] | 30 | RTC_OBJC_TYPE(RTCVideoCodecInfo) *constrainedHighInfo = |
| 31 | [[RTC_OBJC_TYPE(RTCVideoCodecInfo) alloc] initWithName:kRTCVideoCodecH264Name |
| 32 | parameters:constrainedHighParams]; |
Johannes Kron | 6a29eb1 | 2020-03-06 12:47:23 +0100 | [diff] [blame] | 33 | |
| 34 | NSDictionary<NSString *, NSString *> *constrainedBaselineParams = @{ |
| 35 | @"profile-level-id" : kRTCMaxSupportedH264ProfileLevelConstrainedBaseline, |
| 36 | @"level-asymmetry-allowed" : @"1", |
| 37 | @"packetization-mode" : @"1", |
| 38 | }; |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame^] | 39 | RTC_OBJC_TYPE(RTCVideoCodecInfo) *constrainedBaselineInfo = |
| 40 | [[RTC_OBJC_TYPE(RTCVideoCodecInfo) alloc] initWithName:kRTCVideoCodecH264Name |
| 41 | parameters:constrainedBaselineParams]; |
Johannes Kron | 6a29eb1 | 2020-03-06 12:47:23 +0100 | [diff] [blame] | 42 | |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame^] | 43 | RTC_OBJC_TYPE(RTCVideoCodecInfo) *vp8Info = |
| 44 | [[RTC_OBJC_TYPE(RTCVideoCodecInfo) alloc] initWithName:kRTCVideoCodecVp8Name]; |
Johannes Kron | 6a29eb1 | 2020-03-06 12:47:23 +0100 | [diff] [blame] | 45 | |
| 46 | #if defined(RTC_ENABLE_VP9) |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame^] | 47 | RTC_OBJC_TYPE(RTCVideoCodecInfo) *vp9Info = |
| 48 | [[RTC_OBJC_TYPE(RTCVideoCodecInfo) alloc] initWithName:kRTCVideoCodecVp9Name]; |
Johannes Kron | 6a29eb1 | 2020-03-06 12:47:23 +0100 | [diff] [blame] | 49 | #endif |
| 50 | |
| 51 | return @[ |
| 52 | constrainedHighInfo, |
| 53 | constrainedBaselineInfo, |
| 54 | vp8Info, |
| 55 | #if defined(RTC_ENABLE_VP9) |
| 56 | vp9Info, |
| 57 | #endif |
| 58 | ]; |
| 59 | } |
| 60 | |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame^] | 61 | - (id<RTC_OBJC_TYPE(RTCVideoDecoder)>)createDecoder:(RTC_OBJC_TYPE(RTCVideoCodecInfo) *)info { |
Anders Carlsson | 1d4c152 | 2017-10-30 13:07:07 +0100 | [diff] [blame] | 62 | if ([info.name isEqualToString:kRTCVideoCodecH264Name]) { |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame^] | 63 | return [[RTC_OBJC_TYPE(RTCVideoDecoderH264) alloc] init]; |
Anders Carlsson | 1d4c152 | 2017-10-30 13:07:07 +0100 | [diff] [blame] | 64 | } else if ([info.name isEqualToString:kRTCVideoCodecVp8Name]) { |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame^] | 65 | return [RTC_OBJC_TYPE(RTCVideoDecoderVP8) vp8Decoder]; |
Mirko Bonadei | 8ef5793 | 2018-11-16 14:38:03 +0100 | [diff] [blame] | 66 | #if defined(RTC_ENABLE_VP9) |
Anders Carlsson | 1d4c152 | 2017-10-30 13:07:07 +0100 | [diff] [blame] | 67 | } else if ([info.name isEqualToString:kRTCVideoCodecVp9Name]) { |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame^] | 68 | return [RTC_OBJC_TYPE(RTCVideoDecoderVP9) vp9Decoder]; |
Kári Tristan Helgason | 9555e67 | 2017-12-01 14:27:07 +0100 | [diff] [blame] | 69 | #endif |
Anders Carlsson | 7e04281 | 2017-10-05 16:55:38 +0200 | [diff] [blame] | 70 | } |
| 71 | |
| 72 | return nil; |
| 73 | } |
| 74 | |
Anders Carlsson | 7e04281 | 2017-10-05 16:55:38 +0200 | [diff] [blame] | 75 | @end |