11diff --git a/modules/video_coding/codecs/test/android_codec_factory_helper.cc b/modules/video_coding/codecs/test/android_codec_factory_helper.cc
2- index f6a5046210..4ce5a79d25 100644
2+ index f6a5046210..103d979d2a 100644
33--- a/modules/video_coding/codecs/test/android_codec_factory_helper.cc
44+++ b/modules/video_coding/codecs/test/android_codec_factory_helper.cc
55@@ -54,9 +54,9 @@ void InitializeAndroidObjects() {
66 std::unique_ptr<VideoEncoderFactory> CreateAndroidEncoderFactory() {
77 JNIEnv* env = AttachCurrentThreadIfNeeded();
88 ScopedJavaLocalRef<jclass> factory_class =
99- GetClass(env, "org/webrtc/HardwareVideoEncoderFactory");
10- + GetClass(env, "livekit/org/webrtc/HardwareVideoEncoderFactory");
10+ + GetClass(env, "livekit/livekit/ org/webrtc/HardwareVideoEncoderFactory");
1111 jmethodID factory_constructor = env->GetMethodID(
1212- factory_class.obj(), "<init>", "(Lorg/webrtc/EglBase$Context;ZZ)V");
13- + factory_class.obj(), "<init>", "(Llivekit/org/webrtc/EglBase$Context;ZZ)V");
13+ + factory_class.obj(), "<init>", "(Llivekit/livekit/ org/webrtc/EglBase$Context;ZZ)V");
1414 ScopedJavaLocalRef<jobject> factory_object =
1515 ScopedJavaLocalRef<jobject>::Adopt(
1616 env, env->NewObject(factory_class.obj(), factory_constructor,
@@ -27,10 +27,10 @@ index f6a5046210..4ce5a79d25 100644
2727 ScopedJavaLocalRef<jobject>::Adopt(
2828 env, env->NewObject(factory_class.obj(), factory_constructor,
2929diff --git a/sdk/android/BUILD.gn b/sdk/android/BUILD.gn
30- index 8ce74e2c8c..2e88760d0a 100644
30+ index 06fcf84a9d..627e204582 100644
3131--- a/sdk/android/BUILD.gn
3232+++ b/sdk/android/BUILD.gn
33- @@ -1446 ,11 +1446 ,13 @@ if (current_os == "linux" || is_android) {
33+ @@ -1493 ,11 +1493 ,13 @@ if (current_os == "linux" || is_android) {
3434 generate_jni("generated_environment_jni") {
3535 sources = [ "api/org/webrtc/Environment.java" ]
3636 namespace = "webrtc::jni"
@@ -44,15 +44,15 @@ index 8ce74e2c8c..2e88760d0a 100644
4444 }
4545
4646 # Generated JNI for public JNI targets, matching order of targets
47- @@ -1464 ,6 +1466 ,7 @@ if (current_os == "linux" || is_android) {
47+ @@ -1511 ,6 +1513 ,7 @@ if (current_os == "linux" || is_android) {
4848 "src/java/org/webrtc/JniCommon.java",
4949 ]
5050 namespace = "webrtc::jni"
5151+ package_prefix = android_package_prefix
5252 }
5353
5454 generate_jni("generated_video_jni") {
55- @@ -1493 ,11 +1496 ,13 @@ if (current_os == "linux" || is_android) {
55+ @@ -1540 ,11 +1543 ,13 @@ if (current_os == "linux" || is_android) {
5656 "src/java/org/webrtc/WrappedNativeI420Buffer.java",
5757 ]
5858 namespace = "webrtc::jni"
@@ -66,15 +66,15 @@ index 8ce74e2c8c..2e88760d0a 100644
6666 }
6767
6868 generate_jni("generated_libvpx_vp8_jni") {
69- @@ -1507 ,6 +1512 ,7 @@ if (current_os == "linux" || is_android) {
69+ @@ -1554 ,6 +1559 ,7 @@ if (current_os == "linux" || is_android) {
7070 ]
7171
7272 namespace = "webrtc::jni"
7373+ package_prefix = android_package_prefix
7474 }
7575
7676 generate_jni("generated_libvpx_vp9_jni") {
77- @@ -1516 ,18 +1522 ,21 @@ if (current_os == "linux" || is_android) {
77+ @@ -1563 ,18 +1569 ,21 @@ if (current_os == "linux" || is_android) {
7878 ]
7979
8080 namespace = "webrtc::jni"
@@ -96,7 +96,7 @@ index 8ce74e2c8c..2e88760d0a 100644
9696 }
9797
9898 generate_jni("generated_swcodecs_jni") {
99- @@ -1537 ,11 +1546 ,13 @@ if (current_os == "linux" || is_android) {
99+ @@ -1584 ,11 +1593 ,13 @@ if (current_os == "linux" || is_android) {
100100 ]
101101
102102 namespace = "webrtc::jni"
@@ -110,8 +110,8 @@ index 8ce74e2c8c..2e88760d0a 100644
110110 }
111111
112112 generate_jni("generated_peerconnection_jni") {
113- @@ -1585 ,11 +1596 ,13 @@ if (current_os == "linux" || is_android) {
114- "api/org/webrtc/TurnCustomizer .java",
113+ @@ -1637 ,11 +1648 ,13 @@ if (current_os == "linux" || is_android) {
114+ "api/org/webrtc/audio/AudioProcessingState .java",
115115 ]
116116 namespace = "webrtc::jni"
117117+ package_prefix = android_package_prefix
@@ -124,15 +124,15 @@ index 8ce74e2c8c..2e88760d0a 100644
124124 }
125125
126126 generate_jni("generated_builtin_audio_codecs_jni") {
127- @@ -1598 ,6 +1611 ,7 @@ if (current_os == "linux" || is_android) {
127+ @@ -1650 ,6 +1663 ,7 @@ if (current_os == "linux" || is_android) {
128128 "api/org/webrtc/BuiltinAudioEncoderFactoryFactory.java",
129129 ]
130130 namespace = "webrtc::jni"
131131+ package_prefix = android_package_prefix
132132 }
133133
134134 # Generated JNI for native API targets
135- @@ -1609 ,17 +1623 ,20 @@ if (current_os == "linux" || is_android) {
135+ @@ -1661 ,17 +1675 ,20 @@ if (current_os == "linux" || is_android) {
136136 "src/java/org/webrtc/WebRtcClassLoader.java",
137137 ]
138138 namespace = "webrtc::jni"
@@ -153,19 +153,27 @@ index 8ce74e2c8c..2e88760d0a 100644
153153 }
154154
155155 generate_jni("generated_java_audio_device_module_native_jni") {
156- @@ -1628 ,6 +1645 ,7 @@ if (current_os == "linux" || is_android) {
156+ @@ -1680 ,6 +1697 ,7 @@ if (current_os == "linux" || is_android) {
157157 "src/java/org/webrtc/audio/WebRtcAudioTrack.java",
158158 ]
159159 namespace = "webrtc::jni"
160160+ package_prefix = android_package_prefix
161161 }
162162 }
163163
164+ @@ -1937,6 +1955,7 @@ if (is_android) {
165+ "native_unittests/org/webrtc/PeerConnectionFactoryInitializationHelper.java",
166+ ]
167+ namespace = "webrtc::jni"
168+ + package_prefix = android_package_prefix
169+ }
170+
171+ robolectric_binary("android_sdk_junit_tests") {
164172diff --git a/sdk/android/api/org/webrtc/PeerConnectionFactory.java b/sdk/android/api/org/webrtc/PeerConnectionFactory.java
165- index 01679ad12b..7b8545902d 100644
173+ index 8cfa52b033..e878b80f36 100644
166174--- a/sdk/android/api/org/webrtc/PeerConnectionFactory.java
167175+++ b/sdk/android/api/org/webrtc/PeerConnectionFactory.java
168- @@ -88 ,7 +88 ,7 @@ public class PeerConnectionFactory {
176+ @@ -90 ,7 +90 ,7 @@ public class PeerConnectionFactory {
169177 private String fieldTrials = "";
170178 private boolean enableInternalTracer;
171179 private NativeLibraryLoader nativeLibraryLoader = new NativeLibrary.DefaultLoader();
@@ -175,7 +183,7 @@ index 01679ad12b..7b8545902d 100644
175183 @Nullable private Severity loggableSeverity;
176184
177185diff --git a/sdk/android/src/jni/jni_helpers.h b/sdk/android/src/jni/jni_helpers.h
178- index d86c8fa4ad..30f307a2ca 100644
186+ index 950190ece0..7d7b3618c7 100644
179187--- a/sdk/android/src/jni/jni_helpers.h
180188+++ b/sdk/android/src/jni/jni_helpers.h
181189@@ -29,10 +29,10 @@
@@ -225,10 +233,10 @@ index 2fbce97c60..130b3d5fa7 100755
225233
226234 def main():
227235diff --git a/webrtc.gni b/webrtc.gni
228- index 468ba33b01..ca81ce298c 100644
236+ index 0d2db4d1d6..2468184608 100644
229237--- a/webrtc.gni
230238+++ b/webrtc.gni
231- @@ -241 ,6 +241 ,10 @@ declare_args() {
239+ @@ -234 ,6 +234 ,10 @@ declare_args() {
232240 # hasn't been registered.
233241 rtc_strict_field_trials = ""
234242
@@ -240,7 +248,7 @@ index 468ba33b01..ca81ce298c 100644
240248 # with this string.
241249 # See the definition of RTC_OBJC_TYPE_PREFIX in the code.
242250diff --git a/third_party/jni_zero/BUILD.gn b/third_party/jni_zero/BUILD.gn
243- index 7056bdd033c1..2b97de476de7 100644
251+ index 58e0233e52..325b0e36c7 100644
244252--- a/third_party/jni_zero/BUILD.gn
245253+++ b/third_party/jni_zero/BUILD.gn
246254@@ -17,6 +17,7 @@ generate_jni("generate_jni") {
@@ -250,12 +258,12 @@ index 7056bdd033c1..2b97de476de7 100644
250258+ package_prefix = "livekit"
251259 }
252260
253- generate_jar_jni("system_jni") {
261+ # Common classes to save projects from having to generate them.
254262diff --git a/third_party/jni_zero/codegen/header_common.py b/third_party/jni_zero/codegen/header_common.py
255- index 338cd748079f..be2577281a91 100644
263+ index 3967f94ed5..1f5cee6d81 100644
256264--- a/third_party/jni_zero/codegen/header_common.py
257265+++ b/third_party/jni_zero/codegen/header_common.py
258- @@ -12 ,7 +12 ,8 @@ def class_accessors(sb, java_classes, module_name ):
266+ @@ -11 ,7 +11 ,8 @@ def class_accessors(sb, java_classes):
259267 for java_class in java_classes:
260268 if java_class in (java_types.OBJECT_CLASS, java_types.STRING_CLASS):
261269 continue
@@ -265,7 +273,7 @@ index 338cd748079f..be2577281a91 100644
265273 # #ifdef needed when multple .h files are #included that common classes.
266274 sb(f"""\
267275 #ifndef {escaped_name}_clazz_defined
268- @@ -44 ,7 +45 ,7 @@ def class_accessor_expression(java_class):
276+ @@ -42 ,7 +43 ,7 @@ def class_accessor_expression(java_class):
269277 if java_class == java_types.STRING_CLASS:
270278 return 'jni_zero::g_string_class'
271279
@@ -274,17 +282,20 @@ index 338cd748079f..be2577281a91 100644
274282
275283
276284 def header_preamble(script_name,
277- @@ -53,7 +54,7 @@ def header_preamble(script_name,
278- user_includes=None,
279- header_guard=None):
285+ @@ -53,9 +54,9 @@ def header_preamble(script_name,
286+ is_shared_header=False):
280287 if header_guard is None:
281- - header_guard = f'{java_class.to_cpp()}_JNI'
282- + header_guard = f'{java_class.class_without_prefix.to_cpp()}_JNI'
288+ if is_shared_header:
289+ - header_guard = f'{java_class.to_cpp()}_SHARED_JNI'
290+ + header_guard = f'{java_class.class_without_prefix.to_cpp()}_SHARED_JNI'
291+ else:
292+ - header_guard = f'{java_class.to_cpp()}_JNI'
293+ + header_guard = f'{java_class.class_without_prefix.to_cpp()}_JNI'
283294 sb = []
284295 sb.append(f"""\
285296 // This file was generated by
286297diff --git a/third_party/jni_zero/jni_zero.gni b/third_party/jni_zero/jni_zero.gni
287- index 71826b906d10..22d8eaf6e232 100644
298+ index edc5364c59..40726f5cfb 100644
288299--- a/third_party/jni_zero/jni_zero.gni
289300+++ b/third_party/jni_zero/jni_zero.gni
290301@@ -123,7 +123,7 @@ template("_invoke_jni_zero") {
@@ -296,22 +307,21 @@ index 71826b906d10..22d8eaf6e232 100644
296307 # Example
297308 # generate_jni_registration("chrome_jni_registration") {
298309 # java_targets = [ ":chrome_public_apk" ]
299- @@ -327 ,6 +327 ,7 @@ template("generate_jni_impl") {
310+ @@ -345 ,6 +347 ,7 @@ template("generate_jni_impl") {
300311 "deps",
301312 "metadata",
302313 "public_deps",
303314+ "package_prefix",
304315 ])
305316 if (!defined(public_deps)) {
306317 public_deps = []
307- @@ -421,7 +422,9 @@ template("generate_jni_impl") {
308- if (defined(invoker.split_name)) {
309- args += [ "--split-name=${invoker.split_name}" ]
310- }
311- -
312- + if (defined(package_prefix)) {
313- + args += [ "--package-prefix=${package_prefix}" ]
314- + }
315- foreach(_name, _input_names) {
316- _name =
317- string_replace(get_path_info(_name, "name"), "\$", "__") + "_jni.h"
318+ @@ -396,6 +399,9 @@ template("generate_jni_impl") {
319+ if (defined(invoker.namespace)) {
320+ args += [ "--namespace=${invoker.namespace}" ]
321+ }
322+ + if (defined(package_prefix)) {
323+ + args += [ "--package-prefix=${package_prefix}" ]
324+ + }
325+ if (defined(invoker.module_name)) {
326+ args += [ "--module-name=${invoker.module_name}" ]
327+ }
0 commit comments