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

Commit 4feb50a

Browse files
authored
Merge pull request #384 from jianjunz/quic
Add WebTransport support.
2 parents 1ef8e46 + 6f38f1d commit 4feb50a

File tree

16 files changed

+1670
-31
lines changed

16 files changed

+1670
-31
lines changed

docs/design/webtransport.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# WebTransport
2+
3+
## Introduction
4+
5+
This post describes changes to OWT JavaScript SDK to support QuicTransport of WebTransport. Other APIs defined in WebTransport might be supported in the future. QuicTransport is only supported in conference mode as an experimental feature.
6+
7+
## API Changes
8+
9+
Following APIs will be changed to support QuicTransport.
10+
11+
- `LocalStream` can be constructed with a `WritableStream`.
12+
- `RemoteStream` can be constructed with a `ReadableStream`.
13+
- `ConferenceClient` has new method `createSendStream` which returns a `LocalStream` with a unidirectional stream in it.
14+
- `StreamSourceInfo` has a new bool property `data`.
15+
16+
17+
## Internal Changes
18+
19+
JavaScript SDK creates a QuicTransport with a QUIC agent when QUIC agent is enabled at server side, and WebTransport is supported at client side. When app publishes or subscribes a data stream, a new QuicStream is created.
20+
21+
## Examples
22+
23+
### Send data to a conference
24+
25+
```
26+
const sendStream = conferenceClient.createSendStream();
27+
const localStream = new LocalStream(sendStream, new StreamSourceInfo(undefined, undefined, true));
28+
const publication = await conferenceClient.publish(localStream);
29+
sendStream.stream.write(somethingToWrite);
30+
```
31+
32+
### Receive data from a conference
33+
34+
```
35+
conferenceClient.addEventListener('streamadded', async (event) => {
36+
if (event.stream.source.data) { // Data stream.
37+
const subscription = await conference.subscribe(event.stream);
38+
const reader = subscription.stream.readable.getReader();
39+
while (true) {
40+
const {value, done} = await reader.read();
41+
if (done) {
42+
// Stream ends.
43+
break;
44+
}
45+
ProcessData(value);
46+
}
47+
}
48+
});
49+
```

docs/mdfiles/changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
Change Log
22
==========
3+
# 5.0
4+
* `LocalStream`'s property `mediaStream` is renamed to `stream`. It could also be a `SendStream` or `BidirectionalStream`.
5+
36
# 4.3
47
* The type of `conferenceClient.publish` method's option is changed from `AudioEncodingParameters` and `VideoEncodingParameters` to `RTCRtpSendParameters`.
58
* `audio` and `video` of `PublicationSettings` is changed from `AudioPublicationSettings` and `VideoPublicationSettings` to `AudioPublicationSettings` array and `VideoPublicationSettings` array.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
],
1919
"devDependencies": {
2020
"@babel/core": "^7.11.6",
21+
"@babel/plugin-transform-async-to-generator": "^7.8.3",
2122
"@babel/plugin-transform-runtime": "^7.12.1",
2223
"@babel/preset-env": "^7.11.5",
2324
"@babel/runtime": "^7.12.1",

scripts/Gruntfile.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ window.L = L;\n\
5151
debug: false
5252
},
5353
transform: [
54-
["babelify", { "presets": ["@babel/preset-env"], "plugins": [["@babel/plugin-transform-runtime"]] }]
54+
["babelify", {
55+
"presets": ["@babel/preset-env"],
56+
"plugins": ["@babel/plugin-transform-runtime"]
57+
}]
5558
]
5659
},
5760
},
@@ -64,7 +67,11 @@ window.L = L;\n\
6467
debug: true
6568
},
6669
transform: [
67-
["babelify", { "presets": ["@babel/preset-env"], "plugins": [["@babel/plugin-transform-runtime"]] }]
70+
["babelify", {
71+
"presets": ["@babel/preset-env"],
72+
"plugins": ["@babel/plugin-transform-runtime"
73+
]
74+
}]
6875
],
6976
watch: true
7077
},

src/samples/conference/README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
How to run conference sample
2-
============================
1+
Conference sample
2+
----
3+
4+
## How to run conference sample
35

46
1. Run `npm install`.
57
2. Edit `samplertcservice.js`. Find `icsREST.API.init`, replace service ID, service key and REST server URL with the correct values.
68
3. Copy your SSL server certificate to cert/certificate.pfx.
79
4. Run `initcert.js` to generate a keystore file which contains encrypted SSL server's passphase.
810
5. Run `node samplertcservice.js` to start conference sample. By default, it listens on port 3001(insecure) and 3004(secure).
9-
6. Open a browser and navigate to http://\<hostname\>:3001/ or https://\<hostname\>:3004/.
11+
6. Open a browser and navigate to http://hostname:3001/ or https://hostname:3004/.
12+
13+
## QUIC
14+
15+
`public\scripts\quic.js` was added to create QUIC connections between client and server. After navigating to https://hostname:3004/quic.html?publish=false, the page automatically creates a `SendStream` for publishing. It also listens to `stream-added` message and creates new `ReceiveStream` for subscribing. It doesn't subscribe streams published before joining. Please try to modify `quic.js` if you want to try other QUIC features.

0 commit comments

Comments
 (0)