WebKit Bugzilla
Attachment 361415 Details for
Bug 194348
: [MSE] Convert debug-only logging to runtime logging
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-194348-20190207105047.patch (text/plain), 114.81 KB, created by
Eric Carlson
on 2019-02-07 10:50:48 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Eric Carlson
Created:
2019-02-07 10:50:48 PST
Size:
114.81 KB
patch
obsolete
>Subversion Revision: 241049 >diff --git a/Source/WTF/ChangeLog b/Source/WTF/ChangeLog >index 65684330426e758849b51e259223d37e3270e59e..c9b702ee7eac7cf6f6383333388eb4f092e3f072 100644 >--- a/Source/WTF/ChangeLog >+++ b/Source/WTF/ChangeLog >@@ -1,3 +1,21 @@ >+2019-02-06 Eric Carlson <eric.carlson@apple.com> >+ >+ [MSE] Convert debug-only logging to runtime logging >+ https://bugs.webkit.org/show_bug.cgi?id=194348 >+ <rdar://problem/47566449> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * wtf/LoggerHelper.h: >+ (WTF::LoggerHelper::childLogIdentifier const): Helper to generate a log identifier for an >+ object that is associated with another logging object. >+ * wtf/MediaTime.cpp: >+ (WTF::MediaTime::toJSONObject const): >+ (WTF::MediaTime::toJSONString const): >+ (WTF::MediaTimeRange::toJSONString const): >+ (WTF::toJSONStringInternal): Deleted. >+ * wtf/MediaTime.h: >+ > 2019-02-05 Keith Rollin <krollin@apple.com> > > Enable the automatic checking and regenerations of .xcfilelists during builds >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 20840c60dafa706d51455081fc61894f90fcfc79..3c01f89b3b4d1adf6dac57e10146dfb24b446edd 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,185 @@ >+2019-02-06 Eric Carlson <eric.carlson@apple.com> >+ >+ [MSE] Convert debug-only logging to runtime logging >+ https://bugs.webkit.org/show_bug.cgi?id=194348 >+ <rdar://problem/47566449> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ No new tests, this just changes existing logging. >+ >+ * Modules/mediasource/MediaSource.cpp: >+ (WebCore::convertEnumerationToString): >+ (WebCore::MediaSource::MediaSource): >+ (WebCore::MediaSource::~MediaSource): >+ (WebCore::MediaSource::setPrivateAndOpen): >+ (WebCore::MediaSource::addedToRegistry): >+ (WebCore::MediaSource::removedFromRegistry): >+ (WebCore::MediaSource::durationChanged): >+ (WebCore::MediaSource::seekToTime): >+ (WebCore::MediaSource::completeSeek): >+ (WebCore::MediaSource::setLiveSeekableRange): >+ (WebCore::MediaSource::clearLiveSeekableRange): >+ (WebCore::MediaSource::setDuration): >+ (WebCore::MediaSource::setDurationInternal): >+ (WebCore::MediaSource::setReadyState): >+ (WebCore::MediaSource::endOfStream): >+ (WebCore::MediaSource::streamEndedWithError): >+ (WebCore::MediaSource::addSourceBuffer): >+ (WebCore::MediaSource::removeSourceBuffer): >+ (WebCore::MediaSource::isTypeSupported): >+ (WebCore::MediaSource::detachFromElement): >+ (WebCore::MediaSource::attachToElement): >+ (WebCore::MediaSource::openIfInEndedState): >+ (WebCore::MediaSource::suspend): >+ (WebCore::MediaSource::resume): >+ (WebCore::MediaSource::stop): >+ (WebCore::MediaSource::onReadyStateChange): >+ (WebCore::MediaSource::scheduleEvent): >+ (WebCore::MediaSource::logChannel const): >+ (WebCore::MediaSourceInternal::toString): Deleted. >+ * Modules/mediasource/MediaSource.h: >+ (WTF::LogArgument<WebCore::MediaSource::EndOfStreamError>::toString): >+ (WTF::LogArgument<WebCore::MediaSource::ReadyState>::toString): >+ * Modules/mediasource/SourceBuffer.cpp: >+ (WebCore::SourceBuffer::SourceBuffer): >+ (WebCore::SourceBuffer::~SourceBuffer): >+ (WebCore::SourceBuffer::remove): >+ (WebCore::SourceBuffer::seekToTime): >+ (WebCore::SourceBuffer::appendBufferInternal): >+ (WebCore::SourceBuffer::sourceBufferPrivateAppendComplete): >+ (WebCore::SourceBuffer::sourceBufferPrivateDidReceiveRenderingError): >+ (WebCore::removeSamplesFromTrackBuffer): >+ (WebCore::SourceBuffer::removeCodedFrames): >+ (WebCore::SourceBuffer::evictCodedFrames): >+ (WebCore::SourceBuffer::sourceBufferPrivateDidReceiveInitializationSegment): >+ (WebCore::SourceBuffer::sourceBufferPrivateDidReceiveSample): >+ (WebCore::SourceBuffer::sourceBufferPrivateReenqueSamples): >+ (WebCore::SourceBuffer::sourceBufferPrivateDidBecomeReadyForMoreSamples): >+ (WebCore::SourceBuffer::provideMediaData): >+ (WebCore::SourceBuffer::trySignalAllSamplesInTrackEnqueued): >+ (WebCore::SourceBuffer::monitorBufferingRate): >+ (WebCore::SourceBuffer::logChannel const): >+ * Modules/mediasource/SourceBuffer.h: >+ * dom/Document.cpp: >+ (WebCore::messageSourceForWTFLogChannel): >+ (WebCore::Document::didLogMessage): >+ * html/HTMLMediaElement.cpp: >+ (WebCore::convertEnumerationToString): >+ (WebCore::HTMLMediaElement::scheduleCheckPlaybackTargetCompatability): >+ (WebCore::HTMLMediaElement::selectMediaResource): >+ (WebCore::HTMLMediaElement::loadResource): >+ (WebCore::HTMLMediaElement::updateActiveTextTrackCues): >+ (WebCore::HTMLMediaElement::scheduleConfigureTextTracks): >+ (WebCore::HTMLMediaElement::scheduleMediaEngineWasUpdated): >+ (WebCore::HTMLMediaElement::scheduleUpdatePlayState): >+ (WebCore::HTMLMediaElement::scheduleUpdateMediaState): >+ * platform/ContentType.cpp: >+ (WebCore::ContentType::toJSONString const): >+ * platform/ContentType.h: >+ (WTF::LogArgument<WebCore::ContentType>::toString): >+ * platform/MediaSample.h: >+ (WebCore::MediaSample::toJSONString const): >+ (WTF::LogArgument<WebCore::MediaSample>::toString): >+ * platform/graphics/FloatSize.cpp: >+ (WebCore::FloatSize::toJSONObject const): >+ (WebCore::FloatSize::toJSONString const): >+ * platform/graphics/FloatSize.h: >+ (WTF::LogArgument<WebCore::FloatSize>::toString): >+ * platform/graphics/MediaSourcePrivate.h: >+ (WebCore::MediaSourcePrivate::mediaSourceLogIdentifier): >+ (WTF::LogArgument<WebCore::MediaSourcePrivate::AddStatus>::toString): >+ (WTF::LogArgument<WebCore::MediaSourcePrivate::EndOfStreamStatus>::toString): >+ * platform/graphics/SourceBufferPrivate.h: >+ (WebCore::SourceBufferPrivate::sourceBufferLogger const): >+ (WebCore::SourceBufferPrivate::sourceBufferLogIdentifier): >+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: >+ (WebCore::MediaPlayerPrivateAVFoundationObjC::setMuted): >+ (WebCore::MediaPlayerPrivateAVFoundationObjC::setClosedCaptionsVisible): >+ (WebCore::MediaPlayerPrivateAVFoundationObjC::isCurrentPlaybackTargetWireless const): >+ (WebCore::MediaPlayerPrivateAVFoundationObjC::wirelessVideoPlaybackDisabled const): >+ (WebCore::MediaPlayerPrivateAVFoundationObjC::setWirelessVideoPlaybackDisabled): >+ (WebCore::MediaPlayerPrivateAVFoundationObjC::setShouldPlayToPlaybackTarget): >+ (WebCore::MediaPlayerPrivateAVFoundationObjC::setShouldBufferData): >+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h: >+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::mediaPlayerLogIdentifier): >+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::mediaPlayerLogger): >+ (WTF::LogArgument<WebCore::MediaPlayerPrivateMediaSourceAVFObjC::SeekState>::toString): >+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm: >+ (WebCore::convertEnumerationToString): >+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::MediaPlayerPrivateMediaSourceAVFObjC): >+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::~MediaPlayerPrivateMediaSourceAVFObjC): >+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::load): >+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::play): >+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::playInternal): >+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::pause): >+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::pauseInternal): >+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setVolume): >+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setMuted): >+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setVisible): >+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::seekWithTolerance): >+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::seekInternal): >+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::waitForSeekCompleted): >+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::seekCompleted): >+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setPreservesPitch): >+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setHasAvailableVideoFrame): >+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::updateAllRenderersHaveAvailableSamples): >+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::durationChanged): >+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setNaturalSize): >+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setCDMSession): >+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::outputObscuredDueToInsufficientExternalProtectionChanged): >+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::cdmInstanceAttached): >+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::cdmInstanceDetached): >+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::attemptToDecryptWithInstance): >+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::waitingForKeyChanged): >+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::initializationDataEncountered): >+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setReadyState): >+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setNetworkState): >+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setShouldPlayToPlaybackTarget): >+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::isCurrentPlaybackTargetWireless const): >+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::logChannel const): >+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm: >+ (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::enqueueVideoSample): >+ * platform/graphics/avfoundation/objc/MediaSampleAVFObjC.h: >+ * platform/graphics/avfoundation/objc/MediaSampleAVFObjC.mm: >+ (WebCore::MediaSampleAVFObjC::toJSONString const): >+ * platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.h: >+ * platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm: >+ (WebCore::MediaSourcePrivateAVFObjC::MediaSourcePrivateAVFObjC): >+ (WebCore::MediaSourcePrivateAVFObjC::~MediaSourcePrivateAVFObjC): >+ (WebCore::MediaSourcePrivateAVFObjC::addSourceBuffer): >+ (WebCore::MediaSourcePrivateAVFObjC::logChannel const): >+ * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h: >+ * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm: >+ (WebCore::bufferWasConsumedCallback): >+ (WebCore::SourceBufferPrivateAVFObjC::SourceBufferPrivateAVFObjC): >+ (WebCore::SourceBufferPrivateAVFObjC::~SourceBufferPrivateAVFObjC): >+ (WebCore::SourceBufferPrivateAVFObjC::didParseStreamDataAsAsset): >+ (WebCore::SourceBufferPrivateAVFObjC::didFailToParseStreamDataWithError): >+ (WebCore::SourceBufferPrivateAVFObjC::processCodedFrame): >+ (WebCore::SourceBufferPrivateAVFObjC::willProvideContentKeyRequestInitializationDataForTrackID): >+ (WebCore::SourceBufferPrivateAVFObjC::didProvideContentKeyRequestInitializationDataForTrackID): >+ (WebCore::SourceBufferPrivateAVFObjC::append): >+ (WebCore::SourceBufferPrivateAVFObjC::abort): >+ (WebCore::SourceBufferPrivateAVFObjC::resetParserState): >+ (WebCore::SourceBufferPrivateAVFObjC::removedFromMediaSource): >+ (WebCore::SourceBufferPrivateAVFObjC::setReadyState): >+ (WebCore::SourceBufferPrivateAVFObjC::trackDidChangeEnabled): >+ (WebCore::SourceBufferPrivateAVFObjC::setCDMSession): >+ (WebCore::SourceBufferPrivateAVFObjC::setCDMInstance): >+ (WebCore::SourceBufferPrivateAVFObjC::layerDidReceiveError): >+ (WebCore::SourceBufferPrivateAVFObjC::outputObscuredDueToInsufficientExternalProtectionChanged): >+ (WebCore::SourceBufferPrivateAVFObjC::flush): >+ (WebCore::SourceBufferPrivateAVFObjC::flushVideo): >+ (WebCore::SourceBufferPrivateAVFObjC::enqueueSample): >+ (WebCore::SourceBufferPrivateAVFObjC::bufferWasConsumed): >+ (WebCore::SourceBufferPrivateAVFObjC::setActive): >+ (WebCore::SourceBufferPrivateAVFObjC::willSeek): >+ (WebCore::SourceBufferPrivateAVFObjC::didBecomeReadyForMoreSamples): >+ (WebCore::SourceBufferPrivateAVFObjC::canSwitchToType): >+ (WebCore::SourceBufferPrivateAVFObjC::setDecompressionSession): >+ (WebCore::SourceBufferPrivateAVFObjC::logChannel const): >+ > 2019-02-06 John Wilander <wilander@apple.com> > > Forward Ad Click Attribution data from HTMLAnchorElement::handleClick() to WebKit::NavigationActionData >diff --git a/Source/WTF/wtf/LoggerHelper.h b/Source/WTF/wtf/LoggerHelper.h >index f04f26f456d4424e2a2175c8905123d33eaa466d..e82647447c18d408590bc1eb0d0612434e580da5 100644 >--- a/Source/WTF/wtf/LoggerHelper.h >+++ b/Source/WTF/wtf/LoggerHelper.h >@@ -50,6 +50,12 @@ public: > #define DEBUG_LOG(...) logger().debug(logChannel(), __VA_ARGS__) > #define WILL_LOG(_level_) logger().willLog(logChannel(), _level_) > >+ const void* childLogIdentifier(uint64_t identifier) const >+ { >+ static const int64_t parentMask = 0xffffffffffff0000l; >+ static const int64_t maskLowerWord = 0xffffl; >+ return reinterpret_cast<const void*>((reinterpret_cast<uint64_t>(logIdentifier()) & parentMask) | (identifier & maskLowerWord)); >+ } > #else > > #define LOGIDENTIFIER (WTF::nullopt) >diff --git a/Source/WTF/wtf/MediaTime.cpp b/Source/WTF/wtf/MediaTime.cpp >index 417550c3b5c2ec931752bd9a28a566d56b885014..87c7fbd88f6786364cd84f4b2c45622ee341e406 100644 >--- a/Source/WTF/wtf/MediaTime.cpp >+++ b/Source/WTF/wtf/MediaTime.cpp >@@ -598,33 +598,34 @@ String MediaTime::toString() const > return builder.toString(); > } > >-static Ref<JSON::Object> toJSONStringInternal(const MediaTime& time) >+Ref<JSON::Object> MediaTime::toJSONObject() const > { > auto object = JSON::Object::create(); > >- if (time.hasDoubleValue()) >- object->setDouble("value"_s, time.toDouble()); >- else { >- if (time.isInvalid() || time.isIndefinite()) >- object->setString("value"_s, "NaN"_s); >- else if (time.isPositiveInfinite()) >- object->setString("value"_s, "POSITIVE_INFINITY"_s); >- else if (time.isNegativeInfinite()) >- object->setString("value"_s, "NEGATIVE_INFINITY"_s); >- else >- object->setDouble("value"_s, time.toDouble()); >- >- object->setInteger("numerator"_s, static_cast<int>(time.timeValue())); >- object->setInteger("denominator"_s, time.timeScale()); >- object->setInteger("flags"_s, time.timeFlags()); >+ if (hasDoubleValue()) { >+ object->setDouble("value"_s, toDouble()); >+ return object; > } > >+ if (isInvalid() || isIndefinite()) >+ object->setString("value"_s, "NaN"_s); >+ else if (isPositiveInfinite()) >+ object->setString("value"_s, "POSITIVE_INFINITY"_s); >+ else if (isNegativeInfinite()) >+ object->setString("value"_s, "NEGATIVE_INFINITY"_s); >+ else >+ object->setDouble("value"_s, toDouble()); >+ >+ object->setDouble("numerator"_s, static_cast<double>(m_timeValue)); >+ object->setInteger("denominator"_s, m_timeScale); >+ object->setInteger("flags"_s, m_timeFlags); >+ > return object; > } > > String MediaTime::toJSONString() const > { >- return toJSONStringInternal(*this)->toJSONString(); >+ return toJSONObject()->toJSONString(); > } > > MediaTime abs(const MediaTime& rhs) >@@ -645,8 +646,8 @@ String MediaTimeRange::toJSONString() const > { > auto object = JSON::Object::create(); > >- object->setObject("start"_s, toJSONStringInternal(start)); >- object->setObject("end"_s, toJSONStringInternal(end)); >+ object->setObject("start"_s, start.toJSONObject()); >+ object->setObject("end"_s, end.toJSONObject()); > > return object->toJSONString(); > } >diff --git a/Source/WTF/wtf/MediaTime.h b/Source/WTF/wtf/MediaTime.h >index 7cb78978ba9f6de33eb95dc52588ce68d8f0145f..b3478fe9c0c063b857f0a30924eb1acc3c799eae 100644 >--- a/Source/WTF/wtf/MediaTime.h >+++ b/Source/WTF/wtf/MediaTime.h >@@ -29,6 +29,7 @@ > #pragma once > > #include <wtf/FastMalloc.h> >+#include <wtf/JSONValues.h> > #include <wtf/text/WTFString.h> > > #include <cmath> >@@ -111,6 +112,7 @@ public: > void dump(PrintStream& out) const; > String toString() const; > String toJSONString() const; >+ Ref<JSON::Object> toJSONObject() const; > > // Make the following casts errors: > operator double() const = delete; >diff --git a/Source/WebCore/Modules/mediasource/MediaSource.cpp b/Source/WebCore/Modules/mediasource/MediaSource.cpp >index 3986198992ae3ed5011972e10915a2f5c8285f19..28350d45bf1a6445c843ca4d3f060ef8c7e95239 100644 >--- a/Source/WebCore/Modules/mediasource/MediaSource.cpp >+++ b/Source/WebCore/Modules/mediasource/MediaSource.cpp >@@ -51,23 +51,33 @@ > > namespace WebCore { > >-#if !LOG_DISABLED >-namespace MediaSourceInternal { >-static const char* toString(MediaSource::ReadyState readyState) >+String convertEnumerationToString(MediaSourcePrivate::AddStatus enumerationValue) > { >- switch (readyState) { >- case MediaSource::ReadyState::Closed: >- return "closed"; >- case MediaSource::ReadyState::Ended: >- return "ended"; >- case MediaSource::ReadyState::Open: >- return "open"; >- default: >- return "(unknown)"; >- } >+ static const NeverDestroyed<String> values[] = { >+ MAKE_STATIC_STRING_IMPL("Ok"), >+ MAKE_STATIC_STRING_IMPL("NotSupported"), >+ MAKE_STATIC_STRING_IMPL("ReachedIdLimit"), >+ }; >+ static_assert(static_cast<size_t>(MediaSourcePrivate::AddStatus::Ok) == 0, "MediaSourcePrivate::AddStatus::Ok is not 0 as expected"); >+ static_assert(static_cast<size_t>(MediaSourcePrivate::AddStatus::NotSupported) == 1, "MediaSourcePrivate::AddStatus::NotSupported is not 1 as expected"); >+ static_assert(static_cast<size_t>(MediaSourcePrivate::AddStatus::ReachedIdLimit) == 2, "MediaSourcePrivate::AddStatus::ReachedIdLimit is not 2 as expected"); >+ ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values)); >+ return values[static_cast<size_t>(enumerationValue)]; > } >+ >+String convertEnumerationToString(MediaSourcePrivate::EndOfStreamStatus enumerationValue) >+{ >+ static const NeverDestroyed<String> values[] = { >+ MAKE_STATIC_STRING_IMPL("EosNoError"), >+ MAKE_STATIC_STRING_IMPL("EosNetworkError"), >+ MAKE_STATIC_STRING_IMPL("EosDecodeError"), >+ }; >+ static_assert(static_cast<size_t>(MediaSourcePrivate::EndOfStreamStatus::EosNoError) == 0, "MediaSourcePrivate::EndOfStreamStatus::EosNoError is not 0 as expected"); >+ static_assert(static_cast<size_t>(MediaSourcePrivate::EndOfStreamStatus::EosNetworkError) == 1, "MediaSourcePrivate::EndOfStreamStatus::EosNetworkError is not 1 as expected"); >+ static_assert(static_cast<size_t>(MediaSourcePrivate::EndOfStreamStatus::EosDecodeError) == 2, "MediaSourcePrivate::EndOfStreamStatus::EosDecodeError is not 2 as expected"); >+ ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values)); >+ return values[static_cast<size_t>(enumerationValue)]; > } >-#endif > > URLRegistry* MediaSource::s_registry; > >@@ -89,20 +99,23 @@ MediaSource::MediaSource(ScriptExecutionContext& context) > , m_duration(MediaTime::invalidTime()) > , m_pendingSeekTime(MediaTime::invalidTime()) > , m_asyncEventQueue(*this) >+#if !RELEASE_LOG_DISABLED >+ , m_logger(downcast<Document>(context).logger()) >+#endif > { >- LOG(MediaSource, "MediaSource::MediaSource %p", this); > m_sourceBuffers = SourceBufferList::create(scriptExecutionContext()); > m_activeSourceBuffers = SourceBufferList::create(scriptExecutionContext()); > } > > MediaSource::~MediaSource() > { >- LOG(MediaSource, "MediaSource::~MediaSource %p", this); >+ ALWAYS_LOG(LOGIDENTIFIER); > ASSERT(isClosed()); > } > > void MediaSource::setPrivateAndOpen(Ref<MediaSourcePrivate>&& mediaSourcePrivate) > { >+ DEBUG_LOG(LOGIDENTIFIER); > ASSERT(!m_private); > ASSERT(m_mediaElement); > m_private = WTFMove(mediaSourcePrivate); >@@ -133,11 +146,13 @@ void MediaSource::setPrivateAndOpen(Ref<MediaSourcePrivate>&& mediaSourcePrivate > > void MediaSource::addedToRegistry() > { >+ DEBUG_LOG(LOGIDENTIFIER); > setPendingActivity(*this); > } > > void MediaSource::removedFromRegistry() > { >+ DEBUG_LOG(LOGIDENTIFIER); > unsetPendingActivity(*this); > } > >@@ -148,6 +163,7 @@ MediaTime MediaSource::duration() const > > void MediaSource::durationChanged(const MediaTime& duration) > { >+ ALWAYS_LOG(LOGIDENTIFIER, duration); > m_duration = duration; > } > >@@ -210,6 +226,8 @@ void MediaSource::seekToTime(const MediaTime& time) > if (isClosed()) > return; > >+ ALWAYS_LOG(LOGIDENTIFIER, time); >+ > // 2.4.3 Seeking > // https://rawgit.com/w3c/media-source/45627646344eea0170dd1cbc5a3d508ca751abb8/media-source-respec.html#mediasource-seeking > >@@ -227,7 +245,6 @@ void MediaSource::seekToTime(const MediaTime& time) > // 2. The media element waits until an appendBuffer() or an appendStream() call causes the coded > // frame processing algorithm to set the HTMLMediaElement.readyState attribute to a value greater > // than HAVE_METADATA. >- LOG(MediaSource, "MediaSource::seekToTime(%p) - waitForSeekCompleted()", this); > m_private->waitForSeekCompleted(); > return; > } >@@ -251,6 +268,8 @@ void MediaSource::completeSeek() > > ASSERT(m_pendingSeekTime.isValid()); > >+ ALWAYS_LOG(LOGIDENTIFIER, m_pendingSeekTime); >+ > // 2. The media element resets all decoders and initializes each one with data from the appropriate > // initialization segment. > // 3. The media element feeds coded frames from the active track buffers into the decoders starting >@@ -310,6 +329,8 @@ ExceptionOr<void> MediaSource::setLiveSeekableRange(double start, double end) > // W3C Editor's Draft 16 September 2016 > // https://rawgit.com/w3c/media-source/45627646344eea0170dd1cbc5a3d508ca751abb8/media-source-respec.html#dom-mediasource-setliveseekablerange > >+ ALWAYS_LOG(LOGIDENTIFIER, "start = ", start, ", end = ", end); >+ > // If the readyState attribute is not "open" then throw an InvalidStateError exception and abort these steps. > if (!isOpen()) > return Exception { InvalidStateError }; >@@ -330,6 +351,8 @@ ExceptionOr<void> MediaSource::clearLiveSeekableRange() > // W3C Editor's Draft 16 September 2016 > // https://rawgit.com/w3c/media-source/45627646344eea0170dd1cbc5a3d508ca751abb8/media-source-respec.html#dom-mediasource-clearliveseekablerange > >+ ALWAYS_LOG(LOGIDENTIFIER); >+ > // If the readyState attribute is not "open" then throw an InvalidStateError exception and abort these steps. > if (!isOpen()) > return Exception { InvalidStateError }; >@@ -475,6 +498,8 @@ ExceptionOr<void> MediaSource::setDuration(double duration) > // 2.1 Attributes - Duration > // https://www.w3.org/TR/2016/REC-media-source-20161117/#attributes > >+ ALWAYS_LOG(LOGIDENTIFIER, duration); >+ > // On setting, run the following steps: > // 1. If the value being set is negative or NaN then throw a TypeError exception and abort these steps. > if (duration < 0.0 || std::isnan(duration)) >@@ -527,9 +552,9 @@ ExceptionOr<void> MediaSource::setDurationInternal(const MediaTime& duration) > > // 5. Update duration to new duration. > m_duration = newDuration; >+ ALWAYS_LOG(LOGIDENTIFIER, duration); > > // 6. Update the media duration to new duration and run the HTMLMediaElement duration change algorithm. >- LOG(MediaSource, "MediaSource::setDurationInternal(%p) - duration(%s)", this, duration.toString().utf8().data()); > m_private->durationChanged(); > > return { }; >@@ -538,8 +563,6 @@ ExceptionOr<void> MediaSource::setDurationInternal(const MediaTime& duration) > void MediaSource::setReadyState(ReadyState state) > { > auto oldState = readyState(); >- LOG(MediaSource, "MediaSource::setReadyState(%p) : %s -> %s", this, MediaSourceInternal::toString(oldState), MediaSourceInternal::toString(state)); >- > if (oldState == state) > return; > >@@ -550,6 +573,8 @@ void MediaSource::setReadyState(ReadyState state) > > ExceptionOr<void> MediaSource::endOfStream(Optional<EndOfStreamError> error) > { >+ ALWAYS_LOG(LOGIDENTIFIER); >+ > // 2.2 https://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source.html#widl-MediaSource-endOfStream-void-EndOfStreamError-error > // 1. If the readyState attribute is not in the "open" state then throw an > // InvalidStateError exception and abort these steps. >@@ -569,7 +594,13 @@ ExceptionOr<void> MediaSource::endOfStream(Optional<EndOfStreamError> error) > > void MediaSource::streamEndedWithError(Optional<EndOfStreamError> error) > { >- LOG(MediaSource, "MediaSource::streamEndedWithError(%p)", this); >+#if !RELEASE_LOG_DISABLED >+ if (error) >+ ALWAYS_LOG(LOGIDENTIFIER, error.value()); >+ else >+ ALWAYS_LOG(LOGIDENTIFIER); >+#endif >+ > if (isClosed()) > return; > >@@ -632,7 +663,7 @@ void MediaSource::streamEndedWithError(Optional<EndOfStreamError> error) > > ExceptionOr<Ref<SourceBuffer>> MediaSource::addSourceBuffer(const String& type) > { >- LOG(MediaSource, "MediaSource::addSourceBuffer(%s) %p", type.ascii().data(), this); >+ DEBUG_LOG(LOGIDENTIFIER, type); > > // 2.2 http://www.w3.org/TR/media-source/#widl-MediaSource-addSourceBuffer-SourceBuffer-DOMString-type > // When this method is invoked, the user agent must run the following steps: >@@ -662,6 +693,7 @@ ExceptionOr<Ref<SourceBuffer>> MediaSource::addSourceBuffer(const String& type) > } > > auto buffer = SourceBuffer::create(sourceBufferPrivate.releaseReturnValue(), this); >+ DEBUG_LOG(LOGIDENTIFIER, "created SourceBuffer"); > > // 6. Set the generate timestamps flag on the new object to the value in the "Generate Timestamps Flag" > // column of the byte stream format registry [MSE-REGISTRY] entry that is associated with type. >@@ -686,7 +718,8 @@ ExceptionOr<Ref<SourceBuffer>> MediaSource::addSourceBuffer(const String& type) > > ExceptionOr<void> MediaSource::removeSourceBuffer(SourceBuffer& buffer) > { >- LOG(MediaSource, "MediaSource::removeSourceBuffer() %p", this); >+ DEBUG_LOG(LOGIDENTIFIER); >+ > Ref<SourceBuffer> protect(buffer); > > // 2. If sourceBuffer specifies an object that is not in sourceBuffers then >@@ -835,8 +868,6 @@ ExceptionOr<void> MediaSource::removeSourceBuffer(SourceBuffer& buffer) > > bool MediaSource::isTypeSupported(const String& type) > { >- LOG(MediaSource, "MediaSource::isTypeSupported(%s)", type.ascii().data()); >- > // Section 2.2 isTypeSupported() method steps. > // https://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source.html#widl-MediaSource-isTypeSupported-boolean-DOMString-type > // 1. If type is an empty string, then return false. >@@ -882,6 +913,8 @@ bool MediaSource::isEnded() const > > void MediaSource::detachFromElement(HTMLMediaElement& element) > { >+ ALWAYS_LOG(LOGIDENTIFIER); >+ > ASSERT_UNUSED(element, m_mediaElement == &element); > > // 2.4.2 Detaching from a media element >@@ -929,6 +962,8 @@ void MediaSource::openIfInEndedState() > if (m_readyState != ReadyState::Ended) > return; > >+ ALWAYS_LOG(LOGIDENTIFIER); >+ > setReadyState(ReadyState::Open); > m_private->unmarkEndOfStream(); > } >@@ -941,6 +976,8 @@ bool MediaSource::hasPendingActivity() const > > void MediaSource::suspend(ReasonForSuspension reason) > { >+ ALWAYS_LOG(LOGIDENTIFIER, static_cast<int>(reason)); >+ > switch (reason) { > case ReasonForSuspension::PageCache: > case ReasonForSuspension::PageWillBeSuspended: >@@ -955,11 +992,15 @@ void MediaSource::suspend(ReasonForSuspension reason) > > void MediaSource::resume() > { >+ ALWAYS_LOG(LOGIDENTIFIER); >+ > m_asyncEventQueue.resume(); > } > > void MediaSource::stop() > { >+ ALWAYS_LOG(LOGIDENTIFIER); >+ > m_asyncEventQueue.close(); > if (m_mediaElement) > m_mediaElement->detachMediaSource(); >@@ -979,6 +1020,8 @@ const char* MediaSource::activeDOMObjectName() const > > void MediaSource::onReadyStateChange(ReadyState oldState, ReadyState newState) > { >+ ALWAYS_LOG(LOGIDENTIFIER, "old state = ", oldState, ", new state = ", newState); >+ > for (auto& buffer : *m_sourceBuffers) > buffer->readyStateChanged(); > >@@ -1029,6 +1072,8 @@ ExceptionOr<Ref<SourceBufferPrivate>> MediaSource::createSourceBufferPrivate(con > > void MediaSource::scheduleEvent(const AtomicString& eventName) > { >+ DEBUG_LOG(LOGIDENTIFIER, "scheduling '", eventName, "'"); >+ > auto event = Event::create(eventName, Event::CanBubble::No, Event::IsCancelable::No); > event->setTarget(this); > >@@ -1062,6 +1107,19 @@ void MediaSource::regenerateActiveSourceBuffers() > sourceBuffer->setBufferedDirty(true); > } > >+#if !RELEASE_LOG_DISABLED >+void MediaSource::setLogIdentifier(const void* identifier) >+{ >+ m_logIdentifier = identifier; >+ ALWAYS_LOG(LOGIDENTIFIER); >+} >+ >+WTFLogChannel& MediaSource::logChannel() const >+{ >+ return LogMediaSource; >+} >+#endif >+ > } > > #endif >diff --git a/Source/WebCore/Modules/mediasource/MediaSource.h b/Source/WebCore/Modules/mediasource/MediaSource.h >index 24110fe61ce570ad27a9098087de4d7e6e425f5f..d296d0be9393a1629b1c18bbab0f0af9aa118c9e 100644 >--- a/Source/WebCore/Modules/mediasource/MediaSource.h >+++ b/Source/WebCore/Modules/mediasource/MediaSource.h >@@ -38,6 +38,7 @@ > #include "GenericEventQueue.h" > #include "MediaSourcePrivateClient.h" > #include "URLRegistry.h" >+#include <wtf/LoggerHelper.h> > > namespace WebCore { > >@@ -48,7 +49,15 @@ class SourceBufferList; > class SourceBufferPrivate; > class TimeRanges; > >-class MediaSource final : public MediaSourcePrivateClient, public ActiveDOMObject, public EventTargetWithInlineData, public URLRegistrable { >+class MediaSource final >+ : public MediaSourcePrivateClient >+ , public ActiveDOMObject >+ , public EventTargetWithInlineData >+ , public URLRegistrable >+#if !RELEASE_LOG_DISABLED >+ , private LoggerHelper >+#endif >+{ > public: > static void setRegistry(URLRegistry*); > static MediaSource* lookup(const String& url) { return s_registry ? static_cast<MediaSource*>(s_registry->lookup(url)) : nullptr; } >@@ -105,6 +114,14 @@ public: > static const MediaTime& currentTimeFudgeFactor(); > static bool contentTypeShouldGenerateTimestamps(const ContentType&); > >+#if !RELEASE_LOG_DISABLED >+ const Logger& logger() const final { return m_logger.get(); } >+ const void* logIdentifier() const final { return m_logIdentifier; } >+ const char* logClassName() const final { return "MediaSource"; } >+ WTFLogChannel& logChannel() const final; >+ void setLogIdentifier(const void*) final; >+#endif >+ > private: > explicit MediaSource(ScriptExecutionContext&); > >@@ -151,8 +168,38 @@ private: > MediaTime m_pendingSeekTime; > ReadyState m_readyState { ReadyState::Closed }; > GenericEventQueue m_asyncEventQueue; >+#if !RELEASE_LOG_DISABLED >+ Ref<const Logger> m_logger; >+ const void* m_logIdentifier { nullptr }; >+#endif >+}; >+ >+String convertEnumerationToString(MediaSource::EndOfStreamError); >+String convertEnumerationToString(MediaSource::ReadyState); >+ >+} // namespace WebCore >+ >+namespace WTF { >+ >+template<typename Type> >+struct LogArgument; >+ >+template <> >+struct LogArgument<WebCore::MediaSource::EndOfStreamError> { >+ static String toString(const WebCore::MediaSource::EndOfStreamError error) >+ { >+ return convertEnumerationToString(error); >+ } >+}; >+ >+template <> >+struct LogArgument<WebCore::MediaSource::ReadyState> { >+ static String toString(const WebCore::MediaSource::ReadyState state) >+ { >+ return convertEnumerationToString(state); >+ } > }; > >-} >+} // namespace WTF > > #endif >diff --git a/Source/WebCore/Modules/mediasource/SourceBuffer.cpp b/Source/WebCore/Modules/mediasource/SourceBuffer.cpp >index 96686a081360a5aff900ac83d46bd0b879e5923a..c042a5c01430066e7edd8da2e9cc85ea5474e655 100644 >--- a/Source/WebCore/Modules/mediasource/SourceBuffer.cpp >+++ b/Source/WebCore/Modules/mediasource/SourceBuffer.cpp >@@ -1,6 +1,6 @@ > /* > * Copyright (C) 2013 Google Inc. All rights reserved. >- * Copyright (C) 2013-2017 Apple Inc. All rights reserved. >+ * Copyright (C) 2013-2019 Apple Inc. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions are >@@ -114,8 +114,13 @@ SourceBuffer::SourceBuffer(Ref<SourceBufferPrivate>&& sourceBufferPrivate, Media > , m_pendingRemoveStart(MediaTime::invalidTime()) > , m_pendingRemoveEnd(MediaTime::invalidTime()) > , m_removeTimer(*this, &SourceBuffer::removeTimerFired) >+#if !RELEASE_LOG_DISABLED >+ , m_logger(m_private->sourceBufferLogger()) >+ , m_logIdentifier(m_private->sourceBufferLogIdentifier()) >+#endif > { > ASSERT(m_source); >+ ALWAYS_LOG(LOGIDENTIFIER); > > m_private->setClient(this); > } >@@ -123,6 +128,7 @@ SourceBuffer::SourceBuffer(Ref<SourceBufferPrivate>&& sourceBufferPrivate, Media > SourceBuffer::~SourceBuffer() > { > ASSERT(isRemoved()); >+ ALWAYS_LOG(LOGIDENTIFIER); > > m_private->setClient(nullptr); > } >@@ -307,7 +313,7 @@ ExceptionOr<void> SourceBuffer::remove(double start, double end) > > ExceptionOr<void> SourceBuffer::remove(const MediaTime& start, const MediaTime& end) > { >- LOG(MediaSource, "SourceBuffer::remove(%p) - start(%lf), end(%lf)", this, start.toDouble(), end.toDouble()); >+ DEBUG_LOG(LOGIDENTIFIER, "start = ", start, ", end = ", end); > > // https://rawgit.com/w3c/media-source/45627646344eea0170dd1cbc5a3d508ca751abb8/media-source-respec.html#dom-sourcebuffer-remove > // Section 3.2 remove() method steps. >@@ -468,7 +474,7 @@ void SourceBuffer::removedFromMediaSource() > > void SourceBuffer::seekToTime(const MediaTime& time) > { >- LOG(MediaSource, "SourceBuffer::seekToTime(%p) - time(%s)", this, toString(time).utf8().data()); >+ ALWAYS_LOG(LOGIDENTIFIER, time); > > for (auto& trackBufferPair : m_trackBufferMap) { > TrackBuffer& trackBuffer = trackBufferPair.value; >@@ -596,7 +602,7 @@ ExceptionOr<void> SourceBuffer::appendBufferInternal(const unsigned char* data, > #if USE(GSTREAMER) > // 5. If the buffer full flag equals true, then throw a QuotaExceededError exception and abort these step. > if (m_bufferFull) { >- LOG(MediaSource, "SourceBuffer::appendBufferInternal(%p) - buffer full, failing with QuotaExceededError error", this); >+ ERROR_LOG(LOGIDENTIFIER, "buffer full, failing with QuotaExceededError error"); > return Exception { QuotaExceededError }; > } > #endif >@@ -664,7 +670,7 @@ void SourceBuffer::sourceBufferPrivateAppendComplete(AppendResult result) > // 2. If the input buffer contains bytes that violate the SourceBuffer byte stream format specification, > // then run the append error algorithm with the decode error parameter set to true and abort this algorithm. > if (result == ParsingFailed) { >- LOG(MediaSource, "SourceBuffer::sourceBufferPrivateAppendComplete(%p) - result = ParsingFailed", this); >+ ERROR_LOG(LOGIDENTIFIER, "ParsingFailed"); > appendError(true); > return; > } >@@ -697,7 +703,7 @@ void SourceBuffer::sourceBufferPrivateAppendComplete(AppendResult result) > const AtomicString& trackID = trackBufferPair.key; > > if (trackBuffer.needsReenqueueing) { >- LOG(MediaSource, "SourceBuffer::sourceBufferPrivateAppendComplete(%p) - reenqueuing at time (%s)", this, toString(currentMediaTime).utf8().data()); >+ DEBUG_LOG(LOGIDENTIFIER, "reenqueuing at time ", currentMediaTime); > reenqueueMediaForTime(trackBuffer, trackID, currentMediaTime); > } else > provideMediaData(trackBuffer, trackID); >@@ -707,7 +713,7 @@ void SourceBuffer::sourceBufferPrivateAppendComplete(AppendResult result) > if (extraMemoryCost() > this->maximumBufferSize()) > m_bufferFull = true; > >- LOG(Media, "SourceBuffer::sourceBufferPrivateAppendComplete(%p) - buffered = %s", this, toString(m_buffered->ranges()).utf8().data()); >+ DEBUG_LOG(LOGIDENTIFIER); > } > > void SourceBuffer::sourceBufferPrivateDidReceiveRenderingError(int error) >@@ -716,7 +722,7 @@ void SourceBuffer::sourceBufferPrivateDidReceiveRenderingError(int error) > UNUSED_PARAM(error); > #endif > >- LOG(MediaSource, "SourceBuffer::sourceBufferPrivateDidReceiveRenderingError(%p) - result = %i", this, error); >+ ERROR_LOG(LOGIDENTIFIER, error); > > if (!isRemoved()) > m_source->streamEndedWithError(MediaSource::EndOfStreamError::Decode); >@@ -733,6 +739,9 @@ static PlatformTimeRanges removeSamplesFromTrackBuffer(const DecodeOrderSampleMa > MediaTime earliestSample = MediaTime::positiveInfiniteTime(); > MediaTime latestSample = MediaTime::zeroTime(); > size_t bytesRemoved = 0; >+ auto logIdentifier = WTF::Logger::LogSiteIdentifier(buffer->logClassName(), logPrefix, buffer->logIdentifier()); >+ auto& logger = buffer->logger(); >+ auto willLog = logger.willLog(buffer->logChannel(), WTFLogLevelDebug); > #else > UNUSED_PARAM(logPrefix); > UNUSED_PARAM(buffer); >@@ -746,7 +755,11 @@ static PlatformTimeRanges removeSamplesFromTrackBuffer(const DecodeOrderSampleMa > #endif > > const RefPtr<MediaSample>& sample = sampleIt.second; >- LOG(MediaSource, "SourceBuffer::%s(%p) - removing sample(%s)", logPrefix, buffer, toString(*sampleIt.second).utf8().data()); >+ >+#if !LOG_DISABLED >+ if (willLog) >+ logger.debug(buffer->logChannel(), logIdentifier, "removing sample ", *sampleIt.second); >+#endif > > // Remove the erased samples from the TrackBuffer sample map. > trackBuffer.samples.removeSample(sample.get()); >@@ -796,8 +809,8 @@ static PlatformTimeRanges removeSamplesFromTrackBuffer(const DecodeOrderSampleMa > erasedRanges.unionWith(additionalErasedRanges); > > #if !LOG_DISABLED >- if (bytesRemoved) >- LOG(MediaSource, "SourceBuffer::%s(%p) removed %zu bytes, start(%lf), end(%lf)", logPrefix, buffer, bytesRemoved, earliestSample.toDouble(), latestSample.toDouble()); >+ if (bytesRemoved && willLog) >+ logger.debug(buffer->logChannel(), logIdentifier, "removed ", bytesRemoved, ", start = ", earliestSample, ", end = ", latestSample); > #endif > > return erasedRanges; >@@ -805,7 +818,7 @@ static PlatformTimeRanges removeSamplesFromTrackBuffer(const DecodeOrderSampleMa > > void SourceBuffer::removeCodedFrames(const MediaTime& start, const MediaTime& end) > { >- LOG(MediaSource, "SourceBuffer::removeCodedFrames(%p) - start(%s), end(%s)", this, toString(start).utf8().data(), toString(end).utf8().data()); >+ DEBUG_LOG(LOGIDENTIFIER, "start = ", start, ", end = ", end); > > // 3.5.9 Coded Frame Removal Algorithm > // https://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source.html#sourcebuffer-coded-frame-removal >@@ -835,10 +848,7 @@ void SourceBuffer::removeCodedFrames(const MediaTime& start, const MediaTime& en > std::pair<RefPtr<MediaSample>, RefPtr<MediaSample>> replacementSamples = sample->divide(time); > if (!replacementSamples.first || !replacementSamples.second) > return; >- LOG(MediaSource, "SourceBuffer::removeCodedFrames(%p) - splitting sample (%s) into\n\t(%s)\n\t(%s)", this, >- toString(sample).utf8().data(), >- toString(replacementSamples.first).utf8().data(), >- toString(replacementSamples.second).utf8().data()); >+ DEBUG_LOG(LOGIDENTIFIER, "splitting sample ", *sample, " into ", *replacementSamples.first, " and ", *replacementSamples.second); > trackBuffer.samples.removeSample(sample.get()); > trackBuffer.samples.addSample(*replacementSamples.first); > trackBuffer.samples.addSample(*replacementSamples.second); >@@ -947,7 +957,7 @@ void SourceBuffer::evictCodedFrames(size_t newDataSize) > MediaTime maximumRangeEnd = currentTime - thirtySeconds; > > #if !LOG_DISABLED >- LOG(MediaSource, "SourceBuffer::evictCodedFrames(%p) - currentTime = %lf, require %zu bytes, maximum buffer size is %zu", this, m_source->currentTime().toDouble(), extraMemoryCost() + newDataSize, maximumBufferSize); >+ DEBUG_LOG(LOGIDENTIFIER, "currentTime = ", m_source->currentTime(), ", require ", extraMemoryCost() + newDataSize, " bytes, maximum buffer size is ", maximumBufferSize); > size_t initialBufferedSize = extraMemoryCost(); > #endif > >@@ -966,10 +976,12 @@ void SourceBuffer::evictCodedFrames(size_t newDataSize) > rangeEnd += thirtySeconds; > } > >+#if !LOG_DISABLED > if (!m_bufferFull) { >- LOG(MediaSource, "SourceBuffer::evictCodedFrames(%p) - evicted %zu bytes", this, initialBufferedSize - extraMemoryCost()); >+ DEBUG_LOG(LOGIDENTIFIER, "evicted ", initialBufferedSize - extraMemoryCost()); > return; > } >+#endif > > // If there still isn't enough free space and there buffers in time ranges after the current range (ie. there is a gap after > // the current buffered range), delete 30 seconds at a time from duration back to the current time range or 30 seconds after >@@ -977,7 +989,9 @@ void SourceBuffer::evictCodedFrames(size_t newDataSize) > auto buffered = m_buffered->ranges(); > size_t currentTimeRange = buffered.find(currentTime); > if (currentTimeRange == notFound || currentTimeRange == buffered.length() - 1) { >- LOG(MediaSource, "SourceBuffer::evictCodedFrames(%p) - evicted %zu bytes but FAILED to free enough", this, initialBufferedSize - extraMemoryCost()); >+#if !LOG_DISABLED >+ ERROR_LOG(LOGIDENTIFIER, "evicted ", initialBufferedSize - extraMemoryCost(), " bytes but FAILED to free enough"); >+#endif > return; > } > >@@ -1009,7 +1023,12 @@ void SourceBuffer::evictCodedFrames(size_t newDataSize) > rangeEnd -= thirtySeconds; > } > >- LOG(MediaSource, "SourceBuffer::evictCodedFrames(%p) - evicted %zu bytes%s", this, initialBufferedSize - extraMemoryCost(), m_bufferFull ? "" : " but FAILED to free enough"); >+#if !LOG_DISABLED >+ if (m_bufferFull) >+ ERROR_LOG(LOGIDENTIFIER, "evicted ", initialBufferedSize - extraMemoryCost(), " but FAILED to free enough"); >+ else >+ DEBUG_LOG(LOGIDENTIFIER, "evicted ", initialBufferedSize - extraMemoryCost()); >+#endif > } > > size_t SourceBuffer::maximumBufferSize() const >@@ -1061,7 +1080,7 @@ void SourceBuffer::sourceBufferPrivateDidReceiveInitializationSegment(const Init > if (isRemoved()) > return; > >- LOG(MediaSource, "SourceBuffer::sourceBufferPrivateDidReceiveInitializationSegment(%p)", this); >+ ALWAYS_LOG(LOGIDENTIFIER); > > // 3.5.8 Initialization Segment Received (ctd) > // https://rawgit.com/w3c/media-source/c3ad59c7a370d04430969ba73d18dc9bcde57a33/index.html#sourcebuffer-init-segment-received [Editor's Draft 09 January 2015] >@@ -1566,7 +1585,7 @@ void SourceBuffer::sourceBufferPrivateDidReceiveSample(MediaSample& sample) > sample.offsetTimestampsBy(trackBuffer.roundedTimestampOffset); > } > >- LOG(MediaSourceSamples, "SourceBuffer::sourceBufferPrivateDidReceiveSample(%p) - sample(%s)", this, toString(sample).utf8().data()); >+ DEBUG_LOG(LOGIDENTIFIER, sample); > > // 1.7 Let frame end timestamp equal the sum of presentation timestamp and frame duration. > MediaTime frameEndTimestamp = presentationTimestamp + frameDuration; >@@ -1590,7 +1609,7 @@ void SourceBuffer::sourceBufferPrivateDidReceiveSample(MediaSample& sample) > // the presentation timestamp. > MediaTime presentationStartTime = MediaTime::zeroTime(); > if (presentationTimestamp < presentationStartTime) { >- LOG(MediaSource, "SourceBuffer::sourceBufferPrivateDidReceiveSample(%p) - failing because presentationTimestamp < presentationStartTime", this); >+ ERROR_LOG(LOGIDENTIFIER, "failing because presentationTimestamp (", presentationTimestamp, ") < presentationStartTime (", presentationStartTime, ")"); > m_source->streamEndedWithError(MediaSource::EndOfStreamError::Decode); > return; > } >@@ -1953,7 +1972,7 @@ void SourceBuffer::sourceBufferPrivateReenqueSamples(const AtomicString& trackID > if (isRemoved()) > return; > >- LOG(MediaSource, "SourceBuffer::sourceBufferPrivateReenqueSamples(%p)", this); >+ DEBUG_LOG(LOGIDENTIFIER); > auto it = m_trackBufferMap.find(trackID); > if (it == m_trackBufferMap.end()) > return; >@@ -1968,7 +1987,7 @@ void SourceBuffer::sourceBufferPrivateDidBecomeReadyForMoreSamples(const AtomicS > if (isRemoved()) > return; > >- LOG(MediaSource, "SourceBuffer::sourceBufferPrivateDidBecomeReadyForMoreSamples(%p)", this); >+ DEBUG_LOG(LOGIDENTIFIER); > auto it = m_trackBufferMap.find(trackID); > if (it == m_trackBufferMap.end()) > return; >@@ -2023,7 +2042,9 @@ void SourceBuffer::provideMediaData(TrackBuffer& trackBuffer, const AtomicString > #endif > } > >- LOG(MediaSource, "SourceBuffer::provideMediaData(%p) - Enqueued %u samples, %zu remaining", this, enqueuedSamples, static_cast<size_t>(trackBuffer.decodeQueue.size())); >+#if !LOG_DISABLED >+ DEBUG_LOG(LOGIDENTIFIER, "Enqueued ", enqueuedSamples, " samples, ", static_cast<size_t>(trackBuffer.decodeQueue.size()), " remaining"); >+#endif > > trySignalAllSamplesInTrackEnqueued(trackID); > } >@@ -2031,7 +2052,7 @@ void SourceBuffer::provideMediaData(TrackBuffer& trackBuffer, const AtomicString > void SourceBuffer::trySignalAllSamplesInTrackEnqueued(const AtomicString& trackID) > { > if (m_source->isEnded() && m_trackBufferMap.get(trackID).decodeQueue.empty()) { >- LOG(MediaSource, "SourceBuffer::trySignalAllSamplesInTrackEnqueued(%p) - All samples in track \"%s\" enqueued.", this, trackID.string().utf8().data()); >+ DEBUG_LOG(LOGIDENTIFIER, "All samples in track ", trackID, " enqueued"); > m_private->allSamplesInTrackEnqueued(trackID); > } > } >@@ -2113,7 +2134,7 @@ void SourceBuffer::monitorBufferingRate() > > m_averageBufferRate += (interval.seconds() * ExponentialMovingAverageCoefficient) * (rateSinceLastMonitor - m_averageBufferRate); > >- LOG(MediaSource, "SourceBuffer::monitorBufferingRate(%p) - m_avegareBufferRate: %lf", this, m_averageBufferRate); >+ DEBUG_LOG(LOGIDENTIFIER, m_averageBufferRate); > } > > void SourceBuffer::updateBufferedFromTrackBuffers() >@@ -2275,6 +2296,13 @@ ExceptionOr<void> SourceBuffer::setMode(AppendMode newMode) > return { }; > } > >+#if !RELEASE_LOG_DISABLED >+WTFLogChannel& SourceBuffer::logChannel() const >+{ >+ return LogMediaSource; >+} >+#endif >+ > } // namespace WebCore > > #endif >diff --git a/Source/WebCore/Modules/mediasource/SourceBuffer.h b/Source/WebCore/Modules/mediasource/SourceBuffer.h >index aae7a7d36de80e73f2ef094d516018d043be258d..edf145a129336ca254e97c0bf0807a098b72db72 100644 >--- a/Source/WebCore/Modules/mediasource/SourceBuffer.h >+++ b/Source/WebCore/Modules/mediasource/SourceBuffer.h >@@ -42,6 +42,7 @@ > #include "TextTrack.h" > #include "Timer.h" > #include "VideoTrack.h" >+#include <wtf/LoggerHelper.h> > > namespace WebCore { > >@@ -54,7 +55,18 @@ class TextTrackList; > class TimeRanges; > class VideoTrackList; > >-class SourceBuffer final : public RefCounted<SourceBuffer>, public ActiveDOMObject, public EventTargetWithInlineData, private SourceBufferPrivateClient, private AudioTrackClient, private VideoTrackClient, private TextTrackClient { >+class SourceBuffer final >+ : public RefCounted<SourceBuffer> >+ , public ActiveDOMObject >+ , public EventTargetWithInlineData >+ , private SourceBufferPrivateClient >+ , private AudioTrackClient >+ , private VideoTrackClient >+ , private TextTrackClient >+#if !RELEASE_LOG_DISABLED >+ , private LoggerHelper >+#endif >+{ > public: > static Ref<SourceBuffer> create(Ref<SourceBufferPrivate>&&, MediaSource*); > virtual ~SourceBuffer(); >@@ -118,6 +130,13 @@ public: > > void trySignalAllSamplesEnqueued(); > >+#if !RELEASE_LOG_DISABLED >+ const Logger& logger() const final { return m_logger.get(); } >+ const void* logIdentifier() const final { return m_logIdentifier; } >+ const char* logClassName() const final { return "SourceBuffer"; } >+ WTFLogChannel& logChannel() const final; >+#endif >+ > private: > SourceBuffer(Ref<SourceBufferPrivate>&&, MediaSource*); > >@@ -231,6 +250,11 @@ private: > MediaTime m_pendingRemoveEnd; > Timer m_removeTimer; > >+#if !RELEASE_LOG_DISABLED >+ Ref<const Logger> m_logger; >+ const void* m_logIdentifier; >+#endif >+ > bool m_updating { false }; > bool m_receivedFirstInitializationSegment { false }; > bool m_active { false }; >diff --git a/Source/WebCore/dom/Document.cpp b/Source/WebCore/dom/Document.cpp >index 31f442bf75292b1c30bbf9ad2c2a234e8fd1b00d..050555ba9491f47ca0bb4dfdaaa193d9ac54edf9 100644 >--- a/Source/WebCore/dom/Document.cpp >+++ b/Source/WebCore/dom/Document.cpp >@@ -8569,7 +8569,6 @@ static MessageSource messageSourceForWTFLogChannel(const WTFLogChannel& channel) > if (equalIgnoringASCIICase(webrtcChannel, channel.name)) > return MessageSource::WebRTC; > >- ASSERT_NOT_REACHED(); > return MessageSource::Other; > } > >@@ -8603,11 +8602,14 @@ void Document::didLogMessage(const WTFLogChannel& channel, WTFLogLevel level, Ve > > ASSERT(sessionID().isAlwaysOnLoggingAllowed()); > >- m_logMessageTaskQueue.enqueueTask([this, channel, level, logMessages = WTFMove(logMessages)]() mutable { >+ auto messageSource = messageSourceForWTFLogChannel(channel); >+ if (messageSource == MessageSource::Other) >+ return; >+ >+ m_logMessageTaskQueue.enqueueTask([this, level, messageSource, logMessages = WTFMove(logMessages)]() mutable { > if (!page()) > return; > >- auto messageSource = messageSourceForWTFLogChannel(channel); > auto messageLevel = messageLevelFromWTFLogLevel(level); > auto message = std::make_unique<Inspector::ConsoleMessage>(messageSource, MessageType::Log, messageLevel, WTFMove(logMessages), mainWorldExecState(frame())); > >diff --git a/Source/WebCore/html/HTMLMediaElement.cpp b/Source/WebCore/html/HTMLMediaElement.cpp >index 86c30fb8ac444d450f0683fd96542f10f8932f9a..ab1ebd803c0614170584f4027f3be30ad860603f 100644 >--- a/Source/WebCore/html/HTMLMediaElement.cpp >+++ b/Source/WebCore/html/HTMLMediaElement.cpp >@@ -228,11 +228,11 @@ String convertEnumerationToString(HTMLMediaElement::ReadyState enumerationValue) > MAKE_STATIC_STRING_IMPL("HAVE_FUTURE_DATA"), > MAKE_STATIC_STRING_IMPL("HAVE_ENOUGH_DATA"), > }; >- static_assert(static_cast<size_t>(HTMLMediaElementEnums::HAVE_NOTHING) == 0, "HTMLMediaElement::HAVE_NOTHING is not 0 as expected"); >- static_assert(static_cast<size_t>(HTMLMediaElementEnums::HAVE_METADATA) == 1, "HTMLMediaElement::HAVE_METADATA is not 1 as expected"); >- static_assert(static_cast<size_t>(HTMLMediaElementEnums::HAVE_CURRENT_DATA) == 2, "HTMLMediaElement::HAVE_CURRENT_DATA is not 2 as expected"); >- static_assert(static_cast<size_t>(HTMLMediaElementEnums::HAVE_FUTURE_DATA) == 3, "HTMLMediaElement::HAVE_FUTURE_DATA is not 3 as expected"); >- static_assert(static_cast<size_t>(HTMLMediaElementEnums::HAVE_ENOUGH_DATA) == 4, "HTMLMediaElement::HAVE_ENOUGH_DATA is not 4 as expected"); >+ static_assert(static_cast<size_t>(HTMLMediaElementEnums::HAVE_NOTHING) == 0, "HTMLMediaElementEnums::HAVE_NOTHING is not 0 as expected"); >+ static_assert(static_cast<size_t>(HTMLMediaElementEnums::HAVE_METADATA) == 1, "HTMLMediaElementEnums::HAVE_METADATA is not 1 as expected"); >+ static_assert(static_cast<size_t>(HTMLMediaElementEnums::HAVE_CURRENT_DATA) == 2, "HTMLMediaElementEnums::HAVE_CURRENT_DATA is not 2 as expected"); >+ static_assert(static_cast<size_t>(HTMLMediaElementEnums::HAVE_FUTURE_DATA) == 3, "HTMLMediaElementEnums::HAVE_FUTURE_DATA is not 3 as expected"); >+ static_assert(static_cast<size_t>(HTMLMediaElementEnums::HAVE_ENOUGH_DATA) == 4, "HTMLMediaElementEnums::HAVE_ENOUGH_DATA is not 4 as expected"); > ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values)); > return values[static_cast<size_t>(enumerationValue)]; > } >@@ -1097,7 +1097,7 @@ void HTMLMediaElement::scheduleCheckPlaybackTargetCompatability() > ALWAYS_LOG(logSiteIdentifier, "task scheduled"); > m_checkPlaybackTargetCompatablityTask.scheduleTask([this, logSiteIdentifier] { > UNUSED_PARAM(logSiteIdentifier); >- ALWAYS_LOG(logSiteIdentifier, "- lambda(), task fired"); >+ ALWAYS_LOG(logSiteIdentifier, "lambda(), task fired"); > checkPlaybackTargetCompatablity(); > }); > } >@@ -1350,7 +1350,13 @@ void HTMLMediaElement::selectMediaResource() > // put into the background. > m_mediaSession->removeBehaviorRestriction(MediaElementSession::RequirePageConsentToLoadMedia); > >- m_resourceSelectionTaskQueue.enqueueTask([this] { >+ auto logSiteIdentifier = LOGIDENTIFIER; >+ UNUSED_PARAM(logSiteIdentifier); >+ >+ m_resourceSelectionTaskQueue.enqueueTask([this, logSiteIdentifier] { >+ >+ ALWAYS_LOG(logSiteIdentifier, "lambda(), task fired"); >+ > // 5. If the media element’s blocked-on-parser flag is false, then populate the list of pending text tracks. > #if ENABLE(VIDEO_TRACK) > if (hasMediaControls()) >@@ -1380,7 +1386,7 @@ void HTMLMediaElement::selectMediaResource() > mode = Attribute; > ASSERT(m_player); > if (!m_player) { >- ERROR_LOG(LOGIDENTIFIER, " - has srcAttr but m_player is not created"); >+ ERROR_LOG(logSiteIdentifier, " has srcAttr but m_player is not created"); > return; > } > } else if (auto firstSource = childrenOfType<HTMLSourceElement>(*this).first()) { >@@ -1397,7 +1403,7 @@ void HTMLMediaElement::selectMediaResource() > setShouldDelayLoadEvent(false); > m_networkState = NETWORK_EMPTY; > >- ALWAYS_LOG(LOGIDENTIFIER, "nothing to load"); >+ ALWAYS_LOG(logSiteIdentifier, "nothing to load"); > return; > } > >@@ -1427,7 +1433,7 @@ void HTMLMediaElement::selectMediaResource() > > ContentType contentType; > loadResource(URL(), contentType, String()); >- ALWAYS_LOG(LOGIDENTIFIER, "using 'srcObject' property"); >+ ALWAYS_LOG(logSiteIdentifier, "using 'srcObject' property"); > > // If that algorithm returns without aborting this one, then the load failed. > // 4. Failed with media provider: Reaching this step indicates that the media resource >@@ -1450,7 +1456,7 @@ void HTMLMediaElement::selectMediaResource() > URL absoluteURL = getNonEmptyURLAttribute(srcAttr); > if (absoluteURL.isEmpty()) { > mediaLoadingFailed(MediaPlayer::FormatError); >- ALWAYS_LOG(LOGIDENTIFIER, "empty 'src'"); >+ ALWAYS_LOG(logSiteIdentifier, "empty 'src'"); > return; > } > >@@ -1471,7 +1477,7 @@ void HTMLMediaElement::selectMediaResource() > // will have to pick a media engine based on the file extension. > ContentType contentType; > loadResource(absoluteURL, contentType, String()); >- ALWAYS_LOG(LOGIDENTIFIER, "using 'src' attribute url"); >+ ALWAYS_LOG(logSiteIdentifier, "using 'src' attribute url"); > > // 6. Failed with attribute: Reaching this step indicates that the media resource failed to load > // or that the given URL could not be resolved. Queue a task to run the dedicated media source failure steps. >@@ -1593,6 +1599,8 @@ void HTMLMediaElement::loadResource(const URL& initialURL, ContentType& contentT > > if (m_mediaSource) { > loadAttempted = true; >+ >+ ALWAYS_LOG(LOGIDENTIFIER, "loading MSE blob"); > if (!m_mediaSource->attachToElement(*this) || !m_player->load(url, contentType, m_mediaSource.get())) { > // Forget our reference to the MediaSource, so we leave it alone > // while processing remainder of load failure. >@@ -1609,6 +1617,7 @@ void HTMLMediaElement::loadResource(const URL& initialURL, ContentType& contentT > > if (m_mediaStreamSrcObject) { > loadAttempted = true; >+ ALWAYS_LOG(LOGIDENTIFIER, "loading media stream blob"); > if (!m_player->load(m_mediaStreamSrcObject->privateStream())) > mediaLoadingFailed(MediaPlayer::FormatError); > } >@@ -1617,6 +1626,7 @@ void HTMLMediaElement::loadResource(const URL& initialURL, ContentType& contentT > > if (!loadAttempted && m_blob) { > loadAttempted = true; >+ ALWAYS_LOG(LOGIDENTIFIER, "loading generic blob"); > if (!m_player->load(m_blob->url(), contentType, keySystem)) > mediaLoadingFailed(MediaPlayer::FormatError); > } >@@ -1773,7 +1783,7 @@ void HTMLMediaElement::updateActiveTextTrackCues(const MediaTime& movieTime) > return; > > auto currentMediaTime = weakThis->currentMediaTime(); >- INFO_LOG(LOGIDENTIFIER, " - lambda, currentMediaTime:", currentMediaTime); >+ INFO_LOG(LOGIDENTIFIER, " lambda, currentMediaTime:", currentMediaTime); > weakThis->updateActiveTextTrackCues(currentMediaTime); > }, nextInterestingTime); > } >@@ -4526,7 +4536,7 @@ void HTMLMediaElement::scheduleConfigureTextTracks() > ALWAYS_LOG(logSiteIdentifier, "task scheduled"); > m_configureTextTracksTask.scheduleTask([this, logSiteIdentifier] { > UNUSED_PARAM(logSiteIdentifier); >- ALWAYS_LOG(logSiteIdentifier, "- lambda(), task fired"); >+ ALWAYS_LOG(logSiteIdentifier, "lambda(), task fired"); > Ref<HTMLMediaElement> protectedThis(*this); // configureTextTracks calls methods that can trigger arbitrary DOM mutations. > configureTextTracks(); > }); >@@ -5080,7 +5090,7 @@ void HTMLMediaElement::scheduleMediaEngineWasUpdated() > ALWAYS_LOG(logSiteIdentifier, "task scheduled"); > m_mediaEngineUpdatedTask.scheduleTask([this, logSiteIdentifier] { > UNUSED_PARAM(logSiteIdentifier); >- ALWAYS_LOG(logSiteIdentifier, "- lambda(), task fired"); >+ ALWAYS_LOG(logSiteIdentifier, "lambda(), task fired"); > Ref<HTMLMediaElement> protectedThis(*this); // mediaEngineWasUpdated calls methods that can trigger arbitrary DOM mutations. > mediaEngineWasUpdated(); > }); >@@ -5378,7 +5388,7 @@ void HTMLMediaElement::scheduleUpdatePlayState() > ALWAYS_LOG(logSiteIdentifier, "task scheduled"); > m_updatePlayStateTask.scheduleTask([this, logSiteIdentifier] { > UNUSED_PARAM(logSiteIdentifier); >- ALWAYS_LOG(logSiteIdentifier, "- lambda(), task fired"); >+ ALWAYS_LOG(logSiteIdentifier, "lambda(), task fired"); > Ref<HTMLMediaElement> protectedThis(*this); // updatePlayState calls methods that can trigger arbitrary DOM mutations. > updatePlayState(); > }); >@@ -7704,7 +7714,7 @@ void HTMLMediaElement::scheduleUpdateMediaState() > ALWAYS_LOG(logSiteIdentifier, "task scheduled"); > m_updateMediaStateTask.scheduleTask([this, logSiteIdentifier] { > UNUSED_PARAM(logSiteIdentifier); >- ALWAYS_LOG(logSiteIdentifier, "- lambda(), task fired"); >+ ALWAYS_LOG(logSiteIdentifier, "lambda(), task fired"); > Ref<HTMLMediaElement> protectedThis(*this); // updateMediaState calls methods that can trigger arbitrary DOM mutations. > updateMediaState(); > }); >diff --git a/Source/WebCore/platform/ContentType.cpp b/Source/WebCore/platform/ContentType.cpp >index 7ca8be5dc809da6ef8b928c8a6fe8de96f2eb1d2..f0d2c10b88f2087ebdabf157bc81b65c58081389 100644 >--- a/Source/WebCore/platform/ContentType.cpp >+++ b/Source/WebCore/platform/ContentType.cpp >@@ -28,6 +28,7 @@ > #include "config.h" > #include "ContentType.h" > #include "HTMLParserIdioms.h" >+#include <wtf/JSONValues.h> > #include <wtf/NeverDestroyed.h> > > namespace WebCore { >@@ -113,4 +114,21 @@ Vector<String> ContentType::profiles() const > return splitParameters(parameter(profilesParameter())); > } > >+String ContentType::toJSONString() const >+{ >+ auto object = JSON::Object::create(); >+ >+ object->setString("containerType"_s, containerType()); >+ >+ auto codecs = codecsParameter(); >+ if (!codecs.isEmpty()) >+ object->setString("codecs"_s, codecs); >+ >+ auto profiles = profilesParameter(); >+ if (!profiles.isEmpty()) >+ object->setString("profiles"_s, profiles); >+ >+ return object->toJSONString(); >+} >+ > } // namespace WebCore >diff --git a/Source/WebCore/platform/ContentType.h b/Source/WebCore/platform/ContentType.h >index 07a92b65e9915e06265d201dc941b5774982419f..c82b5b7197c9e15d1e2f547fd5641fc5f4ec5ecf 100644 >--- a/Source/WebCore/platform/ContentType.h >+++ b/Source/WebCore/platform/ContentType.h >@@ -46,10 +46,26 @@ public: > Vector<String> profiles() const; > const String& raw() const { return m_type; } > bool isEmpty() const { return m_type.isEmpty(); } >+ >+ String toJSONString() const; >+ > private: > String m_type; > }; > > } // namespace WebCore > >+namespace WTF { >+template<typename Type> struct LogArgument; >+ >+template <> >+struct LogArgument<WebCore::ContentType> { >+ static String toString(const WebCore::ContentType& type) >+ { >+ return type.toJSONString(); >+ } >+}; >+ >+} // namespace WTF >+ > #endif // ContentType_h >diff --git a/Source/WebCore/platform/MediaSample.h b/Source/WebCore/platform/MediaSample.h >index 751665621acd25a2dfb2ea29a1c9065ee2293118..094522c43d065aeaa25bb3fdd5137a10f0243172 100644 >--- a/Source/WebCore/platform/MediaSample.h >+++ b/Source/WebCore/platform/MediaSample.h >@@ -100,6 +100,7 @@ public: > bool hasAlpha() const { return flags() & HasAlpha; } > > virtual void dump(PrintStream&) const = 0; >+ virtual String toJSONString() const { return { }; } > }; > > } // namespace WebCore >@@ -116,6 +117,15 @@ template<> struct EnumTraits<WebCore::MediaSample::VideoRotation> { > >; > }; > >+template<typename Type> struct LogArgument; >+template <> >+struct LogArgument<WebCore::MediaSample> { >+ static String toString(const WebCore::MediaSample& sample) >+ { >+ return sample.toJSONString(); >+ } >+}; >+ > } // namespace WTF > > #endif >diff --git a/Source/WebCore/platform/graphics/FloatSize.cpp b/Source/WebCore/platform/graphics/FloatSize.cpp >index 8bb86d7402406cf8a449bc2e58808e6e544f18ce..6c5741d6316d93c587cca260b59fa7df0e59d008 100644 >--- a/Source/WebCore/platform/graphics/FloatSize.cpp >+++ b/Source/WebCore/platform/graphics/FloatSize.cpp >@@ -31,6 +31,7 @@ > #include "IntSize.h" > #include <limits> > #include <math.h> >+#include <wtf/JSONValues.h> > #include <wtf/text/TextStream.h> > > namespace WebCore { >@@ -75,4 +76,19 @@ TextStream& operator<<(TextStream& ts, const FloatSize& size) > << " height=" << TextStream::FormatNumberRespectingIntegers(size.height()); > } > >+Ref<JSON::Object> FloatSize::toJSONObject() const >+{ >+ auto object = JSON::Object::create(); >+ >+ object->setDouble("width"_s, m_width); >+ object->setDouble("height"_s, m_height); >+ >+ return object; >+} >+ >+String FloatSize::toJSONString() const >+{ >+ return toJSONObject()->toJSONString(); >+} >+ > } >diff --git a/Source/WebCore/platform/graphics/FloatSize.h b/Source/WebCore/platform/graphics/FloatSize.h >index 9e7c90f4f4baa7b2fa7fb8bc5bb9a6a84412aa91..bc6b253078768382953f324696530e2d4fbdd24b 100644 >--- a/Source/WebCore/platform/graphics/FloatSize.h >+++ b/Source/WebCore/platform/graphics/FloatSize.h >@@ -28,7 +28,9 @@ > #pragma once > > #include "IntPoint.h" >+#include <wtf/JSONValues.h> > #include <wtf/MathExtras.h> >+#include <wtf/text/WTFString.h> > > #if PLATFORM(IOS_FAMILY) > #include <CoreGraphics/CoreGraphics.h> >@@ -153,6 +155,9 @@ public: > operator D2D1_SIZE_F() const; > #endif > >+ String toJSONString() const; >+ Ref<JSON::Object> toJSONObject() const; >+ > private: > float m_width { 0 }; > float m_height { 0 }; >@@ -259,4 +264,14 @@ WEBCORE_EXPORT WTF::TextStream& operator<<(WTF::TextStream&, const FloatSize&); > namespace WTF { > template<> struct DefaultHash<WebCore::FloatSize>; > template<> struct HashTraits<WebCore::FloatSize>; >-} >+ >+template<typename Type> struct LogArgument; >+template <> >+struct LogArgument<WebCore::FloatSize> { >+ static String toString(const WebCore::FloatSize& size) >+ { >+ return size.toJSONString(); >+ } >+}; >+ >+} // namespace WTF >diff --git a/Source/WebCore/platform/graphics/MediaSourcePrivate.h b/Source/WebCore/platform/graphics/MediaSourcePrivate.h >index db55d11e1288a736e6dd2f3faab113ec780f4653..e147f14d8e1966b8397184bd2bd87d1717826263 100644 >--- a/Source/WebCore/platform/graphics/MediaSourcePrivate.h >+++ b/Source/WebCore/platform/graphics/MediaSourcePrivate.h >@@ -63,7 +63,32 @@ public: > virtual void seekCompleted() = 0; > }; > >-} >+String convertEnumerationToString(MediaSourcePrivate::AddStatus); >+String convertEnumerationToString(MediaSourcePrivate::EndOfStreamStatus); >+ >+} // namespace WebCore >+ >+namespace WTF { >+ >+template<typename Type> struct LogArgument; >+ >+template <> >+struct LogArgument<WebCore::MediaSourcePrivate::AddStatus> { >+ static String toString(const WebCore::MediaSourcePrivate::AddStatus status) >+ { >+ return convertEnumerationToString(status); >+ } >+}; >+ >+template <> >+struct LogArgument<WebCore::MediaSourcePrivate::EndOfStreamStatus> { >+ static String toString(const WebCore::MediaSourcePrivate::EndOfStreamStatus status) >+ { >+ return convertEnumerationToString(status); >+ } >+}; >+ >+} // namespace WTF > > #endif > #endif >diff --git a/Source/WebCore/platform/graphics/MediaSourcePrivateClient.h b/Source/WebCore/platform/graphics/MediaSourcePrivateClient.h >index da2ab536686604d85d8f5fc62e86a95ee1e38eb5..1941382ea2e326dd6a67eaf5c40492a177fe2b44 100644 >--- a/Source/WebCore/platform/graphics/MediaSourcePrivateClient.h >+++ b/Source/WebCore/platform/graphics/MediaSourcePrivateClient.h >@@ -29,6 +29,7 @@ > #if ENABLE(MEDIA_SOURCE) > > #include "PlatformTimeRanges.h" >+#include <wtf/Logger.h> > #include <wtf/RefCounted.h> > > namespace WebCore { >@@ -45,6 +46,10 @@ public: > virtual std::unique_ptr<PlatformTimeRanges> buffered() const = 0; > virtual void seekToTime(const MediaTime&) = 0; > virtual void monitorSourceBuffers() = 0; >+ >+#if !RELEASE_LOG_DISABLED >+ virtual void setLogIdentifier(const void*) = 0; >+#endif > }; > > } >diff --git a/Source/WebCore/platform/graphics/SourceBufferPrivate.h b/Source/WebCore/platform/graphics/SourceBufferPrivate.h >index 3e1683f2f35c4a18a2324e9bffb803e532943eb6..594770337da60490d773b295d245602de3f78934 100644 >--- a/Source/WebCore/platform/graphics/SourceBufferPrivate.h >+++ b/Source/WebCore/platform/graphics/SourceBufferPrivate.h >@@ -34,6 +34,7 @@ > #if ENABLE(MEDIA_SOURCE) > > #include "MediaPlayer.h" >+#include <wtf/Logger.h> > > namespace WebCore { > >@@ -64,6 +65,11 @@ public: > virtual Vector<String> enqueuedSamplesForTrackID(const AtomicString&) { return { }; } > > virtual bool canSwitchToType(const ContentType&) { return false; } >+ >+#if !RELEASE_LOG_DISABLED >+ virtual const Logger& sourceBufferLogger() const = 0; >+ virtual const void* sourceBufferLogIdentifier() = 0; >+#endif > }; > > } >diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm b/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm >index 1567fdb7f10be64c7f9df0ac22bcfc5edd43a9cb..fd484d7340edf80fe56f2b0c05c27a66ed5620ca 100644 >--- a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm >+++ b/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm >@@ -1395,7 +1395,7 @@ void MediaPlayerPrivateAVFoundationObjC::setMuted(bool muted) > if (m_muted == muted) > return; > >- INFO_LOG(LOGIDENTIFIER, "- ", muted); >+ INFO_LOG(LOGIDENTIFIER, muted); > > m_muted = muted; > >@@ -1412,7 +1412,7 @@ void MediaPlayerPrivateAVFoundationObjC::setClosedCaptionsVisible(bool closedCap > if (!metaDataAvailable()) > return; > >- INFO_LOG(LOGIDENTIFIER, "- ", closedCaptionsVisible); >+ INFO_LOG(LOGIDENTIFIER, closedCaptionsVisible); > } > > void MediaPlayerPrivateAVFoundationObjC::setRateDouble(double rate) >@@ -2813,7 +2813,7 @@ bool MediaPlayerPrivateAVFoundationObjC::isCurrentPlaybackTargetWireless() const > wirelessTarget = m_avPlayer && m_avPlayer.get().externalPlaybackActive; > #endif > >- INFO_LOG(LOGIDENTIFIER, "- ", wirelessTarget); >+ INFO_LOG(LOGIDENTIFIER, wirelessTarget); > > return wirelessTarget; > } >@@ -2941,14 +2941,14 @@ bool MediaPlayerPrivateAVFoundationObjC::wirelessVideoPlaybackDisabled() const > return !m_allowsWirelessVideoPlayback; > > m_allowsWirelessVideoPlayback = [m_avPlayer.get() allowsExternalPlayback]; >- INFO_LOG(LOGIDENTIFIER, "- ", !m_allowsWirelessVideoPlayback); >+ INFO_LOG(LOGIDENTIFIER, !m_allowsWirelessVideoPlayback); > > return !m_allowsWirelessVideoPlayback; > } > > void MediaPlayerPrivateAVFoundationObjC::setWirelessVideoPlaybackDisabled(bool disabled) > { >- INFO_LOG(LOGIDENTIFIER, "- ", disabled); >+ INFO_LOG(LOGIDENTIFIER, disabled); > m_allowsWirelessVideoPlayback = !disabled; > if (!m_avPlayer) > return; >@@ -2982,7 +2982,7 @@ void MediaPlayerPrivateAVFoundationObjC::setShouldPlayToPlaybackTarget(bool shou > if (!m_playbackTarget) > return; > >- INFO_LOG(LOGIDENTIFIER, "- ", shouldPlay); >+ INFO_LOG(LOGIDENTIFIER, shouldPlay); > > if (m_playbackTarget->targetType() == MediaPlaybackTarget::AVFoundation) { > AVOutputContext *newContext = shouldPlay ? m_outputContext.get() : nil; >@@ -3109,7 +3109,7 @@ void MediaPlayerPrivateAVFoundationObjC::trackEnabledDidChange(bool) > > void MediaPlayerPrivateAVFoundationObjC::setShouldBufferData(bool shouldBuffer) > { >- INFO_LOG(LOGIDENTIFIER, "- ", shouldBuffer); >+ INFO_LOG(LOGIDENTIFIER, shouldBuffer); > > if (m_shouldBufferData == shouldBuffer) > return; >diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h b/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h >index f846adfe67302b4bbd39f4ce8f1abf41d0e64319..79f246127e2e607656eb2f0eef71813361738aec 100644 >--- a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h >+++ b/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h >@@ -32,6 +32,7 @@ > #include "SourceBufferPrivateClient.h" > #include <wtf/Function.h> > #include <wtf/HashMap.h> >+#include <wtf/LoggerHelper.h> > #include <wtf/MediaTime.h> > #include <wtf/WeakPtr.h> > >@@ -57,7 +58,12 @@ class VideoTextureCopierCV; > class WebCoreDecompressionSession; > > >-class MediaPlayerPrivateMediaSourceAVFObjC : public MediaPlayerPrivateInterface { >+class MediaPlayerPrivateMediaSourceAVFObjC >+ : public MediaPlayerPrivateInterface >+#if !RELEASE_LOG_DISABLED >+ , private LoggerHelper >+#endif >+{ > public: > explicit MediaPlayerPrivateMediaSourceAVFObjC(MediaPlayer*); > virtual ~MediaPlayerPrivateMediaSourceAVFObjC(); >@@ -141,6 +147,22 @@ public: > > WeakPtr<MediaPlayerPrivateMediaSourceAVFObjC> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); } > >+#if !RELEASE_LOG_DISABLED >+ const Logger& logger() const final { return m_logger.get(); } >+ const char* logClassName() const override { return "MediaPlayerPrivateMediaSourceAVFObjC"; } >+ const void* logIdentifier() const final { return reinterpret_cast<const void*>(m_logIdentifier); } >+ WTFLogChannel& logChannel() const final; >+ >+ const void* mediaPlayerLogIdentifier() { return logIdentifier(); } >+ const Logger& mediaPlayerLogger() { return logger(); } >+#endif >+ >+ enum SeekState { >+ Seeking, >+ WaitingForAvailableFame, >+ SeekCompleted, >+ }; >+ > private: > // MediaPlayerPrivateInterface > void load(const String& url) override; >@@ -292,16 +314,12 @@ private: > double m_rate; > bool m_playing; > bool m_seeking; >- enum SeekState { >- Seeking, >- WaitingForAvailableFame, >- SeekCompleted, >- }; > SeekState m_seekCompleted { SeekCompleted }; > mutable bool m_loadingProgressed; > bool m_hasBeenAskedToPaintGL { false }; > bool m_hasAvailableVideoFrame { false }; > bool m_allRenderersHaveAvailableSamples { false }; >+ bool m_visible { false }; > std::unique_ptr<TextureCacheCV> m_textureCache; > std::unique_ptr<VideoTextureCopierCV> m_videoTextureCopier; > RetainPtr<CVOpenGLTextureRef> m_lastTexture; >@@ -310,10 +328,32 @@ private: > bool m_shouldPlayToTarget { false }; > #endif > std::unique_ptr<VideoFullscreenLayerManagerObjC> m_videoFullscreenLayerManager; >+ >+#if !RELEASE_LOG_DISABLED >+ Ref<const Logger> m_logger; >+ const void* m_logIdentifier; >+#endif > }; > >+String convertEnumerationToString(MediaPlayerPrivateMediaSourceAVFObjC::SeekState); >+ > } > >+namespace WTF { >+ >+template<typename Type> >+struct LogArgument; >+ >+template <> >+struct LogArgument<WebCore::MediaPlayerPrivateMediaSourceAVFObjC::SeekState> { >+ static String toString(const WebCore::MediaPlayerPrivateMediaSourceAVFObjC::SeekState state) >+ { >+ return convertEnumerationToString(state); >+ } >+}; >+ >+} // namespace WTF >+ > #endif // ENABLE(MEDIA_SOURCE) && USE(AVFOUNDATION) > > #endif // MediaPlayerPrivateMediaSourceAVFObjC_h >diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm b/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm >index 4c18fcb4f6ca855ed2c93874d4069f8a5154ef6f..448d31f0d0d0dc4f18e9b42ca66622e22f69c95e 100644 >--- a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm >+++ b/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm >@@ -88,6 +88,20 @@ SOFT_LINK_CONSTANT(AVFoundation, AVAudioTimePitchAlgorithmVarispeed, NSString*) > namespace WebCore { > using namespace PAL; > >+String convertEnumerationToString(MediaPlayerPrivateMediaSourceAVFObjC::SeekState enumerationValue) >+{ >+ static const NeverDestroyed<String> values[] = { >+ MAKE_STATIC_STRING_IMPL("Seeking"), >+ MAKE_STATIC_STRING_IMPL("WaitingForAvailableFame"), >+ MAKE_STATIC_STRING_IMPL("SeekCompleted"), >+ }; >+ static_assert(static_cast<size_t>(MediaPlayerPrivateMediaSourceAVFObjC::SeekState::Seeking) == 0, "MediaPlayerPrivateMediaSourceAVFObjC::SeekState::Seeking is not 0 as expected"); >+ static_assert(static_cast<size_t>(MediaPlayerPrivateMediaSourceAVFObjC::SeekState::WaitingForAvailableFame) == 1, "MediaPlayerPrivateMediaSourceAVFObjC::SeekState::WaitingForAvailableFame is not 1 as expected"); >+ static_assert(static_cast<size_t>(MediaPlayerPrivateMediaSourceAVFObjC::SeekState::SeekCompleted) == 2, "MediaPlayerPrivateMediaSourceAVFObjC::SeekState::SeekCompleted is not 2 as expected"); >+ ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values)); >+ return values[static_cast<size_t>(enumerationValue)]; >+} >+ > #pragma mark - > #pragma mark MediaPlayerPrivateMediaSourceAVFObjC > >@@ -112,11 +126,19 @@ MediaPlayerPrivateMediaSourceAVFObjC::MediaPlayerPrivateMediaSourceAVFObjC(Media > , m_seeking(false) > , m_loadingProgressed(false) > , m_videoFullscreenLayerManager(std::make_unique<VideoFullscreenLayerManagerObjC>()) >+#if !RELEASE_LOG_DISABLED >+ , m_logger(player->mediaPlayerLogger()) >+ , m_logIdentifier(player->mediaPlayerLogIdentifier()) >+#endif > { > CMTimebaseRef timebase = [m_synchronizer timebase]; > CMNotificationCenterRef nc = CMNotificationCenterGetDefaultLocalCenter(); > CMNotificationCenterAddListener(nc, this, CMTimebaseEffectiveRateChangedCallback, kCMTimebaseNotification_EffectiveRateChanged, timebase, 0); > >+ auto logSiteIdentifier = LOGIDENTIFIER; >+ ALWAYS_LOG(logSiteIdentifier); >+ UNUSED_PARAM(logSiteIdentifier); >+ > // addPeriodicTimeObserverForInterval: throws an exception if you pass a non-numeric CMTime, so just use > // an arbitrarily large time value of once an hour: > __block auto weakThis = createWeakPtr(); >@@ -128,8 +150,9 @@ MediaPlayerPrivateMediaSourceAVFObjC::MediaPlayerPrivateMediaSourceAVFObjC(Media > if (!weakThis) > return; > >+ DEBUG_LOG(logSiteIdentifier, "synchronizer fired for ", toMediaTime(time), ", seeking = ", m_seeking, ", pending = ", !!m_pendingSeek); >+ > if (m_seeking && !m_pendingSeek) { >- LOG(MediaSource, "MediaPlayerPrivateMediaSourceAVFObjC::m_timeJumpedObserver(%p) - time(%s)", weakThis.get(), toString(PAL::toMediaTime(time)).utf8().data()); > m_seeking = false; > > if (shouldBePlaying()) >@@ -145,6 +168,8 @@ MediaPlayerPrivateMediaSourceAVFObjC::MediaPlayerPrivateMediaSourceAVFObjC(Media > > MediaPlayerPrivateMediaSourceAVFObjC::~MediaPlayerPrivateMediaSourceAVFObjC() > { >+ ALWAYS_LOG(LOGIDENTIFIER); >+ > CMTimebaseRef timebase = [m_synchronizer timebase]; > CMNotificationCenterRef nc = CMNotificationCenterGetDefaultLocalCenter(); > CMNotificationCenterRemoveListener(nc, this, CMTimebaseEffectiveRateChangedCallback, kCMTimebaseNotification_EffectiveRateChanged, timebase); >@@ -229,9 +254,9 @@ void MediaPlayerPrivateMediaSourceAVFObjC::load(const String&) > m_player->networkStateChanged(); > } > >-void MediaPlayerPrivateMediaSourceAVFObjC::load(const String& url, MediaSourcePrivateClient* client) >+void MediaPlayerPrivateMediaSourceAVFObjC::load(const String&, MediaSourcePrivateClient* client) > { >- UNUSED_PARAM(url); >+ ALWAYS_LOG(LOGIDENTIFIER); > > m_mediaSourcePrivate = MediaSourcePrivateAVFObjC::create(this, client); > m_mediaSourcePrivate->setVideoLayer(m_sampleBufferDisplayLayer.get()); >@@ -262,6 +287,7 @@ PlatformLayer* MediaPlayerPrivateMediaSourceAVFObjC::platformLayer() const > > void MediaPlayerPrivateMediaSourceAVFObjC::play() > { >+ ALWAYS_LOG(LOGIDENTIFIER); > callOnMainThread([weakThis = createWeakPtr()] { > if (!weakThis) > return; >@@ -274,6 +300,7 @@ void MediaPlayerPrivateMediaSourceAVFObjC::playInternal() > if (currentMediaTime() >= m_mediaSourcePrivate->duration()) > return; > >+ ALWAYS_LOG(LOGIDENTIFIER); > m_playing = true; > if (shouldBePlaying()) > [m_synchronizer setRate:m_rate]; >@@ -281,6 +308,7 @@ void MediaPlayerPrivateMediaSourceAVFObjC::playInternal() > > void MediaPlayerPrivateMediaSourceAVFObjC::pause() > { >+ ALWAYS_LOG(LOGIDENTIFIER); > callOnMainThread([weakThis = createWeakPtr()] { > if (!weakThis) > return; >@@ -290,6 +318,7 @@ void MediaPlayerPrivateMediaSourceAVFObjC::pause() > > void MediaPlayerPrivateMediaSourceAVFObjC::pauseInternal() > { >+ ALWAYS_LOG(LOGIDENTIFIER); > m_playing = false; > [m_synchronizer setRate:0]; > } >@@ -301,6 +330,7 @@ bool MediaPlayerPrivateMediaSourceAVFObjC::paused() const > > void MediaPlayerPrivateMediaSourceAVFObjC::setVolume(float volume) > { >+ ALWAYS_LOG(LOGIDENTIFIER, volume); > for (const auto& key : m_sampleBufferAudioRendererMap.keys()) > [(__bridge AVSampleBufferAudioRenderer *)key.get() setVolume:volume]; > } >@@ -312,6 +342,7 @@ bool MediaPlayerPrivateMediaSourceAVFObjC::supportsScanning() const > > void MediaPlayerPrivateMediaSourceAVFObjC::setMuted(bool muted) > { >+ ALWAYS_LOG(LOGIDENTIFIER, muted); > for (const auto& key : m_sampleBufferAudioRendererMap.keys()) > [(__bridge AVSampleBufferAudioRenderer *)key.get() setMuted:muted]; > } >@@ -337,9 +368,15 @@ bool MediaPlayerPrivateMediaSourceAVFObjC::hasAudio() const > return m_mediaSourcePrivate->hasAudio(); > } > >-void MediaPlayerPrivateMediaSourceAVFObjC::setVisible(bool) >+void MediaPlayerPrivateMediaSourceAVFObjC::setVisible(bool visible) > { >- acceleratedRenderingStateChanged(); >+ if (m_visible == visible) >+ return; >+ >+ ALWAYS_LOG(LOGIDENTIFIER, visible); >+ m_visible = visible; >+ if (m_visible) >+ acceleratedRenderingStateChanged(); > } > > MediaTime MediaPlayerPrivateMediaSourceAVFObjC::durationMediaTime() const >@@ -369,7 +406,8 @@ MediaTime MediaPlayerPrivateMediaSourceAVFObjC::initialTime() const > > void MediaPlayerPrivateMediaSourceAVFObjC::seekWithTolerance(const MediaTime& time, const MediaTime& negativeThreshold, const MediaTime& positiveThreshold) > { >- LOG(MediaSource, "MediaPlayerPrivateMediaSourceAVFObjC::seekWithTolerance(%p) - time(%s), negativeThreshold(%s), positiveThreshold(%s)", this, toString(time).utf8().data(), toString(negativeThreshold).utf8().data(), toString(positiveThreshold).utf8().data()); >+ DEBUG_LOG(LOGIDENTIFIER, "time = ", time, ", negativeThreshold = ", negativeThreshold, ", positiveThreshold = ", positiveThreshold); >+ > m_seeking = true; > auto weakThis = createWeakPtr(); > m_pendingSeek = std::make_unique<PendingSeek>(time, negativeThreshold, positiveThreshold); >@@ -399,7 +437,7 @@ void MediaPlayerPrivateMediaSourceAVFObjC::seekInternal() > m_lastSeekTime = MediaTime::createWithDouble(m_lastSeekTime.toDouble(), MediaTime::DefaultTimeScale); > > MediaTime synchronizerTime = PAL::toMediaTime(CMTimebaseGetTime([m_synchronizer timebase])); >- LOG(MediaSource, "MediaPlayerPrivateMediaSourceAVFObjC::seekInternal(%p) - seekTime(%s), synchronizerTime(%s)", this, toString(m_lastSeekTime).utf8().data(), toString(synchronizerTime).utf8().data()); >+ DEBUG_LOG(LOGIDENTIFIER, "seekTime = ", m_lastSeekTime, ", synchronizerTime = ", synchronizerTime); > > bool doesNotRequireSeek = synchronizerTime == m_lastSeekTime; > >@@ -424,7 +462,7 @@ void MediaPlayerPrivateMediaSourceAVFObjC::waitForSeekCompleted() > { > if (!m_seeking) > return; >- LOG(MediaSource, "MediaPlayerPrivateMediaSourceAVFObjC::waitForSeekCompleted(%p)", this); >+ ALWAYS_LOG(LOGIDENTIFIER); > m_seekCompleted = Seeking; > } > >@@ -433,10 +471,11 @@ void MediaPlayerPrivateMediaSourceAVFObjC::seekCompleted() > if (m_seekCompleted == SeekCompleted) > return; > if (hasVideo() && !m_hasAvailableVideoFrame) { >+ ALWAYS_LOG(LOGIDENTIFIER, "waiting for video frame"); > m_seekCompleted = WaitingForAvailableFame; > return; > } >- LOG(MediaSource, "MediaPlayerPrivateMediaSourceAVFObjC::seekCompleted(%p)", this); >+ ALWAYS_LOG(LOGIDENTIFIER); > m_seekCompleted = SeekCompleted; > if (shouldBePlaying()) > [m_synchronizer setRate:m_rate]; >@@ -459,6 +498,7 @@ void MediaPlayerPrivateMediaSourceAVFObjC::setRateDouble(double rate) > > void MediaPlayerPrivateMediaSourceAVFObjC::setPreservesPitch(bool preservesPitch) > { >+ ALWAYS_LOG(LOGIDENTIFIER, preservesPitch); > NSString *algorithm = preservesPitch ? AVAudioTimePitchAlgorithmSpectral : AVAudioTimePitchAlgorithmVarispeed; > for (const auto& key : m_sampleBufferAudioRendererMap.keys()) > [(__bridge AVSampleBufferAudioRenderer *)key.get() setAudioTimePitchAlgorithm:algorithm]; >@@ -745,6 +785,8 @@ void MediaPlayerPrivateMediaSourceAVFObjC::setHasAvailableVideoFrame(bool flag) > { > if (m_hasAvailableVideoFrame == flag) > return; >+ >+ DEBUG_LOG(LOGIDENTIFIER, flag); > m_hasAvailableVideoFrame = flag; > updateAllRenderersHaveAvailableSamples(); > >@@ -772,6 +814,7 @@ ALLOW_NEW_API_WITHOUT_GUARDS_END > auto& properties = iter->value; > if (properties.hasAudibleSample == flag) > return; >+ DEBUG_LOG(LOGIDENTIFIER, flag); > properties.hasAudibleSample = flag; > updateAllRenderersHaveAvailableSamples(); > } >@@ -797,6 +840,7 @@ void MediaPlayerPrivateMediaSourceAVFObjC::updateAllRenderersHaveAvailableSample > if (m_allRenderersHaveAvailableSamples == allRenderersHaveAvailableSamples) > return; > >+ DEBUG_LOG(LOGIDENTIFIER, allRenderersHaveAvailableSamples); > m_allRenderersHaveAvailableSamples = allRenderersHaveAvailableSamples; > > if (shouldBePlaying() && [m_synchronizer rate] != m_rate) >@@ -819,18 +863,20 @@ void MediaPlayerPrivateMediaSourceAVFObjC::durationChanged() > auto weakThis = createWeakPtr(); > NSArray* times = @[[NSValue valueWithCMTime:PAL::toCMTime(duration)]]; > >- LOG(MediaSource, "MediaPlayerPrivateMediaSourceAVFObjC::durationChanged(%p) - duration = %s", this, toString(duration).utf8().data()); >+ auto logSiteIdentifier = LOGIDENTIFIER; >+ DEBUG_LOG(logSiteIdentifier, duration); >+ UNUSED_PARAM(logSiteIdentifier); > >- m_durationObserver = [m_synchronizer addBoundaryTimeObserverForTimes:times queue:dispatch_get_main_queue() usingBlock:[weakThis, duration] { >+ m_durationObserver = [m_synchronizer addBoundaryTimeObserverForTimes:times queue:dispatch_get_main_queue() usingBlock:[weakThis, duration, logSiteIdentifier, this] { > if (!weakThis) > return; > > MediaTime now = weakThis->currentMediaTime(); >- LOG(MediaSource, "MediaPlayerPrivateMediaSourceAVFObjC::durationChanged(%p) - boundary time observer called, now = %s", weakThis.get(), toString(now).utf8().data()); >+ DEBUG_LOG(logSiteIdentifier, "boundary time observer called, now = ", now); > > weakThis->pauseInternal(); > if (now < duration) { >- LOG(MediaSource, "MediaPlayerPrivateMediaSourceAVFObjC::durationChanged(%p) ERROR: boundary time observer called before duration!", weakThis.get()); >+ ERROR_LOG(logSiteIdentifier, "ERROR: boundary time observer called before duration"); > [weakThis->m_synchronizer setRate:0 time:PAL::toCMTime(duration)]; > } > weakThis->m_player->timeChanged(); >@@ -872,6 +918,8 @@ void MediaPlayerPrivateMediaSourceAVFObjC::setNaturalSize(const FloatSize& size) > if (size == m_naturalSize) > return; > >+ ALWAYS_LOG(LOGIDENTIFIER, size); >+ > m_naturalSize = size; > m_player->sizeChanged(); > } >@@ -912,6 +960,8 @@ void MediaPlayerPrivateMediaSourceAVFObjC::setCDMSession(LegacyCDMSession* sessi > if (session == m_session) > return; > >+ ALWAYS_LOG(LOGIDENTIFIER); >+ > m_session = makeWeakPtr(toCDMSessionMediaSourceAVFObjC(session)); > > if (CDMSessionAVStreamSession* cdmStreamSession = toCDMSessionAVStreamSession(m_session.get())) >@@ -931,6 +981,7 @@ void MediaPlayerPrivateMediaSourceAVFObjC::keyNeeded(Uint8Array* initData) > void MediaPlayerPrivateMediaSourceAVFObjC::outputObscuredDueToInsufficientExternalProtectionChanged(bool obscured) > { > #if ENABLE(ENCRYPTED_MEDIA) >+ ALWAYS_LOG(LOGIDENTIFIER, obscured); > if (m_mediaSourcePrivate) > m_mediaSourcePrivate->outputObscuredDueToInsufficientExternalProtectionChanged(obscured); > #else >@@ -941,18 +992,21 @@ void MediaPlayerPrivateMediaSourceAVFObjC::outputObscuredDueToInsufficientExtern > #if ENABLE(ENCRYPTED_MEDIA) > void MediaPlayerPrivateMediaSourceAVFObjC::cdmInstanceAttached(CDMInstance& instance) > { >+ ALWAYS_LOG(LOGIDENTIFIER); > if (m_mediaSourcePrivate) > m_mediaSourcePrivate->cdmInstanceAttached(instance); > } > > void MediaPlayerPrivateMediaSourceAVFObjC::cdmInstanceDetached(CDMInstance& instance) > { >+ ALWAYS_LOG(LOGIDENTIFIER); > if (m_mediaSourcePrivate) > m_mediaSourcePrivate->cdmInstanceDetached(instance); > } > > void MediaPlayerPrivateMediaSourceAVFObjC::attemptToDecryptWithInstance(CDMInstance& instance) > { >+ ALWAYS_LOG(LOGIDENTIFIER); > if (m_mediaSourcePrivate) > m_mediaSourcePrivate->attemptToDecryptWithInstance(instance); > } >@@ -964,11 +1018,13 @@ bool MediaPlayerPrivateMediaSourceAVFObjC::waitingForKey() const > > void MediaPlayerPrivateMediaSourceAVFObjC::waitingForKeyChanged() > { >+ ALWAYS_LOG(LOGIDENTIFIER); > m_player->waitingForKeyChanged(); > } > > void MediaPlayerPrivateMediaSourceAVFObjC::initializationDataEncountered(const String& initDataType, RefPtr<ArrayBuffer>&& initData) > { >+ ALWAYS_LOG(LOGIDENTIFIER, initDataType); > m_player->initializationDataEncountered(initDataType, WTFMove(initData)); > } > #endif >@@ -988,6 +1044,7 @@ void MediaPlayerPrivateMediaSourceAVFObjC::setReadyState(MediaPlayer::ReadyState > if (m_readyState == readyState) > return; > >+ ALWAYS_LOG(LOGIDENTIFIER, readyState); > m_readyState = readyState; > > if (shouldBePlaying()) >@@ -1008,6 +1065,7 @@ void MediaPlayerPrivateMediaSourceAVFObjC::setNetworkState(MediaPlayer::NetworkS > if (m_networkState == networkState) > return; > >+ ALWAYS_LOG(LOGIDENTIFIER, networkState); > m_networkState = networkState; > m_player->networkStateChanged(); > } >@@ -1087,6 +1145,7 @@ void MediaPlayerPrivateMediaSourceAVFObjC::setShouldPlayToPlaybackTarget(bool sh > if (shouldPlayToTarget == m_shouldPlayToTarget) > return; > >+ ALWAYS_LOG(LOGIDENTIFIER, shouldPlayToTarget); > m_shouldPlayToTarget = shouldPlayToTarget; > > if (m_player) >@@ -1098,7 +1157,9 @@ bool MediaPlayerPrivateMediaSourceAVFObjC::isCurrentPlaybackTargetWireless() con > if (!m_playbackTarget) > return false; > >- return m_shouldPlayToTarget && m_playbackTarget->hasActiveRoute(); >+ auto hasTarget = m_shouldPlayToTarget && m_playbackTarget->hasActiveRoute(); >+ DEBUG_LOG(LOGIDENTIFIER, hasTarget); >+ return hasTarget; > } > #endif > >@@ -1115,6 +1176,13 @@ bool MediaPlayerPrivateMediaSourceAVFObjC::performTaskAtMediaTime(WTF::Function< > return true; > } > >+#if !RELEASE_LOG_DISABLED >+WTFLogChannel& MediaPlayerPrivateMediaSourceAVFObjC::logChannel() const >+{ >+ return LogMediaSource; >+} >+#endif >+ > } > > #endif >diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm b/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm >index 935b1bfc236e95af6d061baffb49cf2c4e7a540f..aee746522b6b69b3a7997c5c662734ca58c67136 100644 >--- a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm >+++ b/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm >@@ -381,9 +381,9 @@ void MediaPlayerPrivateMediaStreamAVFObjC::enqueueVideoSample(MediaStreamTrackPr > INFO_LOG(LOGIDENTIFIER, "timeline offset for track ", track.id(), " set to ", timelineOffset); > } > >- DEBUG_LOG(LOGIDENTIFIER, "original sample = ", toString(sample)); >+ DEBUG_LOG(LOGIDENTIFIER, "original sample = ", sample); > sample.offsetTimestampsBy(timelineOffset); >- DEBUG_LOG(LOGIDENTIFIER, "updated sample = ", toString(sample)); >+ DEBUG_LOG(LOGIDENTIFIER, "updated sample = ", sample); > > if (WILL_LOG(WTFLogLevelDebug)) { > MediaTime now = streamTime(); >diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/MediaSampleAVFObjC.h b/Source/WebCore/platform/graphics/avfoundation/objc/MediaSampleAVFObjC.h >index 966ccd5569f9e06b6f9a581997aa7b389d1dd230..06eb4684d891cb4dd06c7173e7fe86536a2d90a5 100644 >--- a/Source/WebCore/platform/graphics/avfoundation/objc/MediaSampleAVFObjC.h >+++ b/Source/WebCore/platform/graphics/avfoundation/objc/MediaSampleAVFObjC.h >@@ -68,6 +68,8 @@ public: > > CMSampleBufferRef sampleBuffer() const { return m_sample.get(); } > >+ String toJSONString() const override; >+ > protected: > MediaSampleAVFObjC(RetainPtr<CMSampleBufferRef>&& sample) > : m_sample(WTFMove(sample)) >@@ -101,4 +103,5 @@ protected: > bool m_mirrored { false }; > }; > >-} >+} // namespace WebCore >+ >diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/MediaSampleAVFObjC.mm b/Source/WebCore/platform/graphics/avfoundation/objc/MediaSampleAVFObjC.mm >index 0ef943c4dd2bf43ceaf5ba5fe3345ba28c52b2e6..ffc69d7785772dcad1a49ad7a4a1b07d6cb91eec 100644 >--- a/Source/WebCore/platform/graphics/avfoundation/objc/MediaSampleAVFObjC.mm >+++ b/Source/WebCore/platform/graphics/avfoundation/objc/MediaSampleAVFObjC.mm >@@ -311,4 +311,18 @@ RefPtr<JSC::Uint8ClampedArray> MediaSampleAVFObjC::getRGBAImageData() const > #endif > } > >+String MediaSampleAVFObjC::toJSONString() const >+{ >+ auto object = JSON::Object::create(); >+ >+ object->setObject("pts"_s, presentationTime().toJSONObject()); >+ object->setObject("opts"_s, outputPresentationTime().toJSONObject()); >+ object->setObject("dts"_s, decodeTime().toJSONObject()); >+ object->setObject("duration"_s, duration().toJSONObject()); >+ object->setInteger("flags"_s, static_cast<unsigned>(flags())); >+ object->setObject("presentationSize"_s, presentationSize().toJSONObject()); >+ >+ return object->toJSONString(); >+} >+ > } >diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.h b/Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.h >index 16812759e0a1aefcf48bef1a4364d584c9181dc6..9ff1c04edb50da613f7f696575c4e7adb4efa5f4 100644 >--- a/Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.h >+++ b/Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.h >@@ -30,6 +30,7 @@ > > #include "MediaSourcePrivate.h" > #include <wtf/Deque.h> >+#include <wtf/LoggerHelper.h> > #include <wtf/RefPtr.h> > #include <wtf/RetainPtr.h> > #include <wtf/Vector.h> >@@ -51,7 +52,12 @@ class SourceBufferPrivateAVFObjC; > class TimeRanges; > class WebCoreDecompressionSession; > >-class MediaSourcePrivateAVFObjC final : public MediaSourcePrivate { >+class MediaSourcePrivateAVFObjC final >+ : public MediaSourcePrivate >+#if !RELEASE_LOG_DISABLED >+ , private LoggerHelper >+#endif >+{ > public: > static Ref<MediaSourcePrivateAVFObjC> create(MediaPlayerPrivateMediaSourceAVFObjC*, MediaSourcePrivateClient*); > virtual ~MediaSourcePrivateAVFObjC(); >@@ -95,6 +101,15 @@ public: > void outputObscuredDueToInsufficientExternalProtectionChanged(bool); > #endif > >+#if !RELEASE_LOG_DISABLED >+ const Logger& logger() const final { return m_logger.get(); } >+ const char* logClassName() const override { return "MediaSourcePrivateAVFObjC"; } >+ const void* logIdentifier() const final { return m_logIdentifier; } >+ WTFLogChannel& logChannel() const final; >+ >+ const void* nextSourceBufferLogIdentifier() { return childLogIdentifier(++m_nextSourceBufferID); } >+#endif >+ > private: > MediaSourcePrivateAVFObjC(MediaPlayerPrivateMediaSourceAVFObjC*, MediaSourcePrivateClient*); > >@@ -120,6 +135,11 @@ private: > #if ENABLE(ENCRYPTED_MEDIA) > RefPtr<CDMInstance> m_cdmInstance; > #endif >+#if !RELEASE_LOG_DISABLED >+ Ref<const Logger> m_logger; >+ const void* m_logIdentifier; >+ uint64_t m_nextSourceBufferID { 0 }; >+#endif > }; > > } >diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm b/Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm >index 2b37ec7dfeab465f11f7a507e08892ed97890a02..163297b5ebf315b5bb0a4dac0f85df060a521bde 100644 >--- a/Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm >+++ b/Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm >@@ -31,6 +31,7 @@ > #import "CDMInstance.h" > #import "CDMSessionMediaSourceAVFObjC.h" > #import "ContentType.h" >+#import "Logging.h" > #import "MediaPlayerPrivateMediaSourceAVFObjC.h" > #import "MediaSourcePrivateClient.h" > #import "SourceBufferPrivateAVFObjC.h" >@@ -55,17 +56,29 @@ MediaSourcePrivateAVFObjC::MediaSourcePrivateAVFObjC(MediaPlayerPrivateMediaSour > : m_player(parent) > , m_client(client) > , m_isEnded(false) >+#if !RELEASE_LOG_DISABLED >+ , m_logger(m_player->mediaPlayerLogger()) >+ , m_logIdentifier(m_player->mediaPlayerLogIdentifier()) >+#endif > { >+ ALWAYS_LOG(LOGIDENTIFIER); >+#if !RELEASE_LOG_DISABLED >+ m_client->setLogIdentifier(m_logIdentifier); >+#endif > } > > MediaSourcePrivateAVFObjC::~MediaSourcePrivateAVFObjC() > { >+ ALWAYS_LOG(LOGIDENTIFIER); >+ > for (auto it = m_sourceBuffers.begin(), end = m_sourceBuffers.end(); it != end; ++it) > (*it)->clearMediaSource(); > } > > MediaSourcePrivate::AddStatus MediaSourcePrivateAVFObjC::addSourceBuffer(const ContentType& contentType, RefPtr<SourceBufferPrivate>& outPrivate) > { >+ DEBUG_LOG(LOGIDENTIFIER, contentType); >+ > MediaEngineSupportParameters parameters; > parameters.isMediaSource = true; > parameters.type = contentType; >@@ -305,6 +318,13 @@ void MediaSourcePrivateAVFObjC::setSourceBufferWithSelectedVideo(SourceBufferPri > } > } > >+#if !RELEASE_LOG_DISABLED >+WTFLogChannel& MediaSourcePrivateAVFObjC::logChannel() const >+{ >+ return LogMediaSource; >+} >+#endif >+ > } > > #endif // ENABLE(MEDIA_SOURCE) && USE(AVFOUNDATION) >diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h b/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h >index f9866e02f976a931cb41ff800542d278530c894e..6759be103aa64b28afc09ab9f9bfaca780db72e1 100644 >--- a/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h >+++ b/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h >@@ -32,6 +32,7 @@ > #include <wtf/Box.h> > #include <wtf/Deque.h> > #include <wtf/HashMap.h> >+#include <wtf/LoggerHelper.h> > #include <wtf/MediaTime.h> > #include <wtf/OSObjectPtr.h> > #include <wtf/RefPtr.h> >@@ -77,7 +78,13 @@ public: > ALLOW_NEW_API_WITHOUT_GUARDS_END > }; > >-class SourceBufferPrivateAVFObjC final : public SourceBufferPrivate, public CanMakeWeakPtr<SourceBufferPrivateAVFObjC> { >+class SourceBufferPrivateAVFObjC final >+ : public SourceBufferPrivate >+ , public CanMakeWeakPtr<SourceBufferPrivateAVFObjC> >+#if !RELEASE_LOG_DISABLED >+ , private LoggerHelper >+#endif >+{ > public: > static Ref<SourceBufferPrivateAVFObjC> create(MediaSourcePrivateAVFObjC*); > virtual ~SourceBufferPrivateAVFObjC(); >@@ -127,6 +134,15 @@ public: > > void bufferWasConsumed(); > >+#if !RELEASE_LOG_DISABLED >+ const Logger& logger() const final { return m_logger.get(); } >+ const char* logClassName() const override { return "SourceBufferPrivateAVFObjC"; } >+ const void* logIdentifier() const final { return m_logIdentifier; } >+ WTFLogChannel& logChannel() const final; >+ const Logger& sourceBufferLogger() const final { return m_logger.get(); } >+ const void* sourceBufferLogIdentifier() final { return logIdentifier(); } >+#endif >+ > private: > explicit SourceBufferPrivateAVFObjC(MediaSourcePrivateAVFObjC*); > >@@ -196,6 +212,11 @@ private: > int m_enabledVideoTrackID { -1 }; > int m_protectedTrackID { -1 }; > uint64_t m_mapID; >+ >+#if !RELEASE_LOG_DISABLED >+ Ref<const Logger> m_logger; >+ const void* m_logIdentifier; >+#endif > }; > > } >diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm b/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm >index 11afe9f0eefb64c5e072580436fe53204889dfb7..23d9b2f48d8d8fda9f93f5d8f7b8ff72a729cc4d 100644 >--- a/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm >+++ b/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm >@@ -456,8 +456,6 @@ static uint64_t nextMapID() > > static void bufferWasConsumedCallback(CMNotificationCenterRef, const void* listener, CFStringRef notificationName, const void*, CFTypeRef) > { >- LOG(MediaSource, "bufferWasConsumedCallback - nofication %s", [(__bridge NSString *)notificationName UTF8String]); >- > if (!CFEqual(kCMSampleBufferConsumerNotification_BufferConsumed, notificationName)) > return; > >@@ -470,7 +468,7 @@ static void bufferWasConsumedCallback(CMNotificationCenterRef, const void* liste > > uint64_t mapID = reinterpret_cast<uint64_t>(listener); > if (!mapID) { >- LOG(MediaSource, "bufferWasConsumedCallback - ERROR: didn't find ID %llu in map", mapID); >+ RELEASE_LOG(MediaSource, "bufferWasConsumedCallback - ERROR: didn't find ID %llu in map", mapID); > return; > } > >@@ -490,7 +488,13 @@ SourceBufferPrivateAVFObjC::SourceBufferPrivateAVFObjC(MediaSourcePrivateAVFObjC > , m_isAppendingGroup(adoptOSObject(dispatch_group_create())) > , m_mediaSource(parent) > , m_mapID(nextMapID()) >+#if !RELEASE_LOG_DISABLED >+ , m_logger(parent->logger()) >+ , m_logIdentifier(parent->nextSourceBufferLogIdentifier()) >+#endif > { >+ ALWAYS_LOG(LOGIDENTIFIER); >+ > CMNotificationCenterAddListener(CMNotificationCenterGetDefaultLocalCenter(), reinterpret_cast<void*>(m_mapID), bufferWasConsumedCallback, kCMSampleBufferConsumerNotification_BufferConsumed, nullptr, 0); > m_delegate.get().abortSemaphore = Box<Semaphore>::create(0); > >@@ -499,6 +503,8 @@ SourceBufferPrivateAVFObjC::SourceBufferPrivateAVFObjC(MediaSourcePrivateAVFObjC > > SourceBufferPrivateAVFObjC::~SourceBufferPrivateAVFObjC() > { >+ ALWAYS_LOG(LOGIDENTIFIER); >+ > ASSERT(!m_client); > sourceBufferMap().remove(m_mapID); > destroyParser(); >@@ -512,7 +518,7 @@ SourceBufferPrivateAVFObjC::~SourceBufferPrivateAVFObjC() > > void SourceBufferPrivateAVFObjC::didParseStreamDataAsAsset(AVAsset* asset) > { >- LOG(MediaSource, "SourceBufferPrivateAVFObjC::didParseStreamDataAsAsset(%p)", this); >+ ALWAYS_LOG(LOGIDENTIFIER); > > if (!m_mediaSource) > return; >@@ -578,7 +584,7 @@ void SourceBufferPrivateAVFObjC::didFailToParseStreamDataWithError(NSError *erro > #if LOG_DISABLED > UNUSED_PARAM(error); > #endif >- LOG(MediaSource, "SourceBufferPrivateAVFObjC::didFailToParseStreamDataWithError(%p) - error:\"%s\"", this, String([error description]).utf8().data()); >+ ERROR_LOG(LOGIDENTIFIER, [[error description] UTF8String]); > > m_parsingSucceeded = false; > } >@@ -607,7 +613,7 @@ bool SourceBufferPrivateAVFObjC::processCodedFrame(int trackID, CMSampleBufferRe > > if (m_client) { > Ref<MediaSample> mediaSample = MediaSampleAVFObjC::create(sampleBuffer, trackID); >- LOG(MediaSourceSamples, "SourceBufferPrivateAVFObjC::processCodedFrame(%p) - sample(%s)", this, toString(mediaSample.get()).utf8().data()); >+ DEBUG_LOG(LOGIDENTIFIER, mediaSample.get()); > m_client->sourceBufferPrivateDidReceiveSample(mediaSample); > } > >@@ -627,7 +633,8 @@ void SourceBufferPrivateAVFObjC::willProvideContentKeyRequestInitializationDataF > ASSERT(m_parser); > > #if HAVE(AVSTREAMSESSION) && ENABLE(LEGACY_ENCRYPTED_MEDIA) >- LOG(MediaSource, "SourceBufferPrivateAVFObjC::willProvideContentKeyRequestInitializationDataForTrackID(%p) - track:%d", this, trackID); >+ ALWAYS_LOG(LOGIDENTIFIER, "track = ", trackID); >+ > m_protectedTrackID = trackID; > > if (CDMSessionMediaSourceAVFObjC* session = m_mediaSource->player()->cdmSession()) >@@ -648,7 +655,8 @@ void SourceBufferPrivateAVFObjC::didProvideContentKeyRequestInitializationDataFo > return; > > #if HAVE(AVSTREAMSESSION) && ENABLE(LEGACY_ENCRYPTED_MEDIA) >- LOG(MediaSource, "SourceBufferPrivateAVFObjC::didProvideContentKeyRequestInitializationDataForTrackID(%p) - track:%d", this, trackID); >+ ALWAYS_LOG(LOGIDENTIFIER, "track = ", trackID); >+ > m_protectedTrackID = trackID; > auto initDataArray = Uint8Array::create([initData length]); > [initData getBytes:initDataArray->data() length:initDataArray->length()]; >@@ -710,7 +718,7 @@ static dispatch_queue_t globalDataParserQueue() > > void SourceBufferPrivateAVFObjC::append(Vector<unsigned char>&& data) > { >- LOG(MediaSource, "SourceBufferPrivateAVFObjC::append(%p) - data:%p, length:%d", this, data.data(), (int)data.size()); >+ DEBUG_LOG(LOGIDENTIFIER, "data length = ", data.size()); > > // FIXME: Avoid the data copy by wrapping around the Vector<> object. > RetainPtr<NSData> nsData = adoptNS([[NSData alloc] initWithBytes:data.data() length:data.size()]); >@@ -747,6 +755,8 @@ void SourceBufferPrivateAVFObjC::appendCompleted() > > void SourceBufferPrivateAVFObjC::abort() > { >+ ALWAYS_LOG(LOGIDENTIFIER); >+ > // The parsing queue may be blocked waiting for the main thread to provide it a AVStreamSession. We > // were asked to abort, and that cancels all outstanding append operations. Without cancelling this > // semaphore, the m_isAppendingGroup wait operation will deadlock. >@@ -761,7 +771,8 @@ void SourceBufferPrivateAVFObjC::abort() > > void SourceBufferPrivateAVFObjC::resetParserState() > { >- LOG(MediaSource, "SourceBufferPrivateAVFObjC::resetParserState(%p)", this); >+ ALWAYS_LOG(LOGIDENTIFIER); >+ > m_parserStateWasReset = true; > m_discardSamplesUntilNextInitializationSegment = true; > } >@@ -808,6 +819,8 @@ void SourceBufferPrivateAVFObjC::destroyRenderers() > > void SourceBufferPrivateAVFObjC::removedFromMediaSource() > { >+ ALWAYS_LOG(LOGIDENTIFIER); >+ > destroyParser(); > destroyRenderers(); > >@@ -822,7 +835,7 @@ MediaPlayer::ReadyState SourceBufferPrivateAVFObjC::readyState() const > > void SourceBufferPrivateAVFObjC::setReadyState(MediaPlayer::ReadyState readyState) > { >- LOG(MediaSource, "SourceBufferPrivateAVFObjC::setReadyState(%p) - readyState = %i", this, (int)readyState); >+ ALWAYS_LOG(LOGIDENTIFIER, readyState); > > if (m_mediaSource) > m_mediaSource->player()->setReadyState(readyState); >@@ -847,7 +860,7 @@ void SourceBufferPrivateAVFObjC::trackDidChangeEnabled(VideoTrackPrivateMediaSou > { > int trackID = track->trackID(); > >- LOG(MediaSource, "SourceBufferPrivateAVFObjC::trackDidChangeEnabled(%p) - video trackID = %i, selected = %s", this, trackID, track->selected() ? "true" : "false"); >+ ALWAYS_LOG(LOGIDENTIFIER, "video trackID = ", trackID, ", selected = ", track->selected()); > > if (!track->selected() && m_enabledVideoTrackID == trackID) { > m_enabledVideoTrackID = -1; >@@ -873,7 +886,7 @@ void SourceBufferPrivateAVFObjC::trackDidChangeEnabled(AudioTrackPrivateMediaSou > { > int trackID = track->trackID(); > >- LOG(MediaSource, "SourceBufferPrivateAVFObjC::trackDidChangeEnabled(%p) - audio trackID = %i, enabled = %s", this, trackID, track->enabled() ? "true" : "false"); >+ ALWAYS_LOG(LOGIDENTIFIER, "audio trackID = ", trackID, ", selected = ", track->enabled()); > > if (!track->enabled()) { > ALLOW_NEW_API_WITHOUT_GUARDS_BEGIN >@@ -910,6 +923,8 @@ void SourceBufferPrivateAVFObjC::setCDMSession(CDMSessionMediaSourceAVFObjC* ses > if (session == m_session) > return; > >+ ALWAYS_LOG(LOGIDENTIFIER); >+ > if (m_session) > m_session->removeSourceBuffer(this); > >@@ -945,6 +960,8 @@ void SourceBufferPrivateAVFObjC::setCDMInstance(CDMInstance* instance) > if (fpsInstance == m_cdmInstance) > return; > >+ ALWAYS_LOG(LOGIDENTIFIER); >+ > m_cdmInstance = fpsInstance; > attemptToDecrypt(); > #else >@@ -993,7 +1010,7 @@ void SourceBufferPrivateAVFObjC::unregisterForErrorNotifications(SourceBufferPri > > void SourceBufferPrivateAVFObjC::layerDidReceiveError(AVSampleBufferDisplayLayer *layer, NSError *error) > { >- LOG(MediaSource, "SourceBufferPrivateAVFObjC::layerDidReceiveError(%p): layer(%p), error(%s)", this, layer, [[error description] UTF8String]); >+ ERROR_LOG(LOGIDENTIFIER, [[error description] UTF8String]); > > // FIXME(142246): Remove the following once <rdar://problem/20027434> is resolved. > bool anyIgnored = false; >@@ -1022,6 +1039,8 @@ void SourceBufferPrivateAVFObjC::outputObscuredDueToInsufficientExternalProtecti > UNUSED_PARAM(obscured); > #endif > >+ ERROR_LOG(LOGIDENTIFIER, obscured); >+ > RetainPtr<NSError> error = [NSError errorWithDomain:@"com.apple.WebKit" code:'HDCP' userInfo:nil]; > layerDidReceiveError(m_displayLayer.get(), error.get()); > } >@@ -1030,7 +1049,7 @@ ALLOW_NEW_API_WITHOUT_GUARDS_BEGIN > void SourceBufferPrivateAVFObjC::rendererDidReceiveError(AVSampleBufferAudioRenderer *renderer, NSError *error) > ALLOW_NEW_API_WITHOUT_GUARDS_END > { >- LOG(MediaSource, "SourceBufferPrivateAVFObjC::rendererDidReceiveError(%p): renderer(%p), error(%s)", this, renderer, [[error description] UTF8String]); >+ ERROR_LOG(LOGIDENTIFIER, [[error description] UTF8String]); > > if ([error code] == 'HDCP') > m_hdcpError = error; >@@ -1049,7 +1068,7 @@ ALLOW_NEW_API_WITHOUT_GUARDS_END > void SourceBufferPrivateAVFObjC::flush(const AtomicString& trackIDString) > { > int trackID = trackIDString.toInt(); >- LOG(MediaSource, "SourceBufferPrivateAVFObjC::flush(%p) - trackId: %d", this, trackID); >+ DEBUG_LOG(LOGIDENTIFIER, trackID); > > if (trackID == m_enabledVideoTrackID) { > flushVideo(); >@@ -1059,6 +1078,7 @@ void SourceBufferPrivateAVFObjC::flush(const AtomicString& trackIDString) > > void SourceBufferPrivateAVFObjC::flushVideo() > { >+ DEBUG_LOG(LOGIDENTIFIER); > [m_displayLayer flush]; > > if (m_decompressionSession) { >@@ -1097,13 +1117,13 @@ void SourceBufferPrivateAVFObjC::enqueueSample(Ref<MediaSample>&& sample, const > if (platformSample.type != PlatformSample::CMSampleBufferType) > return; > >- LOG(MediaSourceSamples, "SourceBufferPrivateAVFObjC::enqueueSample(%p) - sample(%s)", this, toString(sample.get()).utf8().data()); >+ DEBUG_LOG(LOGIDENTIFIER, "track ID = ", trackID, "sample = ", sample.get()); > > if (trackID == m_enabledVideoTrackID) { > CMFormatDescriptionRef formatDescription = CMSampleBufferGetFormatDescription(platformSample.sample.cmSampleBuffer); > FloatSize formatSize = FloatSize(CMVideoFormatDescriptionGetPresentationDimensions(formatDescription, true, true)); > if (!m_cachedSize || formatSize != m_cachedSize.value()) { >- LOG(MediaSource, "SourceBufferPrivateAVFObjC::enqueueSample(%p) - size change detected: {width=%lf, height=%lf}", this, formatSize.width(), formatSize.height()); >+ DEBUG_LOG(LOGIDENTIFIER, "size changed to ", formatSize); > bool sizeWasNull = !m_cachedSize; > m_cachedSize = formatSize; > if (m_mediaSource) { >@@ -1121,7 +1141,7 @@ void SourceBufferPrivateAVFObjC::enqueueSample(Ref<MediaSample>&& sample, const > return; > > if (m_mediaSource && !m_mediaSource->player()->hasAvailableVideoFrame() && !sample->isNonDisplaying()) { >- LOG(MediaSource, "SourceBufferPrivateAVFObjC::didParseStreamDataAsAsset(%p) - adding buffer attachment", this); >+ DEBUG_LOG(LOGIDENTIFIER, "adding buffer attachment"); > > CMSampleBufferRef rawSampleCopy; > CMSampleBufferCreateCopy(kCFAllocatorDefault, platformSample.sample.cmSampleBuffer, &rawSampleCopy); >@@ -1144,7 +1164,7 @@ void SourceBufferPrivateAVFObjC::enqueueSample(Ref<MediaSample>&& sample, const > > void SourceBufferPrivateAVFObjC::bufferWasConsumed() > { >- LOG(MediaSource, "SourceBufferPrivateAVFObjC::bufferWasConsumed(%p)", this); >+ DEBUG_LOG(LOGIDENTIFIER); > > if (m_mediaSource) > m_mediaSource->player()->setHasAvailableVideoFrame(true); >@@ -1168,6 +1188,7 @@ bool SourceBufferPrivateAVFObjC::isReadyForMoreSamples(const AtomicString& track > > void SourceBufferPrivateAVFObjC::setActive(bool isActive) > { >+ ALWAYS_LOG(LOGIDENTIFIER, isActive); > if (m_mediaSource) > m_mediaSource->sourceBufferPrivateDidChangeActiveState(this, isActive); > } >@@ -1181,7 +1202,7 @@ MediaTime SourceBufferPrivateAVFObjC::fastSeekTimeForMediaTime(const MediaTime& > > void SourceBufferPrivateAVFObjC::willSeek() > { >- LOG(MediaSource, "SourceBufferPrivateAVFObjC::willSeek(%p)", this); >+ ALWAYS_LOG(LOGIDENTIFIER); > flush(); > } > >@@ -1192,7 +1213,8 @@ FloatSize SourceBufferPrivateAVFObjC::naturalSize() > > void SourceBufferPrivateAVFObjC::didBecomeReadyForMoreSamples(int trackID) > { >- LOG(Media, "SourceBufferPrivateAVFObjC::didBecomeReadyForMoreSamples(%p) - track(%d)", this, trackID); >+ INFO_LOG(LOGIDENTIFIER, trackID); >+ > if (trackID == m_enabledVideoTrackID) { > if (m_decompressionSession) > m_decompressionSession->stopRequestingMediaData(); >@@ -1233,6 +1255,8 @@ void SourceBufferPrivateAVFObjC::notifyClientWhenReadyForMoreSamples(const Atomi > > bool SourceBufferPrivateAVFObjC::canSwitchToType(const ContentType& contentType) > { >+ ALWAYS_LOG(LOGIDENTIFIER, contentType); >+ > MediaEngineSupportParameters parameters; > parameters.isMediaSource = true; > parameters.type = contentType; >@@ -1271,7 +1295,7 @@ void SourceBufferPrivateAVFObjC::setDecompressionSession(WebCoreDecompressionSes > if (m_decompressionSession == decompressionSession) > return; > >- LOG(MediaSource, "SourceBufferPrivateAVFObjC::setDecompressionSession(%p)", this); >+ ALWAYS_LOG(LOGIDENTIFIER); > > if (m_decompressionSession) { > m_decompressionSession->stopRequestingMediaData(); >@@ -1296,6 +1320,13 @@ void SourceBufferPrivateAVFObjC::setDecompressionSession(WebCoreDecompressionSes > m_client->sourceBufferPrivateReenqueSamples(AtomicString::number(m_enabledVideoTrackID)); > } > >+#if !RELEASE_LOG_DISABLED >+WTFLogChannel& SourceBufferPrivateAVFObjC::logChannel() const >+{ >+ return LogMediaSource; >+} >+#endif >+ > } > > #endif // ENABLE(MEDIA_SOURCE) && USE(AVFOUNDATION) >diff --git a/Source/WebCore/platform/mock/mediasource/MockMediaPlayerMediaSource.h b/Source/WebCore/platform/mock/mediasource/MockMediaPlayerMediaSource.h >index b3bf3a19a66f39ba7dc0d6b5c96d67abf8126950..7dfc1f228da21394f376c7f2964cf1446e8ca31e 100644 >--- a/Source/WebCore/platform/mock/mediasource/MockMediaPlayerMediaSource.h >+++ b/Source/WebCore/platform/mock/mediasource/MockMediaPlayerMediaSource.h >@@ -29,6 +29,7 @@ > #if ENABLE(MEDIA_SOURCE) > > #include "MediaPlayerPrivate.h" >+#include <wtf/Logger.h> > #include <wtf/MediaTime.h> > > namespace WebCore { >@@ -56,6 +57,11 @@ public: > void waitForSeekCompleted(); > void seekCompleted(); > >+#if !RELEASE_LOG_DISABLED >+ const void* mediaPlayerLogIdentifier() { return m_player->mediaPlayerLogIdentifier(); } >+ const Logger& mediaPlayerLogger() { return m_player->mediaPlayerLogger(); } >+#endif >+ > private: > // MediaPlayerPrivate Overrides > void load(const String& url) override; >diff --git a/Source/WebCore/platform/mock/mediasource/MockMediaSourcePrivate.cpp b/Source/WebCore/platform/mock/mediasource/MockMediaSourcePrivate.cpp >index aa42e88a43c19cca285f65eea1e791a05285428e..7dcc964935028649315e5b381fb9eaf81b3aa95a 100644 >--- a/Source/WebCore/platform/mock/mediasource/MockMediaSourcePrivate.cpp >+++ b/Source/WebCore/platform/mock/mediasource/MockMediaSourcePrivate.cpp >@@ -46,6 +46,9 @@ MockMediaSourcePrivate::MockMediaSourcePrivate(MockMediaPlayerMediaSource& paren > : m_player(parent) > , m_client(client) > { >+#if !RELEASE_LOG_DISABLED >+ m_client->setLogIdentifier(m_player.mediaPlayerLogIdentifier()); >+#endif > } > > MockMediaSourcePrivate::~MockMediaSourcePrivate() >@@ -179,6 +182,18 @@ Optional<VideoPlaybackQualityMetrics> MockMediaSourcePrivate::videoPlaybackQuali > }; > } > >+#if !RELEASE_LOG_DISABLED >+const Logger& MockMediaSourcePrivate::mediaSourceLogger() const >+{ >+ return m_player.mediaPlayerLogger(); >+} >+ >+const void* MockMediaSourcePrivate::mediaSourceLogIdentifier() >+{ >+ return m_player.mediaPlayerLogIdentifier(); >+} >+#endif >+ > } > > #endif >diff --git a/Source/WebCore/platform/mock/mediasource/MockMediaSourcePrivate.h b/Source/WebCore/platform/mock/mediasource/MockMediaSourcePrivate.h >index 8bcbe3b38b0b5033dca3f499674f8e217b453699..1467bd48ad83c8f533b8f66015f47be0a577e752 100644 >--- a/Source/WebCore/platform/mock/mediasource/MockMediaSourcePrivate.h >+++ b/Source/WebCore/platform/mock/mediasource/MockMediaSourcePrivate.h >@@ -60,6 +60,11 @@ public: > void incrementCorruptedFrames() { ++m_corruptedVideoFrames; } > void incrementTotalFrameDelayBy(const MediaTime& delay) { m_totalFrameDelay += delay; } > >+#if !RELEASE_LOG_DISABLED >+ const Logger& mediaSourceLogger() const; >+ const void* mediaSourceLogIdentifier(); >+#endif >+ > private: > MockMediaSourcePrivate(MockMediaPlayerMediaSource&, MediaSourcePrivateClient&); > >diff --git a/Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.cpp b/Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.cpp >index ce273f17f1670bbee3e469b8f238540c97b9974a..593430ce3850b62514cf9f22844fe4988fae0170 100644 >--- a/Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.cpp >+++ b/Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.cpp >@@ -289,6 +289,18 @@ MediaTime MockSourceBufferPrivate::fastSeekTimeForMediaTime(const MediaTime& tim > return time; > } > >+#if !RELEASE_LOG_DISABLED >+const Logger& MockSourceBufferPrivate::sourceBufferLogger() const >+{ >+ return m_mediaSource->mediaSourceLogger(); >+} >+ >+const void* MockSourceBufferPrivate::sourceBufferLogIdentifier() >+{ >+ return m_mediaSource->mediaSourceLogIdentifier(); >+} >+#endif >+ > } > > #endif >diff --git a/Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.h b/Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.h >index a3e65dbdbecc94469a1b0e1b1f770b21d4bfc976..f89a80b50d0761c7186fc9cb4c9767f0b768d400 100644 >--- a/Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.h >+++ b/Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.h >@@ -74,6 +74,11 @@ private: > void didReceiveInitializationSegment(const MockInitializationBox&); > void didReceiveSample(const MockSampleBox&); > >+#if !RELEASE_LOG_DISABLED >+ const Logger& sourceBufferLogger() const final; >+ const void* sourceBufferLogIdentifier() final; >+#endif >+ > MockMediaSourcePrivate* m_mediaSource; > SourceBufferPrivateClient* m_client; > Vector<String> m_enqueuedSamples;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 194348
:
361338
|
361352
|
361396
|
361407
|
361410
|
361413
| 361415