Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
281 views
in Technique[技术] by (71.8m points)

python - Implementing webbased real time video chat using HTML5 websockets

Does anyone know how to implement voice/video over IP in a webapplication using HTML5 websockets?

It would be nice if I could implement this with PHP or Python since I (unfortunately) don't know any other programming language at the moment.

A good tutorial will do, as well as an already-build-solution which I have to pay for.

Update1:
Added video because it's not only audio/voip related.

Update2:
First HTML5 Video Conference App is already created. See my own answer

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

If you want to go with HTML5 only, you will need a browser implementing the HTML Media Capture draft (available here) in order to access the raw data from the microphone.

Once you have this data in hand, you need to send it over the network. Websockets would be the HTML5 option to have fast enough round trips with the server (sending local audio data and receiving remote audio data at the same time)

Since you mention python, I would recommend looking around the twisted implementation of websockets.

You can have all your clients "register" on the websocket server with a callerID, so the server knows where to find a given callerID.

Then your server will need an "invite" API where caller1 "invites" caller2.

Once the call is setup and each client starts sending its audio data, the server will be able to send this audio data to the other party.

Upon receiving audio data, the browser will need to play this audio data on the speakers, probably using the HTML5 audiotag.

To do this, you may be forced to use a "trick" : instead of having the websocket server forward the raw audio data to the client, you may need to simulate 2 "infinite" files :

  1. caller1.wav : sound captured on caller1 mic
  2. caller2.wav : sound captured on caller2 mic

caller1 browser would add caller2.wav in the audio.src attribute once the call is setup (caller1 would be informed of this event via websocket) and hopefully if the python server appends the raw audio data to the caller2.wav as it receives it, it would start playing.

This sounds like a cool prototype you're going to hack up !

Good luck on your journey,

Jerome Wagner


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...