mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-13 05:40:42 +01:00
Cleanup webrtc::Environment propagation through java wrappers
Force and thus guarantee VideoDecoder created through java wrappers get access to the webrtc::Environment Bug: webrtc:15791 Change-Id: I3f145937c0b914c8e34b24e1ecc55da756551069 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/338441 Reviewed-by: Sergey Silkin <ssilkin@webrtc.org> Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Cr-Commit-Position: refs/heads/main@{#41745}
This commit is contained in:
parent
45242adc4c
commit
2eee89e904
11 changed files with 4 additions and 79 deletions
|
@ -12,7 +12,7 @@ package org.webrtc;
|
|||
|
||||
public class Dav1dDecoder extends WrappedNativeVideoDecoder {
|
||||
@Override
|
||||
public long createNativeVideoDecoder() {
|
||||
public long createNative(long webrtcEnvRef) {
|
||||
return nativeCreateDecoder();
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ package org.webrtc;
|
|||
|
||||
public class LibvpxVp8Decoder extends WrappedNativeVideoDecoder {
|
||||
@Override
|
||||
public long createNativeVideoDecoder() {
|
||||
public long createNative(long webrtcEnvRef) {
|
||||
return nativeCreateDecoder();
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ package org.webrtc;
|
|||
|
||||
public class LibvpxVp9Decoder extends WrappedNativeVideoDecoder {
|
||||
@Override
|
||||
public long createNativeVideoDecoder() {
|
||||
public long createNative(long webrtcEnvRef) {
|
||||
return nativeCreateDecoder();
|
||||
}
|
||||
|
||||
|
|
|
@ -30,11 +30,6 @@ public class SoftwareVideoDecoderFactory implements VideoDecoderFactory {
|
|||
return null;
|
||||
}
|
||||
return new WrappedNativeVideoDecoder() {
|
||||
@Override
|
||||
public long createNativeVideoDecoder() {
|
||||
return nativeCreateDecoder(nativeFactory, info);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long createNative(long webrtcEnvRef) {
|
||||
return nativeCreate(nativeFactory, webrtcEnvRef, info);
|
||||
|
@ -49,8 +44,6 @@ public class SoftwareVideoDecoderFactory implements VideoDecoderFactory {
|
|||
|
||||
private static native long nativeCreateFactory();
|
||||
|
||||
private static native long nativeCreateDecoder(long factory, VideoCodecInfo videoCodecInfo);
|
||||
|
||||
private static native boolean nativeIsSupported(long factory, VideoCodecInfo info);
|
||||
|
||||
private static native long nativeCreate(
|
||||
|
|
|
@ -70,12 +70,6 @@ public interface VideoDecoder {
|
|||
*/
|
||||
@CalledByNative
|
||||
default long createNative(long webrtcEnvRef) {
|
||||
return createNativeVideoDecoder();
|
||||
}
|
||||
|
||||
@CalledByNative
|
||||
@Deprecated
|
||||
default long createNativeVideoDecoder() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,18 +22,11 @@ public class VideoDecoderFallback extends WrappedNativeVideoDecoder {
|
|||
this.primary = primary;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long createNativeVideoDecoder() {
|
||||
return nativeCreateDecoder(fallback, primary);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long createNative(long webrtcEnvRef) {
|
||||
return nativeCreate(webrtcEnvRef, fallback, primary);
|
||||
}
|
||||
|
||||
private static native long nativeCreateDecoder(VideoDecoder fallback, VideoDecoder primary);
|
||||
|
||||
private static native long nativeCreate(
|
||||
long webrtcEnvRef, VideoDecoder fallback, VideoDecoder primary);
|
||||
}
|
||||
|
|
|
@ -14,9 +14,7 @@ package org.webrtc;
|
|||
* Wraps a native webrtc::VideoDecoder.
|
||||
*/
|
||||
public abstract class WrappedNativeVideoDecoder implements VideoDecoder {
|
||||
// TODO: bugs.webrtc.org/15791 - uncomment when implemented by all
|
||||
// derived classes instead of the createNativeVideoDecoder
|
||||
// @Override public abstract long createNative(long webrtcEnvRef);
|
||||
@Override public abstract long createNative(long webrtcEnvRef);
|
||||
|
||||
@Override
|
||||
public final VideoCodecStatus initDecode(Settings settings, Callback decodeCallback) {
|
||||
|
|
|
@ -27,22 +27,6 @@ static jlong JNI_SoftwareVideoDecoderFactory_CreateFactory(JNIEnv* env) {
|
|||
CreateBuiltinVideoDecoderFactory().release());
|
||||
}
|
||||
|
||||
static jlong JNI_SoftwareVideoDecoderFactory_CreateDecoder(
|
||||
JNIEnv* env,
|
||||
jlong j_factory,
|
||||
const webrtc::JavaParamRef<jobject>& j_video_codec_info) {
|
||||
auto* const native_factory =
|
||||
reinterpret_cast<webrtc::VideoDecoderFactory*>(j_factory);
|
||||
const auto video_format =
|
||||
webrtc::jni::VideoCodecInfoToSdpVideoFormat(env, j_video_codec_info);
|
||||
|
||||
auto decoder = native_factory->CreateVideoDecoder(video_format);
|
||||
if (decoder == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
return webrtc::NativeToJavaPointer(decoder.release());
|
||||
}
|
||||
|
||||
jboolean JNI_SoftwareVideoDecoderFactory_IsSupported(
|
||||
JNIEnv* env,
|
||||
jlong j_factory,
|
||||
|
|
|
@ -18,23 +18,6 @@
|
|||
namespace webrtc {
|
||||
namespace jni {
|
||||
|
||||
static jlong JNI_VideoDecoderFallback_CreateDecoder(
|
||||
JNIEnv* jni,
|
||||
const JavaParamRef<jobject>& j_fallback_decoder,
|
||||
const JavaParamRef<jobject>& j_primary_decoder) {
|
||||
std::unique_ptr<VideoDecoder> fallback_decoder =
|
||||
JavaToNativeVideoDecoder(jni, j_fallback_decoder);
|
||||
std::unique_ptr<VideoDecoder> primary_decoder =
|
||||
JavaToNativeVideoDecoder(jni, j_primary_decoder);
|
||||
|
||||
VideoDecoder* nativeWrapper =
|
||||
CreateVideoDecoderSoftwareFallbackWrapper(std::move(fallback_decoder),
|
||||
std::move(primary_decoder))
|
||||
.release();
|
||||
|
||||
return jlongFromPointer(nativeWrapper);
|
||||
}
|
||||
|
||||
static jlong JNI_VideoDecoderFallback_Create(
|
||||
JNIEnv* jni,
|
||||
jlong j_webrtc_env_ref,
|
||||
|
|
|
@ -269,20 +269,6 @@ absl::optional<uint8_t> VideoDecoderWrapper::ParseQP(
|
|||
return qp;
|
||||
}
|
||||
|
||||
std::unique_ptr<VideoDecoder> JavaToNativeVideoDecoder(
|
||||
JNIEnv* jni,
|
||||
const JavaRef<jobject>& j_decoder) {
|
||||
const jlong native_decoder =
|
||||
Java_VideoDecoder_createNativeVideoDecoder(jni, j_decoder);
|
||||
VideoDecoder* decoder;
|
||||
if (native_decoder == 0) {
|
||||
decoder = new VideoDecoderWrapper(jni, j_decoder);
|
||||
} else {
|
||||
decoder = reinterpret_cast<VideoDecoder*>(native_decoder);
|
||||
}
|
||||
return std::unique_ptr<VideoDecoder>(decoder);
|
||||
}
|
||||
|
||||
std::unique_ptr<VideoDecoder> JavaToNativeVideoDecoder(
|
||||
JNIEnv* jni,
|
||||
const JavaRef<jobject>& j_decoder,
|
||||
|
|
|
@ -116,12 +116,6 @@ class VideoDecoderWrapper : public VideoDecoder {
|
|||
/* If the j_decoder is a wrapped native decoder, unwrap it. If it is not,
|
||||
* wrap it in a VideoDecoderWrapper.
|
||||
*/
|
||||
// TODO: bugs.webrtc.org/15791 - delete variant without the webrtcEnvRef
|
||||
// parameter when unused.
|
||||
std::unique_ptr<VideoDecoder> JavaToNativeVideoDecoder(
|
||||
JNIEnv* jni,
|
||||
const JavaRef<jobject>& j_decoder);
|
||||
|
||||
std::unique_ptr<VideoDecoder> JavaToNativeVideoDecoder(
|
||||
JNIEnv* jni,
|
||||
const JavaRef<jobject>& j_decoder,
|
||||
|
|
Loading…
Reference in a new issue