Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebRtcServer #834

Merged
merged 60 commits into from
Jun 22, 2022
Merged
Show file tree
Hide file tree
Changes from 46 commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
95aa9ef
RTC::WebRtcServer first commit
ibc Jun 15, 2022
2328e9f
Add TODO_WEBRTC_SERVER.md
ibc Jun 16, 2022
2885079
more
ibc Jun 16, 2022
f7fd0f6
more
ibc Jun 16, 2022
d1d4f78
more
ibc Jun 16, 2022
c0ee2e5
Handle WebRtcServer closure
ibc Jun 16, 2022
e648a53
cosmetic
ibc Jun 16, 2022
8fb82c6
more
ibc Jun 16, 2022
91b7c68
foo
ibc Jun 16, 2022
9c1f7a7
Even more
ibc Jun 16, 2022
5cca09b
more
ibc Jun 16, 2022
0806354
fix things
ibc Jun 16, 2022
b088159
Document an issue
ibc Jun 16, 2022
762ee75
Better doc
ibc Jun 16, 2022
f33dae6
fix STUN USERNAME attribute matching
ibc Jun 16, 2022
0d26814
HArdcode TCP listen backlog to 256 because it's mostly irrelevant
ibc Jun 16, 2022
3637fa3
foo
ibc Jun 16, 2022
899b7f1
Complete more events
ibc Jun 17, 2022
809149e
cosmetic
ibc Jun 17, 2022
b50998d
Add missing IceServer destructor
ibc Jun 17, 2022
1ad4c52
upps
ibc Jun 17, 2022
550a462
More events and a new Set
ibc Jun 17, 2022
4c86951
more
ibc Jun 17, 2022
652aad0
TransportTuple: replace id (string) for hash (size_t)
jmillan Jun 17, 2022
0d1142d
more
ibc Jun 17, 2022
8cc29c7
Complete C++ side
ibc Jun 17, 2022
7762b0f
Add TypeScript layer
ibc Jun 17, 2022
67ba1d0
Fix comment
ibc Jun 17, 2022
ad6900b
TransportTuple: compare tuple by checking the hash
jmillan Jun 17, 2022
fb133bd
Add node/tests/test-WebRtcServer.js (hoever last test produces a crash)
ibc Jun 17, 2022
da815c5
fix lint
ibc Jun 17, 2022
370ba49
fix node/tests/test-WebRtcServer.js
ibc Jun 17, 2022
ad1dcd5
made old Node happy
ibc Jun 17, 2022
e18e231
Fix event name and add test
ibc Jun 17, 2022
839d6b3
WebRtcServer.cpp: cosmetic and add asserts
ibc Jun 17, 2022
51e70e4
IceServer: Limit max number of tuples per WebRtcTransport
ibc Jun 17, 2022
dd0b31c
upps
ibc Jun 17, 2022
dee74b7
Fix terrible regression
ibc Jun 17, 2022
034ad91
Ready for review
ibc Jun 17, 2022
4987b68
Update Changelog
ibc Jun 17, 2022
0915312
fix comments
ibc Jun 17, 2022
4d6e1e8
fix comment
ibc Jun 17, 2022
c0ef9f6
cosmetic
ibc Jun 17, 2022
06a4332
router.createWebRtcTransport(): pass webRtcServerId in internal objec…
ibc Jun 17, 2022
ad12b95
Address feedback
ibc Jun 18, 2022
b7420b0
cosmetic
ibc Jun 18, 2022
1bce071
Have a generic transport.on('listenserverclose') event
ibc Jun 18, 2022
63bc1f0
Add more tests
ibc Jun 18, 2022
facf73a
cosmetic
ibc Jun 18, 2022
2b7a183
more tests
ibc Jun 18, 2022
a989157
TransportTuple.hpp: rename GenerateHash() to SetHash()
ibc Jun 18, 2022
abd3ede
Merge branch 'v3' into webrtcserver
ibc Jun 18, 2022
00e2ff0
Update CHANGELOG.md
ibc Jun 18, 2022
de5275c
cosmetic
ibc Jun 18, 2022
13154c3
Merge branch 'v3' into webrtcserver
ibc Jun 19, 2022
11e0132
Remove deprecated router.createPlainRtpTransport() method
ibc Jun 19, 2022
9ff885c
WebRtcServer: add observer 'webrtctransporthandled' and 'webrtctransp…
ibc Jun 19, 2022
86881e8
WebRtcServer.cpp: don't assert tuple.hash in the table since a malici…
ibc Jun 20, 2022
1caf223
cosmetic
ibc Jun 20, 2022
4671cac
New TransportTuple.hash uint64_t implementation (#839)
ibc Jun 21, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

### WIP

* `WebRtcServer`: A new class that brings to `WebRtcTransports` the ability to listen on a single UDP/TCP port (PR #834).
* `TransportCongestionControlClient`: Allow setting max outgoing bitrate before created (PR #833).


Expand Down
2 changes: 1 addition & 1 deletion node/lib/Router.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export declare class Router extends EnhancedEventEmitter<RouterEvents> {
/**
* Create a WebRtcTransport.
*/
createWebRtcTransport({ listenIps, port, enableUdp, enableTcp, preferUdp, preferTcp, initialAvailableOutgoingBitrate, enableSctp, numSctpStreams, maxSctpMessageSize, sctpSendBufferSize, appData }: WebRtcTransportOptions): Promise<WebRtcTransport>;
createWebRtcTransport({ webRtcServer, listenIps, port, enableUdp, enableTcp, preferUdp, preferTcp, initialAvailableOutgoingBitrate, enableSctp, numSctpStreams, maxSctpMessageSize, sctpSendBufferSize, appData }: WebRtcTransportOptions): Promise<WebRtcTransport>;
/**
* Create a PlainTransport.
*/
Expand Down
2 changes: 1 addition & 1 deletion node/lib/Router.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 31 additions & 19 deletions node/lib/Router.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,27 +159,35 @@ class Router extends EnhancedEventEmitter_1.EnhancedEventEmitter {
/**
* Create a WebRtcTransport.
*/
async createWebRtcTransport({ listenIps, port, enableUdp = true, enableTcp = false, preferUdp = false, preferTcp = false, initialAvailableOutgoingBitrate = 600000, enableSctp = false, numSctpStreams = { OS: 1024, MIS: 1024 }, maxSctpMessageSize = 262144, sctpSendBufferSize = 262144, appData }) {
async createWebRtcTransport({ webRtcServer, listenIps, port, enableUdp = true, enableTcp = false, preferUdp = false, preferTcp = false, initialAvailableOutgoingBitrate = 600000, enableSctp = false, numSctpStreams = { OS: 1024, MIS: 1024 }, maxSctpMessageSize = 262144, sctpSendBufferSize = 262144, appData }) {
logger.debug('createWebRtcTransport()');
if (!Array.isArray(listenIps))
throw new TypeError('missing listenIps');
if (!webRtcServer && !Array.isArray(listenIps))
throw new TypeError('missing webRtcServer and listenIps (one of them is mandatory)');
else if (appData && typeof appData !== 'object')
throw new TypeError('if given, appData must be an object');
listenIps = listenIps.map((listenIp) => {
if (typeof listenIp === 'string' && listenIp) {
return { ip: listenIp };
}
else if (typeof listenIp === 'object') {
return {
ip: listenIp.ip,
announcedIp: listenIp.announcedIp || undefined
};
}
else {
throw new TypeError('wrong listenIp');
}
});
const internal = { ...this.#internal, transportId: (0, uuid_1.v4)() };
if (webRtcServer)
listenIps = undefined;
if (listenIps) {
listenIps = listenIps.map((listenIp) => {
if (typeof listenIp === 'string' && listenIp) {
return { ip: listenIp };
}
else if (typeof listenIp === 'object') {
return {
ip: listenIp.ip,
announcedIp: listenIp.announcedIp || undefined
};
}
else {
throw new TypeError('wrong listenIp');
}
});
}
const internal = {
...this.#internal,
transportId: (0, uuid_1.v4)(),
webRtcServerId: webRtcServer ? webRtcServer.id : undefined
};
const reqData = {
listenIps,
port,
Expand All @@ -194,7 +202,9 @@ class Router extends EnhancedEventEmitter_1.EnhancedEventEmitter {
sctpSendBufferSize,
isDataChannel: true
};
const data = await this.#channel.request('router.createWebRtcTransport', internal, reqData);
const data = webRtcServer
? await this.#channel.request('router.createWebRtcTransportWithServer', internal, reqData)
: await this.#channel.request('router.createWebRtcTransport', internal, reqData);
const transport = new WebRtcTransport_1.WebRtcTransport({
internal,
data,
Expand All @@ -211,6 +221,8 @@ class Router extends EnhancedEventEmitter_1.EnhancedEventEmitter {
transport.on('@producerclose', (producer) => this.#producers.delete(producer.id));
transport.on('@newdataproducer', (dataProducer) => (this.#dataProducers.set(dataProducer.id, dataProducer)));
transport.on('@dataproducerclose', (dataProducer) => (this.#dataProducers.delete(dataProducer.id)));
if (webRtcServer)
webRtcServer.handleWebRtcTransport(transport);
// Emit observer event.
this.#observer.safeEmit('newtransport', transport);
return transport;
Expand Down
7 changes: 7 additions & 0 deletions node/lib/Transport.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,13 @@ export declare class Transport<Events extends TransportEvents = TransportEvents,
* @virtual
*/
routerClosed(): void;
/**
* Just called in WebRtcTransports when closing the associated WebRtcServer.
*
* @private
* @virtual
*/
mustClose(): void;
/**
* Dump Transport.
*/
Expand Down
Loading