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;
|
package org.webrtc;
|
||||||
|
|
||||||
public class LibaomAv1Encoder extends WrappedNativeVideoEncoder {
|
public class LibaomAv1Encoder extends WrappedNativeVideoEncoder {
|
||||||
@Override
|
|
||||||
public long createNativeVideoEncoder() {
|
|
||||||
return nativeCreateEncoder();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long createNative(long webrtcEnvRef) {
|
public long createNative(long webrtcEnvRef) {
|
||||||
return nativeCreate(webrtcEnvRef);
|
return nativeCreate(webrtcEnvRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
static native long nativeCreateEncoder();
|
|
||||||
static native long nativeCreate(long webrtcEnvRef);
|
static native long nativeCreate(long webrtcEnvRef);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -11,17 +11,11 @@
|
|||||||
package org.webrtc;
|
package org.webrtc;
|
||||||
|
|
||||||
public class LibvpxVp8Encoder extends WrappedNativeVideoEncoder {
|
public class LibvpxVp8Encoder extends WrappedNativeVideoEncoder {
|
||||||
@Override
|
|
||||||
public long createNativeVideoEncoder() {
|
|
||||||
return nativeCreateEncoder();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long createNative(long webrtcEnvRef) {
|
public long createNative(long webrtcEnvRef) {
|
||||||
return nativeCreate(webrtcEnvRef);
|
return nativeCreate(webrtcEnvRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
static native long nativeCreateEncoder();
|
|
||||||
static native long nativeCreate(long webrtcEnvRef);
|
static native long nativeCreate(long webrtcEnvRef);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -11,17 +11,11 @@
|
|||||||
package org.webrtc;
|
package org.webrtc;
|
||||||
|
|
||||||
public class LibvpxVp9Encoder extends WrappedNativeVideoEncoder {
|
public class LibvpxVp9Encoder extends WrappedNativeVideoEncoder {
|
||||||
@Override
|
|
||||||
public long createNativeVideoEncoder() {
|
|
||||||
return nativeCreateEncoder();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long createNative(long webrtcEnvRef) {
|
public long createNative(long webrtcEnvRef) {
|
||||||
return nativeCreate(webrtcEnvRef);
|
return nativeCreate(webrtcEnvRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
static native long nativeCreateEncoder();
|
|
||||||
static native long nativeCreate(long webrtcEnvRef);
|
static native long nativeCreate(long webrtcEnvRef);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -32,11 +32,6 @@ public class SoftwareVideoEncoderFactory implements VideoEncoderFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return new WrappedNativeVideoEncoder() {
|
return new WrappedNativeVideoEncoder() {
|
||||||
@Override
|
|
||||||
public long createNativeVideoEncoder() {
|
|
||||||
return nativeCreateEncoder(nativeFactory, info);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long createNative(long webrtcEnvRef) {
|
public long createNative(long webrtcEnvRef) {
|
||||||
return nativeCreate(nativeFactory, webrtcEnvRef, info);
|
return nativeCreate(nativeFactory, webrtcEnvRef, info);
|
||||||
@ -56,8 +51,6 @@ public class SoftwareVideoEncoderFactory implements VideoEncoderFactory {
|
|||||||
|
|
||||||
private static native long nativeCreateFactory();
|
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 boolean nativeIsSupported(long factory, VideoCodecInfo info);
|
||||||
|
|
||||||
private static native long nativeCreate(long factory, long webrtcEnvRef, 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
|
* the Java interface methods declared below should thus throw an
|
||||||
* UnsupportedOperationException.
|
* UnsupportedOperationException.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@CalledByNative
|
|
||||||
@Deprecated
|
|
||||||
default long createNativeVideoEncoder() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@CalledByNative
|
@CalledByNative
|
||||||
default long createNative(long webrtcEnvRef) {
|
default long createNative(long webrtcEnvRef) {
|
||||||
return createNativeVideoEncoder();
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -22,11 +22,6 @@ public class VideoEncoderFallback extends WrappedNativeVideoEncoder {
|
|||||||
this.primary = primary;
|
this.primary = primary;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public long createNativeVideoEncoder() {
|
|
||||||
return nativeCreateEncoder(fallback, primary);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long createNative(long webrtcEnvRef) {
|
public long createNative(long webrtcEnvRef) {
|
||||||
return nativeCreate(webrtcEnvRef, fallback, primary);
|
return nativeCreate(webrtcEnvRef, fallback, primary);
|
||||||
@ -37,7 +32,6 @@ public class VideoEncoderFallback extends WrappedNativeVideoEncoder {
|
|||||||
return primary.isHardwareEncoder();
|
return primary.isHardwareEncoder();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static native long nativeCreateEncoder(VideoEncoder fallback, VideoEncoder primary);
|
|
||||||
private static native long nativeCreate(
|
private static native long nativeCreate(
|
||||||
long webrtcEnvRef, VideoEncoder fallback, VideoEncoder primary);
|
long webrtcEnvRef, VideoEncoder fallback, VideoEncoder primary);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,9 +14,7 @@ package org.webrtc;
|
|||||||
* Wraps a native webrtc::VideoEncoder.
|
* Wraps a native webrtc::VideoEncoder.
|
||||||
*/
|
*/
|
||||||
public abstract class WrappedNativeVideoEncoder implements VideoEncoder {
|
public abstract class WrappedNativeVideoEncoder implements VideoEncoder {
|
||||||
// TODO: bugs.webrtc.org/15860 - uncomment when implemented by all
|
@Override public abstract long createNative(long webrtcEnvRef);
|
||||||
// derived classes instead of the createNativeVideoEncoder
|
|
||||||
// @Override public abstract long createNative(long webrtcEnvRef);
|
|
||||||
@Override public abstract boolean isHardwareEncoder();
|
@Override public abstract boolean isHardwareEncoder();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -19,10 +19,6 @@
|
|||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
namespace jni {
|
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) {
|
jlong JNI_LibaomAv1Encoder_Create(JNIEnv* jni, jlong j_webrtc_env_ref) {
|
||||||
return NativeToJavaPointer(
|
return NativeToJavaPointer(
|
||||||
CreateLibaomAv1Encoder(
|
CreateLibaomAv1Encoder(
|
||||||
|
|||||||
@ -45,22 +45,6 @@ jlong JNI_SoftwareVideoEncoderFactory_Create(
|
|||||||
.release());
|
.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>
|
static webrtc::ScopedJavaLocalRef<jobject>
|
||||||
JNI_SoftwareVideoEncoderFactory_GetSupportedCodecs(JNIEnv* env,
|
JNI_SoftwareVideoEncoderFactory_GetSupportedCodecs(JNIEnv* env,
|
||||||
jlong j_factory) {
|
jlong j_factory) {
|
||||||
|
|||||||
@ -92,18 +92,6 @@ VideoEncoderFactoryWrapper::VideoEncoderFactoryWrapper(
|
|||||||
}
|
}
|
||||||
VideoEncoderFactoryWrapper::~VideoEncoderFactoryWrapper() = default;
|
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(
|
std::unique_ptr<VideoEncoder> VideoEncoderFactoryWrapper::Create(
|
||||||
const Environment& env,
|
const Environment& env,
|
||||||
const SdpVideoFormat& format) {
|
const SdpVideoFormat& format) {
|
||||||
|
|||||||
@ -31,9 +31,6 @@ class VideoEncoderFactoryWrapper : public VideoEncoderFactory {
|
|||||||
const JavaRef<jobject>& encoder_factory);
|
const JavaRef<jobject>& encoder_factory);
|
||||||
~VideoEncoderFactoryWrapper() override;
|
~VideoEncoderFactoryWrapper() override;
|
||||||
|
|
||||||
std::unique_ptr<VideoEncoder> CreateVideoEncoder(
|
|
||||||
const SdpVideoFormat& format) override;
|
|
||||||
|
|
||||||
std::unique_ptr<VideoEncoder> Create(const Environment& env,
|
std::unique_ptr<VideoEncoder> Create(const Environment& env,
|
||||||
const SdpVideoFormat& format) override;
|
const SdpVideoFormat& format) override;
|
||||||
|
|
||||||
|
|||||||
@ -19,24 +19,6 @@
|
|||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
namespace jni {
|
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(
|
jlong JNI_VideoEncoderFallback_Create(
|
||||||
JNIEnv* jni,
|
JNIEnv* jni,
|
||||||
jlong j_webrtc_env_ref,
|
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>
|
std::vector<VideoEncoder::ResolutionBitrateLimits>
|
||||||
JavaToNativeResolutionBitrateLimits(
|
JavaToNativeResolutionBitrateLimits(
|
||||||
JNIEnv* jni,
|
JNIEnv* jni,
|
||||||
|
|||||||
@ -126,11 +126,6 @@ std::unique_ptr<VideoEncoder> JavaToNativeVideoEncoder(
|
|||||||
const JavaRef<jobject>& j_encoder,
|
const JavaRef<jobject>& j_encoder,
|
||||||
jlong webrtcEnvRef);
|
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);
|
bool IsHardwareVideoEncoder(JNIEnv* jni, const JavaRef<jobject>& j_encoder);
|
||||||
|
|
||||||
std::vector<VideoEncoder::ResolutionBitrateLimits>
|
std::vector<VideoEncoder::ResolutionBitrateLimits>
|
||||||
|
|||||||
@ -19,10 +19,6 @@
|
|||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
namespace jni {
|
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) {
|
jlong JNI_LibvpxVp8Encoder_Create(JNIEnv* jni, jlong j_webrtc_env_ref) {
|
||||||
return NativeToJavaPointer(
|
return NativeToJavaPointer(
|
||||||
CreateVp8Encoder(*reinterpret_cast<const Environment*>(j_webrtc_env_ref))
|
CreateVp8Encoder(*reinterpret_cast<const Environment*>(j_webrtc_env_ref))
|
||||||
|
|||||||
@ -19,10 +19,6 @@
|
|||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
namespace jni {
|
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) {
|
jlong JNI_LibvpxVp9Encoder_Create(JNIEnv* jni, jlong j_webrtc_env_ref) {
|
||||||
return NativeToJavaPointer(
|
return NativeToJavaPointer(
|
||||||
CreateVp9Encoder(*reinterpret_cast<const Environment*>(j_webrtc_env_ref))
|
CreateVp9Encoder(*reinterpret_cast<const Environment*>(j_webrtc_env_ref))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user