author Boris Zbarsky <>
Wed, 20 Mar 2019 18:05:09 +0000
changeset 465263 3ab48ce01773af9a130477e46c50e17f9042ea4b
parent 396893 dc853f9fd97293ff703530d806ebf2633740ed69
permissions -rw-r--r--
Bug 1535124 part 3. Add MOZ_CAN_RUN_SCRIPT annotations to geolocation code as needed. r=jdm Differential Revision:

This is a generic media transport system for WebRTC.

The basic model is that you have a TransportFlow which contains a
series of TransportLayers, each of which gets an opportunity to
manipulate data up and down the stack (think SysV STREAMS or a
standard networking stack). You can also address individual
sublayers to manipulate them or to bypass reading and writing
at an upper layer; WebRTC uses this to implement DTLS-SRTP.

Unlike the existing nsSocket I/O system, this is a push rather
than a pull system. Clients of the interface do writes downward
with SendPacket() and receive notification of incoming packets
via callbacks registed via sigslot.h. It is the responsibility
of the bottom layer (or any other layer which needs to reference
external events) to arrange for that somehow; typically by
using nsITimer or the SocketTansportService.

This sort of push model is a much better fit for the demands
of WebRTC, expecially because ICE contexts span multiple
network transports.

There are no thread locks. It is the responsibility of the caller to
arrange that any given TransportLayer/TransportFlow is only
manipulated in one thread at once. One good way to do this is to run
everything on the STS thread. Many of the existing layer implementations
(TransportLayerIce, TransportLayerLoopback) already run on STS so in those
cases you must run on STS, though you can do setup on the main thread and
then activate them on the STS.

The following transport layers are currently implemented:

* DTLS -- a wrapper around NSS's DTLS [RFC 6347] stack
* ICE  -- a wrapper around the nICEr ICE [RFC 5245] stack.
* Loopback -- a loopback IO mechanism
* Logging -- a passthrough that just logs its data

The last two are primarily for debugging.