0

I am new in JSSIP. I need to switch Audio call to video call in ongoing call.

const session = userAgent.call(destinationNumber, {
      mediaConstraints: {
        audio: true,
        video: false
      },
      pcConfig: {
        iceServers: [{ urls: Config.STUN_SERVER }]
      }
    });

This is how i initiate audio call. How i can able to switch to video call in between the call?

Jibin Francis
  • 348
  • 2
  • 14

1 Answers1

1

You can do a trick and initiate a call with video, but instead of putting real video track, you will put some dummy "silent" video track:

function createSilentVideoTrack() {
          const canvas = document.createElement("canvas");
          canvas.width = 50;
          canvas.height = 30;
          canvas.getContext("2d").fillRect(0, 0, canvas.width, canvas.height);
          animateCanvas(canvas);
          const stream = canvas.captureStream(1);
          const tracks = stream.getTracks();
          const videoTrack = tracks[0];
          return videoTrack;
        }

And when you need to enable video, you just replace dummy video track to the real one:

navigator.mediaDevices.getUserMedia(constraints).getVideoTracks()[0].then(track => {
        connection.getSenders().filter(sender => sender.track !== null && sender.track.kind === "video").forEach(sender => {
          sender.replaceTrack(track);
        });
Igor Khvostenkov
  • 714
  • 5
  • 15