Commit Graph

1084 Commits

Author SHA1 Message Date
Kaku Kuo
77834d2806 Bug 1244768 part 1 - implement utilities which are the foundation of promise-based play operation; r=jwwang
In this patch, the following utilities are implemented:
(1) A list to keep pending promises of a HTMLMediaElement.
(2) A method to take pending promises out from the HTMLMediaElement.
(3) A global function to resolve the passed promises.
(4) A global function to reject the passed promises with an error code.
(5) A method to asynchronously resolve all pending promises of a HTMLMediaElement.
(6) A method to asynchronously reject all pending promises of a HTMLMediaElement.
(7) A method to dispatch a 'playing' event and resolve all the pending play promises.

All the above functionalities are defined at WHATWG 4.8.12.8:
https://html.spec.whatwg.org/multipage/embedded-content.html#list-of-pending-play-promises

This patch also implements two MediaEvent classes, nsResolveOrRejectPendingPlayPromisesRunner and nsNotifyAboutPlayingRunner, which help (5), (6) and (7).

This patch also implements a list of already-dispatched nsResolveOrRejectPendingPlayPromisesRunner; we keep tracing these tasks because the load algorithm resolves/rejects all already-dispatched pending play promises (in patch 2).

MozReview-Commit-ID: EUirNqDfttk
2016-12-08 14:34:39 -10:00
JW Wang
813f283d4e Bug 1322087. Part 2 - move readyState to HAVE_ENOUGH_DATA when we have no more data to fetch. r=cpearce
http://searchfox.org/mozilla-central/rev/dc8cf05768b83a6ef0b4039edd6efddd56ee4109/dom/media/MediaDecoderStateMachine.cpp#1065
Changing nextFrameStatus to UNAVAILABLE might change readyState to HAVE_CURRENT_DATA and cause 'waiting' to fire.
It doesn't make sense to fire 'waiting' at the end of playback.

http://searchfox.org/mozilla-central/rev/dc8cf05768b83a6ef0b4039edd6efddd56ee4109/dom/html/HTMLMediaElement.cpp#5423
Note the check for Ended() doesn't work as expected to prevent 'waiting' from firing at the end of playback
because of the way how TailDispatcher schedules stateChange tasks.

This patch keeps readyState in HAVE_ENOUGH_DATA when playback is near the end for wanting no more data.
readyState will change to HAVE_CURRENT_DATA when the playing state of MediaDecoder is changed to PLAY_STATE_ENDED.

MozReview-Commit-ID: 6EspaD2hhx
2016-12-07 10:41:33 -10:00
JW Wang
184a2184eb Bug 1322087. Part 1 - move |if (!mFirstFrameLoaded)| up to save some duplicate checks. r=cpearce
MozReview-Commit-ID: 77duxxtEAQP
2016-12-06 15:54:51 -10:00
Kaku Kuo
ad9fdaf9ff Bug 1321497 - correct the logic of resuming from AudioChannel; r=alwu,jwwang
MozReview-Commit-ID: JxeqdzADlrU
2016-12-01 16:30:18 +08:00
Alastor Wu
678fa0e7b5 Bug 1321410 - stop agent after cycle collection. r=jwwang
The crash reason seems the mOwner has been released, so we shouldn't call any method which would call mOwner.
The AudioChannelAgentCallback could only be called from two parts, one is from mOwner, another is from AudioChannelService (via AudioChannelAgent).
We don't want this class be called after mOwner was released, we should disconnect it from AudioChannelService.
Calling NotifyStoppedPlaying() can unregister agent from service, so service won't call agent anymore.
Therefore, no one would call AudioChannelAgentCallback after CC happened.

MozReview-Commit-ID: 7HY4KpciacB
2016-12-04 11:02:10 +08:00
Bill McCloskey
d2a1c646a4 Bug 1318506 - Label some common runnables with a DocGroup (r=ehsan)
MozReview-Commit-ID: 19gyZRfbzXP
2016-12-01 15:00:13 -08:00
Kaku Kuo
1b0552843e Bug 1321196 part 2 - rework the IsAllowedToPlay policy; r=alwu,jwwang
MozReview-Commit-ID: 8mrXoLRK42y
2016-11-30 16:01:36 +08:00
Kaku Kuo
dd95108d31 Bug 1321196 part 1 - typo correction; r=alwu
MozReview-Commit-ID: 4EodGXfjb8i
2016-11-30 14:43:41 +08:00
ctai
90bdf8580c Bug 1133483 - Dispatch |NoSupportedMediaSourceError| to main thread in |SelectResource|. r=jwwang
We need to end the synchronous section when the src attribute is empty and then run the "failed with elements step" in non-sync section.

MozReview-Commit-ID: DJ7GYqa6aI5
2016-11-18 11:04:36 +08:00
Alastor Wu
57dca5de8b Bug 1309162 - part7 : wrap custom policy function. r=jwwang
MozReview-Commit-ID: EdjzMi90ukx
2016-11-29 12:40:47 +08:00
Alastor Wu
f2045df120 Bug 1309162 - part6 : remove useless comment. r=jwwang
These comments should be removed after landing bug1302350.

MozReview-Commit-ID: 7N0cWImZDDI
2016-11-29 12:40:45 +08:00
Alastor Wu
290dc21abc Bug 1309162 - part5 : only set the audible state when stream starts playing. r=baku
If input is a media stream, we would always regard it as audible when it's playing.
We won't need to set it as non-audible.

MozReview-Commit-ID: 8mzTsAkt6lG
2016-11-29 12:40:43 +08:00
Alastor Wu
d5d037103c Bug 1309162 - part4 : remove checking for mPlayingBeforeSeek. r=baku
In previous patch, we removed UpdateAudioChannelPlayingState() from AddRemoveSelfReference(), now we
don't call UpdateAudioChannelPlayingState() during the seeking. So we don't need to afraid to stop
audio channel agent during the seeking.


MozReview-Commit-ID: GTuIRB24zlq
2016-11-29 12:40:41 +08:00
Alastor Wu
0b306ad6ba Bug 1309162 - part3 : modify the place calling UpdateAudioChannelPlayingState(). r=baku
UpdateAudioChannelPlayingState() should only be called when following attributes changed.
eg. pause/ready state/error/owner document's visibility/exteral source stream.

Therefore, we don't need to call this function in FinishDecoderSetup() and AddRemoveSelfReference().

Remove AutoNotifyAudioChannelAgent is because now we don't check HasAudio() for IsPlayingThroughTheAudioChannel().

MozReview-Commit-ID: 4VTHIAdAqX1
2016-11-29 12:40:39 +08:00
Alastor Wu
6f4b863655 Bug 1309162 - part2 : remove audio channel code from media element. r=jwwang
Remove the audio channel related codes.

MozReview-Commit-ID: Fc09gDDF21a
2016-11-29 12:40:35 +08:00
Alastor Wu
98177d02da Bug 1309162 - part1 : create a separate class to handle audio channel releated stuffs. r=baku,jwwang
In order to keep the media element's code clear (spec code only), we want to remove our
custom policy code out from media element. This new class will handle all audio channel
related stuffs, eg. mute/unmuted operation from tab audio indicator, play/resume from
Fennec's media control.

MozReview-Commit-ID: 5mDqDBTnBOr
2016-11-29 12:40:32 +08:00
Wes Kocher
e9ed4f958a Backed out 7 changesets (bug 1309162) for valgrind failures a=backout
Backed out changeset 3f0ad2d2c594 (bug 1309162)
Backed out changeset 17c744162fbe (bug 1309162)
Backed out changeset 2015de6577af (bug 1309162)
Backed out changeset fe1771c91309 (bug 1309162)
Backed out changeset b5ab5eae225d (bug 1309162)
Backed out changeset 16ceabbf8eef (bug 1309162)
Backed out changeset 6b09c6adcfa5 (bug 1309162)
2016-11-28 13:16:31 -08:00
Alastor Wu
b1b53dfa7c Bug 1309162 - part7 : wrap custom policy function. r=jwwang
MozReview-Commit-ID: EdjzMi90ukx
2016-11-28 10:23:14 +08:00
Alastor Wu
d2ea8b2c55 Bug 1309162 - part6 : remove useless comment. r=jwwang
These comments should be removed after landing bug1302350.

MozReview-Commit-ID: 7N0cWImZDDI
2016-11-26 02:35:23 +08:00
Alastor Wu
ef95b74b1b Bug 1309162 - part5 : only set the audible state when stream starts playing. r=baku
If input is a media stream, we would always regard it as audible when it's playing.
We won't need to set it as non-audible.

MozReview-Commit-ID: 8mzTsAkt6lG
2016-11-26 02:35:20 +08:00
Alastor Wu
95fac941d3 Bug 1309162 - part4 : remove checking for mPlayingBeforeSeek. r=baku
In previous patch, we removed UpdateAudioChannelPlayingState() from AddRemoveSelfReference(), now we
don't call UpdateAudioChannelPlayingState() during the seeking. So we don't need to afraid to stop
audio channel agent during the seeking.


MozReview-Commit-ID: GTuIRB24zlq
2016-11-26 02:35:18 +08:00
Alastor Wu
f627f175a1 Bug 1309162 - part3 : modify the place calling UpdateAudioChannelPlayingState(). r=baku
UpdateAudioChannelPlayingState() should only be called when following attributes changed.
eg. pause/ready state/error/owner document's visibility/exteral source stream.

Therefore, we don't need to call this function in FinishDecoderSetup() and AddRemoveSelfReference().

Remove AutoNotifyAudioChannelAgent is because now we don't check HasAudio() for IsPlayingThroughTheAudioChannel().

MozReview-Commit-ID: 4VTHIAdAqX1
2016-11-26 02:34:49 +08:00
Alastor Wu
325a48daae Bug 1309162 - part2 : remove audio channel code from media element. r=jwwang
Remove the audio channel related codes.

MozReview-Commit-ID: Fc09gDDF21a
2016-11-26 02:34:42 +08:00
Alastor Wu
a15ae0e683 Bug 1309162 - part1 : create a separate class to handle audio channel releated stuffs. r=baku,jwwang
In order to keep the media element's code clear (spec code only), we want to remove our
custom policy code out from media element. This new class will handle all audio channel
related stuffs, eg. mute/unmuted operation from tab audio indicator, play/resume from
Fennec's media control.

MozReview-Commit-ID: 5mDqDBTnBOr
2016-11-26 02:34:39 +08:00
Kilik Kuo
a73f416fe2 Bug 1319686 - Remove the use of AutoNoJSAPI from HTMLMediaElement::NotifyAudioChannelAgent r=jwwang
MozReview-Commit-ID: FMKloJPpT93
2016-11-23 18:16:31 +08:00
Alastor Wu
273d74cd0e Bug 1301055 - part4 : special error dispatching stragedy for Fennec. r=jwwang
On Fennec, we would use external app (Android view) to play the media whih is
unsupported by gecko. We implement some special logic in error sink.

(1) dispatch "OpenMediaWithExternalApp" event
we use this event to start the android video player

(2) doesn't dispatch "error" event
some JS players won't let user to trigger play() again after receving the "error".
So we don't dispatch that event if we want to play the unsupported media more than once.

MozReview-Commit-ID: 7fZK5hdvaOG
2016-11-24 10:24:08 +08:00
Alastor Wu
726bbd643a Bug 1301055 - part2 : create a error sink to handle media element's error related event. r=bkelly,jwwang
Error sink would be response for the error handling, we could write different
error dispatching stragedies for different situation. eg. if we can play
unsupported type media with external app, we won't dispatch the "error" event on fennec.

MozReview-Commit-ID: Lm4x9ksspAY
2016-11-24 10:24:04 +08:00
Kilik Kuo
f2e7b85310 Bug 1316758-Remove nsContentUtils::LegacyIsCallerChromeOrNativeCode and IsCallerChrome calls from HTMLMediaElement. r=cpearce
MozReview-Commit-ID: 47pOATtfflP
2016-11-18 10:30:00 +08:00
Alastor Wu
7d72019557 Bug 1317167 - only need to do the untrust JS checking in play(). r=jwwang
The first checking condition in the IsAllowedPlay() is used to prevent the play() operation
is called by untrusted JS when media.autoplay.enabled=false. Therefore, we don't need to check
that in CanActivateAutoplay().

MozReview-Commit-ID: 6yqoG8ISyra
2016-11-17 15:09:59 +08:00
Bryce Van Dyk
264b104a6c Bug 1298027 - Shut down CDMs when a containing document becomes inactive. r=cpearce
The previous changeset against this bug relaxed the conditions under which the
CDM and associated objects were shut down. This was to address moving a tab to a
new window breaking EME videos. However, this had the unwanted side effect of
not shutting down those objects early enough when pages are closed.

This changeset introduces a new check to see if the containing document is
currently active, if not we shutdown the CDM. This means CDMs are shutdown on
time, while retaining the desired behaviour that CDMs should not be shut down on
moving tabs to new windows. Shutdowns previously happened because we shut down
if a page hide happened, which took place during a reparent.

MozReview-Commit-ID: K5CD3ej43Y0
2016-11-14 15:02:48 +13:00
Bryce Van Dyk
9551c5b836 Bug 1298027 - Relax decoder shutdown and mediakey removal on MediaElement suspension. r=cpearce
This changeset relaxes the shutting down of decoders and removal of mediakeys
when suspending HTMLMediaElements. This should now only happen for adobe
primetime. This alleviates, for non-primetime CDMs, the issue of videos
breaking when moving an EME protected video from a tab to a new window.

These conditions can be relaxed as neither clearkey or widevine support
secure stop. This means we don't need to shutdown their decoders and keys to
signal a stoppage, as at this stage, doing so doesn't give us secure stop and
instead means that playback is busted when we try to resume.

MozReview-Commit-ID: 3MGNXGGDVLS
2016-10-31 10:55:19 +13:00
Alastor Wu
8beec95340 Bug 1315551 - part2 : check we have initialized agent when we want to call the agent's function. r=jwwang
Because the agent's initialization might fail if we don't get the valid inner window, we need to
check whether the agent exists before calling the agent's method.

MozReview-Commit-ID: IUuvyGh7CMd
2016-11-08 11:08:02 +08:00
Phil Ringnalda
46002fb492 Backed out changeset 87b698764664 (bug 1315521) for jetpack failures in test-leak-tab-events.js.test 2016-11-07 21:01:45 -08:00
Alastor Wu
a18f48568b Bug 1315521 - remove CC for audio channel agent. r=jwwang
Because audio channel agent uses weak ref to HTMLMediaElement, so we don't need to add it into the CC list.

MozReview-Commit-ID: 4cFfDUlbMFB
2016-11-08 11:03:23 +08:00
JW Wang
44d181cc79 Bug 1314547. Part 1 - remove the call to MediaDecoder::SetMediaSeekableOnlyInBufferedRanges(). r=cpearce
MozReview-Commit-ID: 52BESjY8f74
2016-11-02 17:11:29 +08:00
JW Wang
ceec46085b Bug 1314529. Part 1 - remove the call to MediaDecoder::SetMediaSeekable(). r=cpearce
MozReview-Commit-ID: 1vsazRU9KNw
2016-11-02 14:39:18 +08:00
Jean-Yves Avenard
018dfa1f8e Bug 1302656: P1. Don't detach mediasource when error occurs. r=jwwang
MozReview-Commit-ID: 88EIb4XXcdR
2016-11-01 20:33:33 +11:00
Wes Kocher
efe043b241 Backed out 2 changesets (bug 1302656) for WinXP wpt failures a=backout
Backed out changeset e8ce7f515092 (bug 1302656)
Backed out changeset 416dbe42e4a3 (bug 1302656)
2016-11-04 14:51:27 -07:00
Jean-Yves Avenard
3a8c5e7e44 Bug 1302656: P1. Don't detach mediasource when error occurs. r=jwwang
MozReview-Commit-ID: 88EIb4XXcdR
2016-11-01 20:33:33 +11:00
Alastor Wu
3cf8874ec0 Bug 1302350 - part6 : ensure loading process doens't be interrupted even media element can't be played. r=jwwang
We don't want to stop the loading process even we canceled the play operation.

MozReview-Commit-ID: FyPqBlDKYo0
2016-11-02 14:22:35 +08:00
Alastor Wu
01a17b2a49 Bug 1302350 - part4 : refactor the media-blocking mechanism. r=jwwang
The old way is to start playing first, and then block the media element. This
way is too complicated because it involves lots of interal state and isn't intuitive.

The new way is to ignore the play if the media element should be blocked. It's
easy to know and we doesn't need to keep any internal states because we don't play
the media element.

MozReview-Commit-ID: B20e0pvXES4
2016-11-02 14:22:24 +08:00
Alastor Wu
03e0ef5d80 Bug 1302350 - part2 : provide a method to check whether the agent was started. r=baku
Since the agent is created in beginning in patch1, we need another way to know
whether we have already called notifyStartedPlaying().

MozReview-Commit-ID: 5YNhwEl5Xfp
2016-11-01 17:46:09 +08:00
Alastor Wu
5d226762d6 Bug 1302350 - part1 : create audio channel agent in the beginning. r=baku
We create audio channel agent in the beginning in oreder to use some agent's methods.
But the agent is still started after media element starting playing.

MozReview-Commit-ID: KPGb7snB2t7
2016-11-01 17:46:07 +08:00
Andreas Pehrson
a3454bf495 Bug 1301675 - Uncomment assertion for when removed live track was not found. r=jib
It needs an extra guard for when we're an audio element and a live video track
was removed. That's ok and we should ignore it.

MozReview-Commit-ID: FVw3lDKd4oU
2016-09-23 16:56:39 +02:00
Andreas Pehrson
b09ec5c14e Bug 1301675 - Rename BasicUnstoppableTrackSource to BasicTrackSource. r=jib
They are not unstoppable any longer. We just don't forward Stop() to the real source.

MozReview-Commit-ID: FdFccMsD3eb
2016-09-16 15:19:28 +02:00
Andreas Pehrson
10be33a1ac Bug 1301675 - Clarify why we don't need to do anything on DecoderCaptureTrackSource::Stop(). r=jib
MozReview-Commit-ID: H1zaO1FKWvK
2016-09-16 11:10:17 +02:00
Andreas Pehrson
b028a0b40f Bug 1301675 - Implement StreamCaptureTrackSource::Stop. r=jib
MozReview-Commit-ID: 2qwNba6bA80
2016-09-23 16:53:10 +02:00
Andreas Pehrson
9c1477829d Bug 1301675 - Remove MediaStreamTrackSource::mIsRemote. r=jib
MediaStreamTrack.remote is no longer part of the spec.

MozReview-Commit-ID: BgHJ1zNIoWN
2016-09-12 15:59:58 +02:00
Andreas Pehrson
34317e3f12 Bug 1208316 - A media element should autoplay a MediaStream that becomes active. r=jib
MozReview-Commit-ID: 98H7REtqShI
2016-09-14 10:04:26 +02:00
Andreas Pehrson
f903bb32df Bug 1208316 - HTMLMediaElement.ended should follow MediaStream.active. r=jib
MozReview-Commit-ID: CIJZz5khY8R
2016-09-14 10:02:23 +02:00