iOS: GStreamer framework custom build


It might be the case that, the next official release of GStreamer package will be available after a month or two, but you need the package based on the latest code repository.

If we are on the same page, let’s start to build the GStreamer framework for iOS (as well as for Mac OSX).

The procedure is same for other OS. That means, If you would like to build for Windows, you can use a Windows machine.

Of course, iOS and Mac OSX framework can not be built from Windows, in case you were wondering.

Requirements

  • Latest XCode with iOS 8 SDK
  • XCode Command line tools
  • CMake (Install CMake with Homebrew, this will install and create symlink)

Build-tool

GStreamer uses Cerbero as build – tool. You can get the latest code from here,

http://cgit.freedesktop.org/gstreamer/cerbero/

Download the git repository using your favorite git client or from command-line.

Architecture

There are several architectures involved, namely,

  • ios_arm64
  • ios_armv7
  • ios_armv7s
  • ios_x86
  • ios_x86_64

You might want the build for any particular architecture according to your need. Or, you can go for universal build.

Please note that, in either case you will get the corresponding Mac OSX package.

Parallel Build

It is very common that you have a multi-core processor system. If you would like to make the build process faster then you have an option to involve all cores to the build process.

I had asked the question in their forum and got the response from Andoni.

By default cerbero is using only one core to compile, using “make”. To support parallel builds (make -jX) and make use of all the cores in your system you can add the following line to your cerbero.cbc config: allow_parallel_build = True

– Andoni.

To make it work, do as follows, Go to the code location using Finder (File Explorer).

Open the cerbero/config/cross-ios-universal.cbc file using Text Edit. It should look like,

from cerbero.config import Platform, Architecture, Distro, DistroVersion

target_platform=Platform.IOS
target_arch=Architecture.UNIVERSAL
target_distro=Distro.IOS
universal_archs=[Architecture.ARMv7, Architecture.X86, Architecture.ARMv7S, Architecture.ARM64, Architecture.X86_64]

Add this line below, allow_parallel_build = True Now the file will look like,

from cerbero.config import Platform, Architecture, Distro, DistroVersion

target_platform=Platform.IOS
target_arch=Architecture.UNIVERSAL
target_distro=Distro.IOS
universal_archs=[Architecture.ARMv7, Architecture.X86, Architecture.ARMv7S, Architecture.ARM64, Architecture.X86_64]
allow_parallel_build = True

save the file.

Please note, If you are interested to build only for armv7 architecture (for example), then you should edit the corresponding file (for example, cross-ios-armv7.cbc file)

This simple edits will allow the build process to make use of all the cores as well as all hyper-threads, which will enable the process to run much faster. The processing power is required most at compile step. This is the screenshot of the CPU history of my MBP in an arbitrary plugin compile step.

Screen Shot 2014-12-11 at 11.59.26 AM

You can see, all the cores and hyper-threads are in use at their fullest capacity. My MBP specification is, 2.3 GHz Intel Core i7 with 8 GB 1600 MHz DDR3 RAM.

As a sidenote, I am using Yosemite (10.10.1) and I have experienced that it makes lesser halts and errors during the build process as opposed to Mavericks (10.9); Although I do not have any proper reasoning and it is quite possible that, this happens only in my case.

Bootstrap

Fire up your terminal. Go to the code location. In my case,

cd /Users/USER_NAME/code/cerbero  

Run the following command for universal build,

./cerbero-uninstalled -c config/cross-ios-universal.cbc bootstrap

If you are interested only for armv7s build then you should have run the following command instead,

./cerbero-uninstalled -c config/cross-ios-arm7s.cbc bootstrap

Now you will be asked for the password. After providing the password, it might take 2/3 hours to complete the process, depending on your internet and processor speed.

Basically, it will download 23 plugins. Each of these plugin will go through 6 common steps. Namely,

  1. Fetch
  2. Extract
  3. Configure
  4. Compile
  5. Install
  6. Post install

You can see the downloaded plugins folder in the following location

Users ▸ USER_NAME ▸ cerbero ▸ sources ▸ local

GStreamer build

Run the command for universal build,

./cerbero-uninstalled -c config/cross-ios-universal.cbc package gstreamer-1.0

Run the command instead for armv7s build,

./cerbero-uninstalled -c config/cross-ios-arm7s.cbc package gstreamer-1.0

It is even a longer process and might take up 8-9 hours for universal build and 2-3 hours for a single architecture build.

Basically, it will download 84 different plugins and each of these plugins will go through the same 6 steps with one more additional step.

  • Merge

Good news is, if for some reason the process halts, (might be an internet connection issue or any error) you will have an opportunity to run again from the failed step.

For example, If any OS error occurs, then you will see output like below,

OSError: [Errno 2] No such file or directory: '/Users/USER_NAME/cerbero/sources/local/lame-3.99.5/lame-3.99.5.tar.gz'

Select an action to proceed:
[0] Enter the shell
[1] Rebuild the recipe from scratch
[2] Rebuild starting from the failed step
[3] Skip recipe
[4] Abort

Similarly, If any step fails for some reason, you will see output like below,

Recipe 'gst-plugins-ugly-1.0' failed at the build step 'install'

Select an action to proceed:
[0] Enter the shell
[1] Rebuild the recipe from scratch
[2] Rebuild starting from the failed step
[3] Skip recipe
[4] Abort

In such cases, first try out enter 2, which is Rebuild starting from the failed step.

If doesn’t work then try out enter 1, which is Rebuild the recipe from scratch.

If doesn’t work, look for and try to figure out the specific error message from the bunch of error text above the 5 options text.

After completion, you will find two *.pkg file in the cerbero code location. Namely,
gstreamer-1.0-devel-1.5.0-ios-universal.pkg and
gstreamer-1.0.devel-1.5.0-Macosx-universal.pkg

For any help you can refer to their forum: GStreamer developer forum

Good luck! 🙂

Advertisements

One thought on “iOS: GStreamer framework custom build

  1. I’m playing aac audio stream on my iOS device using GStreamer SDK, its working fine, but delay is above 2.0 seconds.

    Can I make this delay lower then 2.0 seconds?
    There may be some buffering issue.
    This is how I’m creating the pipeline
    pipeline = gst_parse_launch(“playbin2”, &error);

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s