peerjs
peerjs copied to clipboard
One Way Streaming
Hello Everyone! i am using peerjs for screensharing purpose only which is one way streaming. Is there any way to achieve this, that one user sends his desktop capture as a stream whereas other user sends no stream. Looking forward for your answer
I'm not sure you can send without stream but you can create and empty stream.
function 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 });
};
and create the stream
const videoTrack = createEmptyVideoTrack({ width: 500, height: 500 })
const mediaStream = new MediaStream([ videoTrack]);
call.answer(mediaStream)
I'm pretty certain this is covered in the docs if I have understood you correctly.
All you would need to do is answer the call on the receiving end without passing any argument back to the caller;
ex:
call.answer()
From the docs;
When answering a call, the MediaStream is optional and if none is provided then a one-way call is established.
I have this problem that,
- user1 start streaming his cam
- user2 has user1 Id and he use this Id to connect to user1 3)user1 answer(in js) with his cam stream, user2 send no stream
- problem is user2 can't connect with Id #without providing stream#
- please help!!