I am trying to build a video chat web api using html and javascript. So far I found this code that accesses the microphones and webcam on the client's device and displays the video and audio on client's screen. Here is that code:
<script>
navigator.getUserMedia = navigator.getUserMedia ||
navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia;
if (navigator.getUserMedia) {
navigator.getUserMedia({ audio: true, video: { width: 1280, height: 720 } },
function(stream) {
var video = document.querySelector('video');
video.src = window.URL.createObjectURL(stream);
video.onloadedmetadata = function(e) {
video.play();
};
},
function(err) {
console.log("The following error occurred: " + err.name);
}
);
} else {
console.log("getUserMedia not supported");
}
</script>
For the video chat web app to work the video and audio is going to have to be sent to the server where the video and audio can be sent to the other user to carry out a conversation. I am having trouble finding a way to send the data to the server and then for the server to send the data to another client's computer. I have done a bit of research and I think that websockets are the best way to send streaming data to the server and then for the server to process that data and send it out to another client. The problem I am having is that, although I understand how to send data to the server using websockets, I am unclear how to write code (preferably server side javascript) to receive the data, process it, then use another websocket to stream the video and audio data to another client's computer. I would extremely appreciate all ideas source code, and links on how to stream video and audio data to a server and then for the server to receive the data using server side javascript, and then for the server to stream that data to another clients computer. Similarly, I would like to know how to receive and process data sent to the server with server side javascript that was sent to the server via a websocket, if websockets are a good way of completing this task.
Thank you for your time!

New Topic/Question
Reply


MultiQuote





|