GStreamer SDK: "playbin2" creation fails on Android - android

I'd like to use GStreamer in my Android application. So far, I can already create GstNetClock and use it successfully.
If I try to create a playbin2 element, the factory always returns NULL. My code:
GstElement* player = gst_element_factory_make("playbin2", NULL);
The relevant lines of jni/Android.mk:
GSTREAMER_PLUGINS := $(GSTREAMER_PLUGINS_CORE) \
$(GSTREAMER_PLUGINS_PLAYBACK) \
$(GSTREAMER_PLUGINS_CODECS) \
$(GSTREAMER_PLUGINS_NET) \
$(GSTREAMER_PLUGINS_SYS)
GSTREAMER_EXTRA_DEPS := gstreamer-net-0.10 \
gstreamer-interfaces-0.10 \
gstreamer-video-0.10 \
gstreamer-plugins-base-0.10
In addition I tried to increase log verbosity of GStreamer to GST_LEVEL_LOG. However no logs are shown at all (as with default settings).
Do I have to load additional plugins or libraries? Or should I configure anything differently?

Please check if you can run at command prompt gst-inspect-0.10 playbin2. You might have an earlier deprecated version which is playbin. Try running that also.
A: Don't think you will require extra plugins as playbin2 is part of gst-plugins-base

Related

How to include util-linux in AOSP?

How do I include util-linux from here in AOSP? Where should I add this util-linux folder in AOSP so that I can build AOSP and these utils could be added in /system/bin/ or /system/xbin/? And is there any specific Makefile or Android.mk that I need to make it to compile with Android build?
I have added an application from util-linux package in AOSP.
Here's how I did it. I added the util-linux (2.34) from https://mirrors.edge.kernel.org/pub/linux/utils/util-linux/v2.34/util-linux-2.34.tar.gz in external of AOSP folder.
I just wanted to add chrt from util-linux. Therefore, I run the normal make command in util-linux to see what files are compiled for chrt. I took a note and created an Android.mk accordingly. I am sure there's a better way to do it hierarchically by making the library first and then make the chrt executable. However, this works too.
I added the following Android.mk at external\util-linux\. The Android.mk looks like the following:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := sohamchrt
LOCAL_SRC_FILES := schedutils/chrt.c lib/blkdev.c lib/canonicalize.c \
lib/crc32.c lib/crc32c.c lib/idcache.c lib/fileutils.c \
lib/ismounted.c lib/color-names.c lib/mangle.c lib/match.c lib/mbsalign.c \
lib/mbsedit.c lib/md5.c lib/pager.c lib/parse-date.c lib/pwdutils.c lib/randutils.c \
lib/setproctitle.c lib/strutils.c lib/timeutils.c lib/ttyutils.c lib/exec_shell.c \
lib/strv.c lib/sha1.c lib/signames.c lib/linux_version.c lib/loopdev.c \
lib/plymouth-ctrl.c lib/cpuset.c lib/path.c lib/procutils.c lib/sysfs.c
LOCAL_CFLAGS = -DHAVE_NANOSLEEP -include config.h \
-isystem bionic/libc/upstream-openbsd/android/include
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
include $(BUILD_EXECUTABLE)
Now, when I run m -j8 iso_img, then Android tries to compile sohamchrt. I named the package sohamchrt because chrt is already provided by toybox which have limitations.
The problem is util-linux is not fully compatible with bionic. So, I needed to make some changes to some .c and .h files such as fileutils.c, include/c.h, etc.
After successful compilation, the binary sohamchrt appears in /system/bin when Android is running, and it works with no issues.
This is also a guide on how you can add a C source file for a userspace executable binary in AOSP.
It's always worth checking whether a library you want to add already exists at https://android.googlesource.com/. In your case, unfortunately, it does not.
As util-linux does not come with an Android.bp. You will have to understand how util-linux is built and how Soong works to create a custom Android.bp for integration. The correct folder to place it would be external/util-linux/.
Maybe you will want to take a shortcut and just add util-linux as prebuilt binaries. That will reduce the effort.
Please check licensing issues first, though.

calling ndk-build for echoPrint android sample

I'm getting this error after calling the ndk-build command in the cmd.
I followed the steps in this link http://masl.cis.gvsu.edu/2012/01/25/android-echoprint/
make.exe: *** No rule to make target `/codegen/src/Codegen.cpp', needed by `obj/
local/armeabi/objs/echoprint-jni//codegen/src/Codegen.o'. Stop.
Can any one help me with this issue?
I don't know which platform the blog author used, and which version of NDK this was. But if you simply remove the heading "/" from the lines in Android.mk file, it should simply compile for you:
LOCAL_SRC_FILES :=AndroidCodegen.cpp \
codegen/src/Codegen.cpp \
codegen/src/Whitening.cpp \
codegen/src/SubbandAnalysis.cpp \
codegen/src/MatrixUtility.cpp \
codegen/src/Fingerprint.cpp \
codegen/src/Base64.cpp \
codegen/src/AudioStreamInput.cpp \
codegen/src/AudioBufferInput.cpp

MAKE problems in Android Project enabled with cocos2dx - "No rule to make target"?

BACKGROUND:
I'm following a tutorial online: Game apps in Android by Todd Perkins
- It's been very straightforward other than the hiccups that come with setting up NDK with eclipse, which I've managed to solve.
Problem:
I'm stuck at the point where I want my cocos2dx code to respond to a touch event and based on that, call Java android code from an activity.
I've added a bunch of screen shots below to show you how I've set everything up:
When I run build_native.sh:
Now I've made sure that I've linked my folders correctly in the project.
Below is a screen shot of the "linked" JNI folder(jni_linked), along with JniURL.cpp and JniURL.h:
and here's what my Android.mk file looks like:
I've double/triple checked the path of my Jni folder and it is:
C:\Users\DarkRaveDev\Documents\cocos2d-x-2.0.1\cocos2dx\platform\android\jni
Do I need to change the Android.mk file to have this line:
LOCAL_SRC_FILES := helloworld/main.cpp \
../../Classes/AppDelegate.cpp \
../../jni_linked/JniURL.cpp \
../../Classes/HelloWorldScene.cpp
It's probably treating:
/../../../cocos2dx/platform/android/jni/JniURL.cpp \
as starting with an absolute path instead of a relative path. It probably should be:
$(LOCAL_PATH)/../../../cocos2dx/platform/android/jni/JniURL.cpp \
or maybe:
../../../cocos2dx/platform/android/jni/JniURL.cpp \

Android filesystem includes

I am developing a native Android app, and I need access to GraphicBuffer.h (which is located in frameworks/base/include)
So I added the following to my Android.mk
#Android includes
LOCAL_C_INCLUDES += \
$(MYDROID)/frameworks/base \
$(MYDROID)/frameworks/base/include
The problem is that GraphicBuffer.h includes a bunch of other header files, and I don't want to have to add the paths to all of them in my makefile. What is the correct way to do this?
Update: While I would LOVE to know the correct way of doing this for the future, in this case, all that was needed was
#Android includes
LOCAL_C_INCLUDES += \
$(MYDROID)/frameworks/base/include \
$(MYDROID)/hardware/libhardware/include \
$(MYDROID)/system/core/include
You're supposed to use NDK to build native application.
What you're doing is trying to include header from Android source. This is not guaranteed to work on all devices, since this is not public API.

browser plugin for default android browser

I would like to develop a plugin for the default android browser which would specify the category of sites in the google search result. The android browser dont explicitly show plugin architecture. I would like to know how that can be done and any reference materials related to that.
Thanks,
I recently tried to make an android plugin and found many questions on SO but not many detailed answers, so I'd thought I'd share my research here even though the question is quite old now. I'm not sure if a plugin is really what you want to do here since you could probably use google's JSON/ATOM Custom Search API and parse that, but nonetheless I give details on how to get plugins working on Android. I hope it is useful for others.
If you look here: PluginManager.java you will see the following lines:
// Only plugin matches one of the signatures in the list can be loaded
// inside the WebView process
private static final String SIGNATURE_1 = "308204c5..."
The signature used here is the one for the Adobe Flash plugin (support for which has now been dropped by Adobe.)
and further down here you will see:
if (SystemProperties.getBoolean("ro.secure", false)) {
boolean signatureMatch = false;
for (Signature signature : signatures) {
for (int i = 0; i < SIGNATURES.length; i++) {
if (SIGNATURES[i].equals(signature)) {
signatureMatch = true;
break;
}
}
}
if (!signatureMatch) {
return false;
}
}
This means that if ro.secure=0 then it won't check the signatures - it would only allow the flash plugin otherwise.
ro.secure is a build property that you can set if you have root privaleges for your device or you have a dev build (type adb shell getprop ro.secure to find out what you have). You can research how to change this if necessary. I was using a Qualcomm Snapdragon MDP8960 which is development board which had ro.secure=0 already. To get your plugin signature included in android you'll have to talk to someone in charge - not sure how feasible this is at present.
Now to write a plugin - you can find an example called SampleBrowserPlugin in the android sourcetree (make sure you have a 64 bit linux machine if you want to build it - type make SampleBrowserPlugin from the source tree root. You might need to set up the build configuration first using lunch and you can find instructions on the android source tree site)
I actually grabbed the source I needed from android source on github and made an NDK build of the source as I am more familiar with how to do this than modifying the android build scripts. It will also be a lot faster than downloading the whole android tree - you can see what to download by looking at what is included in Android.mk (see below).
Basically, I pulled the shared object libraries that I needed from the device to make sure my plugin would be compatible. They were in /system/lib on my device: (e.g. type adb pull /system/libnativehelper.so etc from the directory where you want them stored)
get the following:
libnativehelper.so
libandroid.so
libutils.so
libcutils.so
libEGL.so
libGLESv2.so
libskia.so
Put them where SO_LIB_PATH points to in Android.mk (see below and change Path as necessary).
Then after installing the NDK sdk you should be able to use the following build script - don't need a 64 bit machine - (you can install winbash, use cygwin, or a linux virtual machine e.g. Oracle VM VirtualBox:
(Place these files in C:/Path/BrowserPlugin/jni/ and make sure the ndk-build command is on your path)
(if you're on linux remove the .cmd from ndk-build.cmd)
build.sh:
#!/bin/bash
echo -e "Mode\t\t: Debug"
OPTIM=debug
### ---------------- Generic Build Command ----------------
# run NDK build
ndk-build.cmd \
-d \
-B \
NDK_DEBUG=1 \
NDK_PROJECT_PATH=C:/Path/BrowserPlugin/jni \
NDK_APPLICATION_MK=C:/Path/BrowserPlugin/jni/Application.mk \
NDK_MODULE_PATH=C:/Path/BrowserPlugin/jni \
NDK_APP_OUT=C:/Path/BrowserPlugin/jni/Out/ \
APP_BUILD_SCRIPT=C:/Path/BrowserPlugin/jni/Android.mk \
APP_OPTIM=$OPTIM
cp C:/Path/BrowserPlugin/jni/Out/local/armeabi/libsampleplugin.so C:/Path/BrowserPlugin/libs/armeabi/.
echo "copied libsampleplugin.so into PROJECT_ROOT/libs dir"
Android.mk:
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
main.cpp \
PluginObject.cpp \
RenderingThread.cpp \
animation/AnimationPlugin.cpp \
animation/AnimationThread.cpp \
audio/AudioPlugin.cpp \
background/BackgroundPlugin.cpp \
form/FormPlugin.cpp \
navigation/NavigationPlugin.cpp \
paint/PaintPlugin.cpp \
video/VideoPlugin.cpp \
jni-bridge.cpp \
WEBCORE_PATH := C:/Path/AndroidBrowserPlugin/webkit/Source/WebCore
LOCAL_C_INCLUDES += \
$(JNI_H_INCLUDE) \
$(LOCAL_PATH) \
$(LOCAL_PATH)/animation \
$(LOCAL_PATH)/audio \
$(LOCAL_PATH)/background \
$(LOCAL_PATH)/form \
$(LOCAL_PATH)/navigation \
$(LOCAL_PATH)/paint \
$(LOCAL_PATH)/video \
$(WEBCORE_PATH)/bridge \
$(WEBCORE_PATH)/plugins \
C:/Path/AndroidBrowserPlugin/webkit/Source/WebKit/android/JavaVM \
C:/Path/AndroidBrowserPlugin/webkit/Source/WebKit/android/plugins \
C:/Path/AndroidBrowserPlugin/platform_external_skia/include/core \
C:/Path/AndroidBrowserPlugin/frameworks_native/include \
C:/Path/AndroidBrowserPlugin/frameworks_native/libs \
C:/Path/AndroidBrowserPlugin/frameworks_native/opengl/libs \
C:/Path/AndroidBrowserPlugin/platform_system_core/include \
C:/Path/AndroidBrowserPlugin/frameworks_native/opengl/include \
C:/Users/user/android-ndk-r8c/platforms/android-14/arch-arm/usr/include \
C:/Path/AndroidBrowserPlugin/BrowserPlugin/jni/libs/armeabi \
C:/Path/AndroidBrowserPlugin/platform_bionic \
C:/Path/AndroidBrowserPlugin/platform_bionic/libc/private \
C:/Path/AndroidBrowserPlugin/platform_hardware_libhardware/include
SO_LIB_PATH := C:/Path/AndroidBrowserPlugin/libs_qualcomm_MDP8960
LOCAL_LDLIBS := \
-L$(SO_LIB_PATH)/ -lnativehelper -landroid -lutils -lcutils -lEGL -lGLESv2 -lskia
LOCAL_CFLAGS += -fvisibility=hidden
LOCAL_CFLAGS += -DHAVE_PTHREADS -DANDROID
LOCAL_MODULE:= libsampleplugin
LOCAL_MODULE_TAGS := optional
include $(BUILD_SHARED_LIBRARY)
Application.mk:
# =============================================================================
#
# Main build file defining the project modules and their global variables.
#
# =============================================================================
# Don't remove this - mandatory
APP_PROJECT_PATH := $(call my-dir)
# The only STL implementation currently working with exceptions
APP_STL := gnustl_static
# Don't optimize for better debugging
APP_OPTIM := debug
You may also need some header files (e.g. JNIHelp.h) which you can place e.g. in the root where you are doing the ndk build BrowserPlugin/jni/.
Hopefully bash build.sh should build your libsampleplugin.so which the build script copies into the app directory. You can then e.g. import the project into eclipse and build the app. Install it on the device, then e.g. use WAMP server to host the following file:
index.html:
<!DOCTYPE html>
<html>
<head>
<title>Test Plugin</title>
</head>
<body>
<object type="application/x-testbrowserplugin" height=50 width=250 id="testPlugin">
<param name="DrawingModel" value="Bitmap" />
<param name="PluginType" value="Form" />
</object>
</body>
</html>
run ipconfig from your host machine to get the IP address e.g. 192.168.x.x
Then point your device browser to e.g. http://192.168.x.x/ and voila you should see a form plugin.
I couldn't get the animation plugins to work properly, and the form plugin didn't work fully, but at least the plugin was recognised and loaded ok.
Now, you can write a webkit NPAPI plugin to do what you like either using the sample plugin browser as a guide, or other internet resources.
This is actually quite interesting topic which was discussed recently during blackhat 2014 (FakeID) but in a bit different context. They've found security bug in signature validation.
In your case there are two helpful links :
1) http://androidxref.com/4.3_r2.1/xref/frameworks/base/tests/BrowserTestPlugin/ This is the newest sample of writing webkit plugins. Try to build it - it will require to have webkit external statically linked otherwise you will get ‘ fatal error: android_npapi.h: No such file or directory’
2) http://androidxref.com/2.2.3/xref/development/samples/BrowserPlugin/ This is older sample but it has wider description of "how to build" browser plugin
Use combination of both link to start your plugin development
However this doesn't solve signature check problem. Even if the plugin is recognised it won't be allowed to run. I'm not sure what is the process with google to do browser plugin development

Categories

Resources