Skip to content
This repository was archived by the owner on Oct 25, 2024. It is now read-only.

Commit b42a414

Browse files
starwarfanlzhai
authored andcommitted
Add document for simulcast (#298)
* Add document for simulcast * Update some comments * Change some descriptions * Rewrite some descriptions
1 parent 897a924 commit b42a414

File tree

2 files changed

+74
-1
lines changed

2 files changed

+74
-1
lines changed

docs/jsdoc/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"recurseDepth": 10,
44
"source": {
55
"include": "src/sdk",
6-
"exclude": ["src/sdk/rest", "src/sdk/nuve", "src/sdk/ui"],
6+
"exclude": ["src/sdk/rest", "src/sdk/ui"],
77
"excludePattern": "w*.legacy.*"
88
},
99
"sourceType": "module",

docs/mdfiles/simulcast.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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

Comments
 (0)