Use Environment propagated through android sdk
This way VP8Decoder and DecoderFallback would use propagated instead of global field trials.
Bug: webrtc:15791, webrtc:10335
Change-Id: I5ad5fae38f5b9379bc6376334562c154fbc56e39
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/340040
Reviewed-by: Sergey Silkin <ssilkin@webrtc.org>
Auto-Submit: Danil Chapovalov <danilchap@webrtc.org>
Commit-Queue: Sergey Silkin <ssilkin@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#41763}
diff --git a/sdk/android/BUILD.gn b/sdk/android/BUILD.gn
index 13c27c0..87e76235 100644
--- a/sdk/android/BUILD.gn
+++ b/sdk/android/BUILD.gn
@@ -858,6 +858,7 @@
":base_jni",
":generated_libvpx_vp8_jni",
":video_jni",
+ "../../api/environment",
"../../modules/video_coding:webrtc_vp8",
]
}
diff --git a/sdk/android/api/org/webrtc/LibvpxVp8Decoder.java b/sdk/android/api/org/webrtc/LibvpxVp8Decoder.java
index b3846f2..7d3e959 100644
--- a/sdk/android/api/org/webrtc/LibvpxVp8Decoder.java
+++ b/sdk/android/api/org/webrtc/LibvpxVp8Decoder.java
@@ -13,8 +13,8 @@
public class LibvpxVp8Decoder extends WrappedNativeVideoDecoder {
@Override
public long createNative(long webrtcEnvRef) {
- return nativeCreateDecoder();
+ return nativeCreateDecoder(webrtcEnvRef);
}
- static native long nativeCreateDecoder();
+ static native long nativeCreateDecoder(long webrtcEnvRef);
}
diff --git a/sdk/android/src/jni/video_decoder_fallback.cc b/sdk/android/src/jni/video_decoder_fallback.cc
index 2688c59..86d643d 100644
--- a/sdk/android/src/jni/video_decoder_fallback.cc
+++ b/sdk/android/src/jni/video_decoder_fallback.cc
@@ -10,6 +10,7 @@
#include <jni.h>
+#include "api/environment/environment.h"
#include "api/video_codecs/video_decoder_software_fallback_wrapper.h"
#include "sdk/android/generated_video_jni/VideoDecoderFallback_jni.h"
#include "sdk/android/src/jni/jni_helpers.h"
@@ -29,8 +30,9 @@
JavaToNativeVideoDecoder(jni, j_primary_decoder, j_webrtc_env_ref);
VideoDecoder* native_wrapper =
- CreateVideoDecoderSoftwareFallbackWrapper(std::move(fallback_decoder),
- std::move(primary_decoder))
+ CreateVideoDecoderSoftwareFallbackWrapper(
+ *reinterpret_cast<const Environment*>(j_webrtc_env_ref),
+ std::move(fallback_decoder), std::move(primary_decoder))
.release();
return NativeToJavaPointer(native_wrapper);
diff --git a/sdk/android/src/jni/vp8_codec.cc b/sdk/android/src/jni/vp8_codec.cc
index 8b34495..b33fece 100644
--- a/sdk/android/src/jni/vp8_codec.cc
+++ b/sdk/android/src/jni/vp8_codec.cc
@@ -10,6 +10,7 @@
#include <jni.h>
+#include "api/environment/environment.h"
#include "modules/video_coding/codecs/vp8/include/vp8.h"
#include "sdk/android/generated_libvpx_vp8_jni/LibvpxVp8Decoder_jni.h"
#include "sdk/android/generated_libvpx_vp8_jni/LibvpxVp8Encoder_jni.h"
@@ -22,8 +23,11 @@
return jlongFromPointer(VP8Encoder::Create().release());
}
-static jlong JNI_LibvpxVp8Decoder_CreateDecoder(JNIEnv* jni) {
- return jlongFromPointer(VP8Decoder::Create().release());
+static jlong JNI_LibvpxVp8Decoder_CreateDecoder(JNIEnv* jni,
+ jlong j_webrtc_env_ref) {
+ return NativeToJavaPointer(
+ CreateVp8Decoder(*reinterpret_cast<const Environment*>(j_webrtc_env_ref))
+ .release());
}
} // namespace jni