- ARMv5TE, including Thumb-1 instructions
- ARMv7-A, including Thumb-2 and VFPv3-D16 instructions, with optional support for NEON/VFPv3-D32 instructions
- x86 instructions
- MIPS instructions
| CPU Architecture Used | Compatible Android Platforms |
|---|---|
| ARM, ARM-NEON | Android 1.5 (API Level 3) and higher |
| x86 | Android 2.3 (API Level 9) and higher |
| MIPS | Android 2.3 (API Level 9) and higher |
NEON technology is a 128-bit SIMD
(Single Instruction, Multiple Data) architecture extension for the ARM
Cortex™-A series processors,
designed to provide flexible and powerful acceleration for consumer
multimedia applications, delivering a significantly enhanced user
experience.
It would be nice filter out the incompatible terminals based on CPU type by running a check before calling the native library. I can get the CPU type info by reading /proc/cpuinfo (it doesn't require super user privilege). A short example by roman10.
If I want to filter-out the incompatible terminals using Google Play, I may use a database of Android terminals and their features that exists on Wikipedia .
To ensure compatibility, an application using a native library produced with the NDK must declare a
<uses-sdk> element in its manifest file, with an
android:minSdkVersion attribute value of "3" or higher.- Place your native sources under
<project>/jni/... - Create
<project>/jni/Android.mkto describe your native sources to the NDK build system - Optional: Create
<project>/jni/Application.mk. - Build your native code by running the 'ndk-build' script from your project's directory. It
is located in the top-level NDK directory:
cd <project> <ndk>/ndk-build
The build tools copy the stripped, shared libraries needed by your application to the proper location in the application's project directory.
- Finally, compile your application using the SDK tools in the usual way. The SDK build tools
will package the shared libraries in the application's deployable
.apkfile.
- libc (C library) headers
- libm (math library) headers
- JNI interface headers
- libz (Zlib compression) headers
- liblog (Android logging) header
- OpenGL ES 1.1 and OpenGL ES 2.0 (3D graphics libraries) headers
- libjnigraphics (Pixel buffer access) header (for Android 2.2 and above).
- A Minimal set of headers for C++ support
- OpenSL ES native audio libraries
- Android native application APIS
Another approach is to compile ffmpeg as a standalone executable like this and then package it with the app. There are a few issues to be aware of:
- In order to run a native linux command we use Runtime.getRuntime.exec("command") - example.
- In order to run our ffmpeg on a non-rooted phone, the safest method (no internet downloads) is to copy the binary inside the assets folder. At runtime we copy it to a writable location and change its file permissions - see other choices. It seems the only folder we can write to and change the file permissions is /data/data/app-package-name (e.g. /data/data/org.vlc.android.run_ffmpeg)
- When reading the binary file from the assets folder, an IOException is thrown if the file size exceeds 1MB. This is because the file is automatically compressed when packaged, and there is a limit set in one of the Android headers - see this thread for details. A quick fix is adding a .mp3 extension to the bundled file - Android will think it's an already compressed mp3 and will not compress it.
Niciun comentariu:
Trimiteți un comentariu