2017-10-05 16:55:38 +02:00
|
|
|
/*
|
|
|
|
|
* Copyright 2017 The WebRTC Project Authors. All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-10-30 13:07:07 +01:00
|
|
|
#import "WebRTC/RTCVideoCodecFactory.h"
|
2017-10-05 16:55:38 +02:00
|
|
|
|
2017-10-18 14:22:22 +02:00
|
|
|
#import "WebRTC/RTCVideoCodec.h"
|
2017-10-05 16:55:38 +02:00
|
|
|
#import "WebRTC/RTCVideoCodecH264.h"
|
2018-04-13 15:36:43 +02:00
|
|
|
#import "WebRTC/RTCVideoEncoderVP8.h"
|
2017-12-01 14:27:07 +01:00
|
|
|
#if !defined(RTC_DISABLE_VP9)
|
2018-04-13 15:36:43 +02:00
|
|
|
#import "WebRTC/RTCVideoEncoderVP9.h"
|
2018-01-30 10:32:13 +01:00
|
|
|
#endif
|
2017-10-05 16:55:38 +02:00
|
|
|
|
2017-10-30 13:07:07 +01:00
|
|
|
@implementation RTCDefaultVideoEncoderFactory
|
2017-10-05 16:55:38 +02:00
|
|
|
|
2017-10-16 13:51:43 +02:00
|
|
|
@synthesize preferredCodec;
|
|
|
|
|
|
2017-10-30 13:07:07 +01:00
|
|
|
+ (NSArray<RTCVideoCodecInfo *> *)supportedCodecs {
|
2017-10-05 16:55:38 +02:00
|
|
|
NSDictionary<NSString *, NSString *> *constrainedHighParams = @{
|
2018-04-26 15:41:01 +03:00
|
|
|
@"profile-level-id" : kRTCMaxSupportedH264ProfileLevelConstrainedHigh,
|
2017-10-05 16:55:38 +02:00
|
|
|
@"level-asymmetry-allowed" : @"1",
|
|
|
|
|
@"packetization-mode" : @"1",
|
|
|
|
|
};
|
|
|
|
|
RTCVideoCodecInfo *constrainedHighInfo =
|
2017-10-20 11:01:22 +02:00
|
|
|
[[RTCVideoCodecInfo alloc] initWithName:kRTCVideoCodecH264Name
|
|
|
|
|
parameters:constrainedHighParams];
|
2017-10-05 16:55:38 +02:00
|
|
|
|
|
|
|
|
NSDictionary<NSString *, NSString *> *constrainedBaselineParams = @{
|
2018-04-26 15:41:01 +03:00
|
|
|
@"profile-level-id" : kRTCMaxSupportedH264ProfileLevelConstrainedBaseline,
|
2017-10-05 16:55:38 +02:00
|
|
|
@"level-asymmetry-allowed" : @"1",
|
|
|
|
|
@"packetization-mode" : @"1",
|
|
|
|
|
};
|
|
|
|
|
RTCVideoCodecInfo *constrainedBaselineInfo =
|
2017-10-20 11:01:22 +02:00
|
|
|
[[RTCVideoCodecInfo alloc] initWithName:kRTCVideoCodecH264Name
|
2017-10-18 14:22:22 +02:00
|
|
|
parameters:constrainedBaselineParams];
|
2017-10-05 16:55:38 +02:00
|
|
|
|
2017-10-30 13:07:07 +01:00
|
|
|
RTCVideoCodecInfo *vp8Info = [[RTCVideoCodecInfo alloc] initWithName:kRTCVideoCodecVp8Name];
|
|
|
|
|
|
2017-12-01 14:27:07 +01:00
|
|
|
#if !defined(RTC_DISABLE_VP9)
|
2017-10-30 13:07:07 +01:00
|
|
|
RTCVideoCodecInfo *vp9Info = [[RTCVideoCodecInfo alloc] initWithName:kRTCVideoCodecVp9Name];
|
2017-12-01 14:27:07 +01:00
|
|
|
#endif
|
2017-10-05 16:55:38 +02:00
|
|
|
|
2018-01-30 10:32:13 +01:00
|
|
|
return @[
|
|
|
|
|
constrainedHighInfo,
|
|
|
|
|
constrainedBaselineInfo,
|
|
|
|
|
vp8Info,
|
2017-12-01 14:27:07 +01:00
|
|
|
#if !defined(RTC_DISABLE_VP9)
|
2018-01-30 10:32:13 +01:00
|
|
|
vp9Info,
|
|
|
|
|
#endif
|
|
|
|
|
];
|
2017-10-30 13:07:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (id<RTCVideoEncoder>)createEncoder:(RTCVideoCodecInfo *)info {
|
|
|
|
|
if ([info.name isEqualToString:kRTCVideoCodecH264Name]) {
|
|
|
|
|
return [[RTCVideoEncoderH264 alloc] initWithCodecInfo:info];
|
|
|
|
|
} else if ([info.name isEqualToString:kRTCVideoCodecVp8Name]) {
|
|
|
|
|
return [RTCVideoEncoderVP8 vp8Encoder];
|
2017-12-01 14:27:07 +01:00
|
|
|
#if !defined(RTC_DISABLE_VP9)
|
2017-10-30 13:07:07 +01:00
|
|
|
} else if ([info.name isEqualToString:kRTCVideoCodecVp9Name]) {
|
|
|
|
|
return [RTCVideoEncoderVP9 vp9Encoder];
|
2017-12-01 14:27:07 +01:00
|
|
|
#endif
|
2017-10-30 13:07:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSArray<RTCVideoCodecInfo *> *)supportedCodecs {
|
|
|
|
|
NSMutableArray<RTCVideoCodecInfo *> *codecs = [[[self class] supportedCodecs] mutableCopy];
|
2017-10-05 16:55:38 +02:00
|
|
|
|
2017-10-16 13:51:43 +02:00
|
|
|
NSMutableArray<RTCVideoCodecInfo *> *orderedCodecs = [NSMutableArray array];
|
|
|
|
|
NSUInteger index = [codecs indexOfObject:self.preferredCodec];
|
|
|
|
|
if (index != NSNotFound) {
|
|
|
|
|
[orderedCodecs addObject:[codecs objectAtIndex:index]];
|
|
|
|
|
[codecs removeObjectAtIndex:index];
|
|
|
|
|
}
|
|
|
|
|
[orderedCodecs addObjectsFromArray:codecs];
|
|
|
|
|
|
|
|
|
|
return [orderedCodecs copy];
|
2017-10-05 16:55:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@end
|