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

Commit 5d84bcc

Browse files
starwarfanlzhai
authored andcommitted
Add simulcast section in doc (#304)
1 parent 5c97cb0 commit 5d84bcc

File tree

2 files changed

+70
-79
lines changed

2 files changed

+70
-79
lines changed

docs/mdfiles/index.md

Lines changed: 70 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,81 @@ In the customized signaling channel, you need to implement `connect`, `disconnec
7070

7171
# 5 Conference mode
7272

73-
Conference mode is designed for applications with multiple participants. The JavaScript SDK includes a demo application for this.
74-
75-
Please refer to [media server user guide](https://software.intel.com/sites/products/documentation/webrtc/conference) for detailed server side features.
76-
77-
To initialize your HTML code, copy and paste the following code into the head section of your HTML document:
73+
Conference mode is designed for applications with multiple participants through MCU conference server. To enable conference chat, copy and paste the following code into the head section of your HTML document:
7874
~~~~~~{.js}
7975
<script type="text/javascript" src="socket.io.js"></script>
8076
<script type="text/javascript" src="adapter.js"></script>
8177
<script type="text/javascript" src="owt.js"></script>
8278
~~~~~~
83-
After a room and a token are created, the token can then be sent to a client to join the conference using JavaScript APIs.
79+
80+
The JavaScript SDK includes a demo application for whole conferencing workflow with operations including join room, publish and subscribe streams, etc. Moreover, the conference server also supports simulcast. This can be enabled through JavaScript SDK.
81+
82+
## 5.1 Publish a simulcast stream
83+
~~~~~~{.js}
84+
// Example of simulcast publication.
85+
conference = new Owt.Conference.ConferenceClient();
86+
// ...
87+
conference.join(token).then(resp => {
88+
// ...
89+
Owt.Base.MediaStreamFactory.createMediaStream(new Owt.Base.StreamConstraints(
90+
audioConstraints, videoConstraints)).then(stream => {
91+
/*
92+
* Use `RTCRtpEncodingParameters` as publish option
93+
* (https://w3c.github.io/webrtc-pc/#dom-rtcrtpencodingparameters).
94+
* The following option would create 3 streams with resolutions if browser supports:
95+
* OriginResolution, OriginResolution/2.0 and OriginResolution/4.0.
96+
* For current Firefox, the resolutions should be sorted in descending order(reversed sample's option).
97+
* For current Safari, legacy simulcast is used and the parameters like `rid` won't take effect.
98+
* Besides `scaleResolutionDownBy`, other `RTCRtpEncodingParameters` can be set
99+
* if browser supports.
100+
* The actual output will be determined by browsers, the outcome may not be exactly same
101+
* as what is set in publishOption, e.g. For a vga video stream, there may be 2 RTP streams
102+
* rather than 3.
103+
*/
104+
const publishOption = {video:[
105+
{rid: 'q', active: true, scaleResolutionDownBy: 4.0},
106+
{rid: 'h', active: true, scaleResolutionDownBy: 2.0},
107+
{rid: 'f', active: true, scaleResolutionDownBy: 1.0}
108+
]};
109+
/*
110+
* Codec priority list.
111+
* Here 'vp8' will be used if enabled.
112+
*/
113+
const codecs = ['vp8', 'h264'];
114+
localStream = new Owt.Base.LocalStream(
115+
stream, new Owt.Base.StreamSourceInfo(
116+
'mic', 'camera'));
117+
conference.publish(localStream, publishOption, codecs).then(publication => {
118+
// ...
119+
});
120+
});
121+
~~~~~~
122+
123+
## 5.2 Subscribe a simulcast stream
124+
~~~~~~{.js}
125+
// Example of subscription.
126+
conference = new Owt.Conference.ConferenceClient();
127+
// ...
128+
conference.join(token).then(resp => {
129+
// ...
130+
/*
131+
* Subscribe simulcast stream with specified `rid`
132+
* which can be found in `RemoteStream.settings.video[i].rid`.
133+
* If `rid` is set when subscribing, other parameters will be ignored.
134+
*/
135+
const subscribeOption = {
136+
audio: true,
137+
video: {rid: 'q'}
138+
};
139+
conference.subscribe(remoteStream, subscribeOption).then((subscription) => {
140+
// ...
141+
});
142+
~~~~~~
143+
144+
**Note**:
145+
a. The simulcast stream published to conference won't be transcoded.
146+
b. The `rid` attribute may not be present once a 'streamadded' event triggered. Users should listen on stream's `updated` event for new `rid` added.
147+
c. Current browsers support VP8 simulcast well while H.264 simulcast has some limitations.
84148

85149
# 6 Events
86150

docs/mdfiles/simulcast.md

Lines changed: 0 additions & 73 deletions
This file was deleted.

0 commit comments

Comments
 (0)