Search code examples
androidandroid-ndkffmpegstagefright

stagefright for ffmpeg: undefined symbol '_ZTIN7android11MediaSourceE'


all... I want to try ffmpeg hw accelerate with libstagefright_h264 for android device. Seems that the source code has a little bit old with ffmpeg 2.2.1 and android 4.2.2. So I try to update the source code but when I only write just a little code like following:

struct FFSource : public MediaSource {                                                                                   
    virtual status_t start(MetaData *params) { return -1; }                      
    virtual status_t stop() { return -1; }                                        
    virtual sp<MetaData> getFormat() { return sp<MetaData>(); }                  
    virtual status_t read(                                                                                               
            MediaBuffer **buffer, const ReadOptions *options) { return -1; }     
};

static av_cold int Stagefright_init(AVCodecContext *avctx)                                                            
{                                                                                                                        
    av_log(avctx, AV_LOG_ERROR, "In function: %s\n", __FUNCTION__);                                                      
    FFSource *decoder;                                                                                                   
    sp<MediaSource> mediaSource;

    decoder = new FFSource();                                                        
    return -1;
}

it tells me like following when I run the code: cannot locate symbol "_ZTIN7android11MediaSourceE" referenced by "libavcodec-55.so"...

And the result show the nm command for libavcodec-55.so:

[cxm@ubuntu ffmpeg-2.2.1.lsc]$nm ./libavcodec/libavcodec.so  | grep Source

003a31a8 t _ZN7android11MediaSource10setBuffersERKNS_6VectorIPNS_11MediaBufferEEE
003a319c t _ZN7android11MediaSource5pauseEv
         U _ZN7android11MediaSourceC2Ev
         U _ZN7android11MediaSourceD0Ev
         U _ZN7android11MediaSourceD1Ev
         U _ZN7android11MediaSourceD2Ev
003a31d0 t _ZN8FFSource4readEPPN7android11MediaBufferEPKNS0_11MediaSource11ReadOptionsE
003a31bc t _ZN8FFSource4stopEv
003a31b4 t _ZN8FFSource5startEPN7android8MetaDataE
003a31c4 t _ZN8FFSource9getFormatEv
003a3340 t _ZN8FFSourceD0Ev
003a32e0 t _ZN8FFSourceD1Ev
007b29f0 d _ZTC8FFSource0_N7android11MediaSourceE
007b29e0 d _ZTI8FFSource
         U _ZTIN7android11MediaSourceE
006ac028 r _ZTS8FFSource
007b2970 d _ZTT8FFSource
         U _ZTv0_n12_N7android11MediaSourceD0Ev
         U _ZTv0_n12_N7android11MediaSourceD1Ev
003a3330 t _ZTv0_n12_N8FFSourceD0Ev
003a32d0 t _ZTv0_n12_N8FFSourceD1Ev
007b2980 d _ZTV8FFSource

Also I cannot find _ZTIN7android11MediaSourceE in libstagefright.so. I think there's any mistake I have in writing the source code instead of mis-link the stagefright library. I use android standalone toolchain to compile ffmpeg source. Like following configuration:

    function config_lsf                                                                                                                                                                             
    {
        # build flags                                                                                                                                                                               
        PREFIX=/home/cxm/work/Android/proj/dy-proj-careye/dy-proj-careye/jni/src/lib/android/            FLAGS="--prefix=$PREFIX"                                                                                                                                                                    
        FLAGS="$FLAGS --disable-static"                                                                                                                                                             
        FLAGS="$FLAGS --disable-doc"                                                                                                                                                                
        FLAGS="$FLAGS --disable-programs"                                                                                                                                                           
        FLAGS="$FLAGS --disable-avdevice"                                                                                                                                                           
        FLAGS="$FLAGS --disable-symver"                                                                                                                                                             
        FLAGS="$FLAGS --enable-shared"                                                                                                                                                              
        FLAGS="$FLAGS --cross-prefix=arm-linux-androideabi-"                                                                                                                                        
        FLAGS="$FLAGS --target-os=linux"                                                                                                                                                            
        FLAGS="$FLAGS --arch=arm"                                                                                                                                                                   
        FLAGS="$FLAGS --enable-cross-compile"                                                                                                                                                       

        FLAGS="$FLAGS --disable-decoder=h264"                                                                                                                                                       
        FLAGS="$FLAGS --disable-decoder=h264_vdpau"                                                                                                                                                 
        FLAGS="$FLAGS --enable-libstagefright-h264"                                                                                                                                                 

        # cflags                                                                                                                                                                                    
        CFLAGS="-Os -fpic -marm"                                                                                                 
        ANDROID_SOURCE=../mokesoures/                                                                                                                                                               
        ANDROID_LIBS=../android-libs                                                                                                                                                                
        CFLAGS="$CFLAGS -I$ANDROID_SOURCE/frameworks/av/include"                                                                                                                                    
        CFLAGS="$CFLAGS -I$ANDROID_SOURCE/frameworks/native/include/"                                                                                                                               
        CFLAGS="$CFLAGS -I$ANDROID_SOURCE/system/core/include"                                                                                                                                      
        CFLAGS="$CFLAGS -I$ANDROID_SOURCE/hardware/libhardware/include"                                                                                                                             
        CFLAGS="$CFLAGS -I$ANDROID_SOURCE/frameworks/native/include/media/openmax/"                                                                                                                 

        # ld flags                                                                                                                                                                                  
        LDFLAGS="-Wl,--fix-cortex-a8"                                                                                                                                                               
        LDFLAGS="$LDFLAGS -lstdc++ -lgnustl_shared -lstagefright -lutils -lbinder"                                                                                                                  
        LDFLAGS="$LDFLAGS -L$ANDROID_LIBS"                                                                                                                                                          
        LDFLAGS="$LDFLAGS -Wl,-rpath-link,$ANDROID_LIBS"                                                                                                                   

        ./configure.android $FLAGS --extra-cflags="$CFLAGS" \                                                                                                                                       
            --extra-ldflags="$LDFLAGS" \                                                                                                                                                            

        sed -i 's/#define\ HAVE_POSIX_MEMALIGN\ 1/#define\ HAVE_POSIX_MEMALIGN\ 0/' ./config.h                                                                                                      
        make -j4 V=1 2>&1 | tee log                                                                                                                                                                 
        make install                                                                                                                                                                                
    }                                                                                                                                                                                               

Please help about this topic. Thanks very much.


Solution

  • _ZTIN7android11MediaSourceE is typeinfo for android::MediaSource. You probably have -frtti enabled in your build configuration, but Android libraries do not include run-time type information; so, you should remove this flag at least from FFSource class.