blob: 51583d09eb69f2796c504ee1dc906585ebecff89 [file] [log] [blame]
kthelgasonfb143122017-07-25 07:55:58 -07001/*
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
11#import "WebRTC/RTCVideoCodecH264.h"
12
13#include <vector>
14
15#import "RTCVideoCodec+Private.h"
16#import "WebRTC/RTCVideoCodec.h"
kthelgasonfb143122017-07-25 07:55:58 -070017
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020018#include "rtc_base/timeutils.h"
kthelgasonfb143122017-07-25 07:55:58 -070019
20// H264 specific settings.
21@implementation RTCCodecSpecificInfoH264
22
23@synthesize packetizationMode = _packetizationMode;
24
magjed8eab09c2017-07-31 02:56:35 -070025- (webrtc::CodecSpecificInfo)nativeCodecSpecificInfo {
kthelgasonfb143122017-07-25 07:55:58 -070026 webrtc::CodecSpecificInfo codecSpecificInfo;
27 codecSpecificInfo.codecType = webrtc::kVideoCodecH264;
Kári Tristan Helgasonfc313dc2017-10-20 11:01:22 +020028 codecSpecificInfo.codec_name = [kRTCVideoCodecH264Name cStringUsingEncoding:NSUTF8StringEncoding];
kthelgasonfb143122017-07-25 07:55:58 -070029 codecSpecificInfo.codecSpecific.H264.packetization_mode =
30 (webrtc::H264PacketizationMode)_packetizationMode;
31
32 return codecSpecificInfo;
33}
34
35@end
36
kthelgasonfb143122017-07-25 07:55:58 -070037// Encoder factory.
38@implementation RTCVideoEncoderFactoryH264
39
40- (NSArray<RTCVideoCodecInfo *> *)supportedCodecs {
41 NSMutableArray<RTCVideoCodecInfo *> *codecs = [NSMutableArray array];
Kári Tristan Helgasonfc313dc2017-10-20 11:01:22 +020042 NSString *codecName = kRTCVideoCodecH264Name;
kthelgasonfb143122017-07-25 07:55:58 -070043
Kári Tristan Helgasoncad94442018-05-02 10:29:12 +020044 NSDictionary<NSString *, NSString *> *constrainedHighParams = @{
45 @"profile-level-id" : kRTCMaxSupportedH264ProfileLevelConstrainedHigh,
46 @"level-asymmetry-allowed" : @"1",
47 @"packetization-mode" : @"1",
48 };
49 RTCVideoCodecInfo *constrainedHighInfo =
50 [[RTCVideoCodecInfo alloc] initWithName:codecName parameters:constrainedHighParams];
51 [codecs addObject:constrainedHighInfo];
kthelgasonfb143122017-07-25 07:55:58 -070052
53 NSDictionary<NSString *, NSString *> *constrainedBaselineParams = @{
Yura Yaroshevich0f77fea2018-04-26 15:41:01 +030054 @"profile-level-id" : kRTCMaxSupportedH264ProfileLevelConstrainedBaseline,
kthelgasonfb143122017-07-25 07:55:58 -070055 @"level-asymmetry-allowed" : @"1",
56 @"packetization-mode" : @"1",
57 };
58 RTCVideoCodecInfo *constrainedBaselineInfo =
andersc81bc5232017-08-18 06:34:09 -070059 [[RTCVideoCodecInfo alloc] initWithName:codecName parameters:constrainedBaselineParams];
kthelgasonfb143122017-07-25 07:55:58 -070060 [codecs addObject:constrainedBaselineInfo];
61
62 return [codecs copy];
63}
64
65- (id<RTCVideoEncoder>)createEncoder:(RTCVideoCodecInfo *)info {
66 return [[RTCVideoEncoderH264 alloc] initWithCodecInfo:info];
67}
68
69@end
70
71// Decoder factory.
72@implementation RTCVideoDecoderFactoryH264
73
74- (id<RTCVideoDecoder>)createDecoder:(RTCVideoCodecInfo *)info {
75 return [[RTCVideoDecoderH264 alloc] init];
76}
77
78- (NSArray<RTCVideoCodecInfo *> *)supportedCodecs {
Kári Tristan Helgasonfc313dc2017-10-20 11:01:22 +020079 NSString *codecName = kRTCVideoCodecH264Name;
andersc81bc5232017-08-18 06:34:09 -070080 return @[ [[RTCVideoCodecInfo alloc] initWithName:codecName parameters:nil] ];
kthelgasonfb143122017-07-25 07:55:58 -070081}
82
83@end