blob: a895011a720629228a22885924299085e3bde63e [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
11#import "ARDVideoEncoderFactory.h"
12
13#import "WebRTC/RTCVideoCodecH264.h"
14#import "WebRTC/RTCVideoEncoderVP8.h"
15#import "WebRTC/RTCVideoEncoderVP9.h"
16
17static NSString *kLevel31ConstrainedHigh = @"640c1f";
18static NSString *kLevel31ConstrainedBaseline = @"42e01f";
19
20@implementation ARDVideoEncoderFactory
21
22- (id<RTCVideoEncoder>)createEncoder:(RTCVideoCodecInfo *)info {
23 if ([info.name isEqualToString:@"H264"]) {
24 return [[RTCVideoEncoderH264 alloc] initWithCodecInfo:info];
25 } else if ([info.name isEqualToString:@"VP8"]) {
26 return [RTCVideoEncoderVP8 vp8Encoder];
27 } else if ([info.name isEqualToString:@"VP9"]) {
28 return [RTCVideoEncoderVP9 vp9Encoder];
29 }
30
31 return nil;
32}
33
34- (NSArray<RTCVideoCodecInfo *> *)supportedCodecs {
35 NSMutableArray<RTCVideoCodecInfo *> *codecs = [NSMutableArray array];
36
37 NSDictionary<NSString *, NSString *> *constrainedHighParams = @{
38 @"profile-level-id" : kLevel31ConstrainedHigh,
39 @"level-asymmetry-allowed" : @"1",
40 @"packetization-mode" : @"1",
41 };
42 RTCVideoCodecInfo *constrainedHighInfo =
43 [[RTCVideoCodecInfo alloc] initWithName:@"H264" parameters:constrainedHighParams];
44 [codecs addObject:constrainedHighInfo];
45
46 NSDictionary<NSString *, NSString *> *constrainedBaselineParams = @{
47 @"profile-level-id" : kLevel31ConstrainedBaseline,
48 @"level-asymmetry-allowed" : @"1",
49 @"packetization-mode" : @"1",
50 };
51 RTCVideoCodecInfo *constrainedBaselineInfo =
52 [[RTCVideoCodecInfo alloc] initWithName:@"H264" parameters:constrainedBaselineParams];
53 [codecs addObject:constrainedBaselineInfo];
54
55 RTCVideoCodecInfo *vp8Info = [[RTCVideoCodecInfo alloc] initWithName:@"VP8" parameters:nil];
56 [codecs addObject:vp8Info];
57
58 RTCVideoCodecInfo *vp9Info = [[RTCVideoCodecInfo alloc] initWithName:@"VP9" parameters:nil];
59 [codecs addObject:vp9Info];
60
61 return [codecs copy];
62}
63
64@end