summaryrefslogtreecommitdiff
path: root/dom
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2022-04-21 13:59:55 -0500
committerMatt A. Tobin <email@mattatobin.com>2022-04-21 13:59:55 -0500
commitb5cf6b9b3f577ad7d08205dab34cf4a812088fde (patch)
treef5695b41090d3e7fa5f98db4a4b9b1373c490992 /dom
parent796ef61698ff59668594ff18e1cad3489c875924 (diff)
downloadaura-central-b5cf6b9b3f577ad7d08205dab34cf4a812088fde.tar.gz
Issue #25 - Part 14: Remove DOM Media code relating to waiting for an eme key
Diffstat (limited to 'dom')
-rw-r--r--dom/base/nsGkAtomList.h1
-rw-r--r--dom/html/HTMLMediaElement.cpp34
-rw-r--r--dom/html/HTMLMediaElement.h16
-rw-r--r--dom/media/AbstractMediaDecoder.h12
-rw-r--r--dom/media/MediaFormatReader.cpp54
-rw-r--r--dom/media/MediaFormatReader.h10
-rw-r--r--dom/media/mediasource/MediaSourceDecoder.cpp12
-rw-r--r--dom/media/mediasource/MediaSourceDecoder.h5
-rw-r--r--dom/media/platforms/PlatformDecoderModule.h6
-rw-r--r--dom/media/platforms/agnostic/gmp/MediaDataDecoderProxy.h5
10 files changed, 14 insertions, 141 deletions
diff --git a/dom/base/nsGkAtomList.h b/dom/base/nsGkAtomList.h
index ad2eda211..50b3d911d 100644
--- a/dom/base/nsGkAtomList.h
+++ b/dom/base/nsGkAtomList.h
@@ -2105,7 +2105,6 @@ GK_ATOM(onenter, "onenter")
GK_ATOM(onexit, "onexit")
GK_ATOM(onencrypted, "onencrypted")
GK_ATOM(encrypted, "encrypted")
-GK_ATOM(onwaitingforkey, "onwaitingforkey")
GK_ATOM(onkeystatuseschange, "onkeystatuseschange")
GK_ATOM(onremovetrack, "onremovetrack")
GK_ATOM(loadstart, "loadstart")
diff --git a/dom/html/HTMLMediaElement.cpp b/dom/html/HTMLMediaElement.cpp
index 35df8dd0e..9de0fd82b 100644
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -1067,7 +1067,6 @@ void HTMLMediaElement::ShutdownDecoder()
{
RemoveMediaElementFromURITable();
NS_ASSERTION(mDecoder, "Must have decoder to shut down");
- mWaitingForKeyListener.DisconnectIfExists();
for (OutputMediaStream& out : mOutputStreams) {
if (!out.mCapturingDecoder) {
continue;
@@ -1151,7 +1150,6 @@ void HTMLMediaElement::AbortExistingLoads()
mDownloadSuspendedByCache = false;
mMediaInfo = MediaInfo();
mIsEncrypted = false;
- mWaitingForKey = NOT_WAITING_FOR_KEY;
mSourcePointer = nullptr;
mTags = nullptr;
@@ -3149,7 +3147,6 @@ HTMLMediaElement::HTMLMediaElement(already_AddRefed<mozilla::dom::NodeInfo>& aNo
mMediaSecurityVerified(false),
mCORSMode(CORS_NONE),
mIsEncrypted(false),
- mWaitingForKey(NOT_WAITING_FOR_KEY),
mDownloadSuspendedByCache(false, "HTMLMediaElement::mDownloadSuspendedByCache"),
mAudioChannelVolume(1.0),
mPlayingThroughTheAudioChannel(false),
@@ -4467,8 +4464,8 @@ void HTMLMediaElement::MetadataLoaded(const MediaInfo* aInfo,
void HTMLMediaElement::FirstFrameLoaded()
{
- LOG(LogLevel::Debug, ("%p, FirstFrameLoaded() mFirstFrameLoaded=%d mWaitingForKey=%d",
- this, mFirstFrameLoaded, mWaitingForKey));
+ LOG(LogLevel::Debug, ("%p, FirstFrameLoaded() mFirstFrameLoaded=%d",
+ this, mFirstFrameLoaded));
NS_ASSERTION(!mSuspendedAfterFirstFrame, "Should not have already suspended");
@@ -4813,28 +4810,8 @@ HTMLMediaElement::UpdateReadyStateInternal()
}
enum NextFrameStatus nextFrameStatus = NextFrameStatus();
- if (nextFrameStatus == NEXT_FRAME_UNAVAILABLE ||
- (nextFrameStatus == NEXT_FRAME_UNAVAILABLE_BUFFERING &&
- mWaitingForKey == WAITING_FOR_KEY)) {
- if (mWaitingForKey != NOT_WAITING_FOR_KEY) {
- // http://w3c.github.io/encrypted-media/#wait-for-key
- // Continuing 7.3.4 Queue a "waitingforkey" Event
- // 4. Queue a task to fire a simple event named waitingforkey
- // at the media element.
- if (mWaitingForKey == WAITING_FOR_KEY) {
- mWaitingForKey = WAITING_FOR_KEY_DISPATCHED;
- DispatchAsyncEvent(NS_LITERAL_STRING("waitingforkey"));
- }
- // 5. Set the readyState of media element to HAVE_METADATA.
- // NOTE: We'll change to HAVE_CURRENT_DATA or HAVE_METADATA
- // depending on whether we've loaded the first frame or not
- // below.
- // 6. Suspend playback.
- // Note: Playback will already be stalled, as the next frame is
- // unavailable.
- } else if (mDecoder) {
- nextFrameStatus = mDecoder->NextFrameBufferedStatus();
- }
+ if (nextFrameStatus == NEXT_FRAME_UNAVAILABLE || nextFrameStatus == NEXT_FRAME_UNAVAILABLE_BUFFERING) {
+ nextFrameStatus = mDecoder->NextFrameBufferedStatus();
}
if (nextFrameStatus == MediaDecoderOwner::NEXT_FRAME_UNAVAILABLE_SEEKING) {
@@ -4914,7 +4891,7 @@ HTMLMediaElement::UpdateReadyStateInternal()
// autoplay elements for live streams will never play. Otherwise we
// move to HAVE_ENOUGH_DATA if we can play through the entire media
// without stopping to buffer.
- if (mWaitingForKey == NOT_WAITING_FOR_KEY && mDecoder->CanPlayThrough()) {
+ if (mDecoder->CanPlayThrough()) {
LOG(LogLevel::Debug, ("MediaElement %p UpdateReadyStateInternal() "
"Decoder can play through", this));
ChangeReadyState(nsIDOMHTMLMediaElement::HAVE_ENOUGH_DATA);
@@ -4979,7 +4956,6 @@ void HTMLMediaElement::ChangeReadyState(nsMediaReadyState aState)
mReadyState >= nsIDOMHTMLMediaElement::HAVE_FUTURE_DATA) {
DispatchAsyncEvent(NS_LITERAL_STRING("canplay"));
if (!mPaused) {
- mWaitingForKey = NOT_WAITING_FOR_KEY;
NotifyAboutPlaying();
}
}
diff --git a/dom/html/HTMLMediaElement.h b/dom/html/HTMLMediaElement.h
index 23799b574..08665c674 100644
--- a/dom/html/HTMLMediaElement.h
+++ b/dom/html/HTMLMediaElement.h
@@ -613,8 +613,6 @@ public:
// XPCOM MozPreservesPitch() is OK
- void CannotDecryptWaitingForKey();
-
bool MozAutoplayEnabled() const
{
return mAutoplayEnabled;
@@ -1586,20 +1584,6 @@ protected:
// True if the media has encryption information.
bool mIsEncrypted;
- enum WaitingForKeyState {
- NOT_WAITING_FOR_KEY = 0,
- WAITING_FOR_KEY = 1,
- WAITING_FOR_KEY_DISPATCHED = 2
- };
-
- // True when the CDM cannot decrypt the current block due to lacking a key.
- // Note: the "waitingforkey" event is not dispatched until all decoded data
- // has been rendered.
- WaitingForKeyState mWaitingForKey;
-
- // Listens for waitingForKey events from the owned decoder.
- MediaEventListener mWaitingForKeyListener;
-
// True if the media's channel's download has been suspended.
Watchable<bool> mDownloadSuspendedByCache;
diff --git a/dom/media/AbstractMediaDecoder.h b/dom/media/AbstractMediaDecoder.h
index c38de81af..3b7ad0ca0 100644
--- a/dom/media/AbstractMediaDecoder.h
+++ b/dom/media/AbstractMediaDecoder.h
@@ -78,18 +78,6 @@ public:
return nullptr;
}
- // Notify the media decoder that a decryption key is required before emitting
- // further output. This only needs to be overridden for decoders that expect
- // encryption, such as the MediaSource decoder.
- virtual void NotifyWaitingForKey() {}
-
- // Return an event that will be notified when a decoder is waiting for a
- // decryption key before it can return more output.
- virtual MediaEventSource<void>* WaitingForKeyEvent()
- {
- return nullptr;
- }
-
protected:
virtual void UpdateEstimatedMediaDuration(int64_t aDuration) {};
public:
diff --git a/dom/media/MediaFormatReader.cpp b/dom/media/MediaFormatReader.cpp
index b9289e82a..8e872dd04 100644
--- a/dom/media/MediaFormatReader.cpp
+++ b/dom/media/MediaFormatReader.cpp
@@ -974,21 +974,6 @@ MediaFormatReader::NotifyWaitingForData(TrackType aTrack)
}
void
-MediaFormatReader::NotifyWaitingForKey(TrackType aTrack)
-{
- MOZ_ASSERT(OnTaskQueue());
- auto& decoder = GetDecoderData(aTrack);
- if (mDecoder) {
- mDecoder->NotifyWaitingForKey();
- }
- if (!decoder.mDecodePending) {
- LOGV("WaitingForKey received while no pending decode. Ignoring");
- }
- decoder.mWaitingForKey = true;
- ScheduleUpdate(aTrack);
-}
-
-void
MediaFormatReader::NotifyEndOfStream(TrackType aTrack)
{
MOZ_ASSERT(OnTaskQueue());
@@ -1485,10 +1470,6 @@ MediaFormatReader::Update(TrackType aTrack)
// EOS state. We can immediately reject the data promise.
LOG("Rejecting %s promise: EOS", TrackTypeToStr(aTrack));
decoder.RejectPromise(NS_ERROR_DOM_MEDIA_END_OF_STREAM, __func__);
- } else if (decoder.mWaitingForKey) {
- LOG("Rejecting %s promise: WAITING_FOR_DATA due to waiting for key",
- TrackTypeToStr(aTrack));
- decoder.RejectPromise(NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA, __func__);
}
}
@@ -1522,30 +1503,20 @@ MediaFormatReader::Update(TrackType aTrack)
bool needInput = NeedInput(decoder);
- LOGV("Update(%s) ni=%d no=%d ie=%d, in:%llu out:%llu qs=%u pending:%u waiting:%d promise:%d wfk:%d sid:%u",
+ LOGV("Update(%s) ni=%d no=%d ie=%d, in:%llu out:%llu qs=%u pending:%u waiting:%d promise:%d sid:%u",
TrackTypeToStr(aTrack), needInput, needOutput, decoder.mDecodePending,
decoder.mNumSamplesInput, decoder.mNumSamplesOutput,
uint32_t(size_t(decoder.mSizeOfQueue)), uint32_t(decoder.mOutput.Length()),
- decoder.mWaitingForData, decoder.HasPromise(),
- decoder.mWaitingForKey, decoder.mLastStreamSourceID);
+ decoder.mWaitingForData, decoder.HasPromise(), decoder.mLastStreamSourceID);
if ((decoder.mWaitingForData &&
(!decoder.mTimeThreshold || decoder.mTimeThreshold.ref().mWaiting)) ||
- (decoder.mWaitingForKey && decoder.mDecodePending)) {
+ decoder.mDecodePending) {
// Nothing more we can do at present.
- LOGV("Still waiting for data or key.");
+ LOGV("Still waiting for data.");
return;
}
- if (decoder.mWaitingForKey) {
- decoder.mWaitingForKey = false;
- if (decoder.HasWaitingPromise() && !decoder.IsWaiting()) {
- LOGV("No longer waiting for key. Resolving waiting promise");
- decoder.mWaitingPromise.Resolve(decoder.mType, __func__);
- return;
- }
- }
-
if (!needInput) {
LOGV("No need for additional input (pending:%u)",
uint32_t(decoder.mOutput.Length()));
@@ -1721,15 +1692,6 @@ MediaFormatReader::Error(TrackType aTrack, const MediaResult& aError)
}
void
-MediaFormatReader::WaitingForKey(TrackType aTrack)
-{
- RefPtr<nsIRunnable> task =
- NewRunnableMethod<TrackType>(
- this, &MediaFormatReader::NotifyWaitingForKey, aTrack);
- OwnerThread()->Dispatch(task.forget());
-}
-
-void
MediaFormatReader::Reset(TrackType aTrack)
{
MOZ_ASSERT(OnTaskQueue());
@@ -2254,7 +2216,7 @@ MediaFormatReader::GetMozDebugReaderData(nsAString& aString)
result += nsPrintfCString("audio frames decoded: %lld\n",
mAudio.mNumSamplesOutputTotal);
if (HasAudio()) {
- result += nsPrintfCString("audio state: ni=%d no=%d ie=%d demuxr:%d demuxq:%d tt:%f tths:%d in:%llu out:%llu qs=%u pending:%u waiting:%d wfk:%d sid:%u\n",
+ result += nsPrintfCString("audio state: ni=%d no=%d ie=%d demuxr:%d demuxq:%d tt:%f tths:%d in:%llu out:%llu qs=%u pending:%u waiting:%d sid:%u\n",
NeedInput(mAudio), mAudio.HasPromise(),
mAudio.mDecodePending,
mAudio.mDemuxRequest.Exists(),
@@ -2268,7 +2230,7 @@ MediaFormatReader::GetMozDebugReaderData(nsAString& aString)
mAudio.mNumSamplesInput, mAudio.mNumSamplesOutput,
unsigned(size_t(mAudio.mSizeOfQueue)),
unsigned(mAudio.mOutput.Length()),
- mAudio.mWaitingForData, mAudio.mWaitingForKey,
+ mAudio.mWaitingForData,
mAudio.mLastStreamSourceID);
}
result += nsPrintfCString("video decoder: %s\n", videoName);
@@ -2278,7 +2240,7 @@ MediaFormatReader::GetMozDebugReaderData(nsAString& aString)
mVideo.mNumSamplesOutputTotal,
mVideo.mNumSamplesSkippedTotal);
if (HasVideo()) {
- result += nsPrintfCString("video state: ni=%d no=%d ie=%d demuxr:%d demuxq:%d tt:%f tths:%d in:%llu out:%llu qs=%u pending:%u waiting:%d wfk:%d, sid:%u\n",
+ result += nsPrintfCString("video state: ni=%d no=%d ie=%d demuxr:%d demuxq:%d tt:%f tths:%d in:%llu out:%llu qs=%u pending:%u waiting:%d sid:%u\n",
NeedInput(mVideo), mVideo.HasPromise(),
mVideo.mDecodePending,
mVideo.mDemuxRequest.Exists(),
@@ -2292,7 +2254,7 @@ MediaFormatReader::GetMozDebugReaderData(nsAString& aString)
mVideo.mNumSamplesInput, mVideo.mNumSamplesOutput,
unsigned(size_t(mVideo.mSizeOfQueue)),
unsigned(mVideo.mOutput.Length()),
- mVideo.mWaitingForData, mVideo.mWaitingForKey,
+ mVideo.mWaitingForData,
mVideo.mLastStreamSourceID);
}
aString += NS_ConvertUTF8toUTF16(result);
diff --git a/dom/media/MediaFormatReader.h b/dom/media/MediaFormatReader.h
index 6e83c9e70..fe3c3798d 100644
--- a/dom/media/MediaFormatReader.h
+++ b/dom/media/MediaFormatReader.h
@@ -158,7 +158,6 @@ private:
void NotifyDrainComplete(TrackType aTrack);
void NotifyError(TrackType aTrack, const MediaResult& aError);
void NotifyWaitingForData(TrackType aTrack);
- void NotifyWaitingForKey(TrackType aTrack);
void NotifyEndOfStream(TrackType aTrack);
void ExtractCryptoInitData(nsTArray<uint8_t>& aInitData);
@@ -174,7 +173,6 @@ private:
void Reset(TrackType aTrack);
void DrainComplete(TrackType aTrack);
void DropDecodedSamples(TrackType aTrack);
- void WaitingForKey(TrackType aTrack);
bool ShouldSkip(bool aSkipToNextKeyframe, media::TimeUnit aTimeThreshold);
@@ -209,9 +207,6 @@ private:
bool OnReaderTaskQueue() override {
return mReader->OnTaskQueue();
}
- void WaitingForKey() override {
- mReader->WaitingForKey(mType);
- }
private:
MediaFormatReader* mReader;
@@ -229,7 +224,6 @@ private:
, mUpdateScheduled(false)
, mDemuxEOS(false)
, mWaitingForData(false)
- , mWaitingForKey(false)
, mReceivedNewData(false)
, mOutputRequested(false)
, mDecodePending(false)
@@ -277,7 +271,6 @@ private:
bool mUpdateScheduled;
bool mDemuxEOS;
bool mWaitingForData;
- bool mWaitingForKey;
bool mReceivedNewData;
// Pending seek.
@@ -297,7 +290,7 @@ private:
bool IsWaiting() const
{
MOZ_ASSERT(mOwner->OnTaskQueue());
- return mWaitingForData || mWaitingForKey;
+ return mWaitingForData;
}
// MediaDataDecoder handler's variables.
@@ -400,7 +393,6 @@ private:
MOZ_ASSERT(mOwner->OnTaskQueue());
mDemuxEOS = false;
mWaitingForData = false;
- mWaitingForKey = false;
mQueuedSamples.Clear();
mOutputRequested = false;
mNeedDraining = false;
diff --git a/dom/media/mediasource/MediaSourceDecoder.cpp b/dom/media/mediasource/MediaSourceDecoder.cpp
index 6507b320a..c5b25d6a2 100644
--- a/dom/media/mediasource/MediaSourceDecoder.cpp
+++ b/dom/media/mediasource/MediaSourceDecoder.cpp
@@ -325,18 +325,6 @@ MediaSourceDecoder::CanPlayThrough()
return buffered.ContainsStrict(ClampIntervalToEnd(interval));
}
-void
-MediaSourceDecoder::NotifyWaitingForKey()
-{
- mWaitingForKeyEvent.Notify();
-}
-
-MediaEventSource<void>*
-MediaSourceDecoder::WaitingForKeyEvent()
-{
- return &mWaitingForKeyEvent;
-}
-
TimeInterval
MediaSourceDecoder::ClampIntervalToEnd(const TimeInterval& aInterval)
{
diff --git a/dom/media/mediasource/MediaSourceDecoder.h b/dom/media/mediasource/MediaSourceDecoder.h
index f4d84bc40..6c028f367 100644
--- a/dom/media/mediasource/MediaSourceDecoder.h
+++ b/dom/media/mediasource/MediaSourceDecoder.h
@@ -71,10 +71,6 @@ public:
MediaDecoderOwner::NextFrameStatus NextFrameBufferedStatus() override;
bool CanPlayThrough() override;
- void NotifyWaitingForKey() override;
-
- MediaEventSource<void>* WaitingForKeyEvent() override;
-
private:
void DoSetMediaSourceDuration(double aDuration);
media::TimeInterval ClampIntervalToEnd(const media::TimeInterval& aInterval);
@@ -85,7 +81,6 @@ private:
dom::MediaSource* mMediaSource;
RefPtr<MediaSourceDemuxer> mDemuxer;
RefPtr<MediaFormatReader> mReader;
- MediaEventProducer<void> mWaitingForKeyEvent;
bool mEnded;
};
diff --git a/dom/media/platforms/PlatformDecoderModule.h b/dom/media/platforms/PlatformDecoderModule.h
index 62855335f..a81e7f864 100644
--- a/dom/media/platforms/PlatformDecoderModule.h
+++ b/dom/media/platforms/PlatformDecoderModule.h
@@ -207,12 +207,6 @@ public:
virtual void ReleaseMediaResources() {}
virtual bool OnReaderTaskQueue() = 0;
-
- // Denotes that a pending encryption key is preventing more input being fed
- // into the decoder. This only needs to be overridden for callbacks that
- // handle encryption. E.g. benchmarking does not use eme, so this need
- // not be overridden in that case.
- virtual void WaitingForKey() {}
};
// MediaDataDecoder is the interface exposed by decoders created by the
diff --git a/dom/media/platforms/agnostic/gmp/MediaDataDecoderProxy.h b/dom/media/platforms/agnostic/gmp/MediaDataDecoderProxy.h
index 735b6126e..1e108994d 100644
--- a/dom/media/platforms/agnostic/gmp/MediaDataDecoderProxy.h
+++ b/dom/media/platforms/agnostic/gmp/MediaDataDecoderProxy.h
@@ -95,11 +95,6 @@ public:
return mProxyCallback->OnReaderTaskQueue();
}
- void WaitingForKey() override
- {
- mProxyCallback->WaitingForKey();
- }
-
private:
MediaDataDecoderProxy* mProxyDecoder;
MediaDataDecoderCallback* mProxyCallback;