Add AV1 encoder&decoder wrappers for iOS SDK.

It is now possible to use AV1 encoder and decoder on iOS and test
them in apps like AppRTCMobile.

Bug: None
Change-Id: Ifae221020e5abf3809010676862eecd9ffeec5e3
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/208400
Reviewed-by: Kári Helgason <kthelgason@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33378}
This commit is contained in:
Yura Yaroshevich
2021-03-03 12:29:42 +03:00
committed by Commit Bot
parent 662d4c328f
commit 8cfb287735
13 changed files with 224 additions and 36 deletions

View File

@ -646,6 +646,7 @@ if (is_ios || is_mac) {
]
deps = [
":av1",
":base_objc",
":native_video",
":videocodec_objc",
@ -704,6 +705,25 @@ if (is_ios || is_mac) {
]
}
rtc_library("av1") {
visibility = [ "*" ]
allow_poison = [ "software_video_codecs" ]
sources = [
"objc/api/video_codec/RTCVideoDecoderAV1.h",
"objc/api/video_codec/RTCVideoDecoderAV1.mm",
"objc/api/video_codec/RTCVideoEncoderAV1.h",
"objc/api/video_codec/RTCVideoEncoderAV1.mm",
]
deps = [
":base_objc",
":wrapped_native_codec_objc",
"../media:rtc_media_base",
"../modules/video_coding/codecs/av1:libaom_av1_decoder",
"../modules/video_coding/codecs/av1:libaom_av1_encoder",
]
}
# Build the PeerConnectionFactory without audio/video support.
# This target depends on the objc_peeerconnectionfactory_base which still
# includes some audio/video related objects such as RTCAudioSource because
@ -1261,8 +1281,10 @@ if (is_ios || is_mac) {
"objc/api/video_codec/RTCVideoCodecConstants.h",
"objc/api/video_codec/RTCVideoDecoderVP8.h",
"objc/api/video_codec/RTCVideoDecoderVP9.h",
"objc/api/video_codec/RTCVideoDecoderAV1.h",
"objc/api/video_codec/RTCVideoEncoderVP8.h",
"objc/api/video_codec/RTCVideoEncoderVP9.h",
"objc/api/video_codec/RTCVideoEncoderAV1.h",
"objc/api/video_frame_buffer/RTCNativeI420Buffer.h",
"objc/api/video_frame_buffer/RTCNativeMutableI420Buffer.h",
]
@ -1368,8 +1390,10 @@ if (is_ios || is_mac) {
"objc/api/peerconnection/RTCTracing.h",
"objc/api/peerconnection/RTCVideoSource.h",
"objc/api/peerconnection/RTCVideoTrack.h",
"objc/api/video_codec/RTCVideoDecoderAV1.h",
"objc/api/video_codec/RTCVideoDecoderVP8.h",
"objc/api/video_codec/RTCVideoDecoderVP9.h",
"objc/api/video_codec/RTCVideoEncoderAV1.h",
"objc/api/video_codec/RTCVideoEncoderVP8.h",
"objc/api/video_codec/RTCVideoEncoderVP9.h",
"objc/api/video_frame_buffer/RTCNativeI420Buffer.h",

View File

@ -12,5 +12,6 @@
#import "RTCMacros.h"
RTC_OBJC_EXPORT extern NSString* const kRTCVideoCodecVp8Name;
RTC_OBJC_EXPORT extern NSString* const kRTCVideoCodecVp9Name;
RTC_EXTERN NSString* const kRTCVideoCodecVp8Name;
RTC_EXTERN NSString* const kRTCVideoCodecVp9Name;
RTC_EXTERN NSString* const kRTCVideoCodecAv1Name;

View File

@ -15,3 +15,4 @@
NSString *const kRTCVideoCodecVp8Name = @(cricket::kVp8CodecName);
NSString *const kRTCVideoCodecVp9Name = @(cricket::kVp9CodecName);
NSString *const kRTCVideoCodecAv1Name = @(cricket::kAv1CodecName);

View File

@ -0,0 +1,27 @@
/*
* Copyright 2021 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.
*/
#import <Foundation/Foundation.h>
#import "RTCMacros.h"
#import "RTCVideoDecoder.h"
RTC_OBJC_EXPORT
@interface RTC_OBJC_TYPE (RTCVideoDecoderAV1) : NSObject
/* This returns a AV1 decoder that can be returned from a RTCVideoDecoderFactory injected into
* RTCPeerConnectionFactory. Even though it implements the RTCVideoDecoder protocol, it can not be
* used independently from the RTCPeerConnectionFactory.
*/
+ (id<RTC_OBJC_TYPE(RTCVideoDecoder)>)av1Decoder;
+ (bool)isSupported;
@end

View File

@ -0,0 +1,35 @@
/*
* Copyright (c) 2021 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.
*
*/
#import <Foundation/Foundation.h>
#import "RTCMacros.h"
#import "RTCVideoDecoderAV1.h"
#import "RTCWrappedNativeVideoDecoder.h"
#include "modules/video_coding/codecs/av1/libaom_av1_decoder.h"
@implementation RTC_OBJC_TYPE (RTCVideoDecoderAV1)
+ (id<RTC_OBJC_TYPE(RTCVideoDecoder)>)av1Decoder {
std::unique_ptr<webrtc::VideoDecoder> nativeDecoder(webrtc::CreateLibaomAv1Decoder());
if (nativeDecoder == nullptr) {
return nil;
}
return [[RTC_OBJC_TYPE(RTCWrappedNativeVideoDecoder) alloc]
initWithNativeDecoder:std::move(nativeDecoder)];
}
+ (bool)isSupported {
return webrtc::kIsLibaomAv1DecoderSupported;
}
@end

View File

@ -22,4 +22,6 @@ RTC_OBJC_EXPORT
*/
+ (id<RTC_OBJC_TYPE(RTCVideoDecoder)>)vp9Decoder;
+ (bool)isSupported;
@end

View File

@ -20,8 +20,20 @@
@implementation RTC_OBJC_TYPE (RTCVideoDecoderVP9)
+ (id<RTC_OBJC_TYPE(RTCVideoDecoder)>)vp9Decoder {
std::unique_ptr<webrtc::VideoDecoder> nativeDecoder(webrtc::VP9Decoder::Create());
if (nativeDecoder == nullptr) {
return nil;
}
return [[RTC_OBJC_TYPE(RTCWrappedNativeVideoDecoder) alloc]
initWithNativeDecoder:std::unique_ptr<webrtc::VideoDecoder>(webrtc::VP9Decoder::Create())];
initWithNativeDecoder:std::move(nativeDecoder)];
}
+ (bool)isSupported {
#if defined(RTC_ENABLE_VP9)
return true;
#else
return false;
#endif
}
@end

View File

@ -0,0 +1,27 @@
/*
* Copyright 2021 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.
*/
#import <Foundation/Foundation.h>
#import "RTCMacros.h"
#import "RTCVideoEncoder.h"
RTC_OBJC_EXPORT
@interface RTC_OBJC_TYPE (RTCVideoEncoderAV1) : NSObject
/* This returns a AV1 encoder that can be returned from a RTCVideoEncoderFactory injected into
* RTCPeerConnectionFactory. Even though it implements the RTCVideoEncoder protocol, it can not be
* used independently from the RTCPeerConnectionFactory.
*/
+ (id<RTC_OBJC_TYPE(RTCVideoEncoder)>)av1Encoder;
+ (bool)isSupported;
@end

View File

@ -0,0 +1,35 @@
/*
* Copyright (c) 2021 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.
*
*/
#import <Foundation/Foundation.h>
#import "RTCMacros.h"
#import "RTCVideoEncoderAV1.h"
#import "RTCWrappedNativeVideoEncoder.h"
#include "modules/video_coding/codecs/av1/libaom_av1_encoder.h"
@implementation RTC_OBJC_TYPE (RTCVideoEncoderAV1)
+ (id<RTC_OBJC_TYPE(RTCVideoEncoder)>)av1Encoder {
std::unique_ptr<webrtc::VideoEncoder> nativeEncoder(webrtc::CreateLibaomAv1Encoder());
if (nativeEncoder == nullptr) {
return nil;
}
return [[RTC_OBJC_TYPE(RTCWrappedNativeVideoEncoder) alloc]
initWithNativeEncoder:std::move(nativeEncoder)];
}
+ (bool)isSupported {
return webrtc::kIsLibaomAv1EncoderSupported;
}
@end

View File

@ -22,4 +22,6 @@ RTC_OBJC_EXPORT
*/
+ (id<RTC_OBJC_TYPE(RTCVideoEncoder)>)vp9Encoder;
+ (bool)isSupported;
@end

View File

@ -20,8 +20,20 @@
@implementation RTC_OBJC_TYPE (RTCVideoEncoderVP9)
+ (id<RTC_OBJC_TYPE(RTCVideoEncoder)>)vp9Encoder {
std::unique_ptr<webrtc::VideoEncoder> nativeEncoder(webrtc::VP9Encoder::Create());
if (nativeEncoder == nullptr) {
return nil;
}
return [[RTC_OBJC_TYPE(RTCWrappedNativeVideoEncoder) alloc]
initWithNativeEncoder:std::unique_ptr<webrtc::VideoEncoder>(webrtc::VP9Encoder::Create())];
initWithNativeEncoder:std::move(nativeEncoder)];
}
+ (bool)isSupported {
#if defined(RTC_ENABLE_VP9)
return true;
#else
return false;
#endif
}
@end

View File

@ -13,11 +13,10 @@
#import "RTCH264ProfileLevelId.h"
#import "RTCVideoDecoderH264.h"
#import "api/video_codec/RTCVideoCodecConstants.h"
#import "api/video_codec/RTCVideoDecoderAV1.h"
#import "api/video_codec/RTCVideoDecoderVP8.h"
#import "base/RTCVideoCodecInfo.h"
#if defined(RTC_ENABLE_VP9)
#import "api/video_codec/RTCVideoDecoderVP9.h"
#endif
#import "base/RTCVideoCodecInfo.h"
@implementation RTC_OBJC_TYPE (RTCDefaultVideoDecoderFactory)
@ -43,19 +42,23 @@
RTC_OBJC_TYPE(RTCVideoCodecInfo) *vp8Info =
[[RTC_OBJC_TYPE(RTCVideoCodecInfo) alloc] initWithName:kRTCVideoCodecVp8Name];
#if defined(RTC_ENABLE_VP9)
RTC_OBJC_TYPE(RTCVideoCodecInfo) *vp9Info =
[[RTC_OBJC_TYPE(RTCVideoCodecInfo) alloc] initWithName:kRTCVideoCodecVp9Name];
#endif
return @[
NSMutableArray<RTC_OBJC_TYPE(RTCVideoCodecInfo) *> *result = [@[
constrainedHighInfo,
constrainedBaselineInfo,
vp8Info,
#if defined(RTC_ENABLE_VP9)
vp9Info,
#endif
];
] mutableCopy];
if ([RTC_OBJC_TYPE(RTCVideoDecoderVP9) isSupported]) {
[result
addObject:[[RTC_OBJC_TYPE(RTCVideoCodecInfo) alloc] initWithName:kRTCVideoCodecVp9Name]];
}
if ([RTC_OBJC_TYPE(RTCVideoDecoderAV1) isSupported]) {
[result
addObject:[[RTC_OBJC_TYPE(RTCVideoCodecInfo) alloc] initWithName:kRTCVideoCodecAv1Name]];
}
return result;
}
- (id<RTC_OBJC_TYPE(RTCVideoDecoder)>)createDecoder:(RTC_OBJC_TYPE(RTCVideoCodecInfo) *)info {
@ -63,10 +66,12 @@
return [[RTC_OBJC_TYPE(RTCVideoDecoderH264) alloc] init];
} else if ([info.name isEqualToString:kRTCVideoCodecVp8Name]) {
return [RTC_OBJC_TYPE(RTCVideoDecoderVP8) vp8Decoder];
#if defined(RTC_ENABLE_VP9)
} else if ([info.name isEqualToString:kRTCVideoCodecVp9Name]) {
} else if ([info.name isEqualToString:kRTCVideoCodecVp9Name] &&
[RTC_OBJC_TYPE(RTCVideoDecoderVP9) isSupported]) {
return [RTC_OBJC_TYPE(RTCVideoDecoderVP9) vp9Decoder];
#endif
} else if ([info.name isEqualToString:kRTCVideoCodecAv1Name] &&
[RTC_OBJC_TYPE(RTCVideoDecoderAV1) isSupported]) {
return [RTC_OBJC_TYPE(RTCVideoDecoderAV1) av1Decoder];
}
return nil;

View File

@ -13,11 +13,10 @@
#import "RTCH264ProfileLevelId.h"
#import "RTCVideoEncoderH264.h"
#import "api/video_codec/RTCVideoCodecConstants.h"
#import "api/video_codec/RTCVideoEncoderAV1.h"
#import "api/video_codec/RTCVideoEncoderVP8.h"
#import "base/RTCVideoCodecInfo.h"
#if defined(RTC_ENABLE_VP9)
#import "api/video_codec/RTCVideoEncoderVP9.h"
#endif
#import "base/RTCVideoCodecInfo.h"
@implementation RTC_OBJC_TYPE (RTCDefaultVideoEncoderFactory)
@ -45,19 +44,23 @@
RTC_OBJC_TYPE(RTCVideoCodecInfo) *vp8Info =
[[RTC_OBJC_TYPE(RTCVideoCodecInfo) alloc] initWithName:kRTCVideoCodecVp8Name];
#if defined(RTC_ENABLE_VP9)
RTC_OBJC_TYPE(RTCVideoCodecInfo) *vp9Info =
[[RTC_OBJC_TYPE(RTCVideoCodecInfo) alloc] initWithName:kRTCVideoCodecVp9Name];
#endif
return @[
NSMutableArray<RTC_OBJC_TYPE(RTCVideoCodecInfo) *> *result = [@[
constrainedHighInfo,
constrainedBaselineInfo,
vp8Info,
#if defined(RTC_ENABLE_VP9)
vp9Info,
#endif
];
] mutableCopy];
if ([RTC_OBJC_TYPE(RTCVideoEncoderVP9) isSupported]) {
[result
addObject:[[RTC_OBJC_TYPE(RTCVideoCodecInfo) alloc] initWithName:kRTCVideoCodecVp9Name]];
}
if ([RTC_OBJC_TYPE(RTCVideoEncoderAV1) isSupported]) {
[result
addObject:[[RTC_OBJC_TYPE(RTCVideoCodecInfo) alloc] initWithName:kRTCVideoCodecAv1Name]];
}
return result;
}
- (id<RTC_OBJC_TYPE(RTCVideoEncoder)>)createEncoder:(RTC_OBJC_TYPE(RTCVideoCodecInfo) *)info {
@ -65,10 +68,12 @@
return [[RTC_OBJC_TYPE(RTCVideoEncoderH264) alloc] initWithCodecInfo:info];
} else if ([info.name isEqualToString:kRTCVideoCodecVp8Name]) {
return [RTC_OBJC_TYPE(RTCVideoEncoderVP8) vp8Encoder];
#if defined(RTC_ENABLE_VP9)
} else if ([info.name isEqualToString:kRTCVideoCodecVp9Name]) {
} else if ([info.name isEqualToString:kRTCVideoCodecVp9Name] &&
[RTC_OBJC_TYPE(RTCVideoEncoderVP9) isSupported]) {
return [RTC_OBJC_TYPE(RTCVideoEncoderVP9) vp9Encoder];
#endif
} else if ([info.name isEqualToString:kRTCVideoCodecAv1Name] &&
[RTC_OBJC_TYPE(RTCVideoEncoderAV1) isSupported]) {
return [RTC_OBJC_TYPE(RTCVideoEncoderAV1) av1Encoder];
}
return nil;