New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set muted before SRD resolves, using new set muted algorithm. #1667
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d0326e2
Set muted before SRD resolves, using new set muted algorithm.
jan-ivar 65a5cd8
Missed s/update/set/ in two spots.
jan-ivar cca53ac
Remove parenthesis to avoid confusion.
jan-ivar c759665
Collect mute events and fire them right before track events.
jan-ivar File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5294,7 +5294,7 @@ <h4>Processing Remote MediaStreamTracks</h4> | |
</li> | ||
<li> | ||
<p>If <var>track.muted</var> is <code>false</code>, | ||
<a>update the muted state</a> of <var>track</var> with the value | ||
<a>set the muted state</a> of <var>track</var> to the value | ||
<code>true</code>.</p> | ||
</li> | ||
</ol> | ||
|
@@ -10618,21 +10618,22 @@ <h3>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> | ||
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 <a>update the muted state</a> of the | ||
corresponding <code><a>MediaStreamTrack</a></code> with the value | ||
<code>false</code>.</p> | ||
source for the first time, 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 | ||
due to reception of a BYE or via timeout), it MUST <a>update | ||
the muted state</a> of the corresponding | ||
<code><a>MediaStreamTrack</a></code> with the value | ||
<code>true</code>. If and when packets are received again, | ||
the <a data-lt="update the muted state">muted state MUST be | ||
updated</a> with the value <code>false</code>.</p> | ||
<p>The procedure <dfn data-lt="update the muted state" id= | ||
"update-track-muted">update a track's muted state</dfn> is specified in | ||
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="update the muted state">set the muted state</a> back | ||
to <code>false</code>.</p> | ||
<p>The procedure <dfn data-lt="set the muted state" id= | ||
"update-track-muted">set a track's muted state</dfn> is specified in | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should this "update" also be changed to "set"? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes thanks for spotting that! |
||
[[!GETUSERMEDIA]].</p> | ||
<p>When a <code><a>MediaStreamTrack</a></code> track produced by | ||
an <code><a>RTCRtpReceiver</a></code> <var>receiver</var> has | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adam-be Here's the one place we don't queue a task (the purpose of this PR), inside the process the removal of a remote track algorithm which itself is already called from a queued task, to solve #1568.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we fire the event immediately, the event will be fired before all effects of the SRD has occurred - and inspecting the PC or related objects like sender/receiver/transceiver/streams/tracks will yield confusing results sensitive to the order of objects processed by this algorithm.
If we schedule a task to fire the event the event will occur after the SRD promise has resolved (which is inconsistent with ontrack for tracks being added) and could theoretically occur at a time when the muted state has already changed again.
We should do what we do for ontrack:
Here: Set the muted state, and if it changed as a result of this, enqueue mutedEvent on to mutedEvents.
Before SRD is resolved, but still synchronous to the rest of the SRD steps: For each mutedEvent in mutedEvents, fire mutedEvent.
It's important that all events fired in relation to an SRD are fired synchronously, but after the state of all objects has been updated, to ensure inspecting the state of the PC is meaningful.