Stream Bitmap to Client

Topics: Question
Jul 7, 2016 at 3:25 PM
I am trying to stream a bitmap picture to a Android client
            RtspServer server = new RtspServer(System.Net.IPAddress.Any, 554)
                Logger = new Media.Rtsp.Server.RtspServerConsoleLogger()

            RFC6184Media media = new RFC6184Media(640, 480, "test");
            while (true)
                Bitmap bmp = (Bitmap)Image.FromFile("Frame.bmp", true);
                Bitmap bmp32 = new Bitmap(640, 480, PixelFormat.Format32bppArgb);
                using (Graphics g = Graphics.FromImage(bmp32))
                    g.DrawImage(bmp, 0, 0);
but on the line
i get this Exception
{"Only ARGB is currently supported."}
Jul 7, 2016 at 6:25 PM
Edited Jul 7, 2016 at 6:26 PM
Well your not trying to stream a bitmap your trying to stream a H264 IFrame.

I would recommend JPEG / RFC2435 for now because the pseudo encoder of H264 included with RFC6184Frame does not compress the data and therefor provides absolutely no bandwidth savings over that of JPEG or simply plain YUV due to the addition of the slice headers and macroblock stuffing.

Why don't you try with the RFC2435 frame or better yet start on a RFC4175 implementation?

The RFC2435 will give you compression through JPEG or RFC4175 will give you the ability to send only the data which changes in the raw video..


I would be more than happy to assist you and in the end provide something which can be used by the library for everyone....

If you MUST use H.264 you should use the H.264 encoder on Android for the best performance or yet another H.264 Encoder e.g. nCodec, csCodec, or otherwise.

Let me know if that answers your questions and how I can help you further.
Marked as answer by juliusfriedman on 7/7/2016 at 11:25 AM
Jul 7, 2016 at 10:14 PM
Edited Jul 7, 2016 at 10:24 PM
my "end-goal" is to render a sceen in OpenTK(Opengl) and stream it to android
i have tried JPEG / RFC2435, it doesn't throw an exeption but the android media player that i am using doesn't support those streaming methodes

I would appreciate any kind of help because i am quite new to this subject.
Jul 7, 2016 at 10:53 PM
Edited Jul 7, 2016 at 10:56 PM
Render a Screen

It sounds like you want to take screenshots on the phone of the rendered OpenGL (ES) surface and send them out over RTP but you also have the restriction that you have to use a Encoding which is supported by your media player... Correct?

What formats does your Media Player support?

Do you have access to a JPEG Encoder and Decoder?

If not then you will likely have the easier time implementing the RFC4751 frame class and a custom renderer on Android which can simply take the video in the format you send it and display it on another surface in the required format.

It shouldn't take longer than a few hours to implement the RFC4751 profile, maybe a little longer with unit tests and all that... :)

I will be happy to help if you are willing to meet me half way :)

Let me know what your options are and how serious you are and we will proceed from there.

P.s. MPEG4 has the ability to send the scene directly to the device... It's far more complex than just creating a raster and I am not sure if Android has a complete implementation of MPEG4 which would allow for it but it might be worth the time depending on what your trying to do....
Marked as answer by juliusfriedman on 7/7/2016 at 3:54 PM
Jul 9, 2016 at 6:23 PM
Sorry for the delay
I am going to explain my problem a little bit better

I capture every frame that i render(in OpenTK(OpenGL) on a Windows PC) and i want to send it to a Android Client that is a android media player (basically an app that i made myselve)
I am already streaming sensor data(from Android) to the PC every few milliseconds but i dont think that that will be a problem
I am able to recieve a stream that is being created like this
RtspServer server = new RtspServer(System.Net.IPAddress.Any, 554)
                Logger = new Media.Rtsp.Server.RtspServerConsoleLogger()
            var source = new RtspSource("TEST", @"rtsp://");
but im not able to receve a image stream so far
i can connect to a stream that uses RFC2435/RFC5391
but i get a black screen that does not display it

here are a few links that might be usefull
android media player
android supported media formats
Jul 9, 2016 at 6:35 PM
Is the RtspServer on the Android phone or the Windows computer or both?

You only need an RtspClient or RtpClient on the Android but you could also use the server.

I'm future versions of the library I would intend on the ClientSession of the RtspServer and itself will become a single RtspClient with multiple RtspSessions so keep that in mind...

Why you get a black screen and where is hard to say even with the plethora of information you provided.

Android seems to support JPEG also maybe not in your version of Android, may I ask what version tour targeting?

May I also askin if this is Mono or Xamarin or some other implementation therein of the CLR as it would possibly allow the direction of my response to be that more accurate unless this an attempt to probe some other pieces of information.

A Wireshark capture or logs from the library or something should else should be enough for me to give you information in the blank screen.

Finally is this a private project or is this for your employer?
Marked as answer by juliusfriedman on 7/9/2016 at 11:35 AM
Jul 9, 2016 at 7:52 PM
the server is on my Windows PC
te client on android
i use Android 6.0 Marshmallow
i use Visual Studio (c#) and Android Studio
i am not sure jet, at the moment its private, but that could change
Jul 9, 2016 at 8:20 PM
Edited Jul 9, 2016 at 8:23 PM
Can you share the code in reference to the black screen?

I would only assume that there is something in that code which is causing the issue.

Have you verified the client recieves data and fires events for the packets and frames? Have you verified what was sent can be put back together in the expected way on the receiving end?

Any feedback you can provide e.g. Your difficulty getting started, confusion on method names etc would be helpful for me in terms of what people understand about the library outside of my examples.

Without more information I'm not sure how I can help, what have you tried what error do you get?

'I get a black screen' is surely not enough information, press the power key or the home key....
Marked as answer by juliusfriedman on 7/9/2016 at 1:21 PM
Jul 10, 2016 at 8:42 PM

in the class MainActivity
VideoView vidView = (VideoView) findViewById(;
String vidAddress = Address.getText().toString(); 
Uri vidUri = Uri.parse(vidAddress);
in activity_main
<VideoView android:id="@+id/myVideo"
with "i get a black screen" i ment the VideoView doesnt show anything(a black screen)
Jul 10, 2016 at 8:44 PM
Check wireshark at the PC, something seems weird unless the player is not starting correctly, if RTSP is supported it should work...
Marked as answer by juliusfriedman on 7/10/2016 at 1:44 PM
Jul 11, 2016 at 11:32 PM
Edited Jul 11, 2016 at 11:34 PM
Just checking if you could provide any further info on this...

I don't think VideoView will work for Rtsp but then again it might, it would depend on how VideoView is implemented...

The built in players for Android and iOS should work with RTSP, RTP and SDP considering it's over 20 years old but apparently it's more important to push agendas then compatibility...

If for some reason you can get this working I can probably provide a small example which will get you started but it uses my RtspClient.

Let me know what you find and please provide the proper information (Wireshark, Logs from the RtspServer etc)
Marked as answer by juliusfriedman on 7/11/2016 at 4:33 PM
Jul 11, 2016 at 11:53 PM
Edited Jul 12, 2016 at 12:21 AM
i can receive rtsp streams
for example a rtsp stream that is created like this
 Socket listenSocket;
            Socket clientSock;
            RtspServer server = new RtspServer(System.Net.IPAddress.Any, 554)
                Logger = new Media.Rtsp.Server.RtspServerConsoleLogger()
            var source = new RtspSource("TEST", @"rtsp://");
by connecting to "/rtsp://ip:port/live/TEST"

or directly to "rtsp://"

i can give you the information from wireshark tomorrow
Jul 12, 2016 at 12:31 AM
Edited Jul 12, 2016 at 12:32 AM

Directly would be bypassing the server, but it's a good way to test if the issue is with the server vs another server.

You should be able to connect to both variations if you have internet access, if you only have Wifi on the Handset then you might only be able to access the local network or otherwise what routes are configured by your router..

Let me know when you get the Wireshark Capture and I will take a look, please also include the logs from the RtspServer if possible.

Thanks for your interest and testing and if I can help you further let me know!
Marked as answer by juliusfriedman on 7/11/2016 at 5:31 PM
Jul 12, 2016 at 7:48 PM
how can i give you the log files
Jul 12, 2016 at 8:20 PM
Edited Jul 12, 2016 at 8:20 PM
Sorry I just saw this, sorry for the delay you can email to me at the address in the license or post them to drop box.
Marked as answer by juliusfriedman on 7/12/2016 at 1:20 PM
Jul 12, 2016 at 10:02 PM
I sent you an e-mail
Jul 12, 2016 at 10:05 PM
Already replied...

I just verified VLC mobile...

I will try some more players and see if I can't replicate your difficulties.
Marked as answer by juliusfriedman on 7/12/2016 at 3:11 PM
Jul 12, 2016 at 11:16 PM
I sent you a link to a test project i made
the built apk that i was using is under VideoPlayer\app\build\outputs\apk\app-debug.apk
Jul 14, 2016 at 7:45 PM
I responded to your 'email', I don't have anything further to immediately add.

I will be making some updates to the project in the next week or so, some of which may resolve your issue but it may not.

In short, my RtspClient works with ALL compliant servers and clients, you can download just about any mobile player and give it a shot if your having difficulties; I have tested the released sources primarily with various other software libraries such as but not limited to VLC, QuickTime, RealPlayer, Windows Media Player, etc.

My RtspServer works with my RtspClient on Android Mono or in any other supported environment; It is definitely possible to make it function with Lib Stage Freight either over the open internet or via the lan and I can assist you with such if required.

I also would like to create a few classes which can assist with packet logging in general such as the ability to read and write PCAP files, as well as log network traffic without Wireshark where required.

I also have a bunch of other concepts, some of which are related to Rtp and Media in general but other not so much that I would like to complete and possibly include in the library eventually.

File Writing is probably the 2nd most important feature outside of the base library API and I hope to finish up the Readers and Start on the Writers in due course.

Then probably it would be Compression, Cryptography and Codecs (in that order)

Please do let me know how we can work together and please do remember to display the Apache 2 license if your employer decides to use this library.

Feedback is welcome and support is free.

Marked as answer by juliusfriedman on 7/14/2016 at 12:45 PM