Decoding h264 raw stream on Android 2.3.3

2.4k views Asked by At

I'm trying to decode a raw h264 stream on "older" Android versions. I've tried MediaPlayer class and does not seem to support the stream format.

I can see the stream on other Cam Viewer apps from the market, so I figure there must be a way to do it, probably using the NDK.

I've read about OpenMAX and Stagefright, but couldn't find a working example about streaming.

Could someone please point me in the right direction?

Also, I'm reading in several places about "frameworks/av/include/media/stagefright/MediaSource.h" and other sources, but they don't seem to be either in the regular SDK or the NDK. Where is this source located? is there another sdk?

Thanks in advance.

Update: I'm receiving a rtsp connection.

3

There are 3 answers

0
Ganesh On

If you wish to perform only a simple experiment to verify certain functionality, you can consider employing the command line stagefright utility. Please do consider this condition where your streaming input may not be supported.

If you wish to build a more comprehensive player pipeline, you can consider the handling for rtsp as in here or http as in here. Please note that NuCachedSource2 implementation is essential for streaming input as this provides a page cache implementation which acts as a jitter for the streaming data.

Please do note one critical point: Command line stagefright utility doesn't render to the screen. Hence, if you wish to render, you will to implement the complete playback pipeline with rendering.

On a related note, if your input is streaming input, the standard player implementation does have support for streaming inputs as can be observed here. Did you face any issues with the same?

As fadden has already pointed out, your work is made far more simpler with the introduction of MediaCodec in Android 4.x.

0
Alex Cohn On

Stagefright and OpenMAX IL were (and still are) internal components of Android. You can find the code (including MediaSource.h) at https://android.googlesource.com/platform/frameworks/av/+/master Note that the media framework has moved to a separate "tree" frameworks/av only recently. Before it was part of 'frameworks/base', e.g. https://android.googlesource.com/platform/frameworks/base/+/gingerbread/media/

3
LOG_TAG On

You should use third-party libs like android-h264-decoder which uses JNI for increasing the performance! Also look at this lib Intel

Update: Media codec wasn't exposed until API 16 (Android 4.1), so that won't work for a 2.3.3 device.