This document defines a set of ECMAScript APIs in WebIDL to allow media to be sent and received from another browser or device implementing the appropriate set of real-time protocols. However, unlike the current WebRTC 1.0 APIs, ORTC does not mandate a media signaling protocol or format. As a result, ORTC does not utilize SDP within its APIs, nor does it mandate support for the Offer/Answer state machine. Instead, ORTC focuses on "connections" and "tracks" being carried over those connections.
ORTC provides a powerful API for the development of WebRTC based applications. ORTC does not mandate a media signaling protocol or format (as the current WebRTC 1.0 does by mandating SDP Offer/Answer). ORTC focuses on "connections" and "tracks" being carried over those connections.
RTCConnection is the main class of ORTC. A RTCConnection instance provides the interface for a browser to directly communicate with another browser or a compliant device, for sending and receiving media stream tracks. Communication is signaled through an external means such as via HTTP or WebSocket through a web server or WebSocket server by unspecified means.
A peer instantiates a RTCConnection. Once the RTCConnection has been instantiated and the connect method called, the ICE gathering procedure automatically starts retrieving local ICE candidates.
The peer can, at any time, signal its ICE information to the remote peer. Once the remote ICE information is entered into the RTCConnection ICE establishment procedure begins until the connection is established. ICE candidates can be signaled one by one to each other or at any time (trickle-ICE). In order to apply a discovered local ICE candidate in the RTCConnection the event oncandidate is called by passing as argument the RTCIceCandidateInfo. The remote ICE candidates are added to the RTCConnection by using the addRemoteCandidate method.
The developer's JavaScript can attach MediaStream instances to the RTCConnection to be sent to the remote peer. Audio/video sending tracks can be individually managed by constructing their associated RTCTrack instance via the send method. The developer's JavaScript can also signal the receiving tracks information by providing an RTCTrack to the receive method.
Adds a remote ICE candidate to the RTCConnection.
Parameter | Type | Nullable | Optional | Description |
candidate | RTCIceCandidateInfo | no | no |
Starts the ICE connectivity tests and establishment procedure with the peer. If remote ICE candidates are provided once this method has been called, they will be also considered for the ICE connection connectivity testing procedure.
If gather has not been called at this point then it is implicitly called to start the candidate discovery process.
Connection data for the remote side (the iceUsernameFrag and icePassword attributes within the remote RTCConnectionInfo attribute) must be set before calling this method.
This method will usually be called automatically upon onnetworkchange but can be called manually when a higher layer detects a network topology change (e.g. in mobile network). By calling this method the ICE candidate gathering procedure re-starts again as it did when the RTCConnection was instantiated and onendofcandidates will be called again when no more candidates are able to be discovered.
If gather is called before connect, the ICE candidate gathering process will start immediately but no connectivity checks will be performed until connect is called.
Starts sending a MediaStream or MediaStreamTrack over an RTCConnection.
If an MediaStream is passed in an RTCStream is returned. If an MediaStreamTrack is passed in an RTCTrack is returned.
To send or update the attributes for an existing RTCStream or an RTCTrack call the method with the updated object values. Upon success the same object is returned.
Parameter | Type | Nullable | Optional | Description |
streamOrTrack | MediaStream or MediaStreamTrack or RTCStream or RTCTrack | no | no |
Tell the RTCConnection to expect to start receiving a RTCStream or RTCTrack from the remote peer.
By creating an RTCStream or an RTCTrack with the correct values pre-filled this method will start the receive process for the stream or track from the RTCConnection. Upon success the source for the respective RTCStream and RTCTrack are filled with the MediaStream or MediaStreamTrack objects.
Parameter | Type | Nullable | Optional | Description |
streamOrTrack | RTCStream or RTCTrack | no | no |
Returns a sequence of RTCStream instances being sent over the RTCConnection.
Returns a sequence of RTCTrack instances being received over the RTCConnection.
This event handler, of event handler event type candidate, must be fired to allow a developer's JavaScript to receive a discovered ICE candidate (RTCIceCandidateInfo).
To preserve privacy, this event's default action can be canceled (see http://www.w3.org/TR/DOM-Level-3-Events/#events-event-type-canCancel). The default action is to add the candidate to the list of connectivity tests. Canceling the candidate event will prevent connectivity tests on the candidate.
Event Argument | Description |
RTCIceCandidateInfo candidate | A local ICE candidate. |
This event handler, of event handler event type endofcandidates, must be fired to allow a developer's JavaScript to be notified when all candidate discoveries have completed after the connect method is called and after the gather method executes and completes.
Event arguments: none
This event handler, of event handler event type activecandidate, must be fired to allow a developer's JavaScript to be notified which active ICE candidate local/remote pairing the connection is using. This event could change over time as more optimal routes are discovered.
Event Argument | Description |
RTCIceCandidateInfo localCandidate | The connected local ICE candidate. |
RTCIceCandidateInfo remoteCandidate | The connected remote ICE candidate. |
This event handler, of event handler event type statechanged, must be fired to allow a developer's JavaScript to be notified when the RTCConnection object state has changed.
Event Argument | Description |
RTCConnectionState state | The state at the time this event fired. |
This event handler, of event handler event type networkchange, must be fired to allow a developer's JavaScript to be notified when a change has been detected in the network topology.
The default action is to automatically call the RTCConnection gather method. This event's default action can be canceled (see http://www.w3.org/TR/DOM-Level-3-Events/#events-event-type-canCancel).
Event arguments: none
This event handler, of event handler event type unknowntrack, must be fired to allow a developer's JavaScript to be notified when a track for which there is not RTCTrack has been connected from the remote peer.
It is possible for a peer to receive a track for which its RTCTrack information has not yet been received (via wire signaling) and added via the receive method or for which there won't be RTCTrack known in advance at all. If an unknown track (for which there is no RTCTrack) is connected this event fires by providing the RTCTrack and a collection of the RTP extension headers present in the RTP packets.
The offerer can then indicate, via custom wire signaling, those desired RTP extension header and values to the remote peer, and the remote peer starts sending tracks with the requested RTP extension headers, so the offerer can identify them when the onunknowntrack event fires.
Event Argument | Description |
RTCTrack track | The newly discovered track object. |
Object rtpExtHeaders | A collection of RTP extension header and value pairs. |
Prior to the RTCConnection connect method being called, the RTCConnectionRole is the suggested role for the object. The object can automatically switch roles upon entering the RTCConnectionState connected state.
The default value for the role is controlling and the attribute becomes readonly once the RTCConnection connect method is called.
A local RTCSocket to be reused (which can be retrieved from another RTCConnection instance via the socket attribute).
Reusing the same local socket can be used to implement media forking.
The RTCIceServer is used to provide STUN or TURN server configuration.
In network topologies with multiple layers of NATs, it is desirable to have a STUN server between every layer of NATs in addition to the TURN servers to minimize the peer to peer network latency.
An example array of RTCIceServer objects is:
[ { url:"stun:stun.example.net" } , { url:"turn:user@turn.example.org", credential:"myPassword"} ]
The RTCConnectionInfo object contains information for the local and remote connection connection. An RTCConnection has both a local RTCConnectionInfo (whose attributes are readonly) and a remote RTCConnectionInfo (whose attributes must be set by the JavaScript's developer before attempting the connection procedure (this is, before calling connect on the RTCConnection).
The RTCIceCandidateInfo includes all information relevant to an ICE candidate.
{
foundation: "abcd1234",
component: 1,
transport: "udp",
priority: 1694498815,
connectionAddress: "192.0.2.33",
connectionPort: 10000,
type: "host"
};
The RTCSocket object describes a local physical socket. A local socket can be reused within different RTCConnection instances (useful for media forking situations).
A RTCSocket instance is retrieved from a RTCConnection via the socket attribute.
An RTCStream instance is associated to a sending or receiving MediaStream and provides RTC related methods to it.
A RTCStream instance is retrieved from a RTCConnection via the sendStreams or receiveStreams methods.
An RTCTrack instance is associated to a sending MediaStreamTrack and provides RTC related methods to it.
A RTCTrack instance is retrieved from a RTCConnection via the track or tracks methods or constructed from an MediaStreamTrack object.
The associated MediaStreamTrack instance.
This attribute does not jsonify so that the entire object can be jsonified for easier signaling.
{
kind: "audio",
ssrc: "1234",
codecs: [
{
payload-id: 96,
name: "opus",
clockRate: 48000,
numChannels: 2
}
]
};
TODO: Complete.
An RTCDTMFTrack class instance allows sending DTMF tones to/from the remote peer.
This event handler, of event handler event type tone, must be fired to allow a developer's JavaScript to receive a DTMF tone from the remote peer.
Event Argument | Description |
DOMString tone | The received DTMF character. |
unsigned length duration | The duration of the tone (in milliseconds). |
Method used for sending DTMF tones. The tones parameter is treated as a series of characters. The characters 0 through 9, A through D, #, and * generate the associated DTMF tones. The characters a to d are equivalent to A to D. The character ',' indicates a delay of 2 seconds before processing the next character in the tones parameter. Unrecognized characters are ignored.
The duration parameter indicates the duration in ms to use for each character passed in the tones parameters. The duration cannot be more than 6000 ms or less than 70 ms. The default duration is 100 ms for each tone.
The interToneGap parameter indicates the gap between tones. It must be at least 70 ms. The default value is 70 ms.
Parameter | Type | Nullable | Optional | Description |
tones | DOMString | no | no | |
duration | long | no | yes | |
interToneGap | long | no | yes |
playTones
Calling the constructor method of RTCDTMFTrack with a MediaStreamTrack would enhance the RTCTrack and result in a structure as follows:
{
id: "id",
kind: "audio",
ssrc: "1234",
msid: ["m1"],
codecs: [
{
payload-id: 96,
name: "opus",
clockRate: 48000,
numChannels: 2
},
{
payload-id: 101,
name: "dtmf"
}
]
}
An RTCDataChannel class instance allows sending data messages to/from the remote peer.
Method used for sending data to the remote peer.
Parameter | Type | Nullable | Optional | Description |
data | Object | no | no |
This event handler, of event handler event type data, must be fired to allow a developer's JavaScript to receive data from a remote peer.
Event Argument | Description |
Object data | The received remote data. |
This specification determines that RTCP packets must be multiplexed with the RTP packets as defined by RFC5761.
ORTC extends the Navigator interface for providing WebRTC capabilities to the developer's JavaScript.
interface Navigator {
RTCCapabilities getRTCCapabilities ();
RTCCodec getRTCCodec ();
};
getRTCCapabilities
Get the browser WebRTC capabilities by returning a RTCCapabilities object.
Parameters: none
getRTCCodec
Get a RTCCodec object for the given codec name or null if the browser does not support it. The mandatory list of codec names are: opus, alaw, ulaw, dtmf, vp8 and h264.
Parameter Type Nullable Optional Description name DOMString no no The name of the codec (i.e. "opus").
dictionary RTCCapabilities {
sequence<RTCCodec> audioCodecs;
sequence<RTCCodec> videoCodecs;
};
TODO: Complete.
audioCodecs of type sequence
The list of supported audio codecs.
videoCodecs of type sequence
The list of supported video codecs.
This specification extends the MediaCapture MediaStream class for remote streams received from the network, by adding/modifying the following methods and events:
addTrack
This method, already present in the MediaStream class, allows the JS to add a new MediaStreamTrack within the stream. Currently it is unclear whether the given MediaStreamTrack remains the same or it is cloned into the stream (so becomes a new MediaStreamTrack instance (see the reported issue in Chrome browser).
In case the given MediaStreamTrack is cloned, this specification modifies the addTrack method so instead of returning void it returns the new MediaStreamTrack instance:
Parameter Type Nullable Optional Description track MediaStreamTrack no no In case it is decided that the
addTrack()
method does not clone the given track (but keeps the same MediaStreamTrack instance), then that means that the same MediaStreamTrack should not be added to two different MediaStream within the same RTCConnection.It is unclear the benefit of adding the same track into two media streams, and thus this specification advocates for the cloning solution.
onconnected of type EventHandler,
This event handler, of event handler event type connected, must be fired to allow a developer's JavaScript to be notified when a remote MediaStream is connected, which means that RTP for at least one of the tracks in this MediaStream has been received.
Event arguments: none
ondisconnected of type EventHandler,
This event handler, of event handler event type disconnected, must be fired to allow a developer's JavaScript to be notified when a remote MediaStream is disconnected, which means that a RTCP BYE has been received or RTP timeout occurred for the last remaining track in this MediaStream.
Event arguments: none
This specification extends the MediaCapture MediaStreamTrack class for remote tracks received from the network, by adding the following events:
onconnected of type EventHandler,
This event handler, of event handler event type connected, must be fired to allow a developer's JavaScript to be notified when a remote MediaStreamTrack is connected, which means that RTP for this track has been received.
Note that this event is just fired for a remote MediaStreamTrack which MediaStream was already connected (so onaddstream event was called for it).
Event arguments: none
ondisconnected of type EventHandler,
This event handler, of event handler event type disconnected, must be fired to allow a developer's JavaScript to be notified when a remote MediaStreamTrack is disconnected, which means that a RTCP BYE has been received or RTP timeout occurred.
Event arguments: none
This example code provides a basic audio&video session between two browsers.
var signalingChannel = new SignalingChannel();
var conn;
// call start() to initiate
function start() {
conn = new RTCConnection({ iceServers: [{ url: "stun:stun.example.org" }] });
// send my ICE information to the other peer
signalingChannel.send(JSON.stringify({ "iceInfo": { "usernameFrag": conn.local.ice.usernameFrag, "password": conn.local.ice.password } }));
// apply any local ICE candidate and send it to the remote
conn.oncandidate = function (evt) {
signalingChannel.send(JSON.stringify({ "candidate": evt.candidate }));
}
// get a local stream, show it in a self-view and add it to be sent
navigator.getUserMedia({ "audio": true, "video": true }, function (stream) {
selfView.src = URL.createObjectURL(stream);
conn.send(stream);
// send stream description to the peer
conn.sendStreams().forEach(function(stream) {
signalingChannel.send(JSON.stringify({ "stream": stream }));
});
}, logError);
}
signalingChannel.onmessage = function (evt) {
if (!conn)
start();
var message = JSON.parse(evt.data);
if (message.iceInfo) {
conn.remote.ice.usernameFrag = message.iceInfo.usernameFrag;
conn.remote.ice.password = message.iceInfo.password;
conn.connect();
}
if (message.candidate) {
conn.addRemoteCandidate(message.candidate);
}
if (message.stream) {
// once remote stream information arrives, show it in the remote video element
remoteView.src = URL.createObjectURL(conn.receive(message.stream).source);
}
};
function logError(error) {
log(error.name + ": " + error.message);
}