UDP or RTP streaming solution for android

Omriko picture Omriko · May 10, 2012 · Viewed 16.2k times · Source

I need to create an android app to display a live TV feed. the app is supposed to play live video streams from a Multicast of a DVB gateway, according to the gateway vendor it can stream out UDP or RTP. I set up vlc on my computer to stream out UDP and RTP and broke my fingers trying to get the android player to show them. after a while I found out that android only supports HTTP/S and RTSP live streams. I tried all the FFMPEG solutions and different media players with no success yet. I am not a video expert but to my understanding RTSP is an encapsulation of RTP, can my RTP feed be wrapped and streamed (even via proxy) ? does anyone know of a working UDP solution ?

thanks

I started writing a tunnel that passes a local UDP stream from port 1234, to a TCP connection on port 8888. I am testing with VLC, the UDP payload looks correct, and I am able to see the VLC init the http connection when I wait for the TCP listener to accept the connection. but still VLC wont play the resulting HTTP stream, my code:

public void Bridge()
    {
        //endpoints
        IPEndPoint myRemoteEndpoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 1234);

        //communications objects
        UdpClient myUdpClient = new UdpClient(myRemoteEndpoint);
        TcpListener myTcpListener = new TcpListener(IPAddress.Any, 8888);

        //buffer
        byte[] buffer = new byte[2048];

        //start tcp listener
        myTcpListener.Start();
        Socket tcpAcceptedSocket = myTcpListener.AcceptSocket();            

        while (true)
        {
            try
            {
                //get data from UDP client
                buffer = myUdpClient.Receive(ref myRemoteEndpoint);

                //send bytes received from UDP over TCP
                tcpAcceptedSocket.Send(buffer);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }

        //close sockets
        myUdpClient.Close();
        myTcpListener.Stop();

    }

any thoughts ?

Answer

CodeShane picture CodeShane · Nov 16, 2012

Hopefully you've solved this already?

My first thought was "how do you exit that while (true) loop?" lol

RTP was added to the Android SDK in API level 12:

http://developer.android.com/reference/android/net/rtp/package-summary.html

Perhaps you can use android.net.rtp to catch your streaming video. There seems to be a significant lack of tutorials in this area, so if you did/do get this working I'm sure a quick write-up could fly up the big G search results; not to mention helping out the posters of 600+ other questions on stackoverflow that come up in an "android udp rtp" search.

From the blog-o-sphere:

http://burcudogan.com/2011/06/05/android-rtp-implementation-is-based-on-udp/

And I'll toss in a plug for WebRTC because it looks promising:

http://www.html5rocks.com/en/tutorials/webrtc/basics/