peerjs icon indicating copy to clipboard operation
peerjs copied to clipboard

The "options" in "peer.call(id, stream, options) " should be documented.

Open ziczhu opened this issue 12 years ago • 13 comments

I saw the #126 before, but i think there is something meaningful in the peerconnection's options. Because some problem confuses me when i tried to call the other peer with the audio only, i cannot received the video from that peer. After I search the google, I found that this situation happened because I don't set the OfferToReceiveVideo to true, in webrtc constraints, it means if a caller only has the audio stream, the OfferToReceiveVideo is setting to false, even if the the callee answer a video stream, we won't received it.

As soon as I set it like this:

    var options = {
        'constraints': {
            'mandatory': {
                'OfferToReceiveAudio': true,
                'OfferToReceiveVideo': true
            }
        }
    }
    var call = peer.call(otherPeer, callStream, options);

It finally works.

So I suggest that maybe we could document it in the Docs, or just set it as the default in the source code.

ziczhu avatar Jan 23 '14 05:01 ziczhu

I experienced the same thing today. Documentation needs to be updated.

ghost avatar Jan 24 '14 08:01 ghost

Thanks, will do!

ericz avatar Mar 10 '14 03:03 ericz

https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/createOffer

Note: You shouldn't use this legacy property. Instead, use RTCRtpTransceiver to control whether or not to accept incoming video.

afrokick avatar Mar 27 '19 21:03 afrokick

@afrokick Do you have an example of using RTCRtpTransceiver for this? I'm confused as to how it would be implemented with Peer.JS. I'm having a fairly common issue -- Users with video disabled should still be able to participate -- but when I connect that media stream, the users who only have audio can also only recieve audio.

Redmega avatar Jul 26 '19 15:07 Redmega

@afrokick Can you please provide an example of this being solved with RTCRtpTransceiver? I have the same issue as the others, sending audio, can not receiving video.

horvbalint avatar Nov 13 '19 11:11 horvbalint

Thank you for explaining. this is very helpfull

malisatish avatar May 02 '20 22:05 malisatish

@afrokick I am using PeerJS and facing the same issue, If I tried to call some peer with the only audio stream, I cannot receive the video from that peer. I am confused on how to use the below options in Peer.js

'OfferToReceiveAudio': true,
'OfferToReceiveVideo': true

Could you please refer to this and help me out here.

charmi2011 avatar Jun 12 '20 11:06 charmi2011

    var constraints = {
        'mandatory': {
            'OfferToReceiveAudio': true,
            'OfferToReceiveVideo': true
        },
        offerToReceiveAudio: 1,
        offerToReceiveVideo: 1,
    }

You shoud name your object like "constraints" and then: var call = peer.call(otherPeer, callStream, constraints);

TomaszRzucidlo avatar Jun 19 '20 09:06 TomaszRzucidlo

Thanks @TomaszRzucidlo

        var options = {
          'constraints': {
            'mandatory': {
              'OfferToReceiveAudio': true,
              'OfferToReceiveVideo': true
            },
            offerToReceiveAudio: 1,
            offerToReceiveVideo: 1,
          }
        }

I initialized variable options as shown above and used it as below and it worked: var call = peer.call(otherPeer, callStream, options);

charmi2011 avatar Jun 22 '20 12:06 charmi2011

Hi @TomaszRzucidlo, On Typescript ( Angular ) those parameters was not available for me 🤕 "STEP UP" "peerjs": "^1.2.0", "angular":9 image

Did you know how to create a blank MediaStream as response for those who not accept their camera and microphone to setting up the peer to peer communication. ✨

I really sorry for the misconception of WebRTC 😢

Thank-you

truonghoangduy avatar Jun 24 '20 19:06 truonghoangduy

With constraints it works! Thanks you save my life! Please add to Docs!

sellrock-de avatar Sep 14 '21 10:09 sellrock-de

Hi @TomaszRzucidlo, On Typescript ( Angular ) those parameters was not available for me 🤕 "STEP UP" "peerjs": "^1.2.0", "angular":9 image

Did you know how to create a blank MediaStream as response for those who not accept their camera and microphone to setting up the peer to peer communication. ✨

I really sorry for the misconception of WebRTC 😢

Thank-you

Do u find a answer for it?

angelopedroso avatar Dec 30 '23 20:12 angelopedroso

I resolve it doing this: Typescript not nag

      const options = {
        constraints: {
          mandatory: {
            OfferToReceiveAudio: true,
            OfferToReceiveVideo: true,
          },
          offerToReceiveAudio: 1,
          offerToReceiveVideo: 1,
        },
        sdpTransform: (sdp: string) => {
          return sdp.replace(
            'a=fmtp:111 minptime=10;useinbandfec=1',
            'a=fmtp:111 ptime=5;useinbandfec=1;stereo=1;maxplaybackrate=48000;maxaveragebitrat=128000;sprop-stereo=1',
          )
        },
      }

      const call = me.call(peerId, stream, options)

Ignore sdp. If didnt work, just try add "as any" in options

angelopedroso avatar Dec 30 '23 21:12 angelopedroso