2

I am starting to work with stage fright frame work to implement hardware decoder in android prior to Jelly bean in my video conferencing application.
I have downloaded and built the android source code in Mac system. I am not clear with the whole idea of working with AOSP. And my questions are (with respect to stagefright framework)

  1. Where can I find the libstagefright.so after AOSP build ?.

  2. If I use the OMX codec in my class for decode, how should I link the libstagefright.so to native code of my application ? If I build my native code by copying the libstagefright.so and linking it via make file is that the way ?

  3. How can I use it in my application ? If I load it via System.loadLibrary(" "), will it work ??

UPDATE:
I have tried the suggestion from Ganesh. But when I tried to build the project with NDK it is not taking the headers included as LOCAL_C_INCLUDES.

Here is my android.mk

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_LDLIBS := -llog
LOCAL_MODULE := custom_decoder

LOCAL_C_INCLUDES := $(LOCAL_PATH)\includes \
                    frameworks/av/media/libstagefright/include \
                    frameworks/native/include/media/openmax \
                    frameworks/base/include/media/stagefright

LOCAL_SHARED_LIBRARIES := \
                    libstagefright libstagefright_omx libstagefright_foundation libutils liblog

LOCAL_SRC_FILES := custom_decoder_jni.cpp custom_decoder.cpp

include $(BUILD_SHARED_LIBRARY)

the error is shown from custom_decoder.h when it is reading the includes of AOSP.

 fatal error: DataSource.h: No such file or directory. 

I haven"t included any AOSP .so in my project(as per Ganesh's suggestion in comment 2). Should I do that?

What else should I do to get it built......

Kevin K
  • 589
  • 2
  • 7
  • 28
  • 1
    `libstagefright` and OMX are available on all Android devices since Gingerbread, you don't need to build AOSP to use it. – Alex Cohn Jun 13 '14 at 11:37
  • @Alex Cohn Thank you for your reply. I am doing it via android ndk. To build the native code where I will be calling the OMXCodec apis, I need to include libstagefright.so no, since they are not exposed in ndk ? For that I did the AOSP build... Pls give me some corrections if my way is wrong........ – Kevin K Jun 16 '14 at 06:23

2 Answers2

4

You don't need to rebuild libstagefright.so to use it in your app. You can adb pull the library from your device, or even from an emulator.

Please note that libstagefright communicates with many components in /system/lib, some of which are specific to SoC vendor (e.g. Qualcomm) or ODM (e.g. Samsung). Some uses of Stagefright may require quirks specific to device. This is why OpenMAX IL has not been officially exposed on Android. On the otehr hand, OpneMAX AL has been officially supported since November 2011.

At any rate, libstagefright cannot be directly accessed from Java. If you are looking for a Java solution for video communication, you should first look at the excellent libstreaming library.

The advantage of using libstagefright comes usually when you have you your native (C/C++) library that only has to be connected to an efficient codec.

Here is a nice answer on a related question about Android hardware decoder.

Community
  • 1
  • 1
Alex Cohn
  • 56,089
  • 9
  • 113
  • 307
2

To answer your specific queries,

  1. libstagefright.so is built and installed at /system/lib

  2. I presume you are employing the libstagefright.so in native code. With this assumption, you don't have to copy. I presume you are building your module as a loadable library i.e. .so file. Hence, if you can identify the dependency on libstagefright.so through LOCAL_SHARED_LIBRARIES as well as including the header files, it should be more than sufficient for building your module. Please refer to this example of building a FLAC encoder where similar dependencies have been handled.

  3. By application, if you are referring to a Java application which interacts with a JNI layer, then point 2 should be more than sufficient. However, if you are creating a native layer application, I would recommend you to follow stagefright command line utility's makefile.

Ganesh
  • 5,880
  • 2
  • 36
  • 54
  • Thanks for your answer. I have tried it and I have updated my question with my make file. Please suggest the errors... – Kevin K Jun 20 '14 at 11:10
  • @androkid.. The error is because you are not including `frameworks/av/include`. Also it is recommended to employ something like `$(TOP)/frameworks/av/include`. If this doesn't work, please try `$(TOP)/frameworks/av/include/media/libstagefright`. Hope this helps !! – Ganesh Jun 20 '14 at 11:21
  • Thanks for the spot response...I included the header like this #include (also tried #include "DataSource.h") But to get the same error... – Kevin K Jun 20 '14 at 11:27
  • @androkid..can you please join this room: http://chat.stackoverflow.com/rooms/55977/ganeshtalks – Ganesh Jun 20 '14 at 11:41
  • The header DataSource.h is at $(TOP)/frameworks/base/include/media/stagefright/ I have added that too.. – Kevin K Jun 20 '14 at 11:41
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/55978/discussion-between-androkid-and-ganesh). – Kevin K Jun 20 '14 at 11:43