直接访问StageFright.so以从Android中的JNIlayer解码H.264流 [英] Access StageFright.so directly to decode H.264 stream from JNIlayer in Android

查看:85
本文介绍了直接访问StageFright.so以从Android中的JNIlayer解码H.264流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Android 2.3或更高版本上,是否可以直接访问libstagefright.so以便从JNI层解码H.264流?

Is there a way to access libstagefright.so directly to decode H.264 stream from JNI layer on Android 2.3 or above?

推荐答案

如果您的目标是解码基本H.264流,则您的代码将必须确保提取了该流,将codec-specific-data提供给向编解码器提供主要是SPSPPS数据和帧数据以及时间戳的编解码器.在所有Android版本中,最常见的接口是OMXCodec,它是对基础OMX组件的抽象.

If your objective is to decode an elementary H.264 stream, then your code will have to ensure that the stream is extracted, the codec-specific-data is provided to the codec which is primarily SPS and PPS data and frame data along with time-stamps is provided to the codec. Across all Android versions, the most common interface would be OMXCodec which is an abstraction over an underlying OMX component.

在Gingerbread(Android 2.3)和ICS(Android 4.0.0)中,如果要创建解码器,最好的方法是创建OMXCodec组件并通过MediaSource接口抽象代码,即您的包装器代码被建模为MediaSource,并且OMXCodec 从该来源读取并执行解码.

In Gingerbread (Android 2.3) and ICS (Android 4.0.0), if you would like to create a decoder, the best method would be to create an OMXCodec component and abstract your code through a MediaSource interface i.e. your wrapper code is modeled as MediaSource and OMXCodec reads from this source and performs the decoding.

链接到Android 2.3视频解码器的创建: http://androidxref.com/2.3.6/xref/frameworks/base/media/libstagefright/AwesomePlayer.cpp#1094

Link to Android 2.3 Video decoder creation: http://androidxref.com/2.3.6/xref/frameworks/base/media/libstagefright/AwesomePlayer.cpp#1094

链接到Android 4.0.0视频解码器的创建:

Link to Android 4.0.0 Video decoder creation: http://androidxref.com/4.0.4/xref/frameworks/base/media/libstagefright/AwesomePlayer.cpp#1474

主要挑战如下:

  1. 将输入建模为MediaSource.

读取包装器代码以从编解码器读取缓冲区并处理该缓冲区,然后将其释放回编解码器.

Read a wrapper code to read the buffer from the codec and handle the same and release it back to the codec.

为简单起见,您可以查看stagefright命令行可执行代码,如

For simplification, you could look stagefright command line executable code as in http://androidxref.com/4.0.4/xref/frameworks/base/cmds/stagefright/stagefright.cpp#233

但是,如果您的程序基于JellyBean(Android 4.1.x,4.2.x)及更高版本,则这些程序会稍微简化一些.从您的JNI代码中,您可以创建一个MediaCodec组件并将其用于解码.要将其集成到程序中,可以引用SimplePlayer实现,如

However, if your program is based on JellyBean (Android 4.1.x, 4.2.x) onwards, then these are slightly more simplified. From your JNI code, you could create a MediaCodec component and employ the same for decoding. To integrate the same into your program, you could refer to the SimplePlayer implementation as in http://androidxref.com/4.2.2_r1/xref/frameworks/av/cmds/stagefright/SimplePlayer.cpp#316

这篇关于直接访问StageFright.so以从Android中的JNIlayer解码H.264流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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