Janus
Janus Screen Share on Video Room
May 01, 2020
1 min

how to work with screen share plugin with janus video room plugin.

if you want replace exist video stream with screen share stream

export function publishScreenShareFeed(){
    screenShare = true
    vroomHandle.createOffer(
        {
            media: { 
                video: 'screen', audioSend: true, videoRecv: false,audioRecv: false,replaceVideo:true
            },  // Screen sharing Publishers are sendonly

            success: function(jsep) {
                Janus.debug("Got publisher SDP!", jsep);
                var publish = { request: "configure", audio: true, video: true };
                vroomHandle.send({ message: publish, jsep: jsep });
            },
            error: function(error) {
                Janus.error("WebRTC error:", error);
            }
        });
}

create session

    // Create a new room
    const role = "publisher";
    var create = {
        request: "create",
        description: "share screen",
        bitrate: 500000,
        publishers: 1
    };
    vroomHandle.send({ message: create, success: function(result) {
        var event = result["videoroom"];
        Janus.debug("Event: " + event);
        if(event) {
            // Our own screen sharing session has been created, join it
            const room = result["room"];
            Janus.log("Screen sharing session created: " + room);
            var register = {
                request: "join",
                room: room,
                ptype: "publisher",
                display: store.getState().conference.name
            };
            vroomHandle.send({ message: register });
        }
    }});


Tags

webrtcjanusubuntu

Related Posts

Janus
How to install Janus Gateway in Ubuntu Server 18.04
July 15, 2021
1 min