Peerjs: Peer.Call without stream

Created on 18 Feb 2014  Â·  14Comments  Â·  Source: peers/peerjs

It seems that it impossible to utilize Peer.Call without passing in a user media stream. Peer.Call should be able to call any peer even if the caller decides to not give the browser access to their webcam/mic.

request

Most helpful comment

@yunusberateke it's work
```
const createMediaStreamFake = () => {
return new MediaStream([createEmptyAudioTrack(), createEmptyVideoTrack({ width:640, height:480 })]);
}

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 });
}

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 });

};

All 14 comments

Good point; we'll look into adding this.

+1

Calling without sending a stream seems a reasonable feature to me. Any update on that ? :)

Sorry, haven't had the time recently :(. Happy to review PRs though.

Michelle

On Fri, May 23, 2014 at 2:01 PM, Pierre [email protected] wrote:

+1

Calling without sending a stream seems a reasonable feature to me. Any
update on that ? :)

—
Reply to this email directly or view it on GitHubhttps://github.com/peers/peerjs/issues/158#issuecomment-44059854
.

I solved that by passing new webkitMediaStream() as a media stream to method call(). As my app is being used only in Chrome, it's not an issue for me.

Hope it helps :)

@grabbou can you paste some example code?

+1
@grabbou that`s so simple solution and works for me tks, do you know how do it in firefox? i try MediaStream but not works :sweat_smile:

@michelle, I don't suppose you have any thoughts on how this could be implemented? I know very little about WebRTC, but it would be enormously helpful to me to be able to make calls as a user without a stream.

+1

+1 too

+1

@jhogoforbroke Can you post some sample of how you achieved this. I am attaching the client and server code. The server code is just expected to broadcast the video and all clients can just view the video without having to share any media. When I use new webkitMediaStream() the server is not streaming any data.
peer_server.txt

peer_client.txt

Not sure, if it's still actual, but got able to bypass it using this trick:

const audioCtx = new AudioContext();
const dest = audioCtx.createMediaStreamDestination();
var call = peer.call('testid', dest.stream);

Not sure, if it's still actual, but got able to bypass it using this trick:

const audioCtx = new AudioContext();
const dest = audioCtx.createMediaStreamDestination();
var call = peer.call('testid', dest.stream);

it's not working

can anyone solve this problem?

@yunusberateke it's work
```
const createMediaStreamFake = () => {
return new MediaStream([createEmptyAudioTrack(), createEmptyVideoTrack({ width:640, height:480 })]);
}

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 });
}

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 });

};

Was this page helpful?
0 / 5 - 0 ratings

Related issues

schweini picture schweini  Â·  7Comments

afrokick picture afrokick  Â·  5Comments

lucastwong picture lucastwong  Â·  3Comments

maxpavlov picture maxpavlov  Â·  6Comments

bilo1967 picture bilo1967  Â·  7Comments