Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Live streaming webcam with Janus

Tags:

webrtc

janus

I am trying to live stream video and audio from a user's webcam, with WebRTC. I cannot figure out how to do it with Janus Webrtc gateway, so that a person would stream webcam, and others can view it on another webpage.

I have installed Janus and I am able to connect with the Janus server with a browser. I attach the session to the streaming plugin, and then I create an offer with createOffer. The onlocalstream function is called, and I set the srcObject of my video element.

The broadcaster
I am able to attach the session to the streaming plugin like this:

janus.attach({
   plugin: "janus.plugin.streaming",    
    [...]

..then in the success handler I create an offer like this:

success: function(pluginHandle) {
    streaming = pluginHandle;
    var body = { "audio": { deviceId: { exact: audioSelect.value }},"video": { deviceId: { exact: videoSelect.value }} };
    streaming.createOffer({
        media: {
            audioSend: true,
            videoSend: true,
            audioRecv: false,
            videoRecv: false,
            audio: { deviceId: { exact: audioSelect.value }},
            video: { deviceId: { exact: videoSelect.value }}
       },
       success: function(jsep) {
           console.log("jsep = " + jsep);
           streaming.send({"message": body, "jsep": jsep});
       },
       error: function(error) { 
           console.log("error creating offer: " + error); 
       }
    });
},

The viewer
On the viewer's page I attach to the streaming plugin as well, and here I do not really know what to do. Do I create an offer with createOffer, or createAnswer?

And is the streaming plugin the correct plugin for what I want?

I do see an error on the Janus server when the broadcaster connects:
[ERR] [plugins/janus_streaming.c:janus_streaming_handle_message:3614] Missing mandatory element (request)

I want a user to stream webcam, and other users would see it (one-to-many broadcast). I have read this thread, and the user nschoe said that it is possible with Janus: WebRTC - scalable live stream broadcasting / multicasting

like image 937
John Avatar asked Sep 06 '19 16:09

John


1 Answers

Recently I have faced this issue with a sample implementation using Python. Please try it by adding

media:{
    request:"request type"
    ....
}
Where "request type" can be list, info, create, destroy, recording, edit, enable and disable

You can get more information at its Streaming API documentation

like image 175
Ripundeep Gill Avatar answered Sep 22 '22 09:09

Ripundeep Gill