Diff
Modified: trunk/Source/WebCore/ChangeLog (231603 => 231604)
--- trunk/Source/WebCore/ChangeLog 2018-05-09 22:35:38 UTC (rev 231603)
+++ trunk/Source/WebCore/ChangeLog 2018-05-09 23:02:29 UTC (rev 231604)
@@ -1,3 +1,62 @@
+2018-05-09 Eric Carlson <[email protected]>
+
+ Update MediaSession to use release logging
+ https://bugs.webkit.org/show_bug.cgi?id=185376
+ <rdar://problem/40022203>
+
+ Reviewed by Youenn Fablet.
+
+ No new tests, tested manually.
+
+ * Modules/mediastream/MediaStream.h: hostingDocument() doesn't need to return a const Document.
+ * Modules/webaudio/AudioContext.cpp:
+ (WebCore::AudioContext::hostingDocument const): Ditto.
+ * Modules/webaudio/AudioContext.h:
+
+ * html/HTMLMediaElement.h: Ditto.
+
+ * html/MediaElementSession.cpp:
+ (WebCore::MediaElementSession::MediaElementSession):
+ (WebCore::MediaElementSession::addBehaviorRestriction):
+ (WebCore::MediaElementSession::removeBehaviorRestriction):
+ (WebCore::MediaElementSession::dataLoadingPermitted const):
+ (WebCore::MediaElementSession::fullscreenPermitted const):
+ (WebCore::MediaElementSession::pageAllowsDataLoading const):
+ (WebCore::MediaElementSession::pageAllowsPlaybackAfterResuming const):
+ (WebCore::MediaElementSession::canShowControlsManager const):
+ (WebCore::MediaElementSession::showPlaybackTargetPicker):
+ (WebCore::MediaElementSession::hasWirelessPlaybackTargets const):
+ (WebCore::MediaElementSession::wirelessVideoPlaybackDisabled const):
+ (WebCore::MediaElementSession::setWirelessVideoPlaybackDisabled):
+ (WebCore::MediaElementSession::setHasPlaybackTargetAvailabilityListeners):
+ (WebCore::MediaElementSession::externalOutputDeviceAvailableDidChange):
+ (WebCore::MediaElementSession::setShouldPlayToPlaybackTarget):
+ (WebCore::MediaElementSession::mediaEngineUpdated):
+ (WebCore::MediaElementSession::willLog const): Deleted.
+ (WebCore::MediaElementSession::logger const): Deleted.
+ (WebCore::MediaElementSession::logIdentifier const): Deleted.
+ (WebCore::MediaElementSession::logChannel const): Deleted.
+ * html/MediaElementSession.h:
+
+ * platform/audio/PlatformMediaSession.cpp:
+ (WebCore::nextLogIdentifier):
+ (WebCore::convertEnumerationToString):
+ (WebCore::PlatformMediaSession::PlatformMediaSession):
+ (WebCore::PlatformMediaSession::setState):
+ (WebCore::PlatformMediaSession::beginInterruption):
+ (WebCore::PlatformMediaSession::endInterruption):
+ (WebCore::PlatformMediaSession::clientWillBeginAutoplaying):
+ (WebCore::PlatformMediaSession::clientWillPausePlayback):
+ (WebCore::PlatformMediaSession::pauseSession):
+ (WebCore::PlatformMediaSession::stopSession):
+ (WebCore::PlatformMediaSession::clientDataBufferingTimerFired):
+ (WebCore::PlatformMediaSession::logChannel const):
+ (WebCore::stateName): Deleted.
+ (WebCore::interruptionName): Deleted.
+ * platform/audio/PlatformMediaSession.h:
+ (WTF::LogArgument<WebCore::PlatformMediaSession::State>::toString):
+ (WTF::LogArgument<WebCore::PlatformMediaSession::InterruptionType>::toString):
+
2018-05-09 Thibault Saunier <[email protected]>
[GStreamer] Never call updateTracks if running on legacy pipeline
Modified: trunk/Source/WebCore/Modules/mediastream/MediaStream.h (231603 => 231604)
--- trunk/Source/WebCore/Modules/mediastream/MediaStream.h 2018-05-09 22:35:38 UTC (rev 231603)
+++ trunk/Source/WebCore/Modules/mediastream/MediaStream.h 2018-05-09 23:02:29 UTC (rev 231604)
@@ -151,7 +151,7 @@
bool shouldOverrideBackgroundPlaybackRestriction(PlatformMediaSession::InterruptionType) const final { return false; }
String sourceApplicationIdentifier() const final;
bool canProduceAudio() const final;
- const Document* hostingDocument() const final { return document(); }
+ Document* hostingDocument() const final { return document(); }
bool processingUserGestureForMedia() const final;
// ActiveDOMObject API.
Modified: trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp (231603 => 231604)
--- trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp 2018-05-09 22:35:38 UTC (rev 231603)
+++ trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp 2018-05-09 23:02:29 UTC (rev 231604)
@@ -343,7 +343,7 @@
return downcast<Document>(m_scriptExecutionContext);
}
-const Document* AudioContext::hostingDocument() const
+Document* AudioContext::hostingDocument() const
{
return downcast<Document>(m_scriptExecutionContext);
}
Modified: trunk/Source/WebCore/Modules/webaudio/AudioContext.h (231603 => 231604)
--- trunk/Source/WebCore/Modules/webaudio/AudioContext.h 2018-05-09 22:35:38 UTC (rev 231603)
+++ trunk/Source/WebCore/Modules/webaudio/AudioContext.h 2018-05-09 23:02:29 UTC (rev 231604)
@@ -90,7 +90,7 @@
Document* document() const; // ASSERTs if document no longer exists.
- const Document* hostingDocument() const override;
+ Document* hostingDocument() const final;
AudioDestinationNode* destination() { return m_destinationNode.get(); }
size_t currentSampleFrame() const { return m_destinationNode->currentSampleFrame(); }
Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (231603 => 231604)
--- trunk/Source/WebCore/html/HTMLMediaElement.h 2018-05-09 22:35:38 UTC (rev 231603)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h 2018-05-09 23:02:29 UTC (rev 231604)
@@ -198,7 +198,7 @@
bool inActiveDocument() const { return m_inActiveDocument; }
- const Document* hostingDocument() const override { return &document(); }
+ Document* hostingDocument() const final { return &document(); }
// DOM API
// error state
Modified: trunk/Source/WebCore/html/MediaElementSession.cpp (231603 => 231604)
--- trunk/Source/WebCore/html/MediaElementSession.cpp 2018-05-09 22:35:38 UTC (rev 231603)
+++ trunk/Source/WebCore/html/MediaElementSession.cpp 2018-05-09 23:02:29 UTC (rev 231604)
@@ -61,8 +61,8 @@
static bool isElementRectMostlyInMainFrame(const HTMLMediaElement&);
static bool isElementLargeEnoughForMainContent(const HTMLMediaElement&, MediaSessionMainContentPurpose);
-#if !LOG_DISABLED
-static String restrictionName(MediaElementSession::BehaviorRestrictions restriction)
+#if !RELEASE_LOG_DISABLED
+static String restrictionNames(MediaElementSession::BehaviorRestrictions restriction)
{
StringBuilder restrictionBuilder;
#define CASE(restrictionType) \
@@ -72,19 +72,23 @@
restrictionBuilder.append(#restrictionType); \
} \
- CASE(NoRestrictions);
- CASE(RequireUserGestureForLoad);
- CASE(RequireUserGestureForVideoRateChange);
- CASE(RequireUserGestureForAudioRateChange);
- CASE(RequireUserGestureForFullscreen);
- CASE(RequirePageConsentToLoadMedia);
- CASE(RequirePageConsentToResumeMedia);
-#if ENABLE(WIRELESS_PLAYBACK_TARGET)
- CASE(RequireUserGestureToShowPlaybackTargetPicker);
- CASE(WirelessVideoPlaybackDisabled);
-#endif
- CASE(InvisibleAutoplayNotPermitted);
- CASE(OverrideUserGestureRequirementForMainContent);
+ CASE(NoRestrictions)
+ CASE(RequireUserGestureForLoad)
+ CASE(RequireUserGestureForVideoRateChange)
+ CASE(RequireUserGestureForAudioRateChange)
+ CASE(RequireUserGestureForFullscreen)
+ CASE(RequirePageConsentToLoadMedia)
+ CASE(RequirePageConsentToResumeMedia)
+ CASE(RequireUserGestureToShowPlaybackTargetPicker)
+ CASE(WirelessVideoPlaybackDisabled)
+ CASE(RequireUserGestureToAutoplayToExternalDevice)
+ CASE(MetadataPreloadingNotPermitted)
+ CASE(AutoPreloadingNotPermitted)
+ CASE(InvisibleAutoplayNotPermitted)
+ CASE(OverrideUserGestureRequirementForMainContent)
+ CASE(RequireUserGestureToControlControlsManager)
+ CASE(RequirePlaybackToControlControlsManager)
+ CASE(RequireUserGestureForVideoDueToLowPowerMode)
return restrictionBuilder.toString();
}
@@ -105,6 +109,9 @@
, m_targetAvailabilityChangedTimer(*this, &MediaElementSession::targetAvailabilityChangedTimerFired)
#endif
, m_mainContentCheckTimer(*this, &MediaElementSession::mainContentCheckTimerFired)
+#if !RELEASE_LOG_DISABLED
+ , m_logIdentifier(element.logIdentifier())
+#endif
{
}
@@ -126,12 +133,14 @@
#endif
}
-void MediaElementSession::addBehaviorRestriction(BehaviorRestrictions restriction)
+void MediaElementSession::addBehaviorRestriction(BehaviorRestrictions restrictions)
{
- LOG(Media, "MediaElementSession::addBehaviorRestriction - adding %s", restrictionName(restriction).utf8().data());
- m_restrictions |= restriction;
+ if (restrictions & ~m_restrictions)
+ INFO_LOG(LOGIDENTIFIER, "adding ", restrictionNames(restrictions & ~m_restrictions));
- if (restriction & OverrideUserGestureRequirementForMainContent)
+ m_restrictions |= restrictions;
+
+ if (restrictions & OverrideUserGestureRequirementForMainContent)
m_mainContentCheckTimer.startRepeating(elementMainContentCheckInterval);
}
@@ -143,7 +152,10 @@
page->setAllowsPlaybackControlsForAutoplayingAudio(true);
}
- LOG(Media, "MediaElementSession::removeBehaviorRestriction - removing %s", restrictionName(restriction).utf8().data());
+ if (!(m_restrictions & restriction))
+ return;
+
+ INFO_LOG(LOGIDENTIFIER, "removing ", restrictionNames(m_restrictions & restriction));
m_restrictions &= ~restriction;
}
@@ -256,7 +268,7 @@
return true;
if (m_restrictions & RequireUserGestureForLoad && !m_element.document().processingUserGestureForMedia()) {
- LOG(Media, "MediaElementSession::dataLoadingPermitted - returning FALSE");
+ INFO_LOG(LOGIDENTIFIER, "returning FALSE");
return false;
}
@@ -266,7 +278,7 @@
bool MediaElementSession::fullscreenPermitted() const
{
if (m_restrictions & RequireUserGestureForFullscreen && !m_element.document().processingUserGestureForMedia()) {
- LOG(Media, "MediaElementSession::fullscreenPermitted - returning FALSE");
+ INFO_LOG(LOGIDENTIFIER, "returning FALSE");
return false;
}
@@ -277,7 +289,7 @@
{
Page* page = m_element.document().page();
if (m_restrictions & RequirePageConsentToLoadMedia && page && !page->canStartMedia()) {
- LOG(Media, "MediaElementSession::pageAllowsDataLoading - returning FALSE");
+ INFO_LOG(LOGIDENTIFIER, "returning FALSE");
return false;
}
@@ -288,7 +300,7 @@
{
Page* page = m_element.document().page();
if (m_restrictions & RequirePageConsentToResumeMedia && page && !page->canStartMedia()) {
- LOG(Media, "MediaElementSession::pageAllowsPlaybackAfterResuming - returning FALSE");
+ INFO_LOG(LOGIDENTIFIER, "returning FALSE");
return false;
}
@@ -298,67 +310,67 @@
bool MediaElementSession::canShowControlsManager(PlaybackControlsPurpose purpose) const
{
if (m_element.isSuspended() || !m_element.inActiveDocument()) {
- LOG(Media, "MediaElementSession::canShowControlsManager - returning FALSE: isSuspended()");
+ INFO_LOG(LOGIDENTIFIER, "returning FALSE: isSuspended()");
return false;
}
if (m_element.isFullscreen()) {
- LOG(Media, "MediaElementSession::canShowControlsManager - returning TRUE: Is fullscreen");
+ INFO_LOG(LOGIDENTIFIER, "returning TRUE: is fullscreen");
return true;
}
if (m_element.muted()) {
- LOG(Media, "MediaElementSession::canShowControlsManager - returning FALSE: Muted");
+ INFO_LOG(LOGIDENTIFIER, "returning FALSE: muted");
return false;
}
if (m_element.document().isMediaDocument() && (m_element.document().frame() && m_element.document().frame()->isMainFrame())) {
- LOG(Media, "MediaElementSession::canShowControlsManager - returning TRUE: Is media document");
+ INFO_LOG(LOGIDENTIFIER, "returning TRUE: is media document");
return true;
}
if (client().presentationType() == Audio) {
if (!hasBehaviorRestriction(RequireUserGestureToControlControlsManager) || m_element.document().processingUserGestureForMedia()) {
- LOG(Media, "MediaElementSession::canShowControlsManager - returning TRUE: Audio element with user gesture");
+ INFO_LOG(LOGIDENTIFIER, "returning TRUE: audio element with user gesture");
return true;
}
if (m_element.isPlaying() && allowsPlaybackControlsForAutoplayingAudio()) {
- LOG(Media, "MediaElementSession::canShowControlsManager - returning TRUE: User has played media before");
+ INFO_LOG(LOGIDENTIFIER, "returning TRUE: user has played media before");
return true;
}
- LOG(Media, "MediaElementSession::canShowControlsManager - returning FALSE: Audio element is not suitable");
+ INFO_LOG(LOGIDENTIFIER, "returning FALSE: audio element is not suitable");
return false;
}
if (purpose == PlaybackControlsPurpose::ControlsManager && !isElementRectMostlyInMainFrame(m_element)) {
- LOG(Media, "MediaElementSession::canShowControlsManager - returning FALSE: Not in main frame");
+ INFO_LOG(LOGIDENTIFIER, "returning FALSE: not in main frame");
return false;
}
if (!m_element.hasAudio() && !m_element.hasEverHadAudio()) {
- LOG(Media, "MediaElementSession::canShowControlsManager - returning FALSE: No audio");
+ INFO_LOG(LOGIDENTIFIER, "returning FALSE: no audio");
return false;
}
if (!playbackPermitted()) {
- LOG(Media, "MediaElementSession::canShowControlsManager - returning FALSE: Playback not permitted");
+ INFO_LOG(LOGIDENTIFIER, "returning FALSE: playback not permitted");
return false;
}
if (!hasBehaviorRestriction(RequireUserGestureToControlControlsManager) || m_element.document().processingUserGestureForMedia()) {
- LOG(Media, "MediaElementSession::canShowControlsManager - returning TRUE: No user gesture required");
+ INFO_LOG(LOGIDENTIFIER, "returning TRUE: no user gesture required");
return true;
}
if (purpose == PlaybackControlsPurpose::ControlsManager && hasBehaviorRestriction(RequirePlaybackToControlControlsManager) && !m_element.isPlaying()) {
- LOG(Media, "MediaElementSession::canShowControlsManager - returning FALSE: Needs to be playing");
+ INFO_LOG(LOGIDENTIFIER, "returning FALSE: needs to be playing");
return false;
}
if (!m_element.hasEverNotifiedAboutPlaying()) {
- LOG(Media, "MediaElementSession::canShowControlsManager - returning FALSE: Hasn't fired playing notification");
+ INFO_LOG(LOGIDENTIFIER, "returning FALSE: hasn't fired playing notification");
return false;
}
@@ -365,27 +377,27 @@
// Only allow the main content heuristic to forbid videos from showing up if our purpose is the controls manager.
if (purpose == PlaybackControlsPurpose::ControlsManager && m_element.isVideo()) {
if (!m_element.renderer()) {
- LOG(Media, "MediaElementSession::canShowControlsManager - returning FALSE: No renderer");
+ INFO_LOG(LOGIDENTIFIER, "returning FALSE: no renderer");
return false;
}
if (!m_element.hasVideo() && !m_element.hasEverHadVideo()) {
- LOG(Media, "MediaElementSession::canShowControlsManager - returning FALSE: No video");
+ INFO_LOG(LOGIDENTIFIER, "returning FALSE: no video");
return false;
}
if (isLargeEnoughForMainContent(MediaSessionMainContentPurpose::MediaControls)) {
- LOG(Media, "MediaElementSession::canShowControlsManager - returning TRUE: Is main content");
+ INFO_LOG(LOGIDENTIFIER, "returning TRUE: is main content");
return true;
}
}
if (purpose == PlaybackControlsPurpose::NowPlaying) {
- LOG(Media, "MediaElementSession::canShowControlsManager - returning TRUE: Potentially plays audio");
+ INFO_LOG(LOGIDENTIFIER, "returning TRUE: potentially plays audio");
return true;
}
- LOG(Media, "MediaElementSession::canShowControlsManager - returning FALSE: No user gesture");
+ INFO_LOG(LOGIDENTIFIER, "returning FALSE: no user gesture");
return false;
}
@@ -414,22 +426,22 @@
#if ENABLE(WIRELESS_PLAYBACK_TARGET)
void MediaElementSession::showPlaybackTargetPicker()
{
- LOG(Media, "MediaElementSession::showPlaybackTargetPicker");
+ INFO_LOG(LOGIDENTIFIER);
auto& document = m_element.document();
if (m_restrictions & RequireUserGestureToShowPlaybackTargetPicker && !document.processingUserGestureForMedia()) {
- LOG(Media, "MediaElementSession::showPlaybackTargetPicker - returning early because of permissions");
+ INFO_LOG(LOGIDENTIFIER, "returning early because of permissions");
return;
}
if (!document.page()) {
- LOG(Media, "MediaElementSession::showingPlaybackTargetPickerPermitted - returning early because page is NULL");
+ INFO_LOG(LOGIDENTIFIER, "returning early because page is NULL");
return;
}
#if !PLATFORM(IOS)
if (m_element.readyState() < HTMLMediaElementEnums::HAVE_METADATA) {
- LOG(Media, "MediaElementSession::showPlaybackTargetPicker - returning early because element is not playable");
+ INFO_LOG(LOGIDENTIFIER, "returning early because element is not playable");
return;
}
#endif
@@ -445,7 +457,7 @@
m_hasPlaybackTargets = PlatformMediaSessionManager::sharedManager().hasWirelessTargetsAvailable();
#endif
- LOG(Media, "MediaElementSession::hasWirelessPlaybackTargets - returning %s", m_hasPlaybackTargets ? "TRUE" : "FALSE");
+ INFO_LOG(LOGIDENTIFIER, "returning ", m_hasPlaybackTargets);
return m_hasPlaybackTargets;
}
@@ -453,12 +465,12 @@
bool MediaElementSession::wirelessVideoPlaybackDisabled() const
{
if (!m_element.document().settings().allowsAirPlayForMediaPlayback()) {
- LOG(Media, "MediaElementSession::wirelessVideoPlaybackDisabled - returning TRUE because of settings");
+ INFO_LOG(LOGIDENTIFIER, "returning TRUE because of settings");
return true;
}
if (m_element.hasAttributeWithoutSynchronization(HTMLNames::webkitwirelessvideoplaybackdisabledAttr)) {
- LOG(Media, "MediaElementSession::wirelessVideoPlaybackDisabled - returning TRUE because of attribute");
+ INFO_LOG(LOGIDENTIFIER, "returning TRUE because of attribute");
return true;
}
@@ -465,11 +477,11 @@
#if PLATFORM(IOS)
auto& legacyAirplayAttributeValue = m_element.attributeWithoutSynchronization(HTMLNames::webkitairplayAttr);
if (equalLettersIgnoringASCIICase(legacyAirplayAttributeValue, "deny")) {
- LOG(Media, "MediaElementSession::wirelessVideoPlaybackDisabled - returning TRUE because of legacy attribute");
+ INFO_LOG(LOGIDENTIFIER, "returning TRUE because of legacy attribute");
return true;
}
if (equalLettersIgnoringASCIICase(legacyAirplayAttributeValue, "allow")) {
- LOG(Media, "MediaElementSession::wirelessVideoPlaybackDisabled - returning FALSE because of legacy attribute");
+ INFO_LOG(LOGIDENTIFIER, "returning FALSE because of legacy attribute");
return false;
}
#endif
@@ -479,7 +491,7 @@
return true;
bool disabled = player->wirelessVideoPlaybackDisabled();
- LOG(Media, "MediaElementSession::wirelessVideoPlaybackDisabled - returning %s because media engine says so", disabled ? "TRUE" : "FALSE");
+ INFO_LOG(LOGIDENTIFIER, "returning ", disabled, " because media engine says so");
return disabled;
}
@@ -495,13 +507,13 @@
if (!player)
return;
- LOG(Media, "MediaElementSession::setWirelessVideoPlaybackDisabled - disabled %s", disabled ? "TRUE" : "FALSE");
+ INFO_LOG(LOGIDENTIFIER, disabled);
player->setWirelessVideoPlaybackDisabled(disabled);
}
void MediaElementSession::setHasPlaybackTargetAvailabilityListeners(bool hasListeners)
{
- LOG(Media, "MediaElementSession::setHasPlaybackTargetAvailabilityListeners - hasListeners %s", hasListeners ? "TRUE" : "FALSE");
+ INFO_LOG(LOGIDENTIFIER, hasListeners);
#if PLATFORM(IOS)
m_hasPlaybackTargetAvailabilityListeners = hasListeners;
@@ -528,7 +540,7 @@
if (m_hasPlaybackTargets == hasTargets)
return;
- LOG(Media, "MediaElementSession::externalOutputDeviceAvailableDidChange(%p) - hasTargets %s", this, hasTargets ? "TRUE" : "FALSE");
+ INFO_LOG(LOGIDENTIFIER, hasTargets);
m_hasPlaybackTargets = hasTargets;
m_targetAvailabilityChangedTimer.startOneShot(0_s);
@@ -556,7 +568,7 @@
void MediaElementSession::setShouldPlayToPlaybackTarget(bool shouldPlay)
{
- LOG(Media, "MediaElementSession::setShouldPlayToPlaybackTarget - shouldPlay %s", shouldPlay ? "TRUE" : "FALSE");
+ INFO_LOG(LOGIDENTIFIER, shouldPlay);
m_shouldPlayToPlaybackTarget = shouldPlay;
client().setShouldPlayToPlaybackTarget(shouldPlay);
}
@@ -635,7 +647,7 @@
void MediaElementSession::mediaEngineUpdated()
{
- LOG(Media, "MediaElementSession::mediaEngineUpdated");
+ INFO_LOG(LOGIDENTIFIER);
#if ENABLE(WIRELESS_PLAYBACK_TARGET)
if (m_restrictions & WirelessVideoPlaybackDisabled)
@@ -843,28 +855,6 @@
return page && page->allowsPlaybackControlsForAutoplayingAudio();
}
-bool MediaElementSession::willLog(WTFLogLevel level) const
-{
- return m_element.willLog(level);
}
-#if !RELEASE_LOG_DISABLED
-const Logger& MediaElementSession::logger() const
-{
- return m_element.logger();
-}
-
-const void* MediaElementSession::logIdentifier() const
-{
- return m_element.logIdentifier();
-}
-
-WTFLogChannel& MediaElementSession::logChannel() const
-{
- return m_element.logChannel();
-}
-#endif
-
-}
-
#endif // ENABLE(VIDEO)
Modified: trunk/Source/WebCore/html/MediaElementSession.h (231603 => 231604)
--- trunk/Source/WebCore/html/MediaElementSession.h 2018-05-09 22:35:38 UTC (rev 231603)
+++ trunk/Source/WebCore/html/MediaElementSession.h 2018-05-09 23:02:29 UTC (rev 231604)
@@ -32,7 +32,6 @@
#include "PlatformMediaSession.h"
#include "SuccessOr.h"
#include "Timer.h"
-#include <wtf/LoggerHelper.h>
#include <wtf/TypeCasts.h>
namespace WebCore {
@@ -53,9 +52,6 @@
class SourceBuffer;
class MediaElementSession final : public PlatformMediaSession
-#if !RELEASE_LOG_DISABLED
- , private LoggerHelper
-#endif
{
WTF_MAKE_FAST_ALLOCATED;
public:
@@ -149,12 +145,9 @@
}
#if !RELEASE_LOG_DISABLED
- const Logger& logger() const final;
- const void* logIdentifier() const final;
+ const void* logIdentifier() const final { return m_logIdentifier; }
const char* logClassName() const final { return "MediaElementSession"; }
- WTFLogChannel& logChannel() const final;
#endif
- bool willLog(WTFLogLevel) const;
private:
@@ -189,6 +182,10 @@
mutable bool m_isMainContent { false };
Timer m_mainContentCheckTimer;
+
+#if !RELEASE_LOG_DISABLED
+ const void* m_logIdentifier;
+#endif
};
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/audio/PlatformMediaSession.cpp (231603 => 231604)
--- trunk/Source/WebCore/platform/audio/PlatformMediaSession.cpp 2018-05-09 22:35:38 UTC (rev 231603)
+++ trunk/Source/WebCore/platform/audio/PlatformMediaSession.cpp 2018-05-09 23:02:29 UTC (rev 231604)
@@ -31,43 +31,59 @@
#include "Logging.h"
#include "MediaPlayer.h"
#include "PlatformMediaSessionManager.h"
+#include <wtf/CryptographicallyRandomNumber.h>
namespace WebCore {
static const Seconds clientDataBufferingTimerThrottleDelay { 100_ms };
-#if !LOG_DISABLED
-static const char* stateName(PlatformMediaSession::State state)
+#if !RELEASE_LOG_DISABLED
+static uint64_t nextLogIdentifier()
{
-#define STATE_CASE(state) case PlatformMediaSession::state: return #state
- switch (state) {
- STATE_CASE(Idle);
- STATE_CASE(Autoplaying);
- STATE_CASE(Playing);
- STATE_CASE(Paused);
- STATE_CASE(Interrupted);
- }
+ static uint64_t logIdentifier = cryptographicallyRandomNumber();
+ return ++logIdentifier;
+}
- ASSERT_NOT_REACHED();
- return "";
+String convertEnumerationToString(PlatformMediaSession::State state)
+{
+ static const NeverDestroyed<String> values[] = {
+ MAKE_STATIC_STRING_IMPL("Idle"),
+ MAKE_STATIC_STRING_IMPL("Autoplaying"),
+ MAKE_STATIC_STRING_IMPL("Playing"),
+ MAKE_STATIC_STRING_IMPL("Paused"),
+ MAKE_STATIC_STRING_IMPL("Interrupted"),
+ };
+ static_assert(!static_cast<size_t>(PlatformMediaSession::Idle), "PlatformMediaSession::Idle is not 0 as expected");
+ static_assert(static_cast<size_t>(PlatformMediaSession::Autoplaying == 1), "PlatformMediaSession::Autoplaying is not 1 as expected");
+ static_assert(static_cast<size_t>(PlatformMediaSession::Playing == 2), "PlatformMediaSession::Playing is not 2 as expected");
+ static_assert(static_cast<size_t>(PlatformMediaSession::Paused == 3), "PlatformMediaSession::Paused is not 3 as expected");
+ static_assert(static_cast<size_t>(PlatformMediaSession::Interrupted == 4), "PlatformMediaSession::Interrupted is not 4 as expected");
+ ASSERT(static_cast<size_t>(state) < WTF_ARRAY_LENGTH(values));
+ return values[static_cast<size_t>(state)];
}
-static const char* interruptionName(PlatformMediaSession::InterruptionType type)
+String convertEnumerationToString(PlatformMediaSession::InterruptionType type)
{
-#define INTERRUPTION_CASE(type) case PlatformMediaSession::type: return #type
- switch (type) {
- INTERRUPTION_CASE(NoInterruption);
- INTERRUPTION_CASE(SystemSleep);
- INTERRUPTION_CASE(EnteringBackground);
- INTERRUPTION_CASE(SystemInterruption);
- INTERRUPTION_CASE(SuspendedUnderLock);
- INTERRUPTION_CASE(InvisibleAutoplay);
- INTERRUPTION_CASE(ProcessInactive);
- }
-
- ASSERT_NOT_REACHED();
- return "";
+ static const NeverDestroyed<String> values[] = {
+ MAKE_STATIC_STRING_IMPL("NoInterruption"),
+ MAKE_STATIC_STRING_IMPL("SystemSleep"),
+ MAKE_STATIC_STRING_IMPL("EnteringBackground"),
+ MAKE_STATIC_STRING_IMPL("SystemInterruption"),
+ MAKE_STATIC_STRING_IMPL("SuspendedUnderLock"),
+ MAKE_STATIC_STRING_IMPL("InvisibleAutoplay"),
+ MAKE_STATIC_STRING_IMPL("ProcessInactive"),
+ };
+ static_assert(!static_cast<size_t>(PlatformMediaSession::NoInterruption), "PlatformMediaSession::NoInterruption is not 0 as expected");
+ static_assert(static_cast<size_t>(PlatformMediaSession::SystemSleep == 1), "PlatformMediaSession::SystemSleep is not 1 as expected");
+ static_assert(static_cast<size_t>(PlatformMediaSession::EnteringBackground == 2), "PlatformMediaSession::EnteringBackground is not 2 as expected");
+ static_assert(static_cast<size_t>(PlatformMediaSession::SystemInterruption == 3), "PlatformMediaSession::SystemInterruption is not 3 as expected");
+ static_assert(static_cast<size_t>(PlatformMediaSession::SuspendedUnderLock == 4), "PlatformMediaSession::SuspendedUnderLock is not 4 as expected");
+ static_assert(static_cast<size_t>(PlatformMediaSession::InvisibleAutoplay == 5), "PlatformMediaSession::InvisibleAutoplay is not 5 as expected");
+ static_assert(static_cast<size_t>(PlatformMediaSession::ProcessInactive == 6), "PlatformMediaSession::ProcessInactive is not 6 as expected");
+ ASSERT(static_cast<size_t>(type) < WTF_ARRAY_LENGTH(values));
+ return values[static_cast<size_t>(type)];
}
+
#endif
std::unique_ptr<PlatformMediaSession> PlatformMediaSession::create(PlatformMediaSessionClient& client)
@@ -81,6 +97,10 @@
, m_state(Idle)
, m_stateToRestore(Idle)
, m_notifyingClient(false)
+#if !RELEASE_LOG_DISABLED
+ , m_logger(client.hostingDocument()->logger())
+ , m_logIdentifier(nextLogIdentifier())
+#endif
{
ASSERT(m_client.mediaType() >= None && m_client.mediaType() <= MediaStreamCapturingAudio);
PlatformMediaSessionManager::sharedManager().addSession(*this);
@@ -93,13 +113,13 @@
void PlatformMediaSession::setState(State state)
{
- LOG(Media, "PlatformMediaSession::setState(%p) - %s", this, stateName(state));
+ INFO_LOG(LOGIDENTIFIER, state);
m_state = state;
}
void PlatformMediaSession::beginInterruption(InterruptionType type)
{
- LOG(Media, "PlatformMediaSession::beginInterruption(%p), state = %s, interruption type = %s, interruption count = %i", this, stateName(m_state), interruptionName(type), m_interruptionCount);
+ INFO_LOG(LOGIDENTIFIER, "state = ", m_state, ", interruption type = ", type, ", interruption count = ", m_interruptionCount);
// When interruptions are overridden, m_interruptionType doesn't get set.
// Give nested interruptions a chance when the previous interruptions were overridden.
@@ -107,7 +127,7 @@
return;
if (client().shouldOverrideBackgroundPlaybackRestriction(type)) {
- LOG(Media, "PlatformMediaSession::beginInterruption(%p), returning early because client says to override interruption", this);
+ INFO_LOG(LOGIDENTIFIER, "returning early because client says to override interruption");
return;
}
@@ -121,10 +141,10 @@
void PlatformMediaSession::endInterruption(EndInterruptionFlags flags)
{
- LOG(Media, "PlatformMediaSession::endInterruption(%p) - flags = %i, stateToRestore = %s, interruption count = %i", this, (int)flags, stateName(m_stateToRestore), m_interruptionCount);
+ INFO_LOG(LOGIDENTIFIER, "flags = ", (int)flags, ", stateToRestore = ", m_stateToRestore, ", interruption count = ", m_interruptionCount);
if (!m_interruptionCount) {
- LOG(Media, "PlatformMediaSession::endInterruption(%p) - !! ignoring spurious interruption end !!", this);
+ INFO_LOG(LOGIDENTIFIER, "!! ignoring spurious interruption end !!");
return;
}
@@ -148,10 +168,10 @@
if (m_notifyingClient)
return;
- LOG(Media, "PlatformMediaSession::clientWillBeginAutoplaying(%p)- state = %s", this, stateName(m_state));
+ INFO_LOG(LOGIDENTIFIER, "state = ", m_state);
if (state() == Interrupted) {
m_stateToRestore = Autoplaying;
- LOG(Media, " setting stateToRestore to \"Autoplaying\"");
+ INFO_LOG(LOGIDENTIFIER, " setting stateToRestore to \"Autoplaying\"");
return;
}
@@ -180,10 +200,10 @@
if (m_notifyingClient)
return true;
- LOG(Media, "PlatformMediaSession::clientWillPausePlayback(%p)- state = %s", this, stateName(m_state));
+ INFO_LOG(LOGIDENTIFIER, "state = ", m_state);
if (state() == Interrupted) {
m_stateToRestore = Paused;
- LOG(Media, " setting stateToRestore to \"Paused\"");
+ INFO_LOG(LOGIDENTIFIER, " setting stateToRestore to \"Paused\"");
return false;
}
@@ -195,13 +215,13 @@
void PlatformMediaSession::pauseSession()
{
- LOG(Media, "PlatformMediaSession::pauseSession(%p)", this);
+ INFO_LOG(LOGIDENTIFIER);
m_client.suspendPlayback();
}
void PlatformMediaSession::stopSession()
{
- LOG(Media, "PlatformMediaSession::stopSession(%p)", this);
+ INFO_LOG(LOGIDENTIFIER);
m_client.suspendPlayback();
PlatformMediaSessionManager::sharedManager().removeSession(*this);
}
@@ -266,7 +286,7 @@
void PlatformMediaSession::clientDataBufferingTimerFired()
{
- LOG(Media, "PlatformMediaSession::clientDataBufferingTimerFired(%p)- visible = %s", this, m_client.elementIsHidden() ? "false" : "true");
+ INFO_LOG(LOGIDENTIFIER, "visible = ", m_client.elementIsHidden());
updateClientDataBuffering();
@@ -370,5 +390,13 @@
PlatformMediaSessionManager::sharedManager().clientCharacteristicsChanged(*this);
}
+#if !RELEASE_LOG_DISABLED
+WTFLogChannel& PlatformMediaSession::logChannel() const
+{
+ return LogMedia;
}
#endif
+
+}
+
+#endif
Modified: trunk/Source/WebCore/platform/audio/PlatformMediaSession.h (231603 => 231604)
--- trunk/Source/WebCore/platform/audio/PlatformMediaSession.h 2018-05-09 22:35:38 UTC (rev 231603)
+++ trunk/Source/WebCore/platform/audio/PlatformMediaSession.h 2018-05-09 23:02:29 UTC (rev 231604)
@@ -27,6 +27,7 @@
#define PlatformMediaSession_h
#include "Timer.h"
+#include <wtf/LoggerHelper.h>
#include <wtf/Noncopyable.h>
#include <wtf/text/WTFString.h>
@@ -44,6 +45,9 @@
#if ENABLE(WIRELESS_PLAYBACK_TARGET)
: public MediaPlaybackTargetClient
#endif
+#if !RELEASE_LOG_DISABLED
+ , private LoggerHelper
+#endif
{
public:
static std::unique_ptr<PlatformMediaSession> create(PlatformMediaSessionClient&);
@@ -176,6 +180,13 @@
protected:
PlatformMediaSessionClient& client() const { return m_client; }
+#if !RELEASE_LOG_DISABLED
+ const Logger& logger() const final { return m_logger.get(); }
+ const void* logIdentifier() const override { return reinterpret_cast<const void*>(m_logIdentifier); }
+ const char* logClassName() const override { return "PlatformMediaSession"; }
+ WTFLogChannel& logChannel() const final;
+#endif
+
private:
void clientDataBufferingTimerFired();
void updateClientDataBuffering();
@@ -189,6 +200,11 @@
bool m_notifyingClient;
bool m_isPlayingToWirelessPlaybackTarget { false };
+#if !RELEASE_LOG_DISABLED
+ Ref<const Logger> m_logger;
+ uint64_t m_logIdentifier;
+#endif
+
friend class PlatformMediaSessionManager;
};
@@ -230,7 +246,7 @@
virtual bool isPlayingToWirelessPlaybackTarget() const { return false; }
virtual void setShouldPlayToPlaybackTarget(bool) { }
- virtual const Document* hostingDocument() const = 0;
+ virtual Document* hostingDocument() const = 0;
virtual String sourceApplicationIdentifier() const = 0;
virtual bool processingUserGestureForMedia() const = 0;
@@ -239,6 +255,32 @@
virtual ~PlatformMediaSessionClient() = default;
};
+String convertEnumerationToString(PlatformMediaSession::State);
+String convertEnumerationToString(PlatformMediaSession::InterruptionType);
+
}
+namespace WTF {
+
+template<typename Type>
+struct LogArgument;
+
+template <>
+struct LogArgument<WebCore::PlatformMediaSession::State> {
+ static String toString(const WebCore::PlatformMediaSession::State state)
+ {
+ return convertEnumerationToString(state);
+ }
+};
+
+template <>
+struct LogArgument<WebCore::PlatformMediaSession::InterruptionType> {
+ static String toString(const WebCore::PlatformMediaSession::InterruptionType state)
+ {
+ return convertEnumerationToString(state);
+ }
+};
+
+} // namespace WTF
+
#endif // PlatformMediaSession_h