1

Is there any sample code which gives me an idea about how to access StageFright API's to decode h264 video as well as Rendering the Decoded data (which will be in YUV420 ) using Surfaceflinger APIs from application layer on Android (GB,ICS).

Prashant
  • 39
  • 1
  • 8

1 Answers1

0

In standard android distribution, there is a command line utility also called stagefright at frameworks\base\cmds\stagefright (ICS) which will perform a command line based standalone decoding.

If you wish to decode and display the data on a Surface, then you need to create a MediaPlayer which is a higher level of abstraction above Stagefright framework. You can set a specific Surface through the SetVideoSurface method of the MediaPlayer.

Ganesh
  • 5,880
  • 2
  • 36
  • 54
  • Thanks for Reply Ganesh. Actually i have my own rtsp stack and my java application which capture and record the video data .Now my question here I am getting h264 video and and aac audio data so now i want decode and display the data from my rtsp stack directly and rendering on the surface using my Java application. My rtsp stack is in jni of my application. So I wanted the access the Decoder and Renderer for this. If u know any kind of solution just let me know....!!! Thanks in Advance – Prashant Feb 19 '13 at 07:19
  • 1
    If you are getting the `RTSP` data at `Java` level, I feel you can convert your source as `MediaSource` for the `MediaPlayer`. I would recommend you to kindly refer to `NuPlayer` implementation which actually implements a streaming player. – Ganesh Feb 19 '13 at 15:23
  • Hi Ganesh Can you have any idea for this . Means How to use Streaming player from my jni code . any reference link.Thanks in advance. Actually i want to play video and audio through rtsp in ICS android. i want implement some workaround to play rtsp stream. – Prashant Mar 05 '13 at 15:59
  • @Prashant .. you could refer to this question http://stackoverflow.com/questions/15152172/mediaplayer-change-datasource-error-when-mediaplayer-complets-playing-first-audi This has an example which could provide you with a ready example. You could also refer to http://developer.android.com/reference/android/media/MediaPlayer.html to know more. – Ganesh Mar 05 '13 at 16:45
  • Thanks for reply Ganesh..Actually i want some wrapper or workaround in C or CPP which will take url and in this program i will use set of API's for stream. – Prashant Mar 05 '13 at 16:55
  • @Prashant If you want a pure codec interface without any other parts of player engine, you could look at `MediaCodec` native implementation http://androidxref.com/4.2_r1/xref/frameworks/av/media/libstagefright/MediaCodec.cpp . On the other hand, if you want to create a player that takes a URL as input to play, please refer to http://androidxref.com/4.2_r1/xref/frameworks/av/media/libmediaplayerservice/nuplayer/NuPlayer.cpp, specifically http://androidxref.com/4.2_r1/xref/frameworks/av/media/libmediaplayerservice/nuplayer/NuPlayer.cpp#117 .. Hope this helps – Ganesh Mar 06 '13 at 00:03
  • hi Thank you very much for your support. if there is any sample application you know so i can get actual info..for this ..i want to use this Nuplayer apis in my application JNI code ....this kind of sample is there then it will be very very helpful for me....Thanks in Advance..:) – Prashant Mar 06 '13 at 09:33
  • @Prashant If you wish to include `NuPlayer` in the native code i.e. below the JNI layer, you can create an instance directly. I feel the easiest way is to include an object of `MediaPlayer` which internally will create the `NuPlayer`. For `MediaPlayer` integration in JNI level, you could refer to http://androidxref.com/4.2.2_r1/xref/frameworks/base/media/jni/android_media_MediaPlayer.cpp . Hope this helps :-) – Ganesh Mar 07 '13 at 03:09
  • Hi Ganesh ..Thank u very much. its really helps to me.i have one doubt actually i wanted to build this jni(my_android_player.cpp) & my app(.java) files with ICS AOSP. where should i put this (In system app folder or /framework/base/media/).and (I am just using all jni call from android_mediaplayer.cpp file in my application).if u know any thing on this ...it will be very helpful to me ..actually i am very new to this kind things in android.Thanks in Advance – Prashant Mar 08 '13 at 07:33
  • @Prashant In case of ICS, you can place your JNI implementation at `frameworks/base/media/jni/`. For further details, you can refer to http://androidxref.com/4.0.4/xref/frameworks/base/media/jni/ – Ganesh Mar 08 '13 at 16:01