ffmpeg: libjniaudio on gingerbread

本文详细介绍了如何解决在Galaxy S设备上使用FFmpeg时遇到的音频库libjniaudio和视频库libjnivideo相关的问题。包括通过调整代码以兼容不同Android版本的音频跟踪和视频表面类的变化。
AI助手已提取文章相关产品:

Hi,

I tried to run the ffpmeg app on Galaxy S with v. 2.3.3. Issue#1was withlibjniaudio- due to change of signature of android::AudioTrack::set().

Follows my patch for audiotrack.cpp, functionAndroidAudioTrack_set():

status_t ret = NAME_NOT_FOUND;

void *lptr_media = dlopen("libmedia.so", 0);
__android_log_print(ANDROID_LOG_DEBUG, TAG, "dlopen returns %p", lptr_media);

if (lptr_media)         // first, try gingerbread
{
    status_t (*fptr_set)(AudioTrack* track,
                        int streamType,
                        uint32_t sampleRate,
                        int format,
                        int channels,
                        int frameCount,
                        uint32_t flags,
                        AudioTrack::callback_t cbf,
                        void* user,
                        int notificationFrames,
                        const sp<IMemory>& sharedBuffer,
                        bool threadCanCallJava,
                        int sessionId);

    fptr_set = (typeof fptr_set)dlsym(lptr_media, "_ZN7android10AudioTrack3setEijiiijPFviPvS1_ES1_iRKNS_2spINS_7IMemoryEEEbi");
    __android_log_print(ANDROID_LOG_DEBUG, TAG, "dlsym returns %p", fptr_set);

    if (fptr_set != 0)
    {
        ret = fptr_set(track,
                       streamType,
                       sampleRate,
                       format,
                       channels,
                       0, 0, 0, 0, 0, 0, 0, 0);
        __android_log_print(ANDROID_LOG_DEBUG, TAG, "fptr_set() returns %d", ret);
        dlclose(lptr_media);
        lptr_media = 0;
    }
}

if (lptr_media)         // second, try froyo
{
    status_t (*fptr_set)(AudioTrack* track,
                        int streamType,
                        uint32_t sampleRate,
                        int format,
                        int channels,
                        int frameCount,
                        uint32_t flags,
                        AudioTrack::callback_t cbf,
                        void* user,
                        int notificationFrames,
                        const sp<IMemory>& sharedBuffer,
                        bool threadCanCallJava);

    fptr_set = (typeof fptr_set)dlsym(lptr_media, "_ZN7android10AudioTrack3setEijiiijPFviPvS1_ES1_iRKNS_2spINS_7IMemoryEEEb");
    __android_log_print(ANDROID_LOG_INFO, TAG, "dlsym returns %p", fptr_set);

    if (fptr_set != 0)
    {
        ret = fptr_set(track,
                       streamType,
                       sampleRate,
                       format,
                       channels,
                       0, 0, 0, 0, 0, 0, 0); // push max number of parameters
        __android_log_print(ANDROID_LOG_INFO, TAG, "fptr_set() returns %d", ret);
        dlclose(lptr_media);
        lptr_media = 0;
    }
}

if (lptr_media)         // finally, close library anyway
{
    dlclose(lptr_media);
}




ffmpeg: libjnivideo on gingerbread

No milestone

No one is assigned

Hi,

I tried to run the ffpmeg app on Galaxy S with v. 2.3.3. Issue#2was withlibjnivideo- due to change of name of the native surface field inandroid/view/Surfaceclass.

Follows my patch forsurface.cpp, functiongetNativeSurface():


static Surface* getNativeSurface(JNIEnv* env, jobject jsurface) {
jclass clazz = env->FindClass("android/view/Surface");
jfieldID field_surface = env->GetFieldID(clazz, "mSurface", "I");
if(field_surface == NULL) {
#ifdef ANDROID_VIEW_SURFACE_JNI_ID // using gingerbread version of <surfaceflinger/Surface.h>
env->ExceptionClear();
field_surface = env->GetFieldID(clazz, ANDROID_VIEW_SURFACE_JNI_ID, "I");
#endif
}
if(field_surface == NULL) {
return NULL;
}
return (Surface *) env->GetIntField(jsurface, field_surface);
}

alexcohn, havlenapetr, and sunruiare participating in this issue.

hi, you should change the mSurface to mNativeSurface with under above 2.3.
BTW, how to compile with neon or vfp?

yes I know, better way will be add ifdef for OS version, neon or vfp support zou must set in config.h of ffmpeg, but I think that better way is compile ffmpeg with theirs makefiles and than use this libffmpeg.so like prebuilt library in android's project


您可能感兴趣的与本文相关内容

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值