jni方法签名不对的问题

This commit is contained in:
WangQiang 2022-08-04 10:32:08 +08:00
parent 8ae5b18fd0
commit c2b403a90c
7 changed files with 96 additions and 19 deletions

View File

@ -0,0 +1,38 @@
# Copyright 2019 The MediaPipe Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
licenses(["notice"])
exports_files([
"proguard.pgcfg",
])
android_library(
name = "camera_framework",
proguard_specs = [":proguard.pgcfg"],
visibility = ["//visibility:public"],
exports = [
":camera_core",
],
)
android_library(
name = "camera_core",
srcs = glob(
["**/*.java"],
),
deps = [
"@maven//:com_google_guava_guava",
],
)

View File

@ -0,0 +1,29 @@
# Additional flags to pass to Proguard when processing a binary that uses
# MediaPipe.
# Keep public members of our public interfaces. This also prevents the
# obfuscation of the corresponding methods in classes implementing them,
# such as implementations of PacketCallback#process.
-keep public interface com.google.mediapipe.framework.* {
public *;
}
# This method is invoked by native code.
-keep public class com.google.mediapipe.framework.Packet {
public static *** create(***);
public long getNativeHandle();
public void release();
}
# This method is invoked by native code.
-keep public class com.google.mediapipe.framework.PacketCreator {
*** releaseWithSyncToken(...);
}
# This method is invoked by native code.
-keep public class com.google.mediapipe.framework.MediaPipeException {
<init>(int, byte[]);
}
# Required to use PacketCreator#createProto
-keep class com.google.mediapipe.framework.ProtoUtil$SerializedMessage { *; }

View File

@ -1,10 +1,17 @@
load("@build_bazel_rules_apple//apple:ios.bzl", "ios_framework") load("@build_bazel_rules_apple//apple:ios.bzl", "ios_framework")
licenses(["notice"])
package( package(
default_visibility = ["//visibility:public"], default_visibility = ["//visibility:public"],
features = ["no_layering_check"], features = ["no_layering_check"],
) )
alias(
name = "olarender_jni",
actual = ":olarender",
)
cc_library( cc_library(
name = "olarender", name = "olarender",
srcs = [ srcs = [

View File

@ -9,10 +9,12 @@ load("@build_bazel_rules_android//android:rules.bzl", "android_binary", "android
def ola_aar(name, def ola_aar(name,
srcs = [], srcs = [],
assets = [], assets = [],
gen_lib = True,
proguard_specs = [], proguard_specs = [],
assets_dir = "" ): assets_dir = "" ):
_ola_jni( _ola_jni(
gen_lib = gen_lib,
name = name + "_jni", name = name + "_jni",
) )
@ -46,16 +48,17 @@ EOF
def _ola_jni(name): def _ola_jni(gen_lib, name):
# native.cc_binary( if gen_lib:
# name = "libola_render_jni.so", native.cc_binary(
# linkshared = 1, name = "libola_render_jni.so",
# linkstatic = 1, linkshared = 1,
# deps = [ linkstatic = 1,
# "//mediapipe/render/module/render_queue:olarender_jni", deps = [
# ] "//mediapipe/render/module/render_queue:olarender",
# ) ]
)
native.cc_library( native.cc_library(
name = name + "_cc_lib", name = name + "_cc_lib",

View File

@ -1,12 +1,14 @@
load("//mediapipe/render/module/render_queue:ola_aar.bzl", "ola_aar") load("//mediapipe/render/module/render_queue:ola_aar.bzl", "ola_aar")
licenses(["notice"])
package(default_visibility = ["//visibility:public"]) package(default_visibility = ["//visibility:public"])
cc_binary( cc_binary(
name = "libola_render_jni.so", name = "libola_render_jni.so",
linkshared = 1, linkshared = 1,
linkstatic = 1, linkstatic = 1,
srcs = [ deps = [
"//mediapipe/render/module/render_queue:olarender", "//mediapipe/render/module/render_queue:olarender",
], ],
) )
@ -28,11 +30,9 @@ cc_library(
ola_aar( ola_aar(
name = "render", name = "ola_render",
# srcs = [
# "RenderJni.java"
# ],
srcs = glob(["*.java"]), srcs = glob(["*.java"]),
gen_lib = False,
proguard_specs = ["proguard.pgcfg"], proguard_specs = ["proguard.pgcfg"],
# deps = [ # deps = [
# "//mediapipe/render/module/render_queue:olarender", # "//mediapipe/render/module/render_queue:olarender",

View File

@ -15,16 +15,16 @@ public class RenderJni{
System.loadLibrary("ola_render_jni"); System.loadLibrary("ola_render_jni");
} }
public static native Long create(); public static native long create();
public static native int render( public static native int render(
Long renderContext, long renderContext,
int textureId, int textureId,
int width, int width,
int height, int height,
Long timestamp, long timestamp,
boolean export boolean export
); );
public static native void release(Long render); public static native void release(long render);
} }