webrtc / samples

WebRTC Web demos and samples
https://webrtc.github.io/samples
BSD 3-Clause "New" or "Revised" License
14.03k stars 5.72k forks source link

Scalable Video Codec include an SVC support check #1597

Open opusonline opened 1 year ago

opusonline commented 1 year ago

Please read first!

Please use discuss-webrtc for general technical discussions and questions. If you have found an issue/bug with the native libwebrtc SDK or a browser's behaviour around WebRTC please create an issue in the relevant bug tracker. You can find more information on how to submit a bug and do so in the right place here

Note: If the checkboxes above are not checked (which you do after the issue is posted), the issue will be closed.

Browser affected

Browser name including version (e.g. Chrome 64.0.3282.119) Google Chrome 110.0.5481.77

Description

Add a check if SVC is supported in the current browser to the SVC sample, since even Chrome >= 101 will report supported: true in MediaCapabilities.encodingInfo() with scalabilityMode. But SVC is only supported in Chrome >= 111 (see https://chromestatus.com/feature/5769626174619648).

The only way I could find to check this, is something like:

() => {
  let supported = false;
  try {
      const pc = new RTCPeerConnection();
      const scalabilityMode = 'L2T2';
      const transceiver = pc.addTransceiver('video', { sendEncodings: [{ scalabilityMode }] });
      const parameters = transceiver.sender.getParameters();
      const [encoding] = parameters.encodings || [];
      supported = Boolean(encoding && encoding.scalabilityMode === scalabilityMode);
  } catch (error) {
      console.error(error);
  }
  return supported;
};

Steps to reproduce

Open the SVC sample https://webrtc.github.io/samples/src/content/extensions/svc/ in a Chrome browser >=101 and < 111. Click the "Start button", allow camera access, select "video/VP8" as Codec preferences.

Expected results

Since SVC is not supported in Chrome < 111, the list of scalability modes should be empty.

Actual results

The list of scalability modes include L1T1, L1T2, and L1T3.

Orphis commented 1 year ago

This is a browser bug where the MediaCapabilities would report that the encoders are technically able to do SVC but the WebRTC encoders are not able to be configured for SVC.

It is also an issue for browsers implementing the Media Capabilities API partially and don't read the scalabilityMode query, but would still answer "supported: true", which could possibly be avoided by making sure the "question" could be integrated in the response.