Android设备上的gstreamer-java + gstreamer_ndk_bundle + JNA无法播放声音文件?

时间:2012-06-29 21:47:20

标签: android gstreamer jna java-gstreamer

我为平台8,10和13构建了gstreamer_ndk_bundle,没有任何错误和问题。现在我正在努力让gstreamer-java在android上工作,我想我已经把它做成了 work 。 JNA工作得很好(在我的lib上测试过),我已经将所有缺少的Structure.setFieldOrder()调用添加到gstreamer-java代码中,删除了Android上不存在的所有类和包,并且它在模拟器上编译和运行。另外,我在该平台模拟器上使用了为特定平台编译的gstreamer库。

我使用此代码播放Mp3文件:

File file = new File(getExternalFilesDir(null),"demo_tunes.mp3" );

try 
{
    InputStream is = getResources().openRawResource(R.raw.test);
    OutputStream os = new FileOutputStream(file);
    byte[] data = new byte[is.available()];
    is.read(data);
    os.write(data);
    is.close();
    os.close();
} 
catch (IOException e) 
{
    Log.w("ExternalStorage", "Error writing " + file, e);
}

Gst.init("AudioPlayer", new String[]{"--gst-plugin-path=/data/data/org.gstreamer.marko/lib"});

Pipeline pipe  = new Pipeline("PipeLine"); 
Element src = ElementFactory.make("filesrc","Input File"); 
src.set("location", file.getAbsolutePath()); 
Element decode = ElementFactory.make("decodebin2", "Decode");
Element sink = ElementFactory.make("audioflingersink", "Sink");
pipe.addMany(src, decode, sink); 
Element.linkMany(src, decode, sink);

pipe.play();

所有需要的lib及其依赖项都加载如下:

static
{

    System.loadLibrary("glib-2.0");
    System.loadLibrary("gmodule-2.0");
    System.loadLibrary("gthread-2.0");
    System.loadLibrary("gobject-2.0");
    System.loadLibrary("gstreamer-0.10");

    //Libraries for base plugins
    System.loadLibrary("gstbase-0.10");
    System.loadLibrary("gstpbutils-0.10");          
    System.loadLibrary("gstinterfaces-0.10");
    System.loadLibrary("gstvideo-0.10");
    System.loadLibrary("gstplaybin");

    //Base plugins
    System.loadLibrary("gstcoreelements");
    System.loadLibrary("gstautodetect");

    System.loadLibrary("gsttag-0.10");
    System.loadLibrary("gstaudio-0.10");
    System.loadLibrary("gstriff-0.10");
    System.loadLibrary("ogg");
    System.loadLibrary("gstogg");
    System.loadLibrary("gstaudioflinger");
    System.loadLibrary("mad");
    System.loadLibrary("gstmad");

    System.loadLibrary("gstdecodebin2");
    System.loadLibrary("gstautodetect"); 
}

App运行,但我没有听到任何声音!此外,我试图为这样的所有流最大化设备的音量,但也没有声音:

        AudioManager audman = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
        audman.setStreamVolume(AudioManager.STREAM_MUSIC, audman.getStreamMaxVolume(AudioManager.STREAM_MUSIC), 0);
        audman.setStreamVolume(AudioManager.STREAM_SYSTEM, audman.getStreamMaxVolume(AudioManager.STREAM_SYSTEM), 0);
        audman.setStreamVolume(AudioManager.STREAM_DTMF, audman.getStreamMaxVolume(AudioManager.STREAM_DTMF), 0);

在Log cat输出中,我可以看到创建了audioflinger接收器,但没有声音:

06-29 20:07:09.407: GstAudioFlingerSink(462): gst_audioflinger_sink_getcaps,0x0
06-29 20:07:09.434: GstAudioFlingerSink(462): creating ringbuffer
06-29 20:07:09.434: GstAudioFlingerSink(462): created ringbuffer @0x1fc810
06-29 20:07:09.447: GstAudioFlingerSink(462): >gst_android_audioringbuffer_open_device
06-29 20:07:09.447: GstAudioFlingerSink(462): gst_audioflinger_sink_open
06-29 20:07:09.447: audioflinger_wrapper(462): Create AudioTrack successfully 0x1f6e70
06-29 20:07:09.447: GstAudioFlingerSink(462): create a new flinger, 0x1f6e70

我缺少什么?我也尝试使用PlayBinPlayBinMediaPlayer并尝试使用OGG文件,也运行,但没有声音......

0 个答案:

没有答案