From e3a64c13c42c846eead12f09f5518338711524d2 Mon Sep 17 00:00:00 2001 From: WangQiang Date: Tue, 19 Jul 2022 16:51:33 +0800 Subject: [PATCH] adnroid bazel --- WORKSPACE | 6 +- WORKSPACE-e | 4 +- .../.gradle/7.4/checksums/checksums.lock | Bin 0 -> 17 bytes .../dependencies-accessors.lock | Bin 0 -> 17 bytes .../7.4/dependencies-accessors/gc.properties | 0 .../executionHistory/executionHistory.lock | Bin 0 -> 17 bytes .../.gradle/7.4/fileChanges/last-build.bin | Bin 0 -> 1 bytes .../.gradle/7.4/fileHashes/fileHashes.lock | Bin 0 -> 17 bytes .../solutions/.gradle/7.4/gc.properties | 0 .../buildOutputCleanup.lock | Bin 0 -> 17 bytes .../buildOutputCleanup/cache.properties | 2 + .../solutions/.gradle/vcs-1/gc.properties | 0 mediapipe/render/module/render_queue/BUILD | 113 ++++++++++++++++-- .../render/module/render_queue/OlaRender.h | 10 +- .../src/com/ola/render/RenderJni.java | 29 +++++ 15 files changed, 147 insertions(+), 17 deletions(-) create mode 100644 mediapipe/examples/android/solutions/.gradle/7.4/checksums/checksums.lock create mode 100644 mediapipe/examples/android/solutions/.gradle/7.4/dependencies-accessors/dependencies-accessors.lock create mode 100644 mediapipe/examples/android/solutions/.gradle/7.4/dependencies-accessors/gc.properties create mode 100644 mediapipe/examples/android/solutions/.gradle/7.4/executionHistory/executionHistory.lock create mode 100644 mediapipe/examples/android/solutions/.gradle/7.4/fileChanges/last-build.bin create mode 100644 mediapipe/examples/android/solutions/.gradle/7.4/fileHashes/fileHashes.lock create mode 100644 mediapipe/examples/android/solutions/.gradle/7.4/gc.properties create mode 100644 mediapipe/examples/android/solutions/.gradle/buildOutputCleanup/buildOutputCleanup.lock create mode 100644 mediapipe/examples/android/solutions/.gradle/buildOutputCleanup/cache.properties create mode 100644 mediapipe/examples/android/solutions/.gradle/vcs-1/gc.properties create mode 100644 mediapipe/render/module/render_queue/src/com/ola/render/RenderJni.java diff --git a/WORKSPACE b/WORKSPACE index 1112c0385..36b0d33e5 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -417,7 +417,9 @@ libedgetpu_dependencies() load("@coral_crosstool//:configure.bzl", "cc_crosstool") cc_crosstool(name = "crosstool") -android_sdk_repository(name = "androidsdk", path = "/Users/wangrenzhu/Library/Android/sdk") -android_ndk_repository(name = "androidndk", api_level=21, path = "/Users/wangrenzhu/Library/Android/sdk/ndk/21.2.6472646") +# android_sdk_repository(name = "androidsdk", path = "/Users/wangrenzhu/Library/Android/sdk") +# android_ndk_repository(name = "androidndk", api_level=21, path = "/Users/wangrenzhu/Library/Android/sdk/ndk/21.2.6472646") # android_sdk_repository(name = "androidsdk", path = "/Users/wangrenzhu/Android/sdk") # android_ndk_repository(name = "androidndk", api_level=21, path = "/Users/wangrenzhu/Android/sdk/ndk/android-ndk-r21") +android_sdk_repository(name = "androidsdk") +android_ndk_repository(name = "androidndk", api_level=22) diff --git a/WORKSPACE-e b/WORKSPACE-e index 1112c0385..0f3a6acd4 100644 --- a/WORKSPACE-e +++ b/WORKSPACE-e @@ -417,7 +417,7 @@ libedgetpu_dependencies() load("@coral_crosstool//:configure.bzl", "cc_crosstool") cc_crosstool(name = "crosstool") -android_sdk_repository(name = "androidsdk", path = "/Users/wangrenzhu/Library/Android/sdk") -android_ndk_repository(name = "androidndk", api_level=21, path = "/Users/wangrenzhu/Library/Android/sdk/ndk/21.2.6472646") +# android_sdk_repository(name = "androidsdk", path = "/Users/wangrenzhu/Library/Android/sdk") +# android_ndk_repository(name = "androidndk", api_level=21, path = "/Users/wangrenzhu/Library/Android/sdk/ndk/21.2.6472646") # android_sdk_repository(name = "androidsdk", path = "/Users/wangrenzhu/Android/sdk") # android_ndk_repository(name = "androidndk", api_level=21, path = "/Users/wangrenzhu/Android/sdk/ndk/android-ndk-r21") diff --git a/mediapipe/examples/android/solutions/.gradle/7.4/checksums/checksums.lock b/mediapipe/examples/android/solutions/.gradle/7.4/checksums/checksums.lock new file mode 100644 index 0000000000000000000000000000000000000000..339192710d5d42dd83c9a39bdfc2ff868ad58442 GIT binary patch literal 17 TcmZQRa(eT0;g{-r7@zn;3{U_7JVFHU literal 0 HcmV?d00001 diff --git a/mediapipe/examples/android/solutions/.gradle/7.4/fileChanges/last-build.bin b/mediapipe/examples/android/solutions/.gradle/7.4/fileChanges/last-build.bin new file mode 100644 index 0000000000000000000000000000000000000000..f76dd238ade08917e6712764a16a22005a50573d GIT binary patch literal 1 IcmZPo000310RR91 literal 0 HcmV?d00001 diff --git a/mediapipe/examples/android/solutions/.gradle/7.4/fileHashes/fileHashes.lock b/mediapipe/examples/android/solutions/.gradle/7.4/fileHashes/fileHashes.lock new file mode 100644 index 0000000000000000000000000000000000000000..7c6f0f2a1c1aa10d4b171fd6546caeda8fbe2c25 GIT binary patch literal 17 TcmZQJoPPfg$8`lK1}FdkGFk)Z literal 0 HcmV?d00001 diff --git a/mediapipe/examples/android/solutions/.gradle/7.4/gc.properties b/mediapipe/examples/android/solutions/.gradle/7.4/gc.properties new file mode 100644 index 000000000..e69de29bb diff --git a/mediapipe/examples/android/solutions/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/mediapipe/examples/android/solutions/.gradle/buildOutputCleanup/buildOutputCleanup.lock new file mode 100644 index 0000000000000000000000000000000000000000..5cda3254c0b33c4191361ec3a49df9b62bbf577a GIT binary patch literal 17 UcmZP;{O_^0;PHz+3=qHw06VM&0RR91 literal 0 HcmV?d00001 diff --git a/mediapipe/examples/android/solutions/.gradle/buildOutputCleanup/cache.properties b/mediapipe/examples/android/solutions/.gradle/buildOutputCleanup/cache.properties new file mode 100644 index 000000000..ea21cf2f1 --- /dev/null +++ b/mediapipe/examples/android/solutions/.gradle/buildOutputCleanup/cache.properties @@ -0,0 +1,2 @@ +#Tue Jul 19 14:43:33 CST 2022 +gradle.version=7.4 diff --git a/mediapipe/examples/android/solutions/.gradle/vcs-1/gc.properties b/mediapipe/examples/android/solutions/.gradle/vcs-1/gc.properties new file mode 100644 index 000000000..e69de29bb diff --git a/mediapipe/render/module/render_queue/BUILD b/mediapipe/render/module/render_queue/BUILD index bff9a9b79..087c7a628 100644 --- a/mediapipe/render/module/render_queue/BUILD +++ b/mediapipe/render/module/render_queue/BUILD @@ -1,7 +1,96 @@ load("@build_bazel_rules_apple//apple:ios.bzl", "ios_framework") +load("@build_bazel_rules_android//android:rules.bzl", "android_library") + + + + +GL_BASE_LINK_OPTS = select({ + "//conditions:default": [], + "//mediapipe:android": [ + "-lGLESv3", + "-lEGL", + # Note: on Android, libGLESv3.so is normally a symlink to + # libGLESv2.so, so we don't need to link to it. In fact, we + # do not _want_ to link to it, or we would be unable to load + # on API level < 18, where the symlink is missing entirely. + # Note: if we ever find a strange version of Android where the + # GLESv3 library is not a symlink, we will have to load it at + # runtime. Weak GLESv3 symbols will still be resolved if we + # load it early enough. + ], + "//mediapipe:ios": [ + "-framework OpenGLES", + "-framework CoreVideo", + ], + "//mediapipe:macos": [ + "-framework OpenGL", + "-framework CoreVideo", + ], +}) + +# This is @unused internally. +GL_BASE_LINK_OPTS_OSS = GL_BASE_LINK_OPTS + select({ + "//conditions:default": [ + # Use GLES/EGL on linux. + # Requires support from graphics card driver (nvidia,mesa,etc..) + # and libraries to be installed. + # Ex: libegl1-mesa-dev libgles2-mesa-dev, or libegl1-nvidia libgles2-nvidia, etc... + "-lGLESv2", + "-lEGL", + ], + "//mediapipe:android": [], + "//mediapipe:ios": [], +}) + cc_library( - name = "ios_olarender", + name = "gl_base", + defines = select({ + "//mediapipe:apple": [ + "GLES_SILENCE_DEPRECATION=1", + ], + "//conditions:default": [], + }), + features = ["-layering_check"], + linkopts = GL_BASE_LINK_OPTS_OSS, + textual_hdrs = ["gl_base.h"], + visibility = ["//visibility:public"], + deps = [":gl_base_hdr"] + select({ + "//mediapipe:android": [], + "//mediapipe:apple": [], + "//conditions:default": [ + ], + }), +) + +cc_library( + name = "gl_base_hdr", + hdrs = ["gl_base.h"], + features = ["-layering_check"], + # Note: need the frameworks on Apple platforms to get the headers. + linkopts = select({ + "//conditions:default": [], + "//mediapipe:ios": [ + "-framework OpenGLES", + "-framework CoreVideo", + ], + "//mediapipe:macos": [ + "-framework OpenGL", + "-framework CoreVideo", + ], + }), + visibility = ["//visibility:public"], + deps = select({ + "//mediapipe:android": [], + "//mediapipe:apple": [], + "//conditions:default": [ + ], + }), +) + + +cc_library( + name = "olarender", srcs = [ "util.cpp", "image_queue.cpp", @@ -20,10 +109,11 @@ cc_library( ], # Use -Dverbose=-1 to turn off zlib's trace logging. (#3280) linkstatic = True, + linkopts = GL_BASE_LINK_OPTS_OSS, includes = ["."], visibility = ["//visibility:public"], deps = [ - "//mediapipe/modules/render_queue/math:math", + "//mediapipe/render/module/render_queue/math:math", ], copts = select({ "//mediapipe:apple": [ @@ -35,13 +125,11 @@ cc_library( alwayslink = True, ) - - objc_library( name = "OlaRenderLibrary", visibility = ["//visibility:public"], deps = [ - "//mediapipe/modules/render_queue:ios_olarender", + "//mediapipe/render/module/render_queue:olarender", ], copts = select({ "//mediapipe:apple": [ @@ -54,8 +142,6 @@ objc_library( "AVFoundation", "CoreGraphics", "CoreMedia", - "OpenGLES", - "CoreVideo", "IOSurface", "Foundation", "UIKit", @@ -81,6 +167,17 @@ ios_framework( families = ["iphone", "ipad"], minimum_os_version = "10.0", deps = [ - "//mediapipe/modules/render_queue:OlaRenderLibrary", + "//mediapipe/render/module/render_queue:OlaRenderLibrary", ], ) + +####### android ######## +android_library( + name = "ola_render", + srcs = [ + "src/com/ola/render/RenderJni.java" + ], + deps = [ + "//mediapipe/render/module/render_queue:olarender", + ], +) \ No newline at end of file diff --git a/mediapipe/render/module/render_queue/OlaRender.h b/mediapipe/render/module/render_queue/OlaRender.h index f3adb8fe9..55705fba3 100644 --- a/mediapipe/render/module/render_queue/OlaRender.h +++ b/mediapipe/render/module/render_queue/OlaRender.h @@ -21,7 +21,7 @@ #define USE_NEED_RECREATE 0 #include -#include "macros.h" +// #include "macros.h" #if USE_OLARENDER #include @@ -30,12 +30,12 @@ #endif #endif -#if PLATFORM == PLATFORM_IOS - +// #if PLATFORM == PLATFORM_IOS +#ifdef __APPLE__ #import #import -#elif PLATFORM == PLATFORM_ANDROID - +// #elif PLATFORM == PLATFORM_ANDROID +#else #include #include diff --git a/mediapipe/render/module/render_queue/src/com/ola/render/RenderJni.java b/mediapipe/render/module/render_queue/src/com/ola/render/RenderJni.java new file mode 100644 index 000000000..19e0f4e51 --- /dev/null +++ b/mediapipe/render/module/render_queue/src/com/ola/render/RenderJni.java @@ -0,0 +1,29 @@ +/** + * @ProjectName: MyLrcRender + * @Package: com.ola.render + * @ClassName: RenderJni2 + * @Description: + * @Author: 王强 + * @CreateDate: 2022/7/19 14:41 + */ + +package com.ola.render; + +public class RenderJni{ + static { + System.loadLibrary("render"); + } + + public static native Long create(); + + public static native int render( + Long renderContext, + int textureId, + int width, + int height, + Long timestamp, + boolean export + ); + + public static native void release(Long render); +}