|
| 1 | +OWT Simulcast Description |
| 2 | +--------------------- |
| 3 | + |
| 4 | +# {#simulcast} |
| 5 | +The conference server supports simulcast. This can be enabled through OWT Client SDK for JavaScript. |
| 6 | + |
| 7 | +1. Publish a simulcast stream |
| 8 | +~~~~~~{.js} |
| 9 | +// Example of simulcast publication. |
| 10 | +conference = new Owt.Conference.ConferenceClient(); |
| 11 | +// ... |
| 12 | +conference.join(token).then(resp => { |
| 13 | + // ... |
| 14 | + Owt.Base.MediaStreamFactory.createMediaStream(new Owt.Base.StreamConstraints( |
| 15 | + audioConstraints, videoConstraints)).then(stream => { |
| 16 | + /* |
| 17 | + * Use `RTCRtpEncodingParameters` as publish option |
| 18 | + * (https://w3c.github.io/webrtc-pc/#dom-rtcrtpencodingparameters). |
| 19 | + * The following option would create 3 streams with resolutions if browser supports: |
| 20 | + * OriginResolution, OriginResolution/2.0 and OriginResolution/4.0. |
| 21 | + * For current Firefox, the resolutions must be sorted in descending order. |
| 22 | + * For current Safari, legacy simulcast is used and the parameters like `rid` won't take effect. |
| 23 | + * Besides `scaleResolutionDownBy`, other `RTCRtpEncodingParameters` can be set |
| 24 | + * if browser supports. |
| 25 | + * The actual output will be determined by browsers, the outcome may not be exactly same |
| 26 | + * as what is set in publishOption, e.g. For a vga video stream, there may be 2 RTP streams |
| 27 | + * rather than 3. |
| 28 | + */ |
| 29 | + const publishOption = {video:[ |
| 30 | + {rid: 'q', active: true, scaleResolutionDownBy: 1.0}, |
| 31 | + {rid: 'h', active: true, scaleResolutionDownBy: 2.0}, |
| 32 | + {rid: 'f', active: true, scaleResolutionDownBy: 4.0} |
| 33 | + ]}; |
| 34 | + /* |
| 35 | + * Codec priority list. |
| 36 | + * Here 'vp8' will be used if enabled. |
| 37 | + */ |
| 38 | + const codecs = ['vp8', 'h264']; |
| 39 | + localStream = new Owt.Base.LocalStream( |
| 40 | + stream, new Owt.Base.StreamSourceInfo( |
| 41 | + 'mic', 'camera')); |
| 42 | + conference.publish(localStream, publishOption, codecs).then(publication => { |
| 43 | + // ... |
| 44 | + }); |
| 45 | + }); |
| 46 | +~~~~~~ |
| 47 | + |
| 48 | +2. Subscribe a simulcast stream |
| 49 | +~~~~~~{.js} |
| 50 | +// Example of subscription. |
| 51 | +conference = new Owt.Conference.ConferenceClient(); |
| 52 | +// ... |
| 53 | +conference.join(token).then(resp => { |
| 54 | + // ... |
| 55 | + /* |
| 56 | + * Subscribe simulcast stream with specified `rid` |
| 57 | + * which can be found in `RemoteStream.settings.video[i].rid`. |
| 58 | + * If `rid` is set when subscribing, other parameters will be ignored. |
| 59 | + */ |
| 60 | + const subscribeOption = { |
| 61 | + audio: true, |
| 62 | + video: {rid: 'q'} |
| 63 | + }; |
| 64 | + conference.subscribe(remoteStream, subscribeOption).then((subscription) => { |
| 65 | + // ... |
| 66 | + }); |
| 67 | +~~~~~~ |
| 68 | + |
| 69 | +> **Note:** |
| 70 | +1. The simulcast stream published to conference won't be transcoded. |
| 71 | +2. The `rid` attribute may not be present once a 'streamadded' event triggered. Users should listen on stream's `updated` |
| 72 | +event for new `rid` added. |
| 73 | +3. Current browsers(Chrome/Firefox/Safari) can support VP8 simulcast well while H.264 simulcast has some limitations. |
0 commit comments