From ce5794c3d698cf0906a58ff50a80a9e0e3ddd998 Mon Sep 17 00:00:00 2001 From: Justin Uberti Date: Tue, 14 Oct 2014 23:11:22 -0700 Subject: [PATCH 1/5] Add RTCRtpSender, RTCRtpSender, and friends --- webrtc.html | 694 ++++++++++++++++++++++++---------------------------- 1 file changed, 318 insertions(+), 376 deletions(-) diff --git a/webrtc.html b/webrtc.html index 4dc2321d0..b2596e3d9 100644 --- a/webrtc.html +++ b/webrtc.html @@ -325,15 +325,6 @@

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:

@@ -518,7 +509,7 @@

Operation

"component".

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:

    @@ -528,8 +519,8 @@

    Operation

  1. -

    Create a MediaStream object - stream, to represent the incoming media stream.

    +

    Create a MediaStreamTrack object + track, to represent the incoming media track.

  2. @@ -538,7 +529,7 @@

    Operation

    component.

    The creation of new incoming - MediaStreams may be triggered either by SDP + MediaStreamTracks may be triggered either by SDP negotiation or by the receipt of media on a given flow.

    @@ -556,15 +547,16 @@

    Operation

  3. -

    Add stream to connection's remote streams set.

    +

    Create a new RTCRtpReceiver object for track, and add it + to connection's set of receivers.

  4. -

    Fire a stream event named - addstream with - stream at the connection +

    Fire an event named + addtrack with + track at the connection object.

@@ -573,32 +565,32 @@

Operation

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:

  1. Let connection be the - RTCPeerConnection associated with the stream + RTCPeerConnection associated with the track being removed.

  2. -

    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.

  3. -

    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.

  4. @@ -614,15 +606,15 @@

    Operation

    task ran -->
  5. -

    Remove stream from connection's - remote streams set.

    +

    Remove the RTCRtpSender associated with track from + connection's set of receivers.

  6. -

    Fire a stream event named - removestream with - stream at the connection +

    Fire a track event named + ended + at the track object.

@@ -1256,259 +1248,6 @@

Interface Definition

"#ice-servers-list">ICE servers list.

-
sequence<MediaStream> getLocalStreams()
- -
-

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.

-
- -
sequence<MediaStream> getRemoteStreams()
- -
-

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.

-
- -
MediaStream? getStreamById(DOMString streamId)
- -
-

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.

-
-
- -
void addStream (MediaStream stream)
- -
-

Adds a new stream to the RTCPeerConnection.

- -

When the addStream() method is invoked, the user agent MUST - run the following steps:

- -
    -
  1. -

    Let connection be the - RTCPeerConnection object on which the - MediaStream, stream, is to be - added.

    -
  2. - -
  3. -

    If connection's RTCPeerConnection - signalingState is closed, throw an - InvalidStateError exception and abort these - steps.

    -
  4. - -
  5. -

    If stream is already in connection's - local streams set, then abort - these steps.

    -
  6. - -
  7. -

    Add stream to connection's local streams set.

    -
  8. - -
  9. -

    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.

    -
  10. - -
  11. -

    If connection's RTCPeerConnection - signalingState is stable, then fire a negotiationneeded event at - connection.

    -
  12. -
-
- -
void removeStream (MediaStream stream)
- -
-

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:

- -
    -
  1. -

    Let connection be the - RTCPeerConnection object on which the - MediaStream, stream, is to be - removed.

    -
  2. - -
  3. -

    If connection's RTCPeerConnection - signalingState is closed, throw an - InvalidStateError exception.

    -
  4. - -
  5. -

    If stream is not in connection's - local streams set, then abort - these steps.

    -
  6. - -
  7. -

    Remove stream from connection's - local streams set.

    -
  8. - -
  9. -

    If connection's RTCPeerConnection - signalingState is stable, then fire a negotiationneeded event at - connection.

    -
  10. -
-
-
void close ()
@@ -1562,28 +1301,6 @@

Interface Definition

setRemoteDescription, or code. It does not fire for the initial state change into new.
-
attribute EventHandler onaddstream
- -
This event handler, of event handler event type 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.
- -
attribute EventHandler onremovestream
- -
This event handler, of event handler event type 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.
-
attribute EventHandler oniceconnectionstatechange
@@ -2074,6 +1791,281 @@

RTCPeerConnectionIceEvent

+
+

RTP media API

+ +

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.

+ +
+

RTCPeerConnection Interface Extensions

+ +

The RTP media API extends the + RTCPeerConnection interface as described below.

+ +
+
sequence<RTCRtpSender> getSenders()
+ +
+

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.

+
+ +
sequence<RTCRtpReceiver> getReceivers()
+ +
+

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.

+
+ +
RTCRtpSender addTrack (MediaStreamTrack track, MediaStream... streams)
+ +
+

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:

+ +
    +
  1. +

    Let connection be the + RTCPeerConnection object on which the + MediaStreamTrack, track, is to be + added.

    +
  2. + +
  3. +

    If connection's RTCPeerConnection + signalingState is closed, throw an + InvalidStateError exception and abort these + steps.

    +
  4. + +
  5. +

    If a RTCRtpSender for track already exists in + connection's set of senders, + then abort these steps.

    +
  6. + +
  7. +

    Create a new RTCRtpSender for track, add it to + connection's set of senders, + and return it to the caller.

    +
  8. + +
  9. +

    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.

    +
  10. + +
  11. +

    If connection's RTCPeerConnection + signalingState is stable, then fire a negotiationneeded event at + connection.

    +
  12. +
+
+ +
void removeTrack (RTCRtpSender sender)
+ +
+

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:

+ +
    +
  1. +

    Let connection be the + RTCPeerConnection object on which the + RTCRtpSender, sender, is to be + removed.

    +
  2. + +
  3. +

    If connection's RTCPeerConnection + signalingState is closed, throw an + InvalidStateError exception.

    +
  4. + +
  5. +

    If sender is not in connection's + set of senders, then abort + these steps.

    +
  6. + +
  7. +

    Remove sender from connection's + set of senders.

    +
  8. + +
  9. +

    If connection's RTCPeerConnection + signalingState is stable, then fire a negotiationneeded event at + connection.

    +
  10. +
+
+ +
attribute EventHandler onaddtrack
+ +
This event handler, of event handler event type 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.
+ +
+ +
+ +
+

RTCRtpSender Interface

+ +
+
readonly attribute MediaStreamTrack track
+ +
+

The RTCRtpSender.track + attribute is the track that is immutably associated with this + RTCRtpSender object.

+
+
+ +
+

RTCRtpReceiver Interface

+ +
+
readonly attribute MediaStreamTrack track
+ +
+

The RTCRtpReceiver.track + attribute is the track that is immutably associated with this + RTCRtpReceiver object.

+
+
+ +
+

AddTrackEvent

+ +

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.

+ +
+
Constructor(DOMString type, AddTrackEventInit + eventInitDict)
+ +
readonly attribute RTCRtpReceiver receiver
+
readonly attribute MediaStreamTrack track
+
readonly attribute MediaStream stream
+ +
+

The track attribute + represents the MediaStreamTrack object associated with + the event.

+
+
+ +
+ +
RTCRtpReceiver receiver
+
MediaStreamTrack track
+
MediaStream stream
+ +
+

TODO

+
+
+
+ +
+

Peer-to-peer Data API

@@ -2909,10 +2901,9 @@

RTCPeerConnection Interface Extensions

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.

@@ -4180,7 +4171,7 @@

MediaStreamTrack

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 @@

MediaStreamTrack

seems like an SDP question, not a media-level question.

-
-

MediaStreamEvent

- -

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.

- -
-
Constructor(DOMString type, MediaStreamEventInit - eventInitDict)
- -
readonly attribute MediaStream? stream
- -
-

The stream attribute - represents the MediaStream object associated with - the event.

-
-
- -
-
MediaStream stream
- -
-

TODO

-
-
-
-

Isolated Media Streams

@@ -4288,7 +4237,7 @@

Isolated Media Streams

  • Used as the argument to addStream() + "#widl-RTCPeerConnection-addTrack-void-MediaStream-stream">addTrack() on an RTCPeerConnection instance, subject to the restrictions in .

  • @@ -4475,15 +4424,20 @@

    Simple Peer-to-peer Example

    pc.createOffer(localDescCreated, logError); } - // once remote stream arrives, show it in the remote video element - pc.onaddstream = function (evt) { - remoteView.srcObject = evt.stream; + // 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; + } }; // 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; - pc.addStream(stream); + if (stream.getAudioTracks().length > 0) + pc.addTrack(stream.getAudioTracks(0), stream); + if (stream.getVideoTracks().length > 0) + pc.addTrack(stream.getVideoTracks(0), stream); }, logError); } @@ -4546,7 +4500,7 @@

    Peer-to-peer Data Example

    in detail at the moment. This example can hopefully help to drive that discussion. An assumption made in this example is that the event only triggers when a new negotiation should be started. This means that an - action (such as addStream()) that normally would have fired the + action (such as addTrack()) that normally would have fired the 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. - - - - - removestream + "event-addtrack">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. From dc0b2169b185ed8d477433013b19abf94ddf4198 Mon Sep 17 00:00:00 2001 From: Justin Uberti 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]].

    - +

    Peer-to-peer connections

    @@ -509,8 +509,8 @@

    Operation

    "component".

    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:

    1. @@ -520,7 +520,12 @@

      Operation

    2. Create a MediaStreamTrack object - track, to represent the incoming media track.

      + 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.

    3. @@ -547,7 +552,8 @@

      Operation

    4. -

      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.

    5. @@ -556,8 +562,8 @@

      Operation

      Fire an event named addtrack with - track at the connection - object.

      + receiver, track, and streams + at the connection object.

    @@ -1879,7 +1885,7 @@

    RTCPeerConnection Interface Extensions

  • -

    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.

  • @@ -1897,7 +1903,7 @@

    RTCPeerConnection Interface Extensions

    track CORS cross-origin. These tracks can be supplied to the - addTrack method, and have a RTCRtpSender created for them, but content + 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 ).

    @@ -1991,6 +1997,12 @@

    RTCPeerConnection Interface Extensions

    RTCRtpSender Interface

    +

    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.

    +
    readonly attribute MediaStreamTrack track
    @@ -2006,6 +2018,10 @@

    RTCRtpSender Interface

    RTCRtpReceiver Interface

    +

    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.

    +
    readonly attribute MediaStreamTrack track
    @@ -2042,7 +2058,7 @@

    AddTrackEvent

    readonly attribute RTCRtpReceiver receiver
    readonly attribute MediaStreamTrack track
    -
    readonly attribute MediaStream stream
    +
    readonly attribute sequence<MediaStream> streams

    The AddTrackEvent

    RTCRtpReceiver receiver
    MediaStreamTrack track
    -
    MediaStream stream
    +
    sequence<MediaStream> streams

    TODO

    @@ -2901,7 +2917,7 @@

    RTCPeerConnection Interface Extensions

    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 object's set of senders; if not, throw an InvalidParameter exception and abort these steps.

    @@ -4427,7 +4443,7 @@

    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 Date: Fri, 17 Oct 2014 18:32:16 -0700 Subject: [PATCH 3/5] Merge anchor fix from @dontcallmedom --- webrtc.html | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/webrtc.html b/webrtc.html index cf41a6039..c8d68d729 100644 --- a/webrtc.html +++ b/webrtc.html @@ -1906,7 +1906,8 @@

    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 ).

    + requirements for sending (see
    + isolated streams and RTCPeerConnection).

    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 @@

    Isolated Media Streams

    Used as the argument to addTrack() on an RTCPeerConnection instance, subject to the - restrictions in .

    + restrictions in isolated streams and RTCPeerConnection.

    From 2e0075a96294648a219162b2d99485e90ca4e797 Mon Sep 17 00:00:00 2001 From: Justin Uberti Date: Fri, 17 Oct 2014 18:45:45 -0700 Subject: [PATCH 4/5] AddTrackEvent -> RTCAddTrackEvent Fix the parameter descriptions for RTCAddTrackEvent --- webrtc.html | 49 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 36 insertions(+), 13 deletions(-) diff --git a/webrtc.html b/webrtc.html index c8d68d729..b59bcd386 100644 --- a/webrtc.html +++ b/webrtc.html @@ -2036,45 +2036,68 @@

    RTCRtpReceiver Interface

    -

    AddTrackEvent

    +

    RTCAddTrackEvent

    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.

    -
    -
    Constructor(DOMString type, AddTrackEventInit +
    +
    Constructor(DOMString type, RTCAddTrackEventInit eventInitDict)
    readonly attribute RTCRtpReceiver receiver
    + +
    +

    The receiver attribute + represents the RTCRtpReceiver object associated with + the event.

    +
    +
    readonly attribute MediaStreamTrack track
    -
    readonly attribute sequence<MediaStream> streams

    The track attribute - represents the MediaStreamTrack object associated with - the event.

    + represents the MediaStreamTrack object that is + associated with the RTCRtpReceiver identified by + receiver.

    +
    + +
    readonly attribute sequence<MediaStream> streams
    + +
    +

    The streams attribute + identifies the MediaStreams that + track is a part of.

    +
    -
    +
    RTCRtpReceiver receiver
    +
    +

    TODO

    +
    MediaStreamTrack track
    +
    +

    TODO

    +
    sequence<MediaStream> streams
    -

    TODO

    @@ -4832,7 +4855,7 @@

    Event summary

    addtrack - AddTrackEvent + RTCAddTrackEvent A new RTCRtpReceiver, and associated MediaStreamTrack, has been added to the Date: Sun, 26 Oct 2014 22:30:03 -0700 Subject: [PATCH 5/5] PR feedback; onaddtrack -> ontrack --- webrtc.html | 109 ++++++++++++++++++++++++---------------------------- 1 file changed, 50 insertions(+), 59 deletions(-) diff --git a/webrtc.html b/webrtc.html index b59bcd386..79d61b3c6 100644 --- a/webrtc.html +++ b/webrtc.html @@ -518,20 +518,10 @@

    Operation

    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 MediaStreamTracks may be triggered either by SDP @@ -540,6 +530,13 @@

    Operation

    when you receive multiple conflicting pranswers?]] -->

  • +
  • + Add track to the MediaStreams streams + referenced by the SDP negotiation, creating new ones if they do not + yet exist. If no MediaStreams are specified, + a default MediaStream is created and used.

    +
  • +
  • Queue a task to run the following substeps:

    @@ -560,8 +557,8 @@

    Operation

  • Fire an event named - addtrack with + track with receiver, track, and streams at the connection object.

  • @@ -570,7 +567,7 @@

    Operation

    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.

    @@ -587,7 +584,7 @@

    Operation

  • 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.

  • @@ -612,16 +609,12 @@

    Operation

    task ran -->
  • -

    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.

  • @@ -1832,7 +1825,7 @@

    RTCPeerConnection Interface Extensions

    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 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

    When the other peer stops sending a track in this manner, a ended event is + "#event-mediastream-ended">ended event is fired at the MediaStreamTrack object.

    When the RTCPeerConnection Interface Extensions

    -
    attribute EventHandler onaddtrack
    +
    attribute EventHandler ontrack
    This event handler, of event handler event type addtrack, MUST be fired + "#event-track">track, 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 + 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 @@

    RTCRtpSender Interface

    parameters to the other side.

    + "interface RTCRtpSender">
    readonly attribute MediaStreamTrack track

    The RTCRtpSender.track - attribute is the track that is immutably associated with this + attribute is the track that is associated with this RTCRtpSender object.

    @@ -2024,7 +2017,7 @@

    RTCRtpReceiver Interface

    wants to receive to the other side.

    + "interface RTCRtpReceiver">
    readonly attribute MediaStreamTrack track
    @@ -2036,32 +2029,32 @@

    RTCRtpReceiver Interface

    -

    RTCAddTrackEvent

    +

    RTCTrackEvent

    -

    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.

    -
    -
    Constructor(DOMString type, RTCAddTrackEventInit +
    +
    Constructor(DOMString type, RTCTrackEventInit eventInitDict)
    readonly attribute RTCRtpReceiver receiver

    The receiver attribute + "dom-trackevent-receiver">receiver attribute represents the RTCRtpReceiver object associated with the event.

    @@ -2070,24 +2063,23 @@

    RTCAddTrackEvent

    The track attribute + "dom-trackevent-track">track attribute represents the MediaStreamTrack object that is associated with the RTCRtpReceiver identified by receiver.

    -
    readonly attribute sequence<MediaStream> streams
    - -
    -

    The streams attribute - identifies the MediaStreams that +

    sequence<MediaStream> getStreams()
    + +
    +

    Returns a sequence of MediaStream objects + representing the MediaStreams that this event's track is a part of.

    -
    +
    RTCRtpReceiver receiver
    @@ -3450,7 +3442,7 @@

    Example

    following example code might be used:

     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 to muted on the remote peer if the local user agent disables the corresponding MediaStreamTrack in the - MediaStream that is being sent. When the onaddtrack + MediaStream that is being sent. When the ontrack event triggers on an RTCPeerConnection, all MediaStreamTrack objects in the resulting MediaStream 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

    addtrack + "event-track">track - RTCAddTrackEvent + RTCTrackEvent A new RTCRtpReceiver, and associated MediaStreamTrack, has been added to the