Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add transceiver to mediaConnection #930

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

vimavis
Copy link

@vimavis vimavis commented Feb 23, 2022

Solve the following problems:

  • When creating a call where user A (creates the call) does not have video but has audio and user B has video and audio, user A does not see the video of user B.

  • When creating a call where user A (creates the call) has no audio but video and user B has video and audio, user A does not hear user B's audio.

@rs-duongnt1
Copy link

@vimavis Nice, Same problem :)

@afrokick
Copy link
Member

You can create empty streams(or empty tracks) to achieve the same result:

export function createEmptyAudioTrack() {
  const ctx = new AudioContext();
  const oscillator = ctx.createOscillator();

  const dst = oscillator.connect(ctx.createMediaStreamDestination());

  const track = dst.stream.getAudioTracks()[0];

  return Object.assign(track, { enabled: false });
};

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

//... in your code
const emptyStream = new MediaStream([createEmptyAudioTrack(), createEmptyVideoTrack({width:400,height:300})]);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants