| 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 "TGRTCDefaultVideoDecoderFactory.h" |
| 12 |
| 13 | #import "RTCH264ProfileLevelId.h" |
| 14 | #import "TGRTCVideoDecoderH264.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 | #if !defined(DISABLE_H265) |
| 22 | #import "RTCH265ProfileLevelId.h" |
| 23 | #import "TGRTCVideoDecoderH265.h" |
| 24 | #endif |
| 25 |
| 26 | @implementation TGRTCDefaultVideoDecoderFactory |
| 27 |
| 28 | - (NSArray<RTCVideoCodecInfo *> *)supportedCodecs { |
| 29 | NSDictionary<NSString *, NSString *> *constrainedHighParams = @{ |
| 30 | @"profile-level-id" : kRTCMaxSupportedH264ProfileLevelConstrainedHigh, |
| 31 | @"level-asymmetry-allowed" : @"1", |
| 32 | @"packetization-mode" : @"1", |
| 33 | }; |
| 34 | RTCVideoCodecInfo *constrainedHighInfo = |
| 35 | [[RTCVideoCodecInfo alloc] initWithName:kRTCVideoCodecH264Name |
| 36 | parameters:constrainedHighParams]; |
| 37 |
| 38 | NSDictionary<NSString *, NSString *> *constrainedBaselineParams = @{ |
| 39 | @"profile-level-id" : kRTCMaxSupportedH264ProfileLevelConstrainedBaseline, |
| 40 | @"level-asymmetry-allowed" : @"1", |
| 41 | @"packetization-mode" : @"1", |
| 42 | }; |
| 43 | RTCVideoCodecInfo *constrainedBaselineInfo = |
| 44 | [[RTCVideoCodecInfo alloc] initWithName:kRTCVideoCodecH264Name |
| 45 | parameters:constrainedBaselineParams]; |
| 46 |
| 47 | RTCVideoCodecInfo *vp8Info = [[RTCVideoCodecInfo alloc] initWithName:kRTCVideoCodecVp8Name]; |
| 48 |
| 49 | #if defined(RTC_ENABLE_VP9) |
| 50 | RTCVideoCodecInfo *vp9Info = [[RTCVideoCodecInfo alloc] initWithName:kRTCVideoCodecVp9Name]; |
| 51 | #endif |
| 52 |
| 53 | #if !defined(DISABLE_H265) |
| 54 | RTCVideoCodecInfo *h265Info = [[RTCVideoCodecInfo alloc] initWithName:kRTCVideoCodecH265Name]; |
| 55 | #endif |
| 56 |
| 57 | NSMutableArray<RTCVideoCodecInfo *> *result = [[NSMutableArray alloc] initWithArray:@[ |
| 58 | constrainedHighInfo, |
| 59 | constrainedBaselineInfo, |
| 60 | vp8Info, |
| 61 | #if defined(RTC_ENABLE_VP9) |
| 62 | vp9Info, |
| 63 | #endif |
| 64 | ]]; |
| 65 |
| 66 | #if !defined(DISABLE_H265) |
| 67 | #ifdef WEBRTC_IOS |
| 68 | if (@available(iOS 11.0, *)) { |
| 69 | [result addObject:h265Info]; |
| 70 | } |
| 71 | #else // WEBRTC_IOS |
| 72 | if (@available(macOS 10.13, *)) { |
| 73 | [result addObject:h265Info]; |
| 74 | } |
| 75 | #endif // WEBRTC_IOS |
| 76 | #endif |
| 77 |
| 78 | return result; |
| 79 | } |
| 80 |
| 81 | - (id<RTCVideoDecoder>)createDecoder:(RTCVideoCodecInfo *)info { |
| 82 | if ([info.name isEqualToString:kRTCVideoCodecH264Name]) { |
| 83 | return [[TGRTCVideoDecoderH264 alloc] init]; |
| 84 | } else if ([info.name isEqualToString:kRTCVideoCodecVp8Name]) { |
| 85 | return [RTCVideoDecoderVP8 vp8Decoder]; |
| 86 | } |
| 87 |
| 88 | #if defined(RTC_ENABLE_VP9) |
| 89 | if ([info.name isEqualToString:kRTCVideoCodecVp9Name]) { |
| 90 | return [RTCVideoDecoderVP9 vp9Decoder]; |
| 91 | } |
| 92 | #endif |
| 93 |
| 94 | #if !defined(DISABLE_H265) |
| 95 | #ifdef WEBRTC_IOS |
| 96 | if (@available(iOS 11.0, *)) { |
| 97 | if ([info.name isEqualToString:kRTCVideoCodecH265Name]) { |
| 98 | return [[TGRTCVideoDecoderH265 alloc] init]; |
| 99 | } |
| 100 | } |
| 101 | #else // WEBRTC_IOS |
| 102 | if (@available(macOS 10.13, *)) { |
| 103 | if ([info.name isEqualToString:kRTCVideoCodecH265Name]) { |
| 104 | return [[TGRTCVideoDecoderH265 alloc] init]; |
| 105 | } |
| 106 | } |
| 107 | #endif // WEBRTC_IOS |
| 108 | #endif // !DISABLE_H265 |
| 109 |
| 110 | return nil; |
| 111 | } |
| 112 |
| 113 | @end |
| 114 |