Android RTSP Client

with 2 Comments

Android RTSP Client
I mentioned in a previous post how Android makes it easy to stream from an RTSP source. There was a small amount of interest in exactly how this was accomplished, so here is a quick and dirty example.

AndroidRTSP

Read on for a quick walk-through of the code.

1) Create An Android Project

Just use the defaults for everything and set it to build against API Level 10 (Android 2.3.3). I’m sure it will work with a more up to date version of Android, but this is what I tested with and it worked for me.

2) Edit activity_main.xml

 

 

3) Edit MainActivity.java

 

 

4) Create a RTSP Test Source

There seems to be a lot of issues around the Interwebs with regard to RTSP and Android, but I ‘think’ these are mostly CODEC related. You can find more information about Android supported media formats in the [Android developer docs](http://developer.android.com/guide/appendix/media-formats.html)

Originally, I tested this app with the H264 RTSP stream I blogged about earlier. It didn’t work. Errors were thrown back at me telling me “can not play video” or something to that effect. So to get it to work I switched from H264 to MPEG4-SP. To create the test source, use the code in the previous RTSP post with the following modifications to the streamer pipeline.

 

Thats all folks

Hopefully you should be streaming some fantastically rendered video test patterns to your Android device right about now.
Now make it interesting and change that first pipeline element to a v4l2src or something more useful. See ya!