“钩子”用于 iPhone 流媒体的 libMMS 到 FFmpeg
这几天在研究iPhone Streaming(基于MMS协议)的软件架构。
我们知道,为了播放MMS音频流,我们应该调用libMMS从远程媒体服务器读取wma流数据,然后调用FFmpeg将wma格式的流数据解码到PCM数据缓冲区,最后将PCM数据入队缓冲到 iPhone 的音频队列中以生成真实的声音。
上面的介绍只是描述了iPhone Streaming的工作过程。如果我们只需要实现这个简单的功能,那并不困难。只需按照上面的介绍逐步调用libMMS、FFMpeg和audioqueue,就可以实现流媒体功能。事实上,我上周已经实现了该代码。
但是,我需要的不仅仅是一个简单的流媒体功能!我需要一个软件架构使 FFmpeg 访问 libMMS 就像访问本地文件系统一样!
有人知道如何将 libMMS 接口(如 mms_read/mms_seek)连接到 FFmpeg 文件系统接口(如 av_read_frame/av_seek_frame)吗?
These days, I was researching the software architechture for iPhone Streaming (Base on MMS protocol).
As we know, in order to playback MMS audio stream, we should call libMMS to read wma stream data from remote media server, and then call FFmpeg to decode the stream data from wma format into PCM data buffer, and finally, enqueue the PCM data buffer into iPhone’s audioqueue to generate real sound.
The introduction above just describe the working process of iPhone streaming. If we only need to implement this simple functionality, that is not difficult. Just follow the introduction above to call libMMS, FFMpeg and audioqueue step by step, we can achieve the streaming function. Actually, I have implemented the code last week.
But, what I need is not only a simple streaming function! I need a software architechture makes FFmpeg accessing libMMS just like accessing local filesystem!
Does anybody know how to hook the libMMS interfaces like mms_read/mms_seek onto FFmpeg filesystem interfaces like av_read_frame/av_seek_frame?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想这次我必须再次回答我自己的问题了……
经过几周的研究和调试,我终于得到了真相。
实际上,我们不需要将 libMMS“挂钩”到 FFMpeg 上。为什么?因为FFMpeg已经有它的原生mms协议处理模块“mms_protocol”(见FFMpeg中的mms_protocol.c)。
我们需要做的只是配置 FFMpeg 以启用 mms 模块,如下所示(请参阅 FFMpeg 中的 config.h):
完成此配置后,FFMpeg 会将 mms 协议添加到其协议列表中。 (实际上,协议列表中已经包含了“本地文件系统协议”)。因此,FFMpeg 可以像本地媒体文件一样对待“mms://hostserver/abc”媒体文件。因此,我们仍然可以使用以下命令打开并读取mms媒体文件:
就像我们之前对本地媒体文件所做的那样!
顺便说一下,在我的ffmpeg版本中,用于处理mms协议的libAVFormat模块仍然存在很多错误。我花了一周的时间来调试它,但是,我认为对于像你这样聪明的人来说,它会短得多:-)
I think I have to answer my own question again this time……
After several weeks reseach and debuging, I got the truth finally.
Actually, we don’t need to “hook” libMMS onto FFMpeg. Why? Because the FFMpeg already has its native mms protocol process module “mms_protocol” (see in mms_protocol.c in FFMpeg).
All we need to do is just configuring the FFMpeg to enable the mms module like this (see in config.h in FFMpeg):
After this configuration, FFMpeg will add mms protocol into its protocol list. (Actually, the protocol list has already contained “local file system protocol”). As result, the FFMpeg could be able to treat the “mms://hostserver/abc” media file like local media file. Therefore, we can still open and read the mms media file using:
like we did on local media file before!
By the way, in my ffmpeg version, there are still many bugs in libAVFormat module for proccessing mms protocol. It took one week for me to debug it, however, I think it will be much shorter for the guy as smart as you:-)