From ce5794c3d698cf0906a58ff50a80a9e0e3ddd998 Mon Sep 17 00:00:00 2001
From: Justin Uberti Operation
RTCPeerConnection signaling state, ICE gathering state, and ICE
connection state. These are initialized when the object is created.
An RTCPeerConnection
object has two associated
- stream sets. A local streams set,
- representing streams that are currently sent, and a remote streams set, representing streams
- that are currently received with this
- RTCPeerConnection
object. The stream sets are
- initialized to empty sets when the
- RTCPeerConnection
object is created.
When the RTCPeerConnection()
constructor
is invoked, the user agent MUST run the following steps:
When a user agent has reached the point where a
- MediaStream
can be created to represent incoming
+ MediaStreamTrack
can be created to represent incoming
components, the user agent MUST run the following steps:
Create a MediaStream
object
- stream, to represent the incoming media stream.
Create a MediaStreamTrack
object
+ track, to represent the incoming media track.
The creation of new incoming
- MediaStream
s may be triggered either by SDP
+ MediaStreamTrack
s may be triggered either by SDP
negotiation or by the receipt of media on a given flow.
Add stream to connection's remote streams set.
+Create a new RTCRtpReceiver object for track, and add it + to connection's set of receivers.
Fire a stream event named
- addstream
with
- stream at the connection
+
Fire an event named
+ addtrack
with
+ track at the connection
object.
When a user agent has negotiated media for a component that belongs
to a media stream that is already represented by an existing
- MediaStream
object, the user agent MUST associate
- the component with that MediaStream
object.
MediaStreamTrack
object, the user agent MUST associate
+ the component with that MediaStreamTrack
object.
- When an RTCPeerConnection
finds that a stream
+
When an RTCPeerConnection
finds that a track
from the remote peer has been removed, the user agent MUST follow these
steps:
Let connection be the
- RTCPeerConnection
associated with the stream
+ RTCPeerConnection
associated with the track
being removed.
Let stream be the MediaStream
+
Let track be the MediaStreamTrack
object that represents the media stream being removed, if any. If
there isn't one, then abort these steps.
By definition, stream is now ended.
+By definition, track is now ended.
A task is thus queued to update - stream and fire an event.
+ track and fire an event.Remove stream from connection's - remote streams set.
+Remove the RTCRtpSender associated with track from + connection's set of receivers.
Fire a stream event named
- removestream
with
- stream at the connection
+
Fire a track event named
+ ended
+ at the track
object.
Returns a sequence of MediaStream
objects
- representing the streams that are currently sent with this
- RTCPeerConnection
object.
The getLocalStreams()
- method MUST return a new sequence that represents a snapshot of all
- the MediaStream
objects in this
- RTCPeerConnection
object's local streams set. The conversion from the
- streams set to the sequence, to be returned, is user agent defined
- and the order does not have to stable between calls.
Returns a sequence of MediaStream
objects
- representing the streams that are currently received with this
- RTCPeerConnection
object.
The getRemoteStreams()
- method MUST return a new sequence that represents a snapshot of all
- the MediaStream
objects in this
- RTCPeerConnection
object's remote streams set. The conversion from
- the streams set to the sequence, to be returned, is user agent
- defined and the order does not have to stable between calls.
If a MediaStream
object, with an
- id
- equal to streamId, exists in this
- RTCPeerConnection
object's stream sets
- (local streams set or remote streams set), then the getStreamById()
- method MUST return that MediaStream
object. The
- method MUST return null if no stream matches the
- streamId argument.
For this method to make sense, we need to make sure that ids - are unique within the two stream sets of a RTCPeerConnection. - This is not the case today when a peer re-adds a stream that is - received. Two different stream instances will now have the same - id at both peers; one in the remote stream set and one in the - local stream set.
- -One way to resolve this is to not allow re-adding a stream - instance that is received (guard on id). If an application really - needs this functionality it's really easy to make a clone of the - stream, which will give it a new id, and send the clone.
-Adds a new stream to the RTCPeerConnection.
- -When the addStream()
method is invoked, the user agent MUST
- run the following steps:
Let connection be the
- RTCPeerConnection
object on which the
- MediaStream
, stream, is to be
- added.
If connection's RTCPeerConnection
- signalingState is closed
, throw an
- InvalidStateError
exception and abort these
- steps.
If stream is already in connection's - local streams set, then abort - these steps.
-Add stream to connection's local streams set.
-A stream could have contents that are inaccessible to the - application. This can be due to being marked with a - peerIdentity option or anything that would make a - stream - CORS cross-origin. These streams can be added to the - local streams set but content - MUST NOT be transmitted, though streams marked with - peerIdentity can be transmitted if they meet the - requirements for sending (see ).
- -All other streams that are not accessible to the application - MUST NOT be sent to the peer, with silence (audio), black - frames (video) or equivalently absent content being sent in - place of stream content.
- -Note that this property can change over time.
-If connection's RTCPeerConnection
- signalingState is stable
, then fire a negotiationneeded event at
- connection.
Removes the given stream from the
- RTCPeerConnection
.
When the other peer stops sending a stream in this manner, a
- removestream
event is
- fired at the RTCPeerConnection
object.
When the removeStream()
method is invoked, the user agent
- MUST run the following steps:
Let connection be the
- RTCPeerConnection
object on which the
- MediaStream
, stream, is to be
- removed.
If connection's RTCPeerConnection
- signalingState is closed
, throw an
- InvalidStateError
exception.
If stream is not in connection's - local streams set, then abort - these steps.
-Remove stream from connection's - local streams set.
-If connection's RTCPeerConnection
- signalingState is stable
, then fire a negotiationneeded event at
- connection.
setRemoteDescription
, or code. It does not fire for the
initial state change into new
.addstream
, MUST be fired
- by all objects implementing the RTCPeerConnection
- interface. It is called any time a MediaStream
is added
- by the remote peer. This will be fired only as a result of
- setRemoteDescription
. Onnaddstream happens as early as
- possible after the setRemoteDescription
. This callback
- does not wait for a given media stream to be accepted or rejected via
- SDP negotiation.removestream
, MUST be
- fired by all objects implementing the
- RTCPeerConnection
interface. It is called any
- time a MediaStream
is removed by the remote peer. This
- will be fired only as a result of
- setRemoteDescription
.The RTP media API lets a web application send and receive MediaStreamTracks + over a peer-to-peer connection. Tracks, when added to a PeerConnection, result in + signaling; when this signaling is forwarded to a remote peer, it causes + corresponding tracks to be created on the remote side.
+ +The actual encoding and transmission of MediaStreamTracks is managed through + objects called RTCRtpSenders. Similarly, the reception and decoding of + MediaStreamTracks is managed through objects called RTCRtpReceivers.
+ +A RTCPeerConnection
object contains a
+ set of RTCRtpSenders, representing tracks to
+ be sent, and a set of RTCRtpReceivers,
+ representing tracks that are to be received on this
+ RTCPeerConnection
object. Both of these sets are
+ initialized to empty sets when the
+ RTCPeerConnection
object is created.
The RTP media API extends the
+ RTCPeerConnection
interface as described below.
Returns a sequence of RTCRtpSender
objects
+ representing the RTP senders that are currently attached to this
+ RTCPeerConnection
object.
The getSenders()
+ method MUST return a new sequence that represents a snapshot of all
+ the RTCRtpSenders
objects in this
+ RTCPeerConnection
object's set of senders. The conversion from the
+ senders set to the sequence, to be returned, is user agent defined
+ and the order does not have to stable between calls.
Returns a sequence of RTCRtpReceiver
objects
+ representing the RTP receivers that are currently attached to this
+ RTCPeerConnection
object.
The getReceivers()
+ method MUST return a new sequence that represents a snapshot of all
+ the RTCRtpReceiver
objects in this
+ RTCPeerConnection
object's set of receivers. The conversion from
+ the receivers set to the sequence, to be returned, is user agent
+ defined and the order does not have to stable between calls.
Adds a new track to the RTCPeerConnection, and indicate that it + is contained in the specified MediaStreams.
+ +When the addTrack()
method is invoked, the user agent MUST
+ run the following steps:
Let connection be the
+ RTCPeerConnection
object on which the
+ MediaStreamTrack
, track, is to be
+ added.
If connection's RTCPeerConnection
+ signalingState is closed
, throw an
+ InvalidStateError
exception and abort these
+ steps.
If a RTCRtpSender for track already exists in + connection's set of senders, + then abort these steps.
+Create a new RTCRtpSender for track, add it to + connection's set of senders, + and return it to the caller.
+A track could have contents that are inaccessible to the + application. This can be due to being marked with a + peerIdentity option or anything that would make a + track + CORS cross-origin. These tracks can be supplied to the + addTrack method, and have a RTCRtpSender created for them, but content + MUST NOT be transmitted, though tracks marked with + peerIdentity can be transmitted if they meet the + requirements for sending (see ).
+ +All other tracks that are not accessible to the application + MUST NOT be sent to the peer, with silence (audio), black + frames (video) or equivalently absent content being sent in + place of track content.
+ +Note that this property can change over time.
+If connection's RTCPeerConnection
+ signalingState is stable
, then fire a negotiationneeded event at
+ connection.
Removes sender, and its associated MediaStreamTrack, from the
+ RTCPeerConnection
.
When the other peer stops sending a track in this manner, a
+ ended
event is
+ fired at the MediaStreamTrack
object.
When the removeTrack()
method is invoked, the user agent
+ MUST run the following steps:
Let connection be the
+ RTCPeerConnection
object on which the
+ RTCRtpSender
, sender, is to be
+ removed.
If connection's RTCPeerConnection
+ signalingState is closed
, throw an
+ InvalidStateError
exception.
If sender is not in connection's + set of senders, then abort + these steps.
+Remove sender from connection's + set of senders.
+If connection's RTCPeerConnection
+ signalingState is stable
, then fire a negotiationneeded event at
+ connection.
addtrack
, MUST be fired
+ by all objects implementing the RTCPeerConnection
+ interface. It is called any time a MediaStreamTrack
is added
+ by the remote peer. This will be fired only as a result of
+ setRemoteDescription
. onaddtrack happens as early as
+ possible after the setRemoteDescription
. This callback
+ does not wait for a given media track to be accepted or rejected via
+ SDP negotiation.The RTCRtpSender.track
+ attribute is the track that is immutably associated with this
+ RTCRtpSender
object.
The RTCRtpReceiver.track
+ attribute is the track that is immutably associated with this
+ RTCRtpReceiver
object.
The onaddtrack
+ event uses the
+ AddTrackEvent
interface.
Firing an
+ AddTrackEvent event named e with an
+ MediaStreamTrack
track means that an event
+ with the name e, which does not bubble (except where otherwise
+ stated) and is not cancelable (except where otherwise stated), and which
+ uses the AddTrackEvent
interface with the
+ track
attribute
+ set to track, MUST be created and dispatched at the
+ given target.
The track
attribute
+ represents the MediaStreamTrack
object associated with
+ the event.
TODO
+The createDTMFSender() method creates an RTCDTMFSender
- that references the given MediaStreamTrack. The MediaStreamTrack MUST
- be an element of a MediaStream that's currently in the
- RTCPeerConnection
object's local streams set; if not, throw an
+ that references the given MediaStreamTrack. A RTCRtpSender for track
+ MUST already exist in theRTCPeerConnection
object's set of senders; if not, throw an
InvalidParameter
exception and abort these steps.
readyState
set to muted
on the remote peer if
the local user agent disables the corresponding
MediaStreamTrack
in the
- MediaStream
that is being sent. When the addstream
+ MediaStream
that is being sent. When the onaddtrack
event triggers on an RTCPeerConnection
, all
MediaStreamTrack
objects in the resulting
MediaStream
are muted until media data can be read
@@ -4190,48 +4181,6 @@ The addstream
- and removestream
events use the
- MediaStreamEvent
interface.
Firing a
- stream event named e with a
- MediaStream
stream means that an event
- with the name e, which does not bubble (except where otherwise
- stated) and is not cancelable (except where otherwise stated), and which
- uses the MediaStreamEvent
interface with the
- stream
attribute
- set to stream, MUST be created and dispatched at the
- given target.
The stream
attribute
- represents the MediaStream
object associated with
- the event.
TODO
-Used as the argument to addStream()
+ "#widl-RTCPeerConnection-addTrack-void-MediaStream-stream">addTrack()
on an RTCPeerConnection
instance, subject to the
restrictions in .
negotiationneeded
event will not do so during an ongoing
offer/answer dialog.
@@ -4859,25 +4813,13 @@Event summary
- - - - addstream
- - MediaStreamEvent
- A new stream has been added to the remote streams set. - -- From dc0b2169b185ed8d477433013b19abf94ddf4198 Mon Sep 17 00:00:00 2001 From: Justin Uberti+ "event-addtrack"> removestream
addtrack
-+ MediaStreamEvent
AddTrackEvent
- A stream has been removed from the remote streams set. + A new RTCRtpReceiver, and associated MediaStreamTrack, has been added to the set of receivers. Date: Thu, 16 Oct 2014 23:11:19 -0700 Subject: [PATCH 2/5] Respond to CR comments --- webrtc.html | 42 +++++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/webrtc.html b/webrtc.html index b2596e3d9..cf41a6039 100644 --- a/webrtc.html +++ b/webrtc.html @@ -118,7 +118,7 @@ Terminology
Constraints, and Consumer are defined in [[!GETUSERMEDIA]].
When a user agent has reached the point where a
- MediaStreamTrack
can be created to represent incoming
- components, the user agent MUST run the following steps:
MediaStreamTrack
can be created to represent an incoming
+ component, the user agent MUST run the following steps:
Create a MediaStreamTrack
object
- track, to represent the incoming media track.
Create a new RTCRtpReceiver object for track, and add it
+ Create a new RTCRtpReceiver object receiver
+ for track, and add it
to connection's set of receivers.
Fire an event named
addtrack
with
- track at the connection
- object.
If a RTCRtpSender for track already exists in +
If an RTCRtpSender for track already exists in connection's set of senders, then abort these steps.
The RTCRtpSender
interface allows an application to control how a given
+ MediaStreamTrack
is encoded and transmitted to a remote peer.
+ When attributes on an RTCRtpSender
are modified, the encoding is either
+ changed appropriately, or a negotiation is triggered to signal the new encoding
+ parameters to the other side.
The RTCRtpReceiver
interface allows an application to control the receipt
+ of a MediaStreamTrack
. When attributes on an RTCRtpReceiver
are modified, a negotiation is triggered to signal the changes regarding what the application
+ wants to receive to the other side.
The AddTrackEvent
TODO The createDTMFSender() method creates an RTCDTMFSender
- that references the given MediaStreamTrack. A RTCRtpSender for track
+ that references the given MediaStreamTrack. An RTCRtpSender for track
MUST already exist in theRTCPeerConnection Interface Extensions
RTCPeerConnection
object's set of senders; if not, throw an
InvalidParameter
exception and abort these steps.Simple Peer-to-peer Example
// once remote video track arrives, show it in the remote video element
pc.onaddtrack = function (evt) {
if (evt.track.kind === "video") {
- remoteView.srcObject = evt.stream;
+ remoteView.srcObject = evt.streams[0];
}
};
From 9506f8ba10282de586da19dbefc012403c1944cb Mon Sep 17 00:00:00 2001
From: Justin Uberti RTCPeerConnection Interface Extensions
addTrack method, and have an RTCRtpSender created for them, but content
MUST NOT be transmitted, though tracks marked with
peerIdentity can be transmitted if they meet the
- requirements for sending (see ).
All other tracks that are not accessible to the application MUST NOT be sent to the peer, with silence (audio), black @@ -4255,7 +4256,7 @@
Used as the argument to addTrack()
on an RTCPeerConnection
instance, subject to the
- restrictions in .
The onaddtrack
event uses the
- AddTrackEvent
interface.
RTCAddTrackEvent
interface.
Firing an
- AddTrackEvent event named e with an
+ RTCAddTrackEvent event named e with an
MediaStreamTrack
track means that an event
with the name e, which does not bubble (except where otherwise
stated) and is not cancelable (except where otherwise stated), and which
- uses the AddTrackEvent
interface with the
+ uses the RTCAddTrackEvent
interface with the
track
attribute
set to track, MUST be created and dispatched at the
given target.
The receiver
attribute
+ represents the RTCRtpReceiver
object associated with
+ the event.
The track
attribute
- represents the MediaStreamTrack
object associated with
- the event.
MediaStreamTrack
object that is
+ associated with the RTCRtpReceiver
identified by
+ receiver
.
+ The streams
attribute
+ identifies the MediaStream
s that
+ track
is a part of.
TODO
+TODO
+TODO
addtrack
AddTrackEvent
RTCAddTrackEvent
RTCPeerConnection
expecting this media.
- Create a MediaStreamTrack
object
- track, to represent the incoming media track.
- Add track to the MediaStreams streams
- referenced by the SDP
- negotiation, creating a new ones if they do not exist. If no
- MediaStreams are indicated in the SDP negotiation, a default MediaStream
- is used.
Run the algorithm - to represent an incoming component with a track for each incoming - component.
+ to represent the incoming component with a new +MediaStreamTrack
track.
The creation of new incoming
MediaStreamTrack
s may be triggered either by SDP
@@ -540,6 +530,13 @@
MediaStream
s streams
+ referenced by the SDP negotiation, creating new ones if they do not
+ yet exist. If no MediaStream
s are specified,
+ a default MediaStream
is created and used.
+ Queue a task to run the following substeps:
@@ -560,8 +557,8 @@Fire an event named
- addtrack
with
+ track
with
receiver, track, and streams
at the connection object.
When a user agent has negotiated media for a component that belongs
- to a media stream that is already represented by an existing
+ to a media track that is already represented by an existing
MediaStreamTrack
object, the user agent MUST associate
the component with that MediaStreamTrack
object.
Let track be the MediaStreamTrack
- object that represents the media stream being removed, if any. If
+ object that represents the track being removed, if any. If
there isn't one, then abort these steps.
Remove the RTCRtpSender associated with track from +
Remove the RTCRtpReceiver associated with track from connection's set of receivers.
Fire a track event named
- ended
- at the track
- object.
End the track object.
RTCPeerConnection
object.
The getSenders()
+ "dom-peerconnection-getsenders">getSenders()
method MUST return a new sequence that represents a snapshot of all
the RTCRtpSenders
objects in this
RTCPeerConnection
object's RTCPeerConnection Interface Extensions
RTCPeerConnection
object.
The When the other peer stops sending a track in this manner, a
getReceivers()
+ "dom-peerconnection-getreceivers">getReceivers()
method MUST return a new sequence that represents a snapshot of all
the RTCRtpReceiver
objects in this
RTCPeerConnection
object's RTCPeerConnection Interface Extensions
ended
event is
+ "#event-mediastream-ended">endedMediaStreamTrack
object.
When the RTCPeerConnection Interface Extensions
-
addtrack
, MUST be fired
+ "#event-track">track
RTCPeerConnection
interface. It is called any time a MediaStreamTrack
is added
by the remote peer. This will be fired only as a result of
- setRemoteDescription
. onaddtrack happens as early as
+ setRemoteDescription
. ontrack happens as early as
possible after the setRemoteDescription
. This callback
does not wait for a given media track to be accepted or rejected via
SDP negotiation.
@@ -2005,13 +1998,13 @@ The RTCRtpSender.track
- attribute is the track that is immutably associated with this
+ attribute is the track that is associated with this
RTCRtpSender
object.
The onaddtrack
+
The ontrack
event uses the
- RTCAddTrackEvent
interface.
RTCTrackEvent
interface.
- Firing an - RTCAddTrackEvent event named e with an +
Firing an
+ RTCTrackEvent event named e with an
MediaStreamTrack
track means that an event
with the name e, which does not bubble (except where otherwise
stated) and is not cancelable (except where otherwise stated), and which
- uses the RTCAddTrackEvent
interface with the
- track
attribute
+ uses the RTCTrackEvent
interface with the
+ track
attribute
set to track, MUST be created and dispatched at the
given target.
The receiver
attribute
+ "dom-trackevent-receiver">receiver
attribute
represents the RTCRtpReceiver
object associated with
the event.
The track
attribute
+ "dom-trackevent-track">track
attribute
represents the MediaStreamTrack
object that is
associated with the RTCRtpReceiver
identified by
receiver
.
The streams
attribute
- identifies the MediaStream
s that
+
Returns a sequence of MediaStream
objects
+ representing the MediaStream
s that this event's
track
is a part of.
var baselineReport, currentReport; -var selector = pc.getRemoteStreams()[0].getAudioTracks()[0]; +var selector = pc.getSenders()[0].track; pc.getStats(selector, function (report) { baselineReport = report; @@ -4211,7 +4203,7 @@MediaStreamTrack
readyState
set tomuted
on the remote peer if the local user agent disables the correspondingMediaStreamTrack
in the -MediaStream
that is being sent. When the onaddtrack +MediaStream
that is being sent. When the ontrack event triggers on anRTCPeerConnection
, allMediaStreamTrack
objects in the resultingMediaStream
are muted until media data can be read @@ -4465,19 +4457,18 @@Simple Peer-to-peer Example
} // once remote video track arrives, show it in the remote video element - pc.onaddtrack = function (evt) { - if (evt.track.kind === "video") { + pc.ontrack = function (evt) { + if (evt.track.kind === "video") remoteView.srcObject = evt.streams[0]; - } }; // get a local stream, show it in a self-view and add it to be sent navigator.mediaDevices.getUserMedia({ "audio": true, "video": true }, function (stream) { selfView.srcObject = stream; if (stream.getAudioTracks().length > 0) - pc.addTrack(stream.getAudioTracks(0), stream); + pc.addTrack(stream.getAudioTracks()[0], stream); if (stream.getVideoTracks().length > 0) - pc.addTrack(stream.getVideoTracks(0), stream); + pc.addTrack(stream.getVideoTracks()[0], stream); }, logError); } @@ -4853,9 +4844,9 @@Event summary
+ "event-track"> addtrack
track
-+ RTCAddTrackEvent
RTCTrackEvent
A new RTCRtpReceiver, and associated MediaStreamTrack, has been added to the