ObjC SDK: Stop using built-in SW video codecs
This CL removes the use of default built-in SW in the ObjC layer. If a client want to depend on the video SW codecs, they must inject them explicitly. Bug: webrtc:7925 Change-Id: If752e7f02109ff768dc5ec38d935203de85987c2 Reviewed-on: https://webrtc-review.googlesource.com/69800 Commit-Queue: Magnus Jedvert <magjed@webrtc.org> Reviewed-by: Anders Carlsson <andersc@webrtc.org> Cr-Commit-Position: refs/heads/master@{#23073}
This commit is contained in:
parent
be80681295
commit
8b4e92d0a5
22
sdk/BUILD.gn
22
sdk/BUILD.gn
@ -407,13 +407,9 @@ if (is_ios || is_mac) {
|
||||
":common_objc",
|
||||
":native_video",
|
||||
":videocodec_objc",
|
||||
":vp8",
|
||||
":vp9",
|
||||
]
|
||||
if (rtc_use_builtin_sw_codecs) {
|
||||
deps += [
|
||||
":vp8",
|
||||
":vp9",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
rtc_static_library("vp8") {
|
||||
@ -826,6 +822,7 @@ if (is_ios || is_mac) {
|
||||
":videosource_objc",
|
||||
":videotoolbox_objc",
|
||||
"../../system_wrappers:system_wrappers_default",
|
||||
"../api/video_codecs:video_codecs_api",
|
||||
"../media:rtc_media_base",
|
||||
"../modules:module_api",
|
||||
"../modules/video_coding:video_codec_interface",
|
||||
@ -902,15 +899,12 @@ if (is_ios || is_mac) {
|
||||
"objc/Framework/Headers/WebRTC/RTCVideoTrack.h",
|
||||
"objc/Framework/Headers/WebRTC/RTCVideoViewShading.h",
|
||||
"objc/Framework/Headers/WebRTC/UIDevice+RTCDevice.h",
|
||||
"objc/Framework/Headers/WebRTC/RTCVideoDecoderVP8.h",
|
||||
"objc/Framework/Headers/WebRTC/RTCVideoDecoderVP9.h",
|
||||
"objc/Framework/Headers/WebRTC/RTCVideoEncoderVP8.h",
|
||||
"objc/Framework/Headers/WebRTC/RTCVideoEncoderVP9.h",
|
||||
]
|
||||
if (rtc_use_builtin_sw_codecs) {
|
||||
common_objc_headers += [
|
||||
"objc/Framework/Headers/WebRTC/RTCVideoDecoderVP8.h",
|
||||
"objc/Framework/Headers/WebRTC/RTCVideoDecoderVP9.h",
|
||||
"objc/Framework/Headers/WebRTC/RTCVideoEncoderVP8.h",
|
||||
"objc/Framework/Headers/WebRTC/RTCVideoEncoderVP9.h",
|
||||
]
|
||||
}
|
||||
|
||||
if (!build_with_chromium) {
|
||||
common_objc_headers += [
|
||||
"objc/Framework/Headers/WebRTC/RTCCallbackLogger.h",
|
||||
|
||||
@ -11,11 +11,9 @@
|
||||
#import "WebRTC/RTCVideoCodecFactory.h"
|
||||
|
||||
#import "WebRTC/RTCVideoCodecH264.h"
|
||||
#if defined(USE_BUILTIN_SW_CODECS)
|
||||
#import "WebRTC/RTCVideoDecoderVP8.h" // nogncheck
|
||||
#import "WebRTC/RTCVideoDecoderVP8.h"
|
||||
#if !defined(RTC_DISABLE_VP9)
|
||||
#import "WebRTC/RTCVideoDecoderVP9.h" // nogncheck
|
||||
#endif
|
||||
#import "WebRTC/RTCVideoDecoderVP9.h"
|
||||
#endif
|
||||
|
||||
@implementation RTCDefaultVideoDecoderFactory
|
||||
@ -23,13 +21,11 @@
|
||||
- (id<RTCVideoDecoder>)createDecoder:(RTCVideoCodecInfo *)info {
|
||||
if ([info.name isEqualToString:kRTCVideoCodecH264Name]) {
|
||||
return [[RTCVideoDecoderH264 alloc] init];
|
||||
#if defined(USE_BUILTIN_SW_CODECS)
|
||||
} else if ([info.name isEqualToString:kRTCVideoCodecVp8Name]) {
|
||||
return [RTCVideoDecoderVP8 vp8Decoder];
|
||||
#if !defined(RTC_DISABLE_VP9)
|
||||
} else if ([info.name isEqualToString:kRTCVideoCodecVp9Name]) {
|
||||
return [RTCVideoDecoderVP9 vp9Decoder];
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -39,11 +35,9 @@
|
||||
- (NSArray<RTCVideoCodecInfo *> *)supportedCodecs {
|
||||
return @[
|
||||
[[RTCVideoCodecInfo alloc] initWithName:kRTCVideoCodecH264Name],
|
||||
#if defined(USE_BUILTIN_SW_CODECS)
|
||||
[[RTCVideoCodecInfo alloc] initWithName:kRTCVideoCodecVp8Name],
|
||||
#if !defined(RTC_DISABLE_VP9)
|
||||
[[RTCVideoCodecInfo alloc] initWithName:kRTCVideoCodecVp9Name],
|
||||
#endif
|
||||
#endif
|
||||
];
|
||||
}
|
||||
|
||||
@ -12,11 +12,9 @@
|
||||
|
||||
#import "WebRTC/RTCVideoCodec.h"
|
||||
#import "WebRTC/RTCVideoCodecH264.h"
|
||||
#if defined(USE_BUILTIN_SW_CODECS)
|
||||
#import "WebRTC/RTCVideoEncoderVP8.h" // nogncheck
|
||||
#import "WebRTC/RTCVideoEncoderVP8.h"
|
||||
#if !defined(RTC_DISABLE_VP9)
|
||||
#import "WebRTC/RTCVideoEncoderVP9.h" // nogncheck
|
||||
#endif
|
||||
#import "WebRTC/RTCVideoEncoderVP9.h"
|
||||
#endif
|
||||
|
||||
@implementation RTCDefaultVideoEncoderFactory
|
||||
@ -42,22 +40,18 @@
|
||||
[[RTCVideoCodecInfo alloc] initWithName:kRTCVideoCodecH264Name
|
||||
parameters:constrainedBaselineParams];
|
||||
|
||||
#if defined(USE_BUILTIN_SW_CODECS)
|
||||
RTCVideoCodecInfo *vp8Info = [[RTCVideoCodecInfo alloc] initWithName:kRTCVideoCodecVp8Name];
|
||||
|
||||
#if !defined(RTC_DISABLE_VP9)
|
||||
RTCVideoCodecInfo *vp9Info = [[RTCVideoCodecInfo alloc] initWithName:kRTCVideoCodecVp9Name];
|
||||
#endif
|
||||
#endif
|
||||
|
||||
return @[
|
||||
constrainedHighInfo,
|
||||
constrainedBaselineInfo,
|
||||
#if defined(USE_BUILTIN_SW_CODECS)
|
||||
vp8Info,
|
||||
#if !defined(RTC_DISABLE_VP9)
|
||||
vp9Info,
|
||||
#endif
|
||||
#endif
|
||||
];
|
||||
}
|
||||
@ -65,13 +59,11 @@
|
||||
- (id<RTCVideoEncoder>)createEncoder:(RTCVideoCodecInfo *)info {
|
||||
if ([info.name isEqualToString:kRTCVideoCodecH264Name]) {
|
||||
return [[RTCVideoEncoderH264 alloc] initWithCodecInfo:info];
|
||||
#if defined(USE_BUILTIN_SW_CODECS)
|
||||
} else if ([info.name isEqualToString:kRTCVideoCodecVp8Name]) {
|
||||
return [RTCVideoEncoderVP8 vp8Encoder];
|
||||
#if !defined(RTC_DISABLE_VP9)
|
||||
} else if ([info.name isEqualToString:kRTCVideoCodecVp9Name]) {
|
||||
return [RTCVideoEncoderVP9 vp9Encoder];
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -23,15 +23,6 @@ class AudioProcessing;
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#if defined(USE_BUILTIN_SW_CODECS)
|
||||
namespace cricket {
|
||||
|
||||
class WebRtcVideoEncoderFactory;
|
||||
class WebRtcVideoDecoderFactory;
|
||||
|
||||
} // namespace cricket
|
||||
#endif
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
@ -58,20 +49,6 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
audioProcessingModule:
|
||||
(rtc::scoped_refptr<webrtc::AudioProcessing>)audioProcessingModule;
|
||||
|
||||
#if defined(USE_BUILTIN_SW_CODECS)
|
||||
/* Initialize object with legacy injectable native audio/video encoder/decoder factories
|
||||
TODO(andersc): Remove this when backwards compatiblity is no longer needed.
|
||||
*/
|
||||
- (instancetype)
|
||||
initWithNativeAudioEncoderFactory:
|
||||
(rtc::scoped_refptr<webrtc::AudioEncoderFactory>)audioEncoderFactory
|
||||
nativeAudioDecoderFactory:
|
||||
(rtc::scoped_refptr<webrtc::AudioDecoderFactory>)audioDecoderFactory
|
||||
legacyNativeVideoEncoderFactory:(cricket::WebRtcVideoEncoderFactory*)videoEncoderFactory
|
||||
legacyNativeVideoDecoderFactory:(cricket::WebRtcVideoDecoderFactory*)videoDecoderFactory
|
||||
audioDeviceModule:(nullable webrtc::AudioDeviceModule *)audioDeviceModule;
|
||||
#endif
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@ -58,7 +58,7 @@
|
||||
- (instancetype)init {
|
||||
#ifdef HAVE_NO_MEDIA
|
||||
return [self initWithNoMedia];
|
||||
#elif !defined(USE_BUILTIN_SW_CODECS)
|
||||
#else
|
||||
return [self initWithNativeAudioEncoderFactory:webrtc::CreateBuiltinAudioEncoderFactory()
|
||||
nativeAudioDecoderFactory:webrtc::CreateBuiltinAudioDecoderFactory()
|
||||
nativeVideoEncoderFactory:webrtc::ObjCToNativeVideoEncoderFactory(
|
||||
@ -67,18 +67,6 @@
|
||||
[[RTCVideoDecoderFactoryH264 alloc] init])
|
||||
audioDeviceModule:nullptr
|
||||
audioProcessingModule:nullptr];
|
||||
#else
|
||||
// Here we construct webrtc::ObjCVideoEncoderFactory directly because we rely
|
||||
// on the fact that they inherit from both webrtc::VideoEncoderFactory and
|
||||
// cricket::WebRtcVideoEncoderFactory.
|
||||
return [self initWithNativeAudioEncoderFactory:webrtc::CreateBuiltinAudioEncoderFactory()
|
||||
nativeAudioDecoderFactory:webrtc::CreateBuiltinAudioDecoderFactory()
|
||||
legacyNativeVideoEncoderFactory:new webrtc::ObjCVideoEncoderFactory(
|
||||
[[RTCVideoEncoderFactoryH264 alloc] init])
|
||||
legacyNativeVideoDecoderFactory:new webrtc::ObjCVideoDecoderFactory(
|
||||
[[RTCVideoDecoderFactoryH264 alloc] init])
|
||||
audioDeviceModule:nullptr];
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -151,18 +139,6 @@
|
||||
return [self initWithNoMedia];
|
||||
#else
|
||||
if (self = [self initNative]) {
|
||||
#if defined(USE_BUILTIN_SW_CODECS)
|
||||
if (!videoEncoderFactory) {
|
||||
auto legacy_video_encoder_factory = rtc::MakeUnique<webrtc::ObjCVideoEncoderFactory>(
|
||||
[[RTCVideoEncoderFactoryH264 alloc] init]);
|
||||
videoEncoderFactory = ConvertVideoEncoderFactory(std::move(legacy_video_encoder_factory));
|
||||
}
|
||||
if (!videoDecoderFactory) {
|
||||
auto legacy_video_decoder_factory = rtc::MakeUnique<webrtc::ObjCVideoDecoderFactory>(
|
||||
[[RTCVideoDecoderFactoryH264 alloc] init]);
|
||||
videoDecoderFactory = ConvertVideoDecoderFactory(std::move(legacy_video_decoder_factory));
|
||||
}
|
||||
#endif
|
||||
_nativeFactory = webrtc::CreatePeerConnectionFactory(_networkThread.get(),
|
||||
_workerThread.get(),
|
||||
_signalingThread.get(),
|
||||
@ -179,34 +155,6 @@
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(USE_BUILTIN_SW_CODECS)
|
||||
- (instancetype)
|
||||
initWithNativeAudioEncoderFactory:
|
||||
(rtc::scoped_refptr<webrtc::AudioEncoderFactory>)audioEncoderFactory
|
||||
nativeAudioDecoderFactory:
|
||||
(rtc::scoped_refptr<webrtc::AudioDecoderFactory>)audioDecoderFactory
|
||||
legacyNativeVideoEncoderFactory:(cricket::WebRtcVideoEncoderFactory *)videoEncoderFactory
|
||||
legacyNativeVideoDecoderFactory:(cricket::WebRtcVideoDecoderFactory *)videoDecoderFactory
|
||||
audioDeviceModule:(nullable webrtc::AudioDeviceModule *)audioDeviceModule {
|
||||
#ifdef HAVE_NO_MEDIA
|
||||
return [self initWithNoMedia];
|
||||
#else
|
||||
if (self = [self initNative]) {
|
||||
_nativeFactory = webrtc::CreatePeerConnectionFactory(_networkThread.get(),
|
||||
_workerThread.get(),
|
||||
_signalingThread.get(),
|
||||
audioDeviceModule,
|
||||
audioEncoderFactory,
|
||||
audioDecoderFactory,
|
||||
videoEncoderFactory,
|
||||
videoDecoderFactory);
|
||||
NSAssert(_nativeFactory, @"Failed to initialize PeerConnectionFactory!");
|
||||
}
|
||||
return self;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
- (RTCAudioSource *)audioSourceWithConstraints:(nullable RTCMediaConstraints *)constraints {
|
||||
std::unique_ptr<webrtc::MediaConstraints> nativeConstraints;
|
||||
if (constraints) {
|
||||
|
||||
@ -53,10 +53,6 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
- (instancetype)initWithNativeSdpVideoFormat:(webrtc::SdpVideoFormat)format;
|
||||
- (webrtc::SdpVideoFormat)nativeSdpVideoFormat;
|
||||
|
||||
/* TODO(andersc): These are deprecated, remove when no longer in use. */
|
||||
- (instancetype)initWithNativeVideoCodec:(cricket::VideoCodec)videoCodec;
|
||||
- (cricket::VideoCodec)nativeVideoCodec;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@ -105,11 +105,6 @@ NSString *MaxSupportedProfileLevelConstrainedHigh() {
|
||||
return [self initWithName:[NSString stringForStdString:format.name] parameters:params];
|
||||
}
|
||||
|
||||
- (instancetype)initWithNativeVideoCodec:(cricket::VideoCodec)videoCodec {
|
||||
return [self
|
||||
initWithNativeSdpVideoFormat:webrtc::SdpVideoFormat(videoCodec.name, videoCodec.params)];
|
||||
}
|
||||
|
||||
- (BOOL)isEqualToCodecInfo:(RTCVideoCodecInfo *)info {
|
||||
if (!info ||
|
||||
![self.name isEqualToString:info.name] ||
|
||||
@ -142,16 +137,6 @@ NSString *MaxSupportedProfileLevelConstrainedHigh() {
|
||||
return webrtc::SdpVideoFormat([NSString stdStringForString:_name], parameters);
|
||||
}
|
||||
|
||||
- (cricket::VideoCodec)nativeVideoCodec {
|
||||
cricket::VideoCodec codec([NSString stdStringForString:_name]);
|
||||
for (NSString *paramKey in _parameters.allKeys) {
|
||||
codec.SetParam([NSString stdStringForString:paramKey],
|
||||
[NSString stdStringForString:_parameters[paramKey]]);
|
||||
}
|
||||
|
||||
return codec;
|
||||
}
|
||||
|
||||
#pragma mark - NSCoding
|
||||
|
||||
- (instancetype)initWithCoder:(NSCoder *)decoder {
|
||||
|
||||
@ -167,8 +167,8 @@ void compressionOutputCallback(void *encoder,
|
||||
rotation:encodeParams->rotation];
|
||||
}
|
||||
|
||||
// Extract VideoToolbox profile out of the cricket::VideoCodec. If there is no
|
||||
// specific VideoToolbox profile for the specified level, AutoLevel will be
|
||||
// Extract VideoToolbox profile out of the webrtc::SdpVideoFormat. If there is
|
||||
// no specific VideoToolbox profile for the specified level, AutoLevel will be
|
||||
// returned. The user must initialize the encoder with a resolution and
|
||||
// framerate conforming to the selected H264 level regardless.
|
||||
CFStringRef ExtractProfile(webrtc::SdpVideoFormat videoFormat) {
|
||||
|
||||
@ -90,7 +90,7 @@ typedef NS_ENUM(NSUInteger, RTCVideoCodecMode) {
|
||||
RTCVideoCodecModeScreensharing,
|
||||
};
|
||||
|
||||
/** Holds information to identify a codec. Corresponds to cricket::VideoCodec. */
|
||||
/** Holds information to identify a codec. Corresponds to webrtc::SdpVideoFormat. */
|
||||
RTC_EXPORT
|
||||
@interface RTCVideoCodecInfo : NSObject <NSCoding>
|
||||
|
||||
|
||||
@ -13,16 +13,12 @@
|
||||
|
||||
#include "api/video_codecs/video_decoder_factory.h"
|
||||
#include "media/base/codec.h"
|
||||
#include "media/engine/webrtcvideodecoderfactory.h"
|
||||
|
||||
@protocol RTCVideoDecoderFactory;
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
// TODO(andersc): Remove the inheritance from cricket::WebRtcVideoDecoderFactory
|
||||
// when the legacy path in [RTCPeerConnectionFactory init] is no longer needed.
|
||||
class ObjCVideoDecoderFactory : public VideoDecoderFactory,
|
||||
public cricket::WebRtcVideoDecoderFactory {
|
||||
class ObjCVideoDecoderFactory : public VideoDecoderFactory {
|
||||
public:
|
||||
explicit ObjCVideoDecoderFactory(id<RTCVideoDecoderFactory>);
|
||||
~ObjCVideoDecoderFactory();
|
||||
@ -33,13 +29,6 @@ class ObjCVideoDecoderFactory : public VideoDecoderFactory,
|
||||
std::unique_ptr<VideoDecoder> CreateVideoDecoder(
|
||||
const SdpVideoFormat& format) override;
|
||||
|
||||
// Needed for WebRtcVideoDecoderFactory interface.
|
||||
VideoDecoder* CreateVideoDecoderWithParams(
|
||||
const cricket::VideoCodec& codec,
|
||||
cricket::VideoDecoderParams params) override;
|
||||
VideoDecoder* CreateVideoDecoder(VideoCodecType type) override;
|
||||
void DestroyVideoDecoder(VideoDecoder* decoder) override;
|
||||
|
||||
private:
|
||||
id<RTCVideoDecoderFactory> decoder_factory_;
|
||||
};
|
||||
|
||||
@ -150,22 +150,4 @@ std::vector<SdpVideoFormat> ObjCVideoDecoderFactory::GetSupportedFormats() const
|
||||
return supported_formats;
|
||||
}
|
||||
|
||||
// WebRtcVideoDecoderFactory
|
||||
|
||||
VideoDecoder *ObjCVideoDecoderFactory::CreateVideoDecoderWithParams(
|
||||
const cricket::VideoCodec &codec, cricket::VideoDecoderParams params) {
|
||||
return CreateVideoDecoder(SdpVideoFormat(codec.name, codec.params)).release();
|
||||
}
|
||||
|
||||
VideoDecoder *ObjCVideoDecoderFactory::CreateVideoDecoder(VideoCodecType type) {
|
||||
// This is implemented to avoid hiding an overloaded virtual function
|
||||
RTC_NOTREACHED();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void ObjCVideoDecoderFactory::DestroyVideoDecoder(VideoDecoder *decoder) {
|
||||
delete decoder;
|
||||
decoder = nullptr;
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
@ -14,16 +14,12 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#include "api/video_codecs/video_encoder_factory.h"
|
||||
#include "media/engine/webrtcvideoencoderfactory.h"
|
||||
|
||||
@protocol RTCVideoEncoderFactory;
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
// TODO(andersc): Remove the inheritance from cricket::WebRtcVideoEncoderFactory
|
||||
// when the legacy path in [RTCPeerConnectionFactory init] is no longer needed.
|
||||
class ObjCVideoEncoderFactory : public VideoEncoderFactory,
|
||||
public cricket::WebRtcVideoEncoderFactory {
|
||||
class ObjCVideoEncoderFactory : public VideoEncoderFactory {
|
||||
public:
|
||||
explicit ObjCVideoEncoderFactory(id<RTCVideoEncoderFactory>);
|
||||
~ObjCVideoEncoderFactory();
|
||||
@ -35,16 +31,8 @@ class ObjCVideoEncoderFactory : public VideoEncoderFactory,
|
||||
const SdpVideoFormat& format) override;
|
||||
CodecInfo QueryVideoEncoder(const SdpVideoFormat& format) const override;
|
||||
|
||||
// Needed for WebRtcVideoEncoderFactory interface.
|
||||
VideoEncoder* CreateVideoEncoder(const cricket::VideoCodec& codec) override;
|
||||
const std::vector<cricket::VideoCodec>& supported_codecs() const override;
|
||||
void DestroyVideoEncoder(VideoEncoder* encoder) override;
|
||||
|
||||
private:
|
||||
id<RTCVideoEncoderFactory> encoder_factory_;
|
||||
|
||||
// Needed for WebRtcVideoEncoderFactory interface.
|
||||
mutable std::vector<cricket::VideoCodec> supported_codecs_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
@ -160,28 +160,4 @@ std::unique_ptr<VideoEncoder> ObjCVideoEncoderFactory::CreateVideoEncoder(
|
||||
}
|
||||
}
|
||||
|
||||
// WebRtcVideoEncoderFactory
|
||||
|
||||
VideoEncoder *ObjCVideoEncoderFactory::CreateVideoEncoder(const cricket::VideoCodec &codec) {
|
||||
RTCVideoCodecInfo *info = [[RTCVideoCodecInfo alloc]
|
||||
initWithNativeSdpVideoFormat:SdpVideoFormat(codec.name, codec.params)];
|
||||
id<RTCVideoEncoder> encoder = [encoder_factory_ createEncoder:info];
|
||||
return new ObjCVideoEncoder(encoder);
|
||||
}
|
||||
|
||||
const std::vector<cricket::VideoCodec> &ObjCVideoEncoderFactory::supported_codecs() const {
|
||||
supported_codecs_.clear();
|
||||
for (RTCVideoCodecInfo *supportedCodec in encoder_factory_.supportedCodecs) {
|
||||
SdpVideoFormat format = [supportedCodec nativeSdpVideoFormat];
|
||||
supported_codecs_.push_back(cricket::VideoCodec(format));
|
||||
}
|
||||
|
||||
return supported_codecs_;
|
||||
}
|
||||
|
||||
void ObjCVideoEncoderFactory::DestroyVideoEncoder(VideoEncoder *encoder) {
|
||||
delete encoder;
|
||||
encoder = nullptr;
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
@ -55,30 +55,29 @@ id<RTCVideoDecoderFactory> CreateErrorDecoderFactory() {
|
||||
return CreateDecoderFactoryReturning(WEBRTC_VIDEO_CODEC_ERROR);
|
||||
}
|
||||
|
||||
webrtc::VideoDecoder *GetObjCDecoder(id<RTCVideoDecoderFactory> factory) {
|
||||
std::unique_ptr<webrtc::VideoDecoder> GetObjCDecoder(id<RTCVideoDecoderFactory> factory) {
|
||||
webrtc::ObjCVideoDecoderFactory decoder_factory(factory);
|
||||
return decoder_factory.CreateVideoDecoderWithParams(cricket::VideoCodec(cricket::kH264CodecName),
|
||||
{});
|
||||
return decoder_factory.CreateVideoDecoder(webrtc::SdpVideoFormat(cricket::kH264CodecName));
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
TEST(ObjCVideoDecoderFactoryTest, InitDecodeReturnsOKOnSuccess) {
|
||||
webrtc::VideoDecoder *decoder = GetObjCDecoder(CreateOKDecoderFactory());
|
||||
std::unique_ptr<webrtc::VideoDecoder> decoder = GetObjCDecoder(CreateOKDecoderFactory());
|
||||
|
||||
auto settings = new webrtc::VideoCodec();
|
||||
EXPECT_EQ(decoder->InitDecode(settings, 1), WEBRTC_VIDEO_CODEC_OK);
|
||||
}
|
||||
|
||||
TEST(ObjCVideoDecoderFactoryTest, InitDecodeReturnsErrorOnFail) {
|
||||
webrtc::VideoDecoder *decoder = GetObjCDecoder(CreateErrorDecoderFactory());
|
||||
std::unique_ptr<webrtc::VideoDecoder> decoder = GetObjCDecoder(CreateErrorDecoderFactory());
|
||||
|
||||
auto settings = new webrtc::VideoCodec();
|
||||
EXPECT_EQ(decoder->InitDecode(settings, 1), WEBRTC_VIDEO_CODEC_ERROR);
|
||||
}
|
||||
|
||||
TEST(ObjCVideoDecoderFactoryTest, DecodeReturnsOKOnSuccess) {
|
||||
webrtc::VideoDecoder *decoder = GetObjCDecoder(CreateOKDecoderFactory());
|
||||
std::unique_ptr<webrtc::VideoDecoder> decoder = GetObjCDecoder(CreateOKDecoderFactory());
|
||||
|
||||
webrtc::EncodedImage encoded_image;
|
||||
webrtc::CodecSpecificInfo info;
|
||||
@ -88,7 +87,7 @@ TEST(ObjCVideoDecoderFactoryTest, DecodeReturnsOKOnSuccess) {
|
||||
}
|
||||
|
||||
TEST(ObjCVideoDecoderFactoryTest, DecodeReturnsErrorOnFail) {
|
||||
webrtc::VideoDecoder *decoder = GetObjCDecoder(CreateErrorDecoderFactory());
|
||||
std::unique_ptr<webrtc::VideoDecoder> decoder = GetObjCDecoder(CreateErrorDecoderFactory());
|
||||
|
||||
webrtc::EncodedImage encoded_image;
|
||||
webrtc::CodecSpecificInfo info;
|
||||
@ -98,13 +97,13 @@ TEST(ObjCVideoDecoderFactoryTest, DecodeReturnsErrorOnFail) {
|
||||
}
|
||||
|
||||
TEST(ObjCVideoDecoderFactoryTest, ReleaseDecodeReturnsOKOnSuccess) {
|
||||
webrtc::VideoDecoder *decoder = GetObjCDecoder(CreateOKDecoderFactory());
|
||||
std::unique_ptr<webrtc::VideoDecoder> decoder = GetObjCDecoder(CreateOKDecoderFactory());
|
||||
|
||||
EXPECT_EQ(decoder->Release(), WEBRTC_VIDEO_CODEC_OK);
|
||||
}
|
||||
|
||||
TEST(ObjCVideoDecoderFactoryTest, ReleaseDecodeReturnsErrorOnFail) {
|
||||
webrtc::VideoDecoder *decoder = GetObjCDecoder(CreateErrorDecoderFactory());
|
||||
std::unique_ptr<webrtc::VideoDecoder> decoder = GetObjCDecoder(CreateErrorDecoderFactory());
|
||||
|
||||
EXPECT_EQ(decoder->Release(), WEBRTC_VIDEO_CODEC_ERROR);
|
||||
}
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
#import "WebRTC/RTCVideoCodec.h"
|
||||
#import "WebRTC/RTCVideoCodecFactory.h"
|
||||
#import "WebRTC/RTCVideoFrameBuffer.h"
|
||||
#include "api/video_codecs/sdp_video_format.h"
|
||||
#include "modules/include/module_common_types.h"
|
||||
#include "modules/video_coding/include/video_codec_interface.h"
|
||||
#include "modules/video_coding/include/video_error_codes.h"
|
||||
@ -46,30 +47,30 @@ id<RTCVideoEncoderFactory> CreateErrorEncoderFactory() {
|
||||
return CreateEncoderFactoryReturning(WEBRTC_VIDEO_CODEC_ERROR);
|
||||
}
|
||||
|
||||
webrtc::VideoEncoder *GetObjCEncoder(id<RTCVideoEncoderFactory> factory) {
|
||||
std::unique_ptr<webrtc::VideoEncoder> GetObjCEncoder(id<RTCVideoEncoderFactory> factory) {
|
||||
webrtc::ObjCVideoEncoderFactory encoder_factory(factory);
|
||||
cricket::VideoCodec codec("H264");
|
||||
return encoder_factory.CreateVideoEncoder(codec);
|
||||
webrtc::SdpVideoFormat format("H264");
|
||||
return encoder_factory.CreateVideoEncoder(format);
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
TEST(ObjCVideoEncoderFactoryTest, InitEncodeReturnsOKOnSuccess) {
|
||||
webrtc::VideoEncoder *encoder = GetObjCEncoder(CreateOKEncoderFactory());
|
||||
std::unique_ptr<webrtc::VideoEncoder> encoder = GetObjCEncoder(CreateOKEncoderFactory());
|
||||
|
||||
auto settings = new webrtc::VideoCodec();
|
||||
EXPECT_EQ(encoder->InitEncode(settings, 1, 0), WEBRTC_VIDEO_CODEC_OK);
|
||||
}
|
||||
|
||||
TEST(ObjCVideoEncoderFactoryTest, InitEncodeReturnsErrorOnFail) {
|
||||
webrtc::VideoEncoder *encoder = GetObjCEncoder(CreateErrorEncoderFactory());
|
||||
std::unique_ptr<webrtc::VideoEncoder> encoder = GetObjCEncoder(CreateErrorEncoderFactory());
|
||||
|
||||
auto settings = new webrtc::VideoCodec();
|
||||
EXPECT_EQ(encoder->InitEncode(settings, 1, 0), WEBRTC_VIDEO_CODEC_ERROR);
|
||||
}
|
||||
|
||||
TEST(ObjCVideoEncoderFactoryTest, EncodeReturnsOKOnSuccess) {
|
||||
webrtc::VideoEncoder *encoder = GetObjCEncoder(CreateOKEncoderFactory());
|
||||
std::unique_ptr<webrtc::VideoEncoder> encoder = GetObjCEncoder(CreateOKEncoderFactory());
|
||||
|
||||
CVPixelBufferRef pixel_buffer;
|
||||
CVPixelBufferCreate(kCFAllocatorDefault, 640, 480, kCVPixelFormatType_32ARGB, nil, &pixel_buffer);
|
||||
@ -86,7 +87,7 @@ TEST(ObjCVideoEncoderFactoryTest, EncodeReturnsOKOnSuccess) {
|
||||
}
|
||||
|
||||
TEST(ObjCVideoEncoderFactoryTest, EncodeReturnsErrorOnFail) {
|
||||
webrtc::VideoEncoder *encoder = GetObjCEncoder(CreateErrorEncoderFactory());
|
||||
std::unique_ptr<webrtc::VideoEncoder> encoder = GetObjCEncoder(CreateErrorEncoderFactory());
|
||||
|
||||
CVPixelBufferRef pixel_buffer;
|
||||
CVPixelBufferCreate(kCFAllocatorDefault, 640, 480, kCVPixelFormatType_32ARGB, nil, &pixel_buffer);
|
||||
@ -103,31 +104,31 @@ TEST(ObjCVideoEncoderFactoryTest, EncodeReturnsErrorOnFail) {
|
||||
}
|
||||
|
||||
TEST(ObjCVideoEncoderFactoryTest, ReleaseEncodeReturnsOKOnSuccess) {
|
||||
webrtc::VideoEncoder *encoder = GetObjCEncoder(CreateOKEncoderFactory());
|
||||
std::unique_ptr<webrtc::VideoEncoder> encoder = GetObjCEncoder(CreateOKEncoderFactory());
|
||||
|
||||
EXPECT_EQ(encoder->Release(), WEBRTC_VIDEO_CODEC_OK);
|
||||
}
|
||||
|
||||
TEST(ObjCVideoEncoderFactoryTest, ReleaseEncodeReturnsErrorOnFail) {
|
||||
webrtc::VideoEncoder *encoder = GetObjCEncoder(CreateErrorEncoderFactory());
|
||||
std::unique_ptr<webrtc::VideoEncoder> encoder = GetObjCEncoder(CreateErrorEncoderFactory());
|
||||
|
||||
EXPECT_EQ(encoder->Release(), WEBRTC_VIDEO_CODEC_ERROR);
|
||||
}
|
||||
|
||||
TEST(ObjCVideoEncoderFactoryTest, SetChannelParametersAlwaysReturnsOK) {
|
||||
webrtc::VideoEncoder *encoder = GetObjCEncoder(CreateErrorEncoderFactory());
|
||||
std::unique_ptr<webrtc::VideoEncoder> encoder = GetObjCEncoder(CreateErrorEncoderFactory());
|
||||
|
||||
EXPECT_EQ(encoder->SetChannelParameters(1, 1), WEBRTC_VIDEO_CODEC_OK);
|
||||
}
|
||||
|
||||
TEST(ObjCVideoEncoderFactoryTest, SetRatesReturnsOKOnSuccess) {
|
||||
webrtc::VideoEncoder *encoder = GetObjCEncoder(CreateOKEncoderFactory());
|
||||
std::unique_ptr<webrtc::VideoEncoder> encoder = GetObjCEncoder(CreateOKEncoderFactory());
|
||||
|
||||
EXPECT_EQ(encoder->SetRates(0, 0), WEBRTC_VIDEO_CODEC_OK);
|
||||
}
|
||||
|
||||
TEST(ObjCVideoEncoderFactoryTest, SetRatesReturnsErrorOnFail) {
|
||||
webrtc::VideoEncoder *encoder = GetObjCEncoder(CreateErrorEncoderFactory());
|
||||
std::unique_ptr<webrtc::VideoEncoder> encoder = GetObjCEncoder(CreateErrorEncoderFactory());
|
||||
|
||||
EXPECT_EQ(encoder->SetRates(0, 0), WEBRTC_VIDEO_CODEC_ERROR);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user