Re: [webrtc-pc] Use VP9 when only receiving video (#2592)

The following is the code snippet of caller of adding `pc.addTransceiver()`. The browser(Chrome 86) complains with the error message:

```
OperationError: Failed to execute 'setLocalDescription' on 'RTCPeerConnection': Failed to set local offer sdp: The order of m-lines in subsequent offer doesn't match order from previous offer/answer.
```

```javascript
// code snippet of caller
export class RTCCaller {
  constructor(configuration) {
    const { config, stream, signaling, callback, metadata } = configuration;
    initSignaling(configuration);
    const peerConnection = createPeerConnection(config, callback, stream);
    const channel = peerConnection.createDataChannel('mouseEvent');
    channel.addEventListener('open', () => {
      console.log('webrtc data channel open.');
    })

    if (stream) {
      peerConnection.addEventListener(
        'negotiationneeded',
        () => createOffer(signaling, peerConnection, metadata));
    } else {
      peerConnection.addTransceiver('video', { direction: 'recvonly' });
      if (!RTCRtpSender.getCapabilities) return;

      const { codecs } = RTCRtpSender.getCapabilities('video');
      const [ transceiver ] = peerConnection.getTransceivers();

      const vp9_profile_2 = codecs.find(c => c.mimeType === 'video/VP9' && c.sdpFmtpLine === 'profile-id=2');
      if (vp9_profile_2) {
        console.log([vp9_profile_2]);
        transceiver.setCodecPreferences([ vp9_profile_2 ]);
        createOffer(signaling, peerConnection, metadata);
    }

      const vp9_codecs = codecs.filter(c => c.mimeType === 'video/VP9');
      const preferedCodecs = vp9_codecs.length > 0 ? vp9_codecs : codecs;
      console.log(preferedCodecs);
      transceiver.setCodecPreferences(preferedCodecs);
      createOffer(signaling, peerConnection, metadata);
    }
...
```

-- 
GitHub Notification of comment by jim-king-2000
Please view or discuss this issue at https://github.com/w3c/webrtc-pc/issues/2592#issuecomment-719165613 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Friday, 30 October 2020 04:34:55 UTC