Bug 111079

Summary: MediaStream API: local addTrack() and removeTrack() operations should not fire events.
Product: WebKit Reporter: Adam Bergkvist <adam.bergkvist>
Component: WebCore Misc.Assignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: abarth, eric.carlson, feature-media-reviews, hta, jer.noble, tommyw, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 56459    
Attachments:
Description Flags
Proposed patch none

Description Adam Bergkvist 2013-02-28 07:33:14 PST
According to the spec, addTrack() and removeTrack() called by local JavaScript must not fire "addtrack" and "removetrack" events. The events must however fire if the track set is modified externally (e.g., a track is removed at the other peer in a p2p scenario).
Comment 1 Adam Bergkvist 2013-02-28 07:39:45 PST
Created attachment 190725 [details]
Proposed patch

I replaced the entire test since the old one was driven by the event dispatching removed by this patch.
Comment 2 Adam Barth 2013-02-28 11:42:07 PST
@tommyw: Thoughts?
Comment 3 Tommy Widenflycht 2013-03-01 00:48:10 PST
Since Adam is one of the main editors of the specification he very, very likely knows it better than me ;)

This patch looks just dandy to me, but maybe the spec needs a little bit of clarification exactly when the add/removeTrack events are thrown (only for streams originating from an remote peer).
Comment 4 Adam Barth 2013-03-01 09:57:04 PST
Comment on attachment 190725 [details]
Proposed patch

ok :)
Comment 5 WebKit Review Bot 2013-03-04 02:09:40 PST
Comment on attachment 190725 [details]
Proposed patch

Clearing flags on attachment: 190725

Committed r144610: <http://trac.webkit.org/changeset/144610>
Comment 6 WebKit Review Bot 2013-03-04 02:09:44 PST
All reviewed patches have been landed.  Closing bug.
Comment 7 Adam Bergkvist 2013-03-04 02:25:07 PST
Thanks :)

(In reply to comment #3)
> This patch looks just dandy to me, but maybe the spec needs a little bit of clarification exactly when the add/removeTrack events are thrown (only for streams originating from an remote peer).

I think the text describing these events suffered the most when we extracted the "Media Capture and Streams" stuff from the WebRTC spec. The events are defined in the "Media Capture" spec, but never used there; the usage is described in the WebRTC spec (Section "9.2.2 Events on MediaStream" [1]). Please provide some feedback if you think that section needs to be improved.

There's an non-normative "Event Summary" section in the "Media Capture" spec with short descriptive text for each event. The current text says: "A new MediaStreamTrack has been added to this stream.". We could change the text to make it more clear that these events are used to notify the script about external modifications to the track lists.

[1] http://dev.w3.org/2011/webrtc/editor/webrtc.html#events-on-mediastream