peerjs icon indicating copy to clipboard operation
peerjs copied to clipboard

One Way Streaming

Open Kamran95 opened this issue 4 years ago • 3 comments

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

Kamran95 avatar Sep 28 '20 11:09 Kamran95

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)

valehelle avatar Oct 02 '20 12:10 valehelle

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.

theoboldalex avatar Oct 09 '20 11:10 theoboldalex

I have this problem that,

  1. user1 start streaming his cam
  2. 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!!

ChathuraGH avatar Oct 10 '22 00:10 ChathuraGH