GStreamer on Android

Chuck Crisler ccrisler at mutualink.net
Wed Aug 12 07:02:38 PDT 2015


1. Import project.
2. Open project.
3. Edit the app build.gradle. Here is the important part of mine. I have an
Android phone running 4.4.2, so I used SDK version 19. Take notice of the
cFlags settings! You can include whatever you need.

android {
    compileSdkVersion 19
    buildToolsVersion "19.1"

    defaultConfig {
        applicationId "com.example.ccrisler.cameratest"
        minSdkVersion 19
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"

        ndk {
            moduleName "CameraTest"
            cFlags "-DANDROID_NDK -D_DEBUG
-I/home/ccrisler/gstreamer_android_armv7_debug/include/gstreamer-1.0/gst"
            //    cFlags "-std=c++11 =fexceptions" // Add provisions
to allow C++ 11 functionality
        }
    }

    sourceSets.main {
        jni.srcDirs = [] // This prevents the auto generation of Android.mk
        jniLibs.srcDir 'src/main/libs'
    }

4. Edit local.properties. Add ndk.dir=<absolute path to your NDK>

5. Outside of Android Studio, edit android.mk to set some GStreamer
parameters. Here is mine. I think that it comes from the GStreamer
examples and I
copy it to each project.

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE    := CameraTest
LOCAL_SRC_FILES := MediaProcessing.c
LOCAL_SHARED_LIBRARIES := gstreamer_android
LOCAL_LDLIBS := -llog -landroid
include $(BUILD_SHARED_LIBRARY)

GSTREAMER_JAVA_SRC_DIR := app/src/main/java
GSTREAMER_ROOT := <absolute path>/gstreamer_android_armv7_debug

ifndef GSTREAMER_ROOT
ifndef GSTREAMER_ROOT_ANDROID
$(error GSTREAMER_ROOT_ANDROID is not defined!)
endif
GSTREAMER_ROOT        := $(GSTREAMER_ROOT_ANDROID)
endif
GSTREAMER_NDK_BUILD_PATH  := $(GSTREAMER_ROOT)/share/gst-android/ndk-build/
include $(GSTREAMER_NDK_BUILD_PATH)/plugins.mk
GSTREAMER_PLUGINS         := $(GSTREAMER_PLUGINS_CORE)
$(GSTREAMER_PLUGINS_PLAYBACK) $(GSTREAMER_PLUGINS_CODECS)
$(GSTREAMER_PLUGINS_NET) $(GSTREAMER_PLUGINS_SYS)
G_IO_MODULES              := gnutls
GSTREAMER_EXTRA_DEPS      := gstreamer-video-1.0
include $(GSTREAMER_NDK_BUILD_PATH)/gstreamer-1.0.mk

6. Open a terminal window. On linux, 'export
NDK_PROJECT_PATH=<absolute path to
project>android_tutorial-N/app/src/main'

7. Run ndk-build APP_PLATFORM=android-9

I have forgotten what the APP_PLATFORM does, but it changes a version
of the system files used to prevent many unresolved references.

You can google it for more info. When you run ndk-build, it will build
your GStreamer android libraries and put everything in the 'right'

places. It will create your JNI and libs directories. Obviously, if
you change any of the C code, you have to run ndk-build again.


Here is a great link for NDK
info->http://www.shaneenishry.com/blog/2014/08/17/ndk-with-android-studio/

I still can't find Sebastian's blog! Sorry.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20150812/466f5224/attachment.html>


More information about the gstreamer-devel mailing list