summaryrefslogtreecommitdiff
path: root/data
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian@centricular.com>2015-05-04 09:40:28 +0200
committerSebastian Dröge <sebastian@centricular.com>2015-05-04 09:40:28 +0200
commit631c8e83b2885aa0b485275241a1529bdbfc8a98 (patch)
treecaa9b965bdd281d7c89677241e40c2f8e04bf46f /data
parent7222aa4529c4066b771d2fa0a25f56f59df56e53 (diff)
ndk-build: Remove GStreamer 0.10 files
Diffstat (limited to 'data')
-rwxr-xr-xdata/ndk-build/gstreamer.mk195
-rw-r--r--data/ndk-build/gstreamer_android.c.in426
2 files changed, 0 insertions, 621 deletions
diff --git a/data/ndk-build/gstreamer.mk b/data/ndk-build/gstreamer.mk
deleted file mode 100755
index 742dcdef..00000000
--- a/data/ndk-build/gstreamer.mk
+++ /dev/null
@@ -1,195 +0,0 @@
-# cerbero - a multi-platform build system for Open Source software
-# Copyright (C) 2012 Andoni Morales Alastruey <ylatuya@gmail.com>
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Library General Public
-# License as published by the Free Software Foundation; either
-# version 2 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Library General Public License for more details.
-#
-# You should have received a copy of the GNU Library General Public
-# License along with this library; if not, write to the
-# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA.
-
-$(call assert-defined, GSTREAMER_ROOT)
-$(if $(wildcard $(GSTREAMER_ROOT)),,\
- $(error "The directory GSTREAMER_ROOT=$(GSTREAMER_ROOT) does not exists")\
-)
-
-
-#####################
-# Setup variables #
-#####################
-
-ifndef GSTREAMER_PLUGINS
- $(info "The list of GSTREAMER_PLUGINS is empty")
-endif
-
-# Expand home directory (~/)
-GSTREAMER_SDK_ROOT := $(wildcard $(GSTREAMER_SDK_ROOT))
-
-# Path for GStreamer static plugins
-ifndef GSTREAMER_STATIC_PLUGINS_PATH
-GSTREAMER_STATIC_PLUGINS_PATH := lib/gstreamer-0.10
-endif
-GSTREAMER_STATIC_PLUGINS_PATH := $(GSTREAMER_ROOT)/lib/gstreamer-0.10/static
-
-# Path for the NDK integration makefiles
-ifndef GSTREAMER_NDK_BUILD_PATH
-GSTREAMER_NDK_BUILD_PATH := $(GSTREAMER_ROOT)/share/gst-android/ndk-build
-endif
-
-# Include tools
-include $(GSTREAMER_NDK_BUILD_PATH)/tools.mk
-
-# Path for the static GIO modules
-G_IO_MODULES_PATH := $(GSTREAMER_ROOT)/lib/gio/modules/static
-
-# Host tools
-ifeq ($(HOST_OS),windows)
- HOST_SED := $(GSTREAMER_NDK_BUILD_PATH)/tools/windows/sed
- GSTREAMER_LD :=
-else
-endif
-
-ifndef GSTREAMER_ANDROID_MODULE_NAME
-GSTREAMER_ANDROID_MODULE_NAME := gstreamer_android
-endif
-GSTREAMER_BUILD_DIR := gst-build
-GSTREAMER_ANDROID_O := $(GSTREAMER_BUILD_DIR)/$(GSTREAMER_ANDROID_MODULE_NAME).o
-GSTREAMER_ANDROID_SO := $(GSTREAMER_BUILD_DIR)/lib$(GSTREAMER_ANDROID_MODULE_NAME).so
-GSTREAMER_ANDROID_C := $(GSTREAMER_BUILD_DIR)/$(GSTREAMER_ANDROID_MODULE_NAME).c
-GSTREAMER_ANDROID_C_IN := $(GSTREAMER_NDK_BUILD_PATH)/gstreamer_android.c.in
-GSTREAMER_DEPS := $(GSTREAMER_EXTRA_DEPS) gstreamer-0.10
-GSTREAMER_LD := -fuse-ld=gold
-
-################################
-# NDK Build Prebuilt library #
-################################
-
-# Declare a prebuilt library module, a shared library including
-# gstreamer, its dependencies and all its plugins.
-# Since the shared library is not really prebuilt, but will be built
-# using the defined rules in this file, we can't use the
-# PREBUILT_SHARED_LIBRARY makefiles like explained in the docs,
-# as it checks for the existance of the shared library. We therefore
-# use a custom gstreamer_prebuilt.mk, which skips this step
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := $(GSTREAMER_ANDROID_MODULE_NAME)
-LOCAL_SRC_FILES := $(GSTREAMER_ANDROID_SO)
-LOCAL_BUILD_SCRIPT := PREBUILT_SHARED_LIBRARY
-LOCAL_MODULE_CLASS := PREBUILT_SHARED_LIBRARY
-LOCAL_MAKEFILE := $(local-makefile)
-LOCAL_PREBUILT_PREFIX := lib
-LOCAL_PREBUILT_SUFFIX := .so
-LOCAL_EXPORT_C_INCLUDES := $(subst -I$1, $1, $(call pkg-config-get-includes,$(GSTREAMER_DEPS)))
-LOCAL_EXPORT_C_INCLUDES += $(GSTREAMER_ROOT)/include
-
-
-##################################################################
-# Our custom rules to create a shared libray with gstreamer #
-# and the requested plugins in GSTREAMER_PLUGINS starts here #
-##################################################################
-
-include $(GSTREAMER_NDK_BUILD_PATH)/gstreamer_prebuilt.mk
-# This triggers the build of our library using our custom rules
-$(GSTREAMER_ANDROID_SO): buildsharedlibrary copyjavasource copyfontsres
-
-
-# Some plugins use a different name for the module name, like the playback
-# plugin, which uses playbin for the module name: libgstplaybin.so
-fix-plugin-name = \
- $(subst gst$1 ,gst$2 ,$(GSTREAMER_PLUGINS_LIBS))
-
-fix-deps = \
- $(subst $1,$1 $2,$(GSTREAMER_ANDROID_LIBS))
-
-
-# Generate list of plugin links (eg: -lcoreelements -lvideoscale)
-GSTREAMER_PLUGINS_LIBS := $(foreach plugin, $(GSTREAMER_PLUGINS), -lgst$(plugin) )
-GSTREAMER_PLUGINS_LIBS := $(call fix-plugin-name,playback,playbin)
-GSTREAMER_PLUGINS_LIBS := $(call fix-plugin-name,uridecodebin,decodebin2)
-GSTREAMER_PLUGINS_LIBS := $(call fix-plugin-name,encoding,encodebin)
-GSTREAMER_PLUGINS_LIBS := $(call fix-plugin-name,soup,souphttpsrc)
-GSTREAMER_PLUGINS_LIBS := $(call fix-plugin-name,gstsiren,siren)
-GSTREAMER_PLUGINS_LIBS := $(call fix-plugin-name,sdp,sdpelem)
-GSTREAMER_PLUGINS_LIBS := $(call fix-plugin-name,gstrtpmanager,rtpmanager)
-GSTREAMER_PLUGINS_LIBS := $(call fix-plugin-name,scaletempo,scaletempoplugin)
-GSTREAMER_PLUGINS_LIBS := $(call fix-plugin-name,mpegdemux2,mpegdemux)
-GSTREAMER_PLUGINS_LIBS := $(call fix-plugin-name,realmedia,rmdemux)
-GSTREAMER_PLUGINS_LIBS := $(subst gstgnonlin,gnl,$(GSTREAMER_PLUGINS_LIBS))
-
-# Generate the plugins' declaration strings
-GSTREAMER_PLUGINS_DECLARE := $(foreach plugin, $(GSTREAMER_PLUGINS), \
- GST_PLUGIN_STATIC_DECLARE($(plugin));\n)
-# Generate the plugins' registration strings
-GSTREAMER_PLUGINS_REGISTER := $(foreach plugin, $(GSTREAMER_PLUGINS), \
- GST_PLUGIN_STATIC_REGISTER($(plugin));\n)
-
-# Generate list of gio modules
-G_IO_MODULES_PATH := $(foreach path, $(G_IO_MODULES_PATH), -L$(path))
-G_IO_MODULES_LIBS := $(foreach module, $(G_IO_MODULES), -lgio$(module))
-G_IO_MODULES_DECLARE := $(foreach module, $(G_IO_MODULES), \
- GST_G_IO_MODULE_DECLARE($(module));\n)
-G_IO_MODULES_LOAD := $(foreach module, $(G_IO_MODULES), \
- GST_G_IO_MODULE_LOAD($(module));\n)
-
-# Get the full list of libraries
-# link at least to gstreamer-0.10 in case the plugins list is empty
-GSTREAMER_ANDROID_LIBS := $(call pkg-config-get-libs,$(GSTREAMER_DEPS))
-GSTREAMER_ANDROID_LIBS += $(GSTREAMER_PLUGINS_LIBS) $(G_IO_MODULES_LIBS) -llog -lz
-GSTREAMER_ANDROID_WHOLE_AR := $(call pkg-config-get-libs-no-deps,$(GSTREAMER_DEPS))
-# Fix deps for giognutls
-GSTREAMER_ANDROID_LIBS := $(call fix-deps,-lgiognutls, -lhogweed)
-GSTREAMER_ANDROID_CFLAGS := $(call pkg-config-get-includes,$(GSTREAMER_DEPS)) -I$(GSTREAMER_ROOT)/include
-
-# In newer NDK, SYSROOT is replaced by SYSROOT_INC and SYSROOT_LINK, which
-# now points to the root directory. But this will probably change in the future from:
-# https://android.googlesource.com/platform/ndk/+/fa8c1b4338c1bef2813ecee0ee298e9498a1aaa7
-ifndef SYSROOT
- SYSROOT := $(NDK_PLATFORMS_ROOT)/$(TARGET_PLATFORM)/arch-$(TARGET_ARCH)
-endif
-
-# Create the link command
-GSTREAMER_ANDROID_CMD := $(call libtool-link,$(TARGET_CC) $(TARGET_LDFLAGS) -shared --sysroot=$(SYSROOT) \
- -o $(GSTREAMER_ANDROID_SO) $(GSTREAMER_ANDROID_O) \
- -L$(GSTREAMER_ROOT)/lib -L$(GSTREAMER_STATIC_PLUGINS_PATH) $(G_IO_MODULES_PATH) \
- $(GSTREAMER_ANDROID_LIBS), $(GSTREAMER_LD)) -Wl,-no-undefined $(GSTREAMER_LD)
-GSTREAMER_ANDROID_CMD := $(call libtool-whole-archive,$(GSTREAMER_ANDROID_CMD),$(GSTREAMER_ANDROID_WHOLE_AR))
-
-
-# Generates a source file that declares and registers all the required plugins
-genstatic:
- @$(HOST_ECHO) "GStreamer : [GEN] => $(GSTREAMER_ANDROID_C)"
- @$(call host-mkdir,$(GSTREAMER_BUILD_DIR))
- @$(call host-cp,$(GSTREAMER_ANDROID_C_IN),$(GSTREAMER_ANDROID_C))
- @$(HOST_SED) -i "s/@PLUGINS_DECLARATION@/$(GSTREAMER_PLUGINS_DECLARE)/g" $(GSTREAMER_ANDROID_C)
- @$(HOST_SED) -i "s/@PLUGINS_REGISTRATION@/$(GSTREAMER_PLUGINS_REGISTER)/g" $(GSTREAMER_ANDROID_C)
- @$(HOST_SED) -i "s/@G_IO_MODULES_LOAD@/$(G_IO_MODULES_LOAD)/g" $(GSTREAMER_ANDROID_C)
- @$(HOST_SED) -i "s/@G_IO_MODULES_DECLARE@/$(G_IO_MODULES_DECLARE)/g" $(GSTREAMER_ANDROID_C)
-
-# Compile the source file
-$(GSTREAMER_ANDROID_O): genstatic
- @$(HOST_ECHO) "GStreamer : [COMPILE] => $(GSTREAMER_ANDROID_C)"
- @$(TARGET_CC) --sysroot=$(SYSROOT) $(TARGET_CFLAGS) -c $(GSTREAMER_ANDROID_C) -Wall -Werror -o $(GSTREAMER_ANDROID_O) $(GSTREAMER_ANDROID_CFLAGS)
-
-# Creates a shared library including gstreamer, its plugins and all the dependencies
-buildsharedlibrary: $(GSTREAMER_ANDROID_O)
- @$(HOST_ECHO) "GStreamer : [LINK] => $(GSTREAMER_ANDROID_SO)"
- @$(GSTREAMER_ANDROID_CMD)
-
-copyjavasource:
- @$(call host-mkdir,src/org/freedesktop/gstreamer)
- @$(call host-cp,$(GSTREAMER_NDK_BUILD_PATH)/GStreamer.java,src/org/freedesktop/gstreamer)
-
-copyfontsres:
- @$(call host-mkdir,assets/fontconfig)
- @$(call host-mkdir,assets/fontconfig/fonts/truetype/)
- @$(call host-cp,$(GSTREAMER_NDK_BUILD_PATH)/fontconfig/fonts.conf,assets/fontconfig)
- @$(call host-cp,$(GSTREAMER_NDK_BUILD_PATH)/fontconfig/fonts/Ubuntu-R.ttf,assets/fontconfig/fonts/truetype)
diff --git a/data/ndk-build/gstreamer_android.c.in b/data/ndk-build/gstreamer_android.c.in
deleted file mode 100644
index c7bde635..00000000
--- a/data/ndk-build/gstreamer_android.c.in
+++ /dev/null
@@ -1,426 +0,0 @@
-#include <jni.h>
-#include <gst/gst.h>
-#include <gio/gio.h>
-#include <android/log.h>
-
-static GstClockTime _priv_gst_info_start_time;
-static gboolean _priv_gst_initialized = FALSE;
-
-/* Declaration of static plugins */
- @PLUGINS_DECLARATION@
-
-/* Declaration of static gio modules */
- @G_IO_MODULES_DECLARE@
-
-/* Call this function to register static plugins */
-void
-gst_android_register_static_plugins (void)
-{
- @PLUGINS_REGISTRATION@
-}
-
-/* Call this function to load GIO modules */
-void
-gst_android_load_gio_modules (void)
-{
- @G_IO_MODULES_LOAD@
-}
-
-void
-glib_print_handler (const gchar * string)
-{
- __android_log_print (ANDROID_LOG_INFO, "GLib+stdout", "%s", string);
-}
-
-void
-glib_printerr_handler (const gchar * string)
-{
- __android_log_print (ANDROID_LOG_ERROR, "GLib+stderr", "%s", string);
-}
-
-
-/* Based on GLib's default handler */
-#define CHAR_IS_SAFE(wc) (!((wc < 0x20 && wc != '\t' && wc != '\n' && wc != '\r') || \
- (wc == 0x7f) || \
- (wc >= 0x80 && wc < 0xa0)))
-#define FORMAT_UNSIGNED_BUFSIZE ((GLIB_SIZEOF_LONG * 3) + 3)
-#define STRING_BUFFER_SIZE (FORMAT_UNSIGNED_BUFSIZE + 32)
-#define ALERT_LEVELS (G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING)
-#define DEFAULT_LEVELS (G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING | G_LOG_LEVEL_MESSAGE)
-#define INFO_LEVELS (G_LOG_LEVEL_INFO | G_LOG_LEVEL_DEBUG)
-
-static void
-escape_string (GString * string)
-{
- const char *p = string->str;
- gunichar wc;
-
- while (p < string->str + string->len) {
- gboolean safe;
-
- wc = g_utf8_get_char_validated (p, -1);
- if (wc == (gunichar) - 1 || wc == (gunichar) - 2) {
- gchar *tmp;
- guint pos;
-
- pos = p - string->str;
-
- /* Emit invalid UTF-8 as hex escapes
- */
- tmp = g_strdup_printf ("\\x%02x", (guint) (guchar) * p);
- g_string_erase (string, pos, 1);
- g_string_insert (string, pos, tmp);
-
- p = string->str + (pos + 4); /* Skip over escape sequence */
-
- g_free (tmp);
- continue;
- }
- if (wc == '\r') {
- safe = *(p + 1) == '\n';
- } else {
- safe = CHAR_IS_SAFE (wc);
- }
-
- if (!safe) {
- gchar *tmp;
- guint pos;
-
- pos = p - string->str;
-
- /* Largest char we escape is 0x0a, so we don't have to worry
- * about 8-digit \Uxxxxyyyy
- */
- tmp = g_strdup_printf ("\\u%04x", wc);
- g_string_erase (string, pos, g_utf8_next_char (p) - p);
- g_string_insert (string, pos, tmp);
- g_free (tmp);
-
- p = string->str + (pos + 6); /* Skip over escape sequence */
- } else
- p = g_utf8_next_char (p);
- }
-}
-
-void
-glib_log_handler (const gchar * log_domain, GLogLevelFlags log_level,
- const gchar * message, gpointer user_data)
-{
- gchar *string;
- GString *gstring;
- const gchar *domains;
- gint android_log_level;
- gchar *tag;
-
- if ((log_level & DEFAULT_LEVELS) || (log_level >> G_LOG_LEVEL_USER_SHIFT))
- goto emit;
-
- domains = g_getenv ("G_MESSAGES_DEBUG");
- if (((log_level & INFO_LEVELS) == 0) ||
- domains == NULL ||
- (strcmp (domains, "all") != 0 && (!log_domain
- || !strstr (domains, log_domain))))
- return;
-
-emit:
-
- if (log_domain)
- tag = g_strdup_printf ("GLib+%s", log_domain);
- else
- tag = g_strdup ("GLib");
-
- switch (log_level & G_LOG_LEVEL_MASK) {
- case G_LOG_LEVEL_ERROR:
- android_log_level = ANDROID_LOG_ERROR;
- break;
- case G_LOG_LEVEL_CRITICAL:
- android_log_level = ANDROID_LOG_ERROR;
- break;
- case G_LOG_LEVEL_WARNING:
- android_log_level = ANDROID_LOG_WARN;
- break;
- case G_LOG_LEVEL_MESSAGE:
- android_log_level = ANDROID_LOG_INFO;
- break;
- case G_LOG_LEVEL_INFO:
- android_log_level = ANDROID_LOG_INFO;
- break;
- case G_LOG_LEVEL_DEBUG:
- android_log_level = ANDROID_LOG_DEBUG;
- break;
- default:
- android_log_level = ANDROID_LOG_INFO;
- break;
- }
-
- gstring = g_string_new (NULL);
- if (!message) {
- g_string_append (gstring, "(NULL) message");
- } else {
- GString * msg = g_string_new (message);
- escape_string (msg);
- g_string_append (gstring, msg->str);
- g_string_free (msg, TRUE);
- }
- string = g_string_free (gstring, FALSE);
-
- __android_log_print (android_log_level, tag, "%s", string);
-
- g_free (string);
- g_free (tag);
-}
-
-void
-gst_debug_logcat (GstDebugCategory * category, GstDebugLevel level,
- const gchar * file, const gchar * function, gint line,
- GObject * object, GstDebugMessage * message, gpointer unused)
-{
- GstClockTime elapsed;
- gint android_log_level;
- gchar *tag;
-
- if (level > gst_debug_category_get_threshold (category))
- return;
-
- elapsed = GST_CLOCK_DIFF (_priv_gst_info_start_time,
- gst_util_get_timestamp ());
-
- switch (level) {
- case GST_LEVEL_ERROR:
- android_log_level = ANDROID_LOG_ERROR;
- break;
- case GST_LEVEL_WARNING:
- android_log_level = ANDROID_LOG_WARN;
- break;
- case GST_LEVEL_INFO:
- android_log_level = ANDROID_LOG_INFO;
- break;
- case GST_LEVEL_DEBUG:
- android_log_level = ANDROID_LOG_DEBUG;
- break;
- default:
- android_log_level = ANDROID_LOG_VERBOSE;
- break;
- }
-
- tag = g_strdup_printf ("GStreamer+%s",
- gst_debug_category_get_name (category));
-
- if (object) {
- gchar *obj;
-
- if (GST_IS_PAD (object) && GST_OBJECT_NAME (object)) {
- obj = g_strdup_printf ("<%s:%s>", GST_DEBUG_PAD_NAME (object));
- } else if (GST_IS_OBJECT (object) && GST_OBJECT_NAME (object)) {
- obj = g_strdup_printf ("<%s>", GST_OBJECT_NAME (object));
- } else if (G_IS_OBJECT (object)) {
- obj = g_strdup_printf ("<%s@%p>", G_OBJECT_TYPE_NAME (object), object);
- } else {
- obj = g_strdup_printf ("<%p>", object);
- }
-
- __android_log_print (android_log_level, tag,
- "%" GST_TIME_FORMAT " %p %s:%d:%s:%s %s\n",
- GST_TIME_ARGS (elapsed), g_thread_self (),
- file, line, function, obj, gst_debug_message_get (message));
-
- g_free (obj);
- } else {
- __android_log_print (android_log_level, tag,
- "%" GST_TIME_FORMAT " %p %s:%d:%s %s\n",
- GST_TIME_ARGS (elapsed), g_thread_self (),
- file, line, function, gst_debug_message_get (message));
- }
- g_free (tag);
-}
-
-static gboolean
-get_application_dirs (JNIEnv * env, jobject context, gchar ** cache_dir,
- gchar ** files_dir)
-{
- jclass context_class;
- jmethodID get_cache_dir_id, get_files_dir_id;
- jclass file_class;
- jmethodID get_absolute_path_id;
- jobject dir;
- jstring abs_path;
- const gchar *abs_path_str;
-
- *cache_dir = *files_dir = NULL;
-
- context_class = (*env)->GetObjectClass (env, context);
- if (!context_class) {
- return FALSE;
- }
- get_cache_dir_id =
- (*env)->GetMethodID (env, context_class, "getCacheDir",
- "()Ljava/io/File;");
- get_files_dir_id =
- (*env)->GetMethodID (env, context_class, "getFilesDir",
- "()Ljava/io/File;");
- if (!get_cache_dir_id || !get_files_dir_id) {
- return FALSE;
- }
-
- file_class = (*env)->FindClass (env, "java/io/File");
- get_absolute_path_id =
- (*env)->GetMethodID (env, file_class, "getAbsolutePath",
- "()Ljava/lang/String;");
- if (!get_absolute_path_id) {
- return FALSE;
- }
-
- dir = (*env)->CallObjectMethod (env, context, get_cache_dir_id);
- if ((*env)->ExceptionCheck (env)) {
- return FALSE;
- }
-
- if (dir) {
- abs_path = (*env)->CallObjectMethod (env, dir, get_absolute_path_id);
- if ((*env)->ExceptionCheck (env)) {
- return FALSE;
- }
- abs_path_str = (*env)->GetStringUTFChars (env, abs_path, NULL);
- if ((*env)->ExceptionCheck (env)) {
- return FALSE;
- }
- *cache_dir = abs_path ? g_strdup (abs_path_str) : NULL;
-
- (*env)->ReleaseStringUTFChars (env, abs_path, abs_path_str);
- (*env)->DeleteLocalRef (env, abs_path);
- (*env)->DeleteLocalRef (env, dir);
- }
-
- dir = (*env)->CallObjectMethod (env, context, get_files_dir_id);
- if ((*env)->ExceptionCheck (env)) {
- return FALSE;
- }
- if (dir) {
- abs_path = (*env)->CallObjectMethod (env, dir, get_absolute_path_id);
- if ((*env)->ExceptionCheck (env)) {
- return FALSE;
- }
- abs_path_str = (*env)->GetStringUTFChars (env, abs_path, NULL);
- if ((*env)->ExceptionCheck (env)) {
- return FALSE;
- }
- *files_dir = files_dir ? g_strdup (abs_path_str) : NULL;
-
- (*env)->ReleaseStringUTFChars (env, abs_path, abs_path_str);
- (*env)->DeleteLocalRef (env, abs_path);
- (*env)->DeleteLocalRef (env, dir);
- }
-
- (*env)->DeleteLocalRef (env, file_class);
- (*env)->DeleteLocalRef (env, context_class);
-
- return TRUE;
-}
-
-static void
-gst_android_init (JNIEnv * env, jclass klass, jobject context)
-{
- gchar *cache_dir;
- gchar *files_dir;
- gchar *registry;
- GError *error = NULL;
-
- if (_priv_gst_initialized) {
- __android_log_print (ANDROID_LOG_INFO, "GStreamer",
- "GStreamer already initialized");
- return;
- }
-
- if (!get_application_dirs (env, context, &cache_dir, &files_dir))
- return;
-
- if (cache_dir) {
- g_setenv ("TMP", cache_dir, TRUE);
- g_setenv ("TEMP", cache_dir, TRUE);
- g_setenv ("TMPDIR", cache_dir, TRUE);
- g_setenv ("XDG_RUNTIME_DIR", cache_dir, TRUE);
- g_setenv ("XDG_CACHE_HOME", cache_dir, TRUE);
- registry = g_build_filename (cache_dir, "registry.bin", NULL);
- g_setenv ("GST_REGISTRY", registry, TRUE);
- g_free (registry);
- g_setenv ("GST_REUSE_PLUGIN_SCANNER", "no", TRUE);
- /* TODO: Should probably also set GST_PLUGIN_SCANNER and GST_PLUGIN_SYSTEM_PATH */
- }
- if (files_dir) {
- gchar *fontconfig;
-
- g_setenv ("HOME", files_dir, TRUE);
- g_setenv ("XDG_DATA_DIRS", files_dir, TRUE);
- g_setenv ("XDG_CONFIG_DIRS", files_dir, TRUE);
- g_setenv ("XDG_CONFIG_HOME", files_dir, TRUE);
- g_setenv ("XDG_DATA_HOME", files_dir, TRUE);
-
- fontconfig = g_build_filename (files_dir, "fontconfig", NULL);
- g_setenv ("FONTCONFIG_PATH", fontconfig, TRUE);
- g_free (fontconfig);
- }
- g_free (cache_dir);
- g_free (files_dir);
-
- /* Set GLib print handlers */
- g_set_print_handler (glib_print_handler);
- g_set_printerr_handler (glib_printerr_handler);
- g_log_set_default_handler (glib_log_handler, NULL);
-
- /* Disable this for releases if performance is important
- * or increase the threshold to get more information */
- gst_debug_set_active (TRUE);
- gst_debug_set_default_threshold (GST_LEVEL_WARNING);
- gst_debug_remove_log_function (gst_debug_log_default);
- gst_debug_add_log_function ((GstLogFunction) gst_debug_logcat, NULL);
-
- /* get time we started for debugging messages */
- _priv_gst_info_start_time = gst_util_get_timestamp ();
-
- if (!gst_is_initialized ()) {
- if (!gst_init_check (NULL, NULL, &error)) {
- gchar *message = g_strdup_printf ("GStreamer initialization failed: %s",
- error && error->message ? error->message : "(no message)");
- jclass exception_class = (*env)->FindClass (env, "java/lang/Exception");
- __android_log_print (ANDROID_LOG_ERROR, "GStreamer", message);
- (*env)->ThrowNew (env, exception_class, message);
- g_free (message);
- return;
- }
- }
- gst_android_register_static_plugins ();
- gst_android_load_gio_modules ();
- __android_log_print (ANDROID_LOG_INFO, "GStreamer",
- "GStreamer initialization complete");
- _priv_gst_initialized = TRUE;
-}
-
-static JNINativeMethod native_methods[] = {
- {"nativeInit", "(Landroid/content/Context;)V", (void *) gst_android_init}
-};
-
-jint
-JNI_OnLoad (JavaVM * vm, void *reserved)
-{
- JNIEnv *env = NULL;
-
- if ((*vm)->GetEnv (vm, (void **) &env, JNI_VERSION_1_4) != JNI_OK) {
- __android_log_print (ANDROID_LOG_ERROR, "GStreamer",
- "Could not retrieve JNIEnv");
- return 0;
- }
- jclass klass = (*env)->FindClass (env, "org/freedesktop/gstreamer/GStreamer");
- if (!klass) {
- __android_log_print (ANDROID_LOG_ERROR, "GStreamer",
- "Could not retrieve class org.freedesktop.gstreamer.GStreamer");
- return 0;
- }
- if ((*env)->RegisterNatives (env, klass, native_methods,
- G_N_ELEMENTS (native_methods))) {
- __android_log_print (ANDROID_LOG_ERROR, "GStreamer",
- "Could not register native methods for org.freedesktop.gstreamer.GStreamer");
- return 0;
- }
-
- return JNI_VERSION_1_4;
-}