Streaming from an Android Phone

Topics: Question
May 10, 2015 at 5:26 PM
So I think I am getting to where I can start coding my streaming application but some examples would be greatly appreciated. I need the phone application to be able to point to the streaming server I am creating and then stream the video/audio over RTSP/TCP to the server.

At the server I want to be able to capture the incoming streams and redirect them back out but also redirect them to be saved to disk. I figure that means cloning the incoming packets and redirecting them to separate threads, one that streams them back out and the second the adds the packets to the file(s) on disk.

Based on looking at the TestServer() method in the UnitTests project I would be adding an RtspSource for each phone that is sending in streamed video using a stream as the source (not sure how to do that at the moment). The incoming video is MP4 as far as I can tell.

Any direction you can provide will be much appreciated.
Coordinator
May 10, 2015 at 6:18 PM
It seems like you have your direction, if you run into a specific issue let me know.

Thanks for your interest in the library!
Marked as answer by juliusfriedman on 5/10/2015 at 10:18 AM
May 21, 2015 at 5:51 AM
Julius: Ok so I have a test Android program that is using sockets to stream the video output from the phone to a small test program on my laptop. I am saving the buffer to a file. When I look at the file output it has the normal characteristics of a streaming buffer where the header has basically not been filled in.

I need to make the next step to integrate your code into both ends of this equation. Does the library help me fill in the missing pieces of this puzzle. The video encoder is H253, the Audio AmrNb and the output format is Mpeg4.

Right now when I get a buffer on the phone's camera I write it to a file on the cell phone and also to the socket (nos) so my code looks like the code below. It's currently sitting in a class called InternalVideoServer which I am hoping to morph into an RSTP based server. Can you give me a rough idea how to make this happen?

Then on the server side I want to be able to rebroadcast the stream out to anyone who subscribes to it as well as store the stream in a file. So there is a similar method right now on the PC. So on the PC A.K.A the media server I need to be able to have subscribers request the stream at any time, and also record the video to blob storage
in Azure. The end solution is going to do that on a separate thread. But it has the problem that it needs to be able to fill in the header when recording stops or, potentially at specified intervals to keep the video files manageable. I've tried to do a lot of the reading that you have suggested so I think with some coaching and some code examples I should be able to make this work. I have all Memorial Day weekend and I really want to devote my time to it. Thanks in advance.
    /// <summary>
    /// 
    /// </summary>
    /// <param name="buffer"></param>
    private static void processRequest(ref byte[] buffer)
    {
        try
        {
            //
            // Send the buffer onto the RTSP Server
            //
            if (fs != null)
            {
                fs.Write(buffer, 0, buffer.Length);
            }

            if (nos != null)
            {
                nos.Write(buffer, 0, buffer.Length);
            }
        }
        catch (Exception e)
        {
            //
            // Do something with the exception
            //
        }
        finally
        {
        }
    }
Coordinator
May 27, 2015 at 10:25 AM
Wish I had the spare time you did, Hopefully you won't die in a fire or something more amusing.
Marked as answer by juliusfriedman on 5/27/2015 at 2:25 AM
Jun 28, 2015 at 8:28 PM
Not actually very helpful. I actually don't have a lot of time. So I'll try to be more concise.

The Android phone is playing the role of the server. So can I also have an RTSP server listening on the server sider?

Because the server is the known IP location I am thinking I get the IP/port the server is listening on by calling the server from the phone and getting the IP and port.
Then I setup the server side so the phone can connect and start sending RTP packets to it.

Do you have any sample code that would help me move forward with this?

Thanks
Coordinator
Jun 30, 2015 at 10:27 AM
There is enough sample code which should have already helped you achieve what you need. If you need more you simply don't have the understanding you should.
Marked as answer by juliusfriedman on 6/30/2015 at 2:27 AM