Closed Bug 1208371 Opened 9 years ago Closed 8 years ago

Implement MediaStream/MediaStreamTrack.clone()

Categories

(Core :: Audio/Video: MediaStreamGraph, defect, P1)

33 Branch
defect

Tracking

()

RESOLVED FIXED
mozilla48
Tracking Status
firefox48 --- fixed

People

(Reporter: pehrsons, Assigned: pehrsons)

References

(Blocks 1 open bug)

Details

(Keywords: dev-doc-complete)

Attachments

(106 files, 3 obsolete files)

40 bytes, text/x-review-board-request
roc
: review+
Details
40 bytes, text/x-review-board-request
padenot
: review+
Details
40 bytes, text/x-review-board-request
roc
: review+
Details
40 bytes, text/x-review-board-request
roc
: review+
jib
: review+
Details
40 bytes, text/x-review-board-request
jib
: review+
roc
: review+
Details
40 bytes, text/x-review-board-request
roc
: review+
jib
: review+
Details
40 bytes, text/x-review-board-request
jib
: review+
roc
: review+
Details
40 bytes, text/x-review-board-request
roc
: review+
jib
: review+
Details
40 bytes, text/x-review-board-request
roc
: review+
Details
40 bytes, text/x-review-board-request
roc
: review+
Details
40 bytes, text/x-review-board-request
roc
: review+
Details
40 bytes, text/x-review-board-request
roc
: review+
Details
40 bytes, text/x-review-board-request
roc
: review+
Details
40 bytes, text/x-review-board-request
roc
: review+
Details
40 bytes, text/x-review-board-request
roc
: review+
Details
40 bytes, text/x-review-board-request
roc
: review+
Details
40 bytes, text/x-review-board-request
jib
: review+
roc
: review+
Details
40 bytes, text/x-review-board-request
Details
40 bytes, text/x-review-board-request
roc
: review+
jib
: review+
Details
40 bytes, text/x-review-board-request
roc
: review+
Details
40 bytes, text/x-review-board-request
jib
: review+
Details
40 bytes, text/x-review-board-request
jib
: review+
roc
: review+
Details
40 bytes, text/x-review-board-request
jib
: review+
Details
40 bytes, text/x-review-board-request
jib
: review+
Details
40 bytes, text/x-review-board-request
roc
: review+
Details
40 bytes, text/x-review-board-request
roc
: review+
jib
: review+
smaug
: review+
Details
40 bytes, text/x-review-board-request
roc
: review+
jib
: review+
smaug
: review+
Details
40 bytes, text/x-review-board-request
jib
: review+
Details
40 bytes, text/x-review-board-request
roc
: review+
Details
40 bytes, text/x-review-board-request
jib
: review+
Details
40 bytes, text/x-review-board-request
jib
: review+
Details
40 bytes, text/x-review-board-request
jib
: review+
Details
58 bytes, text/x-review-board-request
Details
58 bytes, text/x-review-board-request
Details
58 bytes, text/x-review-board-request
Details
58 bytes, text/x-review-board-request
roc
: review+
Details
58 bytes, text/x-review-board-request
Details
58 bytes, text/x-review-board-request
Details
58 bytes, text/x-review-board-request
Details
58 bytes, text/x-review-board-request
Details
58 bytes, text/x-review-board-request
Details
58 bytes, text/x-review-board-request
bwc
: review+
Details
58 bytes, text/x-review-board-request
jib
: review+
Details
58 bytes, text/x-review-board-request
Details
58 bytes, text/x-review-board-request
roc
: review+
Details
58 bytes, text/x-review-board-request
padenot
: review+
Details
58 bytes, text/x-review-board-request
Details
58 bytes, text/x-review-board-request
Details
58 bytes, text/x-review-board-request
Details
58 bytes, text/x-review-board-request
roc
: review+
Details
58 bytes, text/x-review-board-request
padenot
: review+
Details
58 bytes, text/x-review-board-request
padenot
: review+
Details
58 bytes, text/x-review-board-request
Details
58 bytes, text/x-review-board-request
Details
58 bytes, text/x-review-board-request
Details
58 bytes, text/x-review-board-request
Details
58 bytes, text/x-review-board-request
Details
58 bytes, text/x-review-board-request
roc
: review+
Details
58 bytes, text/x-review-board-request
roc
: review+
Details
58 bytes, text/x-review-board-request
roc
: review+
Details
58 bytes, text/x-review-board-request
roc
: review+
Details
58 bytes, text/x-review-board-request
jib
: review+
Details
58 bytes, text/x-review-board-request
jib
: review+
Details
58 bytes, text/x-review-board-request
jesup
: review+
roc
: review+
Details
58 bytes, text/x-review-board-request
bwc
: review+
jesup
: review+
Details
58 bytes, text/x-review-board-request
jesup
: review+
Details
58 bytes, text/x-review-board-request
padenot
: review+
Details
58 bytes, text/x-review-board-request
jib
: review+
Details
58 bytes, text/x-review-board-request
jib
: review+
Details
58 bytes, text/x-review-board-request
jib
: review+
Details
58 bytes, text/x-review-board-request
padenot
: review+
Details
58 bytes, text/x-review-board-request
padenot
: review+
Details
58 bytes, text/x-review-board-request
jib
: review+
Details
58 bytes, text/x-review-board-request
padenot
: review+
Details
58 bytes, text/x-review-board-request
padenot
: review+
Details
58 bytes, text/x-review-board-request
padenot
: review+
Details
58 bytes, text/x-review-board-request
pkerr
: review+
Details
58 bytes, text/x-review-board-request
bwc
: review+
Details
58 bytes, text/x-review-board-request
jib
: review+
Details
58 bytes, text/x-review-board-request
padenot
: review+
Details
58 bytes, text/x-review-board-request
jwwang
: review+
Details
58 bytes, text/x-review-board-request
bwc
: review+
Details
58 bytes, text/x-review-board-request
Details
58 bytes, text/x-review-board-request
roc
: review+
Details
58 bytes, text/x-review-board-request
jib
: review+
Details
58 bytes, text/x-review-board-request
Details
58 bytes, text/x-review-board-request
roc
: review+
Details
58 bytes, text/x-review-board-request
roc
: review+
jesup
: review+
Details
58 bytes, text/x-review-board-request
roc
: review+
jesup
: review+
Details
58 bytes, text/x-review-board-request
roc
: review+
jesup
: review+
Details
58 bytes, text/x-review-board-request
jwwang
: review+
Details
58 bytes, text/x-review-board-request
bwc
: review+
Details
58 bytes, text/x-review-board-request
roc
: review+
jesup
: review+
Details
58 bytes, text/x-review-board-request
roc
: review+
jesup
: review+
Details
58 bytes, text/x-review-board-request
bwc
: review+
Details
58 bytes, text/x-review-board-request
bwc
: review+
Details
58 bytes, text/x-review-board-request
jib
: review+
Details
58 bytes, text/x-review-board-request
jesup
: review+
Details
58 bytes, text/x-review-board-request
bwc
: review+
Details
58 bytes, text/x-review-board-request
roc
: review+
jesup
: review+
Details
58 bytes, text/x-review-board-request
bholley
: review+
Details
58 bytes, text/x-review-board-request
jesup
: review+
Details
58 bytes, text/x-review-board-request
padenot
: review+
Details
58 bytes, text/x-review-board-request
Details
58 bytes, text/x-review-board-request
jesup
: review+
Details
58 bytes, text/x-review-board-request
jesup
: review+
Details
A cloned stream will wire up a MediaInputPort from the original DOM stream's input stream to the clone's owned stream.

A cloned track will have to create a dummy DOMMediaStream on which to do the same wiring. The dummy is kept alive by a ref from the track-clone but not exposed to js.
Bug 1208371 - Pass parent window to DOMMediaStream through constructor. r?roc
Attachment #8676157 - Flags: review?(roc)
Bug 1208371 - Make AudioCaptureStream startable. r?padenot
This allows us to add the JS-side MediaStreamTrack before the MSG-side
track.
Attachment #8676159 - Flags: review?(padenot)
Bug 1208371 - Expose TrackPort in DOMMediaStream.h r?roc
Attachment #8676160 - Flags: review?(roc)
Bug 1208371 - Move OnTracksAvailableCallback out of DOMMediaStream. r?roc
So it can be forward declared.
Attachment #8676161 - Flags: review?(roc)
Bug 1208371 - Remove unused MediaManager::NotifyMediaStreamTrackEnded. r?jib
Attachment #8676162 - Flags: review?(jib)
Bug 1208371 - Introduce MediaStreamTrack logs. r?roc
Attachment #8676163 - Flags: review?(roc)
Bug 1208371 - Track original track in MediaStreamTrack clones. r?jib
Attachment #8676164 - Flags: review?(jib)
Bug 1208371 - Add a MediaStreamTrackSource interface. r?roc
This lets a MediaStreamTrack communicate with its source/producer on the
main thread. It's for now used for stopping a track at the source and
retrieving some metadata, but it could also be a link between actual
sinks of a track and the source, to for instance let the source optimize
by scaling down the resolution when all sinks want lowres-video.
Attachment #8676165 - Flags: review?(roc)
Bug 1208371 - Add MediaStreamTrackSourceGetter interface. r?roc
This allows DOMMediaStream to assign MediaStreamTrackSources to
dynamically created MediaStreamTracks.
Attachment #8676168 - Flags: review?(roc)
Bug 1208371 - Let MediaStreamTracks know their TrackID at the source. r?roc
For original tracks, the input TrackID is the same as in its
owned stream.
For cloned tracks, the input TrackID comes from the original track,
since no guarantees about TrackIDs in a cloned DOMMediaStream's owned
stream can be given
(imagine e.g., `new MediaStream([trackID1FromStreamX, trackID1FromStreamY]).clone()`).
Attachment #8676169 - Flags: review?(roc)
Bug 1208371 - Let FindOwnedDOMTrack operate on input stream. r?roc
This let's us use FindOwnedDOMTrack before the TrackID in mOwnedStream
is known.

This is necessary for a stream clone with multiple tracks whose original
TrackID is the same.
Attachment #8676170 - Flags: review?(roc)
Bug 1208371 - Add some MediaStreamTrack helper methods. r?roc
Attachment #8676171 - Flags: review?(roc)
Bug 1208371 - Introduce an unbound state for MediaStreamTracks r?roc,jib
The need for this comes from the following JS code example:
var stream = new MediaStream();
stream.addTrack(gUMVideoTrack1); // TrackID 1 internally
stream.addTrack(gUMVideoTrack2); // TrackID 1 internally
var clone = stream.clone();

I.e., just after cloning a stream, we don't know which TrackIDs the
cloned tracks will have. We have to wait for the MSG to handle the
new MediaInputPorts and notify us of the new TrackIDs.

This will require us to proxy certain operations in MediaStreamTrack in
future patches when the track is in an unbound state, for instance
adding a listener to the underlying stream/track.
Attachment #8676172 - Flags: review?(roc)
Attachment #8676172 - Flags: review?(jib)
Bug 1208371 - Remove obsolete SetTrackEnabled() from DOMMediaStream r?roc
Attachment #8676173 - Flags: review?(roc)
Bug 1208371 - Allow MediaInputPorts to be created before the source's TrackID is known. r?roc
If the tracks of a cloned stream are added to another stream, they may
not have been assigned a TrackID yet. AddTrack() still requires a
MediaInputPort to be set up so we're forced to use what we have;
the input MediaStream and input TrackID to the cloned track.

This patch allows allocation of such input ports and gives
TrackUnionStream the ability handle them. These input ports are
guaranteed to be processed after their sources have been created, so there's
no risk for them not finding the source track.
Attachment #8676174 - Flags: review?(roc)
Bug 1208371 - Allow allocating input ports based on not-yet-initialized input ports. r?roc
Attachment #8676175 - Flags: review?(roc)
Bug 1208371 - Pass MediaStreamTrack to ApplyConstraintsToTrack instead of TrackID. r?jib
Attachment #8676176 - Flags: review?(jib)
Bug 1208371 - Implement MediaStreamTrack::Clone(). r?smaug,jib,roc
Attachment #8676177 - Flags: review?(roc)
Attachment #8676177 - Flags: review?(jib)
Attachment #8676177 - Flags: review?(bugs)
Bug 1208371 - Implement MediaStream.clone() r?smaug,jib,roc
Attachment #8676178 - Flags: review?(roc)
Attachment #8676178 - Flags: review?(jib)
Attachment #8676178 - Flags: review?(bugs)
Bug 1208371 - Forward applyConstraints() to original track for clones. r?jib
Attachment #8676179 - Flags: review?(jib)
Bug 1208371 - Various cleanups in DOMMediaStream/MediaStreamTrack. r?jib
Attachment #8676180 - Flags: review?(jib)
Bug 1208371 - Move track.stop() helpers to MediaStreamPlayback and wrap methods in getters. r?jib
Attachment #8676181 - Flags: review?(jib)
Bug 1208371 - Test MediaStream.clone(). r?jib
Attachment #8676182 - Flags: review?(jib)
This is not quite finished yet, but I thought I'd get started with the reviews. I still need to add a test for track cloning, and for some more corner cases, including making sure that principals are correctly combined.
Comment on attachment 8676162 [details]
MozReview Request: Bug 1208371 - Introduce MediaStreamTrack logs. r?roc,jib

https://reviewboard.mozilla.org/r/22575/#review20101
Attachment #8676162 - Flags: review?(jib) → review+
Comment on attachment 8676177 [details]
MozReview Request: Bug 1208371 - Let DOMMediaStream base its principal on the tracks it contains. r?mt

MediaStreamTrack*
+DOMMediaStream::CreateClonedDOMTrack(MediaStreamTrack& aClonedTrack)
+{
+  MOZ_RELEASE_ASSERT(mOwnedStream);
+  MOZ_RELEASE_ASSERT(mPlaybackStream);
+
+  TrackID inputTrackID = aClonedTrack.GetInputTrackID();
+  MediaStream* inputStream = aClonedTrack.GetInputStream();
+
+  CombineWithPrincipal(aClonedTrack.GetInputDOMStream()->GetPrincipal());
+
+  MOZ_ASSERT(FindOwnedDOMTrack(inputStream, inputTrackID) == nullptr);
+
+  MediaStreamTrackSource& source = aClonedTrack.GetSource();
+  MediaStreamTrack* track;
Please use RefPtr here and make the method to return already_AddRefed<MediaStreamTrack>
Attachment #8676177 - Flags: review?(bugs) → review+
Comment on attachment 8676178 [details]
MozReview Request: Bug 1208371 - Add DOMMediaStream::GetTrackById/GetOwnedTrackById. r?jib


-  : mLogicalStreamStartTime(0), mWindow(aWindow),
+  : mLogicalStreamStartTime(0), mWindow(aWindow), mClonedDOMStream(nullptr)
No need to initialize RefPtr member variables to null (they are initialized to null implicitly)



+  protected:
+    virtual ~ClonedStreamSourceGetter() {}
+    DOMMediaStream* const mStream;
+  };
I'm not familiar with this code, but raw pointers as member variables are scary so it needs some comment 
explaining why it can't ever point to deleted object and perhaps MOZ_NON_OWNING_REF annotation.



r+ for the .webidl change.
Attachment #8676178 - Flags: review?(bugs) → review+
Comment on attachment 8676164 [details]
MozReview Request: Bug 1208371 - Un-nest MediaEngineSource::PhotoCallback. r?roc

https://reviewboard.mozilla.org/r/22579/#review20103

I'll have to come back to this one at the end, once I understand why we need to keep track of the original track.

::: dom/media/MediaStreamTrack.h:77
(Diff revision 1)
> +  RefPtr<MediaStreamTrack> mClonedTrack;

I think you have it right in the patch title, and this should be mOriginalTrack. "ClonedTrack" may be linguistically accurate, but is an odd label and makes me thing of the track-clone.

When I eject two discs from a duplicator, I write "original" on one and "copy" on the other. I don't write "copied" on the first.
Attachment #8676164 - Flags: review?(jib)
https://reviewboard.mozilla.org/r/22581/#review20105

::: dom/html/HTMLCanvasElement.cpp:685
(Diff revision 1)
> -  stream->CreateOwnDOMTrack(videoTrackId, MediaSegment::VIDEO);
> +  stream->CreateOwnDOMTrack(videoTrackId, MediaSegment::VIDEO, new BasicNonStoppableTrackSource());

Unstoppable? :)
https://reviewboard.mozilla.org/r/22585/#review20129

Here's an example: In the description for this patch it says: "For cloned tracks, the input TrackID comes from the original track,"

Here I think you're using "cloned track" to mean the track clone.
https://reviewboard.mozilla.org/r/22585/#review20131

::: dom/media/MediaStreamTrack.h:141
(Diff revision 1)
> +   * Returns the TrackID this MediaStreamTrack has in it's original owning DOM
> +   * stream's input stream.

I hope we can refactor this soon, so we don't have to understand sentences like that. TrackIDs from different domains share the same type, so the possibility for bugs seems high.
Comment on attachment 8676157 [details]
MozReview Request: Bug 1208371 - Pass parent window to DOMMediaStream through constructor. r?roc

https://reviewboard.mozilla.org/r/22567/#review20209
Comment on attachment 8676160 [details]
MozReview Request: Bug 1208371 - Move OnTracksAvailableCallback out of DOMMediaStream. r?roc

https://reviewboard.mozilla.org/r/22571/#review20211
Comment on attachment 8676161 [details]
MozReview Request: Bug 1208371 - Remove unused MediaManager::NotifyMediaStreamTrackEnded. r?jib

https://reviewboard.mozilla.org/r/22573/#review20213
Attachment #8676161 - Flags: review?(roc) → review+
Comment on attachment 8676163 [details]
MozReview Request: Bug 1208371 - Track original track in MediaStreamTrack clones. r?jib

https://reviewboard.mozilla.org/r/22577/#review20217
Attachment #8676163 - Flags: review?(roc) → review+
Comment on attachment 8676165 [details]
MozReview Request: Bug 1208371 - Add MediaStreamTrack::Graph(). r?jib

https://reviewboard.mozilla.org/r/22581/#review20219

Please split the move to MediaEnginePhotoCallback out of this patch to a separate patch.
Attachment #8676165 - Flags: review?(roc)
Comment on attachment 8676168 [details]
MozReview Request: Bug 1208371 - Add a MediaStreamTrackSource interface. r?roc

https://reviewboard.mozilla.org/r/22583/#review20221

::: dom/media/DOMMediaStream.h:75
(Diff revision 1)
> +class MediaStreamTrackSourceGetter

This needs documentation.

::: dom/media/DOMMediaStream.h:81
(Diff revision 1)
> +  NS_IMETHOD_(MozExternalRefCountType) Release(void) = 0;

Why are these pure virtual? Can't we declare inline refcounting on the class?
Attachment #8676168 - Flags: review?(roc)
Comment on attachment 8676169 [details]
MozReview Request: Bug 1208371 - Add MediaStreamTrackSourceGetter interface. r?roc

https://reviewboard.mozilla.org/r/22585/#review20223
Attachment #8676169 - Flags: review?(roc) → review+
Comment on attachment 8676170 [details]
MozReview Request: Bug 1208371 - Let MediaStreamTracks know their TrackID at the source. r?roc

https://reviewboard.mozilla.org/r/22587/#review20225
Attachment #8676170 - Flags: review?(roc) → review+
Comment on attachment 8676172 [details]
MozReview Request: Bug 1208371 - Add some MediaStreamTrack helper methods. r?roc

https://reviewboard.mozilla.org/r/22591/#review20231

> I.e., just after cloning a stream, we don't know which TrackIDs the
> cloned tracks will have. We have to wait for the MSG to handle the
> new MediaInputPorts and notify us of the new TrackIDs.

Is there no way to ensure that the main thread can compute the same track ID assignments as the MSG?
Comment on attachment 8676173 [details]
MozReview Request: Bug 1208371 - Count the users of a MediaStream to ease Destroy() responsibility. r?roc

https://reviewboard.mozilla.org/r/22593/#review20233
Attachment #8676173 - Flags: review?(roc) → review+
Comment on attachment 8676177 [details]
MozReview Request: Bug 1208371 - Let DOMMediaStream base its principal on the tracks it contains. r?mt

https://reviewboard.mozilla.org/r/22601/#review20235

::: dom/media/MediaStreamTrack.cpp:134
(Diff revision 1)
> +  newStream->InitPlaybackStreamCommon(GetStream()->GetPlaybackStream()->Graph());

Factor out Graph() call
Attachment #8676177 - Flags: review?(roc) → review+
Comment on attachment 8676178 [details]
MozReview Request: Bug 1208371 - Add DOMMediaStream::GetTrackById/GetOwnedTrackById. r?jib

https://reviewboard.mozilla.org/r/22603/#review20237

::: dom/media/DOMMediaStream.cpp:629
(Diff revision 1)
> +    DOMMediaStream* const mStream;

How do we know ClonedStreamSourceGetter outlives mStream?
Attachment #8676178 - Flags: review?(roc)
(In reply to Olli Pettay [:smaug] from comment #26)
> Comment on attachment 8676177 [details]
> MozReview Request: Bug 1208371 - Implement MediaStreamTrack::Clone().
> r?smaug,jib,roc
> 
> MediaStreamTrack*
> +DOMMediaStream::CreateClonedDOMTrack(MediaStreamTrack& aClonedTrack)
> +{
> +  MOZ_RELEASE_ASSERT(mOwnedStream);
> +  MOZ_RELEASE_ASSERT(mPlaybackStream);
> +
> +  TrackID inputTrackID = aClonedTrack.GetInputTrackID();
> +  MediaStream* inputStream = aClonedTrack.GetInputStream();
> +
> +  CombineWithPrincipal(aClonedTrack.GetInputDOMStream()->GetPrincipal());
> +
> +  MOZ_ASSERT(FindOwnedDOMTrack(inputStream, inputTrackID) == nullptr);
> +
> +  MediaStreamTrackSource& source = aClonedTrack.GetSource();
> +  MediaStreamTrack* track;
> Please use RefPtr here and make the method to return
> already_AddRefed<MediaStreamTrack>

Similarly to CreateOwnDOMTrack() I think it should be fine to return a raw pointer here - the returned track is kept alive by both mOwnedTracks and mTracks. With a raw pointer we can safely ignore the result when calling CreateClonedDOMTrack, but with already_AddRefed we can't, we'd have to put it in a RefPtr and let that go out of scope.
Comment on attachment 8676159 [details]
MozReview Request: Bug 1208371 - Make AudioCaptureStream startable. r?padenot

https://reviewboard.mozilla.org/r/22569/#review20261
Attachment #8676159 - Flags: review?(padenot) → review+
Comment on attachment 8676172 [details]
MozReview Request: Bug 1208371 - Add some MediaStreamTrack helper methods. r?roc

https://reviewboard.mozilla.org/r/22591/#review20425

Sorry this is taking so long, but the complexity seems to be rising here, and I'm having trouble keeping all the concepts in my head "owning", "input", "bound". I'm still unsure what input is. So I'll need more time to wrap my head around this. I also feel compelled to "fight back" against this complexity (see annoying questions and ideas below).

::: dom/media/MediaStreamTrack.h:148
(Diff revision 1)
> -  TrackID GetTrackID() const { return mTrackID; }
> +  DOMMediaStream* GetStream() const { return mOwningDOMStream; }

The fact that a MediaStreamTrack has an "owning" object very much seems like an implementation detail.

I'm wondering... What would it take to make mOwningDOMStream private to MediaStreamTrack?

I'm looking for ways to encapsulate complexity, and it occurs to me that if MediaStreamTrack were not to expose this detail about itself, even to other implementation objects, then it might simplify things.

MediaStreamTrack would need to proxy some methods to mOwningDOMStream obviously, but how many?

::: dom/media/MediaStreamTrack.h:191
(Diff revision 1)
> +  // Returns true if this MediaStreamTrack has been bound,
> +  // i.e., linked to it's underlying MSG-MediaStream and TrackID.

MSG-MediaStream... That's a nice name (giving me ideas below)

::: dom/media/MediaStreamTrack.h:197
(Diff revision 1)
> +  TrackID BoundTrackID() const

This should be GetBoundTrackID() according to your own comment above.

::: dom/media/MediaStreamTrack.h:213
(Diff revision 1)
> -  RefPtr<DOMMediaStream> mOwningStream;
> +  RefPtr<DOMMediaStream> mOwningDOMStream;
> -  TrackID mTrackID;
>    TrackID mInputTrackID;
>    const RefPtr<MediaStreamTrackSource> mSource;
> +  MediaStream* mBoundOwningStream;
> +  TrackID mBoundTrackID;

I see what you're having to do here to avoid confusion about dom "stream" vs. msg "stream", with the introduction of "mBoundOwningStream" being msg vs. mOwningStream which is dom.

It's not just this line, it's throughout that I find this hard to follow. The fact that we have MediaStream* and MediaStreamTrack* and that they're in different domains, is coming to bear I think.

I humbly suggest the time may have come to undertake a two-step plan either before or shortly after this bug to:

 1. Rename MediaStream to MSGMediaStream or MsgStream (or MediaStreamNode?)
 2. Rename DOMMediaStream to MediaStream sometime soon.

Once that is done, mBoundOwningStream -> mBoundMsgStream, with no need for "Owning" (since we never bind to non-owned things I presume?)

::: dom/media/imagecapture/CaptureTask.cpp:60
(Diff revision 1)
>    RefPtr<DOMMediaStream> domStream = track->GetStream();
> -  domStream->AddPrincipalChangeObserver(this);
> +  MOZ_RELEASE_ASSERT(domStream);
> +  track->GetStream()->AddPrincipalChangeObserver(this);
>  
> -  RefPtr<MediaStream> stream = domStream->GetPlaybackStream();
> -  stream->AddListener(this);
> +  MOZ_RELEASE_ASSERT(domStream->GetOwnedStream());
> +  track->GetStream()->GetOwnedStream()->AddListener(this);

The addref here seems redundant.
Attachment #8676172 - Flags: review?(jib)
https://reviewboard.mozilla.org/r/22591/#review20429

::: dom/media/MediaStreamTrack.h:212
(Diff revision 1)
>  
> -  RefPtr<DOMMediaStream> mOwningStream;
> +  RefPtr<DOMMediaStream> mOwningDOMStream;

Also, can't mOwningDOMStream be const?
(In reply to Robert O'Callahan (:roc) (Mozilla Corporation) from comment #41)
> Comment on attachment 8676172 [details]
> MozReview Request: Bug 1208371 - Introduce an unbound state for
> MediaStreamTracks r?roc,jib
> 
> https://reviewboard.mozilla.org/r/22591/#review20231
> 
> > I.e., just after cloning a stream, we don't know which TrackIDs the
> > cloned tracks will have. We have to wait for the MSG to handle the
> > new MediaInputPorts and notify us of the new TrackIDs.
> 
> Is there no way to ensure that the main thread can compute the same track ID
> assignments as the MSG?

Well, can I do it behind a Mutex in TrackUnionStream? It might block TrackUnionStream::AddTrack() for a bit but will lead to a cleaner solution.

Otherwise we could perhaps get away with reserving the upper half of the TrackID address space for tracks from TRACK_ANY input ports, and the lower half for tracks from explicit ports. It would break the invariant that TrackIDs are preserved when possible, however, and I'm not sure how to work around that.

Please do tell if you have other ideas.
Flags: needinfo?(roc)
(In reply to Olli Pettay [:smaug] from comment #27)
> Comment on attachment 8676178 [details]
> MozReview Request: Bug 1208371 - Implement MediaStream.clone()
> r?smaug,jib,roc
> 
> 
> -  : mLogicalStreamStartTime(0), mWindow(aWindow),
> +  : mLogicalStreamStartTime(0), mWindow(aWindow), mClonedDOMStream(nullptr)
> No need to initialize RefPtr member variables to null (they are initialized
> to null implicitly)

Fixed.


> +  protected:
> +    virtual ~ClonedStreamSourceGetter() {}
> +    DOMMediaStream* const mStream;
> +  };
> I'm not familiar with this code, but raw pointers as member variables are
> scary so it needs some comment 
> explaining why it can't ever point to deleted object and perhaps
> MOZ_NON_OWNING_REF annotation.

I switched this to a WeakPtr to make it more clear. Even with a comment in this case it was quite tricky to see the relationship.
https://reviewboard.mozilla.org/r/22579/#review20103

> I think you have it right in the patch title, and this should be mOriginalTrack. "ClonedTrack" may be linguistically accurate, but is an odd label and makes me thing of the track-clone.
> 
> When I eject two discs from a duplicator, I write "original" on one and "copy" on the other. I don't write "copied" on the first.

mOriginalTrack it is.
(In reply to Robert O'Callahan (:roc) (Mozilla Corporation) from comment #37)
> Comment on attachment 8676168 [details]
> MozReview Request: Bug 1208371 - Add MediaStreamTrackSourceGetter interface.
> r?roc
> 
> https://reviewboard.mozilla.org/r/22583/#review20221
> 
> ::: dom/media/DOMMediaStream.h:75
> (Diff revision 1)
> > +class MediaStreamTrackSourceGetter
> 
> This needs documentation.

Done.


> ::: dom/media/DOMMediaStream.h:81
> (Diff revision 1)
> > +  NS_IMETHOD_(MozExternalRefCountType) Release(void) = 0;
> 
> Why are these pure virtual? Can't we declare inline refcounting on the class?

I removed the refcounting and instead keep them in a UniquePtr in their parent DOMMediaStream.
(In reply to Jan-Ivar Bruaroey [:jib] from comment #47)
> Comment on attachment 8676172 [details]
> MozReview Request: Bug 1208371 - Introduce an unbound state for
> MediaStreamTracks r?roc,jib
> 
> https://reviewboard.mozilla.org/r/22591/#review20425
> 
> Sorry this is taking so long, but the complexity seems to be rising here,
> and I'm having trouble keeping all the concepts in my head "owning",
> "input", "bound". I'm still unsure what input is. So I'll need more time to
> wrap my head around this. I also feel compelled to "fight back" against this
> complexity (see annoying questions and ideas below).

Appreciated! I found myself a bit stuck in this complexity a couple of times while writing the patches. Though I think I managed to clean it up a little bit after everything got wired up and into a working state. All your "annoying" questions are great help towards making it even cleaner. I'll reply to your other questions in mozreview.
https://reviewboard.mozilla.org/r/22591/#review20425

> The fact that a MediaStreamTrack has an "owning" object very much seems like an implementation detail.
> 
> I'm wondering... What would it take to make mOwningDOMStream private to MediaStreamTrack?
> 
> I'm looking for ways to encapsulate complexity, and it occurs to me that if MediaStreamTrack were not to expose this detail about itself, even to other implementation objects, then it might simplify things.
> 
> MediaStreamTrack would need to proxy some methods to mOwningDOMStream obviously, but how many?

I'll try to hide most of it away and see where that takes me.

We shouldn't have to proxy much at all anymore with the MediaStreamTrackSource interface. For now, there's at least ApplyConstraints going through DOMMediaStream, but that can be moved to MediaStreamTrackSource.

> This should be GetBoundTrackID() according to your own comment above.

Right, changed the comment.

> I see what you're having to do here to avoid confusion about dom "stream" vs. msg "stream", with the introduction of "mBoundOwningStream" being msg vs. mOwningStream which is dom.
> 
> It's not just this line, it's throughout that I find this hard to follow. The fact that we have MediaStream* and MediaStreamTrack* and that they're in different domains, is coming to bear I think.
> 
> I humbly suggest the time may have come to undertake a two-step plan either before or shortly after this bug to:
> 
>  1. Rename MediaStream to MSGMediaStream or MsgStream (or MediaStreamNode?)
>  2. Rename DOMMediaStream to MediaStream sometime soon.
> 
> Once that is done, mBoundOwningStream -> mBoundMsgStream, with no need for "Owning" (since we never bind to non-owned things I presume?)

I completely agree that it would be great to solve the naming issue. I can create another patch or two that does this.

We'd also end up with,
MSGMediaStream
MSGProcessedMediaStream
MSGTrackUnionStream
MSGSourceStream

> The addref here seems redundant.

Fixed.
https://reviewboard.mozilla.org/r/22591/#review20429

> Also, can't mOwningDOMStream be const?

No, because of cycle collection.
https://reviewboard.mozilla.org/r/22591/#review20425

> Right, changed the comment.

Not the function name?

> I completely agree that it would be great to solve the naming issue. I can create another patch or two that does this.
> 
> We'd also end up with,
> MSGMediaStream
> MSGProcessedMediaStream
> MSGTrackUnionStream
> MSGSourceStream

Hmm, not ProcessedMSGMediaStream, TrackUnionMSGStream and SourceMSGStream? Bike-shedding time!

Did anyone like MediaStreamNode? i.e. the "nodes in a graph" in a MediaStreamGraph? I think the root of the confusion is that both concepts are "streams" colloquially, and this would address that (if unfairly since they came first). It would also highlight that the implementation objects are in fact nodes in a graph, and maybe also that a single "stream" of data can run through more than one of these objects. It's also easier to compose on:

MediaStreamNode
ProcessedMediaStreamNode
TrackUnionStreamNode
SourceStreamNode

Thoughts?
Comment on attachment 8676176 [details]
MozReview Request: Bug 1208371 - Remove obsolete SetTrackEnabled() from DOMMediaStream r?roc

https://reviewboard.mozilla.org/r/22599/#review20519

with fix.

::: dom/media/MediaManager.cpp:3168
(Diff revision 1)
> -  if (!(((aIsAudio && mAudioDevice) ||
> -         (!aIsAudio && mVideoDevice)) && !mStopped))
> +  if (mStopped || ((aTrackID == kAudioTrack && !mAudioDevice) &&
> +                   (aTrackID == kVideoTrack && !mVideoDevice)))

One inversion too many.

  if (mStopped || ((aTrackID == kAudioTrack && !mAudioDevice) ||
                   (aTrackID == kVideoTrack && !mVideoDevice)))
Comment on attachment 8676176 [details]
MozReview Request: Bug 1208371 - Remove obsolete SetTrackEnabled() from DOMMediaStream r?roc

https://reviewboard.mozilla.org/r/22599/#review20523
Attachment #8676176 - Flags: review+
Attachment #8676177 - Flags: review?(jib) → review+
Comment on attachment 8676177 [details]
MozReview Request: Bug 1208371 - Let DOMMediaStream base its principal on the tracks it contains. r?mt

https://reviewboard.mozilla.org/r/22601/#review20525

lgtm with nits, unless you bite on refactoring away the dom-owning dummy.

::: dom/media/DOMMediaStream.h:499
(Diff revision 1)
> +  /**
> +   * Creates a MediaStreamTrack cloned from aClonedTrack, adds it to mTracks
> +   * and returns it.
> +   */
> +  MediaStreamTrack* CreateClonedDOMTrack(MediaStreamTrack& aClonedTrack);

aOriginalTrack

and maybe CreateDOMTrackClone ?

::: dom/media/DOMMediaStream.cpp:831
(Diff revision 1)
>  MediaStreamTrack*
> +DOMMediaStream::CreateClonedDOMTrack(MediaStreamTrack& aClonedTrack)

Given where this is called from, I would make this return already_AddRefed<MediaStreamTrack>

::: dom/media/DOMMediaStream.cpp:845
(Diff revision 1)
> +  MediaStreamTrack* track;

I would use RefPtr<> here and .forget() at the end, or this is one early return away from a leak.

::: dom/media/DOMMediaStream.cpp:862
(Diff revision 1)
> +  RefPtr<TrackPort> trackPort =
> +    new TrackPort(inputPort, track, TrackPort::InputPortOwnership::OWNED);
> +  mOwnedTracks.AppendElement(trackPort.forget());

Why not:

    mOwnedTracks.AppendElement(new TrackPort(...))

?

::: dom/media/MediaStreamTrack.cpp:127
(Diff revision 1)
> +  // MediaStreamTracks are currently governed by streams, so we need a dummy
> +  // DOMMediaStream to own our track clone.

Ugh, yeah. I wonder does it need to be domstream-owned? Could it just inherit the other track's msg-stream-node thing and be done?

::: dom/media/MediaStreamTrack.cpp:136
(Diff revision 1)
> +  RefPtr<MediaStreamTrack> newTrack =
> +    newStream->CreateClonedDOMTrack(*this);
> +
> +  return newTrack.forget();

With alredy_addRefed, this would become:

    return newStream->CreateClonedDOMTrack(*this);
Comment on attachment 8676178 [details]
MozReview Request: Bug 1208371 - Add DOMMediaStream::GetTrackById/GetOwnedTrackById. r?jib

https://reviewboard.mozilla.org/r/22603/#review20527

I still need to understand this better.

::: dom/media/DOMMediaStream.h:586
(Diff revision 1)
> +  RefPtr<DOMMediaStream> mClonedDOMStream;

mOriginalDOMStream

::: dom/media/DOMMediaStream.cpp:324
(Diff revision 1)
> -  : mLogicalStreamStartTime(0), mWindow(aWindow),
> +  : mLogicalStreamStartTime(0), mWindow(aWindow), mClonedDOMStream(nullptr),

redundant

::: dom/media/DOMMediaStream.cpp:641
(Diff revision 1)
> +  // Set up an input port from our input stream to the new DOM stream's owned
> +  // stream, to allow for dynamically added tracks at the source to appear in
> +  // the clone. The clone may use mInputStream as its own mInputStream but
> +  // ownership remains with us.

(refactor thoughts) Is destroying mInputStream the main reason we need a pointer to the original?

If so, could we get rid of that dependency with some open/close methods on the input stream instead?

::: dom/media/DOMMediaStream.cpp:645
(Diff revision 1)
> +  DOMMediaStream* originalStream = mClonedDOMStream ? mClonedDOMStream.get() : this;
> +  newStream->mClonedDOMStream = originalStream;

inline auto?

::: dom/media/DOMMediaStream.cpp:653
(Diff revision 1)
> +  // Set up locked input ports for all tracks already existing.
> +  // This will ensure they can be removed at any time, even if
> +  // their TrackIDs are not yet known.
> +  // Due to this, we have to track which tracks are owned by us, so that we
> +  // don't set up those tracks multiple times through the generic port.

I'm not understanding locked ports.

::: dom/media/DOMMediaStream.cpp:672
(Diff revision 1)
> +    newStream->CreateClonedDOMTrack(track);

oh I see about the RefPtr now. I might still vote for it though. Something called "Create" usually returns something.

Maybe if it were named CloneAndAdd() or something
Attachment #8676178 - Flags: review?(jib)
Comment on attachment 8676179 [details]
MozReview Request: Bug 1208371 - Move ImageCapture to a MediaStreamTrackListener. r?roc

https://reviewboard.mozilla.org/r/22605/#review20529

::: dom/media/MediaStreamTrack.cpp:121
(Diff revision 1)
> +  if (mClonedTrack) {
> +    return mClonedTrack->ApplyConstraints(aConstraints, aRv);
> +  } else {
> -  return GetStream()->ApplyConstraintsToTrack(*this, aConstraints, aRv);
> +    return GetStream()->ApplyConstraintsToTrack(*this, aConstraints, aRv);
> -}
> +  }

Why is this necessary?
Attachment #8676179 - Flags: review?(jib)
Attachment #8676180 - Flags: review?(jib) → review+
Comment on attachment 8676180 [details]
MozReview Request: Bug 1208371 - Make it possible to look up stream id by track in PeerConnectionImpl. r?jib

https://reviewboard.mozilla.org/r/22607/#review20531
Comment on attachment 8676181 [details]
MozReview Request: Bug 1208371 - Fix DOMMediaStream::OwnsTrack. r?roc

https://reviewboard.mozilla.org/r/22609/#review20533
Attachment #8676181 - Flags: review?(jib) → review+
(In reply to Jan-Ivar Bruaroey [:jib] from comment #56)
> Did anyone like MediaStreamNode? i.e. the "nodes in a graph" in a
> MediaStreamGraph? I think the root of the confusion is that both concepts
> are "streams" colloquially, and this would address that (if unfairly since
> they came first). It would also highlight that the implementation objects
> are in fact nodes in a graph, and maybe also that a single "stream" of data
> can run through more than one of these objects. It's also easier to compose
> on:
> 
> MediaStreamNode
> ProcessedMediaStreamNode
> TrackUnionStreamNode
> SourceStreamNode

Not "Node" since we have Web Audio nodes and that would get confusing.

Maybe GraphMediaStream... etc. Or RTMediaStream... etc for "real time" (although for offline MSGs, they're not).

Maybe GraphMediaStream would get confused with MediaStreamGraph.

Maybe AsyncMediaStream?
Flags: needinfo?(roc)
(In reply to Andreas Pehrson [:pehrsons] (Telenor) from comment #49)
> Well, can I do it behind a Mutex in TrackUnionStream? It might block
> TrackUnionStream::AddTrack() for a bit but will lead to a cleaner solution.

I don't want to bring Mutexes in here.

> Otherwise we could perhaps get away with reserving the upper half of the
> TrackID address space for tracks from TRACK_ANY input ports, and the lower
> half for tracks from explicit ports. It would break the invariant that
> TrackIDs are preserved when possible, however, and I'm not sure how to work
> around that.

I was hoping for a deterministic track assignment algorithm so that the main thread and the MSG thread agree on track IDs.

Maybe we don't need to preserve track IDs. It seemed like a nice thing to have but off the top of my head I don't know of anything that actually needs it.

Seems to me we should be able to set things up so that when the DOM track exists first, the main thread assigns the track ID and propagates that to the MSG. When the MSG track exists first, the MSG assigns the track ID and propagates that to the main thread.
Attachment #8676182 - Flags: review?(jib) → review+
Comment on attachment 8676182 [details]
MozReview Request: Bug 1208371 - Remove MediaStreamTrack::GetStream. r?jib

https://reviewboard.mozilla.org/r/22611/#review20603

Found two minor issues, the rest are ideas.

::: dom/media/tests/mochitest/test_getUserMedia_mediaStreamClone.html:22
(Diff revision 1)
> +      is(stream.getAudioTracks().length, clone.getAudioTracks().length,
> +         "All audio tracks should get cloned");
> +      is(stream.getVideoTracks().length, clone.getVideoTracks().length,
> +         "All video tracks should get cloned");

The clone's value should be the first argument since that's what we're testing, and that's the value we want dumped in the alert message if it's wrong.

::: dom/media/tests/mochitest/test_getUserMedia_mediaStreamClone.html:29
(Diff revision 1)
> +      // XXX Check stream ID and all cloned tracks' IDs are following the spec

bug # or coming follow-on patch?

::: dom/media/tests/mochitest/test_getUserMedia_mediaStreamClone.html:45
(Diff revision 1)
> +        var clonedStream = stream.clone();

On naming: maybe streamClone, since clonedStream has multiple connotations?

::: dom/media/tests/mochitest/test_getUserMedia_mediaStreamClone.html:47
(Diff revision 1)
> +        isnot(clonedTrack, track,
> +              "Cloned track should be different from the original");

I would move this up to the first test, to do it on both audio and video.

Also maybe check kind == kind, enabled == enabled and id != id?

::: dom/media/tests/mochitest/test_getUserMedia_mediaStreamClone.html:64
(Diff revision 1)
> +        // Not part of clonedStream. Does not get stopped by the playback test.
> +        otherTrack.stop();

Maybe throw in stream.stop() as well for good measure?

::: dom/media/tests/mochitest/test_getUserMedia_mediaStreamClone.html:70
(Diff revision 1)
> +    }))

These APIs are extremely flexible now, so I feel like we should throw in some sick tests here as well. E.g.

Test for cycle-collection leaks (e.g. mOriginalTrack):

    var b = a.clone().clone().clone().clone().clone().clone().clone().clone();
    var atracks = a.getTracks(); 
    atracks.forEach(t => (a.removeTrack(t), b.addTrack(t)));

Have tracks multiply, if we support that:

    var atracks = a.getTracks(); 
    for (var i = 0; i < 10; i++) {
      atracks.forEach(t => a.addTrack(t.clone()));
    }
    var b = a.clone();

What do you think?

::: dom/media/tests/mochitest/test_getUserMedia_mediaStreamClone.html:77
(Diff revision 1)
> +      var osc1k = osc1kOriginal.clone();
> +      var audioTrack1k = osc1k.getTracks()[0];

osc1k is unused. i.e. why not:

    var audioTrack1kClone = osc1kOriginal.clone().getTracks()[0];

Also, labeling the clone 'clone' would help at least me remember what's being tested (I lost track below).

Lastly, could we just clone the track here? e.g.

    var audioTrack1kClone = audioTrack1kOriginal.clone();

then we could get rid of var osc1kOriginal as well.

::: dom/media/tests/mochitest/test_getUserMedia_mediaStreamClone.html:82
(Diff revision 1)
> +      var osc5k = osc5kOriginal.clone();
> +      var audioTrack5k = osc5k.getTracks()[0];

same applies here.

::: dom/media/tests/mochitest/test_getUserMedia_mediaStreamClone.html:101
(Diff revision 1)
> +            stream.getTracks().forEach(t => t.stop());
> +            return analyser.waitForAnalysisSuccess(array =>
> +                     array[analyser.binIndexForFrequency(50)] < 50 &&
> +                     array[analyser.binIndexForFrequency(1000)] > 200 &&

Hmm, after stop(), shouldn't this be

    array[analyser.binIndexForFrequency(1000)] < 50 &&

?

::: dom/media/tests/mochitest/test_getUserMedia_mediaStreamClone.html:106
(Diff revision 1)
> +                     // WebAudioDestination streams do not handle stop()
> +                     // array[analyser.binIndexForFrequency(5000)] > 200 &&

Is that a bug? If so, bug #. But again, shouldn't it be < 50 ?

::: dom/media/tests/mochitest/test_getUserMedia_mediaStreamClone.html:127
(Diff revision 1)
> +        var stream = new MediaStream([audioTrack1k, audioTrack5k]);
> +        var clonedStream = stream.clone();

stream is unused. i.e. we could do

    var streamClone = new MediaStream([audioTrack1k, audioTrack5k]).clone();

Less chance of analysing the wrong var below this way I think.

::: dom/media/tests/mochitest/test_getUserMedia_mediaStreamClone.html:141
(Diff revision 1)
> +        var stream = new MediaStream([audioTrack1k, audioTrack5k]);
> +        var clonedStream = stream.clone();
> +        var newStream = new MediaStream();
> +        clonedStream.getTracks().forEach(t => newStream.addTrack(t));

Why not:

    var stream = new MediaStream(new MediaStream([audioTrack1k, audioTrack5k]).clone().getTracks());

?

::: dom/media/tests/mochitest/test_getUserMedia_mediaStreamClone.html:158
(Diff revision 1)
> +        var clonedStream = stream.clone();
> +        stream.getTracks().forEach(t => stream.removeTrack(t));
> +        clonedStream.getTracks().forEach(t => stream.addTrack(t));
> +
> +        var analyser = new AudioStreamAnalyser(ac, stream);
> +        analyser.enableDebugCanvas();
> +        return analyser.waitForAnalysisSuccess(array =>
> +                 array[analyser.binIndexForFrequency(50)] < 50 &&
> +                 array[analyser.binIndexForFrequency(1000)] > 200 &&
> +                 array[analyser.binIndexForFrequency(3000)] < 50 &&
> +                 array[analyser.binIndexForFrequency(5000)] > 200 &&
> +                 array[analyser.binIndexForFrequency(10000)] < 50)
> +          .then(() => analyser.disableDebugCanvas());

What if we mixed it up here and moved just one of the tracks from the clone to the original and then analysed both?

::: dom/media/tests/mochitest/test_getUserMedia_mediaStreamClone.html:172
(Diff revision 1)
> +    }));

Would it be useful to throw in an analyser test that checks that a clone can be enabled/disabled separately from the original?
https://reviewboard.mozilla.org/r/22579/#review20103

After looking at the other patches, it seems to me like this dependency could be refactored out, but I don't see anything wrong either, so marking at Ship it to not block on refactor.
Comment on attachment 8676164 [details]
MozReview Request: Bug 1208371 - Un-nest MediaEngineSource::PhotoCallback. r?roc

https://reviewboard.mozilla.org/r/22579/#review20629
Attachment #8676164 - Flags: review?(jib) → review+
https://reviewboard.mozilla.org/r/22601/#review20525

> aOriginalTrack
> 
> and maybe CreateDOMTrackClone ?

We already have CreateOwnDOMTrack and with that in mind I think CreateClonedDOMTrack makes more sense.

> I would use RefPtr<> here and .forget() at the end, or this is one early return away from a leak.

Done

> Why not:
> 
>     mOwnedTracks.AppendElement(new TrackPort(...))
> 
> ?

We already had this pattern in CreateOwnDOMTrack, but if you don't mind I'll change both.

> Ugh, yeah. I wonder does it need to be domstream-owned? Could it just inherit the other track's msg-stream-node thing and be done?

I can imagine it working by just creating a new MSG-side TrackUnionStream and let that be the track clone's owning stream. The input stream would be inherited.

It might create separate code paths for stream and track cloning though, so I'm not sure I want to do it right now.
https://reviewboard.mozilla.org/r/22603/#review20527

> (refactor thoughts) Is destroying mInputStream the main reason we need a pointer to the original?
> 
> If so, could we get rid of that dependency with some open/close methods on the input stream instead?

Yep, I have a patch that does something like this. It lets us get rid of the pointer to the original.

> I'm not understanding locked ports.

Track-locked maybe?

A port here is a MediaInputPort (MSG-side) that forwards tracks from one stream to another. Normally it forwards all tracks but it can also be locked to a specific TrackID in the input stream.
https://reviewboard.mozilla.org/r/22605/#review20529

> Why is this necessary?

Because of DOMMediaStream sub classes (hello nsDOMUserMediaStream). It should really go through the MediaStreamTrackSource though, I'll move it there for the next version of this patch.
(In reply to Andreas Pehrson [:pehrsons] (Telenor) from comment #69)
> https://reviewboard.mozilla.org/r/22601/#review20525
> 
> > aOriginalTrack
> > 
> > and maybe CreateDOMTrackClone ?
> 
> We already have CreateOwnDOMTrack and with that in mind I think
> CreateClonedDOMTrack makes more sense.

Earlier, this patch used "cloned track" simultaneously to mean the track being cloned and the clone. It could mean both, which is why I think we should avoid the notion.

How about CreateCloneDOMTrack?
(In reply to Andreas Pehrson [:pehrsons] (Telenor) from comment #70)
> Track-locked maybe?
> 
> A port here is a MediaInputPort (MSG-side) that forwards tracks from one
> stream to another. Normally it forwards all tracks but it can also be locked
> to a specific TrackID in the input stream.

Cool. A comment to that effect should do then, unless I missed it.
(In reply to Robert O'Callahan (:roc) (Mozilla Corporation) from comment #65)
> (In reply to Andreas Pehrson [:pehrsons] (Telenor) from comment #49)
> > Well, can I do it behind a Mutex in TrackUnionStream? It might block
> > TrackUnionStream::AddTrack() for a bit but will lead to a cleaner solution.
> 
> I don't want to bring Mutexes in here.
> 
> > Otherwise we could perhaps get away with reserving the upper half of the
> > TrackID address space for tracks from TRACK_ANY input ports, and the lower
> > half for tracks from explicit ports. It would break the invariant that
> > TrackIDs are preserved when possible, however, and I'm not sure how to work
> > around that.
> 
> I was hoping for a deterministic track assignment algorithm so that the main
> thread and the MSG thread agree on track IDs.
> 
> Maybe we don't need to preserve track IDs. It seemed like a nice thing to
> have but off the top of my head I don't know of anything that actually needs
> it.
> 
> Seems to me we should be able to set things up so that when the DOM track
> exists first, the main thread assigns the track ID and propagates that to
> the MSG. When the MSG track exists first, the MSG assigns the track ID and
> propagates that to the main thread.

I was able to make it deterministic by allowing the main thread caller to provide a TrackID mapping as long as no TRACK_ANY input port was added prior (if one exists, there might be a race where the desired TrackID gets taken by a track coming from the source stream rather than the main thread). This solves my use case and simplifies the code by quite a bit. :-)
Depends on: 1220047
https://reviewboard.mozilla.org/r/22611/#review20603

> bug # or coming follow-on patch?

Actually spec just says that using a UUID is good practice so I'll just test that it's non-empty here.

> These APIs are extremely flexible now, so I feel like we should throw in some sick tests here as well. E.g.
> 
> Test for cycle-collection leaks (e.g. mOriginalTrack):
> 
>     var b = a.clone().clone().clone().clone().clone().clone().clone().clone();
>     var atracks = a.getTracks(); 
>     atracks.forEach(t => (a.removeTrack(t), b.addTrack(t)));
> 
> Have tracks multiply, if we support that:
> 
>     var atracks = a.getTracks(); 
>     for (var i = 0; i < 10; i++) {
>       atracks.forEach(t => a.addTrack(t.clone()));
>     }
>     var b = a.clone();
> 
> What do you think?

I think it's a great idea!

You can't add a track if it already exists, but you can clone it and then add it to the original, and loop that a couple of times :-)

> osc1k is unused. i.e. why not:
> 
>     var audioTrack1kClone = osc1kOriginal.clone().getTracks()[0];
> 
> Also, labeling the clone 'clone' would help at least me remember what's being tested (I lost track below).
> 
> Lastly, could we just clone the track here? e.g.
> 
>     var audioTrack1kClone = audioTrack1kOriginal.clone();
> 
> then we could get rid of var osc1kOriginal as well.

I want to do track cloning in another test, but I'll take the rest.

> Hmm, after stop(), shouldn't this be
> 
>     array[analyser.binIndexForFrequency(1000)] < 50 &&
> 
> ?

Yes, this was an error on my part.

> Is that a bug? If so, bug #. But again, shouldn't it be < 50 ?

I'm not sure. I'm planning to take this discussion when we implement the `remote` attribute for tracks, as that's what the stop() algorithm looks at.

> What if we mixed it up here and moved just one of the tracks from the clone to the original and then analysed both?

Sure.

> Would it be useful to throw in an analyser test that checks that a clone can be enabled/disabled separately from the original?

Certainly.
(In reply to Jan-Ivar Bruaroey [:jib] from comment #72)
> (In reply to Andreas Pehrson [:pehrsons] (Telenor) from comment #69)
> > https://reviewboard.mozilla.org/r/22601/#review20525
> > 
> > > aOriginalTrack
> > > 
> > > and maybe CreateDOMTrackClone ?
> > 
> > We already have CreateOwnDOMTrack and with that in mind I think
> > CreateClonedDOMTrack makes more sense.
> 
> Earlier, this patch used "cloned track" simultaneously to mean the track
> being cloned and the clone. It could mean both, which is why I think we
> should avoid the notion.
> 
> How about CreateCloneDOMTrack?



Or CreateDOMTrack()/CloneDOMTrack() for CreateOwnDOMTrack()/CreateClonedDOMTrack()?

I'm about to update the patches here but I haven't resolved this yet. It's on my list.
(In reply to Jan-Ivar Bruaroey [:jib] from comment #73)
> (In reply to Andreas Pehrson [:pehrsons] (Telenor) from comment #70)
> > Track-locked maybe?
> > 
> > A port here is a MediaInputPort (MSG-side) that forwards tracks from one
> > stream to another. Normally it forwards all tracks but it can also be locked
> > to a specific TrackID in the input stream.
> 
> Cool. A comment to that effect should do then, unless I missed it.

https://dxr.mozilla.org/mozilla-central/rev/1fbc958f75576446a57cf93406db87b51b12911d/dom/media/MediaStreamGraph.h#921
https://dxr.mozilla.org/mozilla-central/rev/1fbc958f75576446a57cf93406db87b51b12911d/dom/media/MediaStreamGraph.h#1066

:-)
I'm about to push another set of patches to mozreview, but ordering has changed somewhat and that is messing with reviewboard. I'm letting the first couple of patches keep their r+ as they're unchanged, but I'm requesting new reviews for most other ones. Sorry for any and all inconvenience caused.

This is probably from my workflow of using git and then moving patches over to hg in one go. I don't know of a solution to that problem :/
Comment on attachment 8676157 [details]
MozReview Request: Bug 1208371 - Pass parent window to DOMMediaStream through constructor. r?roc

Bug 1208371 - Pass parent window to DOMMediaStream through constructor. r?roc
Comment on attachment 8676159 [details]
MozReview Request: Bug 1208371 - Make AudioCaptureStream startable. r?padenot

Bug 1208371 - Make AudioCaptureStream startable. r?padenot
This allows us to add the JS-side MediaStreamTrack before the MSG-side
track.
Comment on attachment 8676160 [details]
MozReview Request: Bug 1208371 - Move OnTracksAvailableCallback out of DOMMediaStream. r?roc

Bug 1208371 - Move OnTracksAvailableCallback out of DOMMediaStream. r?roc
So it can be forward declared.
Attachment #8676160 - Attachment description: MozReview Request: Bug 1208371 - Expose TrackPort in DOMMediaStream.h r?roc → MozReview Request: Bug 1208371 - Move OnTracksAvailableCallback out of DOMMediaStream. r?roc
Comment on attachment 8676161 [details]
MozReview Request: Bug 1208371 - Remove unused MediaManager::NotifyMediaStreamTrackEnded. r?jib

Bug 1208371 - Remove unused MediaManager::NotifyMediaStreamTrackEnded. r?jib
Attachment #8676161 - Attachment description: MozReview Request: Bug 1208371 - Move OnTracksAvailableCallback out of DOMMediaStream. r?roc → MozReview Request: Bug 1208371 - Remove unused MediaManager::NotifyMediaStreamTrackEnded. r?jib
Comment on attachment 8676162 [details]
MozReview Request: Bug 1208371 - Introduce MediaStreamTrack logs. r?roc,jib

Bug 1208371 - Introduce MediaStreamTrack logs. r?roc
Attachment #8676162 - Attachment description: MozReview Request: Bug 1208371 - Remove unused MediaManager::NotifyMediaStreamTrackEnded. r?jib → MozReview Request: Bug 1208371 - Introduce MediaStreamTrack logs. r?roc
Comment on attachment 8676163 [details]
MozReview Request: Bug 1208371 - Track original track in MediaStreamTrack clones. r?jib

Bug 1208371 - Track original track in MediaStreamTrack clones. r?jib
Attachment #8676163 - Attachment description: MozReview Request: Bug 1208371 - Introduce MediaStreamTrack logs. r?roc → MozReview Request: Bug 1208371 - Track original track in MediaStreamTrack clones. r?jib
Attachment #8676163 - Flags: review?(jib)
Attachment #8676164 - Attachment description: MozReview Request: Bug 1208371 - Track original track in MediaStreamTrack clones. r?jib → MozReview Request: Bug 1208371 - Un-nest MediaEngineSource::PhotoCallback. r?roc
Attachment #8676164 - Flags: review?(roc)
Comment on attachment 8676164 [details]
MozReview Request: Bug 1208371 - Un-nest MediaEngineSource::PhotoCallback. r?roc

Bug 1208371 - Un-nest MediaEngineSource::PhotoCallback. r?roc
So it may be forward declared.
Comment on attachment 8676165 [details]
MozReview Request: Bug 1208371 - Add MediaStreamTrack::Graph(). r?jib

Bug 1208371 - Make DOMMediaStream support WeakPtrs. r?roc
Attachment #8676165 - Attachment description: MozReview Request: Bug 1208371 - Add a MediaStreamTrackSource interface. r?roc → MozReview Request: Bug 1208371 - Make DOMMediaStream support WeakPtrs. r?roc
Attachment #8676165 - Flags: review?(roc)
Attachment #8676168 - Attachment description: MozReview Request: Bug 1208371 - Add MediaStreamTrackSourceGetter interface. r?roc → MozReview Request: Bug 1208371 - Add a MediaStreamTrackSource interface. r?roc
Attachment #8676168 - Flags: review?(roc)
Comment on attachment 8676168 [details]
MozReview Request: Bug 1208371 - Add a MediaStreamTrackSource interface. r?roc

Bug 1208371 - Add a MediaStreamTrackSource interface. r?roc
This lets a MediaStreamTrack communicate with its source/producer on the
main thread. It's for now used for stopping a track at the source and
retrieving some metadata, but it could also be a link between actual
sinks of a track and the source, to for instance let the source optimize
by scaling down the resolution when all sinks want lowres-video.
Comment on attachment 8676169 [details]
MozReview Request: Bug 1208371 - Add MediaStreamTrackSourceGetter interface. r?roc

Bug 1208371 - Add MediaStreamTrackSourceGetter interface. r?roc
This allows DOMMediaStream to assign MediaStreamTrackSources to
dynamically created MediaStreamTracks.
Attachment #8676169 - Attachment description: MozReview Request: Bug 1208371 - Let MediaStreamTracks know their TrackID at the source. r?roc → MozReview Request: Bug 1208371 - Add MediaStreamTrackSourceGetter interface. r?roc
Comment on attachment 8676170 [details]
MozReview Request: Bug 1208371 - Let MediaStreamTracks know their TrackID at the source. r?roc

Bug 1208371 - Let MediaStreamTracks know their TrackID at the source. r?roc
For original tracks, the input TrackID is the same as in its
owned stream.
For cloned tracks, the input TrackID comes from the original track,
since no guarantees about TrackIDs in a cloned DOMMediaStream's owned
stream can be given
(imagine e.g., `new MediaStream([trackID1FromStreamX, trackID1FromStreamY]).clone()`).
Attachment #8676170 - Attachment description: MozReview Request: Bug 1208371 - Let FindOwnedDOMTrack operate on input stream. r?roc → MozReview Request: Bug 1208371 - Let MediaStreamTracks know their TrackID at the source. r?roc
Comment on attachment 8676171 [details]
MozReview Request: Bug 1208371 - Let FindOwnedDOMTrack operate on input stream. r?roc

Bug 1208371 - Let FindOwnedDOMTrack operate on input stream. r?roc
This let's us use FindOwnedDOMTrack before the TrackID in mOwnedStream
is known.

This is necessary for a stream clone with multiple tracks whose original
TrackID is the same.
Attachment #8676171 - Attachment description: MozReview Request: Bug 1208371 - Add some MediaStreamTrack helper methods. r?roc → MozReview Request: Bug 1208371 - Let FindOwnedDOMTrack operate on input stream. r?roc
Attachment #8676172 - Attachment description: MozReview Request: Bug 1208371 - Introduce an unbound state for MediaStreamTracks r?roc,jib → MozReview Request: Bug 1208371 - Add some MediaStreamTrack helper methods. r?roc
Comment on attachment 8676172 [details]
MozReview Request: Bug 1208371 - Add some MediaStreamTrack helper methods. r?roc

Bug 1208371 - Add some MediaStreamTrack helper methods. r?roc
Comment on attachment 8676173 [details]
MozReview Request: Bug 1208371 - Count the users of a MediaStream to ease Destroy() responsibility. r?roc

Bug 1208371 - Count the users of a MediaStream to ease Destroy() responsibility. r?roc
Attachment #8676173 - Attachment description: MozReview Request: Bug 1208371 - Remove obsolete SetTrackEnabled() from DOMMediaStream r?roc → MozReview Request: Bug 1208371 - Count the users of a MediaStream to ease Destroy() responsibility. r?roc
Comment on attachment 8676174 [details]
MozReview Request: Bug 1208371 - Add convenience method for checking if TrackID is explicit. r?roc

Bug 1208371 - Add convenience method for checking if TrackID is explicit. r?roc
Attachment #8676174 - Attachment description: MozReview Request: Bug 1208371 - Allow MediaInputPorts to be created before the source's TrackID is known. r?roc → MozReview Request: Bug 1208371 - Add convenience method for checking if TrackID is explicit. r?roc
Comment on attachment 8676175 [details]
MozReview Request: Bug 1208371 - Allow MediaInputPorts mapped to a destination TrackID. r?roc

Bug 1208371 - Allow MediaInputPorts mapped to a destination TrackID. r?roc
This lets us know the track's TrackID in the destination stream before
the input port has been processed.
For sanity we only allow mapping to a destination TrackID if the
destination stream does not have any TRACK_ANY input ports already
assigned to it as that can cause intermittent TrackID collisions.
Attachment #8676175 - Attachment description: MozReview Request: Bug 1208371 - Allow allocating input ports based on not-yet-initialized input ports. r?roc → MozReview Request: Bug 1208371 - Allow MediaInputPorts mapped to a destination TrackID. r?roc
Comment on attachment 8676176 [details]
MozReview Request: Bug 1208371 - Remove obsolete SetTrackEnabled() from DOMMediaStream r?roc

Bug 1208371 - Remove obsolete SetTrackEnabled() from DOMMediaStream r?roc
Attachment #8676176 - Attachment description: MozReview Request: Bug 1208371 - Pass MediaStreamTrack to ApplyConstraintsToTrack instead of TrackID. r?jib → MozReview Request: Bug 1208371 - Remove obsolete SetTrackEnabled() from DOMMediaStream r?roc
Attachment #8676176 - Flags: review?(roc)
Attachment #8676177 - Attachment description: MozReview Request: Bug 1208371 - Implement MediaStreamTrack::Clone(). r?smaug,jib,roc → MozReview Request: Bug 1208371 - Add MediaStreamTrack::Graph(). r?jib
Attachment #8676177 - Flags: review+
Comment on attachment 8676177 [details]
MozReview Request: Bug 1208371 - Let DOMMediaStream base its principal on the tracks it contains. r?mt

Bug 1208371 - Add MediaStreamTrack::Graph(). r?jib
Comment on attachment 8676178 [details]
MozReview Request: Bug 1208371 - Add DOMMediaStream::GetTrackById/GetOwnedTrackById. r?jib

Bug 1208371 - Add a PrincipalChangeObserver interface to MediaStreamTrack. r?roc
Also adds MediaStreamTrack::GetPrincipal, so we can start moving
consumers towards checking principals per consumed track, and producers
to set principals per track instead of per stream.

For compatibility with modules consuming whole streams we can move
DOMMediaStream over to listening for principal changes on all its
tracks, plus update its principal when its set of tracks changes.
Attachment #8676178 - Attachment description: MozReview Request: Bug 1208371 - Implement MediaStream.clone() r?smaug,jib,roc → MozReview Request: Bug 1208371 - Add a PrincipalChangeObserver interface to MediaStreamTrack. r?roc
Attachment #8676178 - Flags: review+ → review?(roc)
Comment on attachment 8676179 [details]
MozReview Request: Bug 1208371 - Move ImageCapture to a MediaStreamTrackListener. r?roc

Bug 1208371 - Add an MSGListener interface to MediaStreamTrack. r?roc
This creates a convenience Wrapper MSGListener around
MediaStreamListener to make MediaStreamTrack more self contained. The
convenience lies in that the MediaStreamTrack will handle filtering out
the right TrackID in the MediaStreamListener callback and only forward
the relevant ones to the MSGListener instances.
Attachment #8676179 - Attachment description: MozReview Request: Bug 1208371 - Forward applyConstraints() to original track for clones. r?jib → MozReview Request: Bug 1208371 - Add an MSGListener interface to MediaStreamTrack. r?roc
Attachment #8676179 - Flags: review?(roc)
Comment on attachment 8676180 [details]
MozReview Request: Bug 1208371 - Make it possible to look up stream id by track in PeerConnectionImpl. r?jib

Bug 1208371 - Make it possible to look up stream id by track in PeerConnectionImpl. r?jib
This attempts to get rid of uses of MediaStreamTrack::GetStream() in
PeerConnectionImpl but does unfortunately not go all the way. There's
still a use case in ReplaceTrack() so we handle it for now by making
PeerConnectionImpl a friend of MediaStreamTrack.
Attachment #8676180 - Attachment description: MozReview Request: Bug 1208371 - Various cleanups in DOMMediaStream/MediaStreamTrack. r?jib → MozReview Request: Bug 1208371 - Make it possible to look up stream id by track in PeerConnectionImpl. r?jib
Comment on attachment 8676181 [details]
MozReview Request: Bug 1208371 - Fix DOMMediaStream::OwnsTrack. r?roc

Bug 1208371 - Fix DOMMediaStream::OwnsTrack. r?roc
Attachment #8676181 - Attachment description: MozReview Request: Bug 1208371 - Move track.stop() helpers to MediaStreamPlayback and wrap methods in getters. r?jib → MozReview Request: Bug 1208371 - Fix DOMMediaStream::OwnsTrack. r?roc
Attachment #8676181 - Flags: review?(roc)
Comment on attachment 8676182 [details]
MozReview Request: Bug 1208371 - Remove MediaStreamTrack::GetStream. r?jib

Bug 1208371 - Remove MediaStreamTrack::GetStream/GetParentObject. r?jib
Attachment #8676182 - Attachment description: MozReview Request: Bug 1208371 - Test MediaStream.clone(). r?jib → MozReview Request: Bug 1208371 - Remove MediaStreamTrack::GetStream/GetParentObject. r?jib
Bug 1208371 - Route ApplyConstraints through MediaStreamTrackSource. r?jib
Attachment #8681202 - Flags: review?(jib)
Bug 1208371 - Make it possible to block tracks in a MediaInputPort initally. r?roc
Attachment #8681203 - Flags: review?(roc)
Bug 1208371 - Implement MediaStreamTrack::Clone(). r?smaug,jib,roc
Attachment #8681204 - Flags: review?(roc)
Attachment #8681204 - Flags: review?(jib)
Attachment #8681204 - Flags: review?(bugs)
Bug 1208371 - Implement MediaStream.clone() r?smaug,jib,roc
Attachment #8681205 - Flags: review?(roc)
Attachment #8681205 - Flags: review?(jib)
Attachment #8681205 - Flags: review?(bugs)
Bug 1208371 - Various cleanups in DOMMediaStream/MediaStreamTrack. r?jib
Attachment #8681206 - Flags: review?(jib)
Bug 1208371 - Forward input stream and track id on regular track changes for union streams. r?roc
Attachment #8681207 - Flags: review?(roc)
Bug 1208371 - Move track.stop() helpers to MediaStreamPlayback and wrap methods in getters. r?jib
Attachment #8681208 - Flags: review?(jib)
Bug 1208371 - Test MediaStream.clone(). r?jib
Attachment #8681209 - Flags: review?(jib)
Attachment #8681204 - Flags: review?(bugs) → review+
Comment on attachment 8681205 [details]
MozReview Request: Bug 1208371 - Implement DOMMediaStream::Clone() r?smaug,jib,roc

(MozReview is being silly here, since I r+'ed the previous versions of these patches already.)
Attachment #8681205 - Flags: review?(bugs) → review+
Comment on attachment 8676163 [details]
MozReview Request: Bug 1208371 - Track original track in MediaStreamTrack clones. r?jib

https://reviewboard.mozilla.org/r/22577/#review21293
Attachment #8676163 - Flags: review?(jib) → review+
https://reviewboard.mozilla.org/r/22601/#review21389

::: dom/media/MediaStreamTrack.cpp:118
(Diff revision 2)
> +  return mOwningStream->GetOwnedStream()->Graph();

A lot of owning going on here.
Comment on attachment 8676182 [details]
MozReview Request: Bug 1208371 - Remove MediaStreamTrack::GetStream. r?jib

https://reviewboard.mozilla.org/r/22611/#review21393

::: media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp:2088
(Diff revision 2)
>  PeerConnectionImpl::GetRemoteTrackId(const std::string streamId,
> -                                     TrackID numericTrackId,
> +                                     const MediaStreamTrack& aTrack,
>                                       std::string* trackId) const
>  {
>    if (IsClosed()) {
>      return NS_ERROR_UNEXPECTED;
>    }
>  
> -  return mMedia->GetRemoteTrackId(streamId, numericTrackId, trackId);
> +  return mMedia->GetRemoteTrackId(streamId, aTrack.mTrackID, trackId);

These changes are great! I'd love to push this change deeper, into the same function in PeerConnectionMedia and SourceStreamInfo, as there's a chance we'd reach the bottom and get rid of the id here entirely (but it doesn't need to be in this bug).

The distinction of a "numericTrackId" wont be missed. :)

[1] http://mxr.mozilla.org/mozilla-central/source/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp?rev=e8c7dfe727cd#760
Attachment #8676182 - Flags: review+
Attachment #8681202 - Flags: review?(jib) → review+
Comment on attachment 8681202 [details]
MozReview Request: Bug 1208371 - Route ApplyConstraints through MediaStreamTrackSource. r?jib

https://reviewboard.mozilla.org/r/23771/#review21397

::: dom/media/MediaManager.cpp:3157
(Diff revision 1)
> -  if (!(((aIsAudio && mAudioDevice) ||
> -         (!aIsAudio && mVideoDevice)) && !mStopped))
> +  if (mStopped || ((aTrackID == kAudioTrack && !mAudioDevice) ||
> +                   (aTrackID == kVideoTrack && !mVideoDevice)))
>    {
>      LOG(("gUM track %d applyConstraints, but we don't have type %s",
> -         aTrackID, aIsAudio ? "audio" : "video"));
> +         aTrackID, aTrackID == kAudioTrack ? "audio" : "video"));
>      p->Resolve(false);
>      return p.forget();
>    }
>  
>    // XXX to support multiple tracks of a type in a stream, this should key off
>    // the TrackID and not just the type
> -  RefPtr<AudioDevice> audioDevice = aIsAudio ? mAudioDevice.get() : nullptr;
> -  RefPtr<VideoDevice> videoDevice = !aIsAudio ? mVideoDevice.get() : nullptr;
> +  RefPtr<AudioDevice> audioDevice =
> +    aTrackID == kAudioTrack ? mAudioDevice.get() : nullptr;
> +  RefPtr<VideoDevice> videoDevice =
> +    aTrackID == kVideoTrack ? mVideoDevice.get() : nullptr;

Now that this is cleaner, it seems obvious that this is just:

    if (mStopped || (!audioDevice && !videoDevice))

(if we move the if below the RefPtrs)
(In reply to Andreas Pehrson [:pehrsons] (Telenor) from comment #76)
> Or CreateDOMTrack()/CloneDOMTrack() for
> CreateOwnDOMTrack()/CreateClonedDOMTrack()?

+1
Comment on attachment 8681204 [details]
MozReview Request: Bug 1208371 - Implement MediaStreamTrack::Clone(). r?smaug,jib,roc

https://reviewboard.mozilla.org/r/23775/#review21443

Crashes I think.

::: dom/media/DOMMediaStream.h:524
(Diff revision 1)
> +  already_AddRefed<MediaStreamTrack> CreateClonedDOMTrack(MediaStreamTrack& aClonedTrack,
> +                                                          TrackID aCloneTrackID);

CloneDOMTrack sounds good.

::: dom/media/DOMMediaStream.cpp:816
(Diff revision 1)
> +  TrackID inputTrackID = aOriginalTrack.mInputTrackID;
> +  MediaStream* inputStream = aOriginalTrack.GetInputStream();
> +
> +  CombineWithPrincipal(aOriginalTrack.GetPrincipal());
> +
> +  MediaStreamTrackSource& source = aOriginalTrack.GetSource();
> +  RefPtr<MediaStreamTrack> track;
> +  if (aOriginalTrack.AsAudioStreamTrack()) {
> +    track = new AudioStreamTrack(this, aCloneTrackID, inputTrackID, &source);
> +  } else if (aOriginalTrack.AsVideoStreamTrack()) {
> +    track = new VideoStreamTrack(this, aCloneTrackID, inputTrackID, &source);
> +  } else {
> +    MOZ_CRASH("Unhandled track type");
> +  }
> +
> +  track->mOriginalTrack = &aOriginalTrack;

What if we're cloning a clone?

Do all of these still make sense?

mOriginalTrack will in this case not point to an original track but to another clone.

::: dom/media/MediaStreamTrack.cpp:136
(Diff revision 1)
> +  MediaStreamTrackSourceGetter* getter = nullptr; // No dynamically added tracks
> +  RefPtr<DOMMediaStream> newStream =
> +    new DOMMediaStream(mOwningStream->GetParentObject(), getter);

nit: The getter var exposition just confused me ("is it an out arg?") I would just use nullptr in the arg here, with comment.

::: dom/media/MediaStreamTrack.cpp:150
(Diff revision 1)
>    MediaStreamTrack* originalTrack =
>      mOriginalTrack ? mOriginalTrack.get() : this;
>    MOZ_RELEASE_ASSERT(originalTrack->mOwningStream);

Wont this crash if I clone another clone?
Comment on attachment 8681205 [details]
MozReview Request: Bug 1208371 - Implement DOMMediaStream::Clone() r?smaug,jib,roc

https://reviewboard.mozilla.org/r/23777/#review21445

I don't know what this patch is doing, or why new concepts like weakptrs are needed.

According to the spec [1] this should be as simple as:

 1. Let streamClone be a newly constructed MediaStream object.

 2. Initialize streamClone's id attribute to a newly generated value.

 3. Clone each track in this MediaStream object and add the result to streamClone's track set.


[1] http://w3c.github.io/mediacapture-main/getusermedia.html#widl-MediaStream-clone-MediaStream
Attachment #8681205 - Flags: review?(jib)
Attachment #8681206 - Flags: review?(jib) → review+
Comment on attachment 8681206 [details]
MozReview Request: Bug 1208371 - Various cleanups in DOMMediaStream/MediaStreamTrack. r?jib

https://reviewboard.mozilla.org/r/23779/#review21447
Comment on attachment 8681208 [details]
MozReview Request: Bug 1208371 - Move track.stop() helpers to MediaStreamPlayback. r?jib

https://reviewboard.mozilla.org/r/23783/#review21449

::: dom/media/tests/mochitest/mediaStreamPlayback.js:26
(Diff revision 1)
> -MediaStreamPlayback.prototype = {
> +MediaStreamPlayback.prototype = Object.create(MediaStreamPlayback.prototype, {

Is this creating itself? Seems bad.

Did you copy an inheritance pattern by mistake?
Attachment #8681208 - Flags: review?(jib)
Comment on attachment 8681209 [details]
MozReview Request: Bug 1208371 - Test DOMMediaStream::Clone(). r?jib

https://reviewboard.mozilla.org/r/23785/#review21451

::: dom/media/tests/mochitest/test_getUserMedia_mediaStreamClone.html:33
(Diff revision 1)
> +      is(clone.getAudioTracks().length, stream.getAudioTracks().length,
> +         "All audio tracks should get cloned");
> +      is(clone.getVideoTracks().length, stream.getVideoTracks().length,
> +         "All video tracks should get cloned");
> +      stream.getTracks().forEach(t => ok(!clone.getTracks().includes(t),
> +                                         "The clone should contain an original track"));
> +      checkTrackCloneAgainstOriginal(clone.getAudioTracks()[0], stream.getAudioTracks()[0]);
> +      checkTrackCloneAgainstOriginal(clone.getVideoTracks()[0], stream.getVideoTracks()[0]);
> +
> +      isnot(clone.id.length, 0, "Stream clone should have an id string");
> +      isnot(clone.getAudioTracks()[0].id.length, 0,
> +            "Audio track clone should have an id string");
> +      isnot(clone.getVideoTracks()[0].id.length, 0,
> +            "Audio track clone should have an id string");

Would love to see a checkStreamCloneAgainstOriginal function for symmetry (I also see one new use for it below).

::: dom/media/tests/mochitest/test_getUserMedia_mediaStreamClone.html:91
(Diff revision 1)
> +      var inceptionClone = stream.clone().clone().clone().clone().clone()
> +                                 .clone().clone().clone().clone().clone();

maybe checkStreamCloneAgainstOriginal(inceptionClone, stream); here?

::: dom/media/tests/mochitest/test_getUserMedia_mediaStreamClone.html:107
(Diff revision 1)
> +      var LOOPS = 3;

const?
Attachment #8681209 - Flags: review?(jib) → review+
https://reviewboard.mozilla.org/r/22601/#review21389

> A lot of owning going on here.

I removed the mOwningStream since tracks also have GetOwnedStream() at this point. A little less owning.
Comment on attachment 8676164 [details]
MozReview Request: Bug 1208371 - Un-nest MediaEngineSource::PhotoCallback. r?roc

https://reviewboard.mozilla.org/r/22579/#review21475
Attachment #8676164 - Flags: review?(roc) → review+
https://reviewboard.mozilla.org/r/22611/#review21393

> These changes are great! I'd love to push this change deeper, into the same function in PeerConnectionMedia and SourceStreamInfo, as there's a chance we'd reach the bottom and get rid of the id here entirely (but it doesn't need to be in this bug).
> 
> The distinction of a "numericTrackId" wont be missed. :)
> 
> [1] http://mxr.mozilla.org/mozilla-central/source/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp?rev=e8c7dfe727cd#760

I followed your suggestion but didn't go all the way to completely get rid of it.

I'll also just note that we still need some TrackIDs, e.g., to assign to received tracks.
https://reviewboard.mozilla.org/r/23771/#review21397

> Now that this is cleaner, it seems obvious that this is just:
> 
>     if (mStopped || (!audioDevice && !videoDevice))
> 
> (if we move the if below the RefPtrs)

Done.
https://reviewboard.mozilla.org/r/23775/#review21443

> What if we're cloning a clone?
> 
> Do all of these still make sense?
> 
> mOriginalTrack will in this case not point to an original track but to another clone.

Nice catch!

I can only see the mOriginalTrack assignment being wrong here; it should be aOriginalTrack.mOriginalTrack if there's one, or aOriginalTrack otherwise. I fixed this and did some renaming to avoid confusion here.

> nit: The getter var exposition just confused me ("is it an out arg?") I would just use nullptr in the arg here, with comment.

Done.

> Wont this crash if I clone another clone?

No, all tracks are owned by a DOMMediaStream.
Comment on attachment 8676168 [details]
MozReview Request: Bug 1208371 - Add a MediaStreamTrackSource interface. r?roc

https://reviewboard.mozilla.org/r/22583/#review21587

::: dom/media/MediaStreamTrack.h:26
(Diff revision 2)
> + * Common interface for all MediaStreamTrack producers.

A little more detail here would help. E.g. main-thread-only, who owns it, etc.

::: dom/media/MediaStreamTrack.h:39
(Diff revision 2)
> +   */

Please finish these comments!
Comment on attachment 8676174 [details]
MozReview Request: Bug 1208371 - Add convenience method for checking if TrackID is explicit. r?roc

https://reviewboard.mozilla.org/r/22595/#review21593
Attachment #8676174 - Flags: review?(roc) → review+
Comment on attachment 8676175 [details]
MozReview Request: Bug 1208371 - Allow MediaInputPorts mapped to a destination TrackID. r?roc

https://reviewboard.mozilla.org/r/22597/#review21597

Glad we were able to come up with a reasonably simple solution here!

::: dom/media/MediaStreamGraph.h:940
(Diff revision 2)
> + * know that this TrackID in the destination stream is available. We assert

"When we do this, we must know"
Attachment #8676175 - Flags: review?(roc) → review+
Comment on attachment 8676176 [details]
MozReview Request: Bug 1208371 - Remove obsolete SetTrackEnabled() from DOMMediaStream r?roc

https://reviewboard.mozilla.org/r/22599/#review21601
Comment on attachment 8676178 [details]
MozReview Request: Bug 1208371 - Add DOMMediaStream::GetTrackById/GetOwnedTrackById. r?jib

https://reviewboard.mozilla.org/r/22603/#review21603

Glad to see us moving in this direction.

::: dom/media/MediaStreamTrack.h:188
(Diff revision 2)
> +   * XXX

What did you intend to write here?

::: dom/media/MediaStreamTrack.h:193
(Diff revision 2)
> +    virtual void PrincipalChanged(MediaStreamTrack* aTrack) = 0;

If you intend to follow the same ownership regime as DOMMediaStream::PrincipalChangeObserver, please comment here what that regime is. (Yes, I know it's not documented in DOMMediaStream::PrincipalChangeObserver, but it should be!)

Namely, the invariant is that a PrincipalChangeObserver must be removed from the stream by whoever added it before the observer object dies.

::: dom/media/MediaStreamTrack.h:212
(Diff revision 2)
> +  class PrincipalChangeObserverForwarder :

Explain what this class does

l
Attachment #8676178 - Flags: review?(roc)
Comment on attachment 8676179 [details]
MozReview Request: Bug 1208371 - Move ImageCapture to a MediaStreamTrackListener. r?roc

https://reviewboard.mozilla.org/r/22605/#review21605

::: dom/media/MediaStreamTrack.h:201
(Diff revision 2)
> +   * XXX

Please fix this comment

::: dom/media/MediaStreamTrack.h:203
(Diff revision 2)
> +  class MSGListener

Can we call this MSGTrackListener to make it a little more clear?
Comment on attachment 8676181 [details]
MozReview Request: Bug 1208371 - Fix DOMMediaStream::OwnsTrack. r?roc

https://reviewboard.mozilla.org/r/22609/#review21609
Attachment #8676181 - Flags: review?(roc) → review+
Comment on attachment 8681203 [details]
MozReview Request: Bug 1208371 - Make it possible to block tracks in a MediaInputPort initally. r?roc

https://reviewboard.mozilla.org/r/23773/#review21611
Attachment #8681203 - Flags: review?(roc) → review+
Comment on attachment 8681204 [details]
MozReview Request: Bug 1208371 - Implement MediaStreamTrack::Clone(). r?smaug,jib,roc

https://reviewboard.mozilla.org/r/23775/#review21613

::: dom/media/DOMMediaStream.cpp:829
(Diff revision 1)
> +  }

It would be cleaner to give MediaStreamTrack a CloneInternal() method.
Attachment #8681204 - Flags: review?(roc) → review+
Comment on attachment 8681205 [details]
MozReview Request: Bug 1208371 - Implement DOMMediaStream::Clone() r?smaug,jib,roc

https://reviewboard.mozilla.org/r/23777/#review21615
Attachment #8681205 - Flags: review?(roc) → review+
Comment on attachment 8681207 [details]
MozReview Request: Bug 1208371 - Forward input stream and track id on regular track changes for union streams. r?roc

https://reviewboard.mozilla.org/r/23781/#review21617
Attachment #8681207 - Flags: review?(roc) → review+
https://reviewboard.mozilla.org/r/23777/#review21445

Yeah but then we have some extra things to deal with, like connecting streams with input ports so that the data in the tracks we just cloned flows to the right place.

See comment 50 for the WeakPtr.
https://reviewboard.mozilla.org/r/23783/#review21449

> Is this creating itself? Seems bad.
> 
> Did you copy an inheritance pattern by mistake?

Hmm, I probably copied it from LocalMediaStreamPlayback. I'll just restore the old prototype and skip the getters altogether.
https://reviewboard.mozilla.org/r/23785/#review21451

> Would love to see a checkStreamCloneAgainstOriginal function for symmetry (I also see one new use for it below).

Good idea.

> maybe checkStreamCloneAgainstOriginal(inceptionClone, stream); here?

I also put it in the first, basic clone(), test.
https://reviewboard.mozilla.org/r/23777/#review21445

Thanks for the link to comment 50. Are you saying the WeakPtrs serve no technical purpose here other than to demote use-after-free refs to nullptr crashes ? Unsure how I feel about that.

On the "extra things do deal with", don't we already have to deal with those when users do:

    var clone = new MediaStream(stream);

? If so, then I see no reason to maintain a redundant codepath. Seems like premature optimization.
Comment on attachment 8676182 [details]
MozReview Request: Bug 1208371 - Remove MediaStreamTrack::GetStream. r?jib

https://reviewboard.mozilla.org/r/22611/#review21793
Attachment #8676182 - Flags: review+
https://reviewboard.mozilla.org/r/22601/#review20525

> We already have CreateOwnDOMTrack and with that in mind I think CreateClonedDOMTrack makes more sense.

Still hopin' for CloneDOMTrack.
(In reply to Jan-Ivar Bruaroey [:jib] from comment #144)
> https://reviewboard.mozilla.org/r/23777/#review21445
> 
> Thanks for the link to comment 50. Are you saying the WeakPtrs serve no
> technical purpose here other than to demote use-after-free refs to nullptr
> crashes ? Unsure how I feel about that.

No, it's demoting use-after-free refs to "Ah it's been destructed, let's return early" -- in the case where we have a TrackSourceGetter on a clone referring back to the original. The clone is indirectly keeping the original alive but since it's non-obvious the WeakPtr provides extra safety. There is no ref from the original to the getter so we can't tell it to Forget() its mStream pointer like we do for the MediaStreamListeners.

For the listeners (OwnedStreamListener and PlaybackStreamListener) I wanted to use the WeakPtr as well but that didn't work because of garbage collection doing actual object destruction asynchronously, i.e., it'd call DOMMediaStream::Destroy() first, then dispatch a task to remove the last (GC-held) refs to the DOMMediaStream objects. In between this, the MSG would have a runnable run on the main thread which would call into the live DOMMediaStream (by WeakPtr), triggering asserts due to certain members being null (like mOwnedStream which should always exist).


> On the "extra things do deal with", don't we already have to deal with those
> when users do:
> 
>     var clone = new MediaStream(stream);

Hmm, how?

This is also not a clone, the new stream just adds all the tracks from the one passed in to its constructor. The tracks keep the original alive by strong refs.
https://reviewboard.mozilla.org/r/22583/#review21587

> A little more detail here would help. E.g. main-thread-only, who owns it, etc.

Done. Sorry for missing this when pushing the latest revision.
(In reply to Andreas Pehrson [:pehrsons] (Telenor) from comment #147)
> The clone is indirectly keeping the original alive

Why not use a strong pointer then, and let the cycle-collector break it?

> This is also not a clone, the new stream just adds all the tracks from the
> one passed in to its constructor. The tracks keep the original alive by
> strong refs.

That's what we want I think. Are you working off some other definition of 'clone' than http://w3c.github.io/mediacapture-main/getusermedia.html#widl-MediaStream-clone-MediaStream ?
Sorry, I meant:

    var clone = new MediaStream(stream.getTracks().map(track => track.clone());
https://reviewboard.mozilla.org/r/22603/#review21603

> What did you intend to write here?

It is now:

```
Get this track's principal.

This is currently the same principal as for the track's owning
DOMMediaStream.
```
https://reviewboard.mozilla.org/r/22603/#review21603

> If you intend to follow the same ownership regime as DOMMediaStream::PrincipalChangeObserver, please comment here what that regime is. (Yes, I know it's not documented in DOMMediaStream::PrincipalChangeObserver, but it should be!)
> 
> Namely, the invariant is that a PrincipalChangeObserver must be removed from the stream by whoever added it before the observer object dies.

Comments added. I also threw in the same comments for DOMMediaStream::Add/RemovePrincipalChangeObserver.
(In reply to Jan-Ivar Bruaroey [:jib] from comment #149)
> (In reply to Andreas Pehrson [:pehrsons] (Telenor) from comment #147)
> > The clone is indirectly keeping the original alive
> 
> Why not use a strong pointer then, and let the cycle-collector break it?

I couldn't get a native cycle collected inherited class working. :/


> Are you working off some other definition of
> 'clone' than
> http://w3c.github.io/mediacapture-main/getusermedia.html#widl-MediaStream-
> clone-MediaStream ?

No. It feels like we're going in circles around each other here.. I'd like to understand what you mean in comment 144 by "don't we already have to deal with those". Which, specifically?
Flags: needinfo?(jib)
https://reviewboard.mozilla.org/r/23775/#review21613

> It would be cleaner to give MediaStreamTrack a CloneInternal() method.

Done!
https://reviewboard.mozilla.org/r/22591/#review20425

> Hmm, not ProcessedMSGMediaStream, TrackUnionMSGStream and SourceMSGStream? Bike-shedding time!
> 
> Did anyone like MediaStreamNode? i.e. the "nodes in a graph" in a MediaStreamGraph? I think the root of the confusion is that both concepts are "streams" colloquially, and this would address that (if unfairly since they came first). It would also highlight that the implementation objects are in fact nodes in a graph, and maybe also that a single "stream" of data can run through more than one of these objects. It's also easier to compose on:
> 
> MediaStreamNode
> ProcessedMediaStreamNode
> TrackUnionStreamNode
> SourceStreamNode
> 
> Thoughts?

I'll create a new bug for the renaming.
See Also: → 1221890
Comment on attachment 8676157 [details]
MozReview Request: Bug 1208371 - Pass parent window to DOMMediaStream through constructor. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22567/diff/2-3/
Comment on attachment 8676159 [details]
MozReview Request: Bug 1208371 - Make AudioCaptureStream startable. r?padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22569/diff/2-3/
Comment on attachment 8676160 [details]
MozReview Request: Bug 1208371 - Move OnTracksAvailableCallback out of DOMMediaStream. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22571/diff/2-3/
Comment on attachment 8676161 [details]
MozReview Request: Bug 1208371 - Remove unused MediaManager::NotifyMediaStreamTrackEnded. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22573/diff/2-3/
Comment on attachment 8676162 [details]
MozReview Request: Bug 1208371 - Introduce MediaStreamTrack logs. r?roc,jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22575/diff/2-3/
Attachment #8676162 - Attachment description: MozReview Request: Bug 1208371 - Introduce MediaStreamTrack logs. r?roc → MozReview Request: Bug 1208371 - Introduce MediaStreamTrack logs. r?roc,jib
Attachment #8676162 - Flags: review?(roc)
Comment on attachment 8676163 [details]
MozReview Request: Bug 1208371 - Track original track in MediaStreamTrack clones. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22577/diff/2-3/
Comment on attachment 8676164 [details]
MozReview Request: Bug 1208371 - Un-nest MediaEngineSource::PhotoCallback. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22579/diff/2-3/
Comment on attachment 8676165 [details]
MozReview Request: Bug 1208371 - Add MediaStreamTrack::Graph(). r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22581/diff/2-3/
Attachment #8676168 - Flags: review?(roc)
Comment on attachment 8676168 [details]
MozReview Request: Bug 1208371 - Add a MediaStreamTrackSource interface. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22583/diff/2-3/
Comment on attachment 8676169 [details]
MozReview Request: Bug 1208371 - Add MediaStreamTrackSourceGetter interface. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22585/diff/2-3/
Comment on attachment 8676170 [details]
MozReview Request: Bug 1208371 - Let MediaStreamTracks know their TrackID at the source. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22587/diff/2-3/
Comment on attachment 8676171 [details]
MozReview Request: Bug 1208371 - Let FindOwnedDOMTrack operate on input stream. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22589/diff/2-3/
Comment on attachment 8676172 [details]
MozReview Request: Bug 1208371 - Add some MediaStreamTrack helper methods. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22591/diff/2-3/
Attachment #8676172 - Flags: review?(roc)
Comment on attachment 8676173 [details]
MozReview Request: Bug 1208371 - Count the users of a MediaStream to ease Destroy() responsibility. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22593/diff/2-3/
Comment on attachment 8676174 [details]
MozReview Request: Bug 1208371 - Add convenience method for checking if TrackID is explicit. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22595/diff/2-3/
Comment on attachment 8676175 [details]
MozReview Request: Bug 1208371 - Allow MediaInputPorts mapped to a destination TrackID. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22597/diff/2-3/
Comment on attachment 8676176 [details]
MozReview Request: Bug 1208371 - Remove obsolete SetTrackEnabled() from DOMMediaStream r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22599/diff/2-3/
Comment on attachment 8676177 [details]
MozReview Request: Bug 1208371 - Let DOMMediaStream base its principal on the tracks it contains. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22601/diff/2-3/
Attachment #8676178 - Flags: review?(roc)
Comment on attachment 8676178 [details]
MozReview Request: Bug 1208371 - Add DOMMediaStream::GetTrackById/GetOwnedTrackById. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22603/diff/2-3/
Attachment #8676179 - Attachment description: MozReview Request: Bug 1208371 - Add an MSGListener interface to MediaStreamTrack. r?roc → MozReview Request: Bug 1208371 - Add an MSGTrackListener interface to MediaStreamTrack. r?roc
Attachment #8676179 - Flags: review?(roc)
Comment on attachment 8676179 [details]
MozReview Request: Bug 1208371 - Move ImageCapture to a MediaStreamTrackListener. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22605/diff/2-3/
Comment on attachment 8676157 [details]
MozReview Request: Bug 1208371 - Pass parent window to DOMMediaStream through constructor. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22567/diff/2-3/
Comment on attachment 8676180 [details]
MozReview Request: Bug 1208371 - Make it possible to look up stream id by track in PeerConnectionImpl. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22607/diff/2-3/
Comment on attachment 8676181 [details]
MozReview Request: Bug 1208371 - Fix DOMMediaStream::OwnsTrack. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22609/diff/2-3/
Comment on attachment 8676182 [details]
MozReview Request: Bug 1208371 - Remove MediaStreamTrack::GetStream. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22611/diff/2-3/
Comment on attachment 8681202 [details]
MozReview Request: Bug 1208371 - Route ApplyConstraints through MediaStreamTrackSource. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23771/diff/1-2/
Comment on attachment 8681203 [details]
MozReview Request: Bug 1208371 - Make it possible to block tracks in a MediaInputPort initally. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23773/diff/1-2/
Comment on attachment 8681204 [details]
MozReview Request: Bug 1208371 - Implement MediaStreamTrack::Clone(). r?smaug,jib,roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23775/diff/1-2/
Attachment #8681204 - Flags: review+ → review?(jib)
Attachment #8681205 - Attachment description: MozReview Request: Bug 1208371 - Implement MediaStream.clone() r?smaug,jib,roc → MozReview Request: Bug 1208371 - Implement DOMMediaStream::Clone() r?smaug,jib,roc
Attachment #8681205 - Flags: review+ → review?(jib)
Comment on attachment 8681205 [details]
MozReview Request: Bug 1208371 - Implement DOMMediaStream::Clone() r?smaug,jib,roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23777/diff/1-2/
Comment on attachment 8681206 [details]
MozReview Request: Bug 1208371 - Various cleanups in DOMMediaStream/MediaStreamTrack. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23779/diff/1-2/
Comment on attachment 8681207 [details]
MozReview Request: Bug 1208371 - Forward input stream and track id on regular track changes for union streams. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23781/diff/1-2/
Attachment #8681208 - Attachment description: MozReview Request: Bug 1208371 - Move track.stop() helpers to MediaStreamPlayback and wrap methods in getters. r?jib → MozReview Request: Bug 1208371 - Move track.stop() helpers to MediaStreamPlayback. r?jib
Attachment #8681208 - Flags: review?(jib)
Comment on attachment 8681208 [details]
MozReview Request: Bug 1208371 - Move track.stop() helpers to MediaStreamPlayback. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23783/diff/1-2/
Comment on attachment 8681209 [details]
MozReview Request: Bug 1208371 - Test DOMMediaStream::Clone(). r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23785/diff/1-2/
Bug 1208371 - Rename CreateOwnDOMTrack/CreateClonedDOMTrack to CreateDOMTrack/CloneDOMTrack. r?jib
Attachment #8683551 - Flags: review?(jib)
(In reply to Andreas Pehrson [:pehrsons] (Telenor) from comment #153)
> (In reply to Jan-Ivar Bruaroey [:jib] from comment #149)
> > Are you working off some other definition of 'clone' than
> > http://w3c.github.io/mediacapture-main/getusermedia.html#widl-MediaStream-clone-MediaStream ?
> 
> No. It feels like we're going in circles around each other here.. I'd like
> to understand what you mean in comment 144 by "don't we already have to deal
> with those". Which, specifically?

It is needed for what I mentioned in comment 150:

    var clone = new MediaStream(stream.getTracks().map(track => track.clone());

This already works, is a shoe-in for clone, and the spec says we MUST implement clone this way.

clone

    Clones the given MediaStream and all its tracks.

    When the MediaStream.clone() method is invoked, the User Agent MUST run the following steps:

        Let streamClone be a newly constructed MediaStream object.

        Initialize streamClone's id attribute to a newly generated value.

        Clone each track in this MediaStream object and add the result to streamClone's track set.

In https://reviewboard.mozilla.org/r/23777/#review21445 you seem to be saying there are arguments for deviating from the spec here, but I don't understand what they are, since comment 150 already works. Fewer code-paths is good.
Flags: needinfo?(jib)
https://reviewboard.mozilla.org/r/23777/#review21445

> var clone = new MediaStream(stream);

This was a typo mistake on my part. Here I meant:

    var clone = new MediaStream(stream.getTracks().map(track => track.clone());
Comment on attachment 8681208 [details]
MozReview Request: Bug 1208371 - Move track.stop() helpers to MediaStreamPlayback. r?jib

https://reviewboard.mozilla.org/r/23783/#review21933
Attachment #8681208 - Flags: review?(jib) → review+
Comment on attachment 8681205 [details]
MozReview Request: Bug 1208371 - Implement DOMMediaStream::Clone() r?smaug,jib,roc

https://reviewboard.mozilla.org/r/23777/#review21937

::: dom/media/DOMMediaStream.cpp:576
(Diff revision 2)
> +already_AddRefed<DOMMediaStream>
> +DOMMediaStream::Clone()
> +{
> +  class ClonedStreamSourceGetter : public MediaStreamTrackSourceGetter
> +  {
> +  public:
> +    ClonedStreamSourceGetter(DOMMediaStream* aStream)
> +      : mStream(aStream) {}

(Repeating issue for mozReview's benefit, since top descriptions apparently don't count as issues.)

According to spec [1] clone MUST be implemented as:

    Let streamClone be a newly constructed MediaStream object.

    Initialize streamClone's id attribute to a newly generated value.

    Clone each track in this MediaStream object and add the result to streamClone's track set.

So this seems implementable entirely using existing code, i.e. the c++ that covers:

    var clone = new MediaStream(stream.getTracks().map(track => track.clone());

[1] http://w3c.github.io/mediacapture-main/getusermedia.html#widl-MediaStream-clone-MediaStream

::: dom/media/DOMMediaStream.cpp:724
(Diff revision 2)
> +  mOwnedStream->RegisterUser();

Is the register/unregister thing needed if we do it the spec way?
Attachment #8681205 - Flags: review?(jib)
Comment on attachment 8683551 [details]
MozReview Request: Bug 1208371 - Rename CreateOwnDOMTrack/CreateClonedDOMTrack to CreateDOMTrack/CloneDOMTrack. r?jib

https://reviewboard.mozilla.org/r/24365/#review21939
Attachment #8683551 - Flags: review?(jib) → review+
Comment on attachment 8676178 [details]
MozReview Request: Bug 1208371 - Add DOMMediaStream::GetTrackById/GetOwnedTrackById. r?jib

https://reviewboard.mozilla.org/r/22603/#review21975
https://reviewboard.mozilla.org/r/23777/#review21937

> (Repeating issue for mozReview's benefit, since top descriptions apparently don't count as issues.)
> 
> According to spec [1] clone MUST be implemented as:
> 
>     Let streamClone be a newly constructed MediaStream object.
> 
>     Initialize streamClone's id attribute to a newly generated value.
> 
>     Clone each track in this MediaStream object and add the result to streamClone's track set.
> 
> So this seems implementable entirely using existing code, i.e. the c++ that covers:
> 
>     var clone = new MediaStream(stream.getTracks().map(track => track.clone());
> 
> [1] http://w3c.github.io/mediacapture-main/getusermedia.html#widl-MediaStream-clone-MediaStream

Right, I see what you mean now. Good that you brought this up.

The thing we are doing differently here is also setting up a generic MediaInputPort between the original and the clone if the original has an input stream, to ensure that dynamically added tracks show up in both.

Nothing in mediacapture-main gets tracks dynamically added by the user agent. There are "addtrack" and "removetrack" events for a MediaStream, but clone() seems to  have been overseen in this regard. At least I see value in having dynamically added tracks appear in the clones as well, see more below.

PeerConnections can do it, but are regulated in another spec, [2].

Our main use case for this is HTMLMediaElement::CaptureStream where one gets a stream that sees its entire track set swapped out when the media element changes source. See mediacapture-fromelement at [3].

There's some backstory here, though not too much, see bug 1170958 comment 57, bug 1170958 comment 114, and bug 1170958 comment 117.

I think we should decide whether to set up a generic input port when cloning streams and if needed bring this to the spec.

I vote for setting it up, but I guess jib and mt are the main peers for the spec here so what do you think we should do?

I'll also note that there's no real value to stream cloning without this, since one can do the same thing in JS with a MediaStream constructor and track cloning, per jib's example above.


[2] http://w3c.github.io/webrtc-pc/
[3] https://w3c.github.io/mediacapture-fromelement/index.html

> Is the register/unregister thing needed if we do it the spec way?

Yeah, DOMMediaStream::mInputStream is still shared across track clones.
Flags: needinfo?(martin.thomson)
Flags: needinfo?(jib)
Also, some security considerations.

(Bug 942367) Martin, how should we handle DOMMediaStream::mPeerIdentity on stream.clone()? addTrack/removeTrack?

(Bug 937718) Paul, how should we handle DOMMediaStream::mCORSMode on stream.clone()? addTrack/removeTrack?
Flags: needinfo?(padenot)
Blocks: 1083354
There's apparently some magic in `GetParentObject()` that I couldn't find docs for. Restoring it for MediaStreamTrack to return the owning window solved most of these: https://treeherder.mozilla.org/#/jobs?repo=try&revision=e73778cb5a31
(In reply to Andreas Pehrson [:pehrsons] (Telenor) from comment #201)
> Also, some security considerations.
> 
> (Bug 942367) Martin, how should we handle DOMMediaStream::mPeerIdentity on
> stream.clone()? addTrack/removeTrack?
> 
> (Bug 937718) Paul, how should we handle DOMMediaStream::mCORSMode on
> stream.clone()? addTrack/removeTrack?

I'm usually asking Martin himself when touching CORS things, so I guess he can answer both questions here.
Flags: needinfo?(padenot)
https://reviewboard.mozilla.org/r/23777/#review21937

> Right, I see what you mean now. Good that you brought this up.
> 
> The thing we are doing differently here is also setting up a generic MediaInputPort between the original and the clone if the original has an input stream, to ensure that dynamically added tracks show up in both.
> 
> Nothing in mediacapture-main gets tracks dynamically added by the user agent. There are "addtrack" and "removetrack" events for a MediaStream, but clone() seems to  have been overseen in this regard. At least I see value in having dynamically added tracks appear in the clones as well, see more below.
> 
> PeerConnections can do it, but are regulated in another spec, [2].
> 
> Our main use case for this is HTMLMediaElement::CaptureStream where one gets a stream that sees its entire track set swapped out when the media element changes source. See mediacapture-fromelement at [3].
> 
> There's some backstory here, though not too much, see bug 1170958 comment 57, bug 1170958 comment 114, and bug 1170958 comment 117.
> 
> I think we should decide whether to set up a generic input port when cloning streams and if needed bring this to the spec.
> 
> I vote for setting it up, but I guess jib and mt are the main peers for the spec here so what do you think we should do?
> 
> I'll also note that there's no real value to stream cloning without this, since one can do the same thing in JS with a MediaStream constructor and track cloning, per jib's example above.
> 
> 
> [2] http://w3c.github.io/webrtc-pc/
> [3] https://w3c.github.io/mediacapture-fromelement/index.html

Thanks, I hadn't considered that. Essentially: "do addtrack and removetrack events fire on cloned streams?"

Good question. Starting with removetrack was helpful for me:

The spec allows UAs to pull tracks at will [1], so when a PeerConnection renegotiates away a media source, or an audio element with capture disables an audio source, removetrack clearly MUST be fired on all streams (originals and clones) that used to contain a track (original or clone!) from that source.

But addtrack is tied to the stream, so here it seems we have a choice. I no longer think it's a mediacapture spec issue, since [1] seems to allow UAs to add tracks anywhere to any stream at any time.

Our options seem to be:

1. addtrack only fires on originals. People must re-acquire host stream, or re-clone original
   to get updates. Maybe remove .clone() on MediaStream to avoid confusion.

   pros: Simple. Why clone if things keep behaving like the original?
   cons: Awkward to deal with .captureStream and remote streams?

2. addtrack fires on clones as well. Watch out for surprise tracks popping up, and wonder
   if stream.clone() and new MediaStream(stream) do the same thing.

   pros: Symmetry, powerful
   cons: Two kinds of clones, pc.addStream(stream) still wont get future tracks.

Lets say it's (1). What problems would that cause? What good use-cases does it hamper or break? Listing those may help.

I understand that with (2) we get it both ways, with new MediaStream(stream.getTracks()) being the opt-out, but at a complexity cost.

My main concern is: what's most predictable?

[1] http://w3c.github.io/mediacapture-main/getusermedia.html#mediastreamtrackevent
Flags: needinfo?(jib)
Comment on attachment 8681205 [details]
MozReview Request: Bug 1208371 - Implement DOMMediaStream::Clone() r?smaug,jib,roc

https://reviewboard.mozilla.org/r/23777/#review22035

I think we should still resolve comment 204, but if we file a follow-up bug for that, and if Martin agrees, then I'm OK with landing this.
Attachment #8681205 - Flags: review+
Attachment #8681204 - Flags: review?(jib) → review+
Comment on attachment 8681204 [details]
MozReview Request: Bug 1208371 - Implement MediaStreamTrack::Clone(). r?smaug,jib,roc

https://reviewboard.mozilla.org/r/23775/#review22037
(In reply to Paul Adenot (:padenot) from comment #203)
> (In reply to Andreas Pehrson [:pehrsons] (Telenor) from comment #201)
> > Also, some security considerations.
> > 
> > (Bug 942367) Martin, how should we handle DOMMediaStream::mPeerIdentity on
> > stream.clone()? addTrack/removeTrack?
> > 
> > (Bug 937718) Paul, how should we handle DOMMediaStream::mCORSMode on
> > stream.clone()? addTrack/removeTrack?
> 
> I'm usually asking Martin himself when touching CORS things, so I guess he
> can answer both questions here.

The best option would be to move these properties to the tracks.  They are properly track properties.
Flags: needinfo?(martin.thomson)
Martin, please also see comment 200.
Flags: needinfo?(martin.thomson)
Hmm, I don't think that you need to concern yourself with propagating add/remove on cloned streams.  The best option (to my mind) would be to clone with the current state of the stream.  That's going to be the least surprising option in many cases.  For other cases, applications can perform their own propagation of added and removed tracks.
Flags: needinfo?(martin.thomson)
There are some issues with that approach that I'd like to highlight and want to hear your comments on Martin. Also ni-ing jib in case he has any new thoughts.

If applications perform their own propagation there's a risk that data goes missing because events are async. I.e., there's a gap from when a track first appears in a stream until that track is exposed to JS.

This is not so much of a problem for realtime streams (gUM) but if you're capturing a media element you may get a noticable part missing in the very start after changing sources.

I'd also like to argue that if a clone propagates UA-added/removed tracks they're easy to avoid should one want it (`new MediaStream(stream.getTracks().forEach(t => t.clone))`).

Likewise if we don't propagate to a clone, stream cloning could just be done like the snippet above. If we stay on this route I think the api for stream cloning should be removed from the spec to keep it simple since it doesn't add any value.

Like jib said in comment 204 these are our two options, and I believe the missed data I mentioned above is the main downside to doing js-side propagation. Regarding predictability I think both cases make sense and I don't think surprises is that much of a concern if the behavior is just explained in docs. All developers read docs, right?
Flags: needinfo?(martin.thomson)
Flags: needinfo?(jib)
(In reply to Andreas Pehrson [:pehrsons] (Telenor) from comment #210)
> if you're capturing a media element you may get a noticable part missing
> in the very start after changing sources.

Doesn't this presume a sink that automatically picks up on new tracks in a stream (otherwise a visit to JS seems inevitable)? What's an example of this? PeerConnection is track-based now, so it doesn't seem to qualify.

Also, in these cases, what use-case is not covered by using the original stream?

> I'd also like to argue that if a clone propagates UA-added/removed tracks
> they're easy to avoid should one want it (`new
> MediaStream(stream.getTracks().forEach(t => t.clone))`).

Sure, though that's not an argument for keeping it.

> Likewise if we don't propagate to a clone, stream cloning could just be done
> like the snippet above. If we stay on this route I think the api for stream
> cloning should be removed from the spec to keep it simple since it doesn't
> add any value.

It's hard to argue that stream.clone() is in the spec for any reason other than convenience, given that it's defined as a redundancy.

That said, I think removing stream.clone() is an opportunity to reduce confusion if hosts are going to be removing tracks from clones yet never replenish them with new ones.
Flags: needinfo?(jib)
I think that we should take this discussion to the media capture list.  I can see now why the model Andreas suggests has some value, but if we don't have clarity in the spec, I don't see any value in doing the extra work.

Is it possible to include that part of this work in a follow-up bug?  Then we can track that extra piece independently.
Flags: needinfo?(martin.thomson)
Great to raise the issue, but I don't think, as I mentioned in comment 204, that we're blocked on that spec here, since from my reading [1] seems to allow UAs to add tracks anywhere to any stream at any time.

The way I read it, another spec can add tracks even to clones from e.g. new MediaStream(stream) if it wants, i.e. how a clone is created might not be significant.

In other words, I'm not sure the language on stream.clone() precludes hosts from adding tracks to clones (but I could be wrong). 

[1] http://w3c.github.io/mediacapture-main/getusermedia.html#mediastreamtrackevent
(In reply to Jan-Ivar Bruaroey [:jib] from comment #214)
> Great to raise the issue, but I don't think, as I mentioned in comment 204,
> that we're blocked on that spec here, since from my reading [1] seems to
> allow UAs to add tracks anywhere to any stream at any time.

I don't think that having one browser propagate track changes to clones and another not doing so is a recipe for interoperability.  We should decide, collectively, what the best option is and do that.  Right now, the status quo is to not propagate changes, though I will acknowledge the uncertainty that the text you cite implies.
Agree, I'm saying this might be specified in the specs that introduce host-managed tracks, rather than in the mediastream spec which has none.
Thanks for bringing it to the spec guys.

While moving the principal stuff I ran into an issue that I'd like some advice on how best to resolve. Martin, perhaps?

I now have patches that move nsPrincipal, PeerIdentity and CORSMode from DOMMediaStream to MediaStreamTrack. DOMMediaStream still has a principal because of APIs that consumes it - it is essentially a combination of all its current tracks and their principal changes from the point the stream started to be consumed.

Now WebRTC had special access to updating the principal on a stream, not by combining but by replacing it. With that moved to the track the track gets the new principal and signals it to the stream, which combines it with its old one, still having the stream content inaccessible to script.

I could fix this by always having the streams principal be the combination of all of its tracks' one. But then what would happen if we remove the only video track (with system principal) from a stream played in a media element? We'd make its last rendered frame accessible to anyone (given that the remaining audio tracks are).

We had a similar bug for the same reason where the MediaRecorder would throw a security error because the stream's contents were inaccessible. Any thoughts on how to solve this?

I see an ideal world where this info is passed along with the actual audio/video data. That would simplify a lot. But its a major change and principals with all their nsCOMPtrs and stuff look scary to pass to and use on the MSG thread, etc.
Flags: needinfo?(martin.thomson)
I think that - where possible - we should be relying on track principals for access checks.  Obviously there are a number of places where we can't do that, but I would rather fail than create a situation where the last video frame is leaked.  What you describe (a cumulative combining at DOMMediaStream) will fail more than is ideal, but that is not necessarily bad.

That means that you should take at least a cursory look at the sites where the DOMMediaStream principal is checked to see if it can (or should) be changed to check the tracks instead.  For instance, rendering a video tag to canvas could be trivially simplified; MediaRecorder can also trivially look at tracks.

Note, I don't think that this needs to be moved to the MSG thread, but some care will need to be taken at the point where changes are made.
Flags: needinfo?(martin.thomson)
(In reply to Martin Thomson [:mt:] from comment #218)
> I think that - where possible - we should be relying on track principals for
> access checks.  Obviously there are a number of places where we can't do
> that, but I would rather fail than create a situation where the last video
> frame is leaked.  What you describe (a cumulative combining at
> DOMMediaStream) will fail more than is ideal, but that is not necessarily
> bad.
> 
> That means that you should take at least a cursory look at the sites where
> the DOMMediaStream principal is checked to see if it can (or should) be
> changed to check the tracks instead.  For instance, rendering a video tag to
> canvas could be trivially simplified;

Point taken, and I have an idea that I think works. I hope I have it up for review to you before the end of the week. Though to make it trivial with media elements we have to implement explicit track selection. There's an implementation of tracks behind a pref today but afaik it doesn't do anything to rendering.


> MediaRecorder can also trivially look at tracks.

This on the other hand should be trivial already today.


> Note, I don't think that this needs to be moved to the MSG thread, but some
> care will need to be taken at the point where changes are made.
backlog: --- → webrtc/webaudio+
Rank: 19
Priority: -- → P1
Comment on attachment 8676162 [details]
MozReview Request: Bug 1208371 - Introduce MediaStreamTrack logs. r?roc,jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22575/diff/3-4/
Comment on attachment 8676168 [details]
MozReview Request: Bug 1208371 - Add a MediaStreamTrackSource interface. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22583/diff/3-4/
Comment on attachment 8676169 [details]
MozReview Request: Bug 1208371 - Add MediaStreamTrackSourceGetter interface. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22585/diff/3-4/
Comment on attachment 8676170 [details]
MozReview Request: Bug 1208371 - Let MediaStreamTracks know their TrackID at the source. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22587/diff/3-4/
Comment on attachment 8676171 [details]
MozReview Request: Bug 1208371 - Let FindOwnedDOMTrack operate on input stream. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22589/diff/3-4/
Comment on attachment 8676172 [details]
MozReview Request: Bug 1208371 - Add some MediaStreamTrack helper methods. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22591/diff/3-4/
Comment on attachment 8676173 [details]
MozReview Request: Bug 1208371 - Count the users of a MediaStream to ease Destroy() responsibility. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22593/diff/3-4/
Comment on attachment 8676174 [details]
MozReview Request: Bug 1208371 - Add convenience method for checking if TrackID is explicit. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22595/diff/3-4/
Comment on attachment 8676175 [details]
MozReview Request: Bug 1208371 - Allow MediaInputPorts mapped to a destination TrackID. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22597/diff/3-4/
Comment on attachment 8676176 [details]
MozReview Request: Bug 1208371 - Remove obsolete SetTrackEnabled() from DOMMediaStream r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22599/diff/3-4/
Comment on attachment 8676165 [details]
MozReview Request: Bug 1208371 - Add MediaStreamTrack::Graph(). r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22581/diff/3-4/
Attachment #8676165 - Attachment description: MozReview Request: Bug 1208371 - Make DOMMediaStream support WeakPtrs. r?roc → MozReview Request: Bug 1208371 - Add MediaStreamTrack::Graph(). r?jib
Attachment #8676178 - Attachment description: MozReview Request: Bug 1208371 - Add a PrincipalChangeObserver interface to MediaStreamTrack. r?roc → MozReview Request: dummy
Comment on attachment 8676178 [details]
MozReview Request: Bug 1208371 - Add DOMMediaStream::GetTrackById/GetOwnedTrackById. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22603/diff/3-4/
Comment on attachment 8676177 [details]
MozReview Request: Bug 1208371 - Let DOMMediaStream base its principal on the tracks it contains. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22601/diff/3-4/
Attachment #8676177 - Attachment description: MozReview Request: Bug 1208371 - Add MediaStreamTrack::Graph(). r?jib → MozReview Request: dummy
Comment on attachment 8676179 [details]
MozReview Request: Bug 1208371 - Move ImageCapture to a MediaStreamTrackListener. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22605/diff/3-4/
Comment on attachment 8676180 [details]
MozReview Request: Bug 1208371 - Make it possible to look up stream id by track in PeerConnectionImpl. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22607/diff/3-4/
Comment on attachment 8676181 [details]
MozReview Request: Bug 1208371 - Fix DOMMediaStream::OwnsTrack. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22609/diff/3-4/
Comment on attachment 8676182 [details]
MozReview Request: Bug 1208371 - Remove MediaStreamTrack::GetStream. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22611/diff/3-4/
Comment on attachment 8681202 [details]
MozReview Request: Bug 1208371 - Route ApplyConstraints through MediaStreamTrackSource. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23771/diff/2-3/
Comment on attachment 8681203 [details]
MozReview Request: Bug 1208371 - Make it possible to block tracks in a MediaInputPort initally. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23773/diff/2-3/
Comment on attachment 8681204 [details]
MozReview Request: Bug 1208371 - Implement MediaStreamTrack::Clone(). r?smaug,jib,roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23775/diff/2-3/
Comment on attachment 8681205 [details]
MozReview Request: Bug 1208371 - Implement DOMMediaStream::Clone() r?smaug,jib,roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23777/diff/2-3/
Comment on attachment 8681206 [details]
MozReview Request: Bug 1208371 - Various cleanups in DOMMediaStream/MediaStreamTrack. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23779/diff/2-3/
Comment on attachment 8681207 [details]
MozReview Request: Bug 1208371 - Forward input stream and track id on regular track changes for union streams. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23781/diff/2-3/
Comment on attachment 8681208 [details]
MozReview Request: Bug 1208371 - Move track.stop() helpers to MediaStreamPlayback. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23783/diff/2-3/
Comment on attachment 8681209 [details]
MozReview Request: Bug 1208371 - Test DOMMediaStream::Clone(). r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23785/diff/2-3/
Comment on attachment 8683551 [details]
MozReview Request: Bug 1208371 - Rename CreateOwnDOMTrack/CreateClonedDOMTrack to CreateDOMTrack/CloneDOMTrack. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/24365/diff/1-2/
Comment on attachment 8700527 [details]
MozReview Request: Bug 1208371 - Make ImageCapture listen to principal changes of MediaStreamTrack instead. r?mt

Review commit: https://reviewboard.mozilla.org/r/28741/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/28741/
Comment on attachment 8676179 [details]
MozReview Request: Bug 1208371 - Move ImageCapture to a MediaStreamTrackListener. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22605/diff/3-4/
Comment on attachment 8681202 [details]
MozReview Request: Bug 1208371 - Route ApplyConstraints through MediaStreamTrackSource. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23771/diff/3-4/
Comment on attachment 8681207 [details]
MozReview Request: Bug 1208371 - Forward input stream and track id on regular track changes for union streams. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23781/diff/2-3/
Attachment #8700521 - Attachment is obsolete: true
Attachment #8700522 - Attachment is obsolete: true
Attachment #8700523 - Attachment is obsolete: true
Attachment #8700524 - Attachment is obsolete: true
Attachment #8700525 - Attachment is obsolete: true
Depends on: 1234162
Brace for impact.
Comment on attachment 8676157 [details]
MozReview Request: Bug 1208371 - Pass parent window to DOMMediaStream through constructor. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22567/diff/3-4/
Comment on attachment 8676159 [details]
MozReview Request: Bug 1208371 - Make AudioCaptureStream startable. r?padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22569/diff/3-4/
Comment on attachment 8676160 [details]
MozReview Request: Bug 1208371 - Move OnTracksAvailableCallback out of DOMMediaStream. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22571/diff/3-4/
Attachment #8676161 - Flags: review?(jib)
Comment on attachment 8676161 [details]
MozReview Request: Bug 1208371 - Remove unused MediaManager::NotifyMediaStreamTrackEnded. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22573/diff/3-4/
Comment on attachment 8676162 [details]
MozReview Request: Bug 1208371 - Introduce MediaStreamTrack logs. r?roc,jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22575/diff/3-4/
Comment on attachment 8676163 [details]
MozReview Request: Bug 1208371 - Track original track in MediaStreamTrack clones. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22577/diff/3-4/
Comment on attachment 8676164 [details]
MozReview Request: Bug 1208371 - Un-nest MediaEngineSource::PhotoCallback. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22579/diff/3-4/
Comment on attachment 8676168 [details]
MozReview Request: Bug 1208371 - Add a MediaStreamTrackSource interface. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22583/diff/4-5/
Comment on attachment 8676169 [details]
MozReview Request: Bug 1208371 - Add MediaStreamTrackSourceGetter interface. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22585/diff/4-5/
Comment on attachment 8676170 [details]
MozReview Request: Bug 1208371 - Let MediaStreamTracks know their TrackID at the source. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22587/diff/4-5/
Comment on attachment 8676171 [details]
MozReview Request: Bug 1208371 - Let FindOwnedDOMTrack operate on input stream. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22589/diff/4-5/
Comment on attachment 8676172 [details]
MozReview Request: Bug 1208371 - Add some MediaStreamTrack helper methods. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22591/diff/4-5/
Comment on attachment 8676173 [details]
MozReview Request: Bug 1208371 - Count the users of a MediaStream to ease Destroy() responsibility. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22593/diff/4-5/
Comment on attachment 8676174 [details]
MozReview Request: Bug 1208371 - Add convenience method for checking if TrackID is explicit. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22595/diff/4-5/
Comment on attachment 8676175 [details]
MozReview Request: Bug 1208371 - Allow MediaInputPorts mapped to a destination TrackID. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22597/diff/4-5/
Comment on attachment 8676176 [details]
MozReview Request: Bug 1208371 - Remove obsolete SetTrackEnabled() from DOMMediaStream r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22599/diff/4-5/
Attachment #8676165 - Flags: review?(jib)
Comment on attachment 8676165 [details]
MozReview Request: Bug 1208371 - Add MediaStreamTrack::Graph(). r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22581/diff/4-5/
Attachment #8676178 - Attachment description: MozReview Request: dummy → MozReview Request: Bug 1208371 - Add DOMMediaStream::GetTrackById/GetOwnedTrackById. r?jib
Attachment #8676178 - Flags: review?(jib)
Comment on attachment 8676178 [details]
MozReview Request: Bug 1208371 - Add DOMMediaStream::GetTrackById/GetOwnedTrackById. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22603/diff/4-5/
Comment on attachment 8700521 [details]
MozReview Request: Bug 1208371 - Add principal APIs to MediaStreamTrack. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28729/diff/1-2/
Attachment #8700521 - Attachment description: MozReview Request: dummy → MozReview Request: Bug 1208371 - Add principal APIs to MediaStreamTrack. r?mt
Attachment #8700521 - Attachment is obsolete: false
Attachment #8700521 - Flags: review?(martin.thomson)
Comment on attachment 8700522 [details]
MozReview Request: Bug 1208371 - Create MediaStreamTrackSource::Sink that forwards principal changes from the source. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28731/diff/1-2/
Attachment #8700522 - Attachment description: MozReview Request: dummy → MozReview Request: Bug 1208371 - Create MediaStreamTrackSource::Sink that forwards principal changes from the source. r?mt
Attachment #8700522 - Attachment is obsolete: false
Attachment #8700522 - Flags: review?(martin.thomson)
Comment on attachment 8700523 [details]
MozReview Request: Bug 1208371 - Add a generic PrincipalChangeObserver interface. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28733/diff/1-2/
Attachment #8700523 - Attachment description: MozReview Request: dummy → MozReview Request: Bug 1208371 - Let DOMMediaStream base its principal on the tracks it contains. r?mt
Attachment #8700523 - Attachment is obsolete: false
Attachment #8700523 - Flags: review?(martin.thomson)
Attachment #8700524 - Attachment description: MozReview Request: dummy → MozReview Request: Bug 1208371 - Add an interface DecoderPrincipalChangeObserver to HTMLMediaElement. r?roc
Attachment #8700524 - Attachment is obsolete: false
Attachment #8700524 - Flags: review?(roc)
Comment on attachment 8700524 [details]
MozReview Request: Bug 1208371 - Add an interface DecoderPrincipalChangeObserver to HTMLMediaElement. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28735/diff/1-2/
Attachment #8700525 - Attachment description: MozReview Request: dummy → MozReview Request: Bug 1208371 - Make HTMLMediaElement::CaptureStream pass its principal to MediaStreamTrack. r?mt
Attachment #8700525 - Attachment is obsolete: false
Attachment #8700525 - Flags: review?(martin.thomson)
Comment on attachment 8700525 [details]
MozReview Request: Bug 1208371 - Make HTMLMediaElement::CaptureStream pass its principal to MediaStreamTrack. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28737/diff/1-2/
Comment on attachment 8700526 [details]
MozReview Request: Bug 1208371 - Make MediaManager pass its principal to MediaStreamTrack for gUM. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28739/diff/1-2/
Attachment #8700526 - Attachment description: MozReview Request: dummy → MozReview Request: Bug 1208371 - Make MediaManager pass its principal to MediaStreamTrack for gUM. r?mt
Attachment #8700526 - Flags: review?(martin.thomson)
Comment on attachment 8700527 [details]
MozReview Request: Bug 1208371 - Make ImageCapture listen to principal changes of MediaStreamTrack instead. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28741/diff/1-2/
Attachment #8700527 - Attachment description: MozReview Request: dummy → MozReview Request: Bug 1208371 - Make ImageCapture listen to principal changes of MediaStreamTrack instead. r?mt
Attachment #8700527 - Flags: review?(martin.thomson)
Attachment #8700528 - Attachment description: MozReview Request: dummy → MozReview Request: Bug 1208371 - Make PeerConnectionImpl pass its principal to MediaStreamTrack through a new RemoteTrackSource. r?mt
Attachment #8700528 - Flags: review?(martin.thomson)
Comment on attachment 8700528 [details]
MozReview Request: Bug 1208371 - Make PeerConnectionImpl pass its principal to MediaStreamTrack through a new RemoteTrackSource. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28743/diff/1-2/
Comment on attachment 8700529 [details]
MozReview Request: Bug 1208371 - Make remaining DOMMediaStream principal sources use MediaStreamTrack. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28745/diff/1-2/
Attachment #8700529 - Attachment description: MozReview Request: dummy → MozReview Request: Bug 1208371 - Make remaining DOMMediaStream principal sources use MediaStreamTrack. r?mt
Attachment #8700529 - Flags: review?(martin.thomson)
Attachment #8676177 - Attachment description: MozReview Request: dummy → MozReview Request: Bug 1208371 - Remove some no longer necessary principal methods on DOMMediaStream. r?mt
Attachment #8676177 - Flags: review?(martin.thomson)
Comment on attachment 8676177 [details]
MozReview Request: Bug 1208371 - Let DOMMediaStream base its principal on the tracks it contains. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22601/diff/4-5/
Comment on attachment 8676179 [details]
MozReview Request: Bug 1208371 - Move ImageCapture to a MediaStreamTrackListener. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22605/diff/4-5/
Attachment #8676179 - Attachment description: MozReview Request: Bug 1208371 - Add an MSGTrackListener interface to MediaStreamTrack. r?roc → MozReview Request: Bug 1208371 - Add a MediaStreamTrackListener to MediaStreamGraph. r?roc
Comment on attachment 8676180 [details]
MozReview Request: Bug 1208371 - Make it possible to look up stream id by track in PeerConnectionImpl. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22607/diff/4-5/
Comment on attachment 8676181 [details]
MozReview Request: Bug 1208371 - Fix DOMMediaStream::OwnsTrack. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22609/diff/4-5/
Comment on attachment 8676182 [details]
MozReview Request: Bug 1208371 - Remove MediaStreamTrack::GetStream. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22611/diff/4-5/
Attachment #8676182 - Attachment description: MozReview Request: Bug 1208371 - Remove MediaStreamTrack::GetStream/GetParentObject. r?jib → MozReview Request: Bug 1208371 - Remove MediaStreamTrack::GetStream. r?jib
Comment on attachment 8681202 [details]
MozReview Request: Bug 1208371 - Route ApplyConstraints through MediaStreamTrackSource. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23771/diff/3-4/
Comment on attachment 8681203 [details]
MozReview Request: Bug 1208371 - Make it possible to block tracks in a MediaInputPort initally. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23773/diff/3-4/
Attachment #8681204 - Flags: review?(bugs)
Comment on attachment 8681204 [details]
MozReview Request: Bug 1208371 - Implement MediaStreamTrack::Clone(). r?smaug,jib,roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23775/diff/3-4/
Comment on attachment 8676157 [details]
MozReview Request: Bug 1208371 - Pass parent window to DOMMediaStream through constructor. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22567/diff/3-4/
Comment on attachment 8681205 [details]
MozReview Request: Bug 1208371 - Implement DOMMediaStream::Clone() r?smaug,jib,roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23777/diff/3-4/
Attachment #8681205 - Flags: review?(bugs)
Comment on attachment 8676159 [details]
MozReview Request: Bug 1208371 - Make AudioCaptureStream startable. r?padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22569/diff/3-4/
Comment on attachment 8681206 [details]
MozReview Request: Bug 1208371 - Various cleanups in DOMMediaStream/MediaStreamTrack. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23779/diff/3-4/
Comment on attachment 8681207 [details]
MozReview Request: Bug 1208371 - Forward input stream and track id on regular track changes for union streams. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23781/diff/3-4/
Comment on attachment 8681208 [details]
MozReview Request: Bug 1208371 - Move track.stop() helpers to MediaStreamPlayback. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23783/diff/3-4/
Comment on attachment 8681209 [details]
MozReview Request: Bug 1208371 - Test DOMMediaStream::Clone(). r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23785/diff/3-4/
Attachment #8681209 - Attachment description: MozReview Request: Bug 1208371 - Test MediaStream.clone(). r?jib → MozReview Request: Bug 1208371 - Test DOMMediaStream::Clone(). r?jib
Comment on attachment 8683551 [details]
MozReview Request: Bug 1208371 - Rename CreateOwnDOMTrack/CreateClonedDOMTrack to CreateDOMTrack/CloneDOMTrack. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/24365/diff/2-3/
Otherwise we don't get an accurate nr-of-nonzero-samples measurement as
the sources now lock on to a track (main thread) before attaching a
listener.

Review commit: https://reviewboard.mozilla.org/r/30017/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/30017/
Attachment #8705541 - Flags: review?(padenot)
This so it can be shared between multiple tracks.

Review commit: https://reviewboard.mozilla.org/r/30019/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/30019/
Attachment #8705542 - Flags: review?(martin.thomson)
It does not leak anymore, and the exception from bug 919051 is not
in the spec.

Review commit: https://reviewboard.mozilla.org/r/30031/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/30031/
Attachment #8705549 - Flags: review?(roc)
Disabling the audio analyser debug canvas gave us enough perf to enable
the test reliably here.

Review commit: https://reviewboard.mozilla.org/r/30059/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/30059/
Attachment #8705563 - Flags: review?(jib)
LoadManagerSingleton has a separate shutdown path (xpcom-shutdown) from
its users (Audio/VideoConduit - garbage collected). These have appeared
racy, so in some cases the singleton was destructed before the users had
deregistered (e.g., when conduits destructed by SnowWhiteKiller).

A WeakPtr can solve this.

Review commit: https://reviewboard.mozilla.org/r/30067/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/30067/
Attachment #8705567 - Flags: review?(pkerr)
In case MediaPipeline gets destructed on main thread we cannot dispatch
to main thread. In this case, destroy the conduits directly.

The easiest way to test this that I have found is to shut Firefox down
in the middle of a PeerConnection mochitest, when the PeerConnection is
still active.

Review commit: https://reviewboard.mozilla.org/r/30069/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/30069/
Attachment #8705568 - Flags: review?(docfaraday)
Otherwise we'd risk reading old pixels in case we draw something
transparent.

Review commit: https://reviewboard.mozilla.org/r/30071/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/30071/
Attachment #8705569 - Flags: review?(jib)
Comment on attachment 8681204 [details]
MozReview Request: Bug 1208371 - Implement MediaStreamTrack::Clone(). r?smaug,jib,roc

Sorry for the spam smaug, nothing new for you to review here.
Attachment #8681204 - Flags: review?(bugs)
Comment on attachment 8681205 [details]
MozReview Request: Bug 1208371 - Implement DOMMediaStream::Clone() r?smaug,jib,roc

jib, this should per the spec discussions now. Though I see a bug. I'll comment in mozreview.
Attachment #8681205 - Flags: review?(jib)
Attachment #8681205 - Flags: review?(bugs)
Attachment #8681205 - Flags: review+
Comment on attachment 8676179 [details]
MozReview Request: Bug 1208371 - Move ImageCapture to a MediaStreamTrackListener. r?roc

I made this a fullworthy listener instead of a wrapper around MediaStreamListener, so it'd be great if you could take another look at it roc.
Attachment #8676179 - Flags: review+ → review?(roc)
https://reviewboard.mozilla.org/r/23777/#review26809

::: dom/media/DOMMediaStream.cpp:670
(Diff revision 4)
> +  if (aForwarding == TrackForwardingOption::CURRENT) {

This should really be `if (aForwarding == TrackForwardingOption::ALL) {`.
https://reviewboard.mozilla.org/r/22605/#review26811

::: dom/media/MediaStreamGraph.h:284
(Diff revision 5)
> + * XXX

I'll fix this.
Ok, seems to have worked \o/

There are a lot of new patches because:

1. Plenty APIs moved from streams (or were added) to tracks, including CORSMode, Principals, PeerIdentity, MSG-side listeners and all their users were adapted.

2. Lots of intermittent bugs that I saw on try got fixed. I still have a tricky one on Android Debug that I'm closing in on, so expect one more patch for that.
Comment on attachment 8705535 [details]
MozReview Request: Bug 1208371 - Lock MediaStreamAudioSourceNode onto the first AudioStreamTrack in mInputStream at time of construction. r?mt,padenot

https://reviewboard.mozilla.org/r/30005/#review26825

::: dom/media/webaudio/MediaStreamAudioSourceNode.h:75
(Diff revision 1)
> +  void AttachToFirstTrack(const RefPtr<DOMMediaStream>& aMediaStream);

This is changing in the Web Audio spec, but I would not worry about it right now. The problem is that "the first available audio track in aMediaStream" is not very well defined.
Attachment #8705535 - Flags: review?(padenot) → review+
Attachment #8705540 - Flags: review?(padenot) → review+
Comment on attachment 8705540 [details]
MozReview Request: Bug 1208371 - Update tests to accomodate the fact that MediaStreamAudioSourceNodes lock onto the first audio track. r?padenot

https://reviewboard.mozilla.org/r/30015/#review26827
Attachment #8705541 - Flags: review?(padenot) → review+
Comment on attachment 8705541 [details]
MozReview Request: Bug 1208371 - Modify WebAudio source nodes tests to wait for tracks befoure measuring nr of samples. r?padenot

https://reviewboard.mozilla.org/r/30017/#review26829
Comment on attachment 8705557 [details]
MozReview Request: Bug 1208371 - Make GraphDriver callback log calls verbose. r?padenot

https://reviewboard.mozilla.org/r/30047/#review26831

::: dom/media/GraphDriver.cpp:867
(Diff revision 1)
> -    STREAM_LOG(LogLevel::Debug, ("interval[%ld; %ld] state[%ld; %ld] (frames: %ld) (durationMS: %u) (duration ticks: %ld)\n",
> +    STREAM_LOG(LogLevel::Verbose, ("interval[%ld; %ld] state[%ld; %ld] (frames: %ld) (durationMS: %u) (duration ticks: %ld)\n",

This is going to be bitrot (or maybe you're going to bitrot someone).
Attachment #8705557 - Flags: review?(padenot) → review+
Attachment #8705561 - Flags: review?(padenot) → review+
Comment on attachment 8705561 [details]
MozReview Request: Bug 1208371 - Remove debug canvas from addTrackRemoveTrack test to help android perf. r?padenot

https://reviewboard.mozilla.org/r/30055/#review26833
Comment on attachment 8705562 [details]
MozReview Request: Bug 1208371 - Remove debug canvas from peerConnection_trackDisabling test to help android perf. r?padenot

https://reviewboard.mozilla.org/r/30057/#review26835
Attachment #8705562 - Flags: review?(padenot) → review+
Comment on attachment 8705564 [details]
MozReview Request: Bug 1208371 - Remove debug canvas from mediaStreamConstructors test to help android perf. r?padenot

https://reviewboard.mozilla.org/r/30061/#review26837
Attachment #8705564 - Flags: review?(padenot) → review+
Comment on attachment 8705565 [details]
MozReview Request: Bug 1208371 - Add disconnect method to test helper AudioStreamAnalyser to improve performance on slow devices. r?padenot

https://reviewboard.mozilla.org/r/30063/#review26839
Attachment #8705565 - Flags: review?(padenot) → review+
Comment on attachment 8705566 [details]
MozReview Request: Bug 1208371 - Turn DOMMediaStream::PrincipalChangeObserver into PrincipalChangeObserver<DOMMediaStream>. r?mt

https://reviewboard.mozilla.org/r/30065/#review26841
Attachment #8705566 - Flags: review?(padenot) → review+
Comment on attachment 8705570 [details]
MozReview Request: Bug 1208371 - Wait for "loadedmetadata" before setting up nodes in test_mediaElementAudioSourceNodeCrossOrigin.html. r?padenot

https://reviewboard.mozilla.org/r/30073/#review26843
Attachment #8705570 - Flags: review?(padenot) → review+
Comment on attachment 8705567 [details]
MozReview Request: Bug 1208371 - Guard LoadManagerSingleton with a WeakPtr. r?pkerr

https://reviewboard.mozilla.org/r/30067/#review26853

r+
Attachment #8705567 - Flags: review?(pkerr) → review+
Comment on attachment 8676165 [details]
MozReview Request: Bug 1208371 - Add MediaStreamTrack::Graph(). r?jib

https://reviewboard.mozilla.org/r/22581/#review26901
Attachment #8676165 - Flags: review?(jib) → review+
I've spent over half an hour now determining which diff versions (I think it's 2-5? though it may vary by patch?) that I need to be reviewing. It would be nice if MozReview kept track of the last diff I've reviewed, or at least showed associated dates for the various numeric (1,2,3,4,5 etc.) "revisions"...
Attachment #8705555 - Flags: review?(docfaraday) → review+
Comment on attachment 8705555 [details]
MozReview Request: Bug 1208371 - Switch MediaPipeline to use direct listeners on tracks. r?jesup,bwc

https://reviewboard.mozilla.org/r/30043/#review26907

Just some minor nits.

::: media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp:109
(Diff revision 1)
>    DetachTransport_s();

Let's just move the code from DetachTransport_s in here, and remove that function.

::: media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp:923
(Diff revision 1)
> +  MOZ_ASSERT(conduit_->type() ==

Can't we just put a MOZ_ASSERT(false, "...") in the if block below?

::: media/webrtc/signaling/src/peerconnection/MediaPipelineFactory.cpp:577
(Diff revision 1)
> +    stream->GetMediaStream()->GetTrackById(NS_ConvertUTF8toUTF16(aTrack.GetTrackId().c_str()));

Please wrap to 80.

::: media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp:1195
(Diff revision 1)
> +    mMediaStream->GetOwnedTrackById(NS_ConvertUTF8toUTF16(newTrackId.c_str()));

Any particular reason we're using GetOwnedTrackById here, but GetTrackById further up? Is there some subtlety I'm missing here?

::: media/webrtc/signaling/test/FakeMediaStreams.h:181
(Diff revision 1)
> +        mTrackListeners.erase(it);

This leaks.

::: media/webrtc/signaling/test/mediapipeline_unittest.cpp:252
(Diff revision 1)
> +    ASSERT_TRUE(1 == tracks.Length());

For gtest, we prefer ASSERT_EQ(1U, tracks.Length());
Comment on attachment 8705568 [details]
MozReview Request: Bug 1208371 - Don't dispatch conduit destruction to main thread when not needed. r?bwc

https://reviewboard.mozilla.org/r/30069/#review26925
Attachment #8705568 - Flags: review?(docfaraday) → review+
Attachment #8705531 - Flags: review?(docfaraday) → review+
Comment on attachment 8705531 [details]
MozReview Request: Bug 1208371 - Resolve ambiguous symbol MediaStreamTrack. r?bwc

https://reviewboard.mozilla.org/r/29997/#review26875
(In reply to Jan-Ivar Bruaroey [:jib] from comment #361)
> I've spent over half an hour now determining which diff versions (I think
> it's 2-5? though it may vary by patch?) that I need to be reviewing. It
> would be nice if MozReview kept track of the last diff I've reviewed, or at
> least showed associated dates for the various numeric (1,2,3,4,5 etc.)
> "revisions"...
Please file a mozreview bug about this.
https://bugzilla.mozilla.org/enter_bug.cgi?product=Developer%20Services&component=MozReview
I've also complained about it being hard to know what all has been reviewed, but this is a bit different type of issue
Comment on attachment 8676179 [details]
MozReview Request: Bug 1208371 - Move ImageCapture to a MediaStreamTrackListener. r?roc

https://reviewboard.mozilla.org/r/22605/#review26951

::: dom/media/MediaStreamGraph.h:284
(Diff revision 5)
> + * XXX

Still not fixed...
Comment on attachment 8700524 [details]
MozReview Request: Bug 1208371 - Add an interface DecoderPrincipalChangeObserver to HTMLMediaElement. r?roc

https://reviewboard.mozilla.org/r/28735/#review26953

::: dom/html/HTMLMediaElement.cpp:4157
(Diff revision 2)
> +  return *mDecoderPrincipalChangeObservers.AppendElement(aObserver) == aObserver;

I think we should make this infallible.

If you really want this to be fallible, this isn't the way to do it, because it will crash if AppendElement fails.
Attachment #8700524 - Flags: review?(roc)
Attachment #8705571 - Flags: review?(jwwang) → review+
Comment on attachment 8705571 [details]
MozReview Request: Bug 1208371 - Improve reliability of test_mediarecorder_record_timeslice.html. r?jwwang

https://reviewboard.mozilla.org/r/30075/#review26955
Comment on attachment 8705534 [details]
MozReview Request: Bug 1208371 - Add convenience method for forwarding a track to an MSG-stream. r?roc

https://reviewboard.mozilla.org/r/30003/#review26957
Comment on attachment 8705539 [details]
MozReview Request: Bug 1208371 - Remove ref counting from DOMMediaStream::TrackListener. r?roc

https://reviewboard.mozilla.org/r/30013/#review26959
Comment on attachment 8705548 [details]
MozReview Request: Bug 1208371 - Add convenience method for checking track forwarding to MediaStreamTrack. r?roc

https://reviewboard.mozilla.org/r/30029/#review26961
Comment on attachment 8705549 [details]
MozReview Request: Bug 1208371 - Remove test_mediarecorder_record_nosrc.html. r?roc

https://reviewboard.mozilla.org/r/30031/#review26963
Attachment #8705549 - Flags: review?(roc) → review+
Comment on attachment 8705551 [details]
MozReview Request: Bug 1208371 - Check principal per track instead of per stream in MediaRecorder. r?roc

https://reviewboard.mozilla.org/r/30035/#review26967
Comment on attachment 8705554 [details]
MozReview Request: Bug 1208371 - Add DirectTrackLister to MediaStreamGraph and MediaStreamTrack. r?roc,jesup

https://reviewboard.mozilla.org/r/30041/#review26969

::: dom/media/TrackUnionStream.cpp:354
(Diff revision 1)
> +                                         entry.mInputTrackID);

Are you sure it's impossible to create a stream cycle that includes a TrackUnionStream? I'm not. If it's possible then someone could trigger a stack overflow crash here.
This was the cause of some intermittent assertion failures, as the non-ended
track didn't contain enough data when linked to other streams in the graph,
but input extraction wouldn't get that data since the stream was finished.

Review commit: https://reviewboard.mozilla.org/r/30299/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/30299/
Attachment #8706309 - Flags: review?(roc)
Comment on attachment 8706309 [details]
MozReview Request: Bug 1208371 - Break PCImpl::SetRemoteDescription into smaller pieces. r?mt,bwc

https://reviewboard.mozilla.org/r/30299/#review27185
Attachment #8706309 - Flags: review?(roc) → review+
Attachment #8700521 - Flags: review?(martin.thomson) → review+
Comment on attachment 8700521 [details]
MozReview Request: Bug 1208371 - Add principal APIs to MediaStreamTrack. r?mt

https://reviewboard.mozilla.org/r/28729/#review27197

::: dom/media/MediaStreamTrack.h:211
(Diff revision 2)
> +  class PrincipalChangeObserver

Does this duplicate the same class on MediaStream?  I would have thought that moving this out into a standalone would make more sense here.
Comment on attachment 8700522 [details]
MozReview Request: Bug 1208371 - Create MediaStreamTrackSource::Sink that forwards principal changes from the source. r?mt

https://reviewboard.mozilla.org/r/28731/#review27199
Attachment #8700522 - Flags: review?(martin.thomson) → review+
Comment on attachment 8700523 [details]
MozReview Request: Bug 1208371 - Add a generic PrincipalChangeObserver interface. r?mt

https://reviewboard.mozilla.org/r/28733/#review27205

::: dom/media/DOMMediaStream.cpp:993
(Diff revision 2)
> +  aTrack->RemovePrincipalChangeObserver(this);

I don't think that this is enough in this case.  Both here and for the PrincipalChangeObserver callback.

The problem is that this is progressively going to reduce the principal to the null principal and that is a unrecoverable state.

I think that you want the principal on the stream to reflect the combination of the principals on the tracks at the current point in time.  There might be a few corner cases, but I think that it is generally safe to rebuild the principal completely in the case that a track is removed, or its principal changed.  The corner cases can be covered by changing the track principal.
Attachment #8700523 - Flags: review?(martin.thomson)
https://reviewboard.mozilla.org/r/30043/#review26907

> Let's just move the code from DetachTransport_s in here, and remove that function.

It's also used in `UpdateTransport_s`. Line 175. What would you like me to do?

> Any particular reason we're using GetOwnedTrackById here, but GetTrackById further up? Is there some subtlety I'm missing here?

There's basically a limbo state here, where the PeerConnection API is in between the old stream-oriented structure and the new track-oriented one.

I think I'll have to fix the stream-oriented case a bit (where those GetTrackById calls are) for this to work reliably.

> This leaks.

So mListeners leaks as well. I changed mListeners to hold RefPtr instead of raw ptrs, and mTrackListeners to a vector of BoundTrackListener (no ptr) - sets are ordered so I'd have to implement a comparer to continue using them. I'll let you re-review this.
https://reviewboard.mozilla.org/r/30043/#review26907

> It's also used in `UpdateTransport_s`. Line 175. What would you like me to do?

Actually, let's just remove ShutdownTransport_s, and have all previous callers call DetachTransport_s instead, since that's a better name for what is happening.
Comment on attachment 8700525 [details]
MozReview Request: Bug 1208371 - Make HTMLMediaElement::CaptureStream pass its principal to MediaStreamTrack. r?mt

https://reviewboard.mozilla.org/r/28737/#review27419

::: dom/html/HTMLMediaElement.cpp:1881
(Diff revision 2)
> +  void NotifyDecoderPrincipalChanged() override
> +  {
> +    nsCOMPtr<nsIPrincipal> newPrincipal = mElement->GetCurrentPrincipal();
> +    if (nsContentUtils::CombineResourcePrincipals(&mPrincipal, newPrincipal)) {

Can you explain why this is using CombineX rather than just updating the principal?

::: dom/html/HTMLMediaElement.cpp:1922
(Diff revision 2)
> -    already_AddRefed<dom::MediaStreamTrackSource>
> +  already_AddRefed<dom::MediaStreamTrackSource>
> -    GetMediaStreamTrackSource(TrackID aInputTrackID) override
> +  GetMediaStreamTrackSource(TrackID aInputTrackID) override
> -    {
> +  {
> -      return do_AddRef(new BasicUnstoppableTrackSource());
> +    return do_AddRef(new CaptureStreamTrackSource(mElement));
> -    }
> +  }

I'm not entirely comfortable with the idea that you have a getter that returns a new instance of the source.
Attachment #8700525 - Flags: review?(martin.thomson) → review+
Attachment #8700526 - Flags: review?(martin.thomson) → review+
Comment on attachment 8700526 [details]
MozReview Request: Bug 1208371 - Make MediaManager pass its principal to MediaStreamTrack for gUM. r?mt

https://reviewboard.mozilla.org/r/28739/#review27421
Comment on attachment 8700527 [details]
MozReview Request: Bug 1208371 - Make ImageCapture listen to principal changes of MediaStreamTrack instead. r?mt

https://reviewboard.mozilla.org/r/28741/#review27423
Attachment #8700527 - Flags: review?(martin.thomson) → review+
Attachment #8705554 - Flags: review?(rjesup) → review+
Comment on attachment 8705554 [details]
MozReview Request: Bug 1208371 - Add DirectTrackLister to MediaStreamGraph and MediaStreamTrack. r?roc,jesup

https://reviewboard.mozilla.org/r/30041/#review27267

::: dom/media/MediaStreamGraph.h:445
(Diff revision 1)
> +  // XXX

remove or add comment

::: dom/media/MediaStreamTrack.h:319
(Diff revision 1)
> +   * Attemtps to add a direct track listener to this track.

typo

::: dom/media/TrackUnionStream.h:74
(Diff revision 1)
> +  // XXX

comment or remove

::: dom/media/TrackUnionStream.cpp:233
(Diff revision 1)
> +                                   this, bound.mListener.get(), bound.mTrackID,

Are TrackID's signed or unsigned?  not by any means important, though.

::: dom/media/TrackUnionStream.cpp:380
(Diff revision 1)
> +  for (int32_t i = mPendingDirectTrackListeners.Length() - 1; i >= 0; --i) {

Normally I'd suggest "auto" here, but not with the way the loop is set up (same for the other 'for (int32_t i = blah.Length(); ...)' loops)
Comment on attachment 8705556 [details]
MozReview Request: Bug 1208371 - Switch MediaStreamTrack to enable/disable tracks on owned stream. r?jesup

https://reviewboard.mozilla.org/r/30045/#review27427
Attachment #8705556 - Flags: review?(rjesup) → review+
Attachment #8700528 - Flags: review?(martin.thomson) → review+
Comment on attachment 8700528 [details]
MozReview Request: Bug 1208371 - Make PeerConnectionImpl pass its principal to MediaStreamTrack through a new RemoteTrackSource. r?mt

https://reviewboard.mozilla.org/r/28743/#review27425

::: media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp:1808
(Diff revision 2)
> +#if !defined(MOZILLA_EXTERNAL_LINKAGE)

I hate to do this to you, but this function is way too long.  It needs to be busted apart.

There are two obvious chunks in this success path to split out into CreateNewRemoteTracks() and RemoveOldRemoteTracks().

::: media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.h:158
(Diff revision 2)
> +  dom::MediaSourceEnum GetMediaSource() const override { return dom::MediaSourceEnum::Other; }

Nit: wrap
Attachment #8705555 - Flags: review?(rjesup) → review+
Comment on attachment 8705555 [details]
MozReview Request: Bug 1208371 - Switch MediaPipeline to use direct listeners on tracks. r?jesup,bwc

https://reviewboard.mozilla.org/r/30043/#review27433
Comment on attachment 8700529 [details]
MozReview Request: Bug 1208371 - Make remaining DOMMediaStream principal sources use MediaStreamTrack. r?mt

https://reviewboard.mozilla.org/r/28745/#review27435
Attachment #8700529 - Flags: review?(martin.thomson) → review+
Attachment #8705533 - Flags: review?(martin.thomson) → review+
Comment on attachment 8705533 [details]
MozReview Request: Bug 1208371 - Add CORSMode methods to MediaStreamTrack. r?mt

https://reviewboard.mozilla.org/r/30001/#review27437
Comment on attachment 8705535 [details]
MozReview Request: Bug 1208371 - Lock MediaStreamAudioSourceNode onto the first AudioStreamTrack in mInputStream at time of construction. r?mt,padenot

https://reviewboard.mozilla.org/r/30005/#review27439
Attachment #8705535 - Flags: review?(martin.thomson) → review+
Comment on attachment 8705536 [details]
MozReview Request: Bug 1208371 - Move HTMLMediaElement::CaptureStream to forward CORSMode changes through MediaStreamTrackSource. r?mt

https://reviewboard.mozilla.org/r/30007/#review27441
Attachment #8705536 - Flags: review?(martin.thomson) → review+
Attachment #8705537 - Flags: review?(martin.thomson)
Comment on attachment 8705537 [details]
MozReview Request: Bug 1208371 - Remove CORSMode methods from DOMMediaStream. r?mt

https://reviewboard.mozilla.org/r/30009/#review27443

^H^H^H == good
Attachment #8705538 - Flags: review?(martin.thomson)
Comment on attachment 8705538 [details]
MozReview Request: Bug 1208371 - Change HTMLMediaElement video sinks to check principal for video only tracks. r?mt

https://reviewboard.mozilla.org/r/30011/#review27445

::: dom/html/HTMLMediaElement.cpp:4239
(Diff revision 1)
> +      if (track->Ended()) {

Should this check track->Enabled() instead?

It was my understanding that only one video track contributes to the image rendered to a video tag. If that is the case, shouldn't this just attempt to identify that track and forward the principal?

I was under the impression from previous discussions that a video tag with a single ended video track would continue to show the last frame shown in that track.  That suggests that ended is the wrong attribute here.

::: dom/html/HTMLMediaElement.cpp:4240
(Diff revision 1)
> +        // Ended video tracks don't receive any more frames. Skip.
Attachment #8705542 - Flags: review?(martin.thomson) → review+
Comment on attachment 8705542 [details]
MozReview Request: Bug 1208371 - Make PeerIdentity RefCounted. r?mt

https://reviewboard.mozilla.org/r/30019/#review27447
Comment on attachment 8676161 [details]
MozReview Request: Bug 1208371 - Remove unused MediaManager::NotifyMediaStreamTrackEnded. r?jib

https://reviewboard.mozilla.org/r/22573/#review27449
Attachment #8676161 - Flags: review?(jib) → review+
Comment on attachment 8705537 [details]
MozReview Request: Bug 1208371 - Remove CORSMode methods from DOMMediaStream. r?mt

https://reviewboard.mozilla.org/r/30009/#review27451
Attachment #8705537 - Flags: review+
Comment on attachment 8705543 [details]
MozReview Request: Bug 1208371 - Add GetPeerIdentity() to MediaStreamTrackSource. r?mt

https://reviewboard.mozilla.org/r/30021/#review27453
Attachment #8705543 - Flags: review?(martin.thomson) → review+
Comment on attachment 8705545 [details]
MozReview Request: Bug 1208371 - Add PeerIdentity to LocalTrackSource for gUM tracks. r?mt

https://reviewboard.mozilla.org/r/30023/#review27455
Attachment #8705545 - Flags: review?(martin.thomson) → review+
Comment on attachment 8705546 [details]
MozReview Request: Bug 1208371 - Move PeerConnection to use PeerIdentity on MediaStreamTrack. r?mt

https://reviewboard.mozilla.org/r/30025/#review27467
Attachment #8705546 - Flags: review?(martin.thomson) → review+
Attachment #8705547 - Flags: review?(martin.thomson) → review+
Comment on attachment 8705547 [details]
MozReview Request: Bug 1208371 - Remove PeerIdentity from DOMMediaStream. r?mt

https://reviewboard.mozilla.org/r/30027/#review27469
Comment on attachment 8676177 [details]
MozReview Request: Bug 1208371 - Let DOMMediaStream base its principal on the tracks it contains. r?mt

https://reviewboard.mozilla.org/r/22601/#review27475

Hard to see where this is going to called from with all these accumulated changes.
Attachment #8676177 - Flags: review?(martin.thomson) → review+
Comment on attachment 8676178 [details]
MozReview Request: Bug 1208371 - Add DOMMediaStream::GetTrackById/GetOwnedTrackById. r?jib

https://reviewboard.mozilla.org/r/22603/#review27477
Attachment #8676178 - Flags: review?(jib) → review+
Comment on attachment 8681205 [details]
MozReview Request: Bug 1208371 - Implement DOMMediaStream::Clone() r?smaug,jib,roc

https://reviewboard.mozilla.org/r/23777/#review27479

::: dom/media/DOMMediaStream.cpp:634
(Diff revisions 2 - 4)
> +  return newStream.forget();

Nit: Why not return CloneInternal?
Attachment #8681205 - Flags: review?(jib) → review+
Comment on attachment 8705532 [details]
MozReview Request: Bug 1208371 - Test MediaStreamTrack::Clone(). r?jib

https://reviewboard.mozilla.org/r/29999/#review27481

No interdiff, but looks the same to me.

::: dom/media/tests/mochitest/test_getUserMedia_mediaStreamTrackClone.html:36
(Diff revision 1)
> +    .then(() => getUserMedia({video: true})).then(stream => {

Nit: video test code is identical to audio. Refactor to common function?
Attachment #8705532 - Flags: review?(jib) → review+
Comment on attachment 8705552 [details]
MozReview Request: Bug 1208371 - Simplify track disabling test code. r?jib

https://reviewboard.mozilla.org/r/30037/#review27483
Attachment #8705552 - Flags: review?(jib) → review+
https://reviewboard.mozilla.org/r/22605/#review26951

> Still not fixed...

I just posted the "I'll fix this" recently. It's now fixed locally.
https://reviewboard.mozilla.org/r/30041/#review27267

> Are TrackID's signed or unsigned?  not by any means important, though.

int32_t.

> Normally I'd suggest "auto" here, but not with the way the loop is set up (same for the other 'for (int32_t i = blah.Length(); ...)' loops)

This is because I need the index for RemoveElementAt() to avoid the nsTArray looping once again. I'll make it loop forwards though, since we're breaking when we find the listener in both cases.
https://reviewboard.mozilla.org/r/30041/#review26969

> Are you sure it's impossible to create a stream cycle that includes a TrackUnionStream? I'm not. If it's possible then someone could trigger a stack overflow crash here.

Good point. I'm pretty sure it's impossible from JS-MediaStreams, but I'll build in some protection against this.
Attachment #8705553 - Flags: review?(jib) → review+
Comment on attachment 8705553 [details]
MozReview Request: Bug 1208371 - Test disabling track across peerconnection not affecting clones. r?jib

https://reviewboard.mozilla.org/r/30039/#review27555
Comment on attachment 8705558 [details]
MozReview Request: Bug 1208371 - Do not require DOMLocalMediaStream for gUM (audioCapture). r?jib

https://reviewboard.mozilla.org/r/30049/#review27557
Attachment #8705558 - Flags: review?(jib) → review+
Comment on attachment 8705559 [details]
MozReview Request: Bug 1208371 - Add a track getter to gUM for fake tracks. r?jib

https://reviewboard.mozilla.org/r/30051/#review27563
Attachment #8705559 - Flags: review?(jib) → review+
Comment on attachment 8705560 [details]
MozReview Request: Bug 1208371 - Remove unnecessary fakeTracks:true from test_streams_individual_pause.html. r?jib

https://reviewboard.mozilla.org/r/30053/#review27565
Attachment #8705560 - Flags: review?(jib) → review+
Attachment #8705563 - Flags: review?(jib) → review+
Comment on attachment 8705563 [details]
MozReview Request: Bug 1208371 - Enable test_peerConnection_trackDisabling.html on android 4.3 debug. r?jib

https://reviewboard.mozilla.org/r/30059/#review27567
Comment on attachment 8705569 [details]
MozReview Request: Bug 1208371 - Clear output canvas on each drawImage(). r?jib

https://reviewboard.mozilla.org/r/30071/#review27569
Attachment #8705569 - Flags: review?(jib) → review+
Comment on attachment 8706310 [details]
MozReview Request: Bug 1208371 - Remove some no longer necessary principal methods on DOMMediaStream. r?mt

https://reviewboard.mozilla.org/r/30301/#review27575

::: dom/media/MediaManager.cpp:333
(Diff revision 1)
> -          // We consider ourselves finished if all tracks have been stopped, as
> -          // there is no way to restart them from the JS APIs.
> +          if (mType == MEDIA_STOP) {
> +            source->EndAllTrackAndFinish();
> -          if (mBool || ((!mAudioDevice || mAudioDevice->GetSource()->IsAvailable()) &&
> -                        (!mVideoDevice || mVideoDevice->GetSource()->IsAvailable()))) {
> -            source->Finish();

Wont this resurface Bug 1192170 ? If not, why not?

Not holding up review over it, but if you could talk me through it that would be great.
Attachment #8706310 - Flags: review?(jib) → review+
https://reviewboard.mozilla.org/r/30041/#review26969

> Good point. I'm pretty sure it's impossible from JS-MediaStreams, but I'll build in some protection against this.

Thinking a bit more about it, this should be fine. The only way a TrackUnionStream can have a track is if an input contains that track. The only stream types supporting direct listeners are TrackUnionStreams and SourceMediaStreams, so we're guaranteed to terminate at a SourceMediaStream or at an unsupported stream type (and we'll call back with InstallationResult::STREAM_NOT_SUPPORTED).
Attachment #8705554 - Flags: review?(roc)
https://reviewboard.mozilla.org/r/28729/#review27197

> Does this duplicate the same class on MediaStream?  I would have thought that moving this out into a standalone would make more sense here.

Well, the argument to `PrincipalChanged()` is different, but I can template that away.
https://reviewboard.mozilla.org/r/28733/#review27205

> I don't think that this is enough in this case.  Both here and for the PrincipalChangeObserver callback.
> 
> The problem is that this is progressively going to reduce the principal to the null principal and that is a unrecoverable state.
> 
> I think that you want the principal on the stream to reflect the combination of the principals on the tracks at the current point in time.  There might be a few corner cases, but I think that it is generally safe to rebuild the principal completely in the case that a track is removed, or its principal changed.  The corner cases can be covered by changing the track principal.

Won't that lead to potential information leaks since we remove the principal on main thread but the stream might still have the track alive and well on the MediaStreamGraph thread? I could wait until the track has ended in the (MSG-)playback stream I suppose.
I think that there should be a clear set of invariants on principals that will allow us to rely on the principal on the main thread always reflecting the actual media contents.  Namely:

1. Changes to the principal of a track that originate on the main thread should first combine old and new principals before dispatching to the MSG.  Once this dispatch has returned and the change to the media has been confirmed, then the principal should be set (not combined) to the new one.

2. Changes to the principal of a track that originate on the MSG thread should block (i.e., not produce new content to consumers) until confirmation has been received that the principal has changed on the main thread.

The upshot of #1 is probably that we will have tracks with a null principal during a changeover, but I think that is the right answer.  In most cases, I'm guessing that such a blip will be too fast for script to even notice (assuming that they are even able to notice, given that most transitions that will affect them will be to or from an inaccessible state).  But it means that track principals will always be "safe" and we can combine them based on the instantaneous value rather than a historic one.

A track shouldn't be removed from consideration until the MSG thread has confirmed that it isn't playing, yeah.
https://reviewboard.mozilla.org/r/28737/#review27419

> Can you explain why this is using CombineX rather than just updating the principal?

Not more than that's the way we did it before.

> I'm not entirely comfortable with the idea that you have a getter that returns a new instance of the source.

I'll add a comment on why it's OK. (simpler; sources don't keep state, just call through to the same element)
https://reviewboard.mozilla.org/r/30011/#review27445

> Should this check track->Enabled() instead?
> 
> It was my understanding that only one video track contributes to the image rendered to a video tag. If that is the case, shouldn't this just attempt to identify that track and forward the principal?
> 
> I was under the impression from previous discussions that a video tag with a single ended video track would continue to show the last frame shown in that track.  That suggests that ended is the wrong attribute here.

The track selected for video rendering in a video element is currently an implementation detail to MediaStreamGraph. Until that is fixed we'll have to base it on the combined principal of all video tracks.
https://reviewboard.mozilla.org/r/30011/#review27445

> The track selected for video rendering in a video element is currently an implementation detail to MediaStreamGraph. Until that is fixed we'll have to base it on the combined principal of all video tracks.

OK, a comment to that effect might be advisable.  I think that it is safe to skip disabled tracks though.  Those produce nothing.
https://reviewboard.mozilla.org/r/30011/#review27445

> OK, a comment to that effect might be advisable.  I think that it is safe to skip disabled tracks though.  Those produce nothing.

I'd prefer holding that back since it requires some infrastructure we don't have on MediaStreamGraph.
https://reviewboard.mozilla.org/r/30301/#review27575

> Wont this resurface Bug 1192170 ? If not, why not?
> 
> Not holding up review over it, but if you could talk me through it that would be great.

Yeah, I think you're right.
See Also: → 1202309
Comment on attachment 8676157 [details]
MozReview Request: Bug 1208371 - Pass parent window to DOMMediaStream through constructor. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22567/diff/4-5/
Comment on attachment 8676159 [details]
MozReview Request: Bug 1208371 - Make AudioCaptureStream startable. r?padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22569/diff/4-5/
Comment on attachment 8676160 [details]
MozReview Request: Bug 1208371 - Move OnTracksAvailableCallback out of DOMMediaStream. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22571/diff/4-5/
Comment on attachment 8676161 [details]
MozReview Request: Bug 1208371 - Remove unused MediaManager::NotifyMediaStreamTrackEnded. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22573/diff/4-5/
Comment on attachment 8676162 [details]
MozReview Request: Bug 1208371 - Introduce MediaStreamTrack logs. r?roc,jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22575/diff/4-5/
Comment on attachment 8676163 [details]
MozReview Request: Bug 1208371 - Track original track in MediaStreamTrack clones. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22577/diff/4-5/
Comment on attachment 8676164 [details]
MozReview Request: Bug 1208371 - Un-nest MediaEngineSource::PhotoCallback. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22579/diff/4-5/
Comment on attachment 8676168 [details]
MozReview Request: Bug 1208371 - Add a MediaStreamTrackSource interface. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22583/diff/5-6/
Comment on attachment 8676169 [details]
MozReview Request: Bug 1208371 - Add MediaStreamTrackSourceGetter interface. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22585/diff/5-6/
Comment on attachment 8676170 [details]
MozReview Request: Bug 1208371 - Let MediaStreamTracks know their TrackID at the source. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22587/diff/5-6/
Comment on attachment 8676171 [details]
MozReview Request: Bug 1208371 - Let FindOwnedDOMTrack operate on input stream. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22589/diff/5-6/
Comment on attachment 8676172 [details]
MozReview Request: Bug 1208371 - Add some MediaStreamTrack helper methods. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22591/diff/5-6/
Comment on attachment 8676173 [details]
MozReview Request: Bug 1208371 - Count the users of a MediaStream to ease Destroy() responsibility. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22593/diff/5-6/
Comment on attachment 8676174 [details]
MozReview Request: Bug 1208371 - Add convenience method for checking if TrackID is explicit. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22595/diff/5-6/
Comment on attachment 8676175 [details]
MozReview Request: Bug 1208371 - Allow MediaInputPorts mapped to a destination TrackID. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22597/diff/5-6/
Comment on attachment 8676176 [details]
MozReview Request: Bug 1208371 - Remove obsolete SetTrackEnabled() from DOMMediaStream r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22599/diff/5-6/
Comment on attachment 8676165 [details]
MozReview Request: Bug 1208371 - Add MediaStreamTrack::Graph(). r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22581/diff/5-6/
Comment on attachment 8676178 [details]
MozReview Request: Bug 1208371 - Add DOMMediaStream::GetTrackById/GetOwnedTrackById. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22603/diff/5-6/
Attachment #8700523 - Attachment description: MozReview Request: Bug 1208371 - Let DOMMediaStream base its principal on the tracks it contains. r?mt → MozReview Request: Bug 1208371 - Add a generic PrincipalChangeObserver interface. r?mt
Attachment #8700523 - Flags: review?(martin.thomson)
Comment on attachment 8700523 [details]
MozReview Request: Bug 1208371 - Add a generic PrincipalChangeObserver interface. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28733/diff/2-3/
Attachment #8705566 - Attachment description: MozReview Request: Bug 1208371 - Fix segfaulting GraphDriver log call. r?padenot → MozReview Request: Bug 1208371 - Turn DOMMediaStream::PrincipalChangeObserver into PrincipalChangeObserver<DOMMediaStream>. r?mt
Attachment #8705566 - Flags: review?(martin.thomson)
Comment on attachment 8705566 [details]
MozReview Request: Bug 1208371 - Turn DOMMediaStream::PrincipalChangeObserver into PrincipalChangeObserver<DOMMediaStream>. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30065/diff/1-2/
Comment on attachment 8700521 [details]
MozReview Request: Bug 1208371 - Add principal APIs to MediaStreamTrack. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28729/diff/2-3/
Comment on attachment 8700522 [details]
MozReview Request: Bug 1208371 - Create MediaStreamTrackSource::Sink that forwards principal changes from the source. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28731/diff/2-3/
Attachment #8676177 - Attachment description: MozReview Request: Bug 1208371 - Remove some no longer necessary principal methods on DOMMediaStream. r?mt → MozReview Request: Bug 1208371 - Let DOMMediaStream base its principal on the tracks it contains. r?mt
Comment on attachment 8676177 [details]
MozReview Request: Bug 1208371 - Let DOMMediaStream base its principal on the tracks it contains. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22601/diff/5-6/
Comment on attachment 8700524 [details]
MozReview Request: Bug 1208371 - Add an interface DecoderPrincipalChangeObserver to HTMLMediaElement. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28735/diff/2-3/
Attachment #8700524 - Flags: review?(roc)
Comment on attachment 8700525 [details]
MozReview Request: Bug 1208371 - Make HTMLMediaElement::CaptureStream pass its principal to MediaStreamTrack. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28737/diff/2-3/
Comment on attachment 8700526 [details]
MozReview Request: Bug 1208371 - Make MediaManager pass its principal to MediaStreamTrack for gUM. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28739/diff/2-3/
Comment on attachment 8700527 [details]
MozReview Request: Bug 1208371 - Make ImageCapture listen to principal changes of MediaStreamTrack instead. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28741/diff/2-3/
Attachment #8706309 - Attachment description: MozReview Request: Bug 1208371 - Assert when stream finishes but contains live tracks. r?roc → MozReview Request: Bug 1208371 - Break PCImpl::SetRemoteDescription into smaller pieces. r?mt,bwc
Attachment #8706309 - Flags: review?(martin.thomson)
Attachment #8706309 - Flags: review?(docfaraday)
Comment on attachment 8706309 [details]
MozReview Request: Bug 1208371 - Break PCImpl::SetRemoteDescription into smaller pieces. r?mt,bwc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30299/diff/1-2/
Comment on attachment 8700528 [details]
MozReview Request: Bug 1208371 - Make PeerConnectionImpl pass its principal to MediaStreamTrack through a new RemoteTrackSource. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28743/diff/2-3/
Comment on attachment 8700529 [details]
MozReview Request: Bug 1208371 - Make remaining DOMMediaStream principal sources use MediaStreamTrack. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28745/diff/2-3/
Attachment #8706310 - Attachment description: MozReview Request: Bug 1208371 - Ensure that MediaManager ends all tracks before finishing its source stream. r?jib → MozReview Request: Bug 1208371 - Remove some no longer necessary principal methods on DOMMediaStream. r?mt
Attachment #8706310 - Flags: review?(martin.thomson)
Comment on attachment 8706310 [details]
MozReview Request: Bug 1208371 - Remove some no longer necessary principal methods on DOMMediaStream. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30301/diff/1-2/
Comment on attachment 8676157 [details]
MozReview Request: Bug 1208371 - Pass parent window to DOMMediaStream through constructor. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22567/diff/4-5/
Comment on attachment 8676159 [details]
MozReview Request: Bug 1208371 - Make AudioCaptureStream startable. r?padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22569/diff/4-5/
Comment on attachment 8676179 [details]
MozReview Request: Bug 1208371 - Move ImageCapture to a MediaStreamTrackListener. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22605/diff/5-6/
Attachment #8676179 - Attachment description: MozReview Request: Bug 1208371 - Add a MediaStreamTrackListener to MediaStreamGraph. r?roc → MozReview Request: Bug 1208371 - Move ImageCapture to a MediaStreamTrackListener. r?roc
Attachment #8676179 - Flags: review?(roc)
Comment on attachment 8676160 [details]
MozReview Request: Bug 1208371 - Move OnTracksAvailableCallback out of DOMMediaStream. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22571/diff/4-5/
Comment on attachment 8676180 [details]
MozReview Request: Bug 1208371 - Make it possible to look up stream id by track in PeerConnectionImpl. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22607/diff/5-6/
Comment on attachment 8676181 [details]
MozReview Request: Bug 1208371 - Fix DOMMediaStream::OwnsTrack. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22609/diff/5-6/
Comment on attachment 8676182 [details]
MozReview Request: Bug 1208371 - Remove MediaStreamTrack::GetStream. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22611/diff/5-6/
Comment on attachment 8681202 [details]
MozReview Request: Bug 1208371 - Route ApplyConstraints through MediaStreamTrackSource. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23771/diff/4-5/
Comment on attachment 8681203 [details]
MozReview Request: Bug 1208371 - Make it possible to block tracks in a MediaInputPort initally. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23773/diff/4-5/
Attachment #8681204 - Flags: review?(bugs)
Comment on attachment 8681204 [details]
MozReview Request: Bug 1208371 - Implement MediaStreamTrack::Clone(). r?smaug,jib,roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23775/diff/4-5/
Comment on attachment 8681205 [details]
MozReview Request: Bug 1208371 - Implement DOMMediaStream::Clone() r?smaug,jib,roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23777/diff/4-5/
Attachment #8681205 - Flags: review?(bugs)
Comment on attachment 8681206 [details]
MozReview Request: Bug 1208371 - Various cleanups in DOMMediaStream/MediaStreamTrack. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23779/diff/4-5/
Comment on attachment 8681207 [details]
MozReview Request: Bug 1208371 - Forward input stream and track id on regular track changes for union streams. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23781/diff/4-5/
Comment on attachment 8681208 [details]
MozReview Request: Bug 1208371 - Move track.stop() helpers to MediaStreamPlayback. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23783/diff/4-5/
Comment on attachment 8681209 [details]
MozReview Request: Bug 1208371 - Test DOMMediaStream::Clone(). r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23785/diff/4-5/
Comment on attachment 8683551 [details]
MozReview Request: Bug 1208371 - Rename CreateOwnDOMTrack/CreateClonedDOMTrack to CreateDOMTrack/CloneDOMTrack. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/24365/diff/3-4/
Comment on attachment 8705531 [details]
MozReview Request: Bug 1208371 - Resolve ambiguous symbol MediaStreamTrack. r?bwc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/29997/diff/1-2/
Comment on attachment 8705532 [details]
MozReview Request: Bug 1208371 - Test MediaStreamTrack::Clone(). r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/29999/diff/1-2/
Comment on attachment 8705533 [details]
MozReview Request: Bug 1208371 - Add CORSMode methods to MediaStreamTrack. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30001/diff/1-2/
Comment on attachment 8705534 [details]
MozReview Request: Bug 1208371 - Add convenience method for forwarding a track to an MSG-stream. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30003/diff/1-2/
Comment on attachment 8705535 [details]
MozReview Request: Bug 1208371 - Lock MediaStreamAudioSourceNode onto the first AudioStreamTrack in mInputStream at time of construction. r?mt,padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30005/diff/1-2/
Comment on attachment 8705536 [details]
MozReview Request: Bug 1208371 - Move HTMLMediaElement::CaptureStream to forward CORSMode changes through MediaStreamTrackSource. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30007/diff/1-2/
Comment on attachment 8705537 [details]
MozReview Request: Bug 1208371 - Remove CORSMode methods from DOMMediaStream. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30009/diff/1-2/
Comment on attachment 8705538 [details]
MozReview Request: Bug 1208371 - Change HTMLMediaElement video sinks to check principal for video only tracks. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30011/diff/1-2/
Attachment #8705538 - Flags: review?(martin.thomson)
Comment on attachment 8705539 [details]
MozReview Request: Bug 1208371 - Remove ref counting from DOMMediaStream::TrackListener. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30013/diff/1-2/
Comment on attachment 8705540 [details]
MozReview Request: Bug 1208371 - Update tests to accomodate the fact that MediaStreamAudioSourceNodes lock onto the first audio track. r?padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30015/diff/1-2/
Comment on attachment 8705541 [details]
MozReview Request: Bug 1208371 - Modify WebAudio source nodes tests to wait for tracks befoure measuring nr of samples. r?padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30017/diff/1-2/
Comment on attachment 8705542 [details]
MozReview Request: Bug 1208371 - Make PeerIdentity RefCounted. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30019/diff/1-2/
Comment on attachment 8705543 [details]
MozReview Request: Bug 1208371 - Add GetPeerIdentity() to MediaStreamTrackSource. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30021/diff/1-2/
Comment on attachment 8705545 [details]
MozReview Request: Bug 1208371 - Add PeerIdentity to LocalTrackSource for gUM tracks. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30023/diff/1-2/
Comment on attachment 8705546 [details]
MozReview Request: Bug 1208371 - Move PeerConnection to use PeerIdentity on MediaStreamTrack. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30025/diff/1-2/
Comment on attachment 8705547 [details]
MozReview Request: Bug 1208371 - Remove PeerIdentity from DOMMediaStream. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30027/diff/1-2/
Comment on attachment 8705548 [details]
MozReview Request: Bug 1208371 - Add convenience method for checking track forwarding to MediaStreamTrack. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30029/diff/1-2/
Comment on attachment 8705549 [details]
MozReview Request: Bug 1208371 - Remove test_mediarecorder_record_nosrc.html. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30031/diff/1-2/
Comment on attachment 8705550 [details]
MozReview Request: Bug 1208371 - Inline MediaRecorder::Session::SetupStreams. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30033/diff/1-2/
Comment on attachment 8705551 [details]
MozReview Request: Bug 1208371 - Check principal per track instead of per stream in MediaRecorder. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30035/diff/1-2/
Comment on attachment 8705552 [details]
MozReview Request: Bug 1208371 - Simplify track disabling test code. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30037/diff/1-2/
Comment on attachment 8705553 [details]
MozReview Request: Bug 1208371 - Test disabling track across peerconnection not affecting clones. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30039/diff/1-2/
Comment on attachment 8705554 [details]
MozReview Request: Bug 1208371 - Add DirectTrackLister to MediaStreamGraph and MediaStreamTrack. r?roc,jesup

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30041/diff/1-2/
Comment on attachment 8705555 [details]
MozReview Request: Bug 1208371 - Switch MediaPipeline to use direct listeners on tracks. r?jesup,bwc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30043/diff/1-2/
Comment on attachment 8705556 [details]
MozReview Request: Bug 1208371 - Switch MediaStreamTrack to enable/disable tracks on owned stream. r?jesup

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30045/diff/1-2/
Comment on attachment 8705557 [details]
MozReview Request: Bug 1208371 - Make GraphDriver callback log calls verbose. r?padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30047/diff/1-2/
Comment on attachment 8705558 [details]
MozReview Request: Bug 1208371 - Do not require DOMLocalMediaStream for gUM (audioCapture). r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30049/diff/1-2/
Comment on attachment 8705559 [details]
MozReview Request: Bug 1208371 - Add a track getter to gUM for fake tracks. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30051/diff/1-2/
Comment on attachment 8705560 [details]
MozReview Request: Bug 1208371 - Remove unnecessary fakeTracks:true from test_streams_individual_pause.html. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30053/diff/1-2/
Comment on attachment 8705561 [details]
MozReview Request: Bug 1208371 - Remove debug canvas from addTrackRemoveTrack test to help android perf. r?padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30055/diff/1-2/
Comment on attachment 8705562 [details]
MozReview Request: Bug 1208371 - Remove debug canvas from peerConnection_trackDisabling test to help android perf. r?padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30057/diff/1-2/
Comment on attachment 8705563 [details]
MozReview Request: Bug 1208371 - Enable test_peerConnection_trackDisabling.html on android 4.3 debug. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30059/diff/1-2/
Comment on attachment 8705564 [details]
MozReview Request: Bug 1208371 - Remove debug canvas from mediaStreamConstructors test to help android perf. r?padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30061/diff/1-2/
Comment on attachment 8705565 [details]
MozReview Request: Bug 1208371 - Add disconnect method to test helper AudioStreamAnalyser to improve performance on slow devices. r?padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30063/diff/1-2/
Comment on attachment 8705567 [details]
MozReview Request: Bug 1208371 - Guard LoadManagerSingleton with a WeakPtr. r?pkerr

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30067/diff/1-2/
Comment on attachment 8705568 [details]
MozReview Request: Bug 1208371 - Don't dispatch conduit destruction to main thread when not needed. r?bwc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30069/diff/1-2/
Comment on attachment 8705569 [details]
MozReview Request: Bug 1208371 - Clear output canvas on each drawImage(). r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30071/diff/1-2/
Comment on attachment 8705570 [details]
MozReview Request: Bug 1208371 - Wait for "loadedmetadata" before setting up nodes in test_mediaElementAudioSourceNodeCrossOrigin.html. r?padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30073/diff/1-2/
Comment on attachment 8705571 [details]
MozReview Request: Bug 1208371 - Improve reliability of test_mediarecorder_record_timeslice.html. r?jwwang

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30075/diff/1-2/
This was the cause of some intermittent assertion failures, as the non-ended
track didn't contain enough data when linked to other streams in the graph,
but input extraction wouldn't get that data since the stream was finished.

Review commit: https://reviewboard.mozilla.org/r/32165/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/32165/
Attachment #8711413 - Flags: review?(roc)
This puts all the logic in GetUserMediaCallbackMediaStreamListener and none in
MediaOperationTask to make it simpler to reason about what's happening.

When we want to stop a track, the gUMCallbackListener will send a
MEDIA_STOP_TRACK if other tracks will still be live.
If it was the last live track, the gUMCallbackListener will send a MEDIA_STOP
instead. The MEDIA_STOP makes sure the passed in devices (we pass in all) are
stopped before finishing the stream.

Review commit: https://reviewboard.mozilla.org/r/32167/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/32167/
Attachment #8711414 - Flags: review?(jib)
principalId is a void pointer that can be passed by value in the MSG.

A MediaStreamTrack whose source has just updated its principal, sets the new
principal aside (as its "pending principal"), and combines the new principal
into its current principal.

Then the source starts passing the new principal to the MediaStreamGraph as
a principalId (the nsIPrincipal is static_cast()ed).

Changes to a track's principalId on the MSG will be surfaced through the
MediaStreamTrackListener API. These changes are dispatched to main thread
and compared to a MediaStreamTrack's pending principal. In case of a match
the track knows the correct principal is flowing and can move the pending
principal to the current principal and update any main thread principal
observers.

Review commit: https://reviewboard.mozilla.org/r/32171/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/32171/
Attachment #8711416 - Flags: review?(roc)
Attachment #8711416 - Flags: review?(martin.thomson)
Calculating a principal when adding a track is easy - just combine the new
track principal into the stream's principal.

When removing a track it's a bit trickier. The DOMMediaStream has to wait until
the MediaStreamGraph has removed the track from the underlying playback stream.

We do this by letting the MediaStreamGraph return a Pledge (single threaded
Promise) when blocking a track in a stream (the way we end removed tracks).
The pledge gets passed to the MediaStreamGraph and when the block has been
applied it is passed back to the main thread where it is finally resolved
and the DOMMediaStream may recompute its principal once all outstanding
track removals have been applied.

Review commit: https://reviewboard.mozilla.org/r/32181/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/32181/
Attachment #8711421 - Flags: review?(roc)
Attachment #8711421 - Flags: review?(martin.thomson)
HTMLMediaElement needs special protection when playing a stream since its
ImageContainer can outlive the video track of a stream.

Consider for instance when a (cross-origin) video track is removed from a
DOMMediaStream by a user and the remaining video track (non-CORS) does not yet
contain any actual video frames. The HTMLMediaElement will display a frame from
the removed track but the DOMMediaStream's principal has been updated to not
include the principal from the removed track.

With this patch we handle this by letting VideoFrameContainer notify
HTMLMediaElement when it has flushed out all video frames belonging to a
certain principalId. I.e., when a new principalId has been applied to the
underlying ImageContainer.

Review commit: https://reviewboard.mozilla.org/r/32183/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/32183/
Attachment #8711422 - Flags: review?(roc)
Attachment #8711422 - Flags: review?(martin.thomson)
Not sure why this surfaced now. Include ordering must have changed.

Review commit: https://reviewboard.mozilla.org/r/32191/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/32191/
Attachment #8711426 - Flags: review?(rjesup)
Comment on attachment 8681204 [details]
MozReview Request: Bug 1208371 - Implement MediaStreamTrack::Clone(). r?smaug,jib,roc

smaug, for the sake of autoland I'd appreciate if you could r+ these two patches again. The WebIDL hasn't been changed since your last r+. Thanks!
Attachment #8705555 - Flags: review+ → review?(docfaraday)
Depends on: 1242246
Attachment #8676177 - Flags: review?(martin.thomson)
Attachment #8676177 - Flags: review+
Attachment #8705566 - Flags: review+
Attachment #8706310 - Flags: review+
Attachment #8706309 - Flags: review+
Comment on attachment 8711411 [details]
MozReview Request: Bug 1208371 - Kill nsDOMUserMediaStream with fire. r?jib

https://reviewboard.mozilla.org/r/32161/#review28829
Attachment #8711411 - Flags: review?(jib) → review+
Comment on attachment 8700523 [details]
MozReview Request: Bug 1208371 - Add a generic PrincipalChangeObserver interface. r?mt

https://reviewboard.mozilla.org/r/28733/#review28833
Attachment #8700523 - Flags: review?(martin.thomson) → review+
Attachment #8705566 - Flags: review?(martin.thomson) → review+
Comment on attachment 8705566 [details]
MozReview Request: Bug 1208371 - Turn DOMMediaStream::PrincipalChangeObserver into PrincipalChangeObserver<DOMMediaStream>. r?mt

https://reviewboard.mozilla.org/r/30065/#review28839
Attachment #8706309 - Flags: review?(martin.thomson)
Comment on attachment 8706309 [details]
MozReview Request: Bug 1208371 - Break PCImpl::SetRemoteDescription into smaller pieces. r?mt,bwc

https://reviewboard.mozilla.org/r/30299/#review28841

Just nits

::: media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp:1731
(Diff revision 2)
> -        if (NS_FAILED(nrv)) {
> +      NS_ENSURE_SUCCESS(nrv, nrv);
> -          pco->OnSetRemoteDescriptionError(
> -              kInternalError,
> -              ObString("CreateRemoteSourceStreamInfo failed"),
> -              jrv);
> -          return NS_OK;

I think that I'd keep these.  This function calls aPco functions elsewhere, so having it call OnSetRemoteDescriptionError here with a more specific error is probably best.  The return can be boolean (success/failure) so that the caller can dump out early.

::: media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp:1798
(Diff revision 2)
> +nsresult
> +PeerConnectionImpl::RemoveOldRemoteTracks(RefPtr<PeerConnectionObserver>& aPco)

I'd make this a void return.
Comment on attachment 8706310 [details]
MozReview Request: Bug 1208371 - Remove some no longer necessary principal methods on DOMMediaStream. r?mt

https://reviewboard.mozilla.org/r/30301/#review28843

This might be a little more broken down than is ideal :)
Attachment #8706310 - Flags: review?(martin.thomson) → review+
Attachment #8705538 - Flags: review?(martin.thomson) → review+
Comment on attachment 8705538 [details]
MozReview Request: Bug 1208371 - Change HTMLMediaElement video sinks to check principal for video only tracks. r?mt

https://reviewboard.mozilla.org/r/30011/#review28845

::: dom/html/HTMLMediaElement.h:264
(Diff revision 2)
> +  // principal of the currently playing video resource. Anything accessing the

Nit: s/principal/Principal/

::: dom/html/HTMLMediaElement.h:266
(Diff revision 2)
> +  // principal. Returns GetCurrentPrincipal() if there are no live VideoTracks.

I know that it's easier to have a non-null value, but is this right?  This is fine, safe, and so forth, but it might be better to return nullptr when you have no video.

::: dom/media/DOMMediaStream.h:451
(Diff revision 2)
> +   * Should the last video track be removed, the last valid principal will be
> +   * returned.

It might pay to explain why this is the case.  That being that the last frame from the video might continue to be rendered to the output.

::: dom/media/DOMMediaStream.cpp:878
(Diff revision 2)
>    nsCOMPtr<nsIPrincipal> previousPrincipal;
> +  nsCOMPtr<nsIPrincipal> previousVideoPrincipal;

BUG: you need to initialize these two variables.

::: layout/base/nsLayoutUtils.cpp:7185
(Diff revision 2)
> -  nsCOMPtr<nsIPrincipal> principal = aElement->GetCurrentPrincipal();
> +  nsCOMPtr<nsIPrincipal> principal = aElement->GetCurrentVideoPrincipal();

I'm trusting here that you have surveyed other sites where a similar switch might be needed.
Attachment #8711412 - Flags: review?(martin.thomson) → review+
Comment on attachment 8711412 [details]
MozReview Request: Bug 1208371 - Let PeerConnection consume principals from tracks instead of streams. r?mt

https://reviewboard.mozilla.org/r/32163/#review28849

::: media/webrtc/signaling/src/mediapipeline/MediaPipeline.h:406
(Diff revision 1)
> -  virtual void UpdateSinkIdentity_m(nsIPrincipal* principal,
> +  // We only act if the passed track is the track currently attached.

I think that you can remove this comment.  Two reasons:

The carve-out for nullptr is important a this implies that nullptr means no action.

The statement is pretty obvious.  What might not be obvious is *why* we might be receiving notifications for tracks that we aren't sending.

::: media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp:686
(Diff revision 1)
> +  if (track != nullptr && track != domtrack_) {
> +    return;
> +  }

Please add a comment explaining what conditions lead to this check being needed.

// If a track is specified, then it might not be for this pipeline, since we receive notifications for all tracks on the PC.
// nullptr means that the principal has changed.

::: media/webrtc/signaling/test/FakeMediaStreams.h
(Diff revision 1)
> -  void AddPrincipalChangeObserver(void* ignoredObserver) {}
> -  void RemovePrincipalChangeObserver(void* ignoredObserver) {}

Nice.
Attachment #8711416 - Flags: review?(martin.thomson)
Comment on attachment 8711416 [details]
MozReview Request: Bug 1208371 - Add PrincipalHandle to MediaChunks. r?mt,jesup

https://reviewboard.mozilla.org/r/32171/#review28851

::: dom/media/AudioSegment.h:242
(Diff revision 1)
> +  void* mPrincipalId;

I think that it would be best if you typedef'd this `void*` to `PrincipalId`.

::: dom/media/MediaSegment.h:91
(Diff revision 1)
> +  void* GetLastPrincipalId() const { return mLastPrincipalId; }

Adding the typedef and constant for neverChangingPrincipalId to MediaSegment.h seems about right.  Don't forget to explain why nullptr is the right choice for the neverChanging constant as well.

::: dom/media/MediaStreamGraph.h:315
(Diff revision 1)
>        aTo.AppendFrame(do_AddRef(it->mFrame.GetImage()), it->GetDuration(),
> -                      it->mFrame.GetIntrinsicSize(), true);
> +                      it->mFrame.GetIntrinsicSize(), nullptr, true);

This looks like an error to me.  You either want to copy the aFrom principal, or a constant.

::: dom/media/encoder/TrackEncoder.cpp:253
(Diff revision 1)
> +    void* neverChangingPrincipalId = nullptr;

Use a constant.

::: dom/media/gtest/TestVideoSegment.cpp:24
(Diff revision 1)
> +                      nullptr,

Use the constant here too.
Comment on attachment 8711417 [details]
MozReview Request: Bug 1208371 - Add `NotifyPrincipalHandleChanged` to MediaStreamTrackListener. r?mt,jesup

https://reviewboard.mozilla.org/r/32173/#review28853

This looks fine to me, but I'm a little outside my comfort zone.

::: dom/media/MediaStreamGraph.cpp:316
(Diff revision 1)
> +MediaStreamGraphImpl::ProcessChunkMetadataForInterval(MediaStream* aStream,
> +                                                      TrackID aTrackID,
> +                                                      C& aSegment,
> +                                                      StreamTime aStart,
> +                                                      StreamTime aEnd)

I'm not seeing any use for aStart and aEnd.

::: dom/media/MediaStreamGraph.cpp:2295
(Diff revision 1)
> +  l->mListener->NotifyPrincipalIdChange(Graph(), lastPrincipalId);

Will calling the observer synchronously cause issues?  Might be worth adding a note about this one.
Attachment #8711417 - Flags: review?(martin.thomson) → review+
Comment on attachment 8711418 [details]
MozReview Request: Bug 1208371 - Add a PrincipalHandleListener to MediaStreamTrack. r?mt,jesup

https://reviewboard.mozilla.org/r/32175/#review28857

::: dom/media/MediaStreamTrack.cpp:53
(Diff revision 1)
> +  void Forget() { mTrack = nullptr; }

Add an assert here too.

::: dom/media/MediaStreamTrack.cpp:238
(Diff revision 1)
> -  LOG(LogLevel::Info, ("MediaStreamTrack %p Principal changed. Now: "
> +  nsCOMPtr<nsIPrincipal> newPrincipal = aPrincipal;

This temporary doesn't seem to be doing anything (other than bouncing the refCnt).
Attachment #8711418 - Flags: review?(martin.thomson) → review+
Comment on attachment 8711419 [details]
MozReview Request: Bug 1208371 - Hook up DecodedStream with PrincipalHandle. r?mt,jwwang

https://reviewboard.mozilla.org/r/32177/#review28859

Looks fine, but I don't know this code at all.
Attachment #8711419 - Flags: review?(martin.thomson) → review+
Comment on attachment 8711420 [details]
MozReview Request: Bug 1208371 - Hook up MediaPipeline with PrincipalHandle. r?mt,bwc

https://reviewboard.mozilla.org/r/32179/#review28861

::: media/webrtc/signaling/src/mediapipeline/MediaPipeline.h:573
(Diff revision 1)
> +  // Must be called on the main thread
> +  virtual void SetPrincipalId_m(void* principal_id) = 0;

Please add a comment saying what this is for: setting the principal of the tracks that this receive pipeline produces.

::: media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp:1284
(Diff revision 1)
> +      ->SetPrincipalId_m(static_cast<void*>(aPrincipal));

I'm a little unhappy about this `void*` stuff leaking outside of the MSG.  Would be unreasonable to have a static inline method on MediaSegment (or something else) that performed the conversion?
Attachment #8711420 - Flags: review?(martin.thomson) → review+
Attachment #8711421 - Flags: review?(martin.thomson)
Comment on attachment 8711421 [details]
MozReview Request: Bug 1208371 - Ensure DOMMediaStream principals reflect what could reside in their playback streams. r?mt,jesup

https://reviewboard.mozilla.org/r/32181/#review28865

This looks mostly good, though BlockTrackId could be improved.

::: dom/media/MediaStreamGraph.cpp:2952
(Diff revision 1)
> -void
> +already_AddRefed<Pledge<bool>>
>  MediaInputPort::BlockTrackId(TrackID aTrackId)

This is a little brittle here.  Perhaps the best way to manage this is to create the nsIRunnable on the main thread and pass THAT to the ControlMessage class.  That way, the inner class doesn't have to use kid gloves when handling the Pledge instance.  It's a little more transient state to maintain, but I think that it would be more readable.

::: dom/media/MediaStreamGraph.cpp:2965
(Diff revision 1)
> +      // passing it to the runnable to avoid modifying its refcount.

...to avoid modifying its refcount on the MSG thread.

::: dom/media/MediaStreamGraph.cpp:2972
(Diff revision 1)
> +        NS_IMETHOD Run() override { mPledge->Resolve(true); return NS_OK; }

Make this multi-line, add an assert for being on the main thread.
Attachment #8711422 - Flags: review?(martin.thomson) → review+
Comment on attachment 8711422 [details]
MozReview Request: Bug 1208371 - Ensure a media element's ImageContainer is protected when playing a stream. r?mt,jesup

https://reviewboard.mozilla.org/r/32183/#review28867

::: dom/media/MediaStreamGraph.h:813
(Diff revision 1)
> +

You can revert this change.

::: dom/media/VideoFrameContainer.cpp:90
(Diff revision 1)
>    nsTArray<ImageContainer::OwningImage> kungFuDeathGrip;

Let's give this a proper name.

::: dom/media/VideoFrameContainer.cpp:97
(Diff revision 1)
> +          kungFuDeathGrip.LastElement().mFrameID >= lastFrameIDForOldPrincipalId) ||
> +        (!aImages.IsEmpty() &&
> +          aImages[0].mFrameID > lastFrameIDForOldPrincipalId))) {

Maybe you can also explain why it's >= for the OwningImage array, but > for the argument.
Comment on attachment 8676177 [details]
MozReview Request: Bug 1208371 - Let DOMMediaStream base its principal on the tracks it contains. r?mt

https://reviewboard.mozilla.org/r/22601/#review28869

::: dom/media/DOMMediaStream.cpp:788
(Diff revision 6)
> +  nsCOMPtr<nsIPrincipal> previousPrincipal;

BUG: initialize this.
Attachment #8676177 - Flags: review?(martin.thomson) → review+
Comment on attachment 8711414 [details]
MozReview Request: Bug 1208371 - Ensure that MediaManager ends all tracks before finishing its source stream. r?jib

https://reviewboard.mozilla.org/r/32167/#review28855

::: dom/media/MediaManager.cpp:336
(Diff revision 1)
> -          // We consider ourselves finished if all tracks have been stopped, as
> -          // there is no way to restart them from the JS APIs.
> +          if (mType == MEDIA_STOP) {
> +            source->EndAllTrackAndFinish();
> -          if (mBool || ((!mAudioDevice || mAudioDevice->GetSource()->IsAvailable()) &&
> -                        (!mVideoDevice || mVideoDevice->GetSource()->IsAvailable()))) {
> -            source->Finish();

I like the move of the track vs. stream stop-decision to main thread, but when is Finish() no longer sufficient here?

::: dom/media/MediaManager.cpp:3203
(Diff revision 1)
> +      (aTrackID == kAudioTrack && (!mAudioDevice || mAudioStopped)) ||
> +      (aTrackID == kVideoTrack && (!mVideoDevice || mVideoStopped)))

Nit: Can we have mXxxStopped come before !mXxxDevice here to at least match the order in the repeat use below?

(A lot of variables to keep straight here).

::: dom/media/MediaManager.cpp:3217
(Diff revision 1)
> -    bool stopVideo = aTrackID == kVideoTrack && !mVideoStopped;
> +  bool stopAudio = aTrackID == kAudioTrack;
> +  bool stopVideo = aTrackID == kVideoTrack;

Nit: move these up, and it might simplify the code above a tiny bit?

::: dom/media/MediaManager.cpp:3221
(Diff revision 1)
> +    Invalidate();

Can we rename Invalidate to Stop? Seems more consistent, and makes it easier to follow what's going on.
Attachment #8711414 - Flags: review?(jib) → review+
Attachment #8711425 - Flags: review?(jib) → review+
Comment on attachment 8711425 [details]
MozReview Request: Bug 1208371 - Move MediaStreamTrack's label to MediaStreamTrackSource. r?jib

https://reviewboard.mozilla.org/r/32189/#review28871

Seems good. My only concern is screensharing, where there seemed to be some allowance in the spec for conceptually treating each capture as a unique source, which would only matter in practice in that it might allow us to put descriptive info in the label, like dimensions and monitor id, something that's been requested and is information there's no other decent way to find out. I don't know that well enough to know whether this is a problem, and right now we don't have good labels there, so this may be a problem for later. I suppose we can always back this out if we need to switch back to the other approach.
I meant to say "I don't know that CODE well enough"...
Comment on attachment 8711419 [details]
MozReview Request: Bug 1208371 - Hook up DecodedStream with PrincipalHandle. r?mt,jwwang

https://reviewboard.mozilla.org/r/32177/#review28873
Attachment #8711419 - Flags: review?(jwwang) → review+
https://reviewboard.mozilla.org/r/30011/#review28845

> I know that it's easier to have a non-null value, but is this right?  This is fine, safe, and so forth, but it might be better to return nullptr when you have no video.

Done. Elaborated a bit in the comment.

> It might pay to explain why this is the case.  That being that the last frame from the video might continue to be rendered to the output.

Sorry, I changed this behavior but forgot to update the comment. I meant for the media element to handle this case explicitly, and DOMMediaStream to just be a combinination of its live tracks.

> I'm trusting here that you have surveyed other sites where a similar switch might be needed.

There are no other external users of GetCurrentPrincipal().
https://reviewboard.mozilla.org/r/32183/#review28867

> Let's give this a proper name.

Named it `oldImages`.
Comment on attachment 8706309 [details]
MozReview Request: Bug 1208371 - Break PCImpl::SetRemoteDescription into smaller pieces. r?mt,bwc

https://reviewboard.mozilla.org/r/30299/#review28911
Attachment #8706309 - Flags: review?(docfaraday) → review+
Attachment #8711420 - Flags: review?(docfaraday) → review+
Comment on attachment 8711420 [details]
MozReview Request: Bug 1208371 - Hook up MediaPipeline with PrincipalHandle. r?mt,bwc

https://reviewboard.mozilla.org/r/32179/#review28917
Attachment #8711423 - Flags: review?(docfaraday) → review+
Comment on attachment 8711423 [details]
MozReview Request: Bug 1208371 - Forward declare MediaStreamTrack in MediaPipeline.h. r?bwc

https://reviewboard.mozilla.org/r/32185/#review28919
Comment on attachment 8711424 [details]
MozReview Request: Bug 1208371 - Clean up unnecessary virtuals in MediaPipeline. r?bwc

https://reviewboard.mozilla.org/r/32187/#review28921
Attachment #8711424 - Flags: review?(docfaraday) → review+
Attachment #8711427 - Flags: review?(docfaraday) → review+
Comment on attachment 8711427 [details]
MozReview Request: Bug 1208371 - Forward declare MediaStreamGraph classes in MediaPipeline.h. r?bwc

https://reviewboard.mozilla.org/r/32193/#review28923
Comment on attachment 8705555 [details]
MozReview Request: Bug 1208371 - Switch MediaPipeline to use direct listeners on tracks. r?jesup,bwc

https://reviewboard.mozilla.org/r/30043/#review28933

::: dom/media/TrackUnionStream.cpp:406
(Diff revisions 1 - 2)
> -    for (int32_t i = entry.mOwnedDirectListeners.Length() - 1; i >= 0; --i) {
> +    for (size_t i = 0; i < entry.mOwnedDirectListeners.Length(); ++i) {

Why this change?

::: media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.h:123
(Diff revision 2)
>    // These get set up before we generate our local description, the pipelines
>    // and conduits are set up once offer/answer completes.
> -  std::set<std::string> mTracks;
>    std::map<std::string, RefPtr<MediaPipeline>> mPipelines;
> +  std::map<std::string, RefPtr<dom::MediaStreamTrack>> mTracks;

Reordering this makes the comment wrong. (mTracks is set up before generating the local description)
Attachment #8705555 - Flags: review?(docfaraday) → review+
Attachment #8681204 - Flags: review?(bugs) → review+
Comment on attachment 8681204 [details]
MozReview Request: Bug 1208371 - Implement MediaStreamTrack::Clone(). r?smaug,jib,roc

https://reviewboard.mozilla.org/r/23775/#review29031
Comment on attachment 8711426 [details]
MozReview Request: Bug 1208371 - Move GetCurrentTime undef to DOMMediaStream.cpp. r?jesup

https://reviewboard.mozilla.org/r/32191/#review29055
Attachment #8711426 - Flags: review?(rjesup) → review+
Comment on attachment 8681205 [details]
MozReview Request: Bug 1208371 - Implement DOMMediaStream::Clone() r?smaug,jib,roc

https://reviewboard.mozilla.org/r/23777/#review29067

r+ for the .webidl
Attachment #8681205 - Flags: review?(bugs) → review+
https://reviewboard.mozilla.org/r/32171/#review28851

I fixed this patch per your comments, mt. I also set up all MediaStreamTrack producers to report the right PrincipalID; it'll be needed for HTMLMediaElement.
https://reviewboard.mozilla.org/r/32173/#review28853

> I'm not seeing any use for aStart and aEnd.

Right, I had forgotten to add checks for chunks staying within the aStart, aEnd interval. Fixed now.

> Will calling the observer synchronously cause issues?  Might be worth adding a note about this one.

This is what we do for all listener methods. Nothing new.
https://reviewboard.mozilla.org/r/32175/#review28857

> Add an assert here too.

Assert that mTrack is not null, or that we're on main thread? I have added the latter.

> This temporary doesn't seem to be doing anything (other than bouncing the refCnt).

Fixed.
https://reviewboard.mozilla.org/r/32179/#review28861

> I'm a little unhappy about this `void*` stuff leaking outside of the MSG.  Would be unreasonable to have a static inline method on MediaSegment (or something else) that performed the conversion?

Added a `PrincipalID ConvertToPrincipalID(nsIPrincipal*)` to MediaSegment. I added a `typedef void* PrincipalID` earlier.
https://reviewboard.mozilla.org/r/32181/#review28865

> This is a little brittle here.  Perhaps the best way to manage this is to create the nsIRunnable on the main thread and pass THAT to the ControlMessage class.  That way, the inner class doesn't have to use kid gloves when handling the Pledge instance.  It's a little more transient state to maintain, but I think that it would be more readable.

I wish I had thought of that myself! :-)
https://reviewboard.mozilla.org/r/32167/#review28855

> I like the move of the track vs. stream stop-decision to main thread, but when is Finish() no longer sufficient here?

I changed it so that if we only have one track left and we're stopping it, we'll send MEDIA_STOP and _no_ MEDIA_STOP_TRACK. We then do EndAllTrackAndFinish() to ensure that tracks get stopped at the same time.

I could make it send a last MEDIA_STOP_TRACK before MEDIA_STOP if you'd rather want that.

> Nit: Can we have mXxxStopped come before !mXxxDevice here to at least match the order in the repeat use below?
> 
> (A lot of variables to keep straight here).

Someone(TM) should clean it up and make it generic to allow for multiple tracks of the same type sometime soon :)
https://reviewboard.mozilla.org/r/32189/#review28871

For that case I think we should keep them as unique MediaStreamTrackSources. Which we already do I think, if you by "each capture" refer to each gUM call. For track-cloning, the source will stay the same.
https://reviewboard.mozilla.org/r/30043/#review28933

> Why this change?

Comment 411.

> Reordering this makes the comment wrong. (mTracks is set up before generating the local description)

Don't know why I did that. Reordered them back.
Attachment #8676177 - Flags: review?(roc)
Attachment #8676177 - Flags: review?(jib)
Comment on attachment 8676177 [details]
MozReview Request: Bug 1208371 - Let DOMMediaStream base its principal on the tracks it contains. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22601/diff/6-7/
Comment on attachment 8700524 [details]
MozReview Request: Bug 1208371 - Add an interface DecoderPrincipalChangeObserver to HTMLMediaElement. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28735/diff/3-4/
Comment on attachment 8700525 [details]
MozReview Request: Bug 1208371 - Make HTMLMediaElement::CaptureStream pass its principal to MediaStreamTrack. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28737/diff/3-4/
Comment on attachment 8700526 [details]
MozReview Request: Bug 1208371 - Make MediaManager pass its principal to MediaStreamTrack for gUM. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28739/diff/3-4/
Comment on attachment 8700527 [details]
MozReview Request: Bug 1208371 - Make ImageCapture listen to principal changes of MediaStreamTrack instead. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28741/diff/3-4/
Attachment #8706309 - Flags: review?(roc)
Attachment #8706309 - Flags: review?(martin.thomson)
Comment on attachment 8706309 [details]
MozReview Request: Bug 1208371 - Break PCImpl::SetRemoteDescription into smaller pieces. r?mt,bwc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30299/diff/2-3/
Comment on attachment 8700528 [details]
MozReview Request: Bug 1208371 - Make PeerConnectionImpl pass its principal to MediaStreamTrack through a new RemoteTrackSource. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28743/diff/3-4/
Comment on attachment 8700529 [details]
MozReview Request: Bug 1208371 - Make remaining DOMMediaStream principal sources use MediaStreamTrack. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28745/diff/3-4/
Attachment #8706310 - Flags: review?(jib)
Comment on attachment 8706310 [details]
MozReview Request: Bug 1208371 - Remove some no longer necessary principal methods on DOMMediaStream. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30301/diff/2-3/
Comment on attachment 8711410 [details]
MozReview Request: Bug 1208371 - Add a MediaStreamTrackListener to MediaStreamGraph. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32159/diff/1-2/
Comment on attachment 8676179 [details]
MozReview Request: Bug 1208371 - Move ImageCapture to a MediaStreamTrackListener. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22605/diff/6-7/
Comment on attachment 8676180 [details]
MozReview Request: Bug 1208371 - Make it possible to look up stream id by track in PeerConnectionImpl. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22607/diff/6-7/
Comment on attachment 8676181 [details]
MozReview Request: Bug 1208371 - Fix DOMMediaStream::OwnsTrack. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22609/diff/6-7/
Comment on attachment 8676182 [details]
MozReview Request: Bug 1208371 - Remove MediaStreamTrack::GetStream. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22611/diff/6-7/
Comment on attachment 8681202 [details]
MozReview Request: Bug 1208371 - Route ApplyConstraints through MediaStreamTrackSource. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23771/diff/5-6/
Comment on attachment 8711411 [details]
MozReview Request: Bug 1208371 - Kill nsDOMUserMediaStream with fire. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32161/diff/1-2/
Comment on attachment 8681203 [details]
MozReview Request: Bug 1208371 - Make it possible to block tracks in a MediaInputPort initally. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23773/diff/5-6/
Comment on attachment 8681204 [details]
MozReview Request: Bug 1208371 - Implement MediaStreamTrack::Clone(). r?smaug,jib,roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23775/diff/5-6/
Comment on attachment 8681205 [details]
MozReview Request: Bug 1208371 - Implement DOMMediaStream::Clone() r?smaug,jib,roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23777/diff/5-6/
Comment on attachment 8681206 [details]
MozReview Request: Bug 1208371 - Various cleanups in DOMMediaStream/MediaStreamTrack. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23779/diff/5-6/
Comment on attachment 8681207 [details]
MozReview Request: Bug 1208371 - Forward input stream and track id on regular track changes for union streams. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23781/diff/5-6/
Comment on attachment 8681208 [details]
MozReview Request: Bug 1208371 - Move track.stop() helpers to MediaStreamPlayback. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23783/diff/5-6/
Comment on attachment 8681209 [details]
MozReview Request: Bug 1208371 - Test DOMMediaStream::Clone(). r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23785/diff/5-6/
Comment on attachment 8683551 [details]
MozReview Request: Bug 1208371 - Rename CreateOwnDOMTrack/CreateClonedDOMTrack to CreateDOMTrack/CloneDOMTrack. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/24365/diff/4-5/
Comment on attachment 8705531 [details]
MozReview Request: Bug 1208371 - Resolve ambiguous symbol MediaStreamTrack. r?bwc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/29997/diff/2-3/
Comment on attachment 8676177 [details]
MozReview Request: Bug 1208371 - Let DOMMediaStream base its principal on the tracks it contains. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22601/diff/6-7/
Comment on attachment 8705532 [details]
MozReview Request: Bug 1208371 - Test MediaStreamTrack::Clone(). r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/29999/diff/2-3/
Comment on attachment 8705533 [details]
MozReview Request: Bug 1208371 - Add CORSMode methods to MediaStreamTrack. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30001/diff/2-3/
Comment on attachment 8700524 [details]
MozReview Request: Bug 1208371 - Add an interface DecoderPrincipalChangeObserver to HTMLMediaElement. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28735/diff/3-4/
Comment on attachment 8705534 [details]
MozReview Request: Bug 1208371 - Add convenience method for forwarding a track to an MSG-stream. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30003/diff/2-3/
Comment on attachment 8700525 [details]
MozReview Request: Bug 1208371 - Make HTMLMediaElement::CaptureStream pass its principal to MediaStreamTrack. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28737/diff/3-4/
Comment on attachment 8700526 [details]
MozReview Request: Bug 1208371 - Make MediaManager pass its principal to MediaStreamTrack for gUM. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28739/diff/3-4/
Comment on attachment 8705535 [details]
MozReview Request: Bug 1208371 - Lock MediaStreamAudioSourceNode onto the first AudioStreamTrack in mInputStream at time of construction. r?mt,padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30005/diff/2-3/
Comment on attachment 8705536 [details]
MozReview Request: Bug 1208371 - Move HTMLMediaElement::CaptureStream to forward CORSMode changes through MediaStreamTrackSource. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30007/diff/2-3/
Comment on attachment 8705537 [details]
MozReview Request: Bug 1208371 - Remove CORSMode methods from DOMMediaStream. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30009/diff/2-3/
Comment on attachment 8705538 [details]
MozReview Request: Bug 1208371 - Change HTMLMediaElement video sinks to check principal for video only tracks. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30011/diff/2-3/
Comment on attachment 8705539 [details]
MozReview Request: Bug 1208371 - Remove ref counting from DOMMediaStream::TrackListener. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30013/diff/2-3/
Comment on attachment 8705540 [details]
MozReview Request: Bug 1208371 - Update tests to accomodate the fact that MediaStreamAudioSourceNodes lock onto the first audio track. r?padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30015/diff/2-3/
Comment on attachment 8705541 [details]
MozReview Request: Bug 1208371 - Modify WebAudio source nodes tests to wait for tracks befoure measuring nr of samples. r?padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30017/diff/2-3/
Comment on attachment 8705542 [details]
MozReview Request: Bug 1208371 - Make PeerIdentity RefCounted. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30019/diff/2-3/
Comment on attachment 8705543 [details]
MozReview Request: Bug 1208371 - Add GetPeerIdentity() to MediaStreamTrackSource. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30021/diff/2-3/
Comment on attachment 8705545 [details]
MozReview Request: Bug 1208371 - Add PeerIdentity to LocalTrackSource for gUM tracks. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30023/diff/2-3/
Comment on attachment 8705546 [details]
MozReview Request: Bug 1208371 - Move PeerConnection to use PeerIdentity on MediaStreamTrack. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30025/diff/2-3/
Comment on attachment 8705547 [details]
MozReview Request: Bug 1208371 - Remove PeerIdentity from DOMMediaStream. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30027/diff/2-3/
Comment on attachment 8705548 [details]
MozReview Request: Bug 1208371 - Add convenience method for checking track forwarding to MediaStreamTrack. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30029/diff/2-3/
Comment on attachment 8705549 [details]
MozReview Request: Bug 1208371 - Remove test_mediarecorder_record_nosrc.html. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30031/diff/2-3/
Comment on attachment 8705550 [details]
MozReview Request: Bug 1208371 - Inline MediaRecorder::Session::SetupStreams. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30033/diff/2-3/
Comment on attachment 8705551 [details]
MozReview Request: Bug 1208371 - Check principal per track instead of per stream in MediaRecorder. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30035/diff/2-3/
Comment on attachment 8705552 [details]
MozReview Request: Bug 1208371 - Simplify track disabling test code. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30037/diff/2-3/
Comment on attachment 8705553 [details]
MozReview Request: Bug 1208371 - Test disabling track across peerconnection not affecting clones. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30039/diff/2-3/
Comment on attachment 8705554 [details]
MozReview Request: Bug 1208371 - Add DirectTrackLister to MediaStreamGraph and MediaStreamTrack. r?roc,jesup

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30041/diff/2-3/
Comment on attachment 8705555 [details]
MozReview Request: Bug 1208371 - Switch MediaPipeline to use direct listeners on tracks. r?jesup,bwc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30043/diff/2-3/
Comment on attachment 8711412 [details]
MozReview Request: Bug 1208371 - Let PeerConnection consume principals from tracks instead of streams. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32163/diff/1-2/
Comment on attachment 8705556 [details]
MozReview Request: Bug 1208371 - Switch MediaStreamTrack to enable/disable tracks on owned stream. r?jesup

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30045/diff/2-3/
Comment on attachment 8705557 [details]
MozReview Request: Bug 1208371 - Make GraphDriver callback log calls verbose. r?padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30047/diff/2-3/
Comment on attachment 8705558 [details]
MozReview Request: Bug 1208371 - Do not require DOMLocalMediaStream for gUM (audioCapture). r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30049/diff/2-3/
Comment on attachment 8705559 [details]
MozReview Request: Bug 1208371 - Add a track getter to gUM for fake tracks. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30051/diff/2-3/
Comment on attachment 8705560 [details]
MozReview Request: Bug 1208371 - Remove unnecessary fakeTracks:true from test_streams_individual_pause.html. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30053/diff/2-3/
Comment on attachment 8705561 [details]
MozReview Request: Bug 1208371 - Remove debug canvas from addTrackRemoveTrack test to help android perf. r?padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30055/diff/2-3/
Comment on attachment 8705562 [details]
MozReview Request: Bug 1208371 - Remove debug canvas from peerConnection_trackDisabling test to help android perf. r?padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30057/diff/2-3/
Comment on attachment 8705563 [details]
MozReview Request: Bug 1208371 - Enable test_peerConnection_trackDisabling.html on android 4.3 debug. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30059/diff/2-3/
Comment on attachment 8705564 [details]
MozReview Request: Bug 1208371 - Remove debug canvas from mediaStreamConstructors test to help android perf. r?padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30061/diff/2-3/
Comment on attachment 8705565 [details]
MozReview Request: Bug 1208371 - Add disconnect method to test helper AudioStreamAnalyser to improve performance on slow devices. r?padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30063/diff/2-3/
Comment on attachment 8705567 [details]
MozReview Request: Bug 1208371 - Guard LoadManagerSingleton with a WeakPtr. r?pkerr

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30067/diff/2-3/
Comment on attachment 8705568 [details]
MozReview Request: Bug 1208371 - Don't dispatch conduit destruction to main thread when not needed. r?bwc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30069/diff/2-3/
Comment on attachment 8705569 [details]
MozReview Request: Bug 1208371 - Clear output canvas on each drawImage(). r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30071/diff/2-3/
Comment on attachment 8705570 [details]
MozReview Request: Bug 1208371 - Wait for "loadedmetadata" before setting up nodes in test_mediaElementAudioSourceNodeCrossOrigin.html. r?padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30073/diff/2-3/
Depends on: 1242911
This is now stuck in a weird state. Per :mdoglio's advice on IRC I'll try to discard the mozreview draft and push again.
Comment on attachment 8676177 [details]
MozReview Request: Bug 1208371 - Let DOMMediaStream base its principal on the tracks it contains. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22601/diff/6-7/
Comment on attachment 8700524 [details]
MozReview Request: Bug 1208371 - Add an interface DecoderPrincipalChangeObserver to HTMLMediaElement. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28735/diff/3-4/
Comment on attachment 8700525 [details]
MozReview Request: Bug 1208371 - Make HTMLMediaElement::CaptureStream pass its principal to MediaStreamTrack. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28737/diff/3-4/
Comment on attachment 8700526 [details]
MozReview Request: Bug 1208371 - Make MediaManager pass its principal to MediaStreamTrack for gUM. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28739/diff/3-4/
Comment on attachment 8700527 [details]
MozReview Request: Bug 1208371 - Make ImageCapture listen to principal changes of MediaStreamTrack instead. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28741/diff/3-4/
Comment on attachment 8706309 [details]
MozReview Request: Bug 1208371 - Break PCImpl::SetRemoteDescription into smaller pieces. r?mt,bwc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30299/diff/2-3/
Comment on attachment 8700528 [details]
MozReview Request: Bug 1208371 - Make PeerConnectionImpl pass its principal to MediaStreamTrack through a new RemoteTrackSource. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28743/diff/3-4/
Comment on attachment 8700529 [details]
MozReview Request: Bug 1208371 - Make remaining DOMMediaStream principal sources use MediaStreamTrack. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28745/diff/3-4/
Comment on attachment 8706310 [details]
MozReview Request: Bug 1208371 - Remove some no longer necessary principal methods on DOMMediaStream. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30301/diff/2-3/
Comment on attachment 8711410 [details]
MozReview Request: Bug 1208371 - Add a MediaStreamTrackListener to MediaStreamGraph. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32159/diff/1-2/
Comment on attachment 8676179 [details]
MozReview Request: Bug 1208371 - Move ImageCapture to a MediaStreamTrackListener. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22605/diff/6-7/
Comment on attachment 8676180 [details]
MozReview Request: Bug 1208371 - Make it possible to look up stream id by track in PeerConnectionImpl. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22607/diff/6-7/
Comment on attachment 8676181 [details]
MozReview Request: Bug 1208371 - Fix DOMMediaStream::OwnsTrack. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22609/diff/6-7/
Comment on attachment 8676182 [details]
MozReview Request: Bug 1208371 - Remove MediaStreamTrack::GetStream. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22611/diff/6-7/
Comment on attachment 8681202 [details]
MozReview Request: Bug 1208371 - Route ApplyConstraints through MediaStreamTrackSource. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23771/diff/5-6/
Comment on attachment 8711411 [details]
MozReview Request: Bug 1208371 - Kill nsDOMUserMediaStream with fire. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32161/diff/1-2/
Comment on attachment 8681203 [details]
MozReview Request: Bug 1208371 - Make it possible to block tracks in a MediaInputPort initally. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23773/diff/5-6/
Comment on attachment 8681204 [details]
MozReview Request: Bug 1208371 - Implement MediaStreamTrack::Clone(). r?smaug,jib,roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23775/diff/5-6/
Comment on attachment 8681205 [details]
MozReview Request: Bug 1208371 - Implement DOMMediaStream::Clone() r?smaug,jib,roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23777/diff/5-6/
Comment on attachment 8681206 [details]
MozReview Request: Bug 1208371 - Various cleanups in DOMMediaStream/MediaStreamTrack. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23779/diff/5-6/
Comment on attachment 8681207 [details]
MozReview Request: Bug 1208371 - Forward input stream and track id on regular track changes for union streams. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23781/diff/5-6/
Comment on attachment 8681208 [details]
MozReview Request: Bug 1208371 - Move track.stop() helpers to MediaStreamPlayback. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23783/diff/5-6/
Comment on attachment 8681209 [details]
MozReview Request: Bug 1208371 - Test DOMMediaStream::Clone(). r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23785/diff/5-6/
Comment on attachment 8683551 [details]
MozReview Request: Bug 1208371 - Rename CreateOwnDOMTrack/CreateClonedDOMTrack to CreateDOMTrack/CloneDOMTrack. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/24365/diff/4-5/
Comment on attachment 8705531 [details]
MozReview Request: Bug 1208371 - Resolve ambiguous symbol MediaStreamTrack. r?bwc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/29997/diff/2-3/
Comment on attachment 8705532 [details]
MozReview Request: Bug 1208371 - Test MediaStreamTrack::Clone(). r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/29999/diff/2-3/
Comment on attachment 8676177 [details]
MozReview Request: Bug 1208371 - Let DOMMediaStream base its principal on the tracks it contains. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22601/diff/6-7/
Comment on attachment 8705533 [details]
MozReview Request: Bug 1208371 - Add CORSMode methods to MediaStreamTrack. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30001/diff/2-3/
Comment on attachment 8700524 [details]
MozReview Request: Bug 1208371 - Add an interface DecoderPrincipalChangeObserver to HTMLMediaElement. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28735/diff/3-4/
Comment on attachment 8705534 [details]
MozReview Request: Bug 1208371 - Add convenience method for forwarding a track to an MSG-stream. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30003/diff/2-3/
Comment on attachment 8700525 [details]
MozReview Request: Bug 1208371 - Make HTMLMediaElement::CaptureStream pass its principal to MediaStreamTrack. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28737/diff/3-4/
Comment on attachment 8700526 [details]
MozReview Request: Bug 1208371 - Make MediaManager pass its principal to MediaStreamTrack for gUM. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28739/diff/3-4/
Comment on attachment 8700527 [details]
MozReview Request: Bug 1208371 - Make ImageCapture listen to principal changes of MediaStreamTrack instead. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28741/diff/3-4/
Comment on attachment 8706309 [details]
MozReview Request: Bug 1208371 - Break PCImpl::SetRemoteDescription into smaller pieces. r?mt,bwc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30299/diff/2-3/
Comment on attachment 8700528 [details]
MozReview Request: Bug 1208371 - Make PeerConnectionImpl pass its principal to MediaStreamTrack through a new RemoteTrackSource. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28743/diff/3-4/
Comment on attachment 8700529 [details]
MozReview Request: Bug 1208371 - Make remaining DOMMediaStream principal sources use MediaStreamTrack. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28745/diff/3-4/
Comment on attachment 8706310 [details]
MozReview Request: Bug 1208371 - Remove some no longer necessary principal methods on DOMMediaStream. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30301/diff/2-3/
Comment on attachment 8711410 [details]
MozReview Request: Bug 1208371 - Add a MediaStreamTrackListener to MediaStreamGraph. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32159/diff/1-2/
Comment on attachment 8676179 [details]
MozReview Request: Bug 1208371 - Move ImageCapture to a MediaStreamTrackListener. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22605/diff/6-7/
Comment on attachment 8676180 [details]
MozReview Request: Bug 1208371 - Make it possible to look up stream id by track in PeerConnectionImpl. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22607/diff/6-7/
Comment on attachment 8676181 [details]
MozReview Request: Bug 1208371 - Fix DOMMediaStream::OwnsTrack. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22609/diff/6-7/
Comment on attachment 8676182 [details]
MozReview Request: Bug 1208371 - Remove MediaStreamTrack::GetStream. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22611/diff/6-7/
Comment on attachment 8681202 [details]
MozReview Request: Bug 1208371 - Route ApplyConstraints through MediaStreamTrackSource. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23771/diff/5-6/
Comment on attachment 8711411 [details]
MozReview Request: Bug 1208371 - Kill nsDOMUserMediaStream with fire. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32161/diff/1-2/
Comment on attachment 8681203 [details]
MozReview Request: Bug 1208371 - Make it possible to block tracks in a MediaInputPort initally. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23773/diff/5-6/
Comment on attachment 8681204 [details]
MozReview Request: Bug 1208371 - Implement MediaStreamTrack::Clone(). r?smaug,jib,roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23775/diff/5-6/
Comment on attachment 8681205 [details]
MozReview Request: Bug 1208371 - Implement DOMMediaStream::Clone() r?smaug,jib,roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23777/diff/5-6/
Comment on attachment 8681206 [details]
MozReview Request: Bug 1208371 - Various cleanups in DOMMediaStream/MediaStreamTrack. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23779/diff/5-6/
Comment on attachment 8681207 [details]
MozReview Request: Bug 1208371 - Forward input stream and track id on regular track changes for union streams. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23781/diff/5-6/
Comment on attachment 8681208 [details]
MozReview Request: Bug 1208371 - Move track.stop() helpers to MediaStreamPlayback. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23783/diff/5-6/
Comment on attachment 8681209 [details]
MozReview Request: Bug 1208371 - Test DOMMediaStream::Clone(). r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23785/diff/5-6/
Comment on attachment 8683551 [details]
MozReview Request: Bug 1208371 - Rename CreateOwnDOMTrack/CreateClonedDOMTrack to CreateDOMTrack/CloneDOMTrack. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/24365/diff/4-5/
Comment on attachment 8705531 [details]
MozReview Request: Bug 1208371 - Resolve ambiguous symbol MediaStreamTrack. r?bwc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/29997/diff/2-3/
Comment on attachment 8705532 [details]
MozReview Request: Bug 1208371 - Test MediaStreamTrack::Clone(). r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/29999/diff/2-3/
Comment on attachment 8705533 [details]
MozReview Request: Bug 1208371 - Add CORSMode methods to MediaStreamTrack. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30001/diff/2-3/
Comment on attachment 8705534 [details]
MozReview Request: Bug 1208371 - Add convenience method for forwarding a track to an MSG-stream. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30003/diff/2-3/
Comment on attachment 8705535 [details]
MozReview Request: Bug 1208371 - Lock MediaStreamAudioSourceNode onto the first AudioStreamTrack in mInputStream at time of construction. r?mt,padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30005/diff/2-3/
Comment on attachment 8705536 [details]
MozReview Request: Bug 1208371 - Move HTMLMediaElement::CaptureStream to forward CORSMode changes through MediaStreamTrackSource. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30007/diff/2-3/
Comment on attachment 8705537 [details]
MozReview Request: Bug 1208371 - Remove CORSMode methods from DOMMediaStream. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30009/diff/2-3/
Comment on attachment 8705538 [details]
MozReview Request: Bug 1208371 - Change HTMLMediaElement video sinks to check principal for video only tracks. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30011/diff/2-3/
Comment on attachment 8705539 [details]
MozReview Request: Bug 1208371 - Remove ref counting from DOMMediaStream::TrackListener. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30013/diff/2-3/
Comment on attachment 8705540 [details]
MozReview Request: Bug 1208371 - Update tests to accomodate the fact that MediaStreamAudioSourceNodes lock onto the first audio track. r?padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30015/diff/2-3/
Comment on attachment 8705541 [details]
MozReview Request: Bug 1208371 - Modify WebAudio source nodes tests to wait for tracks befoure measuring nr of samples. r?padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30017/diff/2-3/
Comment on attachment 8705542 [details]
MozReview Request: Bug 1208371 - Make PeerIdentity RefCounted. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30019/diff/2-3/
Comment on attachment 8705543 [details]
MozReview Request: Bug 1208371 - Add GetPeerIdentity() to MediaStreamTrackSource. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30021/diff/2-3/
Comment on attachment 8705545 [details]
MozReview Request: Bug 1208371 - Add PeerIdentity to LocalTrackSource for gUM tracks. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30023/diff/2-3/
Comment on attachment 8705546 [details]
MozReview Request: Bug 1208371 - Move PeerConnection to use PeerIdentity on MediaStreamTrack. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30025/diff/2-3/
Comment on attachment 8705547 [details]
MozReview Request: Bug 1208371 - Remove PeerIdentity from DOMMediaStream. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30027/diff/2-3/
Comment on attachment 8705548 [details]
MozReview Request: Bug 1208371 - Add convenience method for checking track forwarding to MediaStreamTrack. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30029/diff/2-3/
Comment on attachment 8705549 [details]
MozReview Request: Bug 1208371 - Remove test_mediarecorder_record_nosrc.html. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30031/diff/2-3/
Comment on attachment 8705550 [details]
MozReview Request: Bug 1208371 - Inline MediaRecorder::Session::SetupStreams. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30033/diff/2-3/
Comment on attachment 8705551 [details]
MozReview Request: Bug 1208371 - Check principal per track instead of per stream in MediaRecorder. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30035/diff/2-3/
Comment on attachment 8705552 [details]
MozReview Request: Bug 1208371 - Simplify track disabling test code. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30037/diff/2-3/
Comment on attachment 8705553 [details]
MozReview Request: Bug 1208371 - Test disabling track across peerconnection not affecting clones. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30039/diff/2-3/
Comment on attachment 8705554 [details]
MozReview Request: Bug 1208371 - Add DirectTrackLister to MediaStreamGraph and MediaStreamTrack. r?roc,jesup

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30041/diff/2-3/
Comment on attachment 8705555 [details]
MozReview Request: Bug 1208371 - Switch MediaPipeline to use direct listeners on tracks. r?jesup,bwc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30043/diff/2-3/
Comment on attachment 8711412 [details]
MozReview Request: Bug 1208371 - Let PeerConnection consume principals from tracks instead of streams. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32163/diff/1-2/
Comment on attachment 8705556 [details]
MozReview Request: Bug 1208371 - Switch MediaStreamTrack to enable/disable tracks on owned stream. r?jesup

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30045/diff/2-3/
Comment on attachment 8705557 [details]
MozReview Request: Bug 1208371 - Make GraphDriver callback log calls verbose. r?padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30047/diff/2-3/
Comment on attachment 8705558 [details]
MozReview Request: Bug 1208371 - Do not require DOMLocalMediaStream for gUM (audioCapture). r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30049/diff/2-3/
Comment on attachment 8705559 [details]
MozReview Request: Bug 1208371 - Add a track getter to gUM for fake tracks. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30051/diff/2-3/
Comment on attachment 8705560 [details]
MozReview Request: Bug 1208371 - Remove unnecessary fakeTracks:true from test_streams_individual_pause.html. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30053/diff/2-3/
Comment on attachment 8705561 [details]
MozReview Request: Bug 1208371 - Remove debug canvas from addTrackRemoveTrack test to help android perf. r?padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30055/diff/2-3/
Comment on attachment 8705562 [details]
MozReview Request: Bug 1208371 - Remove debug canvas from peerConnection_trackDisabling test to help android perf. r?padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30057/diff/2-3/
Comment on attachment 8705563 [details]
MozReview Request: Bug 1208371 - Enable test_peerConnection_trackDisabling.html on android 4.3 debug. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30059/diff/2-3/
Comment on attachment 8705564 [details]
MozReview Request: Bug 1208371 - Remove debug canvas from mediaStreamConstructors test to help android perf. r?padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30061/diff/2-3/
Comment on attachment 8705565 [details]
MozReview Request: Bug 1208371 - Add disconnect method to test helper AudioStreamAnalyser to improve performance on slow devices. r?padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30063/diff/2-3/
Comment on attachment 8705567 [details]
MozReview Request: Bug 1208371 - Guard LoadManagerSingleton with a WeakPtr. r?pkerr

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30067/diff/2-3/
Comment on attachment 8705568 [details]
MozReview Request: Bug 1208371 - Don't dispatch conduit destruction to main thread when not needed. r?bwc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30069/diff/2-3/
Comment on attachment 8705569 [details]
MozReview Request: Bug 1208371 - Clear output canvas on each drawImage(). r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30071/diff/2-3/
Comment on attachment 8705570 [details]
MozReview Request: Bug 1208371 - Wait for "loadedmetadata" before setting up nodes in test_mediaElementAudioSourceNodeCrossOrigin.html. r?padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30073/diff/2-3/
Comment on attachment 8705571 [details]
MozReview Request: Bug 1208371 - Improve reliability of test_mediarecorder_record_timeslice.html. r?jwwang

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30075/diff/2-3/
Comment on attachment 8711413 [details]
MozReview Request: Bug 1208371 - Assert when stream finishes but contains live tracks. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32165/diff/1-2/
Comment on attachment 8711414 [details]
MozReview Request: Bug 1208371 - Ensure that MediaManager ends all tracks before finishing its source stream. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32167/diff/1-2/
Comment on attachment 8711415 [details]
MozReview Request: Bug 1208371 - Move FindTrack from SourceMediaStream to MediaStream. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32169/diff/1-2/
Attachment #8711416 - Attachment description: MozReview Request: Bug 1208371 - Add principalId to MediaChunks. r?mt,roc → MozReview Request: Bug 1208371 - Add PrincipalID to MediaChunks. r?mt,roc
Attachment #8711416 - Flags: review?(martin.thomson)
Comment on attachment 8711416 [details]
MozReview Request: Bug 1208371 - Add PrincipalHandle to MediaChunks. r?mt,jesup

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32171/diff/1-2/
Comment on attachment 8711417 [details]
MozReview Request: Bug 1208371 - Add `NotifyPrincipalHandleChanged` to MediaStreamTrackListener. r?mt,jesup

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32173/diff/1-2/
Comment on attachment 8711418 [details]
MozReview Request: Bug 1208371 - Add a PrincipalHandleListener to MediaStreamTrack. r?mt,jesup

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32175/diff/1-2/
Comment on attachment 8711419 [details]
MozReview Request: Bug 1208371 - Hook up DecodedStream with PrincipalHandle. r?mt,jwwang

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32177/diff/1-2/
Comment on attachment 8711420 [details]
MozReview Request: Bug 1208371 - Hook up MediaPipeline with PrincipalHandle. r?mt,bwc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32179/diff/1-2/
Comment on attachment 8711421 [details]
MozReview Request: Bug 1208371 - Ensure DOMMediaStream principals reflect what could reside in their playback streams. r?mt,jesup

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32181/diff/1-2/
Attachment #8711421 - Flags: review?(martin.thomson)
Comment on attachment 8711422 [details]
MozReview Request: Bug 1208371 - Ensure a media element's ImageContainer is protected when playing a stream. r?mt,jesup

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32183/diff/1-2/
Comment on attachment 8711423 [details]
MozReview Request: Bug 1208371 - Forward declare MediaStreamTrack in MediaPipeline.h. r?bwc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32185/diff/1-2/
Comment on attachment 8711424 [details]
MozReview Request: Bug 1208371 - Clean up unnecessary virtuals in MediaPipeline. r?bwc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32187/diff/1-2/
Comment on attachment 8711425 [details]
MozReview Request: Bug 1208371 - Move MediaStreamTrack's label to MediaStreamTrackSource. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32189/diff/1-2/
Comment on attachment 8711426 [details]
MozReview Request: Bug 1208371 - Move GetCurrentTime undef to DOMMediaStream.cpp. r?jesup

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32191/diff/1-2/
Comment on attachment 8711427 [details]
MozReview Request: Bug 1208371 - Forward declare MediaStreamGraph classes in MediaPipeline.h. r?bwc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32193/diff/1-2/
Comment on attachment 8711428 [details]
MozReview Request: Bug 1208371 - Forward declare DOMMediaStream in HTMLMediaElement.h. r?jesup

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32195/diff/1-2/
Comment on attachment 8705538 [details]
MozReview Request: Bug 1208371 - Change HTMLMediaElement video sinks to check principal for video only tracks. r?mt

I modified this sufficiently to need another review Martin, thanks.

It's essentially a part 1 change, where part 2 is: https://reviewboard.mozilla.org/r/32183/
Attachment #8705538 - Flags: review+ → review?(martin.thomson)
Attachment #8676177 - Flags: review?(roc)
Attachment #8676177 - Flags: review?(jib)
Attachment #8706309 - Flags: review?(roc)
Attachment #8706310 - Flags: review?(jib)
Try has been looking pretty good, modulo a linux x64 e10s intermittent going crazy with all the PrincipalID stuff wired up.
Here's the latest: https://treeherder.mozilla.org/#/jobs?repo=try&revision=1678e9b22fa0
Comment on attachment 8706309 [details]
MozReview Request: Bug 1208371 - Break PCImpl::SetRemoteDescription into smaller pieces. r?mt,bwc

https://reviewboard.mozilla.org/r/30299/#review29231
Attachment #8706309 - Flags: review?(martin.thomson) → review+
https://reviewboard.mozilla.org/r/32175/#review28857

> Assert that mTrack is not null, or that we're on main thread? I have added the latter.

Yep.  Asserts for non-null just add noise.
Attachment #8711416 - Flags: review?(martin.thomson) → review+
Comment on attachment 8711416 [details]
MozReview Request: Bug 1208371 - Add PrincipalHandle to MediaChunks. r?mt,jesup

https://reviewboard.mozilla.org/r/32171/#review29237

::: dom/media/VideoSegment.cpp:102
(Diff revision 2)
> +                          const PrincipalID&  aPrincipalId,

two spaces
Attachment #8711421 - Flags: review?(martin.thomson) → review+
Comment on attachment 8711421 [details]
MozReview Request: Bug 1208371 - Ensure DOMMediaStream principals reflect what could reside in their playback streams. r?mt,jesup

https://reviewboard.mozilla.org/r/32181/#review29245
Attachment #8705538 - Flags: review?(martin.thomson) → review+
Comment on attachment 8705538 [details]
MozReview Request: Bug 1208371 - Change HTMLMediaElement video sinks to check principal for video only tracks. r?mt

https://reviewboard.mozilla.org/r/30011/#review29603

Looks like one benign mistake below.  BTW, I think that implicit conversion is the worst feature of C++.

::: dom/html/HTMLMediaElement.cpp:4164
(Diff revision 3)
> +    UpdateSrcStreamVideoPrincipal(aStream->GetVideoPrincipal());

Are you missing a call to the converter function here?  Or is the signature to UpdateSrcStreamVideoPrincipal() supposed to take a `const nsCOMPtr<nsIPrincipal>&` argument instead?
https://reviewboard.mozilla.org/r/30011/#review29603

> Are you missing a call to the converter function here?  Or is the signature to UpdateSrcStreamVideoPrincipal() supposed to take a `const nsCOMPtr<nsIPrincipal>&` argument instead?

This patch comes before the one that introduces PrincipalID. I found it locally and changed `UpdateSrcStreamVideoPrincipal()` to take an `nsIPrincipal*` instead. It gets changed to const PrincipalID& when `UpdateSrcStreamVideoPrincipal()` gets its full implementation later.
Comment on attachment 8700524 [details]
MozReview Request: Bug 1208371 - Add an interface DecoderPrincipalChangeObserver to HTMLMediaElement. r?roc

https://reviewboard.mozilla.org/r/28735/#review29711
Comment on attachment 8711410 [details]
MozReview Request: Bug 1208371 - Add a MediaStreamTrackListener to MediaStreamGraph. r?roc

https://reviewboard.mozilla.org/r/32159/#review29713

::: dom/media/MediaStreamGraph.h:241
(Diff revision 2)
> +  virtual void NotifyQueuedTrackChanges(MediaStreamGraph* aGraph,

Call it NotifyQueuedChanges since it's clearly on a track

::: dom/media/MediaStreamGraph.h:245
(Diff revision 2)
> +  virtual void NotifyTrackEnded() {}

NotifyEnded
Attachment #8711410 - Flags: review?(roc) → review+
Comment on attachment 8676179 [details]
MozReview Request: Bug 1208371 - Move ImageCapture to a MediaStreamTrackListener. r?roc

https://reviewboard.mozilla.org/r/22605/#review29715
Attachment #8676179 - Flags: review?(roc) → review+
Many patches here are going to conflict with ctai's work, but I guess clone() should land first.
Comment on attachment 8705554 [details]
MozReview Request: Bug 1208371 - Add DirectTrackLister to MediaStreamGraph and MediaStreamTrack. r?roc,jesup

https://reviewboard.mozilla.org/r/30041/#review29717

::: dom/media/MediaStreamGraph.h:289
(Diff revision 3)
> +                                       const MediaSegment& aMedia) {}

Can we make this audio-only? I don't think we want this for other types.

::: dom/media/MediaStreamGraph.h:293
(Diff revision 3)
> +    STREAM_NOT_SUPPORTED,

Please explain what these mean

::: dom/media/MediaStreamTrack.h:311
(Diff revision 3)
> +  void AddDirectListener(MediaStreamTrackDirectListener *aListener);

Somewhere you'd better explain that the direct listener gets attached to the upstream source of the track.
Comment on attachment 8711413 [details]
MozReview Request: Bug 1208371 - Assert when stream finishes but contains live tracks. r?roc

https://reviewboard.mozilla.org/r/32165/#review29719
Attachment #8711413 - Flags: review?(roc) → review+
Comment on attachment 8711415 [details]
MozReview Request: Bug 1208371 - Move FindTrack from SourceMediaStream to MediaStream. r?roc

https://reviewboard.mozilla.org/r/32169/#review29721
Attachment #8711415 - Flags: review?(roc) → review+
Comment on attachment 8711416 [details]
MozReview Request: Bug 1208371 - Add PrincipalHandle to MediaChunks. r?mt,jesup

https://reviewboard.mozilla.org/r/32171/#review29723

::: dom/media/MediaSegment.h:62
(Diff revision 2)
> +typedef void* PrincipalID;

Can you explain somewhere how lifetime management works? How do we know that the underlying nsIPrincipal remains alive as long as all PrincipalID versions of it?
Comment on attachment 8711417 [details]
MozReview Request: Bug 1208371 - Add `NotifyPrincipalHandleChanged` to MediaStreamTrackListener. r?mt,jesup

https://reviewboard.mozilla.org/r/32173/#review29725
Comment on attachment 8711418 [details]
MozReview Request: Bug 1208371 - Add a PrincipalHandleListener to MediaStreamTrack. r?mt,jesup

https://reviewboard.mozilla.org/r/32175/#review29727

::: dom/media/MediaStreamTrack.cpp:47
(Diff revision 2)
> +class MediaStreamTrack::PrincipalIdListener : public MediaStreamTrackListener

Add a comment explaining what this class is for.

I guess it's to ensure that the principal is kept alive for the right amount of time ... but in that case, shouldn't this patch be applied earlier to avoid test failures?
Attachment #8711418 - Flags: review?(roc)
Comment on attachment 8711421 [details]
MozReview Request: Bug 1208371 - Ensure DOMMediaStream principals reflect what could reside in their playback streams. r?mt,jesup

https://reviewboard.mozilla.org/r/32181/#review29729
Attachment #8711421 - Flags: review?(roc) → review+
Comment on attachment 8711422 [details]
MozReview Request: Bug 1208371 - Ensure a media element's ImageContainer is protected when playing a stream. r?mt,jesup

https://reviewboard.mozilla.org/r/32183/#review29731
Attachment #8711422 - Flags: review?(roc) → review+
Comment on attachment 8711428 [details]
MozReview Request: Bug 1208371 - Forward declare DOMMediaStream in HTMLMediaElement.h. r?jesup

https://reviewboard.mozilla.org/r/32195/#review29733
https://reviewboard.mozilla.org/r/32171/#review29723

> Can you explain somewhere how lifetime management works? How do we know that the underlying nsIPrincipal remains alive as long as all PrincipalID versions of it?

It doesn't matter as long as we never upcast from `PrincipalID` aka `void*` to `nsIPrincipal*`. I'll explain that doing that is really bad.
https://reviewboard.mozilla.org/r/32175/#review29727

> Add a comment explaining what this class is for.
> 
> I guess it's to ensure that the principal is kept alive for the right amount of time ... but in that case, shouldn't this patch be applied earlier to avoid test failures?

It is to monitor when the source's PrincipalID changes. If the new PrincipalID matches the desired main thread principal of the track, we will update the track's principal.

So, the main thread principal change happens first, at which point the track makes its principal a combination of the new principal and the old. When the change has been confirmed in data flow by MSG, it will update its principal to be the new one.

Should multiple principal changes happen on main thread before they do on MSG thread, we'll have to wait with setting the principal to the latest main thread one until things have stabilized; i.e., the main thread state will be a combination of all those principals until the latest one comes through on MSG thread.

Added some comments on this.
Comment on attachment 8676157 [details]
MozReview Request: Bug 1208371 - Pass parent window to DOMMediaStream through constructor. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22567/diff/5-6/
Comment on attachment 8676159 [details]
MozReview Request: Bug 1208371 - Make AudioCaptureStream startable. r?padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22569/diff/5-6/
Comment on attachment 8676160 [details]
MozReview Request: Bug 1208371 - Move OnTracksAvailableCallback out of DOMMediaStream. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22571/diff/5-6/
Comment on attachment 8676161 [details]
MozReview Request: Bug 1208371 - Remove unused MediaManager::NotifyMediaStreamTrackEnded. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22573/diff/5-6/
Comment on attachment 8676162 [details]
MozReview Request: Bug 1208371 - Introduce MediaStreamTrack logs. r?roc,jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22575/diff/5-6/
Comment on attachment 8676163 [details]
MozReview Request: Bug 1208371 - Track original track in MediaStreamTrack clones. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22577/diff/5-6/
Comment on attachment 8676164 [details]
MozReview Request: Bug 1208371 - Un-nest MediaEngineSource::PhotoCallback. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22579/diff/5-6/
Comment on attachment 8676168 [details]
MozReview Request: Bug 1208371 - Add a MediaStreamTrackSource interface. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22583/diff/6-7/
Comment on attachment 8676169 [details]
MozReview Request: Bug 1208371 - Add MediaStreamTrackSourceGetter interface. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22585/diff/6-7/
Comment on attachment 8676170 [details]
MozReview Request: Bug 1208371 - Let MediaStreamTracks know their TrackID at the source. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22587/diff/6-7/
Comment on attachment 8676171 [details]
MozReview Request: Bug 1208371 - Let FindOwnedDOMTrack operate on input stream. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22589/diff/6-7/
Comment on attachment 8676172 [details]
MozReview Request: Bug 1208371 - Add some MediaStreamTrack helper methods. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22591/diff/6-7/
Comment on attachment 8676173 [details]
MozReview Request: Bug 1208371 - Count the users of a MediaStream to ease Destroy() responsibility. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22593/diff/6-7/
Comment on attachment 8676174 [details]
MozReview Request: Bug 1208371 - Add convenience method for checking if TrackID is explicit. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22595/diff/6-7/
Comment on attachment 8676175 [details]
MozReview Request: Bug 1208371 - Allow MediaInputPorts mapped to a destination TrackID. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22597/diff/6-7/
Comment on attachment 8676176 [details]
MozReview Request: Bug 1208371 - Remove obsolete SetTrackEnabled() from DOMMediaStream r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22599/diff/6-7/
Comment on attachment 8676165 [details]
MozReview Request: Bug 1208371 - Add MediaStreamTrack::Graph(). r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22581/diff/6-7/
Comment on attachment 8676178 [details]
MozReview Request: Bug 1208371 - Add DOMMediaStream::GetTrackById/GetOwnedTrackById. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22603/diff/6-7/
Comment on attachment 8700523 [details]
MozReview Request: Bug 1208371 - Add a generic PrincipalChangeObserver interface. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28733/diff/3-4/
Attachment #8705566 - Flags: review?(padenot)
Comment on attachment 8705566 [details]
MozReview Request: Bug 1208371 - Turn DOMMediaStream::PrincipalChangeObserver into PrincipalChangeObserver<DOMMediaStream>. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30065/diff/2-3/
Comment on attachment 8700521 [details]
MozReview Request: Bug 1208371 - Add principal APIs to MediaStreamTrack. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28729/diff/3-4/
Comment on attachment 8700522 [details]
MozReview Request: Bug 1208371 - Create MediaStreamTrackSource::Sink that forwards principal changes from the source. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28731/diff/3-4/
Attachment #8676177 - Flags: review?(roc)
Attachment #8676177 - Flags: review?(jib)
Comment on attachment 8676177 [details]
MozReview Request: Bug 1208371 - Let DOMMediaStream base its principal on the tracks it contains. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22601/diff/7-8/
Comment on attachment 8700524 [details]
MozReview Request: Bug 1208371 - Add an interface DecoderPrincipalChangeObserver to HTMLMediaElement. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28735/diff/4-5/
Comment on attachment 8700525 [details]
MozReview Request: Bug 1208371 - Make HTMLMediaElement::CaptureStream pass its principal to MediaStreamTrack. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28737/diff/4-5/
Comment on attachment 8700526 [details]
MozReview Request: Bug 1208371 - Make MediaManager pass its principal to MediaStreamTrack for gUM. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28739/diff/4-5/
Comment on attachment 8700527 [details]
MozReview Request: Bug 1208371 - Make ImageCapture listen to principal changes of MediaStreamTrack instead. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28741/diff/4-5/
Comment on attachment 8706309 [details]
MozReview Request: Bug 1208371 - Break PCImpl::SetRemoteDescription into smaller pieces. r?mt,bwc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30299/diff/3-4/
Attachment #8706309 - Flags: review?(roc)
Comment on attachment 8700528 [details]
MozReview Request: Bug 1208371 - Make PeerConnectionImpl pass its principal to MediaStreamTrack through a new RemoteTrackSource. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28743/diff/4-5/
Comment on attachment 8700529 [details]
MozReview Request: Bug 1208371 - Make remaining DOMMediaStream principal sources use MediaStreamTrack. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28745/diff/4-5/
Comment on attachment 8706310 [details]
MozReview Request: Bug 1208371 - Remove some no longer necessary principal methods on DOMMediaStream. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30301/diff/3-4/
Attachment #8706310 - Flags: review?(jib)
Comment on attachment 8711410 [details]
MozReview Request: Bug 1208371 - Add a MediaStreamTrackListener to MediaStreamGraph. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32159/diff/2-3/
Comment on attachment 8676179 [details]
MozReview Request: Bug 1208371 - Move ImageCapture to a MediaStreamTrackListener. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22605/diff/7-8/
Comment on attachment 8676180 [details]
MozReview Request: Bug 1208371 - Make it possible to look up stream id by track in PeerConnectionImpl. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22607/diff/7-8/
Comment on attachment 8676181 [details]
MozReview Request: Bug 1208371 - Fix DOMMediaStream::OwnsTrack. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22609/diff/7-8/
Comment on attachment 8676182 [details]
MozReview Request: Bug 1208371 - Remove MediaStreamTrack::GetStream. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22611/diff/7-8/
Comment on attachment 8681202 [details]
MozReview Request: Bug 1208371 - Route ApplyConstraints through MediaStreamTrackSource. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23771/diff/6-7/
Comment on attachment 8711411 [details]
MozReview Request: Bug 1208371 - Kill nsDOMUserMediaStream with fire. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32161/diff/2-3/
Comment on attachment 8681203 [details]
MozReview Request: Bug 1208371 - Make it possible to block tracks in a MediaInputPort initally. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23773/diff/6-7/
Comment on attachment 8681204 [details]
MozReview Request: Bug 1208371 - Implement MediaStreamTrack::Clone(). r?smaug,jib,roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23775/diff/6-7/
Comment on attachment 8681205 [details]
MozReview Request: Bug 1208371 - Implement DOMMediaStream::Clone() r?smaug,jib,roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23777/diff/6-7/
Comment on attachment 8681206 [details]
MozReview Request: Bug 1208371 - Various cleanups in DOMMediaStream/MediaStreamTrack. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23779/diff/6-7/
Comment on attachment 8681207 [details]
MozReview Request: Bug 1208371 - Forward input stream and track id on regular track changes for union streams. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23781/diff/6-7/
Comment on attachment 8681208 [details]
MozReview Request: Bug 1208371 - Move track.stop() helpers to MediaStreamPlayback. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23783/diff/6-7/
Comment on attachment 8681209 [details]
MozReview Request: Bug 1208371 - Test DOMMediaStream::Clone(). r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23785/diff/6-7/
Comment on attachment 8683551 [details]
MozReview Request: Bug 1208371 - Rename CreateOwnDOMTrack/CreateClonedDOMTrack to CreateDOMTrack/CloneDOMTrack. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/24365/diff/5-6/
Comment on attachment 8705531 [details]
MozReview Request: Bug 1208371 - Resolve ambiguous symbol MediaStreamTrack. r?bwc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/29997/diff/3-4/
Comment on attachment 8705532 [details]
MozReview Request: Bug 1208371 - Test MediaStreamTrack::Clone(). r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/29999/diff/3-4/
Comment on attachment 8705533 [details]
MozReview Request: Bug 1208371 - Add CORSMode methods to MediaStreamTrack. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30001/diff/3-4/
Comment on attachment 8705534 [details]
MozReview Request: Bug 1208371 - Add convenience method for forwarding a track to an MSG-stream. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30003/diff/3-4/
Comment on attachment 8705535 [details]
MozReview Request: Bug 1208371 - Lock MediaStreamAudioSourceNode onto the first AudioStreamTrack in mInputStream at time of construction. r?mt,padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30005/diff/3-4/
Comment on attachment 8705536 [details]
MozReview Request: Bug 1208371 - Move HTMLMediaElement::CaptureStream to forward CORSMode changes through MediaStreamTrackSource. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30007/diff/3-4/
Comment on attachment 8705537 [details]
MozReview Request: Bug 1208371 - Remove CORSMode methods from DOMMediaStream. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30009/diff/3-4/
Comment on attachment 8705538 [details]
MozReview Request: Bug 1208371 - Change HTMLMediaElement video sinks to check principal for video only tracks. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30011/diff/3-4/
Comment on attachment 8705539 [details]
MozReview Request: Bug 1208371 - Remove ref counting from DOMMediaStream::TrackListener. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30013/diff/3-4/
Comment on attachment 8705540 [details]
MozReview Request: Bug 1208371 - Update tests to accomodate the fact that MediaStreamAudioSourceNodes lock onto the first audio track. r?padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30015/diff/3-4/
Comment on attachment 8705541 [details]
MozReview Request: Bug 1208371 - Modify WebAudio source nodes tests to wait for tracks befoure measuring nr of samples. r?padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30017/diff/3-4/
Comment on attachment 8705542 [details]
MozReview Request: Bug 1208371 - Make PeerIdentity RefCounted. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30019/diff/3-4/
Comment on attachment 8705543 [details]
MozReview Request: Bug 1208371 - Add GetPeerIdentity() to MediaStreamTrackSource. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30021/diff/3-4/
Comment on attachment 8705545 [details]
MozReview Request: Bug 1208371 - Add PeerIdentity to LocalTrackSource for gUM tracks. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30023/diff/3-4/
Comment on attachment 8705546 [details]
MozReview Request: Bug 1208371 - Move PeerConnection to use PeerIdentity on MediaStreamTrack. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30025/diff/3-4/
Comment on attachment 8705547 [details]
MozReview Request: Bug 1208371 - Remove PeerIdentity from DOMMediaStream. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30027/diff/3-4/
Comment on attachment 8705548 [details]
MozReview Request: Bug 1208371 - Add convenience method for checking track forwarding to MediaStreamTrack. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30029/diff/3-4/
Comment on attachment 8705549 [details]
MozReview Request: Bug 1208371 - Remove test_mediarecorder_record_nosrc.html. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30031/diff/3-4/
Comment on attachment 8705550 [details]
MozReview Request: Bug 1208371 - Inline MediaRecorder::Session::SetupStreams. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30033/diff/3-4/
Comment on attachment 8705551 [details]
MozReview Request: Bug 1208371 - Check principal per track instead of per stream in MediaRecorder. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30035/diff/3-4/
Comment on attachment 8705552 [details]
MozReview Request: Bug 1208371 - Simplify track disabling test code. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30037/diff/3-4/
Comment on attachment 8705553 [details]
MozReview Request: Bug 1208371 - Test disabling track across peerconnection not affecting clones. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30039/diff/3-4/
Comment on attachment 8705554 [details]
MozReview Request: Bug 1208371 - Add DirectTrackLister to MediaStreamGraph and MediaStreamTrack. r?roc,jesup

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30041/diff/3-4/
Attachment #8705554 - Flags: review?(roc)
Comment on attachment 8705555 [details]
MozReview Request: Bug 1208371 - Switch MediaPipeline to use direct listeners on tracks. r?jesup,bwc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30043/diff/3-4/
Comment on attachment 8711412 [details]
MozReview Request: Bug 1208371 - Let PeerConnection consume principals from tracks instead of streams. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32163/diff/2-3/
Comment on attachment 8705556 [details]
MozReview Request: Bug 1208371 - Switch MediaStreamTrack to enable/disable tracks on owned stream. r?jesup

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30045/diff/3-4/
Comment on attachment 8705557 [details]
MozReview Request: Bug 1208371 - Make GraphDriver callback log calls verbose. r?padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30047/diff/3-4/
Comment on attachment 8705558 [details]
MozReview Request: Bug 1208371 - Do not require DOMLocalMediaStream for gUM (audioCapture). r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30049/diff/3-4/
Comment on attachment 8705559 [details]
MozReview Request: Bug 1208371 - Add a track getter to gUM for fake tracks. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30051/diff/3-4/
Comment on attachment 8705560 [details]
MozReview Request: Bug 1208371 - Remove unnecessary fakeTracks:true from test_streams_individual_pause.html. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30053/diff/3-4/
Comment on attachment 8705561 [details]
MozReview Request: Bug 1208371 - Remove debug canvas from addTrackRemoveTrack test to help android perf. r?padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30055/diff/3-4/
Comment on attachment 8705562 [details]
MozReview Request: Bug 1208371 - Remove debug canvas from peerConnection_trackDisabling test to help android perf. r?padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30057/diff/3-4/
Comment on attachment 8705563 [details]
MozReview Request: Bug 1208371 - Enable test_peerConnection_trackDisabling.html on android 4.3 debug. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30059/diff/3-4/
Comment on attachment 8705564 [details]
MozReview Request: Bug 1208371 - Remove debug canvas from mediaStreamConstructors test to help android perf. r?padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30061/diff/3-4/
Comment on attachment 8676157 [details]
MozReview Request: Bug 1208371 - Pass parent window to DOMMediaStream through constructor. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22567/diff/5-6/
Comment on attachment 8676159 [details]
MozReview Request: Bug 1208371 - Make AudioCaptureStream startable. r?padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22569/diff/5-6/
Comment on attachment 8676160 [details]
MozReview Request: Bug 1208371 - Move OnTracksAvailableCallback out of DOMMediaStream. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22571/diff/5-6/
Comment on attachment 8676161 [details]
MozReview Request: Bug 1208371 - Remove unused MediaManager::NotifyMediaStreamTrackEnded. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22573/diff/5-6/
Comment on attachment 8676162 [details]
MozReview Request: Bug 1208371 - Introduce MediaStreamTrack logs. r?roc,jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22575/diff/5-6/
Comment on attachment 8676163 [details]
MozReview Request: Bug 1208371 - Track original track in MediaStreamTrack clones. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22577/diff/5-6/
Comment on attachment 8676164 [details]
MozReview Request: Bug 1208371 - Un-nest MediaEngineSource::PhotoCallback. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22579/diff/5-6/
Comment on attachment 8676168 [details]
MozReview Request: Bug 1208371 - Add a MediaStreamTrackSource interface. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22583/diff/6-7/
Comment on attachment 8676169 [details]
MozReview Request: Bug 1208371 - Add MediaStreamTrackSourceGetter interface. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22585/diff/6-7/
Comment on attachment 8676170 [details]
MozReview Request: Bug 1208371 - Let MediaStreamTracks know their TrackID at the source. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22587/diff/6-7/
Comment on attachment 8676171 [details]
MozReview Request: Bug 1208371 - Let FindOwnedDOMTrack operate on input stream. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22589/diff/6-7/
Comment on attachment 8676172 [details]
MozReview Request: Bug 1208371 - Add some MediaStreamTrack helper methods. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22591/diff/6-7/
Comment on attachment 8676173 [details]
MozReview Request: Bug 1208371 - Count the users of a MediaStream to ease Destroy() responsibility. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22593/diff/6-7/
Comment on attachment 8676174 [details]
MozReview Request: Bug 1208371 - Add convenience method for checking if TrackID is explicit. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22595/diff/6-7/
Comment on attachment 8676175 [details]
MozReview Request: Bug 1208371 - Allow MediaInputPorts mapped to a destination TrackID. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22597/diff/6-7/
Comment on attachment 8676176 [details]
MozReview Request: Bug 1208371 - Remove obsolete SetTrackEnabled() from DOMMediaStream r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22599/diff/6-7/
Comment on attachment 8676165 [details]
MozReview Request: Bug 1208371 - Add MediaStreamTrack::Graph(). r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22581/diff/6-7/
Comment on attachment 8676178 [details]
MozReview Request: Bug 1208371 - Add DOMMediaStream::GetTrackById/GetOwnedTrackById. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22603/diff/6-7/
Comment on attachment 8700523 [details]
MozReview Request: Bug 1208371 - Add a generic PrincipalChangeObserver interface. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28733/diff/3-4/
Comment on attachment 8705566 [details]
MozReview Request: Bug 1208371 - Turn DOMMediaStream::PrincipalChangeObserver into PrincipalChangeObserver<DOMMediaStream>. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30065/diff/2-3/
Comment on attachment 8700521 [details]
MozReview Request: Bug 1208371 - Add principal APIs to MediaStreamTrack. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28729/diff/3-4/
Comment on attachment 8700522 [details]
MozReview Request: Bug 1208371 - Create MediaStreamTrackSource::Sink that forwards principal changes from the source. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28731/diff/3-4/
Comment on attachment 8676177 [details]
MozReview Request: Bug 1208371 - Let DOMMediaStream base its principal on the tracks it contains. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22601/diff/7-8/
Comment on attachment 8700524 [details]
MozReview Request: Bug 1208371 - Add an interface DecoderPrincipalChangeObserver to HTMLMediaElement. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28735/diff/4-5/
Comment on attachment 8700525 [details]
MozReview Request: Bug 1208371 - Make HTMLMediaElement::CaptureStream pass its principal to MediaStreamTrack. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28737/diff/4-5/
Comment on attachment 8700526 [details]
MozReview Request: Bug 1208371 - Make MediaManager pass its principal to MediaStreamTrack for gUM. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28739/diff/4-5/
Comment on attachment 8700527 [details]
MozReview Request: Bug 1208371 - Make ImageCapture listen to principal changes of MediaStreamTrack instead. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28741/diff/4-5/
Comment on attachment 8706309 [details]
MozReview Request: Bug 1208371 - Break PCImpl::SetRemoteDescription into smaller pieces. r?mt,bwc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30299/diff/3-4/
Comment on attachment 8700528 [details]
MozReview Request: Bug 1208371 - Make PeerConnectionImpl pass its principal to MediaStreamTrack through a new RemoteTrackSource. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28743/diff/4-5/
Comment on attachment 8700529 [details]
MozReview Request: Bug 1208371 - Make remaining DOMMediaStream principal sources use MediaStreamTrack. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28745/diff/4-5/
Comment on attachment 8706310 [details]
MozReview Request: Bug 1208371 - Remove some no longer necessary principal methods on DOMMediaStream. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30301/diff/3-4/
Comment on attachment 8711410 [details]
MozReview Request: Bug 1208371 - Add a MediaStreamTrackListener to MediaStreamGraph. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32159/diff/2-3/
Comment on attachment 8676179 [details]
MozReview Request: Bug 1208371 - Move ImageCapture to a MediaStreamTrackListener. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22605/diff/7-8/
Comment on attachment 8676180 [details]
MozReview Request: Bug 1208371 - Make it possible to look up stream id by track in PeerConnectionImpl. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22607/diff/7-8/
Comment on attachment 8676181 [details]
MozReview Request: Bug 1208371 - Fix DOMMediaStream::OwnsTrack. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22609/diff/7-8/
Comment on attachment 8676182 [details]
MozReview Request: Bug 1208371 - Remove MediaStreamTrack::GetStream. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22611/diff/7-8/
Comment on attachment 8681202 [details]
MozReview Request: Bug 1208371 - Route ApplyConstraints through MediaStreamTrackSource. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23771/diff/6-7/
Comment on attachment 8711411 [details]
MozReview Request: Bug 1208371 - Kill nsDOMUserMediaStream with fire. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32161/diff/2-3/
Comment on attachment 8681203 [details]
MozReview Request: Bug 1208371 - Make it possible to block tracks in a MediaInputPort initally. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23773/diff/6-7/
Comment on attachment 8681204 [details]
MozReview Request: Bug 1208371 - Implement MediaStreamTrack::Clone(). r?smaug,jib,roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23775/diff/6-7/
Comment on attachment 8681205 [details]
MozReview Request: Bug 1208371 - Implement DOMMediaStream::Clone() r?smaug,jib,roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23777/diff/6-7/
Comment on attachment 8681206 [details]
MozReview Request: Bug 1208371 - Various cleanups in DOMMediaStream/MediaStreamTrack. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23779/diff/6-7/
Comment on attachment 8681207 [details]
MozReview Request: Bug 1208371 - Forward input stream and track id on regular track changes for union streams. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23781/diff/6-7/
Comment on attachment 8681208 [details]
MozReview Request: Bug 1208371 - Move track.stop() helpers to MediaStreamPlayback. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23783/diff/6-7/
Comment on attachment 8681209 [details]
MozReview Request: Bug 1208371 - Test DOMMediaStream::Clone(). r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23785/diff/6-7/
Comment on attachment 8683551 [details]
MozReview Request: Bug 1208371 - Rename CreateOwnDOMTrack/CreateClonedDOMTrack to CreateDOMTrack/CloneDOMTrack. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/24365/diff/5-6/
Comment on attachment 8705531 [details]
MozReview Request: Bug 1208371 - Resolve ambiguous symbol MediaStreamTrack. r?bwc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/29997/diff/3-4/
Comment on attachment 8705532 [details]
MozReview Request: Bug 1208371 - Test MediaStreamTrack::Clone(). r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/29999/diff/3-4/
Comment on attachment 8705533 [details]
MozReview Request: Bug 1208371 - Add CORSMode methods to MediaStreamTrack. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30001/diff/3-4/
Comment on attachment 8705534 [details]
MozReview Request: Bug 1208371 - Add convenience method for forwarding a track to an MSG-stream. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30003/diff/3-4/
Comment on attachment 8705535 [details]
MozReview Request: Bug 1208371 - Lock MediaStreamAudioSourceNode onto the first AudioStreamTrack in mInputStream at time of construction. r?mt,padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30005/diff/3-4/
Comment on attachment 8705536 [details]
MozReview Request: Bug 1208371 - Move HTMLMediaElement::CaptureStream to forward CORSMode changes through MediaStreamTrackSource. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30007/diff/3-4/
Comment on attachment 8705537 [details]
MozReview Request: Bug 1208371 - Remove CORSMode methods from DOMMediaStream. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30009/diff/3-4/
Comment on attachment 8705538 [details]
MozReview Request: Bug 1208371 - Change HTMLMediaElement video sinks to check principal for video only tracks. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30011/diff/3-4/
Comment on attachment 8705539 [details]
MozReview Request: Bug 1208371 - Remove ref counting from DOMMediaStream::TrackListener. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30013/diff/3-4/
Comment on attachment 8705540 [details]
MozReview Request: Bug 1208371 - Update tests to accomodate the fact that MediaStreamAudioSourceNodes lock onto the first audio track. r?padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30015/diff/3-4/
Comment on attachment 8705541 [details]
MozReview Request: Bug 1208371 - Modify WebAudio source nodes tests to wait for tracks befoure measuring nr of samples. r?padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30017/diff/3-4/
Comment on attachment 8705542 [details]
MozReview Request: Bug 1208371 - Make PeerIdentity RefCounted. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30019/diff/3-4/
Comment on attachment 8705543 [details]
MozReview Request: Bug 1208371 - Add GetPeerIdentity() to MediaStreamTrackSource. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30021/diff/3-4/
Comment on attachment 8705545 [details]
MozReview Request: Bug 1208371 - Add PeerIdentity to LocalTrackSource for gUM tracks. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30023/diff/3-4/
Comment on attachment 8705546 [details]
MozReview Request: Bug 1208371 - Move PeerConnection to use PeerIdentity on MediaStreamTrack. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30025/diff/3-4/
Comment on attachment 8705547 [details]
MozReview Request: Bug 1208371 - Remove PeerIdentity from DOMMediaStream. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30027/diff/3-4/
Comment on attachment 8705548 [details]
MozReview Request: Bug 1208371 - Add convenience method for checking track forwarding to MediaStreamTrack. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30029/diff/3-4/
Comment on attachment 8705549 [details]
MozReview Request: Bug 1208371 - Remove test_mediarecorder_record_nosrc.html. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30031/diff/3-4/
Comment on attachment 8705550 [details]
MozReview Request: Bug 1208371 - Inline MediaRecorder::Session::SetupStreams. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30033/diff/3-4/
Comment on attachment 8705551 [details]
MozReview Request: Bug 1208371 - Check principal per track instead of per stream in MediaRecorder. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30035/diff/3-4/
Comment on attachment 8705552 [details]
MozReview Request: Bug 1208371 - Simplify track disabling test code. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30037/diff/3-4/
Comment on attachment 8705553 [details]
MozReview Request: Bug 1208371 - Test disabling track across peerconnection not affecting clones. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30039/diff/3-4/
Comment on attachment 8705554 [details]
MozReview Request: Bug 1208371 - Add DirectTrackLister to MediaStreamGraph and MediaStreamTrack. r?roc,jesup

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30041/diff/3-4/
Comment on attachment 8705555 [details]
MozReview Request: Bug 1208371 - Switch MediaPipeline to use direct listeners on tracks. r?jesup,bwc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30043/diff/3-4/
Comment on attachment 8711412 [details]
MozReview Request: Bug 1208371 - Let PeerConnection consume principals from tracks instead of streams. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32163/diff/2-3/
Comment on attachment 8705556 [details]
MozReview Request: Bug 1208371 - Switch MediaStreamTrack to enable/disable tracks on owned stream. r?jesup

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30045/diff/3-4/
Comment on attachment 8705557 [details]
MozReview Request: Bug 1208371 - Make GraphDriver callback log calls verbose. r?padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30047/diff/3-4/
Comment on attachment 8705558 [details]
MozReview Request: Bug 1208371 - Do not require DOMLocalMediaStream for gUM (audioCapture). r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30049/diff/3-4/
Comment on attachment 8705559 [details]
MozReview Request: Bug 1208371 - Add a track getter to gUM for fake tracks. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30051/diff/3-4/
Comment on attachment 8705560 [details]
MozReview Request: Bug 1208371 - Remove unnecessary fakeTracks:true from test_streams_individual_pause.html. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30053/diff/3-4/
Comment on attachment 8705561 [details]
MozReview Request: Bug 1208371 - Remove debug canvas from addTrackRemoveTrack test to help android perf. r?padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30055/diff/3-4/
Comment on attachment 8705562 [details]
MozReview Request: Bug 1208371 - Remove debug canvas from peerConnection_trackDisabling test to help android perf. r?padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30057/diff/3-4/
Comment on attachment 8705563 [details]
MozReview Request: Bug 1208371 - Enable test_peerConnection_trackDisabling.html on android 4.3 debug. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30059/diff/3-4/
Comment on attachment 8705564 [details]
MozReview Request: Bug 1208371 - Remove debug canvas from mediaStreamConstructors test to help android perf. r?padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30061/diff/3-4/
Comment on attachment 8705565 [details]
MozReview Request: Bug 1208371 - Add disconnect method to test helper AudioStreamAnalyser to improve performance on slow devices. r?padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30063/diff/3-4/
Comment on attachment 8705567 [details]
MozReview Request: Bug 1208371 - Guard LoadManagerSingleton with a WeakPtr. r?pkerr

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30067/diff/3-4/
Comment on attachment 8705568 [details]
MozReview Request: Bug 1208371 - Don't dispatch conduit destruction to main thread when not needed. r?bwc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30069/diff/3-4/
Comment on attachment 8705569 [details]
MozReview Request: Bug 1208371 - Clear output canvas on each drawImage(). r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30071/diff/3-4/
Comment on attachment 8705570 [details]
MozReview Request: Bug 1208371 - Wait for "loadedmetadata" before setting up nodes in test_mediaElementAudioSourceNodeCrossOrigin.html. r?padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30073/diff/3-4/
Comment on attachment 8705571 [details]
MozReview Request: Bug 1208371 - Improve reliability of test_mediarecorder_record_timeslice.html. r?jwwang

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30075/diff/3-4/
Comment on attachment 8711413 [details]
MozReview Request: Bug 1208371 - Assert when stream finishes but contains live tracks. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32165/diff/2-3/
Comment on attachment 8711414 [details]
MozReview Request: Bug 1208371 - Ensure that MediaManager ends all tracks before finishing its source stream. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32167/diff/2-3/
Comment on attachment 8711415 [details]
MozReview Request: Bug 1208371 - Move FindTrack from SourceMediaStream to MediaStream. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32169/diff/2-3/
Comment on attachment 8711416 [details]
MozReview Request: Bug 1208371 - Add PrincipalHandle to MediaChunks. r?mt,jesup

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32171/diff/2-3/
Attachment #8711416 - Flags: review?(roc)
Comment on attachment 8711417 [details]
MozReview Request: Bug 1208371 - Add `NotifyPrincipalHandleChanged` to MediaStreamTrackListener. r?mt,jesup

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32173/diff/2-3/
Comment on attachment 8711418 [details]
MozReview Request: Bug 1208371 - Add a PrincipalHandleListener to MediaStreamTrack. r?mt,jesup

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32175/diff/2-3/
Attachment #8711418 - Flags: review?(roc)
Comment on attachment 8711419 [details]
MozReview Request: Bug 1208371 - Hook up DecodedStream with PrincipalHandle. r?mt,jwwang

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32177/diff/2-3/
Comment on attachment 8711420 [details]
MozReview Request: Bug 1208371 - Hook up MediaPipeline with PrincipalHandle. r?mt,bwc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32179/diff/2-3/
Comment on attachment 8711421 [details]
MozReview Request: Bug 1208371 - Ensure DOMMediaStream principals reflect what could reside in their playback streams. r?mt,jesup

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32181/diff/2-3/
Comment on attachment 8711422 [details]
MozReview Request: Bug 1208371 - Ensure a media element's ImageContainer is protected when playing a stream. r?mt,jesup

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32183/diff/2-3/
Comment on attachment 8711423 [details]
MozReview Request: Bug 1208371 - Forward declare MediaStreamTrack in MediaPipeline.h. r?bwc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32185/diff/2-3/
Comment on attachment 8711424 [details]
MozReview Request: Bug 1208371 - Clean up unnecessary virtuals in MediaPipeline. r?bwc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32187/diff/2-3/
Comment on attachment 8711425 [details]
MozReview Request: Bug 1208371 - Move MediaStreamTrack's label to MediaStreamTrackSource. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32189/diff/2-3/
Comment on attachment 8711426 [details]
MozReview Request: Bug 1208371 - Move GetCurrentTime undef to DOMMediaStream.cpp. r?jesup

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32191/diff/2-3/
Comment on attachment 8711427 [details]
MozReview Request: Bug 1208371 - Forward declare MediaStreamGraph classes in MediaPipeline.h. r?bwc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32193/diff/2-3/
Comment on attachment 8711428 [details]
MozReview Request: Bug 1208371 - Forward declare DOMMediaStream in HTMLMediaElement.h. r?jesup

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32195/diff/2-3/
Attachment #8676177 - Flags: review?(roc)
Attachment #8676177 - Flags: review?(jib)
Attachment #8705566 - Flags: review?(padenot)
Attachment #8706309 - Flags: review?(roc)
Attachment #8706310 - Flags: review?(jib)
Comment on attachment 8705554 [details]
MozReview Request: Bug 1208371 - Add DirectTrackLister to MediaStreamGraph and MediaStreamTrack. r?roc,jesup

https://reviewboard.mozilla.org/r/30041/#review29825
https://reviewboard.mozilla.org/r/32171/#review29723

> It doesn't matter as long as we never upcast from `PrincipalID` aka `void*` to `nsIPrincipal*`. I'll explain that doing that is really bad.

It does matter because if a principal is destroyed, another different principal could be allocated at the same address!

You can probably make this work by allocating unique 64-bit serial numbers to each principal ... if that's acceptable.
Comment on attachment 8711418 [details]
MozReview Request: Bug 1208371 - Add a PrincipalHandleListener to MediaStreamTrack. r?mt,jesup

https://reviewboard.mozilla.org/r/32175/#review29837
We can pass this in MediaChunks going through the MediaStreamGraph off the main
thread. This will be matched to real principals on main thread later to see
when data flows under the new principal.

Review commit: https://reviewboard.mozilla.org/r/33219/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/33219/
Attachment #8714685 - Flags: review?(roc)
Attachment #8714685 - Flags: review?(bzbarsky)
Comment on attachment 8711416 [details]
MozReview Request: Bug 1208371 - Add PrincipalHandle to MediaChunks. r?mt,jesup

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32171/diff/3-4/
Comment on attachment 8711417 [details]
MozReview Request: Bug 1208371 - Add `NotifyPrincipalHandleChanged` to MediaStreamTrackListener. r?mt,jesup

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32173/diff/3-4/
Comment on attachment 8711418 [details]
MozReview Request: Bug 1208371 - Add a PrincipalHandleListener to MediaStreamTrack. r?mt,jesup

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32175/diff/3-4/
Comment on attachment 8711419 [details]
MozReview Request: Bug 1208371 - Hook up DecodedStream with PrincipalHandle. r?mt,jwwang

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32177/diff/3-4/
Comment on attachment 8711420 [details]
MozReview Request: Bug 1208371 - Hook up MediaPipeline with PrincipalHandle. r?mt,bwc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32179/diff/3-4/
Comment on attachment 8711421 [details]
MozReview Request: Bug 1208371 - Ensure DOMMediaStream principals reflect what could reside in their playback streams. r?mt,jesup

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32181/diff/3-4/
Comment on attachment 8711422 [details]
MozReview Request: Bug 1208371 - Ensure a media element's ImageContainer is protected when playing a stream. r?mt,jesup

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32183/diff/3-4/
Comment on attachment 8711423 [details]
MozReview Request: Bug 1208371 - Forward declare MediaStreamTrack in MediaPipeline.h. r?bwc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32185/diff/3-4/
Comment on attachment 8711424 [details]
MozReview Request: Bug 1208371 - Clean up unnecessary virtuals in MediaPipeline. r?bwc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32187/diff/3-4/
Comment on attachment 8711425 [details]
MozReview Request: Bug 1208371 - Move MediaStreamTrack's label to MediaStreamTrackSource. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32189/diff/3-4/
Comment on attachment 8711426 [details]
MozReview Request: Bug 1208371 - Move GetCurrentTime undef to DOMMediaStream.cpp. r?jesup

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32191/diff/3-4/
Comment on attachment 8711427 [details]
MozReview Request: Bug 1208371 - Forward declare MediaStreamGraph classes in MediaPipeline.h. r?bwc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32193/diff/3-4/
Comment on attachment 8711428 [details]
MozReview Request: Bug 1208371 - Forward declare DOMMediaStream in HTMLMediaElement.h. r?jesup

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32195/diff/3-4/
Comment on attachment 8714685 [details]
MozReview Request: Bug 1208371 - Add unique principalId attribute to nsIPrincipal. r?bz,roc

https://reviewboard.mozilla.org/r/33219/#review29945
Attachment #8714685 - Flags: review?(roc) → review+
Comment on attachment 8714685 [details]
MozReview Request: Bug 1208371 - Add unique principalId attribute to nsIPrincipal. r?bz,roc

Looks like something Bobby should OK.
Attachment #8714685 - Flags: review?(bzbarsky) → review?(bobbyholley)
I'm somewhat skeptical here. In general, the particular principal instance doesn't have all that much semantic meaning. We use .equals() to determine if two principals are identical, and .origin to serialize them (at least to the level that is sufficient when you don't care about the path part of the URI).

Can you elaborate on the use-case?
We need to see when data in the MediaStreamGraph reaches whatever consumer there is under a new principal. We can then compare that to our main thread state and if they match we know the new principal has been applied to data and we can update the exposed main thread state accordingly.

I'm not so psyched over putting a copy of the origin string in each MediaChunk and doing string comparisons in the graph.
Flags: needinfo?(bobbyholley)
(In reply to Andreas Pehrson [:pehrsons] (Telenor) from comment #977)
> We need to see when data in the MediaStreamGraph reaches whatever consumer
> there is under a new principal. We can then compare that to our main thread
> state and if they match we know the new principal has been applied to data
> and we can update the exposed main thread state accordingly.

Ok - but what is your definition of "new principal"? Suppose some codepath serializes a principal and sends it to the parent process, which eventually sends that principal back to the child. Are you absolutely sure you want to consider that as a new/distinct principal?

It's true that in Gecko there are various places where we make the assumption you're trying to make. But those are fragile and somewhat incompatible with changes that are being made, which is why I'm pushing back on the proposal to bake this into the API.
 
> I'm not so psyched over putting a copy of the origin string in each
> MediaChunk and doing string comparisons in the graph.

If you don't mind holding your principal alive, you can put it in an nsMainThreadPtrHolder. But you'd still need to be on the main thread to invoke equals().
Flags: needinfo?(bobbyholley)
(In reply to Bobby Holley (busy) from comment #978)
> If you don't mind holding your principal alive, you can put it in an
> nsMainThreadPtrHolder. But you'd still need to be on the main thread to
> invoke equals().

That sounds like a possible solution. Thanks.
Comment on attachment 8714685 [details]
MozReview Request: Bug 1208371 - Add unique principalId attribute to nsIPrincipal. r?bz,roc

FWIW, I agree that it's a huge PITA that we can't use principals off the main thread. I think it would be a worthwhile effort to fix it, but it would be a pretty huge chunk of work.
Attachment #8714685 - Flags: review?(bobbyholley)
See Also: → 1245805
No longer blocks: 1257569
Comment on attachment 8676157 [details]
MozReview Request: Bug 1208371 - Pass parent window to DOMMediaStream through constructor. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22567/diff/6-7/
Comment on attachment 8676159 [details]
MozReview Request: Bug 1208371 - Make AudioCaptureStream startable. r?padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22569/diff/6-7/
Comment on attachment 8676160 [details]
MozReview Request: Bug 1208371 - Move OnTracksAvailableCallback out of DOMMediaStream. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22571/diff/6-7/
Comment on attachment 8676161 [details]
MozReview Request: Bug 1208371 - Remove unused MediaManager::NotifyMediaStreamTrackEnded. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22573/diff/6-7/
Comment on attachment 8676162 [details]
MozReview Request: Bug 1208371 - Introduce MediaStreamTrack logs. r?roc,jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22575/diff/6-7/
Comment on attachment 8676163 [details]
MozReview Request: Bug 1208371 - Track original track in MediaStreamTrack clones. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22577/diff/6-7/
Comment on attachment 8676164 [details]
MozReview Request: Bug 1208371 - Un-nest MediaEngineSource::PhotoCallback. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22579/diff/6-7/
Comment on attachment 8676168 [details]
MozReview Request: Bug 1208371 - Add a MediaStreamTrackSource interface. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22583/diff/7-8/
Comment on attachment 8676169 [details]
MozReview Request: Bug 1208371 - Add MediaStreamTrackSourceGetter interface. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22585/diff/7-8/
Comment on attachment 8676170 [details]
MozReview Request: Bug 1208371 - Let MediaStreamTracks know their TrackID at the source. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22587/diff/7-8/
Comment on attachment 8676171 [details]
MozReview Request: Bug 1208371 - Let FindOwnedDOMTrack operate on input stream. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22589/diff/7-8/
Comment on attachment 8676172 [details]
MozReview Request: Bug 1208371 - Add some MediaStreamTrack helper methods. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22591/diff/7-8/
Comment on attachment 8676173 [details]
MozReview Request: Bug 1208371 - Count the users of a MediaStream to ease Destroy() responsibility. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22593/diff/7-8/
Comment on attachment 8676174 [details]
MozReview Request: Bug 1208371 - Add convenience method for checking if TrackID is explicit. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22595/diff/7-8/
Comment on attachment 8676175 [details]
MozReview Request: Bug 1208371 - Allow MediaInputPorts mapped to a destination TrackID. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22597/diff/7-8/
Comment on attachment 8676176 [details]
MozReview Request: Bug 1208371 - Remove obsolete SetTrackEnabled() from DOMMediaStream r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22599/diff/7-8/
Comment on attachment 8676165 [details]
MozReview Request: Bug 1208371 - Add MediaStreamTrack::Graph(). r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22581/diff/7-8/
Comment on attachment 8676178 [details]
MozReview Request: Bug 1208371 - Add DOMMediaStream::GetTrackById/GetOwnedTrackById. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22603/diff/7-8/
Comment on attachment 8700523 [details]
MozReview Request: Bug 1208371 - Add a generic PrincipalChangeObserver interface. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28733/diff/4-5/
Comment on attachment 8705566 [details]
MozReview Request: Bug 1208371 - Turn DOMMediaStream::PrincipalChangeObserver into PrincipalChangeObserver<DOMMediaStream>. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30065/diff/3-4/
Attachment #8705566 - Flags: review?(padenot)
Comment on attachment 8700521 [details]
MozReview Request: Bug 1208371 - Add principal APIs to MediaStreamTrack. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28729/diff/4-5/
Comment on attachment 8700522 [details]
MozReview Request: Bug 1208371 - Create MediaStreamTrackSource::Sink that forwards principal changes from the source. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28731/diff/4-5/
Comment on attachment 8676157 [details]
MozReview Request: Bug 1208371 - Pass parent window to DOMMediaStream through constructor. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22567/diff/6-7/
Comment on attachment 8676159 [details]
MozReview Request: Bug 1208371 - Make AudioCaptureStream startable. r?padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22569/diff/6-7/
Comment on attachment 8676160 [details]
MozReview Request: Bug 1208371 - Move OnTracksAvailableCallback out of DOMMediaStream. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22571/diff/6-7/
Comment on attachment 8676161 [details]
MozReview Request: Bug 1208371 - Remove unused MediaManager::NotifyMediaStreamTrackEnded. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22573/diff/6-7/
Comment on attachment 8676162 [details]
MozReview Request: Bug 1208371 - Introduce MediaStreamTrack logs. r?roc,jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22575/diff/6-7/
Comment on attachment 8676163 [details]
MozReview Request: Bug 1208371 - Track original track in MediaStreamTrack clones. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22577/diff/6-7/
Comment on attachment 8676164 [details]
MozReview Request: Bug 1208371 - Un-nest MediaEngineSource::PhotoCallback. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22579/diff/6-7/
Comment on attachment 8676168 [details]
MozReview Request: Bug 1208371 - Add a MediaStreamTrackSource interface. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22583/diff/7-8/
Comment on attachment 8676169 [details]
MozReview Request: Bug 1208371 - Add MediaStreamTrackSourceGetter interface. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22585/diff/7-8/
Comment on attachment 8676170 [details]
MozReview Request: Bug 1208371 - Let MediaStreamTracks know their TrackID at the source. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22587/diff/7-8/
Comment on attachment 8676171 [details]
MozReview Request: Bug 1208371 - Let FindOwnedDOMTrack operate on input stream. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22589/diff/7-8/
Comment on attachment 8676172 [details]
MozReview Request: Bug 1208371 - Add some MediaStreamTrack helper methods. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22591/diff/7-8/
Comment on attachment 8676173 [details]
MozReview Request: Bug 1208371 - Count the users of a MediaStream to ease Destroy() responsibility. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22593/diff/7-8/
Comment on attachment 8676174 [details]
MozReview Request: Bug 1208371 - Add convenience method for checking if TrackID is explicit. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22595/diff/7-8/
Comment on attachment 8676175 [details]
MozReview Request: Bug 1208371 - Allow MediaInputPorts mapped to a destination TrackID. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22597/diff/7-8/
Comment on attachment 8676176 [details]
MozReview Request: Bug 1208371 - Remove obsolete SetTrackEnabled() from DOMMediaStream r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22599/diff/7-8/
Comment on attachment 8676165 [details]
MozReview Request: Bug 1208371 - Add MediaStreamTrack::Graph(). r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22581/diff/7-8/
Comment on attachment 8676178 [details]
MozReview Request: Bug 1208371 - Add DOMMediaStream::GetTrackById/GetOwnedTrackById. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22603/diff/7-8/
Comment on attachment 8700523 [details]
MozReview Request: Bug 1208371 - Add a generic PrincipalChangeObserver interface. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28733/diff/4-5/
Comment on attachment 8705566 [details]
MozReview Request: Bug 1208371 - Turn DOMMediaStream::PrincipalChangeObserver into PrincipalChangeObserver<DOMMediaStream>. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30065/diff/3-4/
Comment on attachment 8700521 [details]
MozReview Request: Bug 1208371 - Add principal APIs to MediaStreamTrack. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28729/diff/4-5/
Comment on attachment 8700522 [details]
MozReview Request: Bug 1208371 - Create MediaStreamTrackSource::Sink that forwards principal changes from the source. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28731/diff/4-5/
Attachment #8705566 - Flags: review?(padenot)
Comment on attachment 8705566 [details]
MozReview Request: Bug 1208371 - Turn DOMMediaStream::PrincipalChangeObserver into PrincipalChangeObserver<DOMMediaStream>. r?mt

https://reviewboard.mozilla.org/r/30065/#review37645
Attachment #8705566 - Flags: review+
Depends on: 1257976
Review commit: https://reviewboard.mozilla.org/r/41009/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/41009/
Attachment #8711416 - Attachment description: MozReview Request: Bug 1208371 - Add PrincipalID to MediaChunks. r?mt,roc → MozReview Request: Bug 1208371 - Add PrincipalHandle to MediaChunks. r?mt,jesup
Attachment #8711417 - Attachment description: MozReview Request: Bug 1208371 - Add `NotifyPrincipalIdChange` to MediaStreamTrackListener. r?mt,roc → MozReview Request: Bug 1208371 - Add `NotifyPrincipalHandleChanged` to MediaStreamTrackListener. r?mt,jesup
Attachment #8711418 - Attachment description: MozReview Request: Bug 1208371 - Add a PrincipalIdListener to MediaStreamTrack. r?roc,mt → MozReview Request: Bug 1208371 - Add a PrincipalHandleListener to MediaStreamTrack. r?mt,jesup
Attachment #8711419 - Attachment description: MozReview Request: Bug 1208371 - Hook up DecodedStream with principalId. r?mt,jwwang → MozReview Request: Bug 1208371 - Hook up DecodedStream with PrincipalHandle. r?mt,jwwang
Attachment #8711420 - Attachment description: MozReview Request: Bug 1208371 - Hook up MediaPipeline with principalId. r?mt,bwc → MozReview Request: Bug 1208371 - Hook up MediaPipeline with PrincipalHandle. r?mt,bwc
Attachment #8711421 - Attachment description: MozReview Request: Bug 1208371 - Ensure DOMMediaStream principals reflect what could reside in their playback streams. r?mt,roc → MozReview Request: Bug 1208371 - Ensure DOMMediaStream principals reflect what could reside in their playback streams. r?mt,jesup
Attachment #8711422 - Attachment description: MozReview Request: Bug 1208371 - Ensure a media element's ImageContainer is protected when playing a stream. r?mt,roc → MozReview Request: Bug 1208371 - Ensure a media element's ImageContainer is protected when playing a stream. r?mt,jesup
Attachment #8711428 - Attachment description: MozReview Request: Bug 1208371 - Forward declare DOMMediaStream in HTMLMediaElement.h. r?roc → MozReview Request: Bug 1208371 - Forward declare DOMMediaStream in HTMLMediaElement.h. r?jesup
Attachment #8735722 - Flags: review?(bobbyholley)
Attachment #8735723 - Flags: review?(rjesup)
Attachment #8735724 - Flags: review?(padenot)
Attachment #8735725 - Flags: review?(martin.thomson)
Attachment #8735726 - Flags: review?(rjesup)
Attachment #8735727 - Flags: review?(rjesup)
Attachment #8711416 - Flags: review?(rjesup)
Attachment #8711417 - Flags: review?(rjesup)
Attachment #8711418 - Flags: review?(rjesup)
Attachment #8711421 - Flags: review?(rjesup)
Attachment #8711422 - Flags: review?(rjesup)
Attachment #8711428 - Flags: review?(rjesup)
That this caused problems is probably related to video not being supported for
direct track listeners. Frames could pile up under load and delay the MSG
since there were so many frames queued for processing.

With a direct listener the MediaPipeline processing would occur on the
MediaEngine's thread.

Review commit: https://reviewboard.mozilla.org/r/41017/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/41017/
This is necessary since frame conversion could stall the MediaStreamGraph,
causing delay buildups and other junk.

This passes frames to a TaskQueue that converts on its own thread pool and
passes them on to VideoConduit when converted.

If the TaskQueue already has some buffered tasks (3 for now) we will drop new
frames coming in.

Review commit: https://reviewboard.mozilla.org/r/41019/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/41019/
Comment on attachment 8676157 [details]
MozReview Request: Bug 1208371 - Pass parent window to DOMMediaStream through constructor. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22567/diff/6-7/
Comment on attachment 8676159 [details]
MozReview Request: Bug 1208371 - Make AudioCaptureStream startable. r?padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22569/diff/6-7/
Comment on attachment 8676160 [details]
MozReview Request: Bug 1208371 - Move OnTracksAvailableCallback out of DOMMediaStream. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22571/diff/6-7/
Comment on attachment 8676161 [details]
MozReview Request: Bug 1208371 - Remove unused MediaManager::NotifyMediaStreamTrackEnded. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22573/diff/6-7/
Comment on attachment 8676162 [details]
MozReview Request: Bug 1208371 - Introduce MediaStreamTrack logs. r?roc,jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22575/diff/6-7/
Comment on attachment 8676163 [details]
MozReview Request: Bug 1208371 - Track original track in MediaStreamTrack clones. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22577/diff/6-7/
Comment on attachment 8676164 [details]
MozReview Request: Bug 1208371 - Un-nest MediaEngineSource::PhotoCallback. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22579/diff/6-7/
Comment on attachment 8676168 [details]
MozReview Request: Bug 1208371 - Add a MediaStreamTrackSource interface. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22583/diff/7-8/
Comment on attachment 8676169 [details]
MozReview Request: Bug 1208371 - Add MediaStreamTrackSourceGetter interface. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22585/diff/7-8/
Comment on attachment 8676170 [details]
MozReview Request: Bug 1208371 - Let MediaStreamTracks know their TrackID at the source. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22587/diff/7-8/
Comment on attachment 8676171 [details]
MozReview Request: Bug 1208371 - Let FindOwnedDOMTrack operate on input stream. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22589/diff/7-8/
Comment on attachment 8676172 [details]
MozReview Request: Bug 1208371 - Add some MediaStreamTrack helper methods. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22591/diff/7-8/
Comment on attachment 8676173 [details]
MozReview Request: Bug 1208371 - Count the users of a MediaStream to ease Destroy() responsibility. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22593/diff/7-8/
Comment on attachment 8676174 [details]
MozReview Request: Bug 1208371 - Add convenience method for checking if TrackID is explicit. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22595/diff/7-8/
Comment on attachment 8676175 [details]
MozReview Request: Bug 1208371 - Allow MediaInputPorts mapped to a destination TrackID. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22597/diff/7-8/
Comment on attachment 8676176 [details]
MozReview Request: Bug 1208371 - Remove obsolete SetTrackEnabled() from DOMMediaStream r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22599/diff/7-8/
Comment on attachment 8676165 [details]
MozReview Request: Bug 1208371 - Add MediaStreamTrack::Graph(). r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22581/diff/7-8/
Comment on attachment 8676178 [details]
MozReview Request: Bug 1208371 - Add DOMMediaStream::GetTrackById/GetOwnedTrackById. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22603/diff/7-8/
Comment on attachment 8700523 [details]
MozReview Request: Bug 1208371 - Add a generic PrincipalChangeObserver interface. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28733/diff/4-5/
Comment on attachment 8705566 [details]
MozReview Request: Bug 1208371 - Turn DOMMediaStream::PrincipalChangeObserver into PrincipalChangeObserver<DOMMediaStream>. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30065/diff/3-4/
Comment on attachment 8700521 [details]
MozReview Request: Bug 1208371 - Add principal APIs to MediaStreamTrack. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28729/diff/4-5/
Comment on attachment 8700522 [details]
MozReview Request: Bug 1208371 - Create MediaStreamTrackSource::Sink that forwards principal changes from the source. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28731/diff/4-5/
Comment on attachment 8676177 [details]
MozReview Request: Bug 1208371 - Let DOMMediaStream base its principal on the tracks it contains. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22601/diff/8-9/
Comment on attachment 8700524 [details]
MozReview Request: Bug 1208371 - Add an interface DecoderPrincipalChangeObserver to HTMLMediaElement. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28735/diff/5-6/
Comment on attachment 8700525 [details]
MozReview Request: Bug 1208371 - Make HTMLMediaElement::CaptureStream pass its principal to MediaStreamTrack. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28737/diff/5-6/
Comment on attachment 8700526 [details]
MozReview Request: Bug 1208371 - Make MediaManager pass its principal to MediaStreamTrack for gUM. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28739/diff/5-6/
Comment on attachment 8700527 [details]
MozReview Request: Bug 1208371 - Make ImageCapture listen to principal changes of MediaStreamTrack instead. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28741/diff/5-6/
Comment on attachment 8706309 [details]
MozReview Request: Bug 1208371 - Break PCImpl::SetRemoteDescription into smaller pieces. r?mt,bwc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30299/diff/4-5/
Comment on attachment 8700528 [details]
MozReview Request: Bug 1208371 - Make PeerConnectionImpl pass its principal to MediaStreamTrack through a new RemoteTrackSource. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28743/diff/5-6/
Comment on attachment 8700529 [details]
MozReview Request: Bug 1208371 - Make remaining DOMMediaStream principal sources use MediaStreamTrack. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/28745/diff/5-6/
Comment on attachment 8706310 [details]
MozReview Request: Bug 1208371 - Remove some no longer necessary principal methods on DOMMediaStream. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30301/diff/4-5/
Comment on attachment 8711410 [details]
MozReview Request: Bug 1208371 - Add a MediaStreamTrackListener to MediaStreamGraph. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32159/diff/3-4/
Comment on attachment 8676179 [details]
MozReview Request: Bug 1208371 - Move ImageCapture to a MediaStreamTrackListener. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22605/diff/8-9/
Comment on attachment 8676180 [details]
MozReview Request: Bug 1208371 - Make it possible to look up stream id by track in PeerConnectionImpl. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22607/diff/8-9/
Comment on attachment 8676181 [details]
MozReview Request: Bug 1208371 - Fix DOMMediaStream::OwnsTrack. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22609/diff/8-9/
Comment on attachment 8676182 [details]
MozReview Request: Bug 1208371 - Remove MediaStreamTrack::GetStream. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/22611/diff/8-9/
Comment on attachment 8681202 [details]
MozReview Request: Bug 1208371 - Route ApplyConstraints through MediaStreamTrackSource. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23771/diff/7-8/
Comment on attachment 8711411 [details]
MozReview Request: Bug 1208371 - Kill nsDOMUserMediaStream with fire. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32161/diff/3-4/
Comment on attachment 8681203 [details]
MozReview Request: Bug 1208371 - Make it possible to block tracks in a MediaInputPort initally. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23773/diff/7-8/
Comment on attachment 8681204 [details]
MozReview Request: Bug 1208371 - Implement MediaStreamTrack::Clone(). r?smaug,jib,roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23775/diff/7-8/
Comment on attachment 8681205 [details]
MozReview Request: Bug 1208371 - Implement DOMMediaStream::Clone() r?smaug,jib,roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23777/diff/7-8/
Comment on attachment 8681206 [details]
MozReview Request: Bug 1208371 - Various cleanups in DOMMediaStream/MediaStreamTrack. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23779/diff/7-8/
Comment on attachment 8681207 [details]
MozReview Request: Bug 1208371 - Forward input stream and track id on regular track changes for union streams. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23781/diff/7-8/
Comment on attachment 8681208 [details]
MozReview Request: Bug 1208371 - Move track.stop() helpers to MediaStreamPlayback. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23783/diff/7-8/
Comment on attachment 8681209 [details]
MozReview Request: Bug 1208371 - Test DOMMediaStream::Clone(). r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/23785/diff/7-8/
Comment on attachment 8683551 [details]
MozReview Request: Bug 1208371 - Rename CreateOwnDOMTrack/CreateClonedDOMTrack to CreateDOMTrack/CloneDOMTrack. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/24365/diff/6-7/
Comment on attachment 8705531 [details]
MozReview Request: Bug 1208371 - Resolve ambiguous symbol MediaStreamTrack. r?bwc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/29997/diff/4-5/
Comment on attachment 8705532 [details]
MozReview Request: Bug 1208371 - Test MediaStreamTrack::Clone(). r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/29999/diff/4-5/
Comment on attachment 8705533 [details]
MozReview Request: Bug 1208371 - Add CORSMode methods to MediaStreamTrack. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30001/diff/4-5/
Comment on attachment 8705534 [details]
MozReview Request: Bug 1208371 - Add convenience method for forwarding a track to an MSG-stream. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30003/diff/4-5/
Comment on attachment 8705535 [details]
MozReview Request: Bug 1208371 - Lock MediaStreamAudioSourceNode onto the first AudioStreamTrack in mInputStream at time of construction. r?mt,padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30005/diff/4-5/
Comment on attachment 8705536 [details]
MozReview Request: Bug 1208371 - Move HTMLMediaElement::CaptureStream to forward CORSMode changes through MediaStreamTrackSource. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30007/diff/4-5/
Comment on attachment 8705537 [details]
MozReview Request: Bug 1208371 - Remove CORSMode methods from DOMMediaStream. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30009/diff/4-5/
Comment on attachment 8705538 [details]
MozReview Request: Bug 1208371 - Change HTMLMediaElement video sinks to check principal for video only tracks. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30011/diff/4-5/
Comment on attachment 8705539 [details]
MozReview Request: Bug 1208371 - Remove ref counting from DOMMediaStream::TrackListener. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30013/diff/4-5/
Comment on attachment 8705540 [details]
MozReview Request: Bug 1208371 - Update tests to accomodate the fact that MediaStreamAudioSourceNodes lock onto the first audio track. r?padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30015/diff/4-5/
Comment on attachment 8705541 [details]
MozReview Request: Bug 1208371 - Modify WebAudio source nodes tests to wait for tracks befoure measuring nr of samples. r?padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30017/diff/4-5/
Comment on attachment 8705542 [details]
MozReview Request: Bug 1208371 - Make PeerIdentity RefCounted. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30019/diff/4-5/
Comment on attachment 8705543 [details]
MozReview Request: Bug 1208371 - Add GetPeerIdentity() to MediaStreamTrackSource. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30021/diff/4-5/
Comment on attachment 8705545 [details]
MozReview Request: Bug 1208371 - Add PeerIdentity to LocalTrackSource for gUM tracks. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30023/diff/4-5/
Comment on attachment 8705546 [details]
MozReview Request: Bug 1208371 - Move PeerConnection to use PeerIdentity on MediaStreamTrack. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30025/diff/4-5/
Comment on attachment 8705547 [details]
MozReview Request: Bug 1208371 - Remove PeerIdentity from DOMMediaStream. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30027/diff/4-5/
Comment on attachment 8705548 [details]
MozReview Request: Bug 1208371 - Add convenience method for checking track forwarding to MediaStreamTrack. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30029/diff/4-5/
Comment on attachment 8705549 [details]
MozReview Request: Bug 1208371 - Remove test_mediarecorder_record_nosrc.html. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30031/diff/4-5/
Comment on attachment 8705550 [details]
MozReview Request: Bug 1208371 - Inline MediaRecorder::Session::SetupStreams. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30033/diff/4-5/
Comment on attachment 8705551 [details]
MozReview Request: Bug 1208371 - Check principal per track instead of per stream in MediaRecorder. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30035/diff/4-5/
Comment on attachment 8705552 [details]
MozReview Request: Bug 1208371 - Simplify track disabling test code. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30037/diff/4-5/
Comment on attachment 8705553 [details]
MozReview Request: Bug 1208371 - Test disabling track across peerconnection not affecting clones. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30039/diff/4-5/
Comment on attachment 8705554 [details]
MozReview Request: Bug 1208371 - Add DirectTrackLister to MediaStreamGraph and MediaStreamTrack. r?roc,jesup

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30041/diff/4-5/
Comment on attachment 8705555 [details]
MozReview Request: Bug 1208371 - Switch MediaPipeline to use direct listeners on tracks. r?jesup,bwc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30043/diff/4-5/
Comment on attachment 8711412 [details]
MozReview Request: Bug 1208371 - Let PeerConnection consume principals from tracks instead of streams. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32163/diff/3-4/
Comment on attachment 8705556 [details]
MozReview Request: Bug 1208371 - Switch MediaStreamTrack to enable/disable tracks on owned stream. r?jesup

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30045/diff/4-5/
Comment on attachment 8705557 [details]
MozReview Request: Bug 1208371 - Make GraphDriver callback log calls verbose. r?padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30047/diff/4-5/
Comment on attachment 8705558 [details]
MozReview Request: Bug 1208371 - Do not require DOMLocalMediaStream for gUM (audioCapture). r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30049/diff/4-5/
Comment on attachment 8705559 [details]
MozReview Request: Bug 1208371 - Add a track getter to gUM for fake tracks. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30051/diff/4-5/
Comment on attachment 8705560 [details]
MozReview Request: Bug 1208371 - Remove unnecessary fakeTracks:true from test_streams_individual_pause.html. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30053/diff/4-5/
Comment on attachment 8705561 [details]
MozReview Request: Bug 1208371 - Remove debug canvas from addTrackRemoveTrack test to help android perf. r?padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30055/diff/4-5/
Comment on attachment 8705562 [details]
MozReview Request: Bug 1208371 - Remove debug canvas from peerConnection_trackDisabling test to help android perf. r?padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30057/diff/4-5/
Comment on attachment 8705563 [details]
MozReview Request: Bug 1208371 - Enable test_peerConnection_trackDisabling.html on android 4.3 debug. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30059/diff/4-5/
Comment on attachment 8705564 [details]
MozReview Request: Bug 1208371 - Remove debug canvas from mediaStreamConstructors test to help android perf. r?padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30061/diff/4-5/
Comment on attachment 8705565 [details]
MozReview Request: Bug 1208371 - Add disconnect method to test helper AudioStreamAnalyser to improve performance on slow devices. r?padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30063/diff/4-5/
Comment on attachment 8705567 [details]
MozReview Request: Bug 1208371 - Guard LoadManagerSingleton with a WeakPtr. r?pkerr

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30067/diff/4-5/
Comment on attachment 8705568 [details]
MozReview Request: Bug 1208371 - Don't dispatch conduit destruction to main thread when not needed. r?bwc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30069/diff/4-5/
Comment on attachment 8705569 [details]
MozReview Request: Bug 1208371 - Clear output canvas on each drawImage(). r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30071/diff/4-5/
Comment on attachment 8705570 [details]
MozReview Request: Bug 1208371 - Wait for "loadedmetadata" before setting up nodes in test_mediaElementAudioSourceNodeCrossOrigin.html. r?padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30073/diff/4-5/
Comment on attachment 8705571 [details]
MozReview Request: Bug 1208371 - Improve reliability of test_mediarecorder_record_timeslice.html. r?jwwang

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/30075/diff/4-5/
Comment on attachment 8711415 [details]
MozReview Request: Bug 1208371 - Move FindTrack from SourceMediaStream to MediaStream. r?roc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32169/diff/3-4/
Comment on attachment 8711416 [details]
MozReview Request: Bug 1208371 - Add PrincipalHandle to MediaChunks. r?mt,jesup

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32171/diff/4-5/
Comment on attachment 8711417 [details]
MozReview Request: Bug 1208371 - Add `NotifyPrincipalHandleChanged` to MediaStreamTrackListener. r?mt,jesup

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32173/diff/4-5/
Comment on attachment 8711418 [details]
MozReview Request: Bug 1208371 - Add a PrincipalHandleListener to MediaStreamTrack. r?mt,jesup

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32175/diff/4-5/
Comment on attachment 8711419 [details]
MozReview Request: Bug 1208371 - Hook up DecodedStream with PrincipalHandle. r?mt,jwwang

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32177/diff/4-5/
Comment on attachment 8711420 [details]
MozReview Request: Bug 1208371 - Hook up MediaPipeline with PrincipalHandle. r?mt,bwc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32179/diff/4-5/
Comment on attachment 8711421 [details]
MozReview Request: Bug 1208371 - Ensure DOMMediaStream principals reflect what could reside in their playback streams. r?mt,jesup

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32181/diff/4-5/
Comment on attachment 8711422 [details]
MozReview Request: Bug 1208371 - Ensure a media element's ImageContainer is protected when playing a stream. r?mt,jesup

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32183/diff/4-5/
Comment on attachment 8711423 [details]
MozReview Request: Bug 1208371 - Forward declare MediaStreamTrack in MediaPipeline.h. r?bwc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32185/diff/4-5/
Comment on attachment 8711424 [details]
MozReview Request: Bug 1208371 - Clean up unnecessary virtuals in MediaPipeline. r?bwc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32187/diff/4-5/
Comment on attachment 8711425 [details]
MozReview Request: Bug 1208371 - Move MediaStreamTrack's label to MediaStreamTrackSource. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32189/diff/4-5/
Comment on attachment 8711426 [details]
MozReview Request: Bug 1208371 - Move GetCurrentTime undef to DOMMediaStream.cpp. r?jesup

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32191/diff/4-5/
Comment on attachment 8711427 [details]
MozReview Request: Bug 1208371 - Forward declare MediaStreamGraph classes in MediaPipeline.h. r?bwc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32193/diff/4-5/
Comment on attachment 8711428 [details]
MozReview Request: Bug 1208371 - Forward declare DOMMediaStream in HTMLMediaElement.h. r?jesup

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32195/diff/4-5/
Attachment #8711413 - Attachment is obsolete: true
Attachment #8711414 - Attachment is obsolete: true
Attachment #8714685 - Attachment is obsolete: true
Comment on attachment 8735725 [details]
MozReview Request: Bug 1208371 - Update sink identity after adding track. r?mt

https://reviewboard.mozilla.org/r/41015/#review39443
Attachment #8735725 - Flags: review?(martin.thomson) → review+
Comment on attachment 8735724 [details]
MozReview Request: Bug 1208371 - Don't treat audio chunks as mutable in MediaPipeline. r?padenot

https://reviewboard.mozilla.org/r/41013/#review39455
Attachment #8735724 - Flags: review?(padenot) → review+
Attachment #8735722 - Flags: review?(bobbyholley) → review+
Comment on attachment 8735722 [details]
MozReview Request: Bug 1208371 - Implement operator!= for nsMainThreadPtrHandle. r?bholley

https://reviewboard.mozilla.org/r/41009/#review39575
Attachment #8735723 - Flags: review?(rjesup) → review+
Comment on attachment 8735723 [details]
MozReview Request: Bug 1208371 - Never send more than one disabled frame in a row to the WebRTC encoder. r?jesup

https://reviewboard.mozilla.org/r/41011/#review40523
Comment on attachment 8735726 [details]
MozReview Request: Bug 1208371 - Don't push frames as they come in to MediaEngine. r?jesup

https://reviewboard.mozilla.org/r/41017/#review40665

::: dom/media/webrtc/MediaEngineRemoteVideoSource.cpp:365
(Diff revision 1)
>    // implicitly releases last image
>    mImage = image.forget();
>  
> -  // Push the frame into the MSG with a minimal duration.  This will likely
> -  // mean we'll still get NotifyPull calls which will then return the same
> -  // frame again with a longer duration.  However, this means we won't
> +  // We'll push the frame into the MSG on the next NotifyPull. This will avoid
> +  // swamping the MSG with frames should it be taking longer than normal to run
> +  // an iteration.

If we coalesced segments with the same Image pointer when they're added (i.e. just extended the duration), would that cause the perf hit?

Still, getting all video segments to be timestamp-based and not duration-based would be a far larger win overall, and right now there's no way to "shorten" the duration of an earlier frame.  I.e. MSG runs iterations and constantly extends the time of existing frames by the duration of the audio being asked for, which is really not the "right" thing to do.  ctai's modifications to remove video buffering may well remove this issue, so it (hopefully) is a moot point.
Attachment #8735726 - Flags: review?(rjesup) → review+
(In reply to Randell Jesup [:jesup] from comment #1136)
> Comment on attachment 8735726 [details]
> MozReview Request: Bug 1208371 - Don't push frames as they come in to
> MediaEngine. r?jesup
> 
> https://reviewboard.mozilla.org/r/41017/#review40665
> 
> ::: dom/media/webrtc/MediaEngineRemoteVideoSource.cpp:365
> (Diff revision 1)
> >    // implicitly releases last image
> >    mImage = image.forget();
> >  
> > -  // Push the frame into the MSG with a minimal duration.  This will likely
> > -  // mean we'll still get NotifyPull calls which will then return the same
> > -  // frame again with a longer duration.  However, this means we won't
> > +  // We'll push the frame into the MSG on the next NotifyPull. This will avoid
> > +  // swamping the MSG with frames should it be taking longer than normal to run
> > +  // an iteration.
> 
> If we coalesced segments with the same Image pointer when they're added
> (i.e. just extended the duration), would that cause the perf hit?

Not sure I understand, could you give an example?
Flags: needinfo?(rjesup)
Comment on attachment 8711416 [details]
MozReview Request: Bug 1208371 - Add PrincipalHandle to MediaChunks. r?mt,jesup

https://reviewboard.mozilla.org/r/32171/#review40751

I'm ok with r+ based on rocs, presuming there were no significant changes added - but I can't easily tell, since so much code from other changes landed in m-c is included in the 4-5 diff.  I looked at it all, but I'm not sure I was picking out the right parts.

::: dom/media/MediaManager.cpp:228
(Diff revisions 4 - 5)
>      if (end == (uint32_t)-1) {
>        // Last or only domain name in the comma separated list
>        end = domainWhiteList.Length();
>      }
>  
> -    rv = idnService->ConvertUTF8toACE(Substring(domainWhiteList, begin, end),
> +    rv = idnService->ConvertUTF8toACE(Substring(domainWhiteList, begin, end - begin),

this is a merge from m-c, right?

::: dom/media/MediaSegment.h:96
(Diff revisions 4 - 5)
> +    return false;
> +  }
> +
> +  bool result;
> +  nsresult rv = principal->Equals(aOther, &result);
> +  if (NS_FAILED(rv)) {

minor style... I'd just use
if (NS_FAILED(principal->Equals(...))) {
   NS_ERROR(...);
   return false;
}
return result;

::: dom/media/encoder/TrackEncoder.cpp:261
(Diff revisions 4 - 5)
> +      // Because we may get chunks with a null image (due to input blocking),
> +      // accumulate duration and give it to the next frame that arrives.
> +      // Canonically incorrect - the duration should go to the previous frame
> +      // - but that would require delaying until the next frame arrives.
> +      // Best would be to do like OMXEncoder and pass an effective timestamp
> +      // in with each frame (don't zero mTotalFrameDuration)

Why is this showing up here as a change?  This landed in m-c....
Attachment #8711416 - Flags: review?(rjesup) → review+
Attachment #8711417 - Flags: review?(rjesup) → review+
Comment on attachment 8711417 [details]
MozReview Request: Bug 1208371 - Add `NotifyPrincipalHandleChanged` to MediaStreamTrackListener. r?mt,jesup

https://reviewboard.mozilla.org/r/32173/#review40801
Attachment #8711418 - Flags: review?(rjesup) → review+
Comment on attachment 8711418 [details]
MozReview Request: Bug 1208371 - Add a PrincipalHandleListener to MediaStreamTrack. r?mt,jesup

https://reviewboard.mozilla.org/r/32175/#review40805
Comment on attachment 8711421 [details]
MozReview Request: Bug 1208371 - Ensure DOMMediaStream principals reflect what could reside in their playback streams. r?mt,jesup

https://reviewboard.mozilla.org/r/32181/#review40807
Attachment #8711421 - Flags: review?(rjesup) → review+
Attachment #8711422 - Flags: review?(rjesup) → review+
Comment on attachment 8711422 [details]
MozReview Request: Bug 1208371 - Ensure a media element's ImageContainer is protected when playing a stream. r?mt,jesup

https://reviewboard.mozilla.org/r/32183/#review40809
Attachment #8711428 - Flags: review?(rjesup) → review+
Comment on attachment 8711428 [details]
MozReview Request: Bug 1208371 - Forward declare DOMMediaStream in HTMLMediaElement.h. r?jesup

https://reviewboard.mozilla.org/r/32195/#review40811
Attachment #8735727 - Flags: review?(rjesup)
Comment on attachment 8735727 [details]
MozReview Request: Bug 1208371 - Do image format conversion async in MediaPipeline. r?jesup

https://reviewboard.mozilla.org/r/41019/#review40683

::: media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp:83
(Diff revision 1)
> +  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VideoConverterListener)
> +
> +  virtual void OnVideoFrameConverted(unsigned char* aVideoFrame,
> +                                     unsigned int aVideoFrameLength,
> +                                     unsigned short aWidth,
> +                                     unsigned short aHeight,

I presume other methods/structs in this area are using unsigned short for width/height.  If not, make it match.

::: media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp:114
(Diff revision 1)
> +public:
> +  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VideoFrameConverter)
> +
> +  VideoFrameConverter()
> +    : mLength(0)
> +    , last_img_(-1)

see comment below

::: media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp:130
(Diff revision 1)
> +
> +  void QueueVideoChunk(VideoChunk& aChunk, bool aForceBlack)
> +  {
> +    const int32_t queueThrottlingLimit = 3;
> +    if (mLength > queueThrottlingLimit) {
> +      return;

We should log this (at least a verbose level).  Also you should comment about what this does, and why 3 was selected.   3 frames means perhaps 100ms of delay at 30fps, and much more at lower frame rates.  What's the practical impact of having a limit of 0 (i.e. no queuing?)

::: media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp:141
(Diff revision 1)
> +
> +    bool forceBlack = aForceBlack || aChunk.mFrame.GetForceBlack();
> +
> +    if (forceBlack) {
> +      // Reset the last-img check.
> +      last_img_ = -1;

ditto on the invalid serial

::: media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp:222
(Diff revision 1)
> +    }
> +  }
> +
> +  void ProcessVideoFrame(Image* aImage, bool aForceBlack)
> +  {
> +    --mLength;

perhaps comment // Atomic
Do we need a full barrier here (default) or can it be relaxed?  (and how much does that matter)

::: media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp:385
(Diff revision 1)
> +    int half_height = (size.height + 1) >> 1;
> +    int c_size = half_width * half_height;
> +    int buffer_size = YSIZE(size.width, size.height) + 2 * c_size;
> +    auto yuv_scoped = MakeUniqueFallible<uint8[]>(buffer_size);
> +    if (!yuv_scoped)
> +      return;

add braces since we're tocuhing this

::: media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp:435
(Diff revision 1)
> +
> +  Atomic<int32_t> mLength;
> +  RefPtr<TaskQueue> mTaskQueue;
> +
> +  // Written and read from the queueing thread (normally MSG).
> +  int32_t last_img_; // serial number of last Image

comment (and verify) that -1 is a guaranteed invalid serial number (is there a define for that?)
https://reviewboard.mozilla.org/r/32171/#review40751

That code must be because I rebased between rev 4 and 5. Both items you picked out that were marked changed in my diff are in the parent rev..

When roc r+ed this, I was passing a serial number for principals through MSG, to make principals uniquely identifiable. New for you is that I'm now passing a `nsMainThreadPtrHandle<nsIPrincipal>` instead, based on input from bholley.

> this is a merge from m-c, right?

Correct.

> minor style... I'd just use
> if (NS_FAILED(principal->Equals(...))) {
>    NS_ERROR(...);
>    return false;
> }
> return result;

Fixed!

> Why is this showing up here as a change?  This landed in m-c....

That must be because I rebased between my revs 4 and 5. Reviewboard should arguably ignore this, and I think that's worked on.
https://reviewboard.mozilla.org/r/41019/#review40683

> I presume other methods/structs in this area are using unsigned short for width/height.  If not, make it match.

Yeah, this is from VideoConduit::SendVideoFrame. https://dxr.mozilla.org/mozilla-central/rev/9bd90088875399347b05d87c67d3709e31539dcd/media/webrtc/signaling/src/media-conduit/VideoConduit.h#195

> We should log this (at least a verbose level).  Also you should comment about what this does, and why 3 was selected.   3 frames means perhaps 100ms of delay at 30fps, and much more at lower frame rates.  What's the practical impact of having a limit of 0 (i.e. no queuing?)

Done. See what you think.

> perhaps comment // Atomic
> Do we need a full barrier here (default) or can it be relaxed?  (and how much does that matter)

I had to look a bit into atomics and ordering for this. While I think it's fine for what we want to do it surely makes it hard to reason about, including performance. I guess the perf impact comes down to the CPU executing it.

Worst case that will happen if I got this right, is that it takes a bit longer before we notice that the consumer has caught up again.

> comment (and verify) that -1 is a guaranteed invalid serial number (is there a define for that?)

I just moved this from the MediaPipelineTransmit::PipelineListener constructor.

Then according to our IRC conversation, we'll go with this since it's been in our code a long time, and impact at wrap-around is low. I filed bug 1262134 for getting a clarification.
Comment on attachment 8711416 [details]
MozReview Request: Bug 1208371 - Add PrincipalHandle to MediaChunks. r?mt,jesup

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32171/diff/5-6/
Attachment #8735727 - Flags: review?(rjesup)
Comment on attachment 8711417 [details]
MozReview Request: Bug 1208371 - Add `NotifyPrincipalHandleChanged` to MediaStreamTrackListener. r?mt,jesup

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32173/diff/5-6/
Comment on attachment 8711418 [details]
MozReview Request: Bug 1208371 - Add a PrincipalHandleListener to MediaStreamTrack. r?mt,jesup

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32175/diff/5-6/
Comment on attachment 8711419 [details]
MozReview Request: Bug 1208371 - Hook up DecodedStream with PrincipalHandle. r?mt,jwwang

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32177/diff/5-6/
Comment on attachment 8711420 [details]
MozReview Request: Bug 1208371 - Hook up MediaPipeline with PrincipalHandle. r?mt,bwc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32179/diff/5-6/
Comment on attachment 8711421 [details]
MozReview Request: Bug 1208371 - Ensure DOMMediaStream principals reflect what could reside in their playback streams. r?mt,jesup

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32181/diff/5-6/
Comment on attachment 8711422 [details]
MozReview Request: Bug 1208371 - Ensure a media element's ImageContainer is protected when playing a stream. r?mt,jesup

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32183/diff/5-6/
Comment on attachment 8711423 [details]
MozReview Request: Bug 1208371 - Forward declare MediaStreamTrack in MediaPipeline.h. r?bwc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32185/diff/5-6/
Comment on attachment 8711424 [details]
MozReview Request: Bug 1208371 - Clean up unnecessary virtuals in MediaPipeline. r?bwc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32187/diff/5-6/
Comment on attachment 8711425 [details]
MozReview Request: Bug 1208371 - Move MediaStreamTrack's label to MediaStreamTrackSource. r?jib

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32189/diff/5-6/
Comment on attachment 8711426 [details]
MozReview Request: Bug 1208371 - Move GetCurrentTime undef to DOMMediaStream.cpp. r?jesup

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32191/diff/5-6/
Comment on attachment 8711427 [details]
MozReview Request: Bug 1208371 - Forward declare MediaStreamGraph classes in MediaPipeline.h. r?bwc

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32193/diff/5-6/
Comment on attachment 8711428 [details]
MozReview Request: Bug 1208371 - Forward declare DOMMediaStream in HTMLMediaElement.h. r?jesup

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/32195/diff/5-6/
Comment on attachment 8735723 [details]
MozReview Request: Bug 1208371 - Never send more than one disabled frame in a row to the WebRTC encoder. r?jesup

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/41011/diff/1-2/
Comment on attachment 8735724 [details]
MozReview Request: Bug 1208371 - Don't treat audio chunks as mutable in MediaPipeline. r?padenot

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/41013/diff/1-2/
Comment on attachment 8735725 [details]
MozReview Request: Bug 1208371 - Update sink identity after adding track. r?mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/41015/diff/1-2/
Comment on attachment 8735726 [details]
MozReview Request: Bug 1208371 - Don't push frames as they come in to MediaEngine. r?jesup

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/41017/diff/1-2/
Comment on attachment 8735727 [details]
MozReview Request: Bug 1208371 - Do image format conversion async in MediaPipeline. r?jesup

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/41019/diff/1-2/
Comment on attachment 8735727 [details]
MozReview Request: Bug 1208371 - Do image format conversion async in MediaPipeline. r?jesup

https://reviewboard.mozilla.org/r/41019/#review41051
Attachment #8735727 - Flags: review?(rjesup) → review+
https://hg.mozilla.org/integration/mozilla-inbound/rev/d169710ece91
https://hg.mozilla.org/integration/mozilla-inbound/rev/6a5a585f1a2b
https://hg.mozilla.org/integration/mozilla-inbound/rev/0e67203c73ff
https://hg.mozilla.org/integration/mozilla-inbound/rev/aeffc7ef6fea
https://hg.mozilla.org/integration/mozilla-inbound/rev/987bb0e75a34
https://hg.mozilla.org/integration/mozilla-inbound/rev/e7e2b6a1275e
https://hg.mozilla.org/integration/mozilla-inbound/rev/2f5a37a6a06d
https://hg.mozilla.org/integration/mozilla-inbound/rev/d52afb558df4
https://hg.mozilla.org/integration/mozilla-inbound/rev/f7580ab5826a
https://hg.mozilla.org/integration/mozilla-inbound/rev/f65172114712
https://hg.mozilla.org/integration/mozilla-inbound/rev/f738214b89b3
https://hg.mozilla.org/integration/mozilla-inbound/rev/d602e5f8c5df
https://hg.mozilla.org/integration/mozilla-inbound/rev/da9581059827
https://hg.mozilla.org/integration/mozilla-inbound/rev/49c2839c3cf9
https://hg.mozilla.org/integration/mozilla-inbound/rev/4ad566b38eba
https://hg.mozilla.org/integration/mozilla-inbound/rev/ce9ca4390483
https://hg.mozilla.org/integration/mozilla-inbound/rev/06d9ea133491
https://hg.mozilla.org/integration/mozilla-inbound/rev/e261fd0b3b9c
https://hg.mozilla.org/integration/mozilla-inbound/rev/63151a093538
https://hg.mozilla.org/integration/mozilla-inbound/rev/3d0f2daf1874
https://hg.mozilla.org/integration/mozilla-inbound/rev/6447efd6b5f9
https://hg.mozilla.org/integration/mozilla-inbound/rev/7f030dca26eb
https://hg.mozilla.org/integration/mozilla-inbound/rev/08174b0f9d87
https://hg.mozilla.org/integration/mozilla-inbound/rev/09ee80f2de37
https://hg.mozilla.org/integration/mozilla-inbound/rev/5efb416a6069
https://hg.mozilla.org/integration/mozilla-inbound/rev/e8d5ce427db1
https://hg.mozilla.org/integration/mozilla-inbound/rev/8f79ba90f5e6
https://hg.mozilla.org/integration/mozilla-inbound/rev/ef7d3bf2b554
https://hg.mozilla.org/integration/mozilla-inbound/rev/a159aead2ed4
https://hg.mozilla.org/integration/mozilla-inbound/rev/f90d9c271677
https://hg.mozilla.org/integration/mozilla-inbound/rev/62dec1840f48
https://hg.mozilla.org/integration/mozilla-inbound/rev/d11c35de46c9
https://hg.mozilla.org/integration/mozilla-inbound/rev/5ed0b0214bfd
https://hg.mozilla.org/integration/mozilla-inbound/rev/938ccbd14acb
https://hg.mozilla.org/integration/mozilla-inbound/rev/69e3123ba0cc
https://hg.mozilla.org/integration/mozilla-inbound/rev/9b9a6dbb6eea
https://hg.mozilla.org/integration/mozilla-inbound/rev/67aec27a919c
https://hg.mozilla.org/integration/mozilla-inbound/rev/e11ca9dbdfc3
https://hg.mozilla.org/integration/mozilla-inbound/rev/452ffa3e728f
https://hg.mozilla.org/integration/mozilla-inbound/rev/15797c46bf03
https://hg.mozilla.org/integration/mozilla-inbound/rev/2891bacb6dde
https://hg.mozilla.org/integration/mozilla-inbound/rev/5b67e879cfaa
https://hg.mozilla.org/integration/mozilla-inbound/rev/62696c71c680
https://hg.mozilla.org/integration/mozilla-inbound/rev/18b4e37daae6
https://hg.mozilla.org/integration/mozilla-inbound/rev/2e7f1cef9108
https://hg.mozilla.org/integration/mozilla-inbound/rev/6bf46643d3d7
https://hg.mozilla.org/integration/mozilla-inbound/rev/d3ad0c0579de
https://hg.mozilla.org/integration/mozilla-inbound/rev/7fdc9f0e127e
https://hg.mozilla.org/integration/mozilla-inbound/rev/47197660d76d
https://hg.mozilla.org/integration/mozilla-inbound/rev/ffa89f45c70e
https://hg.mozilla.org/integration/mozilla-inbound/rev/1e531196e085
https://hg.mozilla.org/integration/mozilla-inbound/rev/0df411e1454d
https://hg.mozilla.org/integration/mozilla-inbound/rev/96ec240216e2
https://hg.mozilla.org/integration/mozilla-inbound/rev/f8bbe9a49447
https://hg.mozilla.org/integration/mozilla-inbound/rev/45a432065e0f
https://hg.mozilla.org/integration/mozilla-inbound/rev/000fe13145c4
https://hg.mozilla.org/integration/mozilla-inbound/rev/9acf7dea2588
https://hg.mozilla.org/integration/mozilla-inbound/rev/9f55c5fc20f9
https://hg.mozilla.org/integration/mozilla-inbound/rev/f52964d42db8
https://hg.mozilla.org/integration/mozilla-inbound/rev/15de05d6a316
https://hg.mozilla.org/integration/mozilla-inbound/rev/3e17268608a3
https://hg.mozilla.org/integration/mozilla-inbound/rev/50da13b5c507
https://hg.mozilla.org/integration/mozilla-inbound/rev/8cff901ef29d
https://hg.mozilla.org/integration/mozilla-inbound/rev/2b448b06d6aa
https://hg.mozilla.org/integration/mozilla-inbound/rev/49a3857c6868
https://hg.mozilla.org/integration/mozilla-inbound/rev/7b3edee97b25
https://hg.mozilla.org/integration/mozilla-inbound/rev/61a778ea5288
https://hg.mozilla.org/integration/mozilla-inbound/rev/0c907897958d
https://hg.mozilla.org/integration/mozilla-inbound/rev/9d11ad3a0bf4
https://hg.mozilla.org/integration/mozilla-inbound/rev/a60fb891f103
https://hg.mozilla.org/integration/mozilla-inbound/rev/b743d0c584b0
https://hg.mozilla.org/integration/mozilla-inbound/rev/8f6e5b69d815
https://hg.mozilla.org/integration/mozilla-inbound/rev/5424076e6774
https://hg.mozilla.org/integration/mozilla-inbound/rev/cccddf97d91e
https://hg.mozilla.org/integration/mozilla-inbound/rev/56c5c5547997
https://hg.mozilla.org/integration/mozilla-inbound/rev/1b244668d4ef
https://hg.mozilla.org/integration/mozilla-inbound/rev/178ef911672e
https://hg.mozilla.org/integration/mozilla-inbound/rev/dcc81f090c9c
https://hg.mozilla.org/integration/mozilla-inbound/rev/043eba623b66
https://hg.mozilla.org/integration/mozilla-inbound/rev/914a5488d905
https://hg.mozilla.org/integration/mozilla-inbound/rev/ce5a05155b60
https://hg.mozilla.org/integration/mozilla-inbound/rev/08e7e6ddff87
https://hg.mozilla.org/integration/mozilla-inbound/rev/4d753fefa776
https://hg.mozilla.org/integration/mozilla-inbound/rev/c6bc774c70a0
https://hg.mozilla.org/integration/mozilla-inbound/rev/9a6c27051238
https://hg.mozilla.org/integration/mozilla-inbound/rev/bc51bc211815
https://hg.mozilla.org/integration/mozilla-inbound/rev/72e28ac8e542
https://hg.mozilla.org/integration/mozilla-inbound/rev/7e8bffba9688
https://hg.mozilla.org/integration/mozilla-inbound/rev/7bc17d548c9a
https://hg.mozilla.org/integration/mozilla-inbound/rev/d2f2af7a92ec
https://hg.mozilla.org/integration/mozilla-inbound/rev/9bf356b402b5
https://hg.mozilla.org/integration/mozilla-inbound/rev/e67192879d48
https://hg.mozilla.org/integration/mozilla-inbound/rev/72c2bc247b28
https://hg.mozilla.org/integration/mozilla-inbound/rev/b8f87a9c54d8
https://hg.mozilla.org/integration/mozilla-inbound/rev/d599fc36575d
https://hg.mozilla.org/integration/mozilla-inbound/rev/f0d3d4e374e5
https://hg.mozilla.org/integration/mozilla-inbound/rev/7af35425dc80
https://hg.mozilla.org/integration/mozilla-inbound/rev/452ce28ce3f7
https://hg.mozilla.org/integration/mozilla-inbound/rev/a6ddd6c83437
https://hg.mozilla.org/integration/mozilla-inbound/rev/a2cdbd2df8b6
https://hg.mozilla.org/integration/mozilla-inbound/rev/469e29166c55
https://hg.mozilla.org/integration/mozilla-inbound/rev/64929919a925
https://hg.mozilla.org/integration/mozilla-inbound/rev/00ae81e574ed
https://hg.mozilla.org/integration/mozilla-inbound/rev/b06d6ff27862
https://hg.mozilla.org/integration/mozilla-inbound/rev/da8d6c4eab61
Depends on: 1262808
https://hg.mozilla.org/mozilla-central/rev/d169710ece91
https://hg.mozilla.org/mozilla-central/rev/6a5a585f1a2b
https://hg.mozilla.org/mozilla-central/rev/0e67203c73ff
https://hg.mozilla.org/mozilla-central/rev/aeffc7ef6fea
https://hg.mozilla.org/mozilla-central/rev/987bb0e75a34
https://hg.mozilla.org/mozilla-central/rev/e7e2b6a1275e
https://hg.mozilla.org/mozilla-central/rev/2f5a37a6a06d
https://hg.mozilla.org/mozilla-central/rev/d52afb558df4
https://hg.mozilla.org/mozilla-central/rev/f7580ab5826a
https://hg.mozilla.org/mozilla-central/rev/f65172114712
https://hg.mozilla.org/mozilla-central/rev/f738214b89b3
https://hg.mozilla.org/mozilla-central/rev/d602e5f8c5df
https://hg.mozilla.org/mozilla-central/rev/da9581059827
https://hg.mozilla.org/mozilla-central/rev/49c2839c3cf9
https://hg.mozilla.org/mozilla-central/rev/4ad566b38eba
https://hg.mozilla.org/mozilla-central/rev/ce9ca4390483
https://hg.mozilla.org/mozilla-central/rev/06d9ea133491
https://hg.mozilla.org/mozilla-central/rev/e261fd0b3b9c
https://hg.mozilla.org/mozilla-central/rev/63151a093538
https://hg.mozilla.org/mozilla-central/rev/3d0f2daf1874
https://hg.mozilla.org/mozilla-central/rev/6447efd6b5f9
https://hg.mozilla.org/mozilla-central/rev/7f030dca26eb
https://hg.mozilla.org/mozilla-central/rev/08174b0f9d87
https://hg.mozilla.org/mozilla-central/rev/09ee80f2de37
https://hg.mozilla.org/mozilla-central/rev/5efb416a6069
https://hg.mozilla.org/mozilla-central/rev/e8d5ce427db1
https://hg.mozilla.org/mozilla-central/rev/8f79ba90f5e6
https://hg.mozilla.org/mozilla-central/rev/ef7d3bf2b554
https://hg.mozilla.org/mozilla-central/rev/a159aead2ed4
https://hg.mozilla.org/mozilla-central/rev/f90d9c271677
https://hg.mozilla.org/mozilla-central/rev/62dec1840f48
https://hg.mozilla.org/mozilla-central/rev/d11c35de46c9
https://hg.mozilla.org/mozilla-central/rev/5ed0b0214bfd
https://hg.mozilla.org/mozilla-central/rev/938ccbd14acb
https://hg.mozilla.org/mozilla-central/rev/69e3123ba0cc
https://hg.mozilla.org/mozilla-central/rev/9b9a6dbb6eea
https://hg.mozilla.org/mozilla-central/rev/67aec27a919c
https://hg.mozilla.org/mozilla-central/rev/e11ca9dbdfc3
https://hg.mozilla.org/mozilla-central/rev/452ffa3e728f
https://hg.mozilla.org/mozilla-central/rev/15797c46bf03
https://hg.mozilla.org/mozilla-central/rev/2891bacb6dde
https://hg.mozilla.org/mozilla-central/rev/5b67e879cfaa
https://hg.mozilla.org/mozilla-central/rev/62696c71c680
https://hg.mozilla.org/mozilla-central/rev/18b4e37daae6
https://hg.mozilla.org/mozilla-central/rev/2e7f1cef9108
https://hg.mozilla.org/mozilla-central/rev/6bf46643d3d7
https://hg.mozilla.org/mozilla-central/rev/d3ad0c0579de
https://hg.mozilla.org/mozilla-central/rev/7fdc9f0e127e
https://hg.mozilla.org/mozilla-central/rev/47197660d76d
https://hg.mozilla.org/mozilla-central/rev/ffa89f45c70e
https://hg.mozilla.org/mozilla-central/rev/1e531196e085
https://hg.mozilla.org/mozilla-central/rev/0df411e1454d
https://hg.mozilla.org/mozilla-central/rev/96ec240216e2
https://hg.mozilla.org/mozilla-central/rev/f8bbe9a49447
https://hg.mozilla.org/mozilla-central/rev/45a432065e0f
https://hg.mozilla.org/mozilla-central/rev/000fe13145c4
https://hg.mozilla.org/mozilla-central/rev/9acf7dea2588
https://hg.mozilla.org/mozilla-central/rev/9f55c5fc20f9
https://hg.mozilla.org/mozilla-central/rev/f52964d42db8
https://hg.mozilla.org/mozilla-central/rev/15de05d6a316
https://hg.mozilla.org/mozilla-central/rev/3e17268608a3
https://hg.mozilla.org/mozilla-central/rev/50da13b5c507
https://hg.mozilla.org/mozilla-central/rev/8cff901ef29d
https://hg.mozilla.org/mozilla-central/rev/2b448b06d6aa
https://hg.mozilla.org/mozilla-central/rev/49a3857c6868
https://hg.mozilla.org/mozilla-central/rev/7b3edee97b25
https://hg.mozilla.org/mozilla-central/rev/61a778ea5288
https://hg.mozilla.org/mozilla-central/rev/0c907897958d
https://hg.mozilla.org/mozilla-central/rev/9d11ad3a0bf4
https://hg.mozilla.org/mozilla-central/rev/a60fb891f103
https://hg.mozilla.org/mozilla-central/rev/b743d0c584b0
https://hg.mozilla.org/mozilla-central/rev/8f6e5b69d815
https://hg.mozilla.org/mozilla-central/rev/5424076e6774
https://hg.mozilla.org/mozilla-central/rev/cccddf97d91e
https://hg.mozilla.org/mozilla-central/rev/56c5c5547997
https://hg.mozilla.org/mozilla-central/rev/1b244668d4ef
https://hg.mozilla.org/mozilla-central/rev/178ef911672e
https://hg.mozilla.org/mozilla-central/rev/dcc81f090c9c
https://hg.mozilla.org/mozilla-central/rev/043eba623b66
https://hg.mozilla.org/mozilla-central/rev/914a5488d905
https://hg.mozilla.org/mozilla-central/rev/ce5a05155b60
https://hg.mozilla.org/mozilla-central/rev/08e7e6ddff87
https://hg.mozilla.org/mozilla-central/rev/4d753fefa776
https://hg.mozilla.org/mozilla-central/rev/c6bc774c70a0
https://hg.mozilla.org/mozilla-central/rev/9a6c27051238
https://hg.mozilla.org/mozilla-central/rev/bc51bc211815
https://hg.mozilla.org/mozilla-central/rev/72e28ac8e542
https://hg.mozilla.org/mozilla-central/rev/7e8bffba9688
https://hg.mozilla.org/mozilla-central/rev/7bc17d548c9a
https://hg.mozilla.org/mozilla-central/rev/d2f2af7a92ec
https://hg.mozilla.org/mozilla-central/rev/9bf356b402b5
https://hg.mozilla.org/mozilla-central/rev/e67192879d48
https://hg.mozilla.org/mozilla-central/rev/72c2bc247b28
https://hg.mozilla.org/mozilla-central/rev/b8f87a9c54d8
https://hg.mozilla.org/mozilla-central/rev/d599fc36575d
https://hg.mozilla.org/mozilla-central/rev/f0d3d4e374e5
https://hg.mozilla.org/mozilla-central/rev/7af35425dc80
https://hg.mozilla.org/mozilla-central/rev/452ce28ce3f7
https://hg.mozilla.org/mozilla-central/rev/a6ddd6c83437
https://hg.mozilla.org/mozilla-central/rev/a2cdbd2df8b6
https://hg.mozilla.org/mozilla-central/rev/469e29166c55
https://hg.mozilla.org/mozilla-central/rev/64929919a925
https://hg.mozilla.org/mozilla-central/rev/00ae81e574ed
https://hg.mozilla.org/mozilla-central/rev/b06d6ff27862
https://hg.mozilla.org/mozilla-central/rev/da8d6c4eab61
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla48
Depends on: 1265962
Depends on: 1266680
Depends on: 1266685
Depends on: 1266926
Depends on: 1274221
Depends on: 1275596
Depends on: 1297099
Updated https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/clone. Firefox 48 for developers was already up to date.
MediaStream.clone()?
Flags: needinfo?(eshepherd)
(In reply to Andreas Pehrson [:pehrsons] (Telenor) from comment #1172)
> MediaStream.clone()?

Good catch: https://developer.mozilla.org/en-US/docs/Web/API/MediaStream/clone :)
Flags: needinfo?(eshepherd)
Depends on: 1266345
Flags: needinfo?(rjesup)
You need to log in before you can comment on or make changes to this bug.