Replace use of codec name strings with constants.
Bug: webrtc:8401 Change-Id: I2aee61e026330ec233eb8b3bfe2d529187562249 Reviewed-on: https://webrtc-review.googlesource.com/10814 Reviewed-by: Magnus Jedvert <magjed@webrtc.org> Commit-Queue: Kári Helgason <kthelgason@webrtc.org> Cr-Commit-Position: refs/heads/master@{#20340}
This commit is contained in:
committed by
Commit Bot
parent
a849fd8ef5
commit
117c48291c
@ -11,23 +11,21 @@
|
|||||||
#import "ARDVideoEncoderFactory.h"
|
#import "ARDVideoEncoderFactory.h"
|
||||||
|
|
||||||
#import "ARDSettingsModel.h"
|
#import "ARDSettingsModel.h"
|
||||||
|
#import "WebRTC/RTCVideoCodec.h"
|
||||||
#import "WebRTC/RTCVideoCodecH264.h"
|
#import "WebRTC/RTCVideoCodecH264.h"
|
||||||
#import "WebRTC/RTCVideoEncoderVP8.h"
|
#import "WebRTC/RTCVideoEncoderVP8.h"
|
||||||
#import "WebRTC/RTCVideoEncoderVP9.h"
|
#import "WebRTC/RTCVideoEncoderVP9.h"
|
||||||
|
|
||||||
static NSString *kLevel31ConstrainedHigh = @"640c1f";
|
|
||||||
static NSString *kLevel31ConstrainedBaseline = @"42e01f";
|
|
||||||
|
|
||||||
@implementation ARDVideoEncoderFactory
|
@implementation ARDVideoEncoderFactory
|
||||||
|
|
||||||
@synthesize preferredCodec;
|
@synthesize preferredCodec;
|
||||||
|
|
||||||
- (id<RTCVideoEncoder>)createEncoder:(RTCVideoCodecInfo *)info {
|
- (id<RTCVideoEncoder>)createEncoder:(RTCVideoCodecInfo *)info {
|
||||||
if ([info.name isEqualToString:@"H264"]) {
|
if ([info.name isEqualToString:kVideoCodecH264Name]) {
|
||||||
return [[RTCVideoEncoderH264 alloc] initWithCodecInfo:info];
|
return [[RTCVideoEncoderH264 alloc] initWithCodecInfo:info];
|
||||||
} else if ([info.name isEqualToString:@"VP8"]) {
|
} else if ([info.name isEqualToString:kVideoCodecVp8Name]) {
|
||||||
return [RTCVideoEncoderVP8 vp8Encoder];
|
return [RTCVideoEncoderVP8 vp8Encoder];
|
||||||
} else if ([info.name isEqualToString:@"VP9"]) {
|
} else if ([info.name isEqualToString:kVideoCodecVp9Name]) {
|
||||||
return [RTCVideoEncoderVP9 vp9Encoder];
|
return [RTCVideoEncoderVP9 vp9Encoder];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,7 +41,7 @@ static NSString *kLevel31ConstrainedBaseline = @"42e01f";
|
|||||||
@"packetization-mode" : @"1",
|
@"packetization-mode" : @"1",
|
||||||
};
|
};
|
||||||
RTCVideoCodecInfo *constrainedHighInfo =
|
RTCVideoCodecInfo *constrainedHighInfo =
|
||||||
[[RTCVideoCodecInfo alloc] initWithName:@"H264" parameters:constrainedHighParams];
|
[[RTCVideoCodecInfo alloc] initWithName:kVideoCodecH264Name parameters:constrainedHighParams];
|
||||||
[codecs addObject:constrainedHighInfo];
|
[codecs addObject:constrainedHighInfo];
|
||||||
|
|
||||||
NSDictionary<NSString *, NSString *> *constrainedBaselineParams = @{
|
NSDictionary<NSString *, NSString *> *constrainedBaselineParams = @{
|
||||||
@ -52,13 +50,16 @@ static NSString *kLevel31ConstrainedBaseline = @"42e01f";
|
|||||||
@"packetization-mode" : @"1",
|
@"packetization-mode" : @"1",
|
||||||
};
|
};
|
||||||
RTCVideoCodecInfo *constrainedBaselineInfo =
|
RTCVideoCodecInfo *constrainedBaselineInfo =
|
||||||
[[RTCVideoCodecInfo alloc] initWithName:@"H264" parameters:constrainedBaselineParams];
|
[[RTCVideoCodecInfo alloc] initWithName:kVideoCodecH264Name
|
||||||
|
parameters:constrainedBaselineParams];
|
||||||
[codecs addObject:constrainedBaselineInfo];
|
[codecs addObject:constrainedBaselineInfo];
|
||||||
|
|
||||||
RTCVideoCodecInfo *vp8Info = [[RTCVideoCodecInfo alloc] initWithName:@"VP8" parameters:nil];
|
RTCVideoCodecInfo *vp8Info =
|
||||||
|
[[RTCVideoCodecInfo alloc] initWithName:kVideoCodecVp8Name parameters:nil];
|
||||||
[codecs addObject:vp8Info];
|
[codecs addObject:vp8Info];
|
||||||
|
|
||||||
RTCVideoCodecInfo *vp9Info = [[RTCVideoCodecInfo alloc] initWithName:@"VP9" parameters:nil];
|
RTCVideoCodecInfo *vp9Info =
|
||||||
|
[[RTCVideoCodecInfo alloc] initWithName:kVideoCodecVp9Name parameters:nil];
|
||||||
[codecs addObject:vp9Info];
|
[codecs addObject:vp9Info];
|
||||||
|
|
||||||
NSMutableArray<RTCVideoCodecInfo *> *orderedCodecs = [NSMutableArray array];
|
NSMutableArray<RTCVideoCodecInfo *> *orderedCodecs = [NSMutableArray array];
|
||||||
|
|||||||
@ -14,6 +14,12 @@
|
|||||||
#import "RTCVideoCodec+Private.h"
|
#import "RTCVideoCodec+Private.h"
|
||||||
#import "WebRTC/RTCVideoCodecFactory.h"
|
#import "WebRTC/RTCVideoCodecFactory.h"
|
||||||
|
|
||||||
|
NSString *const kVideoCodecVp8Name = @"VP8";
|
||||||
|
NSString *const kVideoCodecVp9Name = @"VP9";
|
||||||
|
NSString *const kVideoCodecH264Name = @"H264";
|
||||||
|
NSString *const kLevel31ConstrainedHigh = @"640c1f";
|
||||||
|
NSString *const kLevel31ConstrainedBaseline = @"42e01f";
|
||||||
|
|
||||||
@implementation RTCVideoCodecInfo
|
@implementation RTCVideoCodecInfo
|
||||||
|
|
||||||
@synthesize name = _name;
|
@synthesize name = _name;
|
||||||
|
|||||||
@ -20,9 +20,6 @@
|
|||||||
#include "system_wrappers/include/field_trial.h"
|
#include "system_wrappers/include/field_trial.h"
|
||||||
|
|
||||||
const char kHighProfileExperiment[] = "WebRTC-H264HighProfile";
|
const char kHighProfileExperiment[] = "WebRTC-H264HighProfile";
|
||||||
static NSString *kH264CodecName = @"H264";
|
|
||||||
static NSString *kLevel31ConstrainedHigh = @"640c1f";
|
|
||||||
static NSString *kLevel31ConstrainedBaseline = @"42e01f";
|
|
||||||
|
|
||||||
bool IsHighProfileEnabled() {
|
bool IsHighProfileEnabled() {
|
||||||
return webrtc::field_trial::IsEnabled(kHighProfileExperiment);
|
return webrtc::field_trial::IsEnabled(kHighProfileExperiment);
|
||||||
@ -36,7 +33,7 @@ bool IsHighProfileEnabled() {
|
|||||||
- (webrtc::CodecSpecificInfo)nativeCodecSpecificInfo {
|
- (webrtc::CodecSpecificInfo)nativeCodecSpecificInfo {
|
||||||
webrtc::CodecSpecificInfo codecSpecificInfo;
|
webrtc::CodecSpecificInfo codecSpecificInfo;
|
||||||
codecSpecificInfo.codecType = webrtc::kVideoCodecH264;
|
codecSpecificInfo.codecType = webrtc::kVideoCodecH264;
|
||||||
codecSpecificInfo.codec_name = [kH264CodecName cStringUsingEncoding:NSUTF8StringEncoding];
|
codecSpecificInfo.codec_name = [kVideoCodecH264Name cStringUsingEncoding:NSUTF8StringEncoding];
|
||||||
codecSpecificInfo.codecSpecific.H264.packetization_mode =
|
codecSpecificInfo.codecSpecific.H264.packetization_mode =
|
||||||
(webrtc::H264PacketizationMode)_packetizationMode;
|
(webrtc::H264PacketizationMode)_packetizationMode;
|
||||||
|
|
||||||
@ -50,7 +47,7 @@ bool IsHighProfileEnabled() {
|
|||||||
|
|
||||||
- (NSArray<RTCVideoCodecInfo *> *)supportedCodecs {
|
- (NSArray<RTCVideoCodecInfo *> *)supportedCodecs {
|
||||||
NSMutableArray<RTCVideoCodecInfo *> *codecs = [NSMutableArray array];
|
NSMutableArray<RTCVideoCodecInfo *> *codecs = [NSMutableArray array];
|
||||||
NSString *codecName = kH264CodecName;
|
NSString *codecName = kVideoCodecH264Name;
|
||||||
|
|
||||||
if (IsHighProfileEnabled()) {
|
if (IsHighProfileEnabled()) {
|
||||||
NSDictionary<NSString *, NSString *> *constrainedHighParams = @{
|
NSDictionary<NSString *, NSString *> *constrainedHighParams = @{
|
||||||
@ -89,7 +86,7 @@ bool IsHighProfileEnabled() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (NSArray<RTCVideoCodecInfo *> *)supportedCodecs {
|
- (NSArray<RTCVideoCodecInfo *> *)supportedCodecs {
|
||||||
NSString *codecName = kH264CodecName;
|
NSString *codecName = kVideoCodecH264Name;
|
||||||
return @[ [[RTCVideoCodecInfo alloc] initWithName:codecName parameters:nil] ];
|
return @[ [[RTCVideoCodecInfo alloc] initWithName:codecName parameters:nil] ];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -304,7 +304,7 @@ CFStringRef ExtractProfile(webrtc::SdpVideoFormat videoFormat) {
|
|||||||
_packetizationMode = RTCH264PacketizationModeNonInterleaved;
|
_packetizationMode = RTCH264PacketizationModeNonInterleaved;
|
||||||
_profile = ExtractProfile([codecInfo nativeSdpVideoFormat]);
|
_profile = ExtractProfile([codecInfo nativeSdpVideoFormat]);
|
||||||
LOG(LS_INFO) << "Using profile " << CFStringToString(_profile);
|
LOG(LS_INFO) << "Using profile " << CFStringToString(_profile);
|
||||||
RTC_CHECK([codecInfo.name isEqualToString:@"H264"]);
|
RTC_CHECK([codecInfo.name isEqualToString:kVideoCodecH264Name]);
|
||||||
|
|
||||||
#if defined(WEBRTC_IOS)
|
#if defined(WEBRTC_IOS)
|
||||||
[RTCUIApplicationStatusObserver prepareForUse];
|
[RTCUIApplicationStatusObserver prepareForUse];
|
||||||
@ -320,7 +320,7 @@ CFStringRef ExtractProfile(webrtc::SdpVideoFormat videoFormat) {
|
|||||||
- (NSInteger)startEncodeWithSettings:(RTCVideoEncoderSettings *)settings
|
- (NSInteger)startEncodeWithSettings:(RTCVideoEncoderSettings *)settings
|
||||||
numberOfCores:(int)numberOfCores {
|
numberOfCores:(int)numberOfCores {
|
||||||
RTC_DCHECK(settings);
|
RTC_DCHECK(settings);
|
||||||
RTC_DCHECK([settings.name isEqualToString:@"H264"]);
|
RTC_DCHECK([settings.name isEqualToString:kVideoCodecH264Name]);
|
||||||
|
|
||||||
_width = settings.width;
|
_width = settings.width;
|
||||||
_height = settings.height;
|
_height = settings.height;
|
||||||
|
|||||||
@ -144,7 +144,8 @@ VideoEncoderFactory::CodecInfo ObjCVideoEncoderFactory::QueryVideoEncoder(
|
|||||||
const SdpVideoFormat &format) const {
|
const SdpVideoFormat &format) const {
|
||||||
// TODO(andersc): This is a hack until we figure out how this should be done properly.
|
// TODO(andersc): This is a hack until we figure out how this should be done properly.
|
||||||
NSString *formatName = [NSString stringForStdString:format.name];
|
NSString *formatName = [NSString stringForStdString:format.name];
|
||||||
NSSet *wrappedSoftwareFormats = [NSSet setWithObjects:@"VP8", @"VP9", nil];
|
NSSet *wrappedSoftwareFormats =
|
||||||
|
[NSSet setWithObjects:kVideoCodecVp8Name, kVideoCodecVp9Name, nil];
|
||||||
|
|
||||||
CodecInfo codec_info;
|
CodecInfo codec_info;
|
||||||
codec_info.is_hardware_accelerated = ![wrappedSoftwareFormats containsObject:formatName];
|
codec_info.is_hardware_accelerated = ![wrappedSoftwareFormats containsObject:formatName];
|
||||||
|
|||||||
@ -15,6 +15,12 @@
|
|||||||
|
|
||||||
NS_ASSUME_NONNULL_BEGIN
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
RTC_EXPORT extern NSString *const kVideoCodecVp8Name;
|
||||||
|
RTC_EXPORT extern NSString *const kVideoCodecVp9Name;
|
||||||
|
RTC_EXPORT extern NSString *const kVideoCodecH264Name;
|
||||||
|
RTC_EXPORT extern NSString *const kLevel31ConstrainedHigh;
|
||||||
|
RTC_EXPORT extern NSString *const kLevel31ConstrainedBaseline;
|
||||||
|
|
||||||
/** Represents an encoded frame's type. */
|
/** Represents an encoded frame's type. */
|
||||||
typedef NS_ENUM(NSUInteger, RTCFrameType) {
|
typedef NS_ENUM(NSUInteger, RTCFrameType) {
|
||||||
RTCFrameTypeEmptyFrame = 0,
|
RTCFrameTypeEmptyFrame = 0,
|
||||||
|
|||||||
Reference in New Issue
Block a user