blob: 4046cfedbe9653ed16dea699ef62282eb482625b [file] [log] [blame]
Anders Carlsson7e042812017-10-05 16:55:38 +02001/*
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 09:30:29 +020011#import "RTCDefaultVideoDecoderFactory.h"
Anders Carlsson7e042812017-10-05 16:55:38 +020012
Anders Carlsson7bca8ca2018-08-30 09:30:29 +020013#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 Bonadei8ef57932018-11-16 14:38:03 +010018#if defined(RTC_ENABLE_VP9)
Anders Carlsson7bca8ca2018-08-30 09:30:29 +020019#import "api/video_codec/RTCVideoDecoderVP9.h"
Anders Carlssondd8c1652018-01-30 10:32:13 +010020#endif
Anders Carlsson7e042812017-10-05 16:55:38 +020021
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020022@implementation RTC_OBJC_TYPE (RTCDefaultVideoDecoderFactory)
Anders Carlsson7e042812017-10-05 16:55:38 +020023
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020024- (NSArray<RTC_OBJC_TYPE(RTCVideoCodecInfo) *> *)supportedCodecs {
Johannes Kron6a29eb12020-03-06 12:47:23 +010025 NSDictionary<NSString *, NSString *> *constrainedHighParams = @{
26 @"profile-level-id" : kRTCMaxSupportedH264ProfileLevelConstrainedHigh,
27 @"level-asymmetry-allowed" : @"1",
28 @"packetization-mode" : @"1",
29 };
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020030 RTC_OBJC_TYPE(RTCVideoCodecInfo) *constrainedHighInfo =
31 [[RTC_OBJC_TYPE(RTCVideoCodecInfo) alloc] initWithName:kRTCVideoCodecH264Name
32 parameters:constrainedHighParams];
Johannes Kron6a29eb12020-03-06 12:47:23 +010033
34 NSDictionary<NSString *, NSString *> *constrainedBaselineParams = @{
35 @"profile-level-id" : kRTCMaxSupportedH264ProfileLevelConstrainedBaseline,
36 @"level-asymmetry-allowed" : @"1",
37 @"packetization-mode" : @"1",
38 };
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020039 RTC_OBJC_TYPE(RTCVideoCodecInfo) *constrainedBaselineInfo =
40 [[RTC_OBJC_TYPE(RTCVideoCodecInfo) alloc] initWithName:kRTCVideoCodecH264Name
41 parameters:constrainedBaselineParams];
Johannes Kron6a29eb12020-03-06 12:47:23 +010042
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020043 RTC_OBJC_TYPE(RTCVideoCodecInfo) *vp8Info =
44 [[RTC_OBJC_TYPE(RTCVideoCodecInfo) alloc] initWithName:kRTCVideoCodecVp8Name];
Johannes Kron6a29eb12020-03-06 12:47:23 +010045
46#if defined(RTC_ENABLE_VP9)
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020047 RTC_OBJC_TYPE(RTCVideoCodecInfo) *vp9Info =
48 [[RTC_OBJC_TYPE(RTCVideoCodecInfo) alloc] initWithName:kRTCVideoCodecVp9Name];
Johannes Kron6a29eb12020-03-06 12:47:23 +010049#endif
50
51 return @[
52 constrainedHighInfo,
53 constrainedBaselineInfo,
54 vp8Info,
55#if defined(RTC_ENABLE_VP9)
56 vp9Info,
57#endif
58 ];
59}
60
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020061- (id<RTC_OBJC_TYPE(RTCVideoDecoder)>)createDecoder:(RTC_OBJC_TYPE(RTCVideoCodecInfo) *)info {
Anders Carlsson1d4c1522017-10-30 13:07:07 +010062 if ([info.name isEqualToString:kRTCVideoCodecH264Name]) {
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020063 return [[RTC_OBJC_TYPE(RTCVideoDecoderH264) alloc] init];
Anders Carlsson1d4c1522017-10-30 13:07:07 +010064 } else if ([info.name isEqualToString:kRTCVideoCodecVp8Name]) {
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020065 return [RTC_OBJC_TYPE(RTCVideoDecoderVP8) vp8Decoder];
Mirko Bonadei8ef57932018-11-16 14:38:03 +010066#if defined(RTC_ENABLE_VP9)
Anders Carlsson1d4c1522017-10-30 13:07:07 +010067 } else if ([info.name isEqualToString:kRTCVideoCodecVp9Name]) {
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020068 return [RTC_OBJC_TYPE(RTCVideoDecoderVP9) vp9Decoder];
Kári Tristan Helgason9555e672017-12-01 14:27:07 +010069#endif
Anders Carlsson7e042812017-10-05 16:55:38 +020070 }
71
72 return nil;
73}
74
Anders Carlsson7e042812017-10-05 16:55:38 +020075@end