mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-18 08:07:56 +01:00
Deprecate write-only member CodecInfo::is_hardware_accelerated
This member of the CodecInfo struct was set in several places, but not used for anything. To aid deletion, this cl defines a default implementation of VideoEncoderFactory::QueryVideoEncoder. The next step is to delete almost all downstream implementations of that method, since the only classes that have to implement it are the few factories that produce "internal source" encoders, e.g., for Chromium remoting. Bug: None Change-Id: I1f0dbf0d302933004ebdc779460cb2cb3a894e02 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/179520 Reviewed-by: Kári Helgason <kthelgason@webrtc.org> Reviewed-by: Sami Kalliomäki <sakal@webrtc.org> Reviewed-by: Sebastian Jansson <srte@webrtc.org> Commit-Queue: Niels Moller <nisse@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31844}
This commit is contained in:
parent
321396fcd5
commit
2b781bf908
18 changed files with 8 additions and 86 deletions
|
@ -43,14 +43,6 @@ class FunctionVideoEncoderFactory final : public VideoEncoderFactory {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
CodecInfo QueryVideoEncoder(
|
|
||||||
const SdpVideoFormat& /* format */) const override {
|
|
||||||
CodecInfo codec_info;
|
|
||||||
codec_info.is_hardware_accelerated = false;
|
|
||||||
codec_info.has_internal_source = false;
|
|
||||||
return codec_info;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<VideoEncoder> CreateVideoEncoder(
|
std::unique_ptr<VideoEncoder> CreateVideoEncoder(
|
||||||
const SdpVideoFormat& format) override {
|
const SdpVideoFormat& format) override {
|
||||||
return create_(format);
|
return create_(format);
|
||||||
|
|
|
@ -50,8 +50,6 @@ class BuiltinVideoEncoderFactory : public VideoEncoderFactory {
|
||||||
RTC_DCHECK(IsFormatSupported(
|
RTC_DCHECK(IsFormatSupported(
|
||||||
internal_encoder_factory_->GetSupportedFormats(), format));
|
internal_encoder_factory_->GetSupportedFormats(), format));
|
||||||
VideoEncoderFactory::CodecInfo info;
|
VideoEncoderFactory::CodecInfo info;
|
||||||
info.has_internal_source = false;
|
|
||||||
info.is_hardware_accelerated = false;
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,8 +28,7 @@ class VideoEncoderFactory {
|
||||||
public:
|
public:
|
||||||
// TODO(magjed): Try to get rid of this struct.
|
// TODO(magjed): Try to get rid of this struct.
|
||||||
struct CodecInfo {
|
struct CodecInfo {
|
||||||
// |is_hardware_accelerated| is true if the encoders created by this factory
|
// TODO(nisse): Unused in webrtc, delete as soon as downstream use is fixed.
|
||||||
// of the given codec will use hardware support.
|
|
||||||
bool is_hardware_accelerated = false;
|
bool is_hardware_accelerated = false;
|
||||||
// |has_internal_source| is true if encoders created by this factory of the
|
// |has_internal_source| is true if encoders created by this factory of the
|
||||||
// given codec will use internal camera sources, meaning that they don't
|
// given codec will use internal camera sources, meaning that they don't
|
||||||
|
@ -73,8 +72,13 @@ class VideoEncoderFactory {
|
||||||
|
|
||||||
// Returns information about how this format will be encoded. The specified
|
// Returns information about how this format will be encoded. The specified
|
||||||
// format must be one of the supported formats by this factory.
|
// format must be one of the supported formats by this factory.
|
||||||
// TODO(magjed): Try to get rid of this method.
|
|
||||||
virtual CodecInfo QueryVideoEncoder(const SdpVideoFormat& format) const = 0;
|
// TODO(magjed): Try to get rid of this method. Since is_hardware_accelerated
|
||||||
|
// is unused, only factories producing internal source encoders (in itself a
|
||||||
|
// deprecated feature) needs to override this method.
|
||||||
|
virtual CodecInfo QueryVideoEncoder(const SdpVideoFormat& format) const {
|
||||||
|
return CodecInfo();
|
||||||
|
}
|
||||||
|
|
||||||
// Creates a VideoEncoder for the specified format.
|
// Creates a VideoEncoder for the specified format.
|
||||||
virtual std::unique_ptr<VideoEncoder> CreateVideoEncoder(
|
virtual std::unique_ptr<VideoEncoder> CreateVideoEncoder(
|
||||||
|
|
|
@ -44,11 +44,6 @@ std::vector<SdpVideoFormat> FakeVideoEncoderFactory::GetSupportedFormats()
|
||||||
1, SdpVideoFormat(kFakeCodecFactoryCodecName));
|
1, SdpVideoFormat(kFakeCodecFactoryCodecName));
|
||||||
}
|
}
|
||||||
|
|
||||||
VideoEncoderFactory::CodecInfo FakeVideoEncoderFactory::QueryVideoEncoder(
|
|
||||||
const SdpVideoFormat& format) const {
|
|
||||||
return VideoEncoderFactory::CodecInfo{false, false};
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<VideoEncoder> FakeVideoEncoderFactory::CreateVideoEncoder(
|
std::unique_ptr<VideoEncoder> FakeVideoEncoderFactory::CreateVideoEncoder(
|
||||||
const SdpVideoFormat& format) {
|
const SdpVideoFormat& format) {
|
||||||
return std::make_unique<test::FakeEncoder>(Clock::GetRealTimeClock());
|
return std::make_unique<test::FakeEncoder>(Clock::GetRealTimeClock());
|
||||||
|
|
|
@ -30,8 +30,6 @@ class RTC_EXPORT FakeVideoEncoderFactory : public VideoEncoderFactory {
|
||||||
|
|
||||||
// VideoEncoderFactory implementation
|
// VideoEncoderFactory implementation
|
||||||
std::vector<SdpVideoFormat> GetSupportedFormats() const override;
|
std::vector<SdpVideoFormat> GetSupportedFormats() const override;
|
||||||
VideoEncoderFactory::CodecInfo QueryVideoEncoder(
|
|
||||||
const SdpVideoFormat& format) const override;
|
|
||||||
std::unique_ptr<VideoEncoder> CreateVideoEncoder(
|
std::unique_ptr<VideoEncoder> CreateVideoEncoder(
|
||||||
const SdpVideoFormat& format) override;
|
const SdpVideoFormat& format) override;
|
||||||
};
|
};
|
||||||
|
|
|
@ -244,7 +244,6 @@ FakeWebRtcVideoEncoderFactory::QueryVideoEncoder(
|
||||||
const webrtc::SdpVideoFormat& format) const {
|
const webrtc::SdpVideoFormat& format) const {
|
||||||
webrtc::VideoEncoderFactory::CodecInfo info;
|
webrtc::VideoEncoderFactory::CodecInfo info;
|
||||||
info.has_internal_source = encoders_have_internal_sources_;
|
info.has_internal_source = encoders_have_internal_sources_;
|
||||||
info.is_hardware_accelerated = true;
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,14 +41,6 @@ std::vector<SdpVideoFormat> InternalEncoderFactory::GetSupportedFormats()
|
||||||
return SupportedFormats();
|
return SupportedFormats();
|
||||||
}
|
}
|
||||||
|
|
||||||
VideoEncoderFactory::CodecInfo InternalEncoderFactory::QueryVideoEncoder(
|
|
||||||
const SdpVideoFormat& format) const {
|
|
||||||
CodecInfo info;
|
|
||||||
info.is_hardware_accelerated = false;
|
|
||||||
info.has_internal_source = false;
|
|
||||||
return info;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<VideoEncoder> InternalEncoderFactory::CreateVideoEncoder(
|
std::unique_ptr<VideoEncoder> InternalEncoderFactory::CreateVideoEncoder(
|
||||||
const SdpVideoFormat& format) {
|
const SdpVideoFormat& format) {
|
||||||
if (absl::EqualsIgnoreCase(format.name, cricket::kVp8CodecName))
|
if (absl::EqualsIgnoreCase(format.name, cricket::kVp8CodecName))
|
||||||
|
|
|
@ -26,8 +26,6 @@ class RTC_EXPORT InternalEncoderFactory : public VideoEncoderFactory {
|
||||||
static std::vector<SdpVideoFormat> SupportedFormats();
|
static std::vector<SdpVideoFormat> SupportedFormats();
|
||||||
std::vector<SdpVideoFormat> GetSupportedFormats() const override;
|
std::vector<SdpVideoFormat> GetSupportedFormats() const override;
|
||||||
|
|
||||||
CodecInfo QueryVideoEncoder(const SdpVideoFormat& format) const override;
|
|
||||||
|
|
||||||
std::unique_ptr<VideoEncoder> CreateVideoEncoder(
|
std::unique_ptr<VideoEncoder> CreateVideoEncoder(
|
||||||
const SdpVideoFormat& format) override;
|
const SdpVideoFormat& format) override;
|
||||||
};
|
};
|
||||||
|
|
|
@ -57,14 +57,6 @@ std::vector<SdpVideoFormat> MultiplexEncoderFactory::GetSupportedFormats()
|
||||||
return formats;
|
return formats;
|
||||||
}
|
}
|
||||||
|
|
||||||
VideoEncoderFactory::CodecInfo MultiplexEncoderFactory::QueryVideoEncoder(
|
|
||||||
const SdpVideoFormat& format) const {
|
|
||||||
if (!IsMultiplexCodec(cricket::VideoCodec(format)))
|
|
||||||
return factory_->QueryVideoEncoder(format);
|
|
||||||
return factory_->QueryVideoEncoder(
|
|
||||||
SdpVideoFormat(kMultiplexAssociatedCodecName));
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<VideoEncoder> MultiplexEncoderFactory::CreateVideoEncoder(
|
std::unique_ptr<VideoEncoder> MultiplexEncoderFactory::CreateVideoEncoder(
|
||||||
const SdpVideoFormat& format) {
|
const SdpVideoFormat& format) {
|
||||||
if (!IsMultiplexCodec(cricket::VideoCodec(format)))
|
if (!IsMultiplexCodec(cricket::VideoCodec(format)))
|
||||||
|
|
|
@ -49,7 +49,6 @@ class RTC_EXPORT MultiplexEncoderFactory : public VideoEncoderFactory {
|
||||||
bool supports_augmenting_data = false);
|
bool supports_augmenting_data = false);
|
||||||
|
|
||||||
std::vector<SdpVideoFormat> GetSupportedFormats() const override;
|
std::vector<SdpVideoFormat> GetSupportedFormats() const override;
|
||||||
CodecInfo QueryVideoEncoder(const SdpVideoFormat& format) const override;
|
|
||||||
std::unique_ptr<VideoEncoder> CreateVideoEncoder(
|
std::unique_ptr<VideoEncoder> CreateVideoEncoder(
|
||||||
const SdpVideoFormat& format) override;
|
const SdpVideoFormat& format) override;
|
||||||
|
|
||||||
|
|
|
@ -167,8 +167,6 @@ class MockVideoEncoderFactory : public VideoEncoderFactory {
|
||||||
std::unique_ptr<VideoEncoder> CreateVideoEncoder(
|
std::unique_ptr<VideoEncoder> CreateVideoEncoder(
|
||||||
const SdpVideoFormat& format) override;
|
const SdpVideoFormat& format) override;
|
||||||
|
|
||||||
CodecInfo QueryVideoEncoder(const SdpVideoFormat& format) const override;
|
|
||||||
|
|
||||||
const std::vector<MockVideoEncoder*>& encoders() const;
|
const std::vector<MockVideoEncoder*>& encoders() const;
|
||||||
void SetEncoderNames(const std::vector<const char*>& encoder_names);
|
void SetEncoderNames(const std::vector<const char*>& encoder_names);
|
||||||
void set_init_encode_return_value(int32_t value);
|
void set_init_encode_return_value(int32_t value);
|
||||||
|
@ -357,11 +355,6 @@ void MockVideoEncoderFactory::DestroyVideoEncoder(VideoEncoder* encoder) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VideoEncoderFactory::CodecInfo MockVideoEncoderFactory::QueryVideoEncoder(
|
|
||||||
const SdpVideoFormat& format) const {
|
|
||||||
return CodecInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::vector<MockVideoEncoder*>& MockVideoEncoderFactory::encoders()
|
const std::vector<MockVideoEncoder*>& MockVideoEncoderFactory::encoders()
|
||||||
const {
|
const {
|
||||||
return encoders_;
|
return encoders_;
|
||||||
|
|
|
@ -1129,7 +1129,6 @@ TEST(WebRtcVideoEngineNewVideoCodecFactoryTest, Vp8) {
|
||||||
|
|
||||||
// Mock encoder creation. |engine| take ownership of the encoder.
|
// Mock encoder creation. |engine| take ownership of the encoder.
|
||||||
webrtc::VideoEncoderFactory::CodecInfo codec_info;
|
webrtc::VideoEncoderFactory::CodecInfo codec_info;
|
||||||
codec_info.is_hardware_accelerated = false;
|
|
||||||
codec_info.has_internal_source = false;
|
codec_info.has_internal_source = false;
|
||||||
const webrtc::SdpVideoFormat format("VP8");
|
const webrtc::SdpVideoFormat format("VP8");
|
||||||
EXPECT_CALL(*encoder_factory, QueryVideoEncoder(format))
|
EXPECT_CALL(*encoder_factory, QueryVideoEncoder(format))
|
||||||
|
|
|
@ -101,21 +101,6 @@ std::vector<SdpVideoFormat> VideoEncoderFactoryWrapper::GetImplementations()
|
||||||
return implementations_;
|
return implementations_;
|
||||||
}
|
}
|
||||||
|
|
||||||
VideoEncoderFactory::CodecInfo VideoEncoderFactoryWrapper::QueryVideoEncoder(
|
|
||||||
const SdpVideoFormat& format) const {
|
|
||||||
JNIEnv* jni = AttachCurrentThreadIfNeeded();
|
|
||||||
ScopedJavaLocalRef<jobject> j_codec_info =
|
|
||||||
SdpVideoFormatToVideoCodecInfo(jni, format);
|
|
||||||
ScopedJavaLocalRef<jobject> encoder = Java_VideoEncoderFactory_createEncoder(
|
|
||||||
jni, encoder_factory_, j_codec_info);
|
|
||||||
|
|
||||||
CodecInfo codec_info;
|
|
||||||
// Check if this is a wrapped native software encoder implementation.
|
|
||||||
codec_info.is_hardware_accelerated = IsHardwareVideoEncoder(jni, encoder);
|
|
||||||
codec_info.has_internal_source = false;
|
|
||||||
return codec_info;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<VideoEncoderFactory::EncoderSelectorInterface>
|
std::unique_ptr<VideoEncoderFactory::EncoderSelectorInterface>
|
||||||
VideoEncoderFactoryWrapper::GetEncoderSelector() const {
|
VideoEncoderFactoryWrapper::GetEncoderSelector() const {
|
||||||
JNIEnv* jni = AttachCurrentThreadIfNeeded();
|
JNIEnv* jni = AttachCurrentThreadIfNeeded();
|
||||||
|
|
|
@ -37,8 +37,6 @@ class VideoEncoderFactoryWrapper : public VideoEncoderFactory {
|
||||||
|
|
||||||
std::vector<SdpVideoFormat> GetImplementations() const override;
|
std::vector<SdpVideoFormat> GetImplementations() const override;
|
||||||
|
|
||||||
CodecInfo QueryVideoEncoder(const SdpVideoFormat& format) const override;
|
|
||||||
|
|
||||||
std::unique_ptr<EncoderSelectorInterface> GetEncoderSelector() const override;
|
std::unique_ptr<EncoderSelectorInterface> GetEncoderSelector() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -33,7 +33,6 @@ class ObjCVideoEncoderFactory : public VideoEncoderFactory {
|
||||||
std::vector<SdpVideoFormat> GetImplementations() const override;
|
std::vector<SdpVideoFormat> GetImplementations() const override;
|
||||||
std::unique_ptr<VideoEncoder> CreateVideoEncoder(
|
std::unique_ptr<VideoEncoder> CreateVideoEncoder(
|
||||||
const SdpVideoFormat& format) override;
|
const SdpVideoFormat& format) override;
|
||||||
CodecInfo QueryVideoEncoder(const SdpVideoFormat& format) const override;
|
|
||||||
std::unique_ptr<EncoderSelectorInterface> GetEncoderSelector() const override;
|
std::unique_ptr<EncoderSelectorInterface> GetEncoderSelector() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -174,19 +174,6 @@ std::vector<SdpVideoFormat> ObjCVideoEncoderFactory::GetImplementations() const
|
||||||
return GetSupportedFormats();
|
return GetSupportedFormats();
|
||||||
}
|
}
|
||||||
|
|
||||||
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:kRTCVideoCodecVp8Name, kRTCVideoCodecVp9Name, nil];
|
|
||||||
|
|
||||||
CodecInfo codec_info;
|
|
||||||
codec_info.is_hardware_accelerated = ![wrappedSoftwareFormats containsObject:formatName];
|
|
||||||
codec_info.has_internal_source = false;
|
|
||||||
return codec_info;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<VideoEncoder> ObjCVideoEncoderFactory::CreateVideoEncoder(
|
std::unique_ptr<VideoEncoder> ObjCVideoEncoderFactory::CreateVideoEncoder(
|
||||||
const SdpVideoFormat &format) {
|
const SdpVideoFormat &format) {
|
||||||
RTC_OBJC_TYPE(RTCVideoCodecInfo) *info =
|
RTC_OBJC_TYPE(RTCVideoCodecInfo) *info =
|
||||||
|
|
|
@ -125,8 +125,6 @@ class FakeVideoEncoderFactory : public VideoEncoderFactory {
|
||||||
CodecInfo QueryVideoEncoder(const SdpVideoFormat& format) const override {
|
CodecInfo QueryVideoEncoder(const SdpVideoFormat& format) const override {
|
||||||
RTC_CHECK_EQ(format.name, "VP8");
|
RTC_CHECK_EQ(format.name, "VP8");
|
||||||
CodecInfo info;
|
CodecInfo info;
|
||||||
info.has_internal_source = false;
|
|
||||||
info.is_hardware_accelerated = false;
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
std::unique_ptr<VideoEncoder> CreateVideoEncoder(
|
std::unique_ptr<VideoEncoder> CreateVideoEncoder(
|
||||||
|
|
|
@ -38,7 +38,6 @@ class VideoEncoderProxyFactory final : public VideoEncoderFactory {
|
||||||
encoder_selector_(encoder_selector),
|
encoder_selector_(encoder_selector),
|
||||||
num_simultaneous_encoder_instances_(0),
|
num_simultaneous_encoder_instances_(0),
|
||||||
max_num_simultaneous_encoder_instances_(0) {
|
max_num_simultaneous_encoder_instances_(0) {
|
||||||
codec_info_.is_hardware_accelerated = false;
|
|
||||||
codec_info_.has_internal_source = false;
|
codec_info_.has_internal_source = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,9 +69,6 @@ class VideoEncoderProxyFactory final : public VideoEncoderFactory {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetIsHardwareAccelerated(bool is_hardware_accelerated) {
|
|
||||||
codec_info_.is_hardware_accelerated = is_hardware_accelerated;
|
|
||||||
}
|
|
||||||
void SetHasInternalSource(bool has_internal_source) {
|
void SetHasInternalSource(bool has_internal_source) {
|
||||||
codec_info_.has_internal_source = has_internal_source;
|
codec_info_.has_internal_source = has_internal_source;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue