summaryrefslogtreecommitdiff
path: root/data
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2020-09-07 13:39:26 -0400
committerXavier Claessens <xavier.claessens@collabora.com>2022-04-01 08:56:34 -0400
commit9f5b00d528bd796ef2d2e1c15d2dea40169bcbe7 (patch)
treef9255c959d23c3fcd94b1fe238cbe4330b17a368 /data
parent1fc1cf0ad76f34eff887abd2b5b62437c8e617fd (diff)
android: Use GStreamer.java installed by GStreamer core
Part-of: <https://gitlab.freedesktop.org/gstreamer/cerbero/-/merge_requests/843>
Diffstat (limited to 'data')
-rw-r--r--data/ndk-build/GStreamer.java99
-rw-r--r--data/ndk-build/gstreamer-1.0.mk16
2 files changed, 5 insertions, 110 deletions
diff --git a/data/ndk-build/GStreamer.java b/data/ndk-build/GStreamer.java
deleted file mode 100644
index 0a693f81..00000000
--- a/data/ndk-build/GStreamer.java
+++ /dev/null
@@ -1,99 +0,0 @@
-package org.freedesktop.gstreamer;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import android.content.Context;
-import android.content.res.AssetManager;
-
-public class GStreamer {
- private static native void nativeInit(Context context) throws Exception;
-
- public static void init(Context context) throws Exception {
-@INCLUDE_CA_CERTIFICATES@ copyCaCertificates(context);
-@INCLUDE_FONTS@ copyFonts(context);
- nativeInit(context);
- }
-
-@INCLUDE_FONTS@ private static void copyFonts(Context context) {
-@INCLUDE_FONTS@ AssetManager assetManager = context.getAssets();
-@INCLUDE_FONTS@ File filesDir = context.getFilesDir();
-@INCLUDE_FONTS@ File fontsFCDir = new File (filesDir, "fontconfig");
-@INCLUDE_FONTS@ File fontsDir = new File (fontsFCDir, "fonts");
-@INCLUDE_FONTS@ File fontsCfg = new File (fontsFCDir, "fonts.conf");
-@INCLUDE_FONTS@
-@INCLUDE_FONTS@ fontsDir.mkdirs();
-@INCLUDE_FONTS@
-@INCLUDE_FONTS@ try {
-@INCLUDE_FONTS@ /* Copy the config file */
-@INCLUDE_FONTS@ copyFile (assetManager, "fontconfig/fonts.conf", fontsCfg);
-@INCLUDE_FONTS@ /* Copy the fonts */
-@INCLUDE_FONTS@ for(String filename : assetManager.list("fontconfig/fonts/truetype")) {
-@INCLUDE_FONTS@ File font = new File(fontsDir, filename);
-@INCLUDE_FONTS@ copyFile (assetManager, "fontconfig/fonts/truetype/" + filename, font);
-@INCLUDE_FONTS@ }
-@INCLUDE_FONTS@ } catch (IOException e) {
-@INCLUDE_FONTS@ e.printStackTrace();
-@INCLUDE_FONTS@ }
-@INCLUDE_FONTS@ }
-
-@INCLUDE_CA_CERTIFICATES@ private static void copyCaCertificates(Context context) {
-@INCLUDE_CA_CERTIFICATES@ AssetManager assetManager = context.getAssets();
-@INCLUDE_CA_CERTIFICATES@ File filesDir = context.getFilesDir();
-@INCLUDE_CA_CERTIFICATES@ File sslDir = new File (filesDir, "ssl");
-@INCLUDE_CA_CERTIFICATES@ File certsDir = new File (sslDir, "certs");
-@INCLUDE_CA_CERTIFICATES@ File certs = new File (certsDir, "ca-certificates.crt");
-@INCLUDE_CA_CERTIFICATES@
-@INCLUDE_CA_CERTIFICATES@ certsDir.mkdirs();
-@INCLUDE_CA_CERTIFICATES@
-@INCLUDE_CA_CERTIFICATES@ try {
-@INCLUDE_CA_CERTIFICATES@ /* Copy the certificates file */
-@INCLUDE_CA_CERTIFICATES@ copyFile (assetManager, "ssl/certs/ca-certificates.crt", certs);
-@INCLUDE_CA_CERTIFICATES@ } catch (IOException e) {
-@INCLUDE_CA_CERTIFICATES@ e.printStackTrace();
-@INCLUDE_CA_CERTIFICATES@ }
-@INCLUDE_CA_CERTIFICATES@ }
-
-@INCLUDE_COPY_FILE@ private static void copyFile(AssetManager assetManager, String assetPath, File outFile) throws IOException {
-@INCLUDE_COPY_FILE@ InputStream in = null;
-@INCLUDE_COPY_FILE@ OutputStream out = null;
-@INCLUDE_COPY_FILE@ IOException exception = null;
-@INCLUDE_COPY_FILE@
-@INCLUDE_COPY_FILE@ if (outFile.exists())
-@INCLUDE_COPY_FILE@ outFile.delete();
-@INCLUDE_COPY_FILE@
-@INCLUDE_COPY_FILE@ try {
-@INCLUDE_COPY_FILE@ in = assetManager.open(assetPath);
-@INCLUDE_COPY_FILE@ out = new FileOutputStream(outFile);
-@INCLUDE_COPY_FILE@
-@INCLUDE_COPY_FILE@ byte[] buffer = new byte[1024];
-@INCLUDE_COPY_FILE@ int read;
-@INCLUDE_COPY_FILE@ while ((read = in.read(buffer)) != -1) {
-@INCLUDE_COPY_FILE@ out.write(buffer, 0, read);
-@INCLUDE_COPY_FILE@ }
-@INCLUDE_COPY_FILE@ out.flush();
-@INCLUDE_COPY_FILE@ } catch (IOException e) {
-@INCLUDE_COPY_FILE@ exception = e;
-@INCLUDE_COPY_FILE@ } finally {
-@INCLUDE_COPY_FILE@ if (in != null)
-@INCLUDE_COPY_FILE@ try {
-@INCLUDE_COPY_FILE@ in.close();
-@INCLUDE_COPY_FILE@ } catch (IOException e) {
-@INCLUDE_COPY_FILE@ if (exception == null)
-@INCLUDE_COPY_FILE@ exception = e;
-@INCLUDE_COPY_FILE@ }
-@INCLUDE_COPY_FILE@ if (out != null)
-@INCLUDE_COPY_FILE@ try {
-@INCLUDE_COPY_FILE@ out.close();
-@INCLUDE_COPY_FILE@ } catch (IOException e) {
-@INCLUDE_COPY_FILE@ if (exception == null)
-@INCLUDE_COPY_FILE@ exception = e;
-@INCLUDE_COPY_FILE@ }
-@INCLUDE_COPY_FILE@ if (exception != null)
-@INCLUDE_COPY_FILE@ throw exception;
-@INCLUDE_COPY_FILE@ }
-@INCLUDE_COPY_FILE@ }
-}
diff --git a/data/ndk-build/gstreamer-1.0.mk b/data/ndk-build/gstreamer-1.0.mk
index a9cf00bf..6565e4aa 100644
--- a/data/ndk-build/gstreamer-1.0.mk
+++ b/data/ndk-build/gstreamer-1.0.mk
@@ -234,21 +234,15 @@ buildsharedlibrary_$(TARGET_ARCH_ABI): $(GSTREAMER_ANDROID_O)
$(hide)$(PRIV_CMD)
ifeq ($(GSTREAMER_INCLUDE_FONTS),yes)
-GSTREAMER_INCLUDE_FONTS_SUBST :=
+GSTREAMER_INCLUDE_FONTS_SUBST := copyFonts
else
-GSTREAMER_INCLUDE_FONTS_SUBST := //
+GSTREAMER_INCLUDE_FONTS_SUBST := //copyFonts
endif
ifeq ($(GSTREAMER_INCLUDE_CA_CERTIFICATES),yes)
-GSTREAMER_INCLUDE_CA_CERTIFICATES_SUBST :=
+GSTREAMER_INCLUDE_CA_CERTIFICATES_SUBST := copyCaCertificates
else
-GSTREAMER_INCLUDE_CA_CERTIFICATES_SUBST := //
-endif
-
-ifneq (,$(findstring yes,$(GSTREAMER_INCLUDE_FONTS)$(GSTREAMER_INCLUDE_CA_CERTIFICATES)))
-GSTREAMER_COPY_FILE_SUBST :=
-else
-GSTREAMER_COPY_FILE_SUBST := //
+GSTREAMER_INCLUDE_CA_CERTIFICATES_SUBST := //copyCaCertificates
endif
# about the sed command, android-studio doesn't seem to like line continuation characters when executing shell commands
@@ -258,7 +252,7 @@ copyjavasource_$(TARGET_ARCH_ABI):
$(call host-mkdir,$(GSTREAMER_JAVA_SRC_DIR)/org/freedesktop/gstreamer/$(plugin)) && ) echo Done mkdir
$(hide)$(foreach file,$(GSTREAMER_PLUGINS_CLASSES), \
$(call host-cp,$(GSTREAMER_NDK_BUILD_PATH)$(file),$(GSTREAMER_JAVA_SRC_DIR)/org/freedesktop/gstreamer/$(file)) && ) echo Done cp
- $(hide)$(SED_LOCAL) "s;@INCLUDE_FONTS@;$(GSTREAMER_INCLUDE_FONTS_SUBST);g" $(GSTREAMER_NDK_BUILD_PATH)/GStreamer.java | $(SED_LOCAL) "s;@INCLUDE_CA_CERTIFICATES@;$(GSTREAMER_INCLUDE_CA_CERTIFICATES_SUBST);g" | $(SED_LOCAL) "s;@INCLUDE_COPY_FILE@;$(GSTREAMER_COPY_FILE_SUBST);g" > $(GSTREAMER_JAVA_SRC_DIR)/org/freedesktop/gstreamer/GStreamer.java
+ $(hide)$(SED_LOCAL) "s;//copyFonts;$(GSTREAMER_INCLUDE_FONTS_SUBST);g" $(GSTREAMER_NDK_BUILD_PATH)/GStreamer.java | $(SED_LOCAL) "s;//copyCaCertificates;$(GSTREAMER_INCLUDE_CA_CERTIFICATES_SUBST);g" > $(GSTREAMER_JAVA_SRC_DIR)/org/freedesktop/gstreamer/GStreamer.java
ifndef GSTREAMER_ASSETS_DIR
GSTREAMER_ASSETS_DIR := src/main/assets