Android:如何将解码器集成到多媒体框架中 [英] Android: How to integrate a decoder to multimedia framework
问题描述
最近我成功地将视频解码器移植到了 android.还将输出转储到表面视图上,并使用本机 API 检查输出.现在下一个任务是实现播放、暂停、流式传输等,即媒体播放器的其他功能.这样做将是一项返工,因为所有这些功能都已在 android 多媒体框架中定义.听说可以把我们的解码器做成插件,集成到Android的多媒体框架中.虽然我用谷歌搜索了相同的信息,但我几乎找不到任何关于相同的信息.所以我恳请任何读者为上述问题提出一些相关链接或解决方案.提前致谢,等待您的回复.
Recently i have ported a video decoder to android successfully. Also dumped the output on a surfaceview and checked the output using native API's. Now the next task is to implement play, pause, streaming etc. i.e. the other features of the media player. Doing this will be a rework as all these functionalities are already defined in the android multimedia framework. I heard that we can make our decoder as a plug-in and integrate it into Android's multimedia framework. Although i googled regarding the same, i could hardly find any info regarding the same. So i kindly request any of the readers to suggest some relavent links or solution for the above problem. Thanks in advance, waiting for your reply.
推荐答案
在Android SF框架中,编解码器通过media_codecs.xml
注册.在标准的 android 发行版中,可以找到一个示例 media_codecs.xml
此处.所有视听组件都注册为 OMX
组件.
In Android SF framework, the codecs are registered through media_codecs.xml
. In standard android distribution, an example media_codecs.xml
can be found here. All audio-visual components are registered as OMX
components.
1.编解码器注册
要注册您的视频解码器,您必须在
列表下添加一个新条目.为确保您的编解码器始终被选中,请确保您的编解码器被列为特定 MIME
类型的第一个条目.H.264 解码器的示例条目如下所示.
To register your video decoder, you would have to add a new entry under <Decoders>
list. To ensure that your codec is always picked up, please ensure that your codec is listed as the first entry for the specific MIME
type. An example entry for a H.264 decoder could be as below.
<Decoders>
<MediaCodec name="OMX.ABC.XYZ.H264.DECODER" type="video/avc" >
<Quirk name="requires-allocate-on-input-ports" />
<Quirk name="requires-allocate-on-output-ports" />
</MediaCodec>
<MediaCodec name="OMX.google.h264.decoder" type="video/avc" />
哪里,
a.OMX.ABC.XYZ.H264.Decoder
是你的组件名称
B.video/avc
是组件的 MIME
类型.在此示例中,它表示 AVC/H.264 视频解码器.
b. video/avc
is the MIME
type of your component. In this example, it denotes a AVC / H.264 video decoder.
c.接下来的 2 条语句表示您的组件的quirks
或特殊要求.在给定的示例中,requires-allocate-on-input-ports
向 Stagefright
框架指示组件更喜欢在其所有输入端口上分配缓冲区.类似地,另一个 quirk
通知组件也将更喜欢在其输出端口上进行分配.系统支持的quirks
列表可以参考OMXCodec.cpp 文件.这些怪癖转化为标志,然后框架读取这些标志以创建和初始化组件.
c.The next 2 statements denote the quirks
or special requirements of your components. In the given example, requires-allocate-on-input-ports
indicates to the Stagefright
framework that the component prefers to allocate the buffers on all it's input ports. Similarly, the other quirk
is informing that the component will also prefer to allocate on it's output ports. For a list of supported quirks
in the system, you could refer to the function OMXCodec::getComponentQuirks
in OMXCodec.cpp file. These quirks translate into flags which are then read by the framework to create and initialize the components.
在示例插图中,您的 OMX
组件在 Google 实施的默认视频解码器之前注册.
In the example illustration, it is shown that your OMX
component is registered prior to the default Google implemented video decoder.
注意:如果您在终端设备上尝试此操作,则必须确保此条目反映在最终的
NOTE: If you trying this on an end device, you will have to ensure that this entry is reflected in the final media_codecs.xml
file.
2.OMX 核心注册
要创建您的组件并确保调用正确的工厂方法,您可能使用注册您的
框架.OMX
核心>怯场
To create your component and ensure that the correct factory method is invoked, you may have to register your OMX
Core with the Stagefright
framework.
要注册新内核,您必须创建一个名为 libstagefrighthw.so
的新库,该库位于终端系统中的 /system/lib
.该库必须公开一个 createOMXPlugin
符号,该符号将由 dlsym
查找.
To register a new core, you will have to create a new library named libstagefrighthw.so
which will be located at /system/lib
in your end system. This library will have to expose a createOMXPlugin
symbol which will be looked by dlsym
.
OMX
核心的注册是这样的:OMXMaster
调用 addVendorPlugin
,后者在内部调用 addPlugin("libstagefrighthw.so")代码>.在
addPlugin
中,将查找 createOMXPlugin
使用它初始化 makeComponentInstance
、destroyComponentInstance
等的其他函数指针.
The registration of the OMX
core is thus: OMXMaster
invokes addVendorPlugin
which internally invokes addPlugin("libstagefrighthw.so")
. In addPlugin
, the createOMXPlugin
will be looked up using which the other function pointers for makeComponentInstance
, destroyComponentInstance
etc are initialized.
一旦 OMX
核心被初始化,您就可以在 android 框架中运行您自己的组件了.OMXMaster
的参考可以在 此处.
Once the OMX
core is initialized, you are ready to run your own your component within the android framework. The reference for OMXMaster
can be found here.
通过这些更改,您的视频解码器已集成到 android stagefright 框架中.
With these changes, your video decoder is integrated into the android stagefright framework.
这篇关于Android:如何将解码器集成到多媒体框架中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!