Install GStreamer plugins on Android - android

I am trying to build my application on android. I am bit stucked on
GstElement* pipeline = gst_parse_launch ("rtspsrc location=rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov ! decodebin ! appsink name=sink", &err);
because, GError *err writes out no element "rtspsrc". I have already searched for some ways to add missing plugins/elements, but with no success.
I have found this page, which shows how to install plugins in code, but when I tried, gst_install_plugins_sync returned GST_INSTALL_PLUGINS_HELPER_MISSING and from this point, i don't know how to continue.
I have fully built library for gstreamer-1.0 including libgstrtsp-1.0, but I don't understand why my program doesn't find it.
How can I add plugins/elements to android?
Thanks for your help!
//EDIT:
Link, which I used to build libary, and I am using Android 4.4.4

You have to define extra plugins inside your Android.mk file:
GSTREAMER_PLUGINS := $(GSTREAMER_PLUGINS_CORE) $(GSTREAMER_PLUGINS_PLAYBACK) $(GSTREAMER_PLUGINS_CODECS) $(GSTREAMER_PLUGINS_CODECS_RESTRICTED) $(GSTREAMER_PLUGINS_NET) $(GSTREAMER_PLUGINS_SYS)
The list of available plugins groups are defined in:
$(GSTREAMER_ROOT_ANDROID)/$(TARGET_ARCH_ABI)/share/gst-android/ndk-build/plugins.mk
Additonally use playbin to play the RTSP stream like:
gst_parse_launch("playbin uri=rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov", &error);

Related

delphi XE7 firemonkey android shared object / library to be dynamically loaded - template

Is there a template to create a .so file that can be loaded by another delphi ape file - I have tried starting a blank fire monkey project and changing program to library and build it but the .so file that it produces won't load with dlopen within another delphi project. I have read that in other development environments there is a islibrary setting. I guess more to the point is there an example .so library built with fire monkey - I have found the bare bones link without fire monkey but it uses just jni not androidapi.jni - thanks
If you start a blank Firemonkey project and change Unit to Library, you'll get this compiler error:
[DCC Error] myfunnylib.pas(1): E2029 'UNIT' expected but 'LIBRARY' found
Trying to add an existing library project to the project group will separate said project from the rest of the build and assign unique build targets and platforms to it. Which will leave you with options to compile for Windows and OS X.
The only way I've heard of so far is to pre-compile your library with another compiler. FPC has been mentioned elsewhere. I haven't tried that yet but its next on the list.
http://wiki.freepascal.org/Android
Don't get confused by the fact that every Android app is in fact a shared object with the extension .so (for shared object). However, this is not the same thing as a shared library.
Because a library exports its functions while an application does not. To a compiler, that IS quite a difference though you wouldn't see that by looking at the file extension (but its prefix lib instead).
If you restrict your question to XE and Firemonkey, my only suggestion here would be to look into Android services. A bound local service might offer similar capabilities you'd expect from a library:
http://docwiki.embarcadero.com/RADStudio/Seattle/en/Android_Service
It's also important to note that Android N will not allow dynamic linking anymore so many of the methods you'll find elsewhere as a solution won't work.
suat dmk's code example in the answer below, though up-voted, is misleading.
It cannot be compiled for Android or iOS in XE 10.1 or any of its predecessors.
UPDATE:
There's a definite statement from Embarcadero staff regarding this issue.
It took a bit of patience in explaining the question, but the reply is clear enough:
[..] wants Delphi to have a project type of Shared Library(.so),
in this case then he is right, Delphi does not have it right now. [..]
quod erat demonstrandum
Hence there can be no such template. Also answers this question.
the following codes may be useful.
//-- Code for libMylib.so (MyLib.dproj) ---
library MyLib;
// uses SysUtils;
function GetSum(a, b: integer ) : integer; cdecl;
begin
Result := a + b;
end;
exports
GetSum name 'GetSum';
begin
end.
//-- Code for using libMylib.so (TestMyLib.dproj) ---
var
DocDir, LibFN: string;
GetSum: function(a, b: integer ) : integer; cdecl;
hLib: HMODULE;
begin
DocDir := IncludeTrailingPathDelimiter(System.IOUtils.TPath.GetLibrary`enter code here`Path);
LibFN:=DocDir + 'libMyLib.so';
hLib := LoadLibrary(LibFN); //ERROR (Segmentation fault (11))
if hLib<>0 then
begin
GetSum := GetProcAddress(hLib, 'GetSum');//It works
ShowMessage(IntToStr(GetSum(3, 8)));//It works
end;
end;
P.S: you must add compiled libMyLib.so file to Deployment of TestMyLib.dproj.
P.S2: it gives an error while executing "LoadLibrary", but it Works.
I couldn't find a solution. Probably it is related with compiler/linker options of MyLib.dproj. Because when I test another '.so' file which is compiled with C++, no problem occurs while calling LoadLibrary.

Library build error on Android

After more than two days of building errors, I give up...
I followed this good tutorial here: http://www.cryptopp.com/wiki/Android_(Command_Line) .
It compiles, and the "cryptest.exe" passes all tests. So, I guess that the static library "libcryptopp.a" is OK.
So, I move the "libcryptopp.a" and all the headers files in the Android project.
But when it comes to the building step (as often... :-) ), there are compilation errors, like:
.../Classes/libs/android/libcryptopp.a(files.o): in function std::basic_filebuf<char, std::char_traits<char> >::_M_unshift()
[clone .part.40]:/Users/toto/Developer/NDKs/AndroidNDKs/android-ndk-r8e/sources/cxx-stl/stlport/stlport/stl/_fstream.h:322:
error: undefined reference to 'std::_Filebuf_base::_M_write(char*, int)'
and ~50 others ...
"undefined reference to" errors usually mean that a library is not present, but "libcryptopp.a" is correct here. So I expect that something is missing in the "Android.mk":
include $(CLEAR_VARS)
LOCAL_MODULE := cryptopp-prebuilt
LOCAL_SRC_FILES := ...narf/Classes/libs/android/libcryptopp.
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
/*
here are included other library
*/
LOCAL_STATIC_LIBRARIES := cryptopp-prebuilt
include $(BUILD_SHARED_LIBRARY)
After tries with "APP_STL := stlport_static/dynamic", "APP_STL := gnustl_static/dynamic", etc... no more chances.
Being really not a building/compilation expert (even worse on Android), can somebody help me.
Thank you very much!
Ok. It is working now!
So the linking of "libcryptopp.a" is not working on my Android project with "stlport" but only with "gnustl_static". Perhaps because of others include like "cocosd2-x".
So following the tuto "http://www.cryptopp.com/wiki/Android_(Command_Line)" you must change the script "setenv-android.sh" to have a result like this:
ANDROID_STL_INC: /Users/toto/Developer/NDKs/AndroidNDKs/android-ndk-r8e/sources/cxx-stl/gnu-libstdc++/4.6/include/
ANDROID_STL_LIB: /Users/toto/Developer/NDKs/AndroidNDKs/android-ndk-r8e/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi/libgnustl_static.a
and also move the files (just for the compilation)
/Users/toto/Developer/NDKs/AndroidNDKs/android-ndk-r8e/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi/include/bits
in
/Users/toto/Developer/NDKs/AndroidNDKs/android-ndk-r8e/sources/cxx-stl/gnu-libstdc++/4.6/include/bits
otherwise there are compilation problems...
Ouf!
I think there are a couple problems with your answer.
First, when multiple libraries use the standard runtimes, you must use the shared object version and not the static version. That's covered in ANDROID_NDK_ROOT/docs/CPLUSPLUS-SUPPORT.html.
Second, you probably have a problem with library load order. Static linking makes it go away because references to std::_Filebuf_base::_M_write(char*, int) (and friends) are resolved at compile time, and not link/load time. To fix this, you must load libstlport_shared.so (or libgnustl_shared.so) first, and then load libcryptopp.so second.
If you load libcryptopp.so first, then there is no runtime loaded into the process to resolve std::_Filebuf_base::_M_write(char*, int) (and friends). That's covered under the wiki page with the LD_PRELOAD tricks.
To fix it in Android Java, you would perform the following. See Is -rpath working? for details.
static {
System.loadLibrary("stlport_shared");
System.loadLibrary("cryptopp");
}
The Crypto+++ Andrid wiki page has been updated: http://www.cryptopp.com/wiki/Android_(ommand_Line)#Android_Activity.

search.h-No such file or directory while porting libtiff on Android-tiff 4.0.1

I am trying to port libtiff on Android. The source version I am using is tiff 4.0.1.
I am building this source inside u1 android OS.
I am getting the below error when I run mmm external/tiff 4.0.1/
In file included from external/tiff-4.0.1/libtiff/tiffiop.h:33,
from external/tiff-4.0.1/libtiff/tif_dirread.c:42:
external/tiff-4.0.1/libtiff/tif_config.h:93:1: warning: "HAVE_MALLOC_H" redefined
In file included from <command-line>:0:
./system/core/include/arch/linux-arm/AndroidConfig.h:221:1: warning: this is the location of the previous definition
In file included from external/tiff-4.0.1/libtiff/tif_dirread.c:42:
external/tiff-4.0.1/libtiff/tiffiop.h:54:21: error: search.h: No such file or directory
I tries searching a lot on internet but could not get the issue.
Can any one provide me just an approx idea what could be wrong or which package is missing.
I resolved this issue finally. I hope this will help someone who is doing this work in future. We just need to remove the lines from libtiff/tiffiop.h where header file is being referenced.That worked for me.
Depending on your libtiff version, you can also just undefine HAVE_SEARCH_H in the config file tif_config.h which will then no longer include <search.h>:
In tif_config.h:
#ifndef ANDROID
/* Define to 1 if you have the <search.h> header file. */
#define HAVE_SEARCH_H 1
#endif

Problem using OpenCV2.3.1 with Android Native Activity

i'm developing a computer vision application for Android.
That work involves getting camera frames as fast as possible, so I'm trying to build a android application directly in c++ using "android_native_app_glue" and "libnative_camera" to get camera frames.
It seems to be incompatible.
I tested out 2 options.
I tried to use OpenCV on the android NDK sample "NativeActivity", just make the few necessary changes (convert sample to c++, modify android.mk y application.mk and including using namespaces and includes) It gives the following error:
sharedLibrary : libnative-activity.so
C:/Development/android-opencv-wsp/samples/native-activity/obj/local/armeabi-v7a/objs/native-activity/main.o: In function ~Mat':
C:\Development\android-opencv-wsp\samples\native-activity/../../OpenCV-2.3.1/share/OpenCV/../../include/opencv2/core/mat.hpp:297: undefined reference tocv::fastFree(void*)'
and so on
I tried to import the necessary libraries to make a native activity on the OpenCV2.3.1 tutorial 3 sample. I simply modified the Android.mk and added:
LOCAL_STATIC_LIBRARIES := android_native_app_glue
Immediately, when I add this line, I get the following error:
SharedLibrary : libnative_sample.so
C:/Development/android-opencv-wsp/samples/tutorial-3-native/obj/local/armeabi-v7a/objs/native_sample/jni_part.o: In function ~Mat':
C:\Development\android-opencv-wsp\samples\tutorial-3-native/../../OpenCV-2.3.1/share/OpenCV/../../include/opencv2/core/mat.hpp:297: undefined reference tocv::fastFree(void*)'
and so on...
Please, has anyone tested a purely native activity with openCV2.3.1 and libnative_camera to get camera frames?
Thanks in advance.
I solved the problem there. It was my fault (as usual xD) the problem was I was writting in my Android.mk this line: LOCAL_STATIC_LIBRARIES := android_native_app_glue, instead of this line: LOCAL_STATIC_LIBRARIES += android_native_app_glue. I needed the "plus" symbol, in order to add the new library and not deleting the previously loaded. Thanks anyway!!
#Adi Shavit - thx
Change LOCAL_STATIC_LIBRARIES := android_native_app_glue to LOCAL_STATIC_LIBRARIES += android_native_app_glue. Note the plus sign. This will add the new library without deleting the previously loaded one. Source: Edanna in the comments
Maybe you should take a look at the V4L interface? You might want to check out this thread: http://comments.gmane.org/gmane.comp.handhelds.android.ndk/2824
If I recall you can read directly from a camera's dev file in OpenCV.
-James

Using cURL in Android

I would like to use cURL library in my android application in native code (using NDK r5b, the latest). After researching online, it seems the only way to use cURL in android is to build the entire android source tree with curl in it, and somehow this generates a necessary config file for cURL to work on Android. I don't have any experience building the android sources from scratch and was wondering if there is a way to use cURL library in Android without having to rebuild android from source. Ideally, being able to just use cURL as a static or shared library would be perfect. I tried following the steps mentioned here...
http://curl.haxx.se/mail/lib-2009-12/0071.html
but end up getting errors in the file curlrules.h like CURL_SIZEOF_LONG definition is missing!
I assume these errors are due to not having that config file I mentioned but the steps in the above link didn't mention any of that and reported success. Any ideas?
I'm on a similar quest! I'm working on an app right now that requires cURL and just tonight in my search I came across your post here, and what I believe to be the answer:
http://thesoftwarerogue.blogspot.com/2010/05/porting-of-libcurl-to-android-os-using.html
Unlike the link you referenced, there are several follow-up comments from other people who claim to have success also following the instructions. If you manage to get it compiled before me, and wouldn't mind sending me the library, post a follow up here! (I'm pretty new to stack overflow so I don't know if you can pm.) Hope this works out for both of us!
It seems that there are projects on github that automated both openssl and libcurl for NDK build:
https://github.com/jahrome/curl-android
https://github.com/guardianproject/openssl-android
Going to use those in my own app, so I can have single library to deal with backend communication for both iOS and Android...
After check all possibles post about this, I finally got a good compilation using a Linux x64 machine and Curl version 7.37.0 at path ${android-ndk-r10}.
Maybe this steps can help you:
1º
${android-ndk-r10}/build/tools/make-standalone-toolchain.sh --platform=android-15 --arch=armv7-a --toolchain=arm-linux-androideabi-4.8 --install-dir=./tmp/android-15
2º
export CC="${android-ndk-r10}/external/curl/tmp/android-15/bin/arm-linux-androideabi-gcc"
3º
./configure --host=arm-linux --enable-cross-compile --enable-threaded-resolver --disable-shared --disable-ftp --disable-file --disable-ldap --disable-ldaps --disable-rtsp --disable-dict --disable-telnet --disable-tftp --disable-pop3 --disable-imap --disable-smtp --disable-gopher --disable-manual --enable-proxy --enable-ipv6 --enable-cookies --enable-symbol-hiding --disable-versioned-symbols --disable-soname-bump --disable-sspi --disable-ntlm-wb --prefix=${android-ndk-r10}/external/curl/build/curl-7.37.0
4º
make -j4
5º
make install
You will get a build version at ${android-ndk-r10}/external/curl/build/curl-7.37.0.
If you are using a 64bits machine to compile, maybe 2 defines are bad, and you get this error:
error: size of array '__curl_rule_01__' is negative
I solve redefining the variables in file ${CurlbuildAndroid}/include/curl/curlbuild.h (Its dangerous to do this, but it worked!):
CURL_SIZEOF_LONG 4
CURL_TYPEOF_CURL_OFF_T 4
I followid this link. And it works for me. I did not have to download the whole android repository in order to compile the libcurl
You can choose to download cURL for android at https://play.google.com/store/apps/details?id=io.github.faywong.curl
"CURL_SIZEOF_LONG definition is missing!"
there is a way for it .
change the curlbuild.h at line number 162
add like this,if you are arm32 platform.
//----------------------------------------------add
# define CURL_SIZEOF_LONG 4
# define CURL_TYPEOF_CURL_OFF_T long long
# define CURL_FORMAT_CURL_OFF_T "lld"
# define CURL_FORMAT_CURL_OFF_TU "llu"
# define CURL_FORMAT_OFF_T "%lld"
# define CURL_SIZEOF_CURL_OFF_T 8
# define CURL_SUFFIX_CURL_OFF_T LL
# define CURL_SUFFIX_CURL_OFF_TU ULL
# define CURL_TYPEOF_CURL_SOCKLEN_T unsigned int
# define CURL_SIZEOF_CURL_SOCKLEN_T 4
//#define __SYMBIAN32__
I had a similar question which didn't get answered and thus was automatically removed :(
Anyway I've successfully used curl on android and have uploaded a compiled version to help the people still searching.
Download: libcurl_for_arm
I also required a typecheck-gcc.h file which I've amended and uploaded here too
Download: typecheck-gcc.h

Categories

Resources