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

Open webrtc adaptor without camera/mic and open video/audio on the fly - Provide live sample on the codepen.io #5392

Closed
mekya opened this issue Jul 24, 2023 · 3 comments
Assignees

Comments

@mekya
Copy link
Contributor

mekya commented Jul 24, 2023

Scenario
1 – First user initially joins the room. That user is in datachannel only mode (dcOnly = true using url parameter ?dcOnly=true).
2 – 2nd user joins the room. The 2nd user is also in datachannel only mode (dcOnly = true).
3 – Then one of the users starts video (Turn on Camera button).
4 – Same for 2nd user, also starts video.

What we want to do is to go from datachannel only mode to normal conference mode without closing the datachannel connection and reconnecting with webrtcadaptor.onlyDataChannel = true, basically dynamically switch from one mode to the other maintaining the connection and the same stream id.

Discussed here
https://github.com/orgs/ant-media/discussions/5367

@mekya mekya self-assigned this Jul 24, 2023
@mekya mekya changed the title Provide onlyDataChannel to video/audio publisher sample on codepen.io Open webrtc adaptor without camera/mic and open video/audio on the fly - Provide live sample on the codepen.io Jul 26, 2023
@mekya
Copy link
Contributor Author

mekya commented Jul 27, 2023

Hi
SNAPSHOT release is available in npmjs for testing. Check the live sample on codepen.io: Start WebRTC Publish without Opening Cam/Mic and Open Cam/Mic on the fly

Let me quick info for the developers:

  1. Initialize the WebRTC adaptor with dummy audio and video as below
var webRTCAdaptor = new WebRTCAdaptor({
  websocket_url: "wss://test.antmedia.io:5443/WebRTCAppEE/websocket",
  localVideoElement: document.getElementById("localVideo"),
  mediaConstraints: {
    video:"dummy",
    audio:"dummy"
  }
});
  1. Publish the stream
webRTCAdaptor.publish("your_stream_id");
  1. Open camera and Mic on the fly
webRTCAdaptor.openStream({video:true, audio:true}, "your_stream_id");

Please pay attention that second parameter is critical and it is the stream id of your current active broadcast. webRTCAdaptor uses that value to change the tracks of the peer connection on the fly.

@timantmedia
Copy link
Contributor

@mekya I tested this extra method to close the video/audio

closeAudioVideoButton.addEventListener("click", () => {
  console.log("close_audio_video is clicked");
  webRTCAdaptor.openStream({video:"dummy", audio:"dummy"}, streamId);
});

which seems to work shut off the video/audio successfully.

@mekya
Copy link
Contributor Author

mekya commented Jul 27, 2023

Yes, we can also use turnOn/turnOff camera and mute/unmute methods to close it.
Let me put a close audio/video button to the sample as well

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

No branches or pull requests

2 participants