Cleanup sdk android code from using VideoEncoderFactory::CreateVideoEncoder
To force webrtc::Environment propagation through android VideoEncoderFactory wrappers Bug: webrtc:15860 Change-Id: Icad7249b47a5c738b089e09714c729f91eddaf5d Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/342960 Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Reviewed-by: Sergey Silkin <ssilkin@webrtc.org> Cr-Commit-Position: refs/heads/main@{#41936}
This commit is contained in:
parent
e7d1004709
commit
007a62d83d
@ -11,17 +11,11 @@
|
||||
package org.webrtc;
|
||||
|
||||
public class LibaomAv1Encoder extends WrappedNativeVideoEncoder {
|
||||
@Override
|
||||
public long createNativeVideoEncoder() {
|
||||
return nativeCreateEncoder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long createNative(long webrtcEnvRef) {
|
||||
return nativeCreate(webrtcEnvRef);
|
||||
}
|
||||
|
||||
static native long nativeCreateEncoder();
|
||||
static native long nativeCreate(long webrtcEnvRef);
|
||||
|
||||
@Override
|
||||
|
||||
@ -11,17 +11,11 @@
|
||||
package org.webrtc;
|
||||
|
||||
public class LibvpxVp8Encoder extends WrappedNativeVideoEncoder {
|
||||
@Override
|
||||
public long createNativeVideoEncoder() {
|
||||
return nativeCreateEncoder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long createNative(long webrtcEnvRef) {
|
||||
return nativeCreate(webrtcEnvRef);
|
||||
}
|
||||
|
||||
static native long nativeCreateEncoder();
|
||||
static native long nativeCreate(long webrtcEnvRef);
|
||||
|
||||
@Override
|
||||
|
||||
@ -11,17 +11,11 @@
|
||||
package org.webrtc;
|
||||
|
||||
public class LibvpxVp9Encoder extends WrappedNativeVideoEncoder {
|
||||
@Override
|
||||
public long createNativeVideoEncoder() {
|
||||
return nativeCreateEncoder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long createNative(long webrtcEnvRef) {
|
||||
return nativeCreate(webrtcEnvRef);
|
||||
}
|
||||
|
||||
static native long nativeCreateEncoder();
|
||||
static native long nativeCreate(long webrtcEnvRef);
|
||||
|
||||
@Override
|
||||
|
||||
@ -32,11 +32,6 @@ public class SoftwareVideoEncoderFactory implements VideoEncoderFactory {
|
||||
}
|
||||
|
||||
return new WrappedNativeVideoEncoder() {
|
||||
@Override
|
||||
public long createNativeVideoEncoder() {
|
||||
return nativeCreateEncoder(nativeFactory, info);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long createNative(long webrtcEnvRef) {
|
||||
return nativeCreate(nativeFactory, webrtcEnvRef, info);
|
||||
@ -56,8 +51,6 @@ public class SoftwareVideoEncoderFactory implements VideoEncoderFactory {
|
||||
|
||||
private static native long nativeCreateFactory();
|
||||
|
||||
private static native long nativeCreateEncoder(long factory, VideoCodecInfo videoCodecInfo);
|
||||
|
||||
private static native boolean nativeIsSupported(long factory, VideoCodecInfo info);
|
||||
|
||||
private static native long nativeCreate(long factory, long webrtcEnvRef, VideoCodecInfo info);
|
||||
|
||||
@ -322,16 +322,9 @@ public interface VideoEncoder {
|
||||
* the Java interface methods declared below should thus throw an
|
||||
* UnsupportedOperationException.
|
||||
*/
|
||||
|
||||
@CalledByNative
|
||||
@Deprecated
|
||||
default long createNativeVideoEncoder() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@CalledByNative
|
||||
default long createNative(long webrtcEnvRef) {
|
||||
return createNativeVideoEncoder();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -22,11 +22,6 @@ public class VideoEncoderFallback extends WrappedNativeVideoEncoder {
|
||||
this.primary = primary;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long createNativeVideoEncoder() {
|
||||
return nativeCreateEncoder(fallback, primary);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long createNative(long webrtcEnvRef) {
|
||||
return nativeCreate(webrtcEnvRef, fallback, primary);
|
||||
@ -37,7 +32,6 @@ public class VideoEncoderFallback extends WrappedNativeVideoEncoder {
|
||||
return primary.isHardwareEncoder();
|
||||
}
|
||||
|
||||
private static native long nativeCreateEncoder(VideoEncoder fallback, VideoEncoder primary);
|
||||
private static native long nativeCreate(
|
||||
long webrtcEnvRef, VideoEncoder fallback, VideoEncoder primary);
|
||||
}
|
||||
|
||||
@ -14,9 +14,7 @@ package org.webrtc;
|
||||
* Wraps a native webrtc::VideoEncoder.
|
||||
*/
|
||||
public abstract class WrappedNativeVideoEncoder implements VideoEncoder {
|
||||
// TODO: bugs.webrtc.org/15860 - uncomment when implemented by all
|
||||
// derived classes instead of the createNativeVideoEncoder
|
||||
// @Override public abstract long createNative(long webrtcEnvRef);
|
||||
@Override public abstract long createNative(long webrtcEnvRef);
|
||||
@Override public abstract boolean isHardwareEncoder();
|
||||
|
||||
@Override
|
||||
|
||||
@ -19,10 +19,6 @@
|
||||
namespace webrtc {
|
||||
namespace jni {
|
||||
|
||||
static jlong JNI_LibaomAv1Encoder_CreateEncoder(JNIEnv* jni) {
|
||||
return jlongFromPointer(webrtc::CreateLibaomAv1Encoder().release());
|
||||
}
|
||||
|
||||
jlong JNI_LibaomAv1Encoder_Create(JNIEnv* jni, jlong j_webrtc_env_ref) {
|
||||
return NativeToJavaPointer(
|
||||
CreateLibaomAv1Encoder(
|
||||
|
||||
@ -45,22 +45,6 @@ jlong JNI_SoftwareVideoEncoderFactory_Create(
|
||||
.release());
|
||||
}
|
||||
|
||||
static jlong JNI_SoftwareVideoEncoderFactory_CreateEncoder(
|
||||
JNIEnv* env,
|
||||
jlong j_factory,
|
||||
const webrtc::JavaParamRef<jobject>& j_video_codec_info) {
|
||||
auto* const native_factory =
|
||||
reinterpret_cast<webrtc::VideoEncoderFactory*>(j_factory);
|
||||
const auto video_format =
|
||||
webrtc::jni::VideoCodecInfoToSdpVideoFormat(env, j_video_codec_info);
|
||||
|
||||
auto encoder = native_factory->CreateVideoEncoder(video_format);
|
||||
if (encoder == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
return webrtc::NativeToJavaPointer(encoder.release());
|
||||
}
|
||||
|
||||
static webrtc::ScopedJavaLocalRef<jobject>
|
||||
JNI_SoftwareVideoEncoderFactory_GetSupportedCodecs(JNIEnv* env,
|
||||
jlong j_factory) {
|
||||
|
||||
@ -92,18 +92,6 @@ VideoEncoderFactoryWrapper::VideoEncoderFactoryWrapper(
|
||||
}
|
||||
VideoEncoderFactoryWrapper::~VideoEncoderFactoryWrapper() = default;
|
||||
|
||||
std::unique_ptr<VideoEncoder> VideoEncoderFactoryWrapper::CreateVideoEncoder(
|
||||
const SdpVideoFormat& format) {
|
||||
JNIEnv* jni = AttachCurrentThreadIfNeeded();
|
||||
ScopedJavaLocalRef<jobject> j_codec_info =
|
||||
SdpVideoFormatToVideoCodecInfo(jni, format);
|
||||
ScopedJavaLocalRef<jobject> encoder = Java_VideoEncoderFactory_createEncoder(
|
||||
jni, encoder_factory_, j_codec_info);
|
||||
if (!encoder.obj())
|
||||
return nullptr;
|
||||
return JavaToNativeVideoEncoder(jni, encoder);
|
||||
}
|
||||
|
||||
std::unique_ptr<VideoEncoder> VideoEncoderFactoryWrapper::Create(
|
||||
const Environment& env,
|
||||
const SdpVideoFormat& format) {
|
||||
|
||||
@ -31,9 +31,6 @@ class VideoEncoderFactoryWrapper : public VideoEncoderFactory {
|
||||
const JavaRef<jobject>& encoder_factory);
|
||||
~VideoEncoderFactoryWrapper() override;
|
||||
|
||||
std::unique_ptr<VideoEncoder> CreateVideoEncoder(
|
||||
const SdpVideoFormat& format) override;
|
||||
|
||||
std::unique_ptr<VideoEncoder> Create(const Environment& env,
|
||||
const SdpVideoFormat& format) override;
|
||||
|
||||
|
||||
@ -19,24 +19,6 @@
|
||||
namespace webrtc {
|
||||
namespace jni {
|
||||
|
||||
static jlong JNI_VideoEncoderFallback_CreateEncoder(
|
||||
JNIEnv* jni,
|
||||
const JavaParamRef<jobject>& j_fallback_encoder,
|
||||
const JavaParamRef<jobject>& j_primary_encoder) {
|
||||
std::unique_ptr<VideoEncoder> fallback_encoder =
|
||||
JavaToNativeVideoEncoder(jni, j_fallback_encoder);
|
||||
std::unique_ptr<VideoEncoder> primary_encoder =
|
||||
JavaToNativeVideoEncoder(jni, j_primary_encoder);
|
||||
|
||||
VideoEncoder* native_wrapper =
|
||||
CreateVideoEncoderSoftwareFallbackWrapper(
|
||||
std::move(fallback_encoder), std::move(primary_encoder),
|
||||
/*prefer_temporal_support=*/false)
|
||||
.release();
|
||||
|
||||
return NativeToJavaPointer(native_wrapper);
|
||||
}
|
||||
|
||||
jlong JNI_VideoEncoderFallback_Create(
|
||||
JNIEnv* jni,
|
||||
jlong j_webrtc_env_ref,
|
||||
|
||||
@ -471,20 +471,6 @@ std::unique_ptr<VideoEncoder> JavaToNativeVideoEncoder(
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<VideoEncoder> JavaToNativeVideoEncoder(
|
||||
JNIEnv* jni,
|
||||
const JavaRef<jobject>& j_encoder) {
|
||||
const jlong native_encoder =
|
||||
Java_VideoEncoder_createNativeVideoEncoder(jni, j_encoder);
|
||||
VideoEncoder* encoder;
|
||||
if (native_encoder == 0) {
|
||||
encoder = new VideoEncoderWrapper(jni, j_encoder);
|
||||
} else {
|
||||
encoder = reinterpret_cast<VideoEncoder*>(native_encoder);
|
||||
}
|
||||
return std::unique_ptr<VideoEncoder>(encoder);
|
||||
}
|
||||
|
||||
std::vector<VideoEncoder::ResolutionBitrateLimits>
|
||||
JavaToNativeResolutionBitrateLimits(
|
||||
JNIEnv* jni,
|
||||
|
||||
@ -126,11 +126,6 @@ std::unique_ptr<VideoEncoder> JavaToNativeVideoEncoder(
|
||||
const JavaRef<jobject>& j_encoder,
|
||||
jlong webrtcEnvRef);
|
||||
|
||||
// Deprecated, use variant above that requires webrtc::Environment
|
||||
std::unique_ptr<VideoEncoder> JavaToNativeVideoEncoder(
|
||||
JNIEnv* jni,
|
||||
const JavaRef<jobject>& j_encoder);
|
||||
|
||||
bool IsHardwareVideoEncoder(JNIEnv* jni, const JavaRef<jobject>& j_encoder);
|
||||
|
||||
std::vector<VideoEncoder::ResolutionBitrateLimits>
|
||||
|
||||
@ -19,10 +19,6 @@
|
||||
namespace webrtc {
|
||||
namespace jni {
|
||||
|
||||
static jlong JNI_LibvpxVp8Encoder_CreateEncoder(JNIEnv* jni) {
|
||||
return jlongFromPointer(VP8Encoder::Create().release());
|
||||
}
|
||||
|
||||
jlong JNI_LibvpxVp8Encoder_Create(JNIEnv* jni, jlong j_webrtc_env_ref) {
|
||||
return NativeToJavaPointer(
|
||||
CreateVp8Encoder(*reinterpret_cast<const Environment*>(j_webrtc_env_ref))
|
||||
|
||||
@ -19,10 +19,6 @@
|
||||
namespace webrtc {
|
||||
namespace jni {
|
||||
|
||||
static jlong JNI_LibvpxVp9Encoder_CreateEncoder(JNIEnv* jni) {
|
||||
return jlongFromPointer(VP9Encoder::Create().release());
|
||||
}
|
||||
|
||||
jlong JNI_LibvpxVp9Encoder_Create(JNIEnv* jni, jlong j_webrtc_env_ref) {
|
||||
return NativeToJavaPointer(
|
||||
CreateVp9Encoder(*reinterpret_cast<const Environment*>(j_webrtc_env_ref))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user