blob: 6e3baa8750458a8d7eb29c22603553bde1f81fa5 [file] [log] [blame]
Anders Carlsson7e042812017-10-05 14:55:381/*
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 Carlsson7bca8ca2018-08-30 07:30:2911#import "RTCDefaultVideoDecoderFactory.h"
Anders Carlsson7e042812017-10-05 14:55:3812
Anders Carlsson7bca8ca2018-08-30 07:30:2913#import "RTCH264ProfileLevelId.h"
14#import "RTCVideoDecoderH264.h"
15#import "api/video_codec/RTCVideoCodecConstants.h"
Anders Carlsson7bca8ca2018-08-30 07:30:2916#import "api/video_codec/RTCVideoDecoderVP8.h"
Anders Carlsson7bca8ca2018-08-30 07:30:2917#import "api/video_codec/RTCVideoDecoderVP9.h"
Yura Yaroshevich8cfb2872021-03-03 09:29:4218#import "base/RTCVideoCodecInfo.h"
Anders Carlsson7e042812017-10-05 14:55:3819
philipeld44badf2022-07-04 08:44:1420#if defined(RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY)
21#import "api/video_codec/RTCVideoDecoderAV1.h" // nogncheck
22#endif
23
Mirko Bonadeia81e9c82020-05-04 14:14:3224@implementation RTC_OBJC_TYPE (RTCDefaultVideoDecoderFactory)
Anders Carlsson7e042812017-10-05 14:55:3825
Mirko Bonadeia81e9c82020-05-04 14:14:3226- (NSArray<RTC_OBJC_TYPE(RTCVideoCodecInfo) *> *)supportedCodecs {
Johannes Kron6a29eb12020-03-06 11:47:2327 NSDictionary<NSString *, NSString *> *constrainedHighParams = @{
28 @"profile-level-id" : kRTCMaxSupportedH264ProfileLevelConstrainedHigh,
29 @"level-asymmetry-allowed" : @"1",
30 @"packetization-mode" : @"1",
31 };
Mirko Bonadeia81e9c82020-05-04 14:14:3232 RTC_OBJC_TYPE(RTCVideoCodecInfo) *constrainedHighInfo =
33 [[RTC_OBJC_TYPE(RTCVideoCodecInfo) alloc] initWithName:kRTCVideoCodecH264Name
34 parameters:constrainedHighParams];
Johannes Kron6a29eb12020-03-06 11:47:2335
36 NSDictionary<NSString *, NSString *> *constrainedBaselineParams = @{
37 @"profile-level-id" : kRTCMaxSupportedH264ProfileLevelConstrainedBaseline,
38 @"level-asymmetry-allowed" : @"1",
39 @"packetization-mode" : @"1",
40 };
Mirko Bonadeia81e9c82020-05-04 14:14:3241 RTC_OBJC_TYPE(RTCVideoCodecInfo) *constrainedBaselineInfo =
42 [[RTC_OBJC_TYPE(RTCVideoCodecInfo) alloc] initWithName:kRTCVideoCodecH264Name
43 parameters:constrainedBaselineParams];
Johannes Kron6a29eb12020-03-06 11:47:2344
Mirko Bonadeia81e9c82020-05-04 14:14:3245 RTC_OBJC_TYPE(RTCVideoCodecInfo) *vp8Info =
46 [[RTC_OBJC_TYPE(RTCVideoCodecInfo) alloc] initWithName:kRTCVideoCodecVp8Name];
Johannes Kron6a29eb12020-03-06 11:47:2347
Yura Yaroshevich8cfb2872021-03-03 09:29:4248 NSMutableArray<RTC_OBJC_TYPE(RTCVideoCodecInfo) *> *result = [@[
Johannes Kron6a29eb12020-03-06 11:47:2349 constrainedHighInfo,
50 constrainedBaselineInfo,
51 vp8Info,
Yura Yaroshevich8cfb2872021-03-03 09:29:4252 ] mutableCopy];
53
54 if ([RTC_OBJC_TYPE(RTCVideoDecoderVP9) isSupported]) {
55 [result
56 addObject:[[RTC_OBJC_TYPE(RTCVideoCodecInfo) alloc] initWithName:kRTCVideoCodecVp9Name]];
57 }
58
philipeld44badf2022-07-04 08:44:1459#if defined(RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY)
60 [result addObject:[[RTC_OBJC_TYPE(RTCVideoCodecInfo) alloc] initWithName:kRTCVideoCodecAv1Name]];
61#endif
Yura Yaroshevich8cfb2872021-03-03 09:29:4262
63 return result;
Johannes Kron6a29eb12020-03-06 11:47:2364}
65
Mirko Bonadeia81e9c82020-05-04 14:14:3266- (id<RTC_OBJC_TYPE(RTCVideoDecoder)>)createDecoder:(RTC_OBJC_TYPE(RTCVideoCodecInfo) *)info {
Anders Carlsson1d4c1522017-10-30 12:07:0767 if ([info.name isEqualToString:kRTCVideoCodecH264Name]) {
Mirko Bonadeia81e9c82020-05-04 14:14:3268 return [[RTC_OBJC_TYPE(RTCVideoDecoderH264) alloc] init];
Anders Carlsson1d4c1522017-10-30 12:07:0769 } else if ([info.name isEqualToString:kRTCVideoCodecVp8Name]) {
Mirko Bonadeia81e9c82020-05-04 14:14:3270 return [RTC_OBJC_TYPE(RTCVideoDecoderVP8) vp8Decoder];
Yura Yaroshevich8cfb2872021-03-03 09:29:4271 } else if ([info.name isEqualToString:kRTCVideoCodecVp9Name] &&
72 [RTC_OBJC_TYPE(RTCVideoDecoderVP9) isSupported]) {
Mirko Bonadeia81e9c82020-05-04 14:14:3273 return [RTC_OBJC_TYPE(RTCVideoDecoderVP9) vp9Decoder];
philipeld44badf2022-07-04 08:44:1474 }
75
76#if defined(RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY)
77 if ([info.name isEqualToString:kRTCVideoCodecAv1Name]) {
Yura Yaroshevich8cfb2872021-03-03 09:29:4278 return [RTC_OBJC_TYPE(RTCVideoDecoderAV1) av1Decoder];
Anders Carlsson7e042812017-10-05 14:55:3879 }
philipeld44badf2022-07-04 08:44:1480#endif
Anders Carlsson7e042812017-10-05 14:55:3881
82 return nil;
83}
84
Anders Carlsson7e042812017-10-05 14:55:3885@end