Search code examples
androidrtspandroid-mediacodec

How to use MediaCodec to decode data from RTSP server?


I tried setDataSource() in MediaExtractor class but it doesn't work with RTSP path. I can use the same path with MediaPlayer class and it works but it is very important for me to use MediaCodec class instead. I think Android doesn't have any RTSP API I could use nor I can find any RTSP libraries for Android.

Is there a relatively easy way of feeding video stream from RTSP server into MediaCodec class?


Solution

  • No easy way. I ended up using this project:

    https://code.google.com/p/android-rtsp-client/

    for RTSP protocol (worked after some fixes and modifications).

    I needed to implement RTP and RTCP protocols myself (some simplified versions were enough in my case).

    I also needed to create a code for extracting NAL units from RTP packets. I had to read this first:

    http://www.ietf.org/rfc/rfc3984.txt

    to figure out how to do that.