Commit Graph

1369 Commits

Author SHA1 Message Date
Andreas Pehrson
02a55ec5a1 Bug 1592539 - Inject a FirstFrameVideoOutput into MediaStreamRenderer. r=jib
This allows different users of renderers to inject different first frame
outputs. So far there is only one, but a future patch will bring a special one
for the secondary video frame container.

Differential Revision: https://phabricator.services.mozilla.com/D87137
2020-08-26 14:25:20 +00:00
Andreas Pehrson
cc22d15799 Bug 1592539 - Also null out mMediaStreamRenderer in Unlink. r=bryce
I have observed async calls to the MediaStreamRenderer's mWatchManager::Unwatch()
in flight after it was Shutdown(). This would cause an assertion failure in
debug. Per the comment we should do the same in Unlink as
EndSrcMediaStreamPlayback() without creating new strong refs. This conforms to
that instruction.

I am not willing to null out the other members at this point, since at least
HTMLVideoElement's relies on the selected video track to exist in some cases.

Differential Revision: https://phabricator.services.mozilla.com/D87136
2020-08-26 14:25:08 +00:00
Andreas Pehrson
580236ee61 Bug 1592539 - Move the FirstFrameListener to VideoOutput.h. r=jib
This allows the FirstFrameListener to be instantiated outside of
HTMLMediaElement. A future patch brings in a subclass in HTMLVideoElement.

This also renames FirstFrameListener to FirstFrameVideoOutput since that better
denotes what it is.

Differential Revision: https://phabricator.services.mozilla.com/D87135
2020-08-26 14:25:05 +00:00
Andreas Pehrson
fe4286e0d6 Bug 1592539 - Move the FirstFrameListener handling to MediaStreamRenderer. r=jib
This unclutters HTMLMediaElement somewhat by putting away the logic for handling
the FirstFrameListener into MediaStreamRenderer, which is better suited for the
task.

This will allow us to use a second MediaStreamRenderer to properly track video
tracks for a secondary VideoFrameContainer.

Differential Revision: https://phabricator.services.mozilla.com/D87134
2020-08-26 14:24:55 +00:00
Jan-Ivar Bruaroey
008cb1c6ac Bug 1652884 - Rename MediaTrack::SetEnabled to SetDisabledTrackMode. r=pehrsons
Differential Revision: https://phabricator.services.mozilla.com/D86070
2020-08-19 22:18:04 +00:00
Bogdan Tara
2d0c10523f Backed out 14 changesets (bug 1652884) for test_peerConnection_trackDisabling.html failures CLOSED TREE
Backed out changeset f83951453e94 (bug 1652884)
Backed out changeset fc697986d538 (bug 1652884)
Backed out changeset 20a10128b5e1 (bug 1652884)
Backed out changeset c99c32323c76 (bug 1652884)
Backed out changeset 991e8975f03d (bug 1652884)
Backed out changeset 9e9511e32cdd (bug 1652884)
Backed out changeset 605c1ac3081a (bug 1652884)
Backed out changeset dd6edf636659 (bug 1652884)
Backed out changeset 74a2f5a9eea2 (bug 1652884)
Backed out changeset b9f419aed12d (bug 1652884)
Backed out changeset 84e82e25929f (bug 1652884)
Backed out changeset 876dbad27af5 (bug 1652884)
Backed out changeset 8f60e3af2a19 (bug 1652884)
Backed out changeset de7537bda499 (bug 1652884)
2020-08-20 01:13:29 +03:00
Jan-Ivar Bruaroey
87f22f3b67 Bug 1652884 - Rename MediaTrack::SetEnabled to SetDisabledTrackMode. r=pehrsons
Differential Revision: https://phabricator.services.mozilla.com/D86070
2020-08-19 19:30:50 +00:00
Bogdan Tara
e05e174ffa Backed out 14 changesets (bug 1652884) for VideoFrameConverter related failures CLOSED TREE
Backed out changeset 28c4e8c373f0 (bug 1652884)
Backed out changeset 658ba8f39abe (bug 1652884)
Backed out changeset 8e67fe040e4a (bug 1652884)
Backed out changeset 6f5833203763 (bug 1652884)
Backed out changeset 569ff85dfc2e (bug 1652884)
Backed out changeset eaa171643447 (bug 1652884)
Backed out changeset 6b37b60b6662 (bug 1652884)
Backed out changeset 438cce7456fb (bug 1652884)
Backed out changeset e6ed13952b67 (bug 1652884)
Backed out changeset e0b1266231bf (bug 1652884)
Backed out changeset 32f4aae2b5fe (bug 1652884)
Backed out changeset 76b4abccd61b (bug 1652884)
Backed out changeset 9010365ffa66 (bug 1652884)
Backed out changeset 763f39eb5c13 (bug 1652884)
2020-08-19 22:21:31 +03:00
Jan-Ivar Bruaroey
1ebcf3b11a Bug 1652884 - Rename MediaTrack::SetEnabled to SetDisabledTrackMode. r=pehrsons
Differential Revision: https://phabricator.services.mozilla.com/D86070
2020-08-19 14:03:32 +00:00
alwu
e7c70b7753 Bug 1656642 - part2 : prevent to start controller for non-playable media even if it enters fullscreen/PIP mode. r=chunmin
When a media without src or with error enters fullscreen or PIP mode, we don't want to control it. Therefore, we shouldn't start the listener for it.

In addition, updating PIP/fullscreen state no matter the listener starts or not. See following example.

1. Play a media and it enter PIP/fullscreen (it would update `state=true`)
2. abort the current src (that would stop the listener)
3. leave PIP/fullscreen (in this case, we don't have src, so the listener won't start, but we still need to update the `state` to `false`)

Differential Revision: https://phabricator.services.mozilla.com/D85785
2020-08-13 19:16:18 +00:00
alwu
a014325046 Bug 1654657 - part1 : update fullscreen change in media element. r=chunmin
Calling `NotifyMediaFullScreenState()` is related with updating state on media controller, which is only used for media element. So it'd  be better to move that into media element.

Differential Revision: https://phabricator.services.mozilla.com/D85513
2020-08-14 01:23:28 +00:00
alwu
9157b66327 Bug 1657224 - add a pref to control stopping media after media reaches to the end. r=chunmin
In bug1654045, we would stop controlling media once media reaches to the end. Considering some user might still want to control media by pressing media keys even if it has ended, so adding a pref to control this abilitiy.

Differential Revision: https://phabricator.services.mozilla.com/D85930
2020-08-05 23:12:16 +00:00
alwu
9116dcb890 Bug 1654045 - part1 : stop listening to the media keys when media reaches to the end. r=chunmin
Our current implementation is to allow to resume media by using media key after media reaches the the end. However, we don't know how many users would really use media key like that, and if they don't use media key in this way.

The benefit to use that approach are (1) being able to give media key controllability back to other applications which are really playing media (2) to avoid possible compatibility issue (Chrome has been using this approach as well)

Differential Revision: https://phabricator.services.mozilla.com/D85228
2020-07-31 00:05:02 +00:00
alwu
292bd60882 Bug 1654277 - part3 : add a test for only resuming latest paused media. r=chunmin
Differential Revision: https://phabricator.services.mozilla.com/D84879
2020-07-29 23:39:09 +00:00
alwu
3927087eb5 Bug 1654277 - part2 : pause playing media but stop already paused media when receiving 'pause'. r=chunmin
We want to modify our current behavior from "resuming all media" to "resuming latest paused media" when pressing `play` media key.

The reason of doing that is because that give us better user experience, espeically on Facebook. Chrome has been taking this approach, so we want to follow this strategy. The test in D84879 can help to understand this scenario.

Differential Revision: https://phabricator.services.mozilla.com/D85118
2020-07-30 04:01:08 +00:00
alwu
ff1ca2df82 Bug 1655204 - part3 : start listening to media control keys once media starts again. r=chunmin
For media which has been stopped via media key `Stop`, we should start controlling it if it starts playing again.

Differential Revision: https://phabricator.services.mozilla.com/D85102
2020-07-29 22:15:54 +00:00
alwu
05987c5c1d Bug 1655204 - part1 : stop being controlled by media control keys when media element receives Stop. r=chunmin
Currently, we treat `pause` and `stop` equally, but `stop` is actully implying more meaning, which should stop controlling media entirely. Therefore, we would pause media and stop controlling it when receiving `stop`.

In addition, removing pause state checking, because it wouldn't happen anything to call `play()` and `pause()` if media is already playing or paused.

Differential Revision: https://phabricator.services.mozilla.com/D84875
2020-07-29 22:15:50 +00:00
emcminn
08ddcd3855 Bug 1655765 - Add media permission for about:welcome privacy page mp4 r=ckerschb
Differential Revision: https://phabricator.services.mozilla.com/D85192
2020-07-29 08:27:34 +00:00
alwu
f1edd8d315 Bug 1655175 - avoid to access owner media element after unlink. r=bryce
`mElement` would be reset during CC unlink [1], so we should avoid to access it after unlink happens.

[1] https://searchfox.org/mozilla-central/rev/828f2319c0195d7f561ed35533aef6fe183e68e3/dom/html/HTMLMediaElement.cpp#2027

Differential Revision: https://phabricator.services.mozilla.com/D84890
2020-07-27 19:37:04 +00:00
Emilio Cobos Álvarez
af37b13df9 Bug 1652618 - Ensure UA widgets are attached and detached synchronously. r=smaug
This changes the UA widget setup (again). What is going on in this
test-case is that we have a marquee inside a video, two things that have
their own UA widget. Given how the code is currently written, the
runnable to attach and set up the marquee's widget is posted before than
the video one (which is potentially reasonable).

However that means that the marquee one runs before and flushes layout,
and catches the video in an inconsistent state (in the composed doc, but
without a shadow root). That in turn messes up reflow because
nsVideoFrame assumes stuff.

Rather than putting the attach / detach logic in script runners, just
run that bit synchronously, and post only the event async. I audited the
consumers of those events and it seems fine to me, they either already
deal with the possibility of the shadow root being already detached or
they don't care.

For teardown, none of the destructors of the UA widgets rely on the
shadow root being still attached to the element.

Differential Revision: https://phabricator.services.mozilla.com/D84487
2020-07-24 15:43:20 +00:00
alwu
481542192d Bug 1654959 - part2 : start listener when media enters PIP mode. r=bryce
When a media enters PIP mode, we should consider it as an important one which user might want to control. Therefore, start the listener in order to notify the media has been started, then we would update the PIP state [1] which would activate the controller.

As the PIP state changes can happen after `Stop()` is called, so in this patch, we would remove the start check and reset `mControlAgent` in `Stop()` in order to update PIP state after the listener stops. Eg. Reset the PIP video's src, then cancel the PIP.

[1] https://searchfox.org/mozilla-central/rev/9b282b34b5aa0f836beb735656c55efb2cc4c617/dom/html/HTMLMediaElement.cpp#7902

Differential Revision: https://phabricator.services.mozilla.com/D84119
2020-07-24 02:43:25 +00:00
alwu
9446b79dcc Bug 1654959 - part1 : start listener when media enters fullscreen. r=bryce
When a media enters fullscreen mode, we should consider it as an important one which user might want to control. Therefore, start the listener in order to notify the media has been started, then we would update the fullscreen state [1] which would activate the controller.

[1] https://searchfox.org/mozilla-central/rev/9b282b34b5aa0f836beb735656c55efb2cc4c617/dom/base/Document.cpp#13429

Differential Revision: https://phabricator.services.mozilla.com/D84118
2020-07-24 02:43:33 +00:00
alwu
d3a1305ba2 Bug 1653390 - part6 : add audible check back in media element. r=bryce
In D73335, we remove those check which causes a regression where inaudible media is also able to be controlled by media control keys.

In order not to control those inaudible media, we should add the check back. If the media is inaudible, then we should not start the listener that would connect media element to the media control.

In addition, I also found that starting the listener for inaudible media would make the media controller's playback state incorrect, because the playback state is calculated by all controlled media. If an inaudible media is playing, the playback state should not consider that media.

Differential Revision: https://phabricator.services.mozilla.com/D84115
2020-07-24 02:43:33 +00:00
alwu
746a81005f Bug 1653390 - part5 : remove 'StopListeningMediaControlKeyIfNeeded()'. r=bryce
First, rename `Stop()` to `StopIfNeeded()`.

Second, we have already have a check [1] in `StopIfNeeded()` to ensure that that function is only workable when the listener starts, so we don't need `StopListeningMediaControlKeyIfNeeded()` and can call `StopIfNeeded()` directly.

[1] https://searchfox.org/mozilla-central/rev/9b282b34b5aa0f836beb735656c55efb2cc4c617/dom/html/HTMLMediaElement.cpp#425-427

Differential Revision: https://phabricator.services.mozilla.com/D84117
2020-07-23 21:33:31 +00:00
alwu
022d0f80fd Bug 1653390 - part4 : always hold a MediaControlKeyListener until media dies. r=bryce
It seems no much benefit to create `MediaControlKeyListener` lazily, we should create it in the start and destroy it in the end so that we don't need to check if `mMediaControlKeyListener` exists or not when we want to check if the listener starts.

Differential Revision: https://phabricator.services.mozilla.com/D84116
2020-07-23 21:33:23 +00:00
alwu
974b4c3cfd Bug 1653390 - part3 : wrap the detail of updating playback state into Start(). r=bryce
`NotifyMediaControlPlaybackStateChanged()` would be called when `mPaused` changes, but it would only take effect after the listener starts. If the media changes its `mPaused` before we starts listener, then we have to manully update `NotifyMediaControlPlaybackStateChanged()`.

However, I think wrapping this detail into `Start()` itself would be clearer.

Differential Revision: https://phabricator.services.mozilla.com/D84649
2020-07-23 21:32:58 +00:00
alwu
0d3d24993a Bug 1653390 - part2: allow calling 'UpdateMediaAudibleState()' before the listener starts. r=bryce
We already have a check to prevent notifying audible state before the listener starts [1], so we can remove the assertion and call it anytime in order to save the audible state correctly.

[1] https://searchfox.org/mozilla-central/rev/dcd9c2d2bc19d96d487825eb70c2333a4d60994e/dom/html/HTMLMediaElement.cpp#478-486

Differential Revision: https://phabricator.services.mozilla.com/D84650
2020-07-23 21:32:51 +00:00
alwu
0191e49d90 Bug 1653390 - part1 : remove start check. r=bryce
The reason of checking those conditions before calling `StartListeningMediaControlKeyIfNeeded()` is because we was only starting the listener after media starts, which has been modified in D79234.  Now we would start the listener before media starts, so we can remove that check.

Differential Revision: https://phabricator.services.mozilla.com/D84114
2020-07-23 21:32:43 +00:00
Narcis Beleuzu
338c569e68 Backed out changeset 8323b7bb5e1a (bug 1652618) for mochitest failures on test_audiocontrols_dimensions.html . CLOSED TREE 2020-07-23 00:49:31 +03:00
Emilio Cobos Álvarez
581585395d Bug 1652618 - Ensure UA widgets are attached and detached synchronously. r=smaug
This changes the UA widget setup (again). What is going on in this
test-case is that we have a marquee inside a video, two things that have
their own UA widget. Given how the code is currently written, the
runnable to attach and set up the marquee's widget is posted before than
the video one (which is potentially reasonable).

However that means that the marquee one runs before and flushes layout,
and catches the video in an inconsistent state (in the composed doc, but
without a shadow root). That in turn messes up reflow because
nsVideoFrame assumes stuff.

Rather than putting the attach / detach logic in script runners, just
run that bit synchronously, and post only the event async. I audited the
consumers of those events and it seems fine to me, they either already
deal with the possibility of the shadow root being already detached or
they don't care.

For teardown, none of the destructors of the UA widgets rely on the
shadow root being still attached to the element.

Differential Revision: https://phabricator.services.mozilla.com/D84487
2020-07-22 19:42:37 +00:00
Sebastian Streich
e3dac50418 Bug 1653563 - Remove nullptr usage in HTMLMediaElement.cpp r=ckerschb
Differential Revision: https://phabricator.services.mozilla.com/D84538
2020-07-22 16:46:41 +00:00
alwu
32d6dd6d5b Bug 1647430 - part3 : remove DocTreeHadPlayRevoked related variable and method. r=nika
The telemetry probe, which is related with `mDocTreeHadPlayRevoked`, has already been removed, so we don't need these code anymore.

Differential Revision: https://phabricator.services.mozilla.com/D83163
2020-07-13 15:16:29 +00:00
Sebastian Streich
de02494b5b Bug 1450853 - Use Generic Error for 3rdparty MediaElement r=ckerschb,smaug
***
Add test

Differential Revision: https://phabricator.services.mozilla.com/D80080
2020-07-16 12:03:38 +00:00
Frederik Braun
617d3006d9 Bug 1366973: Rename security flags to not contain DATA anymore r=geckoview-reviewers,ckerschb,snorp
Differential Revision: https://phabricator.services.mozilla.com/D83490
2020-07-15 11:20:45 +00:00
alwu
671a611a88 Bug 1652460 - part1 : always store the audible state change. r=bryce
Whenever the audible state changes, we should always store the latest state but only notify the change after playing starts.

Differential Revision: https://phabricator.services.mozilla.com/D83549
2020-07-14 22:01:43 +00:00
Razvan Maries
734e444ca6 Backed out changeset 6b518e88bdf9 (bug 1450853) for perma failures on empty-samples.webm. CLOSED TREE 2020-07-14 15:26:22 +03:00
Sebastian Streich
7d6032bb76 Bug 1450853 - Use Generic Error for 3rdparty MediaElement r=ckerschb,smaug
***
Add test

Differential Revision: https://phabricator.services.mozilla.com/D80080
2020-07-14 11:16:24 +00:00
Alex Chronopoulos
71d449f3c6 Bug 1651049 - Move the sink change logic in MediaStreamRenderer. r=padenot
The MediaStreamRenderer handles the AudioOutput of an HTMLMediaElement. it register/unregister the AudioOutput according to the rendering status. The sink-change follows the logic of AudioOutput thus it has been moved in it.

The previous way created an error when the element had been muted and the sink had been changed before the source MediaStream was attached to the element. The error occured because it was possible, the same entry to be registered more than once in the AudioOutput's list, which resulted in the track to be unmuted when it should not.

Differential Revision: https://phabricator.services.mozilla.com/D82529
2020-07-09 14:32:21 +00:00
alwu
a719910168 Bug 1647425 - part1 : dispatch chrome event to owner doc. r=kmag
We handle `GloballyAutoplayBlocked` event in `Autoplay` actors which exist in all frames [1], so we can actually dispatch the event directly from any document.

Then, we would find the correct top document in `AutoplayParentActor`[2].

[1] https://searchfox.org/mozilla-central/rev/5a4aaccb28665807a6fd49cf48367d47fbb5a19a/toolkit/modules/ActorManagerParent.jsm#118-130
[2] https://searchfox.org/mozilla-central/source/toolkit/actors/AutoplayParent.jsm#11-18

Differential Revision: https://phabricator.services.mozilla.com/D81764
2020-07-01 21:36:25 +00:00
Simon Giesecke
d2e71d5859 Bug 1648010 - Remove NS_NAMED_LITERAL_CSTRING and NS_NAMED_LITERAL_STRING macros. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D80631
2020-07-01 08:42:31 +00:00
Simon Giesecke
a69d79b6db Bug 1648010 - Replace uses of NS_LITERAL_STRING/NS_LITERAL_CSTRING macros by _ns literals. r=geckoview-reviewers,jgilbert,agi,hsivonen,froydnj
Differential Revision: https://phabricator.services.mozilla.com/D80860
2020-07-01 08:29:29 +00:00
alwu
c36b82d85c Bug 1645668 - part1 : reset audible state when aborting current load. r=bryce
When aborting the current load, media element is undoubtedly inaudible. Therefore, we should reset its audible state in order to keep the audible state correct. That can help us show the sound indicator on the tab bar correctly.

Differential Revision: https://phabricator.services.mozilla.com/D81631
2020-06-30 16:50:35 +00:00
longsonr
e9f98b4f97 Bug 1648463 - Move SVGForeignObjectFrame SVGImageFrame and SVGUseFrame to mozilla namespace r=dholbert,jgilbert
stop exposing SVGImageListener as only SVGImageFrame uses it.

Differential Revision: https://phabricator.services.mozilla.com/D81087
2020-06-25 20:42:49 +00:00
Alex Chronopoulos
bf5059a6bc Bug 1648159 - Remove unnecessary redirection of promises when sink changes. r=jya
At the end of `HTMLMediaElement::SetSrcMediaStreamSink` a redirection of MozPromises, from `GenericPromise::AllPromiseType` to `GenericPromise` is taking place. However, this is not necessary since this is an internal method and the returned value of the promise is not useful. Thus the `GenericPromise::AllPromiseType` can be returned directly and avoid the extra thread dispatch.

Differential Revision: https://phabricator.services.mozilla.com/D80908
2020-06-25 14:18:59 +00:00
alwu
531182719f Bug 1642715 - part2 : connect media to media controller after knowing its duration. r=chunmin
This patch would
- build the relationship between a media element and the media controller when media finishes loading, instead of building that after starting playing media

The advantage of doing this is
- the prework of being able to control media before media starts playing

Differential Revision: https://phabricator.services.mozilla.com/D79234
2020-06-24 05:52:33 +00:00
alwu
f96e1b5d04 Bug 1642715 - part1 : move timer to media controller. r=chunmin
This patch would
- move the mechanism of creating a stop timer from media element to media controller

The advantage of doing this is
- to remove redundant timers in the content process, because we only need to maintain one global timer for a whole tab

Differential Revision: https://phabricator.services.mozilla.com/D79233
2020-06-24 05:52:30 +00:00
Jean-Yves Avenard
05adafa9ef Bug 1637500 - P2. Rename methods as they are not always dealing with "threads". r=froydnj
Before P1, GetCurrentThreadSerialEventTarget would have always returned the same data as NS_GetCurrentThread, making the comment incorrect Now it will properly return the running TaskQueue if any.

This change of name more clearly exposes what they are doing, as we aren't always dealing with threads directly; but a nsISerialEventTarget

Differential Revision: https://phabricator.services.mozilla.com/D80354
2020-06-23 05:05:36 +00:00
alwu
b529005ccd Bug 1642590 - part1 : run internal pause when unbind media from DOM tree. r=bryce
This patch will
- run internal pause when removing a media from a document, instead of running `pause()` method

The advantage of doing so is
- to follow the spec [1]. In step 3, it mentions we should run internal pause, not pause.

[1] https://html.spec.whatwg.org/#playing-the-media-resource:remove-an-element-from-a-document

Differential Revision: https://phabricator.services.mozilla.com/D79925
2020-06-22 20:54:21 +00:00
Alex Chronopoulos
ea6c007735 Bug 1493990 - Enable sink change in the srcObject of HTMLMediaElement. r=padenot
The SetSinkId method of HTMLMediaElement has been enhanced to handle the sink change when the element is sourced with a MediaObject through the srcObject attribute. It makes use in the corresponding method of AudioStreamTrack taking into account the AudioOutput and Volume that has to be removed and re-added to the right track.

Differential Revision: https://phabricator.services.mozilla.com/D77809
2020-06-18 14:05:28 +00:00
alwu
5d3e5d3f60 Bug 1640998 - part9 : use MediaControlKey to replace MediaControlKeysEvent r=chunmin,agi,geckoview-reviewers
This patch will
- remove `MediaControlKeysEvent` and use `MediaControlKey` to replace it
- rename names for all `MediaControlKey` related methods, functions, classes and descriptions

The advantage of doing so are
- remove the duplicated type so that we only need to maintain `MediaControlKey`

Differential Revision: https://phabricator.services.mozilla.com/D78140
2020-06-09 02:59:57 +00:00