Init max supported H.264 profile at runtime on iOS
Bug: webrtc:9134, webrtc:7992 Change-Id: Id24c570bf3296298901f61ee817a3d7c3f8c6347 Reviewed-on: https://webrtc-review.googlesource.com/71560 Reviewed-by: Kári Helgason <kthelgason@webrtc.org> Commit-Queue: Kári Helgason <kthelgason@webrtc.org> Cr-Commit-Position: refs/heads/master@{#23034}
This commit is contained in:
committed by
Commit Bot
parent
f364cd7541
commit
0f77feae6d
@ -25,7 +25,7 @@
|
||||
|
||||
+ (NSArray<RTCVideoCodecInfo *> *)supportedCodecs {
|
||||
NSDictionary<NSString *, NSString *> *constrainedHighParams = @{
|
||||
@"profile-level-id" : kRTCLevel31ConstrainedHigh,
|
||||
@"profile-level-id" : kRTCMaxSupportedH264ProfileLevelConstrainedHigh,
|
||||
@"level-asymmetry-allowed" : @"1",
|
||||
@"packetization-mode" : @"1",
|
||||
};
|
||||
@ -34,7 +34,7 @@
|
||||
parameters:constrainedHighParams];
|
||||
|
||||
NSDictionary<NSString *, NSString *> *constrainedBaselineParams = @{
|
||||
@"profile-level-id" : kRTCLevel31ConstrainedBaseline,
|
||||
@"profile-level-id" : kRTCMaxSupportedH264ProfileLevelConstrainedBaseline,
|
||||
@"level-asymmetry-allowed" : @"1",
|
||||
@"packetization-mode" : @"1",
|
||||
};
|
||||
|
||||
@ -12,15 +12,70 @@
|
||||
|
||||
#import "NSString+StdString.h"
|
||||
#import "RTCVideoCodec+Private.h"
|
||||
#if defined(WEBRTC_IOS)
|
||||
#import "UIDevice+H264Profile.h"
|
||||
#endif
|
||||
#import "WebRTC/RTCVideoCodecFactory.h"
|
||||
|
||||
#include "media/base/mediaconstants.h"
|
||||
|
||||
namespace {
|
||||
|
||||
NSString *MaxSupportedProfileLevelConstrainedHigh();
|
||||
NSString *MaxSupportedProfileLevelConstrainedBaseline();
|
||||
|
||||
} // namespace
|
||||
|
||||
NSString *const kRTCVideoCodecVp8Name = @(cricket::kVp8CodecName);
|
||||
NSString *const kRTCVideoCodecVp9Name = @(cricket::kVp9CodecName);
|
||||
NSString *const kRTCVideoCodecH264Name = @(cricket::kH264CodecName);
|
||||
NSString *const kRTCLevel31ConstrainedHigh = @"640c1f";
|
||||
NSString *const kRTCLevel31ConstrainedBaseline = @"42e01f";
|
||||
NSString *const kRTCMaxSupportedH264ProfileLevelConstrainedHigh =
|
||||
MaxSupportedProfileLevelConstrainedHigh();
|
||||
NSString *const kRTCMaxSupportedH264ProfileLevelConstrainedBaseline =
|
||||
MaxSupportedProfileLevelConstrainedBaseline();
|
||||
|
||||
namespace {
|
||||
|
||||
#if defined(WEBRTC_IOS)
|
||||
|
||||
using namespace webrtc::H264;
|
||||
|
||||
NSString *MaxSupportedLevelForProfile(Profile profile) {
|
||||
const rtc::Optional<ProfileLevelId> profileLevelId = [UIDevice maxSupportedH264Profile];
|
||||
if (profileLevelId && profileLevelId->profile >= profile) {
|
||||
const rtc::Optional<std::string> profileString =
|
||||
ProfileLevelIdToString(ProfileLevelId(profile, profileLevelId->level));
|
||||
if (profileString) {
|
||||
return [NSString stringForStdString:*profileString];
|
||||
}
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
#endif
|
||||
|
||||
NSString *MaxSupportedProfileLevelConstrainedBaseline() {
|
||||
#if defined(WEBRTC_IOS)
|
||||
NSString *profile = MaxSupportedLevelForProfile(webrtc::H264::kProfileConstrainedBaseline);
|
||||
if (profile != nil) {
|
||||
return profile;
|
||||
}
|
||||
#endif
|
||||
return kRTCLevel31ConstrainedBaseline;
|
||||
}
|
||||
|
||||
NSString *MaxSupportedProfileLevelConstrainedHigh() {
|
||||
#if defined(WEBRTC_IOS)
|
||||
NSString *profile = MaxSupportedLevelForProfile(webrtc::H264::kProfileConstrainedHigh);
|
||||
if (profile != nil) {
|
||||
return profile;
|
||||
}
|
||||
#endif
|
||||
return kRTCLevel31ConstrainedHigh;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@implementation RTCVideoCodecInfo
|
||||
|
||||
|
||||
@ -50,7 +50,7 @@ bool IsHighProfileEnabled() {
|
||||
|
||||
if (IsHighProfileEnabled()) {
|
||||
NSDictionary<NSString *, NSString *> *constrainedHighParams = @{
|
||||
@"profile-level-id" : kRTCLevel31ConstrainedHigh,
|
||||
@"profile-level-id" : kRTCMaxSupportedH264ProfileLevelConstrainedHigh,
|
||||
@"level-asymmetry-allowed" : @"1",
|
||||
@"packetization-mode" : @"1",
|
||||
};
|
||||
@ -60,7 +60,7 @@ bool IsHighProfileEnabled() {
|
||||
}
|
||||
|
||||
NSDictionary<NSString *, NSString *> *constrainedBaselineParams = @{
|
||||
@"profile-level-id" : kRTCLevel31ConstrainedBaseline,
|
||||
@"profile-level-id" : kRTCMaxSupportedH264ProfileLevelConstrainedBaseline,
|
||||
@"level-asymmetry-allowed" : @"1",
|
||||
@"packetization-mode" : @"1",
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user