如何设置音频流与MediaExtractor和媒体codeC? [英] How to set up Streaming audio with MediaExtractor and MediaCodec?

查看:493
本文介绍了如何设置音频流与MediaExtractor和媒体codeC?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想流进来的AMR_NB。我不能使用MediaPlayer的直接,因为它需要一个可搜索文件。我想用媒体codeC,而是利用媒体codeC,我需要(我想...请指正!)MediaExtractor给我的东西像presentationTime。真的吗?我可以使用媒体codeC不MediaExtractor?

I am trying to stream incoming AMR_NB. I can't use MediaPlayer directly because it requires a seekable file. I would like to use MediaCodec, but to use MediaCodec I need (I think... please correct me!) MediaExtractor to give me things like the presentationTime. Is that true? Can I use MediaCodec without MediaExtractor?

MediaExtractor似乎需要可搜索的文件。该文件只特别说这样的的setDataSource的操作之一,但是当我试图用任何其他的就失败,因为失败的尝试寻求。

MediaExtractor seems to require seekable files. The documentation only specifically says so for one of the setDataSource operations but when I tried to use any of the others it failed due to failed seek attempts.

所以,我能做些什么让我进来的AMR流玩?我知道一个计划,通过你输入的数据保存到一个文件中,并定期制作该文件的副本喂到的MediaPlayer,但我真的preFER找到一个真正诚实的流媒体解决方案。

So, what can I do to get my incoming AMR stream to play? I am aware of a scheme where by you save incoming data to a file and periodically make a copy of that file to feed to MediaPlayer but I'd really prefer to find a real honest streaming solution.

是否可以使用Media codeC不使用MediaExtractor?如果是的话我怎么发现presentation时间,并传递给媒体codec.createDe coderByType字符串?该文件称,音频/ 3GPP是什么,但我想,当我尝试使用我收到以下错误:

Is it possible to use MediaCodec without using MediaExtractor? If so how do I find presentation time and the string to pass to MediaCodec.createDecoderByType? The documentation SAYS that "audio/3gpp" is what I want but when I attempt to use that I get the following error:

codec = MediaCodec.createDecoderByType("audio/3gpp");

01-02 03:59:36.980: E/OMXMaster(21605): A component of name 'OMX.qcom.audio.decoder.aac' already exists, ignoring this one.

所以,我不知道如何得到媒体codeC无论是。

So I'm not sure how to get at MediaCodec either.

推荐答案

我不能用MediaPlayer的直接,因为它需要可搜索的文件,这不是一般的事实。我想你想试试你的信息流,并报告究竟发生了什么。

"I can't use MediaPlayer directly because it requires a seekable file" This is not generally true. I would like you to try it on your stream and report exactly what happens.

我可以使用媒体codeC不MediaExtractor?我对此表示怀疑:我认为,他们的目的是一起使用。

"Can I use MediaCodec without MediaExtractor?" I doubt it: I believe they are designed to be used together.

我已经使用这些组件来播放流媒体。然而,MediaExtractor具有不记录限制(据我所知)。因此,用一个小的代理服务器来喂它东西它可以消化。我有1个线程来运行MediaExtractor,另一把输出从媒体codeC。然后,我必须避免死锁和应对同步研究。但它不是那么糟糕只要你只想前锋只玩。然后,你如何只停止的问题!

I have used these components to play streams. However, the MediaExtractor has limitations that are not documented ( as far as I know ). So use a little proxy server to feed it things it can digest. And I have 1 thread to run the MediaExtractor and another to take output from the the MediaCodec. Then i have to avoid deadlocks and cope with snchronization. But it is not that bad provided you just want to play forwards only. Then you have only the problem of how to stop!

我建议你尝试MediaPlayer的第一位。否则,如果你是热衷足够的尝试MediaExtractor,我们可以分享我们的发现是什么会和不会消化。不要想当然。例如,它似乎会发挥出自己的MP3文件,但无法发现它们的持续时间,或寻求对他们!

I advise that you try MediaPlayer first. Otherwise, if you are keen enough to try the MediaExtractor, we could share our discoveries about what it will and wont digest. Don't take anything for granted. For example it seems it will play my MP3 files, but cannot discover their duration, or seek on them!

这篇关于如何设置音频流与MediaExtractor和媒体codeC?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆