we are fiddling around with WebRTC in our company. And i stumbled upon a weird thing, which i'm not sure is by design in WebRTC or an implementaiton error on our side.
We currently have a simple WebApp which displays a Contact-List of online contacts. One can now simply call any user on the contact list.
The Caller and the Callee are free to choose to share WebCam and/or Audio. Which is then respected by GetUserMedia() (MediaConstraints).
The weird thing now: The clients (Chrome 65) only negotiate a Video-Call if the Caller starts with Video enabled. If the caller is not offering his webcam, we don't get the callee webcam streamed back (if he allowed it).
But when the Caller initiates the Call with his webcam enabled and the Callee than decides not to show his, everything works as expected. (Only Caller has live stream).
If both parties agree on showing video, we get bideractional video streaming.
Anybody got some internal knowledge if this is meant to be this way? Isn't it possible to call someone without showing your own webcam, but later on seeing the callees webcam?
Thanks in advance, Sven
A connection is established through a discovery and negotiation process called signaling. This tutorial will guide you through building a two-way video-call. WebRTC is a fully peer-to-peer technology for the real-time exchange of audio, video, and data, with one central caveat.
We will use WebRTC API to capture the microphone and camera of one peer and send it over the internet to another peer in our P2P communication. How does it work? Let’s take a look at the API we will be using. RTCPeerConnection — it’s used as a starting point of any connection. It provides an interface for connecting a local peer to a remote one.
@WebRTCWeb . Github . Latest issues . What's New? All peers are directly connected with broadcaster. They're not connected with each other. Broadcaster can see/talk with all of them; they can only talk/listen only the broadcaster.
The signaling server Establishing a WebRTC connection between two devices requires the use of a signaling server to resolve how to connect them over the internet. A signaling server's job is to serve as an intermediary to let two peers find and establish a connection while minimizing exposure of potentially private information as much as possible.
try pc.createOffer({offerToReceiveVideo: true})
instead of calling it without those constraints.
Philipp's answer works great. However, by now the proposed option is marked legacy and should not be used anymore. The new way of doing this is to add a video transceiver to the connection before creating the offer:
connection.addTransceiver('video');
// this step seems to be optional:
connection.getTransceivers().forEach(t => t.direction = 'recvonly');
connection.createOffer();
Credit to https://niccoloterreri.com/webrtc-with-transceivers. For the optional step, see https://developer.mozilla.org/en-US/docs/Web/API/RTCRtpTransceiver/direction.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With