我按照本教程构建了一个gstreamer项目 - http://docs.gstreamer.com/display/GstSDK/Android+tutorial+1%3A+Link+against+GStreamer
我在jni文件夹中创建了两个名为main.cpp和Android.mk的文件。 jni文件夹在Android项目中。尽管如此,我认为它的位置无论如何都不重要。这些是这两个文件的内容 - Android.mk -
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := test
LOCAL_SRC_FILES := main.c
LOCAL_SHARED_LIBRARIES := gstreamer_android
LOCAL_LDLIBS := -llog
include $(BUILD_SHARED_LIBRARY)
ifndef GSTREAMER_SDK_ROOT
ifndef GSTREAMER_SDK_ROOT_ANDROID
$(error GSTREAMER_SDK_ROOT_ANDROID is not defined!)
endif
GSTREAMER_SDK_ROOT := $(GSTREAMER_SDK_ROOT_ANDROID)
endif
GSTREAMER_NDK_BUILD_PATH := $(GSTREAMER_SDK_ROOT)/share/gst-android/ndk-build/
GSTREAMER_PLUGINS := coreelements
include $(GSTREAMER_NDK_BUILD_PATH)/gstreamer.mk
main.cpp -
#include <string.h>
#include <jni.h>
#include <android/log.h>
#include <gst/gst.h>
jstring gst_native_get_gstreamer_info (JNIEnv* env, jobject thiz) {
char *version_utf8 = gst_version_string();
jstring *version_jstring = (*env)->NewStringUTF(env, version_utf8);
g_free (version_utf8);
return version_jstring;
}
static JNINativeMethod native_methods[] = {
{ "nativeGetGStreamerInfo", "()Ljava/lang/String;", (void *) gst_native_get_gstreamer_info}
};
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, "tutorial-1", "Could not retrieve JNIEnv");
return 0;
}
jclass klass = (*env)->FindClass (env, "com/gst_sdk_tutorials/tutorial_1/Tutorial1");
(*env)->RegisterNatives (env, klass, native_methods, G_N_ELEMENTS(native_methods));
return JNI_VERSION_1_4;
}
当我从此目录执行ndk-build
时,出现以下错误 -
make: -n: Command not found
/bin/sh: 0: Illegal option -
/bin/sh: 0: Illegal option -
/bin/sh: 0: Illegal option -
/bin/sh: 0: Illegal option -
/bin/sh: 0: Illegal option -
/bin/sh: 0: Illegal option -
/bin/sh: 0: Illegal option -
/bin/sh: 0: Illegal option -
/bin/sh: 0: Illegal option -
GStreamer : [GEN] => gst-build/gstreamer_android.c
/bin/sh: 1: i: not found
make: [genstatic] Error 127 (ignored)
/bin/sh: 1: i: not found
make: [genstatic] Error 127 (ignored)
/bin/sh: 1: i: not found
make: [genstatic] Error 127 (ignored)
/bin/sh: 1: i: not found
make: [genstatic] Error 127 (ignored)
GStreamer : [COMPILE] => gst-build/gstreamer_android.c
gst-build/gstreamer_android.c:9:2: error: stray '@' in program
@PLUGINS_DECLARATION@
^
gst-build/gstreamer_android.c:9:22: error: stray '@' in program
@PLUGINS_DECLARATION@
^
gst-build/gstreamer_android.c:12:2: error: stray '@' in program
@G_IO_MODULES_DECLARE@
^
gst-build/gstreamer_android.c:9:3: error: unknown type name 'PLUGINS_DECLARATION'
@PLUGINS_DECLARATION@
^
gst-build/gstreamer_android.c:12:23: error: stray '@' in program
@G_IO_MODULES_DECLARE@
^
gst-build/gstreamer_android.c:15:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
它就是......
答案 0 :(得分:2)
最新版本的GStreamer for Android与ndk-r10e兼容(至少它们解决了HOST_SED
问题)。请参阅此错误以供参考:https://bugzilla.gnome.org/show_bug.cgi?id=750162
在这里,您可以找到最新的预制GStreamer for Android软件包:http://gstreamer.freedesktop.org/data/pkg/android/1.5.91/
您从教程中链接的版本真的很旧。
编辑:我现在可以确认这是有效的:)
答案 1 :(得分:1)
我通过编辑文件gstreamer-sdk-android-arm-debug-2013.6/share/gst-android/ndk-build/gstreamer.mk
解决了错误。
在文件中,在linux的情况下没有定义变量HOST_SED
。我不得不将它设置为linux命令行工具sed
并且它有效。
这么大的项目在脚本中有如此愚蠢的错误真的很糟糕。
另外,我不得不将NDK降级为ndk-r9。