Tuesday, July 14, 2015

Building GStreamer-1.0-SDK for Android MIPS

GStreamer is a nice SDK with which you can create multimedia applications for a multitude of systems. My concern is primarily Android with RTSP and video playback.
The SDK is already available for Android for a couple of architectures (arm, armv7a and x86). No MIPS support though.
In this post I'll describe the steps needed to get a GStreamer-1.0 SDK for Android MIPS.

 To build the SDK for MIPS, one has to build from source using Cerbero. These are the steps to get a build environment going. We will modify them a bit to add support for MIPS.

 First we are going to install the prerequisites: python 2.7, git and android ndk r8e
 After that we need to get the Cerbero repository. The instructions in this post work for revision 4df49a735b00134516bafa44301bf424108166f5
To clone this specific revision:
git clone -o 4df49a735b00134516bafa44301bf424108166f5 git://anongit.freedesktop.org/gstreamer-sdk/cerbero
Or you can try your luck with the HEAD revision:
git clone git://anongit.freedesktop.org/gstreamer-sdk/cerbero
I'm saying try your luck because we will apply a patch, and newer revisions might cause errors when applying the patch.
Next step is to apply the patch at this address. Download it to a file called gstreamer-android-mips.patch, and apply it:
git apply gstreamer-android-mips.patch
You should get some warnings about trailing spaces, but it's nothing serious.
Next is to add a cerbero alias to the bash profile:
echo "alias cerbero='~/git/cerbero/cerbero-uninstalled'" >> ~/.bashrc
Of course, update the path to your checkout. Then bootstrap (install the packages needed to build cerbero):
cerbero bootstrap
This action will create a ~/cerbero folder. Copy in that folder the android r8e ndk. You should have the following directory structure:  ~/cerbero/android-ndk-r8e/.
After this we can start the gstreamer-1.0-sdk build and packaging:
cerbero -c config/cross-android-mips.cbc package gstreamer-1.0-sdk
This will take some time, so go have a break.

After the packaging finishes you will get archives with the SDK in the build directory.
A few steps still need to be done manually after the package is built, mainly because I didn't have time to modify the scripts to do this automatically:

  • the harfbuzz package is missing from the SDK package - you can copy manually libharfbuzz.* and the harfbuzz headers from ~/cerbero/dist/android-mips/ to the SDK package
  • next, in the SDK package share/gst-android/ndk-build modify the gstreamer-1.0.mk and change the following line:
GSTREAMER_LD                  := -fuse-ld=gold
to
GSTREAMER_LD                  := -fuse-ld=bfd
The reason is that the gold linker is not available in the MIPS toolchain.

That is all. At this point you can build Android applications using the GStreamer 1.0 SDK.
Also, remember to use the r8e ndk, otherwise you will get some linker errors.

1 comment:

  1. for ppl reference, download android--ndk-r8e here http://dl.google.com/android/ndk/android-ndk-r8e-linux-x86.tar.bz2

    ReplyDelete