I have a use-case where:
For this use-case I need, for the Viewer side:
var call = peer.call(presenterPeerID, null);
call.on('stream', function(theirWebcamStream) {
showWebcamStream(theirWebcamStream);
});
This does not work, because peer.call(presenterPeerID, null)
returns undefined
.
How do I call without sending a MediaStream?
Subscribe to this issue
Have you tried initiating the call from the presenter to the viewer, providing the presenters mediastream in the call and answering the call with null as mediastream?
I'm also hoping to do the same thing. See issue #158
+1
You can create empty stream with any track, or with both:
export const createEmptyAudioTrack = () => {
const ctx = new AudioContext();
const oscillator = ctx.createOscillator();
const dst = oscillator.connect(ctx.createMediaStreamDestination());
oscillator.start();
const track = dst.stream.getAudioTracks()[0];
return Object.assign(track, { enabled: false });
};
export const createEmptyVideoTrack = ({ width, height }) => {
const canvas = Object.assign(document.createElement('canvas'), { width, height });
canvas.getContext('2d').fillRect(0, 0, width, height);
const stream = canvas.captureStream();
const track = stream.getVideoTracks()[0];
return Object.assign(track, { enabled: false });
};
...
const audioTrack = createEmptyAudioTrack();
const videoTrack = createEmptyVideoTrack({ width:640, height:480 });
const mediaStream = new MediaStream([audioTrack, videoTrack]);
peer.call('id', mediaStream);
Most helpful comment
You can create empty stream with any track, or with both: