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:
Kári Tristan Helgason 2017-10-18 14:22:22 +02:00 committed by Commit Bot
parent a849fd8ef5
commit 117c48291c
6 changed files with 30 additions and 19 deletions

View File

@ -11,23 +11,21 @@
#import "ARDVideoEncoderFactory.h"
#import "ARDSettingsModel.h"
#import "WebRTC/RTCVideoCodec.h"
#import "WebRTC/RTCVideoCodecH264.h"
#import "WebRTC/RTCVideoEncoderVP8.h"
#import "WebRTC/RTCVideoEncoderVP9.h"
static NSString *kLevel31ConstrainedHigh = @"640c1f";
static NSString *kLevel31ConstrainedBaseline = @"42e01f";
@implementation ARDVideoEncoderFactory
@synthesize preferredCodec;
- (id<RTCVideoEncoder>)createEncoder:(RTCVideoCodecInfo *)info {
if ([info.name isEqualToString:@"H264"]) {
if ([info.name isEqualToString:kVideoCodecH264Name]) {
return [[RTCVideoEncoderH264 alloc] initWithCodecInfo:info];
} else if ([info.name isEqualToString:@"VP8"]) {
} else if ([info.name isEqualToString:kVideoCodecVp8Name]) {
return [RTCVideoEncoderVP8 vp8Encoder];
} else if ([info.name isEqualToString:@"VP9"]) {
} else if ([info.name isEqualToString:kVideoCodecVp9Name]) {
return [RTCVideoEncoderVP9 vp9Encoder];
}
@ -43,7 +41,7 @@ static NSString *kLevel31ConstrainedBaseline = @"42e01f";
@"packetization-mode" : @"1",
};
RTCVideoCodecInfo *constrainedHighInfo =
[[RTCVideoCodecInfo alloc] initWithName:@"H264" parameters:constrainedHighParams];
[[RTCVideoCodecInfo alloc] initWithName:kVideoCodecH264Name parameters:constrainedHighParams];
[codecs addObject:constrainedHighInfo];
NSDictionary<NSString *, NSString *> *constrainedBaselineParams = @{
@ -52,13 +50,16 @@ static NSString *kLevel31ConstrainedBaseline = @"42e01f";
@"packetization-mode" : @"1",
};
RTCVideoCodecInfo *constrainedBaselineInfo =
[[RTCVideoCodecInfo alloc] initWithName:@"H264" parameters:constrainedBaselineParams];
[[RTCVideoCodecInfo alloc] initWithName:kVideoCodecH264Name
parameters:constrainedBaselineParams];
[codecs addObject:constrainedBaselineInfo];
RTCVideoCodecInfo *vp8Info = [[RTCVideoCodecInfo alloc] initWithName:@"VP8" parameters:nil];
RTCVideoCodecInfo *vp8Info =
[[RTCVideoCodecInfo alloc] initWithName:kVideoCodecVp8Name parameters:nil];
[codecs addObject:vp8Info];
RTCVideoCodecInfo *vp9Info = [[RTCVideoCodecInfo alloc] initWithName:@"VP9" parameters:nil];
RTCVideoCodecInfo *vp9Info =
[[RTCVideoCodecInfo alloc] initWithName:kVideoCodecVp9Name parameters:nil];
[codecs addObject:vp9Info];
NSMutableArray<RTCVideoCodecInfo *> *orderedCodecs = [NSMutableArray array];

View File

@ -14,6 +14,12 @@
#import "RTCVideoCodec+Private.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
@synthesize name = _name;

View File

@ -20,9 +20,6 @@
#include "system_wrappers/include/field_trial.h"
const char kHighProfileExperiment[] = "WebRTC-H264HighProfile";
static NSString *kH264CodecName = @"H264";
static NSString *kLevel31ConstrainedHigh = @"640c1f";
static NSString *kLevel31ConstrainedBaseline = @"42e01f";
bool IsHighProfileEnabled() {
return webrtc::field_trial::IsEnabled(kHighProfileExperiment);
@ -36,7 +33,7 @@ bool IsHighProfileEnabled() {
- (webrtc::CodecSpecificInfo)nativeCodecSpecificInfo {
webrtc::CodecSpecificInfo codecSpecificInfo;
codecSpecificInfo.codecType = webrtc::kVideoCodecH264;
codecSpecificInfo.codec_name = [kH264CodecName cStringUsingEncoding:NSUTF8StringEncoding];
codecSpecificInfo.codec_name = [kVideoCodecH264Name cStringUsingEncoding:NSUTF8StringEncoding];
codecSpecificInfo.codecSpecific.H264.packetization_mode =
(webrtc::H264PacketizationMode)_packetizationMode;
@ -50,7 +47,7 @@ bool IsHighProfileEnabled() {
- (NSArray<RTCVideoCodecInfo *> *)supportedCodecs {
NSMutableArray<RTCVideoCodecInfo *> *codecs = [NSMutableArray array];
NSString *codecName = kH264CodecName;
NSString *codecName = kVideoCodecH264Name;
if (IsHighProfileEnabled()) {
NSDictionary<NSString *, NSString *> *constrainedHighParams = @{
@ -89,7 +86,7 @@ bool IsHighProfileEnabled() {
}
- (NSArray<RTCVideoCodecInfo *> *)supportedCodecs {
NSString *codecName = kH264CodecName;
NSString *codecName = kVideoCodecH264Name;
return @[ [[RTCVideoCodecInfo alloc] initWithName:codecName parameters:nil] ];
}

View File

@ -304,7 +304,7 @@ CFStringRef ExtractProfile(webrtc::SdpVideoFormat videoFormat) {
_packetizationMode = RTCH264PacketizationModeNonInterleaved;
_profile = ExtractProfile([codecInfo nativeSdpVideoFormat]);
LOG(LS_INFO) << "Using profile " << CFStringToString(_profile);
RTC_CHECK([codecInfo.name isEqualToString:@"H264"]);
RTC_CHECK([codecInfo.name isEqualToString:kVideoCodecH264Name]);
#if defined(WEBRTC_IOS)
[RTCUIApplicationStatusObserver prepareForUse];
@ -320,7 +320,7 @@ CFStringRef ExtractProfile(webrtc::SdpVideoFormat videoFormat) {
- (NSInteger)startEncodeWithSettings:(RTCVideoEncoderSettings *)settings
numberOfCores:(int)numberOfCores {
RTC_DCHECK(settings);
RTC_DCHECK([settings.name isEqualToString:@"H264"]);
RTC_DCHECK([settings.name isEqualToString:kVideoCodecH264Name]);
_width = settings.width;
_height = settings.height;

View File

@ -144,7 +144,8 @@ VideoEncoderFactory::CodecInfo ObjCVideoEncoderFactory::QueryVideoEncoder(
const SdpVideoFormat &format) const {
// TODO(andersc): This is a hack until we figure out how this should be done properly.
NSString *formatName = [NSString stringForStdString:format.name];
NSSet *wrappedSoftwareFormats = [NSSet setWithObjects:@"VP8", @"VP9", nil];
NSSet *wrappedSoftwareFormats =
[NSSet setWithObjects:kVideoCodecVp8Name, kVideoCodecVp9Name, nil];
CodecInfo codec_info;
codec_info.is_hardware_accelerated = ![wrappedSoftwareFormats containsObject:formatName];

View File

@ -15,6 +15,12 @@
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. */
typedef NS_ENUM(NSUInteger, RTCFrameType) {
RTCFrameTypeEmptyFrame = 0,