GStreamer on Android

Similar documents
OMX, Android, GStreamer How do I decide what to use? 15 July 2011

Introduction to Native Android Development with NDK

Multithreading and Java Native Interface (JNI)!

State of the GStreamer Project. Jan Schmidt. Centricular Ltd

High Efficiency Video Coding (HEVC) or H.265 is a next generation video coding standard developed by ITU-T (VCEG) and ISO/IEC (MPEG).

Multimedia Framework Overview. JongHyuk Choi

Using Mobile Processors for Cost Effective Live Video Streaming to the Internet

VOD Encoder Fast HIDef Video Encoding

ANDROID DEVELOPER TOOLS TRAINING GTC Sébastien Dominé, NVIDIA

Android builders summit The Android media framework

The Decaffeinated Robot

TEGRA X1 DEVELOPER TOOLS SEBASTIEN DOMINE, SR. DIRECTOR SW ENGINEERING

An Android Multimedia Framework based on Gstreamer

Google and Open Source. Jeremy Allison Google Open Source Programs Office

Android NDK Native Development Kit

Issues in Android on Mobile Platform and Their Resolution

Introduction to Android

Multimedia Playback & Streaming

Android Hands-On Labs

Building graphic-rich and better performing native applications. Pro. Android C++ with the NDK. Onur Cinar

l What is Android? l Getting Started l The Emulator l Hello World l ADB l Text to Speech l Other APIs (camera, bitmap, etc)

Overview of CS 282 & Android

How To Develop For A Powergen 2.2 (Tegra) With Nsight) And Gbd (Gbd) On A Quadriplegic (Powergen) Powergen Powergen 3

Streaming Networks with VLC. Jean-Paul Saman

Audio Video Streaming Solution for Bambuser

RTI Connext DDS. Core Libraries Getting Started Guide Addendum for Android Systems Version 5.2.0

GStreamer on Texas Instruments OMAP35x Processors

Example of Standard API

Android on i.mx Applications Processors

Power Benefits Using Intel Quick Sync Video H.264 Codec With Sorenson Squeeze

ipad, a revolutionary device - Apple

Development_Setting. Step I: Create an Android Project

VA (Video Acceleration) API. Jonathan Bian 2009 Linux Plumbers Conference

System Reference 2013

CSE 237A Final Project Final Report

Native code in Android Quad Detection

Using GStreamer for hardware accelerated video decoding on Intel Atom Processor E6xx series

Introduction of Fujitsu DRM Solution for Marlin DRM/MPEG-DASH Solutions

Wowza Media Systems provides all the pieces in the streaming puzzle, from capture to delivery, taking the complexity out of streaming live events.

Region Free DVD Playback with VLC. By Mikio Moriyasu

Android Virtualization from Sierraware. Simply Secure

BogDan Vatra and Andy Gryc. Qt on Android: Is it right for you?

Development Techniques for Native/Hybrid Tizen Apps. Presenter Matti Pakarinen

AAC-ELD based Audio Communication on Android

Mobile Phones Operating Systems

Android Development: Part One

How To Develop Android On Your Computer Or Tablet Or Phone

01. Introduction of Android

Android Programming and Security

OpenCV on Android Platforms

Research and Design of Universal and Open Software Development Platform for Digital Home

Graduate presentation for CSCI By Janakiram Vantipalli ( Janakiram.vantipalli@colorado.edu )

ITG Software Engineering

4Kp60 H.265/HEVC Glass-to-Glass Real-Time Encoder Reference Design

CS378 -Mobile Computing. Android Overview and Android Development Environment

The World`s First Unified Media Server

SIP EXPRESS MEDIA SERVER (SEMS) WITH MPEG4 SUPPORT

What is this talk about?

The MeeGo Multimedia Stack. Dr. Stefan Kost Nokia - The MeeGo Multimedia Stack - CELF Embedded Linux Conference Europe

An Introduction to Android

Using Smartphones and Tablets in Embedded Applications

What else can you do with Android? Inside Android. Chris Simmonds. Embedded Linux Conference Europe Copyright 2010, 2net Limited.

Serving Media with NGINX Plus

Middleware- Driven Mobile Applications

rich mobile applications made easy

Android: How To. Thanks. Aman Nijhawan

Managing video content in DAM How digital asset management software can improve your brands use of video assets

Development. SriSeshaa Technologies. Table of Contents

Accelerate your Mobile Apps and Games for Android on ARM. Matthew Du Puy Software Engineer, ARM

Challenge. Solution. Key Results

Introduction to Android

Version 2.8. Released 30 September 2015

Mobile Operating Systems. Week I

APP DEV. We build your ideas into web and mobile applications. steicho. Technological Solutions

Intel Integrated Native Developer Experience (INDE): IDE Integration for Android*

Avaya Aura Orchestration Designer

Publishing to TIZEN Using the Automated Conversion/Repackaging of Existing Android Apps. Hyeokgon Ryu, Infraware Technology, Ltd.

Open Source Software for loudness measurement

B.E. (Electronics and Communication Engineering) from Govt. College of Engineering, Tirunelveli, Tamilnadu.

Android Architecture. Alexandra Harrison & Jake Saxton

Creating and Using Databases for Android Applications

Audio streaming over Bluetooth

Lecture 1 Introduction to Android

Writing standalone Qt & Python applications for Android

GStreamer Past Present - Future

Developing Applications for ios

PERFORMANCE ANALYSIS OF VIDEO FORMATS ENCODING IN CLOUD ENVIRONMENT

Streaming multimedia les from relational database

An Introduction to Android. Huang Xuguang Database Lab. Inha University

Computer Graphics on Mobile Devices VL SS ECTS

Fetch TV My Media Hub Quick Start Guide For Windows Or Mac

Extending Tizen Native Framework with Node.js

GETTING STARTED WITH ANDROID DEVELOPMENT FOR EMBEDDED SYSTEMS

Creating Content for ipod + itunes

Windows Embedded Compact 7 Multimedia Features 1

Workshop on Android and Applications Development

QuickTime Streaming. End-to-end solutions for live broadcasting and on-demand streaming of digital media. Features

SIP based HD Video Conferencing on OMAP4

Developing multi-platform mobile applications: doing it right. Mihail Ivanchev

Bosch Video Management System

Transcription:

GStreamer on Android

Who are we?

A short Introduction to GStreamer

Just a short overview for those who don't know it yet

Pipeline based multimedia framework Cross platform, open source Bindings for many languages Stable API/ABI

LGPL Runs on Linux, Solaris, *BSD, OSX, Windows, x86, PPC, ARM, SPARC, Python, C++,.NET, Perl, Ruby, 0.10 stable since >5 years, new 1.0 series

Flexible and extensible design Plugin-based architecture Easy to integrate with other software Active developer and user community

Pipeline, elements Media-agnostic core, media-aware plugins and libraries All media-specific code in plugins Only include what you need, add things later Addition of 3rd party plugins, commercial/proprietary things Simplifies license and patent nightmares Integration into apps/libs, integration of libs (ffmpeg) into GStreamer

Generic format negotiation mechanisms Synchronization and data transport of media Flexible communication between app and framework

Very simple Ogg audio/video player pipeline

Plugins for all important codecs and containers Proprietary plugins for patented codecs Plugins for different filters Hardware support Support for many different use cases

and also weird codecs/containers Fluendo, Entropy Wave, device-specific plugins Converters, mixers, effects, OpenMAX, OpenGL, V4L, VDPAU, VAAPI, Playback, encoding, realtime communication Audio/video editing, signal processing, streaming server/client Web browsers

Used in many different applications on desktop platforms Used on many different devices by different companies

Linux (GNOME), OSX, Windows Smartphones, tablets, video cameras, settop boxes, TVs, video conference solutions, Android

GStreamer SDK

Distribution of GStreamer with dependencies Available for Windows, OS X, Linux, Android IDE integration Starter documentation and tutorials Commercial support

fd.o project Installers, packages ios planned later

Why use GStreamer on Android?

Android Multimedia stack Good multimedia API for playback and capture. Support for most common audio and video formats And a few streaming protocols But...

Video players and camera capturers Audio: AAC, MP3, FLAC, Vorbis, AMR, Midi, PCM Video: H264, H264, AVC, VP8 Muxers: WebM, Matroska, MP4, OGG, Mpeg-TS RTSP, HTTP, HLS

We want much more than just playback or capture Some codecs and formats are not supported: ASF, DTS, or new codecs like Opus Other are device specific: WMA and WMV Only a few streaming protocols are supported: DASH, Smooth Streaming, RTP?

We want to write any kind of application from Non-linear to video editors, transcoders or media servers. Opus, WMV and WMA and many other weird codecs Only available on Tegra 3 devices Smooth Streaming or DASH with GStreamer.

GStreamer has almost everything we need: Supports a very large number of formats. Support for more uses cases Multimedia backend re-usable across platforms.

Provide decoders, demuxer, encoders and demuxers for a wide range for formats A single multimedia for all platforms

Problems with using GStreamer on Android

Plugin-based architecture -> too many shared libraries Android's dynamic linker limits the number of shared libraries per process. We have more than 262 shared libraries Hard to easily distribute it in the Market Legal constraints with the LGPL and static linking. The NDK is limited: C library (BIONIC) and other libraries like OpenSL.

GStreamer itself only depends on glib, libxml2, libffi and libz, but plugins pull-in many dependencies android's dynamic linker has a hard-coded limit on the number of.so files (shared libraries and/or plugins) you can load in a single process. Android's linker is limited to 64, 96 and 128 shared libraries Including all plugins we have 262 shared libraries The LGPL requires a re-linking mechanism for statically linked libraries. Other API's are not even available in C like the MediaCodec API

How we solved it..

Static linking with re-locatable archives. A single shared library with everything: libgstreamer_android.so Integration with ndk-build to link this shared library: Complies with the LGPL requirement. Allows selecting only the plugins being used.

Static libraries built with -DPIC and -fpic Static linking inly includes oject libraries that are actually. Easy to re-distribute and load in applications

Building the SDK

We use a build system called Cerbero. Same build system used to build the SDK in all platforms. Re-use of upstream packaging system. Native packaging: Windows.msi, OS X.pkg, RPM and DEB Easy to maintain Easy to add new packages or 3rd party plugins

We use cerbero, a build system developped for building the GStreamer SDK Supports many platforms, cross-compilation and toolchain configuration. Makefile, autotools and CMake. This saved us a lot ot time compared to the old approach of porting the build to ndk-build

$ git clone git://anongit.freedesktop.org/gstreamer-sdk/cerbero $ cerbero -c config/cross-android.cbc bootstrap $ cerbero -c config/cross-android.cbc package gstreamer-sdk

Shows how simple and fast is rebuilding the sdk

Static plugins and modules

GStreamer plugins and GIO modules must be handled in a different way. We are trying to get these changes upstream Static plugins need to be registered manually.

A bug open for glib, missing documentation for GStreamer Instead of being loaded manually from path we must explicetly register them.

Integration with ndk-build

A set of makefiles that extend nkd-build's core to generate libgstreamer_android.so and link it to the application From the point of view of application developers we tried to make things as easy as possible. Example of Android.mk from the Android NDK samples

LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := hello-jni LOCAL_SRC_FILES := hello-jni.c include $(BUILD_SHARED_LIBRARY) include $(CLEAR_VARS)

jni/android.mk modified to include GStreamer

LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := hello-jni LOCAL_SRC_FILES := hello-jni.c LOCAL_SHARED_LIBRARIES := gstreamer_android include $(BUILD_SHARED_LIBRARY) include $(CLEAR_VARS) include $(GSTREAMER_NDK_BUILD_PATH)/plugins.mk GSTREAMER_SDK_ROOT := /home/cerbero/android_arm GSTREAMER_PLUGINS = $(GSTREAMER_PLUGINS_CORE) $(GSTREAMER_PLUGINS_CODECS) GSTREAMER_EXTRA_DEPS := json-glib-1.0 include $(GSTREAMER_NDK_BUILD_PATH)/gstreamer.mk

gstreamer_android.c: redirects GStreamer logs to logcat and adds an entry point to initialize GStreamer and register static plugins Libraries used from the C backend must be explicetly listed to include the whole archive with --whole-archive, otherwise the linker will not include the object files as no symbol is used by the gstreamer plugins.)

We use libtool libraries to resolve link deps Libtool can't be used for portability issues A small libtool replacement in makefiles + sed Portable (works on Windows too) Supports relocations of.la files Much faster than libtool

Requires a unix-like shell on windows equivalent to libtool --comand=link -static-libtool-libs We can install the SDK everywhere as libtool is relocatable

And some stats... 171 plugins (same as for other platforms) Size of libstreamer_android.so not stripped: 60 MB stripped: 15 MB not stripped without GStreamer debug: 55 MB stripped without GStreamer debug: 13 MB

A library with everything is very cool, but at which cost? Most of the time we don't need all plugins This is using the tutorial plugins' list

New plugins

New plugins developed for the SDK on Android To use only public API, add missing features

OpenGL ES / EGL Video Sink

OpenGL ES/EGL only public, native API for video on Android Supports hardware accelerated colorspace conversion, scaling Usable on all Android devices Works like any other GStreamer video sink Allows embedding into Android applications Small and simple codebase

OpenGL not really made for video display but usable Replacement for old surfaceflinger, non-public API YUV, RGB, shaders Also other platforms with OpenGL ES/EGL Available since Android Gingerbread (2.3)

OpenSL ES Audio Sink/Source

OpenSL ES only public native API for audio on Android Very limited implementation available on Android Usable on all Android devices Uses Android-specific API extensions Could support compressed formats later

Khronos standard (think: OpenGL, OpenMAX) Replace old audioflinger based sink, non-public API Very complex and powerful standard though, IMHO overengineered Mono, S16, 16kHz recording Mono/Stereo, U8/S16, up to 48kHz playback No device selection or any other more advanced features Available since Android Gingerbread (2.3) Minimal changes required to work on other platforms

android.media.mediacodec Wrapper

Be able to use device's codecs Uses Java API via JNI Java/JNI not performance problem Usable on all Android devices

Hardware acceleration, no worries about patent licenses OpenMAX AL another option, very limited on Android only MPEGTS decoding Very simple and powerful API Very few method calls per frame MediaCodec only small JNI wrapper around stagefright (C++) Available since Android Jelly Bean (4.1)

Implemented: audio/video decoders Encoders easy to add if necessary 1080p h264 easily possible, impossible in software Supported video codecs: h264/avc, MPEG4, h263, MPEG2 and VP8 Supported audio codecs: AAC, MP3, AMR-NB/WB, A-Law, µ-law, Vorbis and FLAC

Hardware and software codecs Tested so far on TI Ducati and NVidia Tegra3

Developing applications with the SDK

GStreamer projects can be built using the regular tools For Eclipse: using the wizard and project Android Tools Add Native Support Command line: using the standard Ant build command jni/android.mk must be updated for GStreamer

LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := hello-jni LOCAL_SRC_FILES := hello-jni.c LOCAL_SHARED_LIBRARIES := gstreamer_android include $(BUILD_SHARED_LIBRARY) include $(CLEAR_VARS) include $(GSTREAMER_NDK_BUILD_PATH)/plugins.mk GSTREAMER_SDK_ROOT := /home/cerbero/android_arm GSTREAMER_PLUGINS = $(GSTREAMER_PLUGINS_CORE) $(GSTREAMER_PLUGINS_CODECS) include $(GSTREAMER_NDK_BUILD_PATH)/gstreamer.mk

No Java bindings yet Multimedia backend is written in C Bind the backend API to use it in the application through JNI

Bind backend registering dynamic methods with RegisterNatives Declare this new methods as dynamic in the Java side

/* List of implemented native methods */ static JNINativeMethod native_methods[] = { { "nativeinit", "()V", (void *) gst_native_init}, { "nativefinalize", "()V", (void *) gst_native_finalize}, { "nativeplay", "()V", (void *) gst_native_play}, { "nativepause", "()V", (void *) gst_native_pause}, { "nativeclassinit", "()Z", (void *) gst_native_class_init} }; /* Library initializer */ jint JNI_OnLoad(JavaVM *vm, void *reserved) { JNIEnv *env = NULL; java_vm = vm; if ((*vm)->getenv(vm, (void**) &env, JNI_VERSION_1_4)!= JNI_OK) { android_log_print (ANDROID_LOG_ERROR, "tutorial-2", "Could not retrieve JNIEnv"); return 0; } jclass klass = (*env)->findclass (env, "com/gst_sdk_tutorials/tutorial_2/tutorial2"); (*env)->registernatives (env, klass, native_methods, G_N_ELEMENTS(native_methods)); pthread_key_create (&current_jni_env, detach_current_thread); } return JNI_VERSION_1_4;

Glib's main loop is run in a separate thread Use Thread-Local Storage (TLS) for storing the JNI env Load libgstreamer_android.so in the application

Help with threads that are not called form Java

5 tutorials specific for Android: Linking against GStreamer A running pipeline Video A basic media player A complete media player 25 other tutorials for introducing developers into GStreamer development.

GStreamer SDK http://www.gstreamer.com Documentation and tutorials http://www.docs.gstreamer.com

Questions?

Thanks!