diff options
author | wolfbeast <mcwerewolf@gmail.com> | 2018-02-24 22:12:27 +0100 |
---|---|---|
committer | wolfbeast <mcwerewolf@gmail.com> | 2018-02-24 22:12:27 +0100 |
commit | e10dfb62ff916d49632febb59565f3c52f4970bd (patch) | |
tree | e3162c57574bcf7f91d262d9a8cd70ece01f9edb /dom/html | |
parent | fd6b1ad6f9768556bb03a0fbdb16587fdfd0a962 (diff) | |
parent | 27727874636868dc6d61e8117f81cd761c91e2ed (diff) | |
download | UXP-e10dfb62ff916d49632febb59565f3c52f4970bd.tar UXP-e10dfb62ff916d49632febb59565f3c52f4970bd.tar.gz UXP-e10dfb62ff916d49632febb59565f3c52f4970bd.tar.lz UXP-e10dfb62ff916d49632febb59565f3c52f4970bd.tar.xz UXP-e10dfb62ff916d49632febb59565f3c52f4970bd.zip |
Merge branch 'EME-work'
Diffstat (limited to 'dom/html')
-rw-r--r-- | dom/html/HTMLMediaElement.cpp | 43 | ||||
-rw-r--r-- | dom/html/HTMLMediaElement.h | 10 |
2 files changed, 51 insertions, 2 deletions
diff --git a/dom/html/HTMLMediaElement.cpp b/dom/html/HTMLMediaElement.cpp index e81cd20bc..1f1a545fa 100644 --- a/dom/html/HTMLMediaElement.cpp +++ b/dom/html/HTMLMediaElement.cpp @@ -11,7 +11,9 @@ #include "mozilla/ArrayUtils.h" #include "mozilla/MathAlgorithms.h" #include "mozilla/AsyncEventDispatcher.h" +#ifdef MOZ_EME #include "mozilla/dom/MediaEncryptedEvent.h" +#endif #include "base/basictypes.h" #include "nsIDOMHTMLMediaElement.h" @@ -820,7 +822,9 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(HTMLMediaElement, nsGenericHTM NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTextTrackManager) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mAudioTrackList) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mVideoTrackList) +#ifdef MOZ_EME NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMediaKeys) +#endif NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSelectedVideoStreamTrack) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END @@ -845,7 +849,9 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(HTMLMediaElement, nsGenericHTMLE NS_IMPL_CYCLE_COLLECTION_UNLINK(mTextTrackManager) NS_IMPL_CYCLE_COLLECTION_UNLINK(mAudioTrackList) NS_IMPL_CYCLE_COLLECTION_UNLINK(mVideoTrackList) +#ifdef MOZ_EME NS_IMPL_CYCLE_COLLECTION_UNLINK(mMediaKeys) +#endif NS_IMPL_CYCLE_COLLECTION_UNLINK(mSelectedVideoStreamTrack) NS_IMPL_CYCLE_COLLECTION_UNLINK_END @@ -1020,12 +1026,14 @@ void HTMLMediaElement::ShutdownDecoder() void HTMLMediaElement::AbortExistingLoads() { +#ifdef MOZ_EME // If there is no existing decoder then we don't have anything to // report. This prevents reporting the initial load from an // empty video element as a failed EME load. if (mDecoder) { ReportEMETelemetry(); } +#endif // Abort any already-running instance of the resource selection algorithm. mLoadWaitStatus = NOT_WAITING; @@ -1084,7 +1092,9 @@ void HTMLMediaElement::AbortExistingLoads() mDownloadSuspendedByCache = false; mMediaInfo = MediaInfo(); mIsEncrypted = false; +#ifdef MOZ_EME mPendingEncryptedInitData.mInitDatas.Clear(); +#endif mWaitingForKey = NOT_WAITING_FOR_KEY; mSourcePointer = nullptr; @@ -2681,9 +2691,11 @@ HTMLMediaElement::CaptureStreamInternal(bool aFinishWhenEnded, if (!window) { return nullptr; } +#ifdef MOZ_EME if (ContainsRestrictedContent()) { return nullptr; } +#endif if (!mOutputStreams.IsEmpty() && aGraph != mOutputStreams[0].mStream->GetInputStream()->Graph()) { @@ -3638,6 +3650,7 @@ void HTMLMediaElement::HiddenVideoStop() mVideoDecodeSuspendTimer = nullptr; } +#ifdef MOZ_EME void HTMLMediaElement::ReportEMETelemetry() { @@ -3649,6 +3662,7 @@ HTMLMediaElement::ReportEMETelemetry() this, mLoadedDataFired ? "true" : "false")); } } +#endif void HTMLMediaElement::ReportTelemetry() @@ -3997,6 +4011,7 @@ nsresult HTMLMediaElement::FinishDecoderSetup(MediaDecoder* aDecoder, ms.mFinishWhenEnded); } +#ifdef MOZ_EME if (mMediaKeys) { if (mMediaKeys->GetCDMProxy()) { mDecoder->SetCDMProxy(mMediaKeys->GetCDMProxy()); @@ -4006,6 +4021,7 @@ nsresult HTMLMediaElement::FinishDecoderSetup(MediaDecoder* aDecoder, return NS_ERROR_FAILURE; } } +#endif MediaEventSource<void>* waitingForKeyProducer = mDecoder->WaitingForKeyEvent(); // Not every decoder will produce waitingForKey events, only add ones that can @@ -4468,7 +4484,11 @@ void HTMLMediaElement::MetadataLoaded(const MediaInfo* aInfo, SetMediaInfo(*aInfo); - mIsEncrypted = aInfo->IsEncrypted() || mPendingEncryptedInitData.IsEncrypted(); + mIsEncrypted = aInfo->IsEncrypted() +#ifdef MOZ_EME + || mPendingEncryptedInitData.IsEncrypted() +#endif + ; mTags = aTags.forget(); mLoadedDataFired = false; ChangeReadyState(nsIDOMHTMLMediaElement::HAVE_METADATA); @@ -4494,11 +4514,13 @@ void HTMLMediaElement::MetadataLoaded(const MediaInfo* aInfo, return; } +#ifdef MOZ_EME // Dispatch a distinct 'encrypted' event for each initData we have. for (const auto& initData : mPendingEncryptedInitData.mInitDatas) { DispatchEncrypted(initData.mInitData, initData.mType); } mPendingEncryptedInitData.mInitDatas.Clear(); +#endif } mWatchManager.ManualNotify(&HTMLMediaElement::UpdateReadyStateInternal); @@ -5431,9 +5453,12 @@ void HTMLMediaElement::SuspendOrResumeElement(bool aPauseElement, bool aSuspendE UpdateAudioChannelPlayingState(); if (aPauseElement) { ReportTelemetry(); +#ifdef MOZ_EME ReportEMETelemetry(); +#endif - // For EME content, force destruction of the CDM client (and CDM +#ifdef MOZ_EME + // For EME content, we may force destruction of the CDM client (and CDM // instance if this is the last client for that CDM instance) and // the CDM's decoder. This ensures the CDM gets reliable and prompt // shutdown notifications, as it may have book-keeping it needs @@ -5445,6 +5470,7 @@ void HTMLMediaElement::SuspendOrResumeElement(bool aPauseElement, bool aSuspendE ShutdownDecoder(); } } +#endif if (mDecoder) { mDecoder->Pause(); mDecoder->Suspend(); @@ -5495,6 +5521,17 @@ void HTMLMediaElement::NotifyOwnerDocumentActivityChanged() bool pauseElement = ShouldElementBePaused(); SuspendOrResumeElement(pauseElement, !IsActive()); +#ifdef MOZ_EME + // If the owning document has become inactive we should shutdown the CDM. + if (!OwnerDoc()->IsCurrentActiveDocument() && mMediaKeys) { + mMediaKeys->Shutdown(); + mMediaKeys = nullptr; + if (mDecoder) { + ShutdownDecoder(); + } + } +#endif + AddRemoveSelfReference(); } @@ -6270,6 +6307,7 @@ HTMLMediaElement::OnVisibilityChange(Visibility aNewVisibility) } +#ifdef MOZ_EME MediaKeys* HTMLMediaElement::GetMediaKeys() const { @@ -6479,6 +6517,7 @@ HTMLMediaElement::GetTopLevelPrincipal() principal = doc->NodePrincipal(); return principal.forget(); } +#endif //MOZ_EME void HTMLMediaElement::CannotDecryptWaitingForKey() diff --git a/dom/html/HTMLMediaElement.h b/dom/html/HTMLMediaElement.h index d40e9df46..b65049206 100644 --- a/dom/html/HTMLMediaElement.h +++ b/dom/html/HTMLMediaElement.h @@ -20,7 +20,9 @@ #include "mozilla/dom/TextTrackManager.h" #include "mozilla/WeakPtr.h" #include "MediaDecoder.h" +#ifdef MOZ_EME #include "mozilla/dom/MediaKeys.h" +#endif #include "mozilla/StateWatching.h" #include "nsGkAtoms.h" #include "PrincipalChangeObserver.h" @@ -630,6 +632,7 @@ public: // XPCOM MozPreservesPitch() is OK +#ifdef MOZ_EME MediaKeys* GetMediaKeys() const; already_AddRefed<Promise> SetMediaKeys(MediaKeys* mediaKeys, @@ -651,6 +654,7 @@ public: already_AddRefed<nsIPrincipal> GetTopLevelPrincipal(); bool ContainsRestrictedContent(); +#endif // MOZ_EME void CannotDecryptWaitingForKey(); @@ -1198,7 +1202,9 @@ protected: */ void HiddenVideoStop(); +#ifdef MOZ_EME void ReportEMETelemetry(); +#endif void ReportTelemetry(); @@ -1471,8 +1477,10 @@ protected: // Timer used to simulate video-suspend. nsCOMPtr<nsITimer> mVideoDecodeSuspendTimer; +#ifdef MOZ_EME // Encrypted Media Extension media keys. RefPtr<MediaKeys> mMediaKeys; +#endif // Stores the time at the start of the current 'played' range. double mCurrentPlayRangeStart; @@ -1627,8 +1635,10 @@ protected: // Listens for waitingForKey events from the owned decoder. MediaEventListener mWaitingForKeyListener; +#ifdef MOZ_EME // Init Data that needs to be sent in 'encrypted' events in MetadataLoaded(). EncryptionInfo mPendingEncryptedInitData; +#endif // True if the media's channel's download has been suspended. Watchable<bool> mDownloadSuspendedByCache; |