Manish Chawla
Manish Chawla

Reputation: 31

Screen Sharing in kurento issues

facing issues in screen sharing in kurento media server

i am following kurento-java-tutorials (one2many). here is my presenter function at client side

function presenter() {
    if (!webRtcPeer) {
        showSpinner(video);

 var constraints = {
     audio: false,
     video: {
       width : { max : 320 },
       height : { max :  240 },
       framerate : { exact : 15 }
     }
 };

        var options = {
        //  localVideo : video,
        videoStream : video,
            onicecandidate : onIceCandidate,
            mediaConstraints : constraints,
            sendSource : 'screen'
        }
        console.log(options);
      if(navigator.getDisplayMedia || navigator.mediaDevices.getDisplayMedia) {
          function onGettingSteam(stream) {

              video.srcObject = stream;
    
          }

          if(navigator.mediaDevices.getDisplayMedia) {
           
              navigator.mediaDevices.getDisplayMedia({video: true}).then(stream1 => {


                onGettingSteam(stream1);
options.localVideo=stream1;
              }, getDisplayMediaError).catch(getDisplayMediaError);
          }
          else if(navigator.getDisplayMedia) {
              navigator.getDisplayMedia({video: true}).then(stream2 => {
                  onGettingSteam(stream2);
options.localVideo=stream2;

              }, getDisplayMediaError).catch(getDisplayMediaError);
          }
      }
      else {

      }



        webRtcPeer = new kurentoUtils.WebRtcPeer.WebRtcPeerSendonly(options,
                function(error) {
                    if (error) {
                        return console.error(error);
                    }
                    webRtcPeer.generateOffer(onOfferPresenter);
                });

        enableStopButton();
    }
}

i am not getting video stream at viewer side. on console at viewer side it is saying

Call not accepted for the following reason: No active sender now. Become sender or . Try again later ...

Upvotes: 0

Views: 315

Answers (1)

kl3eo
kl3eo

Reputation: 1

We can use startCapture() from https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getDisplayMedia

and this worked for us:

startCapture({video: true}).then(stream => {
    
    video.srcObject = stream;
    
    var cstrx = {
        audio: false,
        video: {
            width : { max : 640 },
            height : { max :  480 },
            framerate : { exact : 15 }
        }
    };

        var options = {
        videoStream: stream,
        onicecandidate: participant.onIceCandidate.bind(participant),
        mediaConstraints : cstrx,
        sendSource : 'screen'
        }
    
        participant.rtcPeer = new kurentoUtils.WebRtcPeer.WebRtcPeerSendonly(options,
...

It means we have to wait for the stream, or we get the empty one if we don't.

Upvotes: 0

Related Questions