Is is possible to receive both video and audio from another peer if the peer who called createOffer()
only allowed audio when requested via getUserMedia()
?
Explanation by scenario:
getUserMedia()
is called, chooses to share both video and audio.getUserMedia()
is called, only shares audio.RTCPeerConnection.createOffer()
. He shares his localDescription
which contains SDP data that does not mention video.Can an offer be created that asks to receive video data without sharing it?
So the key was in the creation of the offer.
The WebRTC 1.0 specification says:
4.2.5 Offer/Answer Options
These dictionaries describe the options that can be used to control the offer/answer creation process.
dictionary RTCOfferOptions { long offerToReceiveVideo; long offerToReceiveAudio; boolean voiceActivityDetection = true; boolean iceRestart = false; };
In the case of video:
offerToReceiveVideo of type long
In some cases, an RTCPeerConnection may wish to receive video but not send any video. The RTCPeerConnection needs to know if it should signal to the remote side whether it wishes to receive video or not. This option allows an application to indicate its preferences for the number of video streams to receive when creating an offer.
RTCPeerConnection.createOffer()
can take MediaConstraints
as an optional third parameter.
The example I found was from the WebRTC for Beginners article:
Creating Offer SDP
peerConnection.createOffer(function (sessionDescription) { peerConnection.setLocalDescription(sessionDescription); // POST-Offer-SDP-For-Other-Peer(sessionDescription.sdp, sessionDescription.type); }, function(error) { alert(error); }, { 'mandatory': { 'OfferToReceiveAudio': true, 'OfferToReceiveVideo': true } });
These MediaContraints
can also be used with createAnswer()
.
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