Skip to content

Commit

Permalink
Merge pull request #1748 from stefhak/gate-unmute
Browse files Browse the repository at this point in the history
Gating 'unmute' events on track with transceiver direction.
  • Loading branch information
alvestrand authored Mar 8, 2018
2 parents 2b6a9b2 + bc78c39 commit ee03811
Showing 1 changed file with 124 additions and 79 deletions.
203 changes: 124 additions & 79 deletions webrtc.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@ <h2>Terminology</h2>
handlers</dfn> and <dfn data-cite="!HTML51/webappapis.html#event-handler-event-type">event
handler event types</dfn> are defined in [[!HTML51]].</p>
<p>The terms <dfn>MediaStream</dfn>, <dfn>MediaStreamTrack</dfn>, and
<dfn>MediaStreamConstraints</dfn> are defined in [[!GETUSERMEDIA]].</p>
<dfn>MediaStreamConstraints</dfn> are defined in [[!GETUSERMEDIA]].
Note that <code><a>MediaStream</a></code> is extended in <code><a href="#mediastream-network-use">
the MediaStream section</a></code> in this document while <code><a>MediaStreamTrack</a></code>
is extended in <code><a href="#mediastreamtrack-network-use">
the MediaStreamTrack section</a></code> in this document.</p>
<p>The term <dfn>Blob</dfn> is defined in [[!FILEAPI]].</p>
<p>The term <dfn>media description</dfn> is defined in [[!RFC4566]].</p>
<p>The term <dfn>media transport</dfn> is defined in [[!RFC7656]].</p>
Expand Down Expand Up @@ -1549,81 +1553,106 @@ <h4>Set the RTCSessionDescription</h4>
<li>
<p>If <var>description</var> is set as a local description,
then run the following steps for each <a>media description</a>
in <var>description</var> that is not yet <a>associated</a> with
an <code><a>RTCRtpTransceiver</a></code> object:</p>
in <var>description</var>:</p>
<ol>
<li>
<p>Let <var>transceiver</var> be the <code>
<a>RTCRtpTransceiver</a></code> used to create the
<a>media description</a>.</p>
<p>If the <a>media description</a> is not yet <a>associated</a>
with an <code><a>RTCRtpTransceiver</a></code> object then run
the following steps:</p>
<ol>
<li>
<p>Let <var>transceiver</var> be the <code>
<a>RTCRtpTransceiver</a></code> used to create the
<a>media description</a>.</p>
</li>
<li>
<p>Set <var>transceiver</var>'s <code><a data-link-for=
"RTCRtpTransceiver">mid</a></code> value to the mid of
the <a>media description</a>.</p>
</li>
<li>
<p>If <var>transceiver</var>'s <a>[[\Stopped]]</a> slot
is <code>true</code>, abort these sub steps.</p>
</li>
<li>
<p>
If the <a>media description</a> is indicated as using
an existing <a>media transport</a> according to
[[!BUNDLE]], let <var>transport</var> and
<var>rtcpTransport</var> be the
<code><a>RTCDtlsTransport</a></code> objects
representing the RTP and RTCP components of that
transport, respectively.
</p>
</li>
<li>
<p>
Otherwise, let <var>transport</var> and
<var>rtcpTransport</var> be newly created
<code><a>RTCDtlsTransport</a></code> objects, each
with a new underlying
<code><a>RTCIceTransport</a></code>. Though if RTCP
multiplexing is negotiated according to [[!RFC5761]],
or if <var>connection</var>'s
<code><a>RTCRtcpMuxPolicy</a></code> is <code><a
data-link-for="RTCRtcpMuxPolicy">require</a></code>,
do not create any RTCP-specific transport objects,
and instead let <var>rtcpTransport</var> equal
<var>transport</var>.
</p>
</li>
<li>
<p>
Set <var>transceiver</var>.<a>[[\Sender]]</a>.<a>[[\SenderTransport]]</a>
to <var>transport</var>.
</p>
</li>
<li>
<p>
Set <var>transceiver</var>.<a>[[\Sender]]</a>.<a>[[\SenderRtcpTransport]]</a>
to <var>rtcpTransport</var>.
</p>
</li>
<li>
<p>
Set <var>transceiver</var>.<a>[[\Receiver]]</a>.<a>[[\ReceiverTransport]]</a>
to <var>transport</var>.
</p>
</li>
<li>
<p>
Set <var>transceiver</var>.<a>[[\Receiver]]</a>.<a>[[\ReceiverRtcpTransport]]</a>
to <var>rtcpTransport</var>.
</p>
</li>
</ol>
</li>
<li>
<p>Set <var>transceiver</var>'s <code><a data-link-for=
"RTCRtpTransceiver">mid</a></code> value to the mid of
the corresponding <a>media description</a>.</p>
<p>Let <var>transceiver</var> be the <code>
<a>RTCRtpTransceiver</a></code> <a>associated</a> with the
<a>media description</a>.</p>
</li>
<li>
<p>If <var>transceiver</var>'s <a>[[\Stopped]]</a> slot
is <code>true</code>, abort these sub steps.</p>
</li>
<li>
<p>If <var>description</var> is of type
<code>"answer"</code> or <code>"pranswer"</code>, then
set <var>transceiver</var>'s <a>[[\CurrentDirection]]</a> slot
to an <code><a>RTCRtpTransceiverDirection</a></code>
value representing the direction of the corresponding
<a>media description</a>.</p>
<p>Let <var>direction</var> be an <code>
<a>RTCRtpTransceiverDirection</a></code> value
representing the direction from the <a>media
description</a>.</p>
</li>
<li>
<p>
If the <a>media description</a> is indicated as using
an existing <a>media transport</a> according to
[[!BUNDLE]], let <var>transport</var> and
<var>rtcpTransport</var> be the
<code><a>RTCDtlsTransport</a></code> objects
representing the RTP and RTCP components of that
transport, respectively.
</p>
<p>If <var>direction</var> is <code>"sendrecv"</code> or
<code>"recvonly"</code>,
set <var>transceiver</var>'s <a>[[\Receptive]]</a> slot
to <code>true</code>, otherwise set it to <code>false</code>.</p>
</li>
<li>
<p>
Otherwise, let <var>transport</var> and
<var>rtcpTransport</var> be newly created
<code><a>RTCDtlsTransport</a></code> objects, each
with a new underlying
<code><a>RTCIceTransport</a></code>. Though if RTCP
multiplexing is negotiated according to [[!RFC5761]],
or if <var>connection</var>'s
<code><a>RTCRtcpMuxPolicy</a></code> is <code><a
data-link-for="RTCRtcpMuxPolicy">require</a></code>,
do not create any RTCP-specific transport objects,
and instead let <var>rtcpTransport</var> equal
<var>transport</var>.
</p>
</li>
<li>
<p>
Set <var>transceiver</var>.<a>[[\Sender]]</a>.<a>[[\SenderTransport]]</a>
to <var>transport</var>.
</p>
</li>
<li>
<p>
Set <var>transceiver</var>.<a>[[\Sender]]</a>.<a>[[\SenderRtcpTransport]]</a>
to <var>rtcpTransport</var>.
</p>
</li>
<li>
<p>
Set <var>transceiver</var>.<a>[[\Receiver]]</a>.<a>[[\ReceiverTransport]]</a>
to <var>transport</var>.
</p>
</li>
<li>
<p>
Set <var>transceiver</var>.<a>[[\Receiver]]</a>.<a>[[\ReceiverRtcpTransport]]</a>
to <var>rtcpTransport</var>.
</p>
<p>If <var>description</var> is of type
<code>"answer"</code> or <code>"pranswer"</code>, then set
<var>transceiver</var>'s <a>[[\CurrentDirection]]</a> slot
to <var>direction</var>.</p>
</li>
</ol>
</li>
Expand Down Expand Up @@ -1697,6 +1726,12 @@ <h4>Set the RTCSessionDescription</h4>
the <a>media description</a>, given <var>transceiver</var>,
<var>addList</var>, and <var>trackEvents</var>.</p>
</li>
<li>
<p>If <var>direction</var> is <code>"sendonly"</code> or
<code>"inactive"</code>,
set <var>transceiver</var>'s <a>[[\Receptive]]</a> slot
to <code>false</code>.</p>
</li>
<li>
<p>If <var>direction</var> is
<code>"sendonly"</code> or <code>"inactive"</code>, and
Expand Down Expand Up @@ -6591,11 +6626,7 @@ <h2>Attributes</h2>
<p>The <code id="dom-rtpreceiver-track">track</code>
attribute is the track that is associated with this
<code><a>RTCRtpReceiver</a></code> object <var>receiver</var>.
When one of the SSRCs for RTP source media streams received
by <var>receiver</var> is removed (either due to reception of
a BYE or via timeout), the <code>mute</code> event is fired at
<code>track</code>. If and when packets are received again,
the <code>unmute</code> event is fired at <code>track</code>.</p>
</p>
<p>Note that <code>track.stop()</code> is final, although
clones are not affected. Since
<code><var>receiver</var>.track.stop()</code>
Expand Down Expand Up @@ -6894,6 +6925,10 @@ <h3><dfn>RTCRtpTransceiver</dfn> Interface</h3>
<p>Let <var>transceiver</var> have a <dfn>[[\Direction]]</dfn> internal slot, initialized to
<var>direction</var>.</p>
</li>
<li>
<p>Let <var>transceiver</var> have a <dfn>[[\Receptive]]</dfn> internal slot,
initialized to <code>false</code>.</p>
</li>
<li>
<p>Let <var>transceiver</var> have a <dfn>[[\CurrentDirection]]</dfn> internal slot,
initialized to null.</p>
Expand Down Expand Up @@ -7107,6 +7142,10 @@ <h2>Methods</h2>
<p>Set <var>transceiver</var>'s <a>[[\Stopped]]</a>
slot to <code>true</code>.</p>
</li>
<li>
<p>Set <var>transceiver</var>'s <a>[[\Receptive]]</a>
slot to <code>false</code>.</p>
</li>
<li>
<p>Set <var>transceiver</var>'s <a>[[\CurrentDirection]]</a>
slot to <code>null</code>.</p>
Expand Down Expand Up @@ -10836,7 +10875,7 @@ <h3>Introduction</h3>
one and only one <code>MediaStreamTrack</code> to the recipient. A peer
is defined as a user agent that supports this specification. In addition,
the sending side application can indicate what <code>MediaStream</code>
object(s) the <code>MediaStreamTrack</code> is member of. The
object(s) the <code>MediaStreamTrack</code> is a member of. The
corresponding <code>MediaStream</code> object(s) on the receiver side
will be created (if not already present) and populated accordingly.</p>
<p>As also described earlier in this document, the objects
Expand Down Expand Up @@ -10876,7 +10915,7 @@ <h3>Introduction</h3>
<code>MediaStreamTrack</code>.</p>
</section>
<section>
<h3>MediaStream</h3>
<h3 id="mediastream-network-use">MediaStream</h3>
<section>
<h4>id</h4>
<p>The <code><a data-cite=
Expand All @@ -10900,24 +10939,30 @@ <h4>id</h4>
</section>
</section>
<section>
<h3>MediaStreamTrack</h3>
<h3 id="mediastreamtrack-network-use">MediaStreamTrack</h3>
<p>A <code>MediaStreamTrack</code> object's reference to its
<code>MediaStream</code> in the non-local media source case (an RTP
source, as is the case for <code>MediaStreamTrack</code>s received over
an <code><a>RTCPeerConnection</a></code>) is always strong.</p>
<p>When an <code><a>RTCPeerConnection</a></code> receives data on an RTP
source for the first time, it MUST queue a task to
<a>set the muted state</a> of the corresponding
source, as is the case for each <code>MediaStreamTrack</code>
associated with
an <code><a>RTCRtpReceiver</a></code>) is always strong.</p>
<p>Whenever an <code><a>RTCRtpReceiver</a></code> receives data on an RTP
source whose corresponding <code><a>MediaStreamTrack</a></code> is muted,
and the <a>[[\Receptive]]</a> slot of the
<a><code>RTCRtpTransceiver</code></a> object the
<a><code>RTCRtpReceiver</code></a> is a member of is <code>true</code>,
it MUST queue a task to <a>set the muted state</a> of the corresponding
<code><a>MediaStreamTrack</a></code> to <code>false</code>.
</p>
<p>When one of the SSRCs for RTP source media streams received
by an <code><a>RTCPeerConnection</a></code> is removed either
by an <code><a>RTCRtpReceiver</a></code> is removed either
due to reception of a BYE or via timeout, it MUST queue a task to
<a>set the muted state</a> of the corresponding
<code><a>MediaStreamTrack</a></code> to
<code>true</code>. If and when packets are received again, it must queue a
task to <a data-lt="set the muted state">set the muted state</a> back
to <code>false</code>.</p>
<code>true</code>. Note that <code><a data-link-for=
"RTCPeerConnection">setRemoteDescription</a></code>
can also lead to <a data-lt="set the muted state"> the setting
of the muted state</a> of the <code>track</code> to the
value <code>true</code>.</p>
<p>The procedures
<dfn data-lt="add the track" id="add-track">add a track</dfn>,
<dfn data-lt="remove the track" id="remove-track">remove a track</dfn> and
Expand Down

0 comments on commit ee03811

Please sign in to comment.