0

I am using XSockets to send real time image data to any connected clients. Each image is fairly large(up to 1080p quality) and the video can be up to 30fps. Therefore there is a fair amount of data being shifted around. Whenever I get a new image I trigger an event and currently pass the raw byte array to the client as so

void NewImage(byte[] imgData)
{
    this.InvokeToAll(imgData, "newimage");
}

My java script handler is currently empty and isn't even doing anything with the received data(I have ensure it works by printing a message etc. when a new image is received).

Without the InvokeToAll code my program runs without any issue and I have used the same code to render to Winforms before without any issue. After running this code for a few seconds it falls over due to an out of memory exception. Is there something I am missing here, the imgData is nulled from where it is sent(after sending it to the clients) and the code works outside of XSockets without any issues.

const_ref
  • 4,016
  • 3
  • 23
  • 38
  • Are you sure Web Sockets are made for video streaming?????? – Matías Fidemraizer Sep 12 '14 at 07:06
  • @MatíasFidemraizer Yes, it should work ok. See here - https://stackoverflow.com/questions/25727065/rendering-series-of-images-as-video-onto-a-webpage – const_ref Sep 12 '14 at 07:09
  • But you're overusing the concept. The other Q&A talks about streaming images of some sensor and this wouldn't be a 1080p/30fps video stream... Web Sockets would work like a charm to send 1 pic per sec, or in more than 30fps intervals... For other uses, don't you have actual video streaming servers and the HTML5 `video` tag? – Matías Fidemraizer Sep 12 '14 at 07:12
  • @MatíasFidemraizer The example was just that an example. The question asked in that question was if its possible to render real time IP camera data. – const_ref Sep 12 '14 at 07:14
  • As @MatíasFidemraizer points out websockets is not made for streaming... 30FPS with 1080p is just to much data to fast... XSockets has WebRTC API´s but then you will not be able to send video from your custom camera... The best solution would be to write a media streaming protocol. That task is not trivial. – Uffe Sep 12 '14 at 07:25
  • @const_ref At the end of the day, it might be possible to implement video streaming with WebSockets, but you would end implementing a new codec, which is useless, this is my point. It might be easier that you connect your cam to a multimedia server (Windows Media Server in Windows Server?) and stream video to a HTML5 video tag. – Matías Fidemraizer Sep 12 '14 at 07:26
  • Ok. Cheers guys, guess a new approach is needed – const_ref Sep 12 '14 at 07:26
  • @const_ref I will add a suggestion as an answer.. – Matías Fidemraizer Sep 12 '14 at 07:30
  • @Uffe Is it possible to use WebRTC with XSockets 4.0. If so could you use it to render an RTSP stream directly from a camera/server? – const_ref Sep 12 '14 at 12:11
  • @const_ref You can use WebRTC with XSockets 4.0, but the API´s only support browsers. There is no client to send a stream from a camera. We have been asked to build such API but we do not have the time (or money) to do that right now. If you feel like doing the job we support you in any way we can – Uffe Sep 15 '14 at 05:38

1 Answers1

0

As we concluded in the question's comment thread, it seems like doing video streaming using WebSockets might be possible, but it would imply implementing a custom video streaming codec, and IMHO this should go out of your project scope - reinventing the wheel -.

If you're in the .NET arena, you should be using a Windows Server system as hosting environment, and this means that you can take advantage of Windows Server Media Pack. Follow this link for more info about the topic.

There should be other options to stream video to the Web, this is just one of them.

Matías Fidemraizer
  • 63,804
  • 18
  • 124
  • 206