0

I have this AutobahnPython server up and running fine. https://github.com/tavendo/AutobahnPython/blob/master/examples/websocket/streaming/streaming_server.py

I want to attach a HTML5 Front end for capture of web cam video and audio. How do I get the HTML5 Blob to send through the socket I just created in HTML5 to the python socket server I also have running?

Is it sendMessage? https://autobahnpython.readthedocs.org/en/latest/websocketbase.html#autobahn.websocket.WebSocketProtocol.sendMessage

1 Answers1

2

Be prepared, doing what you want, and doing it right (which means flow-control), is an advanced topic. I try to give you a couple of hints. You might be also interested in reading this.

  1. WebSocketProtocol.sendMessage is part of the AutobahnPython API. To be precise, it is part of the message-based basic API. Whereas the streaming server above uses the advanced API for receiving, it uses the basic API for sending (since the sent data is small, and there is no need for flow control)

  2. Now, in your case, the web cam is the "mass data" producer. You will want to flow-control the sending from the JS to the server. Since if you just send out WebSocket messages from JS as fast as you get data from cam, your upstream connection might not keep up, and the browser's memory will just run away. Read about bufferedAmount which is part of the JS WebSocket API.

  3. If you just want to consume data is it flow into your server, above AutobahnPython streaming server example is a good starting point since: you can process WebSocket data as it comes in. Other WebSocket frameworks will first buffer up a complete message until they give the message to you.

  4. If you want to redistribute the data received by your server again to other connected client, you will want flow-control on the server's outgoing leg also. And then you will need the advanced API for sending also. See the reference or the streaming (producer) client examples - you can adjust the code to run inside your server.

Now if above all does not make sense to you .. it's a non-trivial thing. Try reading the first link to the Autobahn forum, and more about flow-control. It is also non-trivial since the JS WebSocket API has only limited machinery for doing this kind of flow-control, without falling back to invent your own scheme at app level. Well. Anyway, hope that helps a little.

oberstet
  • 21,353
  • 10
  • 64
  • 97
  • Hi Tobias Thank you for your comments. I've really enjoyed reading your docs and using your software. I'm sure your comments on FlowControl and BufferedAmount are spot on however, I have not got it all to 'work' yet. I'm still at step 1 just getting the webcam blob to the server, and FlowControl etc are step 2, 3, 4 for the fine tuning ;) For the outbound leg, I plan on using FFMPEG so I can keep it in the HTML5 ipad/iphone realm so I have step, 5, 6, 7 to worry about for another day. I'll keep hacking at it. Again thank you for your comments. – Benjamin Schroeder Nov 13 '13 at 00:08
  • Great! Good to hear the answer was somewhat useful to you .. in which case you might click on the "accept" button;) That's how StackOverflow usually works. That is _if_ you found the answer to be satisfying. – oberstet Nov 14 '13 at 08:09