ubuntu build gstreamer for android

ubuntu 14.04

android-ndk-r10e

gstreamer-1.0-android-armv7-1.6.0

android studio 1.3

---------------------------------------

这是官方的一个例子,这里去掉一些没用的文件,只保留了Android相关的东西

1.下载官方的工程 gst-player-master

2.下载官方编译好的gstreamer lib,这里用的是gstreamer-1.0-android-armv7-1.6.0,放到gst-player-master目录下

3.配置编译环境,可以按照官方的README.md来,

GST Player Android port
=======================

Prerequisites
-------------

1. Install Android SDK from https://developer.android.com/sdk/ & set `sdk.dir` in **local.properties** to the installation path
2. Install Android NDK from https://developer.android.com/tools/sdk/ndk/index.html & set `ndk.dir` in **local.properties** to the installation path
3. If you have a different special directory for pkg-config or other tools (e.g. on OSX when using Homebrew), then also set this path using the `ndk.extraPath` variable in **local.properties**
4. Download the GStreamer android ports http://gstreamer.freedesktop.org/data/pkg/android/ and set `gstreamer.$ABI.dir` properties in **local.properties**:

Sample local.properties:

    sdk.dir=/path/to/android-sdk/
    ndk.dir=/path/to/android-ndk/
    ndk.extraPath=/usr/local/bin
    gstreamer.arm.dir=/path/to/gstreamer-1.0-android-arm-release-1.4.5/
    gstreamer.armv7.dir=/path/to/gstreamer-1.0-android-armv7-release-1.4.5/
    gstreamer.x86.dir=/path/to/gstreamer-1.0-android-x86-release-1.4.5/


Compiling the sample
--------------------

Use

    ./gradlew installDebug

to compile and install a debug version onto all connected devices.

Please note this component is using the new Android build system based on Gradle. More information about this is available on http://tools.android.com/tech-docs/new-build-system.

Android Studio
--------------

Android Studio builds will work out of the box. Simply open `build.gradle` in this folder to import the project.

Manual NDK build
----------------

It is still possible to build just the NDK portion. This will speed up the process a bit as you don't need to start gradle first and compile the complete App.
First, make sure to set `NDK_PROJECT_PATH` to this projects main source path. Additionally the SDK & NDK tools are available in `$PATH`.

    export NDK_PROJECT_PATH=$PWD/app/src/main

Second, set the following environment variables to the GStreamer installation folders:

    export GSTREAMER_ROOT_ARM=/path/to/gstreamer-1.0-android-arm-release-1.4.5/
    export GSTREAMER_ROOT_ARMV7=/path/to/tmp/gstreamer-1.0-android-armv7-release-1.4.5/
    export GSTREAMER_ROOT_X86=/path/to/gstreamer-1.0-android-x86-release-1.4.5/

If you don't want to build all architectures, please modify the file `app/src/main/jni/Application.mk`

Finally, within the `app/src/main/` directory, invoke:

    ndk-build


编译的时候可以使用下面命令,可以看到编译信息
./gradlew installDebug --info


最后成功信息

Installed on 1 device.
:app:installDebug (Thread[main,5,main]) completed. Took 24.416 secs.

BUILD SUCCESSFUL

Total time: 1 mins 0.97 secs


4.界面如下,支持mkv、mp4等格式,





本工程在这里下载

-----------------------------------------------------

可能遇到的问题:

1.这是android studio 1.3的问题,看这里

Error: NDK integration is deprecated in the current plugin. Consider trying the new experimental plugin. For details, see http://tools.android.com/tech-docs/new-build-system/gradle-experimental. Set "android.useDeprecatedNdk=true" in gradle.properties to continue using the current NDK integration.
即在  gradle.properties 中加  'android.useDeprecatedNdk=true' 

2.这种应该是配置文件不对,对照README.md步骤,把没用的配置去掉,还有app下面的build.gradle也要配对

"compileTask -> compileTask.dependsOn ndkBuild" like this:
Error:Execution failed for task ':app:ndkBuild'.

java.lang.NullPointerException (no error message)
Any ideas?
3.下面这种神奇的错误,主要出现的低级版本的gstreamer lib中,因为官方没有考虑到有人会在ubuntu下编译
/bin/sh: 0: Illegal option - 
/bin/sh: 0: Illegal option - 
GStreamer      : [GEN] => gst-build-armeabi-v7a/gstreamer_android.c
/bin/sh: 1: i: not found
make: [genstatic_armeabi-v7a] Error 127 (ignored)
/bin/sh: 1: i: not found
make: [genstatic_armeabi-v7a] Error 127 (ignored)
/bin/sh: 1: i: not found
make: [genstatic_armeabi-v7a] Error 127 (ignored)
/bin/sh: 1: i: not found
make: [genstatic_armeabi-v7a] Error 127 (ignored)
GStreamer      : [COMPILE] => gst-build-armeabi-v7a/gstreamer_android.c
gst-build-armeabi-v7a/gstreamer_android.c:15:2: error: stray '@' in program
  @PLUGINS_DECLARATION@
  ^
gst-build-armeabi-v7a/gstreamer_android.c:15:22: error: stray '@' in program
  @PLUGINS_DECLARATION@
                      ^
gst-build-armeabi-v7a/gstreamer_android.c:18:2: error: stray '@' in program
  @G_IO_MODULES_DECLARE@
  ^
gst-build-armeabi-v7a/gstreamer_android.c:15:3: error: unknown type name 'PLUGINS_DECLARATION'
  @PLUGINS_DECLARATION@
   ^
gst-build-armeabi-v7a/gstreamer_android.c:18:23: error: stray '@' in program
  @G_IO_MODULES_DECLARE@
                       ^
gst-build-armeabi-v7a/gstreamer_android.c:21:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
 void
 ^
gst-build-armeabi-v7a/gstreamer_android.c:24:2: error: stray '@' in program
  @PLUGINS_REGISTRATION@
  ^
gst-build-armeabi-v7a/gstreamer_android.c:24:23: error: stray '@' in program
  @PLUGINS_REGISTRATION@
                       ^
gst-build-armeabi-v7a/gstreamer_android.c: In function 'gst_android_load_gio_modules':
gst-build-armeabi-v7a/gstreamer_android.c:31:2: error: stray '@' in program
  @G_IO_MODULES_LOAD@
  ^
gst-build-armeabi-v7a/gstreamer_android.c:31:20: error: stray '@' in program
  @G_IO_MODULES_LOAD@
                    ^
gst-build-armeabi-v7a/gstreamer_android.c:31:3: error: 'G_IO_MODULES_LOAD' undeclared (first use in this function)
  @G_IO_MODULES_LOAD@
   ^
gst-build-armeabi-v7a/gstreamer_android.c:31:3: note: each undeclared identifier is reported only once for each function it appears in
gst-build-armeabi-v7a/gstreamer_android.c:32:1: error: expected ';' before '}' token
 }
 ^
gst-build-armeabi-v7a/gstreamer_android.c: In function 'gst_android_init':
gst-build-armeabi-v7a/gstreamer_android.c:437:3: error: implicit declaration of function 'gst_android_register_static_plugins' [-Werror=implicit-function-declaration]
   gst_android_register_static_plugins ();
   ^
cc1: all warnings being treated as errors
make: *** [gst-build-armeabi-v7a/gstreamer_android.o] Error 1

在xx/gst-player-master/gstreamer-1.0-android-armv7-x.x.x/share/gst-android/ndk-build找到gstreamer-1.0.mk,并添加下面语句

# Host tools
HOST_SED := $(strip $(NDK_HOST_SED))
ifdef HOST_PREBUILT
    ifndef HOST_SED
        HOST_SED := $(strip $(wildcard $(HOST_PREBUILT)/sed$(HOST_EXEEXT)))
    endif
endif
ifndef HOST_SED
    HOST_CMP := sed
endif








评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值