mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-23 02:05:42 +00:00
Backed out changeset 100092ccffcd (bug 1593739) for RefPtr mda perma-failures CLOSED TREE
This commit is contained in:
parent
0a9456f76c
commit
26742ff1c1
@ -375,128 +375,6 @@ class nsSourceErrorEventRunner : public nsMediaEvent {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class HTMLMediaElement::MediaStreamTrackListener
|
|
||||||
: public DOMMediaStream::TrackListener {
|
|
||||||
public:
|
|
||||||
explicit MediaStreamTrackListener(HTMLMediaElement* aElement)
|
|
||||||
: mElement(aElement) {}
|
|
||||||
|
|
||||||
void NotifyTrackAdded(const RefPtr<MediaStreamTrack>& aTrack) override {
|
|
||||||
if (!mElement) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
mElement->NotifyMediaStreamTrackAdded(aTrack);
|
|
||||||
}
|
|
||||||
|
|
||||||
void NotifyTrackRemoved(const RefPtr<MediaStreamTrack>& aTrack) override {
|
|
||||||
if (!mElement) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
mElement->NotifyMediaStreamTrackRemoved(aTrack);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OnActive() {
|
|
||||||
MOZ_ASSERT(mElement);
|
|
||||||
|
|
||||||
// mediacapture-main says:
|
|
||||||
// Note that once ended equals true the HTMLVideoElement will not play media
|
|
||||||
// even if new MediaStreamTracks are added to the MediaStream (causing it to
|
|
||||||
// return to the active state) unless autoplay is true or the web
|
|
||||||
// application restarts the element, e.g., by calling play().
|
|
||||||
//
|
|
||||||
// This is vague on exactly how to go from becoming active to playing, when
|
|
||||||
// autoplaying. However, per the media element spec, to play an autoplaying
|
|
||||||
// media element, we must load the source and reach readyState
|
|
||||||
// HAVE_ENOUGH_DATA [1]. Hence, a MediaStream being assigned to a media
|
|
||||||
// element and becoming active runs the load algorithm, so that it can
|
|
||||||
// eventually be played.
|
|
||||||
//
|
|
||||||
// [1]
|
|
||||||
// https://html.spec.whatwg.org/multipage/media.html#ready-states:event-media-play
|
|
||||||
|
|
||||||
LOG(LogLevel::Debug, ("%p, mSrcStream %p became active, checking if we "
|
|
||||||
"need to run the load algorithm",
|
|
||||||
mElement.get(), mElement->mSrcStream.get()));
|
|
||||||
if (!mElement->IsPlaybackEnded()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!mElement->Autoplay()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
LOG(LogLevel::Info, ("%p, mSrcStream %p became active on autoplaying, "
|
|
||||||
"ended element. Reloading.",
|
|
||||||
mElement.get(), mElement->mSrcStream.get()));
|
|
||||||
mElement->DoLoad();
|
|
||||||
}
|
|
||||||
|
|
||||||
void NotifyActive() override {
|
|
||||||
if (!mElement) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!mElement->IsVideo()) {
|
|
||||||
// Audio elements use NotifyAudible().
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
OnActive();
|
|
||||||
}
|
|
||||||
|
|
||||||
void NotifyAudible() override {
|
|
||||||
if (!mElement) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mElement->IsVideo()) {
|
|
||||||
// Video elements use NotifyActive().
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
OnActive();
|
|
||||||
}
|
|
||||||
|
|
||||||
void OnInactive() {
|
|
||||||
MOZ_ASSERT(mElement);
|
|
||||||
|
|
||||||
if (mElement->IsPlaybackEnded()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
LOG(LogLevel::Debug, ("%p, mSrcStream %p became inactive", mElement.get(),
|
|
||||||
mElement->mSrcStream.get()));
|
|
||||||
|
|
||||||
mElement->PlaybackEnded();
|
|
||||||
}
|
|
||||||
|
|
||||||
void NotifyInactive() override {
|
|
||||||
if (!mElement) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!mElement->IsVideo()) {
|
|
||||||
// Audio elements use NotifyInaudible().
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
OnInactive();
|
|
||||||
}
|
|
||||||
|
|
||||||
void NotifyInaudible() override {
|
|
||||||
if (!mElement) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mElement->IsVideo()) {
|
|
||||||
// Video elements use NotifyInactive().
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
OnInactive();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
const WeakPtr<HTMLMediaElement> mElement;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This listener observes the first video frame to arrive with a non-empty size,
|
* This listener observes the first video frame to arrive with a non-empty size,
|
||||||
* and renders it to its VideoFrameContainer.
|
* and renders it to its VideoFrameContainer.
|
||||||
@ -714,7 +592,11 @@ class HTMLMediaElement::MediaStreamRenderer
|
|||||||
void* const mAudioOutputKey;
|
void* const mAudioOutputKey;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
~MediaStreamRenderer() { Shutdown(); }
|
~MediaStreamRenderer() {
|
||||||
|
MOZ_DIAGNOSTIC_ASSERT(mAudioTracks.IsEmpty());
|
||||||
|
MOZ_DIAGNOSTIC_ASSERT(!mVideoTrack);
|
||||||
|
MOZ_DIAGNOSTIC_ASSERT(mWatchManager.IsShutdown());
|
||||||
|
}
|
||||||
|
|
||||||
void EnsureGraphTimeDummy() {
|
void EnsureGraphTimeDummy() {
|
||||||
if (mGraphTimeDummy) {
|
if (mGraphTimeDummy) {
|
||||||
@ -1812,21 +1694,10 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(HTMLMediaElement,
|
|||||||
nsGenericHTMLElement)
|
nsGenericHTMLElement)
|
||||||
tmp->RemoveMutationObserver(tmp);
|
tmp->RemoveMutationObserver(tmp);
|
||||||
if (tmp->mSrcStream) {
|
if (tmp->mSrcStream) {
|
||||||
// Need to unhook everything that EndSrcMediaStreamPlayback would normally
|
// Need to EndMediaStreamPlayback to clear mSrcStream and make sure
|
||||||
// do, without creating any new strong references.
|
// everything gets unhooked correctly.
|
||||||
if (tmp->mSelectedVideoStreamTrack) {
|
tmp->EndSrcMediaStreamPlayback();
|
||||||
tmp->mSelectedVideoStreamTrack->RemovePrincipalChangeObserver(tmp);
|
|
||||||
}
|
|
||||||
if (tmp->mFirstFrameListener) {
|
|
||||||
tmp->mSelectedVideoStreamTrack->RemoveVideoOutput(
|
|
||||||
tmp->mFirstFrameListener);
|
|
||||||
}
|
|
||||||
if (tmp->mMediaStreamTrackListener) {
|
|
||||||
tmp->mSrcStream->UnregisterTrackListener(
|
|
||||||
tmp->mMediaStreamTrackListener.get());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mSrcStream)
|
|
||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mSrcAttrStream)
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mSrcAttrStream)
|
||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mMediaSource)
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mMediaSource)
|
||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mSrcMediaSource)
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mSrcMediaSource)
|
||||||
@ -4943,6 +4814,128 @@ nsresult HTMLMediaElement::FinishDecoderSetup(MediaDecoder* aDecoder) {
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class HTMLMediaElement::MediaStreamTrackListener
|
||||||
|
: public DOMMediaStream::TrackListener {
|
||||||
|
public:
|
||||||
|
explicit MediaStreamTrackListener(HTMLMediaElement* aElement)
|
||||||
|
: mElement(aElement) {}
|
||||||
|
|
||||||
|
void NotifyTrackAdded(const RefPtr<MediaStreamTrack>& aTrack) override {
|
||||||
|
if (!mElement) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mElement->NotifyMediaStreamTrackAdded(aTrack);
|
||||||
|
}
|
||||||
|
|
||||||
|
void NotifyTrackRemoved(const RefPtr<MediaStreamTrack>& aTrack) override {
|
||||||
|
if (!mElement) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mElement->NotifyMediaStreamTrackRemoved(aTrack);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnActive() {
|
||||||
|
MOZ_ASSERT(mElement);
|
||||||
|
|
||||||
|
// mediacapture-main says:
|
||||||
|
// Note that once ended equals true the HTMLVideoElement will not play media
|
||||||
|
// even if new MediaStreamTracks are added to the MediaStream (causing it to
|
||||||
|
// return to the active state) unless autoplay is true or the web
|
||||||
|
// application restarts the element, e.g., by calling play().
|
||||||
|
//
|
||||||
|
// This is vague on exactly how to go from becoming active to playing, when
|
||||||
|
// autoplaying. However, per the media element spec, to play an autoplaying
|
||||||
|
// media element, we must load the source and reach readyState
|
||||||
|
// HAVE_ENOUGH_DATA [1]. Hence, a MediaStream being assigned to a media
|
||||||
|
// element and becoming active runs the load algorithm, so that it can
|
||||||
|
// eventually be played.
|
||||||
|
//
|
||||||
|
// [1]
|
||||||
|
// https://html.spec.whatwg.org/multipage/media.html#ready-states:event-media-play
|
||||||
|
|
||||||
|
LOG(LogLevel::Debug, ("%p, mSrcStream %p became active, checking if we "
|
||||||
|
"need to run the load algorithm",
|
||||||
|
mElement.get(), mElement->mSrcStream.get()));
|
||||||
|
if (!mElement->IsPlaybackEnded()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!mElement->Autoplay()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
LOG(LogLevel::Info, ("%p, mSrcStream %p became active on autoplaying, "
|
||||||
|
"ended element. Reloading.",
|
||||||
|
mElement.get(), mElement->mSrcStream.get()));
|
||||||
|
mElement->DoLoad();
|
||||||
|
}
|
||||||
|
|
||||||
|
void NotifyActive() override {
|
||||||
|
if (!mElement) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!mElement->IsVideo()) {
|
||||||
|
// Audio elements use NotifyAudible().
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
OnActive();
|
||||||
|
}
|
||||||
|
|
||||||
|
void NotifyAudible() override {
|
||||||
|
if (!mElement) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mElement->IsVideo()) {
|
||||||
|
// Video elements use NotifyActive().
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
OnActive();
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnInactive() {
|
||||||
|
MOZ_ASSERT(mElement);
|
||||||
|
|
||||||
|
if (mElement->IsPlaybackEnded()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
LOG(LogLevel::Debug, ("%p, mSrcStream %p became inactive", mElement.get(),
|
||||||
|
mElement->mSrcStream.get()));
|
||||||
|
|
||||||
|
mElement->PlaybackEnded();
|
||||||
|
}
|
||||||
|
|
||||||
|
void NotifyInactive() override {
|
||||||
|
if (!mElement) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!mElement->IsVideo()) {
|
||||||
|
// Audio elements use NotifyInaudible().
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
OnInactive();
|
||||||
|
}
|
||||||
|
|
||||||
|
void NotifyInaudible() override {
|
||||||
|
if (!mElement) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mElement->IsVideo()) {
|
||||||
|
// Video elements use NotifyInactive().
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
OnInactive();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
const WeakPtr<HTMLMediaElement> mElement;
|
||||||
|
};
|
||||||
|
|
||||||
void HTMLMediaElement::UpdateSrcMediaStreamPlaying(uint32_t aFlags) {
|
void HTMLMediaElement::UpdateSrcMediaStreamPlaying(uint32_t aFlags) {
|
||||||
if (!mSrcStream) {
|
if (!mSrcStream) {
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user