mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-19 23:06:49 +00:00
Cleanup the android page
This commit is contained in:
parent
a4c04e5c43
commit
1b6e026cf6
1 changed files with 96 additions and 98 deletions
|
@ -1,6 +1,6 @@
|
|||
# Installing for Android development
|
||||
# Installing for Android development
|
||||
|
||||
![](images/icons/emoticons/information.png) All versions starting from 2.3.1 Gingerbread are supported
|
||||
![information] All versions starting from 2.3.1 Gingerbread are supported
|
||||
|
||||
## Prerequisites
|
||||
|
||||
|
@ -11,33 +11,27 @@ should obviously be an Android device.
|
|||
The development machine can either be a Linux, Mac OS X or Windows, and
|
||||
needs to have installed:
|
||||
|
||||
- The latest version of the [Android
|
||||
SDK](http://developer.android.com/sdk/index.html)
|
||||
- The latest version of the [Android
|
||||
NDK](http://developer.android.com/tools/sdk/ndk/index.html)
|
||||
- The GStreamer SDK for Android is targeted at API version 9 (Android
|
||||
- The latest version of the [Android SDK]
|
||||
- The latest version of the [Android NDK]
|
||||
- The GStreamer SDK for Android is targeted at API version 9 (Android
|
||||
2.3.1, Gingerbread) or higher. Use the SDK Manager tool to make sure
|
||||
you have at least one Android SDK platform installed with API
|
||||
version 9 or higher.
|
||||
|
||||
Optionally, you can use the [Android Studio] (FIX LINK). As stated in the Android
|
||||
documentation, *developing in Android Studio is highly recommended and
|
||||
is the fastest way to get started*.
|
||||
Optionally, you can use the \[Android Studio\] (FIX LINK). As stated in
|
||||
the Android documentation, *developing in Android Studio is highly
|
||||
recommended and is the fastest way to get started*.
|
||||
|
||||
Before continuing, make sure you can compile and run the samples
|
||||
included in the Android NDK, and that you understand how the integration
|
||||
of C and Java works via the [Java Native
|
||||
Interface](http://en.wikipedia.org/wiki/Java_Native_Interface) (JNI).
|
||||
Besides the [Android
|
||||
NDK](http://developer.android.com/tools/sdk/ndk/index.html)
|
||||
documentation, you can find some useful [Android JNI tips
|
||||
here](http://developer.android.com/guide/practices/jni.html).
|
||||
of C and Java works via the [Java Native Interface] (JNI). Besides the
|
||||
[Android NDK] documentation, you can find some useful [Android JNI tips
|
||||
here].
|
||||
|
||||
## Download and install the SDK
|
||||
|
||||
The GStreamer project provides [prebuilt binaries](https://gstreamer.freedesktop.org/data/pkg/android/)
|
||||
you should download the latest version and unzip it into any folder of your
|
||||
choice.
|
||||
The GStreamer project provides [prebuilt binaries] you should download
|
||||
the latest version and unzip it into any folder of your choice.
|
||||
|
||||
In the process of building GStreamer-enabled Android applications, some
|
||||
tools will need to know where you installed the SDK. You must define an
|
||||
|
@ -48,12 +42,13 @@ system-wide by adding it to your `~/.profile` file (on Linux and Mac) or
|
|||
to the Environment Variables in the System Properties dialog (on
|
||||
Windows).
|
||||
|
||||
Point `GSTREAMER_SDK_ROOT_ANDROID` to the folder where you unzipped the SDK.
|
||||
Point `GSTREAMER_SDK_ROOT_ANDROID` to the folder where you unzipped the
|
||||
SDK.
|
||||
|
||||
> ![](images/icons/emoticons/information.png) If you plan to use Android Studio and
|
||||
> do not want to define this environment variable globally, you can set
|
||||
> it inside Eclipse. Go to Window → Preferences → C/C++ → Build → Build Variables
|
||||
> and define `GSTREAMER_SDK_ROOT_ANDROID` there.
|
||||
> ![information] If you plan to use Android Studio and do not want to define this
|
||||
> environment variable globally, you can set it inside Eclipse. Go to
|
||||
> Window → Preferences → C/C++ → Build → Build Variables and define
|
||||
> `GSTREAMER_SDK_ROOT_ANDROID` there.
|
||||
|
||||
## Configure your development environment
|
||||
|
||||
|
@ -62,12 +57,10 @@ writing your GStreamer code in Java or in C.
|
|||
|
||||
Android applications are mainly written in Java, so adding GStreamer
|
||||
code to them in the same language is a huge advantage. However, this
|
||||
requires using [language
|
||||
bindings](http://en.wikipedia.org/wiki/Language_binding) for the
|
||||
GStreamer API which are not complete yet. In the meantime, this
|
||||
documentation will use Java for the User Interface (UI) part and C for
|
||||
the GStreamer code. Both parts interact through
|
||||
[JNI](http://en.wikipedia.org/wiki/Java_Native_Interface).
|
||||
requires using [language bindings] for the GStreamer API which are not
|
||||
complete yet. In the meantime, this documentation will use Java for the
|
||||
User Interface (UI) part and C for the GStreamer code. Both parts
|
||||
interact through [JNI][Java Native Interface].
|
||||
|
||||
### Building the tutorials
|
||||
|
||||
|
@ -80,9 +73,8 @@ The rest of the GStreamer SDK tutorials (basic and playback tutorials)
|
|||
cannot be run on Android without modification.
|
||||
|
||||
Android projects with GStreamer support are built like conventional
|
||||
Android NDK projects, so the instructions at the [Android
|
||||
NDK](http://developer.android.com/tools/sdk/ndk/index.html) home can be
|
||||
followed:
|
||||
Android NDK projects, so the instructions at the [Android NDK] home can
|
||||
be followed:
|
||||
|
||||
#### Using Eclipse
|
||||
|
||||
|
@ -91,8 +83,8 @@ prerequisites section, and that they are both aware of the location of
|
|||
the Android SDK and NDK respectively.
|
||||
|
||||
Import a tutorial into the Eclipse workspace:
|
||||
File → New → Project… → Android Project from Existing
|
||||
Code, and select the folder called `android-tutorial-1`.
|
||||
File → New → Project… → Android Project from Existing Code, and select
|
||||
the folder called `android-tutorial-1`.
|
||||
|
||||
After reading in the project and generating some extra files and
|
||||
folders, Eclipse might complain about missing files. **This is normal**,
|
||||
|
@ -100,7 +92,8 @@ we are not finished yet.
|
|||
|
||||
Provide native development support by activating the NDK plugin:
|
||||
Right-click on the project in the Project Explorer (this should be the
|
||||
top-most folder, called `com.gst_sdk_tutorials.tutorial_1.Tutorial1`) → Android
|
||||
top-most folder,
|
||||
called `com.gst_sdk_tutorials.tutorial_1.Tutorial1`) → Android
|
||||
tools → Add Native Support… Here the NDK plugin asks for a library name.
|
||||
This is irrelevant and any valid file name will do. Accept.
|
||||
|
||||
|
@ -121,15 +114,12 @@ OpenGL ES).
|
|||
|
||||
#### Using the command line
|
||||
|
||||
> ![](images/icons/emoticons/warning.png) Note that, on Windows,
|
||||
> this procedure requires a working Cygwin shell, as explained in
|
||||
> the [Android NDK System Requirements](http://developer.android.com/tools/sdk/ndk/index.html#Reqs)
|
||||
> ![warning] Note that, on Windows, this procedure requires a working Cygwin
|
||||
> shell, as explained in the [Android NDK System Requirements]
|
||||
|
||||
For each tutorial, move to its folder and run:
|
||||
|
||||
```
|
||||
android update project -p . -s --target X
|
||||
```
|
||||
android update project -p . -s --target X
|
||||
|
||||
Where `X` is one of the targets available in your system (the ones you
|
||||
installed with the SDK manager). Make sure to use a target with at least
|
||||
|
@ -138,18 +128,14 @@ API level 9.
|
|||
To get a list of all available targets in your system issue this
|
||||
command:
|
||||
|
||||
```
|
||||
android list
|
||||
```
|
||||
android list
|
||||
|
||||
The “update project” command generates the `build.xml` file needed by
|
||||
the build system. You only need to perform this action once per project.
|
||||
|
||||
To build the C part, just call:
|
||||
|
||||
```
|
||||
ndk-build
|
||||
```
|
||||
ndk-build
|
||||
|
||||
A few lines in the `Android.mk` file (reviewed later) pull up the
|
||||
necessary machinery to compile the GStreamer bits and generate the
|
||||
|
@ -158,15 +144,11 @@ methods.
|
|||
|
||||
Finally, compile the Java code with:
|
||||
|
||||
```
|
||||
ant debug
|
||||
```
|
||||
ant debug
|
||||
|
||||
And install on the device with:
|
||||
|
||||
```
|
||||
adb install -r bin/Tutorial1-debug.apk
|
||||
```
|
||||
adb install -r bin/Tutorial1-debug.apk
|
||||
|
||||
The `-r` switch allows the installer to overwrite previous versions.
|
||||
Otherwise, you need to manually uninstall previous versions of your
|
||||
|
@ -178,20 +160,28 @@ tutorial in an Android Virtual Device (AVD), make sure to create the
|
|||
device with support for audio playback and GPU Emulation (to enable
|
||||
OpenGL ES).
|
||||
|
||||
> ![](images/icons/emoticons/warning.png) Windows linkage problems
|
||||
> ![warning] Windows linkage problems
|
||||
>
|
||||
> Due to problems related to the standard linker, Google’s <a href="http://en.wikipedia.org/wiki/Gold_(linker)" class="external-link">Gold Linker</a> is used to build GStreamer applications. Unfortunately, the Android NDK toolchain for Windows does not include the gold linker and the standard one has to be used.
|
||||
> Due to problems related to the standard linker, Google’s
|
||||
> <a href="http://en.wikipedia.org/wiki/Gold_(linker)" class="external-link">Gold
|
||||
> Linker</a> is used to build GStreamer applications. Unfortunately,
|
||||
> the Android NDK toolchain for Windows does not include the gold linker
|
||||
> and the standard one has to be used.
|
||||
>
|
||||
> If you observe linkage problems, you can replace the linker in your Android NDK with the gold one from [this project](http://code.google.com/p/mingw-and-ndk/downloads/detail?name=android-ndk-r8b-ma-windows.7z&can=2&q=). Download the `android-ndk-r8b-ma-windows.7z` file, extract `\android-ndk-r8b\toolchains\arm-linux-androideabi-4.6\prebuilt\windows\arm-linux-androideabi\bin\ld.exe` (only this file is needed) and overwrite the one in the same folder in your Android NDK installation. You might need the free [7-Zip archiving utility](http://www.7-zip.org/)
|
||||
> If you observe linkage problems, you can replace the linker in your
|
||||
> Android NDK with the gold one from [this project]. Download the
|
||||
> `android-ndk-r8b-ma-windows.7z` file, extract
|
||||
> `\android-ndk-r8b\toolchains\arm-linux-androideabi-4.6\prebuilt\windows\arm-linux-androideabi\bin\ld.exe`
|
||||
> (only this file is needed) and overwrite the one in the same folder in
|
||||
> your Android NDK installation. You might need the free [7-Zip
|
||||
> archiving utility]
|
||||
|
||||
### Creating new projects
|
||||
|
||||
Create a normal NDK project, either from the command line as described
|
||||
in the [Android
|
||||
NDK](http://developer.android.com/tools/sdk/ndk/index.html#GetStarted)
|
||||
home, or use Eclipse: File → New → Project… → Android Application
|
||||
Project, and, once the wizard is complete, right click on the project
|
||||
→ Android Tools → Add Native Support …
|
||||
in the [Android NDK][2] home, or use Eclipse: File → New → Project…
|
||||
→ Android Application Project, and, once the wizard is complete, right
|
||||
click on the project → Android Tools → Add Native Support …
|
||||
|
||||
To add GStreamer support you only need to modify the
|
||||
`jni/Android.mk` file. This file describes the native files in your
|
||||
|
@ -199,16 +189,14 @@ project, and its barebones structure (as auto-generated by Eclipse) is:
|
|||
|
||||
**Android.mk**
|
||||
|
||||
```
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := NativeApplication
|
||||
LOCAL_SRC_FILES := NativeApplication.c
|
||||
LOCAL_MODULE := NativeApplication
|
||||
LOCAL_SRC_FILES := NativeApplication.c
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
```
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
||||
Where line 5 specifies the name of the `.so` file that will contain your
|
||||
native code and line 6 states all source files that compose your native
|
||||
|
@ -218,26 +206,24 @@ Adding GStreamer support only requires adding these lines:
|
|||
|
||||
**Android.mk with GStreamer support**
|
||||
|
||||
```
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := NativeApplication
|
||||
LOCAL_SRC_FILES := NativeApplication.c
|
||||
LOCAL_SHARED_LIBRARIES := gstreamer_android
|
||||
LOCAL_LDLIBS := -landroid
|
||||
LOCAL_MODULE := NativeApplication
|
||||
LOCAL_SRC_FILES := NativeApplication.c
|
||||
LOCAL_SHARED_LIBRARIES := gstreamer_android
|
||||
LOCAL_LDLIBS := -landroid
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
||||
GSTREAMER_SDK_ROOT := $(GSTREAMER_SDK_ROOT_ANDROID)
|
||||
GSTREAMER_NDK_BUILD_PATH := $(GSTREAMER_SDK_ROOT)/share/gst-android/ndk-build/
|
||||
GSTREAMER_PLUGINS := coreelements ogg theora vorbis ffmpegcolorspace playback eglglessink soup opensles
|
||||
G_IO_MODULES := gnutls
|
||||
GSTREAMER_EXTRA_DEPS := gstreamer-interfaces-0.10 gstreamer-video-0.10
|
||||
GSTREAMER_SDK_ROOT := $(GSTREAMER_SDK_ROOT_ANDROID)
|
||||
GSTREAMER_NDK_BUILD_PATH := $(GSTREAMER_SDK_ROOT)/share/gst-android/ndk-build/
|
||||
GSTREAMER_PLUGINS := coreelements ogg theora vorbis ffmpegcolorspace playback eglglessink soup opensles
|
||||
G_IO_MODULES := gnutls
|
||||
GSTREAMER_EXTRA_DEPS := gstreamer-interfaces-0.10 gstreamer-video-0.10
|
||||
|
||||
include $(GSTREAMER_NDK_BUILD_PATH)/gstreamer.mk
|
||||
```
|
||||
include $(GSTREAMER_NDK_BUILD_PATH)/gstreamer.mk
|
||||
|
||||
Where line 7 specifies an extra library to be included in the project:
|
||||
`libgstreamer_android.so`. This library contains all GStreamer code,
|
||||
|
@ -264,22 +250,34 @@ Listing all desired plugins can be cumbersome, so they have been grouped
|
|||
into categories, which can be used by including the `plugins.mk` file,
|
||||
and used as follows:
|
||||
|
||||
```
|
||||
include $(GSTREAMER_NDK_BUILD_PATH)/plugins.mk
|
||||
GSTREAMER_PLUGINS := $(GSTREAMER_PLUGINS_CORE) $(GSTREAMER_PLUGINS_CODECS) playbin souphttpsrc
|
||||
```
|
||||
include $(GSTREAMER_NDK_BUILD_PATH)/plugins.mk
|
||||
GSTREAMER_PLUGINS := $(GSTREAMER_PLUGINS_CORE) $(GSTREAMER_PLUGINS_CODECS) playbin souphttpsrc
|
||||
|
||||
|
||||
#### List of categories and included plugins
|
||||
|
||||
| Category | Included plugins |
|
||||
|--|--|
|
||||
| `GSTREAMER_PLUGINS_CORE` | coreelements coreindexers adder app audioconvert audiorate audioresample audiotestsrc ffmpegcolorspace gdp gio pango typefindfunctions videorate videoscale videotestsrc volume autodetect videofilter |
|
||||
| `GSTREAMER_PLUGINS_PLAYBACK` | decodebin playbin |
|
||||
| `GSTREAMER_PLUGINS_CODECS` | subparse ogg theora vorbis alaw annodex apetag audioparsers auparse avi flac flv flxdec icydemux id3demux isomp4 jpeg matroska mulaw multipart png speex taglib wavenc wavpack wavparse y4menc adpcmdec adpcmenc aiff cdxaparse dtmf dvbsuboverlay dvdspu fragmented hdvparse id3tag ivfparse jp2k kate mve mxf nsf nuvdemux opus pcapparse pnm schro siren subenc tta videoparsersbad vmnc vp8 y4mdec |
|
||||
| `GSTREAMER_PLUGINS_VIS` | libvisual goom goom2k1 audiovisualizers |
|
||||
| `GSTREAMER_PLUGINS_EFFECTS` | alpha alphacolor audiofx cutter debug deinterlace effectv equalizer gdkpixbuf imagefreeze interleave level multifile replaygain shapewipe smpte spectrum videobox videocrop videomixer autoconvert bayer coloreffects faceoverlay fieldanalysis freeverb frei0r gaudieffects geometrictransform interlace jp2kdecimator liveadder rawparse removesilence scaletempoplugin segmentclip smooth speed stereo videofiltersbad videomeasure videosignal |
|
||||
| `GSTREAMER_PLUGINS_NET` | rtsp rtp rtpmanager souphttpsrc udp dataurisrc rtpmux rtpvp8 sdpelem |
|
||||
| `GSTREAMER_PLUGINS_CODECS_GPL` | assrender |
|
||||
| `GSTREAMER_PLUGINS_SYS` | eglglessink opensles amc |
|
||||
| Category | Included plugins |
|
||||
|--------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `GSTREAMER_PLUGINS_CORE` | coreelements coreindexers adder app audioconvert audiorate audioresample audiotestsrc ffmpegcolorspace gdp gio pango typefindfunctions videorate videoscale videotestsrc volume autodetect videofilter |
|
||||
| `GSTREAMER_PLUGINS_PLAYBACK` | decodebin playbin |
|
||||
| `GSTREAMER_PLUGINS_CODECS` | subparse ogg theora vorbis alaw annodex apetag audioparsers auparse avi flac flv flxdec icydemux id3demux isomp4 jpeg matroska mulaw multipart png speex taglib wavenc wavpack wavparse y4menc adpcmdec adpcmenc aiff cdxaparse dtmf dvbsuboverlay dvdspu fragmented hdvparse id3tag ivfparse jp2k kate mve mxf nsf nuvdemux opus pcapparse pnm schro siren subenc tta videoparsersbad vmnc vp8 y4mdec |
|
||||
| `GSTREAMER_PLUGINS_VIS` | libvisual goom goom2k1 audiovisualizers |
|
||||
| `GSTREAMER_PLUGINS_EFFECTS` | alpha alphacolor audiofx cutter debug deinterlace effectv equalizer gdkpixbuf imagefreeze interleave level multifile replaygain shapewipe smpte spectrum videobox videocrop videomixer autoconvert bayer coloreffects faceoverlay fieldanalysis freeverb frei0r gaudieffects geometrictransform interlace jp2kdecimator liveadder rawparse removesilence scaletempoplugin segmentclip smooth speed stereo videofiltersbad videomeasure videosignal |
|
||||
| `GSTREAMER_PLUGINS_NET` | rtsp rtp rtpmanager souphttpsrc udp dataurisrc rtpmux rtpvp8 sdpelem |
|
||||
| `GSTREAMER_PLUGINS_CODECS_GPL` | assrender |
|
||||
| `GSTREAMER_PLUGINS_SYS` | glimagesink opensles amc |
|
||||
|
||||
Build and run your application as explained in the **Building the tutorials** section.
|
||||
|
||||
[information]: images/icons/emoticons/information.png
|
||||
[Android SDK]: http://developer.android.com/sdk/index.html
|
||||
[Android NDK]: http://developer.android.com/tools/sdk/ndk/index.html
|
||||
[Java Native Interface]: http://en.wikipedia.org/wiki/Java_Native_Interface
|
||||
[Android JNI tips here]: http://developer.android.com/guide/practices/jni.html
|
||||
[prebuilt binaries]: https://gstreamer.freedesktop.org/data/pkg/android/
|
||||
[language bindings]: http://en.wikipedia.org/wiki/Language_binding
|
||||
[warning]: images/icons/emoticons/warning.png
|
||||
[Android NDK System Requirements]: http://developer.android.com/tools/sdk/ndk/index.html#Reqs
|
||||
[this project]: http://code.google.com/p/mingw-and-ndk/downloads/detail?name=android-ndk-r8b-ma-windows.7z&can=2&q=
|
||||
[7-Zip archiving utility]: http://www.7-zip.org/
|
||||
[2]: http://developer.android.com/tools/sdk/ndk/index.html#GetStarted
|
||||
|
|
Loading…
Reference in a new issue