зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1633010 - part8 : rename `MediaSessionController` to `MediaStatusManager` r=chunmin
This patch will do : - rename `MediaSessionController` to `MediaStatusManager` - move `MediaStatusManager.*` to the folder under `mediacontrol` - update the comment for `MediaStatusManager` The advantage of doing so : - increase the readability More details : We've extended the responsibility of `MediaSessionController` and it now handle a broader concept of media related status, not just media session related. Therefore, renaming it to precisely represent o its responsibility. Differential Revision: https://phabricator.services.mozilla.com/D73493
This commit is contained in:
Родитель
97b23b9267
Коммит
ef4977969c
|
@ -23,7 +23,7 @@ namespace mozilla {
|
||||||
namespace dom {
|
namespace dom {
|
||||||
|
|
||||||
MediaController::MediaController(uint64_t aBrowsingContextId)
|
MediaController::MediaController(uint64_t aBrowsingContextId)
|
||||||
: MediaSessionController(aBrowsingContextId) {
|
: MediaStatusManager(aBrowsingContextId) {
|
||||||
MOZ_DIAGNOSTIC_ASSERT(XRE_IsParentProcess(),
|
MOZ_DIAGNOSTIC_ASSERT(XRE_IsParentProcess(),
|
||||||
"MediaController only runs on Chrome process!");
|
"MediaController only runs on Chrome process!");
|
||||||
LOG("Create controller %" PRId64, Id());
|
LOG("Create controller %" PRId64, Id());
|
||||||
|
@ -128,8 +128,7 @@ void MediaController::NotifyMediaPlaybackChanged(uint64_t aBrowsingContextId,
|
||||||
if (mShutdown) {
|
if (mShutdown) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MediaSessionController::NotifyMediaPlaybackChanged(aBrowsingContextId,
|
MediaStatusManager::NotifyMediaPlaybackChanged(aBrowsingContextId, aState);
|
||||||
aState);
|
|
||||||
|
|
||||||
// Update controller's status according to the media status.
|
// Update controller's status according to the media status.
|
||||||
if (ShouldActivateController()) {
|
if (ShouldActivateController()) {
|
||||||
|
@ -146,7 +145,7 @@ void MediaController::NotifyMediaAudibleChanged(uint64_t aBrowsingContextId,
|
||||||
}
|
}
|
||||||
|
|
||||||
bool oldAudible = IsAudible();
|
bool oldAudible = IsAudible();
|
||||||
MediaSessionController::NotifyMediaAudibleChange(aBrowsingContextId, aState);
|
MediaStatusManager::NotifyMediaAudibleChanged(aBrowsingContextId, aState);
|
||||||
if (IsAudible() == oldAudible) {
|
if (IsAudible() == oldAudible) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
#include "ContentMediaController.h"
|
#include "ContentMediaController.h"
|
||||||
#include "MediaEventSource.h"
|
#include "MediaEventSource.h"
|
||||||
#include "MediaPlaybackStatus.h"
|
#include "MediaPlaybackStatus.h"
|
||||||
#include "mozilla/dom/MediaSessionController.h"
|
#include "MediaStatusManager.h"
|
||||||
#include "mozilla/LinkedList.h"
|
#include "mozilla/LinkedList.h"
|
||||||
#include "nsDataHashtable.h"
|
#include "nsDataHashtable.h"
|
||||||
#include "nsISupportsImpl.h"
|
#include "nsISupportsImpl.h"
|
||||||
|
@ -71,7 +71,7 @@ class IMediaController {
|
||||||
*/
|
*/
|
||||||
class MediaController final
|
class MediaController final
|
||||||
: public IMediaController,
|
: public IMediaController,
|
||||||
public MediaSessionController,
|
public MediaStatusManager,
|
||||||
public LinkedListElement<RefPtr<MediaController>> {
|
public LinkedListElement<RefPtr<MediaController>> {
|
||||||
public:
|
public:
|
||||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaController, override);
|
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaController, override);
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
#include "MediaSessionController.h"
|
#include "MediaStatusManager.h"
|
||||||
|
|
||||||
#include "mozilla/dom/CanonicalBrowsingContext.h"
|
#include "mozilla/dom/CanonicalBrowsingContext.h"
|
||||||
#include "mozilla/dom/MediaControlUtils.h"
|
#include "mozilla/dom/MediaControlUtils.h"
|
||||||
|
@ -16,13 +16,13 @@
|
||||||
# include "nsIFaviconService.h"
|
# include "nsIFaviconService.h"
|
||||||
#endif // MOZ_PLACES
|
#endif // MOZ_PLACES
|
||||||
|
|
||||||
mozilla::LazyLogModule gMediaSession("MediaSession");
|
extern mozilla::LazyLogModule gMediaControlLog;
|
||||||
|
|
||||||
// avoid redefined macro in unified build
|
// avoid redefined macro in unified build
|
||||||
#undef LOG
|
#undef LOG
|
||||||
#define LOG(msg, ...) \
|
#define LOG(msg, ...) \
|
||||||
MOZ_LOG(gMediaSession, LogLevel::Debug, \
|
MOZ_LOG(gMediaControlLog, LogLevel::Debug, \
|
||||||
("MediaSessionController=%p, " msg, this, ##__VA_ARGS__))
|
("MediaStatusManager=%p, " msg, this, ##__VA_ARGS__))
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace dom {
|
namespace dom {
|
||||||
|
@ -40,18 +40,18 @@ static bool IsMetadataEmpty(const Maybe<MediaMetadataBase>& aMetadata) {
|
||||||
metadata.mAlbum.IsEmpty() && metadata.mArtwork.IsEmpty();
|
metadata.mAlbum.IsEmpty() && metadata.mArtwork.IsEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
MediaSessionController::MediaSessionController(uint64_t aBrowsingContextId)
|
MediaStatusManager::MediaStatusManager(uint64_t aBrowsingContextId)
|
||||||
: mTopLevelBrowsingContextId(aBrowsingContextId) {
|
: mTopLevelBrowsingContextId(aBrowsingContextId) {
|
||||||
MOZ_DIAGNOSTIC_ASSERT(XRE_IsParentProcess(),
|
MOZ_DIAGNOSTIC_ASSERT(XRE_IsParentProcess(),
|
||||||
"MediaSessionController only runs on Chrome process!");
|
"MediaStatusManager only runs on Chrome process!");
|
||||||
}
|
}
|
||||||
|
|
||||||
void MediaSessionController::NotifyMediaAudibleChanged(
|
void MediaStatusManager::NotifyMediaAudibleChanged(uint64_t aBrowsingContextId,
|
||||||
uint64_t aBrowsingContextId, MediaAudibleState aState) {
|
MediaAudibleState aState) {
|
||||||
mMediaStatusDelegate.UpdateMediaAudibleState(aBrowsingContextId, aState);
|
mPlaybackStatusDelegate.UpdateMediaAudibleState(aBrowsingContextId, aState);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MediaSessionController::NotifySessionCreated(uint64_t aBrowsingContextId) {
|
void MediaStatusManager::NotifySessionCreated(uint64_t aBrowsingContextId) {
|
||||||
if (mMediaSessionInfoMap.Contains(aBrowsingContextId)) {
|
if (mMediaSessionInfoMap.Contains(aBrowsingContextId)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -61,8 +61,7 @@ void MediaSessionController::NotifySessionCreated(uint64_t aBrowsingContextId) {
|
||||||
UpdateActiveMediaSessionContextId();
|
UpdateActiveMediaSessionContextId();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MediaSessionController::NotifySessionDestroyed(
|
void MediaStatusManager::NotifySessionDestroyed(uint64_t aBrowsingContextId) {
|
||||||
uint64_t aBrowsingContextId) {
|
|
||||||
if (!mMediaSessionInfoMap.Contains(aBrowsingContextId)) {
|
if (!mMediaSessionInfoMap.Contains(aBrowsingContextId)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -71,7 +70,7 @@ void MediaSessionController::NotifySessionDestroyed(
|
||||||
UpdateActiveMediaSessionContextId();
|
UpdateActiveMediaSessionContextId();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MediaSessionController::UpdateMetadata(
|
void MediaStatusManager::UpdateMetadata(
|
||||||
uint64_t aBrowsingContextId, const Maybe<MediaMetadataBase>& aMetadata) {
|
uint64_t aBrowsingContextId, const Maybe<MediaMetadataBase>& aMetadata) {
|
||||||
if (!mMediaSessionInfoMap.Contains(aBrowsingContextId)) {
|
if (!mMediaSessionInfoMap.Contains(aBrowsingContextId)) {
|
||||||
return;
|
return;
|
||||||
|
@ -97,7 +96,7 @@ void MediaSessionController::UpdateMetadata(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MediaSessionController::UpdateActiveMediaSessionContextId() {
|
void MediaStatusManager::UpdateActiveMediaSessionContextId() {
|
||||||
// If there is a media session created from top level browsing context, it
|
// If there is a media session created from top level browsing context, it
|
||||||
// would always be chosen as an active media session. Otherwise, we would
|
// would always be chosen as an active media session. Otherwise, we would
|
||||||
// check if we have an active media session already. If we do have, it would
|
// check if we have an active media session already. If we do have, it would
|
||||||
|
@ -141,7 +140,7 @@ void MediaSessionController::UpdateActiveMediaSessionContextId() {
|
||||||
*mActiveMediaSessionContextId);
|
*mActiveMediaSessionContextId);
|
||||||
}
|
}
|
||||||
|
|
||||||
MediaMetadataBase MediaSessionController::CreateDefaultMetadata() const {
|
MediaMetadataBase MediaStatusManager::CreateDefaultMetadata() const {
|
||||||
MediaMetadataBase metadata;
|
MediaMetadataBase metadata;
|
||||||
metadata.mTitle = GetDefaultTitle();
|
metadata.mTitle = GetDefaultTitle();
|
||||||
metadata.mArtwork.AppendElement()->mSrc = GetDefaultFaviconURL();
|
metadata.mArtwork.AppendElement()->mSrc = GetDefaultFaviconURL();
|
||||||
|
@ -152,7 +151,7 @@ MediaMetadataBase MediaSessionController::CreateDefaultMetadata() const {
|
||||||
return metadata;
|
return metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsString MediaSessionController::GetDefaultTitle() const {
|
nsString MediaStatusManager::GetDefaultTitle() const {
|
||||||
RefPtr<CanonicalBrowsingContext> bc =
|
RefPtr<CanonicalBrowsingContext> bc =
|
||||||
CanonicalBrowsingContext::Get(mTopLevelBrowsingContextId);
|
CanonicalBrowsingContext::Get(mTopLevelBrowsingContextId);
|
||||||
if (!bc) {
|
if (!bc) {
|
||||||
|
@ -187,7 +186,7 @@ nsString MediaSessionController::GetDefaultTitle() const {
|
||||||
return defaultTitle;
|
return defaultTitle;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsString MediaSessionController::GetDefaultFaviconURL() const {
|
nsString MediaStatusManager::GetDefaultFaviconURL() const {
|
||||||
#ifdef MOZ_PLACES
|
#ifdef MOZ_PLACES
|
||||||
nsCOMPtr<nsIURI> faviconURI;
|
nsCOMPtr<nsIURI> faviconURI;
|
||||||
nsresult rv = NS_NewURI(getter_AddRefs(faviconURI),
|
nsresult rv = NS_NewURI(getter_AddRefs(faviconURI),
|
||||||
|
@ -213,7 +212,7 @@ nsString MediaSessionController::GetDefaultFaviconURL() const {
|
||||||
return EmptyString();
|
return EmptyString();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MediaSessionController::SetDeclaredPlaybackState(
|
void MediaStatusManager::SetDeclaredPlaybackState(
|
||||||
uint64_t aBrowsingContextId, MediaSessionPlaybackState aState) {
|
uint64_t aBrowsingContextId, MediaSessionPlaybackState aState) {
|
||||||
if (!mMediaSessionInfoMap.Contains(aBrowsingContextId)) {
|
if (!mMediaSessionInfoMap.Contains(aBrowsingContextId)) {
|
||||||
return;
|
return;
|
||||||
|
@ -226,8 +225,8 @@ void MediaSessionController::SetDeclaredPlaybackState(
|
||||||
UpdateActualPlaybackState();
|
UpdateActualPlaybackState();
|
||||||
}
|
}
|
||||||
|
|
||||||
MediaSessionPlaybackState
|
MediaSessionPlaybackState MediaStatusManager::GetCurrentDeclaredPlaybackState()
|
||||||
MediaSessionController::GetCurrentDeclaredPlaybackState() const {
|
const {
|
||||||
if (!mActiveMediaSessionContextId) {
|
if (!mActiveMediaSessionContextId) {
|
||||||
return MediaSessionPlaybackState::None;
|
return MediaSessionPlaybackState::None;
|
||||||
}
|
}
|
||||||
|
@ -235,28 +234,27 @@ MediaSessionController::GetCurrentDeclaredPlaybackState() const {
|
||||||
.mDeclaredPlaybackState;
|
.mDeclaredPlaybackState;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MediaSessionController::NotifyMediaPlaybackChanged(
|
void MediaStatusManager::NotifyMediaPlaybackChanged(uint64_t aBrowsingContextId,
|
||||||
uint64_t aBrowsingContextId, MediaPlaybackState aState) {
|
MediaPlaybackState aState) {
|
||||||
LOG("UpdateMediaPlaybackState %s for context %" PRId64,
|
LOG("UpdateMediaPlaybackState %s for context %" PRId64,
|
||||||
ToMediaPlaybackStateStr(aState), aBrowsingContextId);
|
ToMediaPlaybackStateStr(aState), aBrowsingContextId);
|
||||||
const bool oldPlaying = mMediaStatusDelegate.IsPlaying();
|
const bool oldPlaying = mPlaybackStatusDelegate.IsPlaying();
|
||||||
mMediaStatusDelegate.UpdateMediaPlaybackState(aBrowsingContextId, aState);
|
mPlaybackStatusDelegate.UpdateMediaPlaybackState(aBrowsingContextId, aState);
|
||||||
|
|
||||||
// Playback state doesn't change, we don't need to update the guessed playback
|
// Playback state doesn't change, we don't need to update the guessed playback
|
||||||
// state. This is used to prevent the state from changing from `none` to
|
// state. This is used to prevent the state from changing from `none` to
|
||||||
// `paused` when receiving `MediaPlaybackState::eStarted`.
|
// `paused` when receiving `MediaPlaybackState::eStarted`.
|
||||||
if (mMediaStatusDelegate.IsPlaying() == oldPlaying) {
|
if (mPlaybackStatusDelegate.IsPlaying() == oldPlaying) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mMediaStatusDelegate.IsPlaying()) {
|
if (mPlaybackStatusDelegate.IsPlaying()) {
|
||||||
SetGuessedPlayState(MediaSessionPlaybackState::Playing);
|
SetGuessedPlayState(MediaSessionPlaybackState::Playing);
|
||||||
} else {
|
} else {
|
||||||
SetGuessedPlayState(MediaSessionPlaybackState::Paused);
|
SetGuessedPlayState(MediaSessionPlaybackState::Paused);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MediaSessionController::SetGuessedPlayState(
|
void MediaStatusManager::SetGuessedPlayState(MediaSessionPlaybackState aState) {
|
||||||
MediaSessionPlaybackState aState) {
|
|
||||||
if (aState == mGuessedPlaybackState) {
|
if (aState == mGuessedPlaybackState) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -265,7 +263,7 @@ void MediaSessionController::SetGuessedPlayState(
|
||||||
UpdateActualPlaybackState();
|
UpdateActualPlaybackState();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MediaSessionController::UpdateActualPlaybackState() {
|
void MediaStatusManager::UpdateActualPlaybackState() {
|
||||||
// The way to compute the actual playback state is based on the spec.
|
// The way to compute the actual playback state is based on the spec.
|
||||||
// https://w3c.github.io/mediasession/#actual-playback-state
|
// https://w3c.github.io/mediasession/#actual-playback-state
|
||||||
MediaSessionPlaybackState newState =
|
MediaSessionPlaybackState newState =
|
||||||
|
@ -281,7 +279,7 @@ void MediaSessionController::UpdateActualPlaybackState() {
|
||||||
HandleActualPlaybackStateChanged();
|
HandleActualPlaybackStateChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
MediaMetadataBase MediaSessionController::GetCurrentMediaMetadata() const {
|
MediaMetadataBase MediaStatusManager::GetCurrentMediaMetadata() const {
|
||||||
// If we don't have active media session, active media session doesn't have
|
// If we don't have active media session, active media session doesn't have
|
||||||
// media metadata, or we're in private browsing mode, then we should create a
|
// media metadata, or we're in private browsing mode, then we should create a
|
||||||
// default metadata which is using website's title and favicon as title and
|
// default metadata which is using website's title and favicon as title and
|
||||||
|
@ -299,7 +297,7 @@ MediaMetadataBase MediaSessionController::GetCurrentMediaMetadata() const {
|
||||||
return CreateDefaultMetadata();
|
return CreateDefaultMetadata();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MediaSessionController::FillMissingTitleAndArtworkIfNeeded(
|
void MediaStatusManager::FillMissingTitleAndArtworkIfNeeded(
|
||||||
MediaMetadataBase& aMetadata) const {
|
MediaMetadataBase& aMetadata) const {
|
||||||
// If the metadata doesn't set its title and artwork properly, we would like
|
// If the metadata doesn't set its title and artwork properly, we would like
|
||||||
// to use default title and favicon instead in order to prevent showing
|
// to use default title and favicon instead in order to prevent showing
|
||||||
|
@ -312,7 +310,7 @@ void MediaSessionController::FillMissingTitleAndArtworkIfNeeded(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MediaSessionController::IsInPrivateBrowsing() const {
|
bool MediaStatusManager::IsInPrivateBrowsing() const {
|
||||||
RefPtr<CanonicalBrowsingContext> bc =
|
RefPtr<CanonicalBrowsingContext> bc =
|
||||||
CanonicalBrowsingContext::Get(mTopLevelBrowsingContextId);
|
CanonicalBrowsingContext::Get(mTopLevelBrowsingContextId);
|
||||||
if (!bc) {
|
if (!bc) {
|
||||||
|
@ -325,20 +323,20 @@ bool MediaSessionController::IsInPrivateBrowsing() const {
|
||||||
return nsContentUtils::IsInPrivateBrowsing(element->OwnerDoc());
|
return nsContentUtils::IsInPrivateBrowsing(element->OwnerDoc());
|
||||||
}
|
}
|
||||||
|
|
||||||
MediaSessionPlaybackState MediaSessionController::GetState() const {
|
MediaSessionPlaybackState MediaStatusManager::GetState() const {
|
||||||
return mActualPlaybackState;
|
return mActualPlaybackState;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MediaSessionController::IsMediaAudible() const {
|
bool MediaStatusManager::IsMediaAudible() const {
|
||||||
return mMediaStatusDelegate.IsAudible();
|
return mPlaybackStatusDelegate.IsAudible();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MediaSessionController::IsMediaPlaying() const {
|
bool MediaStatusManager::IsMediaPlaying() const {
|
||||||
return mActualPlaybackState == MediaSessionPlaybackState::Playing;
|
return mActualPlaybackState == MediaSessionPlaybackState::Playing;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MediaSessionController::IsAnyMediaBeingControlled() const {
|
bool MediaStatusManager::IsAnyMediaBeingControlled() const {
|
||||||
return mMediaStatusDelegate.IsAnyMediaBeingControlled();
|
return mPlaybackStatusDelegate.IsAnyMediaBeingControlled();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace dom
|
} // namespace dom
|
|
@ -2,8 +2,8 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
#ifndef DOM_MEDIA_MEDIASESSION_MEDIASESSIONCONTROLLER_H_
|
#ifndef DOM_MEDIA_MEDIACONTROL_MEDIASTATUSMANAGER_H_
|
||||||
#define DOM_MEDIA_MEDIASESSION_MEDIASESSIONCONTROLLER_H_
|
#define DOM_MEDIA_MEDIACONTROL_MEDIASTATUSMANAGER_H_
|
||||||
|
|
||||||
#include "mozilla/dom/MediaMetadata.h"
|
#include "mozilla/dom/MediaMetadata.h"
|
||||||
#include "mozilla/dom/MediaSessionBinding.h"
|
#include "mozilla/dom/MediaSessionBinding.h"
|
||||||
|
@ -74,26 +74,30 @@ class IMediaInfoUpdater {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MediaSessionController is used to track all alive media sessions within a tab
|
* MediaStatusManager would decide the media related status which can represents
|
||||||
|
* the whole tab. The status includes the playback status, tab's metadata and
|
||||||
|
* the active media session ID if it exists.
|
||||||
|
*
|
||||||
|
* We would use `IMediaInfoUpdater` methods to update the media playback related
|
||||||
|
* information and then use `MediaPlaybackStatus` to determine the final
|
||||||
|
* playback state.
|
||||||
|
*
|
||||||
|
* The metadata would be the one from the active media session, or the default
|
||||||
|
* one. This class would determine which media session is an active media
|
||||||
|
* session [1] whithin a tab. It tracks all alive media sessions within a tab
|
||||||
* and store their metadata which could be used to show on the virtual media
|
* and store their metadata which could be used to show on the virtual media
|
||||||
* control interface. In addition, we can use it to get the current media
|
* control interface. In addition, we can use it to get the current media
|
||||||
* metadata even if there is no media session existing.
|
* metadata even if there is no media session existing. However, the meaning of
|
||||||
*
|
* active media session here is not equal to the definition from the spec [1].
|
||||||
* When media session is created in the content process, we would notify
|
* We just choose the session which is the active one inside the tab, the global
|
||||||
* MediaSessionController in the parent process to tell it in which browsing
|
* active media session among different tabs would be the one inside the main
|
||||||
* context media session is created. If there are multiple media sessions
|
* controller which is determined by MediaControlService.
|
||||||
* existing in the same tab, MediaSessionController would take a resbonsibility
|
|
||||||
* to decide which media session should be an active media session. However,
|
|
||||||
* the meaning of active media session here is not equal to the definition from
|
|
||||||
* the spec [1]. We just choose the session which is the active one inside the
|
|
||||||
* tab, the global active media session among different tabs would be selected
|
|
||||||
* in other place, which is related to how we select media controller.
|
|
||||||
*
|
*
|
||||||
* [1] https://w3c.github.io/mediasession/#active-media-session
|
* [1] https://w3c.github.io/mediasession/#active-media-session
|
||||||
*/
|
*/
|
||||||
class MediaSessionController : public IMediaInfoUpdater {
|
class MediaStatusManager : public IMediaInfoUpdater {
|
||||||
public:
|
public:
|
||||||
explicit MediaSessionController(uint64_t aBrowsingContextId);
|
explicit MediaStatusManager(uint64_t aBrowsingContextId);
|
||||||
|
|
||||||
// IMediaInfoUpdater's methods
|
// IMediaInfoUpdater's methods
|
||||||
void NotifyMediaPlaybackChanged(uint64_t aBrowsingContextId,
|
void NotifyMediaPlaybackChanged(uint64_t aBrowsingContextId,
|
||||||
|
@ -124,7 +128,7 @@ class MediaSessionController : public IMediaInfoUpdater {
|
||||||
MediaSessionPlaybackState GetState() const;
|
MediaSessionPlaybackState GetState() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
~MediaSessionController() = default;
|
~MediaStatusManager() = default;
|
||||||
virtual void HandleActualPlaybackStateChanged() = 0;
|
virtual void HandleActualPlaybackStateChanged() = 0;
|
||||||
|
|
||||||
uint64_t mTopLevelBrowsingContextId;
|
uint64_t mTopLevelBrowsingContextId;
|
||||||
|
@ -170,10 +174,10 @@ class MediaSessionController : public IMediaInfoUpdater {
|
||||||
|
|
||||||
nsDataHashtable<nsUint64HashKey, MediaSessionInfo> mMediaSessionInfoMap;
|
nsDataHashtable<nsUint64HashKey, MediaSessionInfo> mMediaSessionInfoMap;
|
||||||
MediaEventProducer<MediaMetadataBase> mMetadataChangedEvent;
|
MediaEventProducer<MediaMetadataBase> mMetadataChangedEvent;
|
||||||
MediaPlaybackStatus mMediaStatusDelegate;
|
MediaPlaybackStatus mPlaybackStatusDelegate;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace dom
|
} // namespace dom
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif // DOM_MEDIA_MEDIASESSION_MEDIASESSIONCONTROLLER_H_
|
#endif // DOM_MEDIA_MEDIACONTROL_MEDIASTATUSMANAGER_H_
|
|
@ -14,6 +14,7 @@ EXPORTS.mozilla.dom += [
|
||||||
'MediaControlService.h',
|
'MediaControlService.h',
|
||||||
'MediaControlUtils.h',
|
'MediaControlUtils.h',
|
||||||
'MediaPlaybackStatus.h',
|
'MediaPlaybackStatus.h',
|
||||||
|
'MediaStatusManager.h',
|
||||||
]
|
]
|
||||||
|
|
||||||
EXPORTS.ipc += [
|
EXPORTS.ipc += [
|
||||||
|
@ -31,6 +32,7 @@ UNIFIED_SOURCES += [
|
||||||
'MediaControlService.cpp',
|
'MediaControlService.cpp',
|
||||||
'MediaControlUtils.cpp',
|
'MediaControlUtils.cpp',
|
||||||
'MediaPlaybackStatus.cpp',
|
'MediaPlaybackStatus.cpp',
|
||||||
|
'MediaStatusManager.cpp',
|
||||||
]
|
]
|
||||||
|
|
||||||
include('/ipc/chromium/chromium-config.mozbuild')
|
include('/ipc/chromium/chromium-config.mozbuild')
|
||||||
|
|
|
@ -9,7 +9,6 @@ MOCHITEST_MANIFESTS += ['test/mochitest.ini']
|
||||||
EXPORTS.mozilla.dom += [
|
EXPORTS.mozilla.dom += [
|
||||||
'MediaMetadata.h',
|
'MediaMetadata.h',
|
||||||
'MediaSession.h',
|
'MediaSession.h',
|
||||||
'MediaSessionController.h',
|
|
||||||
'MediaSessionIPCUtils.h',
|
'MediaSessionIPCUtils.h',
|
||||||
'MediaSessionUtils.h',
|
'MediaSessionUtils.h',
|
||||||
]
|
]
|
||||||
|
@ -17,7 +16,6 @@ EXPORTS.mozilla.dom += [
|
||||||
UNIFIED_SOURCES += [
|
UNIFIED_SOURCES += [
|
||||||
'MediaMetadata.cpp',
|
'MediaMetadata.cpp',
|
||||||
'MediaSession.cpp',
|
'MediaSession.cpp',
|
||||||
'MediaSessionController.cpp',
|
|
||||||
]
|
]
|
||||||
|
|
||||||
include('/ipc/chromium/chromium-config.mozbuild')
|
include('/ipc/chromium/chromium-config.mozbuild')
|
||||||
|
|
Загрузка…
Ссылка в новой задаче