diff --git a/examples/objc/AppRTCMobile/ARDVideoEncoderFactory.m b/examples/objc/AppRTCMobile/ARDVideoEncoderFactory.m index e4aafccb2c..b1163c4ff8 100644 --- a/examples/objc/AppRTCMobile/ARDVideoEncoderFactory.m +++ b/examples/objc/AppRTCMobile/ARDVideoEncoderFactory.m @@ -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)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 *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 *orderedCodecs = [NSMutableArray array]; diff --git a/sdk/objc/Framework/Classes/PeerConnection/RTCVideoCodec.mm b/sdk/objc/Framework/Classes/PeerConnection/RTCVideoCodec.mm index 46e6a51562..2a49189dfd 100644 --- a/sdk/objc/Framework/Classes/PeerConnection/RTCVideoCodec.mm +++ b/sdk/objc/Framework/Classes/PeerConnection/RTCVideoCodec.mm @@ -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; diff --git a/sdk/objc/Framework/Classes/PeerConnection/RTCVideoCodecH264.mm b/sdk/objc/Framework/Classes/PeerConnection/RTCVideoCodecH264.mm index b5322b601a..d7f9c19a73 100644 --- a/sdk/objc/Framework/Classes/PeerConnection/RTCVideoCodecH264.mm +++ b/sdk/objc/Framework/Classes/PeerConnection/RTCVideoCodecH264.mm @@ -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 *)supportedCodecs { NSMutableArray *codecs = [NSMutableArray array]; - NSString *codecName = kH264CodecName; + NSString *codecName = kVideoCodecH264Name; if (IsHighProfileEnabled()) { NSDictionary *constrainedHighParams = @{ @@ -89,7 +86,7 @@ bool IsHighProfileEnabled() { } - (NSArray *)supportedCodecs { - NSString *codecName = kH264CodecName; + NSString *codecName = kVideoCodecH264Name; return @[ [[RTCVideoCodecInfo alloc] initWithName:codecName parameters:nil] ]; } diff --git a/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoEncoderH264.mm b/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoEncoderH264.mm index 7a6629ed36..79eb76398d 100644 --- a/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoEncoderH264.mm +++ b/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoEncoderH264.mm @@ -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; diff --git a/sdk/objc/Framework/Classes/VideoToolbox/objc_video_encoder_factory.mm b/sdk/objc/Framework/Classes/VideoToolbox/objc_video_encoder_factory.mm index f78b74b182..d7601cf3fa 100644 --- a/sdk/objc/Framework/Classes/VideoToolbox/objc_video_encoder_factory.mm +++ b/sdk/objc/Framework/Classes/VideoToolbox/objc_video_encoder_factory.mm @@ -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]; diff --git a/sdk/objc/Framework/Headers/WebRTC/RTCVideoCodec.h b/sdk/objc/Framework/Headers/WebRTC/RTCVideoCodec.h index bfd768a66d..59c69e0e0b 100644 --- a/sdk/objc/Framework/Headers/WebRTC/RTCVideoCodec.h +++ b/sdk/objc/Framework/Headers/WebRTC/RTCVideoCodec.h @@ -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,