Switch text tracks to release logging
authoreric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 15 Sep 2017 16:20:07 +0000 (16:20 +0000)
committereric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 15 Sep 2017 16:20:07 +0000 (16:20 +0000)
https://bugs.webkit.org/show_bug.cgi?id=176809
<rdar://problem/34397605>

Reviewed by Jer Noble.

Source/WebCore:

Make all track objects use the same logger and log identifier as the media element they
"belong" to. Convert all track logging from debug-only to release logging.

* WebCore.xcodeproj/project.pbxproj:
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::updateActiveTextTrackCues):
* html/HTMLMediaElement.h:
* html/track/AudioTrack.cpp:
(WebCore::AudioTrack::AudioTrack):
(WebCore::AudioTrack::setPrivate):
(WebCore::AudioTrack::setMediaElement):
* html/track/AudioTrack.h:
* html/track/DataCue.cpp:
(WebCore::DataCue::toString const):
* html/track/DataCue.h:
(PAL::LogArgument<WebCore::DataCue>::toString):
* html/track/InbandDataTextTrack.cpp:
(WebCore::InbandDataTextTrack::addDataCue):
(WebCore::InbandDataTextTrack::updateDataCue):
(WebCore::InbandDataTextTrack::removeDataCue):
* html/track/InbandDataTextTrack.h:
* html/track/InbandGenericTextTrack.cpp:
(WebCore::InbandGenericTextTrack::addGenericCue):
(WebCore::InbandGenericTextTrack::removeGenericCue):
(WebCore::InbandGenericTextTrack::newCuesParsed):
(WebCore::InbandGenericTextTrack::fileFailedToParse):
* html/track/InbandGenericTextTrack.h:
* html/track/InbandTextTrack.cpp:
(WebCore::InbandTextTrack::InbandTextTrack):
(WebCore::InbandTextTrack::setMediaElement):
* html/track/InbandTextTrack.h:
* html/track/InbandWebVTTTextTrack.cpp:
(WebCore::InbandWebVTTTextTrack::newCuesParsed):
(WebCore::InbandWebVTTTextTrack::fileFailedToParse):
* html/track/InbandWebVTTTextTrack.h:
* html/track/LoadableTextTrack.cpp:
(WebCore::LoadableTextTrack::newCuesAvailable):
(WebCore::LoadableTextTrack::cueLoadingCompleted):
* html/track/LoadableTextTrack.h:
* html/track/TextTrack.cpp:
(WebCore::TextTrack::addCue):
(WebCore::TextTrack::removeCue):
(WebCore::TextTrack::setLanguage):
* html/track/TextTrack.h:
* html/track/TextTrackCue.cpp:
(WebCore::TextTrackCue::toString const):
* html/track/TextTrackCue.h:
(PAL::LogArgument<WebCore::TextTrackCue>::toString):
* html/track/TextTrackCueGeneric.cpp:
(WebCore::TextTrackCueGeneric::setFontSize):
(WebCore::TextTrackCueGeneric::toString const):
* html/track/TextTrackCueGeneric.h:
(PAL::LogArgument<WebCore::TextTrackCueGeneric>::toString):
* html/track/TrackBase.cpp:
(WebCore::nextLogIdentifier):
(WebCore::nullLogger):
(WebCore::TrackBase::TrackBase):
(WebCore::TrackBase::setMediaElement):
(WebCore::TrackBase::logChannel const):
(WebCore::TrackBase::~TrackBase): Deleted.
* html/track/TrackBase.h:
(WebCore::TrackBase::setMediaElement): Deleted.
* html/track/VTTCue.cpp:
(WebCore::VTTCue::setFontSize):
(WebCore::VTTCue::toString const):
* html/track/VTTCue.h:
(PAL::LogArgument<WebCore::VTTCue>::toString):
* html/track/VideoTrack.cpp:
(WebCore::VideoTrack::VideoTrack):
(WebCore::VideoTrack::setPrivate):
(WebCore::VideoTrack::setMediaElement):
* html/track/VideoTrack.h:
* platform/graphics/AudioTrackPrivate.h:
* platform/graphics/InbandTextTrackPrivate.h:
(WebCore::InbandTextTrackPrivate::setClient):
* platform/graphics/InbandTextTrackPrivateClient.h:
(WebCore::GenericCueData::toString const):
(PAL::LogArgument<WebCore::GenericCueData>::toString):
* platform/graphics/TrackPrivateBase.cpp: Added.
(WebCore::TrackPrivateBase::setLogger):
(WebCore::TrackPrivateBase::logChannel const):
* platform/graphics/TrackPrivateBase.h:
* platform/graphics/VideoTrackPrivate.h:
* platform/graphics/avfoundation/AVTrackPrivateAVFObjCImpl.mm:
* platform/graphics/avfoundation/InbandMetadataTextTrackPrivateAVF.cpp:
(WebCore::InbandMetadataTextTrackPrivateAVF::updatePendingCueEndTimes):
(WebCore::InbandMetadataTextTrackPrivateAVF::flushPartialCues):
* platform/graphics/avfoundation/InbandMetadataTextTrackPrivateAVF.h:
* platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp:
(WebCore::InbandTextTrackPrivateAVF::processAttributedStrings):
(WebCore::InbandTextTrackPrivateAVF::removeCompletedCues):
(WebCore::InbandTextTrackPrivateAVF::resetCueValues):
(WebCore::InbandTextTrackPrivateAVF::processNativeSamples):
(WebCore::InbandTextTrackPrivateAVF::readNativeSampleBuffer):
* platform/graphics/avfoundation/InbandTextTrackPrivateAVF.h:
* platform/graphics/avfoundation/objc/AudioTrackPrivateAVFObjC.mm:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(-[WebCoreAVFMovieObserver observeValueForKeyPath:ofObject:change:context:]):
* platform/mediastream/mac/AudioTrackPrivateMediaStreamCocoa.cpp:
(WebCore::AudioTrackPrivateMediaStreamCocoa::createAudioUnit):
* platform/mediastream/mac/AudioTrackPrivateMediaStreamCocoa.h:

Source/WebCore/PAL:

* pal/Logger.h:
(PAL::LogArgument::toString):
(PAL::Logger::willLog const):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222091 268f45cc-cd09-0410-ab3c-d52691b4dbfc

47 files changed:
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/PAL/ChangeLog
Source/WebCore/PAL/pal/Logger.h
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLMediaElement.h
Source/WebCore/html/track/AudioTrack.cpp
Source/WebCore/html/track/AudioTrack.h
Source/WebCore/html/track/DataCue.cpp
Source/WebCore/html/track/DataCue.h
Source/WebCore/html/track/InbandDataTextTrack.cpp
Source/WebCore/html/track/InbandDataTextTrack.h
Source/WebCore/html/track/InbandGenericTextTrack.cpp
Source/WebCore/html/track/InbandGenericTextTrack.h
Source/WebCore/html/track/InbandTextTrack.cpp
Source/WebCore/html/track/InbandTextTrack.h
Source/WebCore/html/track/InbandWebVTTTextTrack.cpp
Source/WebCore/html/track/InbandWebVTTTextTrack.h
Source/WebCore/html/track/LoadableTextTrack.cpp
Source/WebCore/html/track/LoadableTextTrack.h
Source/WebCore/html/track/TextTrack.cpp
Source/WebCore/html/track/TextTrack.h
Source/WebCore/html/track/TextTrackCue.cpp
Source/WebCore/html/track/TextTrackCue.h
Source/WebCore/html/track/TextTrackCueGeneric.cpp
Source/WebCore/html/track/TextTrackCueGeneric.h
Source/WebCore/html/track/TrackBase.cpp
Source/WebCore/html/track/TrackBase.h
Source/WebCore/html/track/VTTCue.cpp
Source/WebCore/html/track/VTTCue.h
Source/WebCore/html/track/VideoTrack.cpp
Source/WebCore/html/track/VideoTrack.h
Source/WebCore/platform/graphics/AudioTrackPrivate.h
Source/WebCore/platform/graphics/InbandTextTrackPrivate.h
Source/WebCore/platform/graphics/InbandTextTrackPrivateClient.h
Source/WebCore/platform/graphics/TrackPrivateBase.cpp [new file with mode: 0644]
Source/WebCore/platform/graphics/TrackPrivateBase.h
Source/WebCore/platform/graphics/VideoTrackPrivate.h
Source/WebCore/platform/graphics/avfoundation/AVTrackPrivateAVFObjCImpl.mm
Source/WebCore/platform/graphics/avfoundation/InbandMetadataTextTrackPrivateAVF.cpp
Source/WebCore/platform/graphics/avfoundation/InbandMetadataTextTrackPrivateAVF.h
Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp
Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.h
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm
Source/WebCore/platform/mediastream/mac/AudioTrackPrivateMediaStreamCocoa.cpp
Source/WebCore/platform/mediastream/mac/AudioTrackPrivateMediaStreamCocoa.h

index 4e602fd..18d8645 100644 (file)
@@ -3426,6 +3426,7 @@ if (ENABLE_VIDEO_TRACK)
         loader/cache/CachedTextTrack.cpp
 
         platform/graphics/TextTrackRepresentation.cpp
+        platform/graphics/TrackPrivateBase.cpp
     )
 endif ()
 
index 7fdb2a8..17ed0c3 100644 (file)
@@ -1,3 +1,113 @@
+2017-09-15  Eric Carlson  <eric.carlson@apple.com>
+
+        Switch text tracks to release logging
+        https://bugs.webkit.org/show_bug.cgi?id=176809
+        <rdar://problem/34397605>
+
+        Reviewed by Jer Noble.
+
+        Make all track objects use the same logger and log identifier as the media element they
+        "belong" to. Convert all track logging from debug-only to release logging.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::updateActiveTextTrackCues):
+        * html/HTMLMediaElement.h:
+        * html/track/AudioTrack.cpp:
+        (WebCore::AudioTrack::AudioTrack):
+        (WebCore::AudioTrack::setPrivate):
+        (WebCore::AudioTrack::setMediaElement):
+        * html/track/AudioTrack.h:
+        * html/track/DataCue.cpp:
+        (WebCore::DataCue::toString const):
+        * html/track/DataCue.h:
+        (PAL::LogArgument<WebCore::DataCue>::toString):
+        * html/track/InbandDataTextTrack.cpp:
+        (WebCore::InbandDataTextTrack::addDataCue):
+        (WebCore::InbandDataTextTrack::updateDataCue):
+        (WebCore::InbandDataTextTrack::removeDataCue):
+        * html/track/InbandDataTextTrack.h:
+        * html/track/InbandGenericTextTrack.cpp:
+        (WebCore::InbandGenericTextTrack::addGenericCue):
+        (WebCore::InbandGenericTextTrack::removeGenericCue):
+        (WebCore::InbandGenericTextTrack::newCuesParsed):
+        (WebCore::InbandGenericTextTrack::fileFailedToParse):
+        * html/track/InbandGenericTextTrack.h:
+        * html/track/InbandTextTrack.cpp:
+        (WebCore::InbandTextTrack::InbandTextTrack):
+        (WebCore::InbandTextTrack::setMediaElement):
+        * html/track/InbandTextTrack.h:
+        * html/track/InbandWebVTTTextTrack.cpp:
+        (WebCore::InbandWebVTTTextTrack::newCuesParsed):
+        (WebCore::InbandWebVTTTextTrack::fileFailedToParse):
+        * html/track/InbandWebVTTTextTrack.h:
+        * html/track/LoadableTextTrack.cpp:
+        (WebCore::LoadableTextTrack::newCuesAvailable):
+        (WebCore::LoadableTextTrack::cueLoadingCompleted):
+        * html/track/LoadableTextTrack.h:
+        * html/track/TextTrack.cpp:
+        (WebCore::TextTrack::addCue):
+        (WebCore::TextTrack::removeCue):
+        (WebCore::TextTrack::setLanguage):
+        * html/track/TextTrack.h:
+        * html/track/TextTrackCue.cpp:
+        (WebCore::TextTrackCue::toString const):
+        * html/track/TextTrackCue.h:
+        (PAL::LogArgument<WebCore::TextTrackCue>::toString):
+        * html/track/TextTrackCueGeneric.cpp:
+        (WebCore::TextTrackCueGeneric::setFontSize):
+        (WebCore::TextTrackCueGeneric::toString const):
+        * html/track/TextTrackCueGeneric.h:
+        (PAL::LogArgument<WebCore::TextTrackCueGeneric>::toString):
+        * html/track/TrackBase.cpp:
+        (WebCore::nextLogIdentifier):
+        (WebCore::nullLogger):
+        (WebCore::TrackBase::TrackBase):
+        (WebCore::TrackBase::setMediaElement):
+        (WebCore::TrackBase::logChannel const):
+        (WebCore::TrackBase::~TrackBase): Deleted.
+        * html/track/TrackBase.h:
+        (WebCore::TrackBase::setMediaElement): Deleted.
+        * html/track/VTTCue.cpp:
+        (WebCore::VTTCue::setFontSize):
+        (WebCore::VTTCue::toString const):
+        * html/track/VTTCue.h:
+        (PAL::LogArgument<WebCore::VTTCue>::toString):
+        * html/track/VideoTrack.cpp:
+        (WebCore::VideoTrack::VideoTrack):
+        (WebCore::VideoTrack::setPrivate):
+        (WebCore::VideoTrack::setMediaElement):
+        * html/track/VideoTrack.h:
+        * platform/graphics/AudioTrackPrivate.h:
+        * platform/graphics/InbandTextTrackPrivate.h:
+        (WebCore::InbandTextTrackPrivate::setClient):
+        * platform/graphics/InbandTextTrackPrivateClient.h:
+        (WebCore::GenericCueData::toString const):
+        (PAL::LogArgument<WebCore::GenericCueData>::toString):
+        * platform/graphics/TrackPrivateBase.cpp: Added.
+        (WebCore::TrackPrivateBase::setLogger):
+        (WebCore::TrackPrivateBase::logChannel const):
+        * platform/graphics/TrackPrivateBase.h:
+        * platform/graphics/VideoTrackPrivate.h:
+        * platform/graphics/avfoundation/AVTrackPrivateAVFObjCImpl.mm:
+        * platform/graphics/avfoundation/InbandMetadataTextTrackPrivateAVF.cpp:
+        (WebCore::InbandMetadataTextTrackPrivateAVF::updatePendingCueEndTimes):
+        (WebCore::InbandMetadataTextTrackPrivateAVF::flushPartialCues):
+        * platform/graphics/avfoundation/InbandMetadataTextTrackPrivateAVF.h:
+        * platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp:
+        (WebCore::InbandTextTrackPrivateAVF::processAttributedStrings):
+        (WebCore::InbandTextTrackPrivateAVF::removeCompletedCues):
+        (WebCore::InbandTextTrackPrivateAVF::resetCueValues):
+        (WebCore::InbandTextTrackPrivateAVF::processNativeSamples):
+        (WebCore::InbandTextTrackPrivateAVF::readNativeSampleBuffer):
+        * platform/graphics/avfoundation/InbandTextTrackPrivateAVF.h:
+        * platform/graphics/avfoundation/objc/AudioTrackPrivateAVFObjC.mm:
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+        (-[WebCoreAVFMovieObserver observeValueForKeyPath:ofObject:change:context:]):
+        * platform/mediastream/mac/AudioTrackPrivateMediaStreamCocoa.cpp:
+        (WebCore::AudioTrackPrivateMediaStreamCocoa::createAudioUnit):
+        * platform/mediastream/mac/AudioTrackPrivateMediaStreamCocoa.h:
+
 2017-09-15  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [Harfbuzz] Material icons not rendered correctly when using the web font
index e486706..a1f09f8 100644 (file)
@@ -1,3 +1,15 @@
+2017-09-15  Eric Carlson  <eric.carlson@apple.com>
+
+        Switch text tracks to release logging
+        https://bugs.webkit.org/show_bug.cgi?id=176809
+        <rdar://problem/34397605>
+
+        Reviewed by Jer Noble.
+
+        * pal/Logger.h:
+        (PAL::LogArgument::toString):
+        (PAL::Logger::willLog const):
+
 2017-09-14  Dan Bernstein  <mitz@apple.com>
 
         Fixed building with the Apple internal macOS 10.12 SDK.
index 024f425..61c52fe 100644 (file)
@@ -41,10 +41,12 @@ struct LogArgument {
     template<typename U = T> static typename std::enable_if<std::is_same<U, int>::value, String>::type toString(int argument) { return String::number(argument); }
     template<typename U = T> static typename std::enable_if<std::is_same<U, unsigned>::value, String>::type toString(unsigned argument) { return String::number(argument); }
     template<typename U = T> static typename std::enable_if<std::is_same<U, unsigned long>::value, String>::type toString(unsigned long argument) { return String::number(argument); }
+    template<typename U = T> static typename std::enable_if<std::is_same<U, long>::value, String>::type toString(long argument) { return String::number(argument); }
     template<typename U = T> static typename std::enable_if<std::is_same<U, float>::value, String>::type toString(float argument) { return String::number(argument); }
     template<typename U = T> static typename std::enable_if<std::is_same<U, double>::value, String>::type toString(double argument) { return String::number(argument); }
     template<typename U = T> static typename std::enable_if<std::is_same<typename std::remove_reference<U>::type, AtomicString>::value, String>::type toString(AtomicString argument) { return argument.string(); }
     template<typename U = T> static typename std::enable_if<std::is_same<typename std::remove_reference<U>::type, String>::value, String>::type toString(String argument) { return argument; }
+    template<typename U = T> static typename std::enable_if<std::is_same<typename std::remove_reference<U>::type, StringBuilder*>::value, String>::type toString(StringBuilder* argument) { return argument->toString(); }
     template<typename U = T> static typename std::enable_if<std::is_same<U, const char*>::value, String>::type toString(const char* argument) { return String(argument); }
     template<size_t length> static String toString(const char (&argument)[length]) { return String(argument); }
 };
index f703817..23b0f0d 100644 (file)
                073B87671E4385AC0071C0EC /* AudioSampleBufferList.h in Headers */ = {isa = PBXBuildFile; fileRef = 073B87631E43859D0071C0EC /* AudioSampleBufferList.h */; };
                073B87681E4385AC0071C0EC /* AudioSampleDataSource.mm in Sources */ = {isa = PBXBuildFile; fileRef = 073B87641E43859D0071C0EC /* AudioSampleDataSource.mm */; };
                073B87691E4385AC0071C0EC /* AudioSampleDataSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 073B87651E43859D0071C0EC /* AudioSampleDataSource.h */; };
+               073BDC051F68436100EE34ED /* TrackPrivateBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 076E11BE1F683E0D00177395 /* TrackPrivateBase.cpp */; };
                073BE34017D17E01002BD431 /* JSNavigatorUserMedia.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 073BE33E17D17E01002BD431 /* JSNavigatorUserMedia.cpp */; };
                073BE34117D17E01002BD431 /* JSNavigatorUserMedia.h in Headers */ = {isa = PBXBuildFile; fileRef = 073BE33F17D17E01002BD431 /* JSNavigatorUserMedia.h */; settings = {ATTRIBUTES = (Private, ); }; };
                073BE34E17D180B2002BD431 /* RTCSessionDescriptionDescriptor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07221BAB17CF0AD400848E51 /* RTCSessionDescriptionDescriptor.cpp */; };
                07638A981884487200E15A1B /* MediaSessionManagerIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MediaSessionManagerIOS.mm; sourceTree = "<group>"; };
                076970841463AD8700F502CF /* TextTrackList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextTrackList.cpp; sourceTree = "<group>"; };
                076970851463AD8700F502CF /* TextTrackList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextTrackList.h; sourceTree = "<group>"; };
+               076E11BE1F683E0D00177395 /* TrackPrivateBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TrackPrivateBase.cpp; sourceTree = "<group>"; };
                076EC1321E44F2CB00E5D813 /* AudioTrackPrivateMediaStreamCocoa.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AudioTrackPrivateMediaStreamCocoa.cpp; sourceTree = "<group>"; };
                076F0D0912B8192700C26AA4 /* MediaPlayerPrivateAVFoundation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaPlayerPrivateAVFoundation.cpp; sourceTree = "<group>"; };
                076F0D0A12B8192700C26AA4 /* MediaPlayerPrivateAVFoundation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaPlayerPrivateAVFoundation.h; sourceTree = "<group>"; };
                                CD1E7346167BC78E009A885D /* TextTrackRepresentation.cpp */,
                                CDD1E525167BA56400CE820B /* TextTrackRepresentation.h */,
                                1AF89A411518FDEA00E547B5 /* TiledBacking.h */,
+                               076E11BE1F683E0D00177395 /* TrackPrivateBase.cpp */,
                                BE913D7F181EF8E500DCB09E /* TrackPrivateBase.h */,
                                E4AFCFA40DAF29A300F5F55C /* UnitBezier.h */,
                                BEF29EEA1715DD0900C4B4C9 /* VideoTrackPrivate.h */,
                                E12DE7171E4B749C00F9ACCF /* GridTrackSizingAlgorithm.cpp in Sources */,
                                414C25D71E9EFEDE00BEE141 /* H264VideoToolBoxEncoder.mm in Sources */,
                                F55B3DBF1251F12D003EF269 /* HiddenInputType.cpp in Sources */,
+                               073BDC051F68436100EE34ED /* TrackPrivateBase.cpp in Sources */,
                                515BE19B1D54F6C100DD7C68 /* HIDGamepad.cpp in Sources */,
                                515BE19D1D54F6C100DD7C68 /* HIDGamepadProvider.cpp in Sources */,
                                BC94D1530C275C8B006BC617 /* History.cpp in Sources */,
index dcf07e9..368cc4b 100644 (file)
@@ -1660,8 +1660,6 @@ void HTMLMediaElement::updateActiveTextTrackCues(const MediaTime& movieTime)
     if (ignoreTrackDisplayUpdateRequests())
         return;
 
-    DEBUG_LOG(LOGIDENTIFIER);
-
     // 1 - Let current cues be a list of cues, initialized to contain all the
     // cues of all the hidden, showing, or showing by default text tracks of the
     // media element (not the disabled ones) whose start times are less than or
index 65dcae4..7f338ad 100644 (file)
@@ -36,6 +36,7 @@
 #include "MediaCanStartListener.h"
 #include "MediaControllerInterface.h"
 #include "MediaElementSession.h"
+#include "MediaPlayer.h"
 #include "MediaProducer.h"
 #include "VisibilityChangeClient.h"
 #include <pal/LoggerHelper.h>
@@ -87,7 +88,6 @@ class MediaControlsHost;
 class MediaElementAudioSourceNode;
 class MediaError;
 class MediaKeys;
-class MediaPlayer;
 class MediaResourceLoader;
 class MediaSession;
 class MediaSource;
@@ -141,7 +141,7 @@ class HTMLMediaElement
     , private CDMClient
 #endif
 #if !RELEASE_LOG_DISABLED
-    , private PAL::LoggerHelper
+    , public PAL::LoggerHelper
 #endif
 {
 public:
@@ -538,6 +538,11 @@ public:
 
     bool supportsSeeking() const override;
 
+#if !RELEASE_LOG_DISABLED
+    const PAL::Logger& logger() const final { return *m_logger.get(); }
+    const void* logIdentifier() const final { return reinterpret_cast<const void*>(m_logIdentifier); }
+#endif
+
 protected:
     HTMLMediaElement(const QualifiedName&, Document&, bool createdByParser);
     virtual ~HTMLMediaElement();
@@ -895,9 +900,7 @@ private:
     void seekToPlaybackPositionEndedTimerFired();
 
 #if !RELEASE_LOG_DISABLED
-    const PAL::Logger& logger() const final { return *m_logger.get(); }
     const char* logClassName() const final { return "HTMLMediaElement"; }
-    const void* logIdentifier() const final { return reinterpret_cast<const void*>(m_logIdentifier); }
     WTFLogChannel& logChannel() const final;
 
     const void* mediaPlayerLogIdentifier() final { return logIdentifier(); }
index eeb0553..abee923 100644 (file)
@@ -77,11 +77,14 @@ const AtomicString& AudioTrack::commentaryKeyword()
 
 AudioTrack::AudioTrack(AudioTrackClient& client, AudioTrackPrivate& trackPrivate)
     : MediaTrackBase(MediaTrackBase::AudioTrack, trackPrivate.id(), trackPrivate.label(), trackPrivate.language())
-    , m_enabled(trackPrivate.enabled())
     , m_client(&client)
     , m_private(trackPrivate)
+    , m_enabled(trackPrivate.enabled())
 {
     m_private->setClient(this);
+#if !RELEASE_LOG_DISABLED
+    m_private->setLogger(logger(), logIdentifier());
+#endif
     updateKindFromPrivate();
 }
 
@@ -99,6 +102,9 @@ void AudioTrack::setPrivate(AudioTrackPrivate& trackPrivate)
     m_private = trackPrivate;
     m_private->setEnabled(m_enabled);
     m_private->setClient(this);
+#if !RELEASE_LOG_DISABLED
+    m_private->setLogger(logger(), logIdentifier());
+#endif
 
     updateKindFromPrivate();
 }
@@ -187,6 +193,14 @@ void AudioTrack::updateKindFromPrivate()
     }
 }
 
+void AudioTrack::setMediaElement(HTMLMediaElement* element)
+{
+    TrackBase::setMediaElement(element);
+#if !RELEASE_LOG_DISABLED
+    m_private->setLogger(logger(), logIdentifier());
+#endif
+}
+
 } // namespace WebCore
 
 #endif
index 07c7794..bce013f 100644 (file)
@@ -65,6 +65,7 @@ public:
     size_t inbandTrackIndex() const;
 
     void setPrivate(AudioTrackPrivate&);
+    void setMediaElement(HTMLMediaElement*) override;
 
 private:
     AudioTrack(AudioTrackClient&, AudioTrackPrivate&);
@@ -82,10 +83,13 @@ private:
 
     void updateKindFromPrivate();
 
-    bool m_enabled;
-    AudioTrackClient* m_client;
+#if !RELEASE_LOG_DISABLED
+    const char* logClassName() const final { return "AudioTrack"; }
+#endif
 
+    AudioTrackClient* m_client { nullptr };
     Ref<AudioTrackPrivate> m_private;
+    bool m_enabled { false };
 };
 
 } // namespace WebCore
index 3bc272a..7807cb4 100644 (file)
@@ -188,6 +188,18 @@ JSValue DataCue::valueOrNull() const
     return jsNull();
 }
 
+String DataCue::toString() const
+{
+    StringBuilder builder;
+
+    builder.append(TextTrackCue::toString());
+
+    builder.appendLiteral(", type = ");
+    builder.append(m_type);
+
+    return builder.toString();
+}
+
 } // namespace WebCore
 
 #endif
index ea32bcc..940c25d 100644 (file)
@@ -87,6 +87,8 @@ public:
     bool cueContentsMatch(const TextTrackCue&) const override;
     bool doesExtendCue(const TextTrackCue&) const override;
 
+    String toString() const override;
+
 private:
     DataCue(ScriptExecutionContext&, const MediaTime& start, const MediaTime& end, ArrayBuffer&, const String&);
     DataCue(ScriptExecutionContext&, const MediaTime& start, const MediaTime& end, const void*, unsigned);
@@ -106,4 +108,19 @@ const DataCue* toDataCue(const TextTrackCue*);
 
 } // namespace WebCore
 
+namespace PAL {
+
+template<typename Type>
+struct LogArgument;
+
+template <>
+struct LogArgument<WebCore::DataCue> {
+    static String toString(const WebCore::DataCue& cue)
+    {
+        return cue.toString();
+    }
+};
+
+}
+
 #endif
index d2d4a01..3973ee0 100644 (file)
@@ -32,7 +32,6 @@
 #include "DataCue.h"
 #include "HTMLMediaElement.h"
 #include "InbandTextTrackPrivate.h"
-#include "Logging.h"
 
 namespace WebCore {
 
@@ -64,7 +63,7 @@ void InbandDataTextTrack::addDataCue(const MediaTime& start, const MediaTime& en
 
     auto cue = DataCue::create(*scriptExecutionContext(), start, end, platformValue.copyRef(), type);
     if (hasCue(cue.ptr(), TextTrackCue::IgnoreDuration)) {
-        LOG(Media, "InbandDataTextTrack::addDataCue ignoring already added cue: start=%s, end=%s\n", toString(cue->startTime()).utf8().data(), toString(cue->endTime()).utf8().data());
+        INFO_LOG(LOGIDENTIFIER, "ignoring already added cue: ", cue.get());
         return;
     }
 
@@ -73,6 +72,8 @@ void InbandDataTextTrack::addDataCue(const MediaTime& start, const MediaTime& en
         m_incompleteCueMap.add(WTFMove(platformValue), cue.copyRef());
     }
 
+    INFO_LOG(LOGIDENTIFIER, cue.get());
+
     addCue(WTFMove(cue));
 }
 
@@ -90,7 +91,7 @@ void InbandDataTextTrack::updateDataCue(const MediaTime& start, const MediaTime&
     else
         m_incompleteCueMap.remove(&platformValue);
 
-    LOG(Media, "InbandDataTextTrack::updateDataCue: was start=%s, end=%s, will be start=%s, end=%s\n", toString(cue->startTime()).utf8().data(), toString(cue->endTime()).utf8().data(), toString(start).utf8().data(), toString(end).utf8().data());
+    INFO_LOG(LOGIDENTIFIER, "was start = ", cue->startMediaTime(), ", end = ", cue->endMediaTime(), ", will be start = ", start, ", end = ", end);
 
     cue->setStartTime(start);
     cue->setEndTime(end);
@@ -101,7 +102,7 @@ void InbandDataTextTrack::updateDataCue(const MediaTime& start, const MediaTime&
 void InbandDataTextTrack::removeDataCue(const MediaTime&, const MediaTime&, SerializedPlatformRepresentation& platformValue)
 {
     if (auto cue = m_incompleteCueMap.take(&platformValue)) {
-        LOG(Media, "InbandDataTextTrack::removeDataCue removing cue: start=%s, end=%s\n", toString(cue->startTime()).utf8().data(), toString(cue->endTime()).utf8().data());
+        INFO_LOG(LOGIDENTIFIER, "removing: ", *cue);
         InbandTextTrack::removeCue(*cue);
     }
 }
index 67aeb6d..0fb4510 100644 (file)
@@ -44,6 +44,10 @@ private:
 
     void addDataCue(const MediaTime& start, const MediaTime& end, const void*, unsigned) final;
 
+#if !RELEASE_LOG_DISABLED
+    const char* logClassName() const final { return "DataCue"; }
+#endif
+
 #if ENABLE(DATACUE_VALUE)
     void addDataCue(const MediaTime& start, const MediaTime& end, Ref<SerializedPlatformRepresentation>&&, const String&) final;
     void updateDataCue(const MediaTime& start, const MediaTime& end, SerializedPlatformRepresentation&) final;
index 8065c88..df57ece 100644 (file)
@@ -127,11 +127,11 @@ void InbandGenericTextTrack::addGenericCue(GenericCueData& cueData)
     auto cue = TextTrackCueGeneric::create(*scriptExecutionContext(), cueData.startTime(), cueData.endTime(), cueData.content());
     updateCueFromCueData(cue.get(), cueData);
     if (hasCue(cue.ptr(), TextTrackCue::IgnoreDuration)) {
-        LOG(Media, "InbandGenericTextTrack::addGenericCue ignoring already added cue: start=%s, end=%s, content=\"%s\"\n", toString(cueData.startTime()).utf8().data(), toString(cueData.endTime()).utf8().data(), cueData.content().utf8().data());
+        DEBUG_LOG(LOGIDENTIFIER, "ignoring already added cue: ", cue.get());
         return;
     }
 
-    LOG(Media, "InbandGenericTextTrack::addGenericCue added cue: start=%.2f, end=%.2f, content=\"%s\"\n", cueData.startTime().toDouble(), cueData.endTime().toDouble(), cueData.content().utf8().data());
+    DEBUG_LOG(LOGIDENTIFIER, "added cue: ", cue.get());
 
     if (cueData.status() != GenericCueData::Complete)
         m_cueMap.add(cueData, cue);
@@ -155,11 +155,11 @@ void InbandGenericTextTrack::removeGenericCue(GenericCueData& cueData)
 {
     auto* cue = m_cueMap.find(cueData);
     if (cue) {
-        LOG(Media, "InbandGenericTextTrack::removeGenericCue removing cue: start=%s, end=%s, content=\"%s\"\n",  toString(cueData.startTime()).utf8().data(), toString(cueData.endTime()).utf8().data(), cueData.content().utf8().data());
+        DEBUG_LOG(LOGIDENTIFIER, *cue);
         removeCue(*cue);
-    } else {
-        LOG(Media, "InbandGenericTextTrack::removeGenericCue UNABLE to find cue: start=%.2f, end=%.2f, content=\"%s\"\n", cueData.startTime().toDouble(), cueData.endTime().toDouble(), cueData.content().utf8().data());
-    }
+    } else
+        DEBUG_LOG(LOGIDENTIFIER, "UNABLE to find cue: ", *cue);
+
 }
 
 ExceptionOr<void> InbandGenericTextTrack::removeCue(TextTrackCue& cue)
@@ -196,9 +196,12 @@ void InbandGenericTextTrack::newCuesParsed()
         auto vttCue = VTTCue::create(*scriptExecutionContext(), *cueData);
 
         if (hasCue(vttCue.ptr(), TextTrackCue::IgnoreDuration)) {
-            LOG(Media, "InbandGenericTextTrack::newCuesParsed ignoring already added cue: start=%.2f, end=%.2f, content=\"%s\"\n", vttCue->startTime(), vttCue->endTime(), vttCue->text().utf8().data());
+            DEBUG_LOG(LOGIDENTIFIER, "ignoring already added cue: ", vttCue.get());
             return;
         }
+
+        DEBUG_LOG(LOGIDENTIFIER, vttCue.get());
+
         addCue(WTFMove(vttCue));
     }
 }
@@ -216,7 +219,7 @@ void InbandGenericTextTrack::newRegionsParsed()
 
 void InbandGenericTextTrack::fileFailedToParse()
 {
-    LOG(Media, "Error parsing WebVTT stream.");
+    ERROR_LOG(LOGIDENTIFIER);
 }
 
 } // namespace WebCore
index e5feb25..d6d0be0 100644 (file)
@@ -74,6 +74,10 @@ private:
     void newRegionsParsed() final;
     void fileFailedToParse() final;
 
+#if !RELEASE_LOG_DISABLED
+    const char* logClassName() const final { return "InbandGenericTextTrack"; }
+#endif
+
     GenericTextTrackCueMap m_cueMap;
     std::unique_ptr<WebVTTParser> m_webVTTParser;
 };
index 43241a2..3378ed8 100644 (file)
@@ -54,6 +54,9 @@ InbandTextTrack::InbandTextTrack(ScriptExecutionContext& context, TextTrackClien
     : TextTrack(&context, &client, emptyAtom(), trackPrivate.id(), trackPrivate.label(), trackPrivate.language(), InBand)
     , m_private(trackPrivate)
 {
+#if !RELEASE_LOG_DISABLED
+    m_private->setLogger(logger(), logIdentifier());
+#endif
     m_private->setClient(this);
     updateKindFromPrivate();
 }
@@ -191,6 +194,15 @@ MediaTime InbandTextTrack::startTimeVariance() const
     return m_private->startTimeVariance();
 }
 
+void InbandTextTrack::setMediaElement(HTMLMediaElement* element)
+{
+    TrackBase::setMediaElement(element);
+#if !RELEASE_LOG_DISABLED
+    m_private->setLogger(logger(), logIdentifier());
+#endif
+}
+
+
 } // namespace WebCore
 
 #endif
index 6cf2687..ee5f2b9 100644 (file)
@@ -48,6 +48,7 @@ public:
     AtomicString inBandMetadataTrackDispatchType() const override;
 
     void setPrivate(InbandTextTrackPrivate&);
+    void setMediaElement(HTMLMediaElement*) override;
 
 protected:
     InbandTextTrack(ScriptExecutionContext&, TextTrackClient&, InbandTextTrackPrivate&);
index d0fae4e..ab3f198 100644 (file)
@@ -74,9 +74,12 @@ void InbandWebVTTTextTrack::newCuesParsed()
     for (auto& cueData : cues) {
         auto vttCue = VTTCue::create(*scriptExecutionContext(), *cueData);
         if (hasCue(vttCue.ptr(), TextTrackCue::IgnoreDuration)) {
-            LOG(Media, "InbandWebVTTTextTrack::newCuesParsed ignoring already added cue: start=%.2f, end=%.2f, content=\"%s\"\n", vttCue->startTime(), vttCue->endTime(), vttCue->text().utf8().data());
+            DEBUG_LOG(LOGIDENTIFIER, "ignoring already added cue: ", vttCue.get());
             return;
         }
+
+        DEBUG_LOG(LOGIDENTIFIER, vttCue.get());
+
         addCue(WTFMove(vttCue));
     }
 }
@@ -93,7 +96,7 @@ void InbandWebVTTTextTrack::newRegionsParsed()
 
 void InbandWebVTTTextTrack::fileFailedToParse()
 {
-    LOG(Media, "Error parsing WebVTT stream.");
+    ERROR_LOG(LOGIDENTIFIER, "Error parsing WebVTT stream.");
 }
 
 } // namespace WebCore
index 21d9134..6293036 100644 (file)
@@ -49,6 +49,10 @@ private:
     void newRegionsParsed() final;
     void fileFailedToParse() final;
 
+#if !RELEASE_LOG_DISABLED
+    const char* logClassName() const final { return "InbandWebVTTTextTrack"; }
+#endif
+
     std::unique_ptr<WebVTTParser> m_webVTTParser;
 };
 
index 67e2da2..5d7f0bf 100644 (file)
@@ -31,6 +31,7 @@
 
 #include "HTMLTrackElement.h"
 #include "TextTrackCueList.h"
+#include "VTTCue.h"
 #include "VTTRegionList.h"
 
 namespace WebCore {
@@ -97,6 +98,7 @@ void LoadableTextTrack::newCuesAvailable(TextTrackLoader* loader)
 
     for (auto& newCue : newCues) {
         newCue->setTrack(this);
+        DEBUG_LOG(LOGIDENTIFIER, *toVTTCue(newCue.get()));
         m_cues->add(newCue.releaseNonNull());
     }
 
@@ -111,6 +113,8 @@ void LoadableTextTrack::cueLoadingCompleted(TextTrackLoader* loader, bool loadin
     if (!m_trackElement)
         return;
 
+    INFO_LOG(LOGIDENTIFIER);
+
     m_trackElement->didCompleteLoad(loadingFailed ? HTMLTrackElement::Failure : HTMLTrackElement::Success);
 }
 
index ba9c76f..f012bc0 100644 (file)
@@ -63,6 +63,10 @@ private:
 
     void loadTimerFired();
 
+#if !RELEASE_LOG_DISABLED
+    const char* logClassName() const override { return "LoadableTextTrack"; }
+#endif
+
     HTMLTrackElement* m_trackElement;
     Timer m_loadTimer;
     std::unique_ptr<TextTrackLoader> m_loader;
index 94fc661..2519e8c 100644 (file)
@@ -34,6 +34,7 @@
 
 #if ENABLE(VIDEO_TRACK)
 
+#include "Document.h"
 #include "Event.h"
 #include "HTMLMediaElement.h"
 #include "SourceBuffer.h"
@@ -316,7 +317,7 @@ ExceptionOr<void> TextTrack::addCue(Ref<TextTrackCue>&& cue)
     // 2. Add cue to the method's TextTrack object's text track's text track list of cues.
     cue->setTrack(this);
     ensureTextTrackCueList().add(cue.copyRef());
-    
+
     if (m_client)
         m_client->textTrackAddCue(*this, cue);
 
@@ -336,6 +337,8 @@ ExceptionOr<void> TextTrack::removeCue(TextTrackCue& cue)
     if (!m_cues)
         return Exception { InvalidStateError };
 
+    DEBUG_LOG(LOGIDENTIFIER, cue);
+
     // 2. Remove cue from the method's TextTrack object's text track's text track list of cues.
     m_cues->remove(cue);
     cue.setIsActive(false);
@@ -542,7 +545,6 @@ bool TextTrack::containsOnlyForcedSubtitles() const
 }
 
 #if ENABLE(MEDIA_SOURCE)
-
 void TextTrack::setLanguage(const AtomicString& language)
 {
     // 11.1 language, on setting:
@@ -564,7 +566,6 @@ void TextTrack::setLanguage(const AtomicString& language)
     if (mediaElement())
         mediaElement()->textTracks().scheduleChangeEvent();
 }
-
 #endif
 
 } // namespace WebCore
index b41026f..2ce17a5 100644 (file)
@@ -147,6 +147,10 @@ public:
 protected:
     TextTrack(ScriptExecutionContext*, TextTrackClient*, const AtomicString& kind, const AtomicString& id, const AtomicString& label, const AtomicString& language, TextTrackType);
 
+#if !RELEASE_LOG_DISABLED
+    const char* logClassName() const override { return "TextTrack"; }
+#endif
+
     RefPtr<TextTrackCueList> m_cues;
 
 private:
index 666ace1..5e96806 100644 (file)
@@ -216,6 +216,35 @@ bool TextTrackCue::doesExtendCue(const TextTrackCue& cue) const
     return true;
 }
 
+String TextTrackCue::toString() const
+{
+    StringBuilder builder;
+
+    builder.appendLiteral("start = ");
+    builder.append(m_startTime.toString());
+
+    builder.appendLiteral(", end = ");
+    builder.append(m_endTime.toString());
+
+    const char* type = "Generic";
+    switch (cueType()) {
+    case TextTrackCue::Generic:
+        type = "Generic";
+        break;
+    case TextTrackCue::WebVTT:
+        type = "WebVTT";
+        break;
+    case TextTrackCue::Data:
+        type = "Data";
+        break;
+    }
+
+    builder.appendLiteral(", type = ");
+    builder.append(type);
+
+    return builder.toString();
+}
+
 } // namespace WebCore
 
 #endif
index 4907546..d902130 100644 (file)
@@ -84,6 +84,8 @@ public:
     void willChange();
     virtual void didChange();
 
+    virtual String toString() const;
+
     using RefCounted::ref;
     using RefCounted::deref;
 
@@ -119,4 +121,20 @@ private:
 
 } // namespace WebCore
 
+namespace PAL {
+
+template<typename Type>
+struct LogArgument;
+
+template <>
+struct LogArgument<WebCore::TextTrackCue> {
+    static String toString(const WebCore::TextTrackCue& cue)
+    {
+        return cue.toString();
+    }
+};
+
+
+}
+
 #endif
index e082b5f..321b041 100644 (file)
@@ -189,8 +189,6 @@ void TextTrackCueGeneric::setFontSize(int fontSize, const IntSize& videoSize, bo
     if (fontSizeMultiplier())
         size *= fontSizeMultiplier() / 100;
     displayTreeInternal().setInlineStyleProperty(CSSPropertyFontSize, lround(size), CSSPrimitiveValue::CSS_PX);
-
-    LOG(Media, "TextTrackCueGeneric::setFontSize - setting cue font size to %li", lround(size));
 }
 
 bool TextTrackCueGeneric::cueContentsMatch(const TextTrackCue& cue) const
@@ -267,7 +265,46 @@ bool TextTrackCueGeneric::isPositionedAbove(const TextTrackCue* that) const
     
     return VTTCue::isOrderedBefore(that);
 }
-    
+
+String TextTrackCueGeneric::toString() const
+{
+    StringBuilder builder;
+
+    builder.append(VTTCue::toString());
+
+    if (m_foregroundColor.isValid()) {
+        builder.appendLiteral(", foreground color = ");
+        builder.append(m_foregroundColor.serialized());
+    }
+
+    if (m_backgroundColor.isValid()) {
+        builder.appendLiteral(", background color = ");
+        builder.append(m_backgroundColor.serialized());
+    }
+
+    if (m_highlightColor.isValid()) {
+        builder.appendLiteral(", hilight color = ");
+        builder.append(m_highlightColor.serialized());
+    }
+
+    if (m_baseFontSizeRelativeToVideoHeight) {
+        builder.appendLiteral(", base font size relative to video height = ");
+        builder.appendNumber(m_baseFontSizeRelativeToVideoHeight);
+    }
+
+    if (m_fontSizeMultiplier) {
+        builder.appendLiteral(", font size multiplier = ");
+        builder.appendNumber(m_fontSizeMultiplier);
+    }
+
+    if (!m_fontName.isEmpty()) {
+        builder.appendLiteral(", font = ");
+        builder.append(m_fontName);
+    }
+
+    return builder.toString();
+}
+
 } // namespace WebCore
 
 #endif
index 6c281eb..266780b 100644 (file)
@@ -67,6 +67,8 @@ public:
 
     void setFontSize(int, const IntSize&, bool important) final;
 
+    String toString() const final;
+
 private:
     TextTrackCueGeneric(ScriptExecutionContext&, const MediaTime& start, const MediaTime& end, const String&);
     
@@ -92,4 +94,18 @@ private:
 
 } // namespace WebCore
 
+namespace PAL {
+
+template<typename Type>
+struct LogArgument;
+
+template <>
+struct LogArgument<WebCore::TextTrackCueGeneric> {
+    static String toString(const WebCore::TextTrackCueGeneric& cue)
+    {
+        return cue.toString();
+    }
+};
+
+}
 #endif
index 86819f5..7f5d448 100644 (file)
@@ -26,6 +26,7 @@
 #include "config.h"
 #include "TrackBase.h"
 
+#include "Logging.h"
 #include <wtf/Language.h>
 #include <wtf/text/StringBuilder.h>
 
@@ -37,6 +38,20 @@ namespace WebCore {
 
 static int s_uniqueId = 0;
 
+#if !RELEASE_LOG_DISABLED
+static const void* nextLogIdentifier()
+{
+    static uint64_t logIdentifier = cryptographicallyRandomNumber();
+    return reinterpret_cast<const void*>(++logIdentifier);
+}
+
+static RefPtr<PAL::Logger>& nullLogger()
+{
+    static NeverDestroyed<RefPtr<PAL::Logger>> logger;
+    return logger;
+}
+#endif
+
 TrackBase::TrackBase(Type type, const AtomicString& id, const AtomicString& label, const AtomicString& language)
     : m_uniqueId(++s_uniqueId)
     , m_id(id)
@@ -46,10 +61,16 @@ TrackBase::TrackBase(Type type, const AtomicString& id, const AtomicString& labe
 {
     ASSERT(type != BaseTrack);
     m_type = type;
-}
 
-TrackBase::~TrackBase()
-{
+#if !RELEASE_LOG_DISABLED
+    if (!nullLogger().get()) {
+        nullLogger() = PAL::Logger::create(this);
+        nullLogger()->setEnabled(this, false);
+    }
+
+    m_logger = nullLogger().get();
+    m_logIdentifier = nextLogIdentifier();
+#endif
 }
 
 Element* TrackBase::element()
@@ -57,6 +78,18 @@ Element* TrackBase::element()
     return m_mediaElement;
 }
 
+void TrackBase::setMediaElement(HTMLMediaElement* element)
+{
+    m_mediaElement = element;
+
+#if !RELEASE_LOG_DISABLED
+    if (element) {
+        m_logger = &element->logger();
+        m_logIdentifier = element->logIdentifier();
+    }
+#endif
+}
+
 // See: https://tools.ietf.org/html/bcp47#section-2.1
 static bool isValidBCP47LanguageTag(const String& languageTag)
 {
@@ -134,6 +167,13 @@ AtomicString TrackBase::validBCP47Language() const
     return m_validBCP47Language;
 }
 
+#if !RELEASE_LOG_DISABLED
+WTFLogChannel& TrackBase::logChannel() const
+{
+    return LogMedia;
+}
+#endif
+
 MediaTrackBase::MediaTrackBase(Type type, const AtomicString& id, const AtomicString& label, const AtomicString& language)
     : TrackBase(type, id, label, language)
 {
index 16d162a..213259d 100644 (file)
@@ -27,6 +27,8 @@
 
 #if ENABLE(VIDEO_TRACK)
 
+#include <pal/Logger.h>
+#include <pal/LoggerHelper.h>
 #include <wtf/text/AtomicString.h>
 
 namespace WebCore {
@@ -35,14 +37,19 @@ class Element;
 class HTMLMediaElement;
 class SourceBuffer;
 
-class TrackBase : public RefCounted<TrackBase> {
+class TrackBase
+    : public RefCounted<TrackBase>
+#if !RELEASE_LOG_DISABLED
+    , private PAL::LoggerHelper
+#endif
+{
 public:
-    virtual ~TrackBase();
+    virtual ~TrackBase() = default;
 
     enum Type { BaseTrack, TextTrack, AudioTrack, VideoTrack };
     Type type() const { return m_type; }
 
-    void setMediaElement(HTMLMediaElement* element) { m_mediaElement = element; }
+    virtual void setMediaElement(HTMLMediaElement*);
     HTMLMediaElement* mediaElement() { return m_mediaElement; }
     virtual Element* element();
 
@@ -67,6 +74,12 @@ public:
 
     virtual bool enabled() const = 0;
 
+#if !RELEASE_LOG_DISABLED
+    const PAL::Logger& logger() const final { ASSERT(m_logger); return *m_logger.get(); }
+    const void* logIdentifier() const final { return m_logIdentifier; }
+    WTFLogChannel& logChannel() const final;
+#endif
+
 protected:
     TrackBase(Type, const AtomicString& id, const AtomicString& label, const AtomicString& language);
 
@@ -83,6 +96,10 @@ private:
     AtomicString m_label;
     AtomicString m_language;
     AtomicString m_validBCP47Language;
+#if !RELEASE_LOG_DISABLED
+    RefPtr<const PAL::Logger> m_logger;
+    const void* m_logIdentifier;
+#endif
 };
 
 class MediaTrackBase : public TrackBase {
index 6a179e8..b85543f 100644 (file)
@@ -1156,8 +1156,6 @@ void VTTCue::setFontSize(int fontSize, const IntSize&, bool important)
 {
     if (!hasDisplayTree() || !fontSize)
         return;
-    
-    LOG(Media, "TextTrackCue::setFontSize - setting cue font size to %i", fontSize);
 
     m_displayTreeShouldChange = true;
     displayTreeInternal().setInlineStyleProperty(CSSPropertyFontSize, fontSize, CSSPrimitiveValue::CSS_PX, important);
@@ -1174,6 +1172,18 @@ const VTTCue* toVTTCue(const TextTrackCue* cue)
     return static_cast<const VTTCue*>(cue);
 }
 
+String VTTCue::toString() const
+{
+    StringBuilder builder;
+
+    builder.append(TextTrackCue::toString());
+
+    builder.appendLiteral(", content = ");
+    builder.append(text());
+
+    return builder.toString();
+}
+
 } // namespace WebCore
 
 #endif
index bedf384..97beb1a 100644 (file)
@@ -167,6 +167,8 @@ public:
 
     void didChange() override;
 
+    String toString() const override;
+
 protected:
     VTTCue(ScriptExecutionContext&, const MediaTime& start, const MediaTime& end, const String& content);
     VTTCue(ScriptExecutionContext&, const WebVTTCueData&);
@@ -227,4 +229,19 @@ const VTTCue* toVTTCue(const TextTrackCue*);
 
 } // namespace WebCore
 
+namespace PAL {
+
+template<typename Type>
+struct LogArgument;
+
+template <>
+struct LogArgument<WebCore::VTTCue> {
+    static String toString(const WebCore::VTTCue& cue)
+    {
+        return cue.toString();
+    }
+};
+
+}
+
 #endif
index dcbd2de..55daa80 100644 (file)
@@ -82,10 +82,13 @@ const AtomicString& VideoTrack::commentaryKeyword()
 
 VideoTrack::VideoTrack(VideoTrackClient& client, VideoTrackPrivate& trackPrivate)
     : MediaTrackBase(MediaTrackBase::VideoTrack, trackPrivate.id(), trackPrivate.label(), trackPrivate.language())
-    , m_selected(trackPrivate.selected())
     , m_client(&client)
     , m_private(trackPrivate)
+    , m_selected(trackPrivate.selected())
 {
+#if !RELEASE_LOG_DISABLED
+    m_private->setLogger(logger(), logIdentifier());
+#endif
     m_private->setClient(this);
     updateKindFromPrivate();
 }
@@ -103,6 +106,9 @@ void VideoTrack::setPrivate(VideoTrackPrivate& trackPrivate)
     m_private->setClient(nullptr);
     m_private = trackPrivate;
     m_private->setClient(this);
+#if !RELEASE_LOG_DISABLED
+    m_private->setLogger(logger(), logIdentifier());
+#endif
 
     m_private->setSelected(m_selected);
     updateKindFromPrivate();
@@ -237,6 +243,14 @@ void VideoTrack::updateKindFromPrivate()
     ASSERT_NOT_REACHED();
 }
 
+void VideoTrack::setMediaElement(HTMLMediaElement* element)
+{
+    TrackBase::setMediaElement(element);
+#if !RELEASE_LOG_DISABLED
+    m_private->setLogger(logger(), logIdentifier());
+#endif
+}
+
 } // namespace WebCore
 
 #endif
index ebee829..5cd36b3 100644 (file)
@@ -73,6 +73,7 @@ public:
     const MediaDescription& description() const;
 
     void setPrivate(VideoTrackPrivate&);
+    void setMediaElement(HTMLMediaElement*) override;
 
 private:
     VideoTrack(VideoTrackClient&, VideoTrackPrivate&);
@@ -92,10 +93,13 @@ private:
 
     void updateKindFromPrivate();
 
-    bool m_selected;
-    VideoTrackClient* m_client;
+#if !RELEASE_LOG_DISABLED
+    const char* logClassName() const final { return "VideoTrack"; }
+#endif
 
+    VideoTrackClient* m_client { nullptr };
     Ref<VideoTrackPrivate> m_private;
+    bool m_selected { false };
 };
 
 } // namespace WebCore
index 710d170..4769393 100644 (file)
@@ -62,6 +62,10 @@ public:
     enum Kind { Alternative, Description, Main, MainDesc, Translation, Commentary, None };
     virtual Kind kind() const { return None; }
 
+#if !RELEASE_LOG_DISABLED
+    const char* logClassName() const override { return "AudioTrackPrivate"; }
+#endif
+
 protected:
     AudioTrackPrivate() = default;
 
index 882db35..0cf0a0b 100644 (file)
@@ -29,6 +29,7 @@
 #if ENABLE(VIDEO_TRACK)
 
 #include "InbandTextTrackPrivateClient.h"
+#include <pal/Logger.h>
 
 namespace WebCore {
 
@@ -42,8 +43,8 @@ public:
     static RefPtr<InbandTextTrackPrivate> create(CueFormat format) { return adoptRef(new InbandTextTrackPrivate(format)); }
     virtual ~InbandTextTrackPrivate() { }
 
-    void setClient(InbandTextTrackPrivateClient* client) { m_client = client; }
     InbandTextTrackPrivateClient* client() const override { return m_client; }
+    void setClient(InbandTextTrackPrivateClient* client) { m_client = client; }
 
     enum Mode {
         Disabled,
@@ -78,6 +79,10 @@ public:
 
     CueFormat cueFormat() const { return m_format; }
 
+#if !RELEASE_LOG_DISABLED
+    const char* logClassName() const override { return "InbandTextTrackPrivate"; }
+#endif
+
 protected:
     InbandTextTrackPrivate(CueFormat format)
         : m_format(format)
index 9a11079..17b6fe3 100644 (file)
@@ -93,6 +93,8 @@ public:
 
     bool doesExtendCueData(const GenericCueData&) const;
 
+    String toString() const;
+
 private:
     GenericCueData() = default;
 
@@ -113,6 +115,102 @@ private:
     Status m_status { Uninitialized };
 };
 
+inline String GenericCueData::toString() const
+{
+    StringBuilder builder;
+
+    builder.appendLiteral("start = ");
+    builder.append(m_startTime.toString());
+
+    builder.appendLiteral(", end = ");
+    builder.append(m_endTime.toString());
+
+    const char* status;
+    switch (m_status) {
+    case GenericCueData::Uninitialized:
+        status = "Uninitialized";
+        break;
+    case GenericCueData::Partial:
+        status = "Partial";
+        break;
+    case GenericCueData::Complete:
+        status = "Complete";
+        break;
+    }
+    builder.appendLiteral(", status = ");
+    builder.append(status);
+
+    builder.appendLiteral(", id = ");
+    builder.append(m_id);
+
+    if (m_line > 0) {
+        builder.appendLiteral(", line = ");
+        builder.appendNumber(m_line);
+    }
+
+    if (m_size > 0) {
+        builder.appendLiteral(", size = ");
+        builder.appendNumber(m_size);
+    }
+
+    if (m_position > 0) {
+        builder.appendLiteral(", position = ");
+        builder.appendNumber(m_position);
+    }
+
+    if (m_align != None) {
+        const char* align;
+        switch (m_align) {
+        case GenericCueData::Start:
+            align = "Start";
+            break;
+        case GenericCueData::Middle:
+            align = "Middle";
+            break;
+        case GenericCueData::End:
+            align = "End";
+            break;
+        case GenericCueData::None:
+            align = "None";
+            break;
+        }
+        builder.appendLiteral(", align = ");
+        builder.append(align);
+    }
+
+    if (m_foregroundColor.isValid()) {
+        builder.appendLiteral(", foreground color = ");
+        builder.append(m_foregroundColor.serialized());
+    }
+
+    if (m_backgroundColor.isValid()) {
+        builder.appendLiteral(", background color = ");
+        builder.append(m_backgroundColor.serialized());
+    }
+
+    if (m_highlightColor.isValid()) {
+        builder.appendLiteral(", hilight color = ");
+        builder.append(m_highlightColor.serialized());
+    }
+
+    if (m_baseFontSize) {
+        builder.appendLiteral(", base font size = ");
+        builder.appendNumber(m_baseFontSize);
+    }
+
+    if (m_relativeFontSize) {
+        builder.appendLiteral(", relative font size = ");
+        builder.appendNumber(m_relativeFontSize);
+    }
+
+    if (!m_fontName.isEmpty()) {
+        builder.appendLiteral(", font = ");
+        builder.append(m_fontName);
+    }
+
+    return builder.toString();
+}
+
 inline bool GenericCueData::doesExtendCueData(const GenericCueData& other) const
 {
     if (m_relativeFontSize != other.m_relativeFontSize)
@@ -166,4 +264,19 @@ public:
 
 } // namespace WebCore
 
+namespace PAL {
+
+template<typename Type>
+struct LogArgument;
+
+template <>
+struct LogArgument<WebCore::GenericCueData> {
+    static String toString(const WebCore::GenericCueData& cue)
+    {
+        return cue.toString();
+    }
+};
+
+}
+
 #endif
diff --git a/Source/WebCore/platform/graphics/TrackPrivateBase.cpp b/Source/WebCore/platform/graphics/TrackPrivateBase.cpp
new file mode 100644 (file)
index 0000000..42a9bf3
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2017 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 met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "TrackPrivateBase.h"
+
+#if ENABLE(VIDEO_TRACK)
+
+#include "Logging.h"
+
+namespace WebCore {
+
+#if !RELEASE_LOG_DISABLED
+void TrackPrivateBase::setLogger(const PAL::Logger& logger, const void* logIdentifier)
+{
+    m_logger = &logger;
+    m_logIdentifier = logIdentifier;
+}
+
+WTFLogChannel& TrackPrivateBase::logChannel() const
+{
+    return LogMedia;
+}
+#endif
+
+} // namespace WebCore
+
+#endif
index 1921a85..9e1792a 100644 (file)
@@ -29,6 +29,8 @@
 
 #if ENABLE(VIDEO_TRACK)
 
+#include <pal/Logger.h>
+#include <pal/LoggerHelper.h>
 #include <wtf/MediaTime.h>
 #include <wtf/ThreadSafeRefCounted.h>
 #include <wtf/text/AtomicString.h>
@@ -44,7 +46,12 @@ public:
     virtual void willRemove() = 0;
 };
 
-class TrackPrivateBase : public ThreadSafeRefCounted<TrackPrivateBase> {
+class TrackPrivateBase
+    : public ThreadSafeRefCounted<TrackPrivateBase>
+#if !RELEASE_LOG_DISABLED
+    , private PAL::LoggerHelper
+#endif
+{
     WTF_MAKE_NONCOPYABLE(TrackPrivateBase);
     WTF_MAKE_FAST_ALLOCATED;
 public:
@@ -66,8 +73,20 @@ public:
             client->willRemove();
     }
 
+#if !RELEASE_LOG_DISABLED
+    void setLogger(const PAL::Logger&, const void*);
+    const PAL::Logger& logger() const final { ASSERT(m_logger); return *m_logger.get(); }
+    const void* logIdentifier() const final { return m_logIdentifier; }
+    WTFLogChannel& logChannel() const final;
+#endif
+
 protected:
     TrackPrivateBase() = default;
+
+#if !RELEASE_LOG_DISABLED
+    RefPtr<const PAL::Logger> m_logger;
+    const void* m_logIdentifier;
+#endif
 };
 
 } // namespace WebCore
index f945335..110d740 100644 (file)
@@ -54,6 +54,10 @@ public:
     enum Kind { Alternative, Captions, Main, Sign, Subtitles, Commentary, None };
     virtual Kind kind() const { return None; }
 
+#if !RELEASE_LOG_DISABLED
+    const char* logClassName() const final { return "VideoTrackPrivate"; }
+#endif
+
 protected:
     VideoTrackPrivate() = default;
 
index 2aafa1c..65f57fa 100644 (file)
@@ -35,6 +35,7 @@
 #import <AVFoundation/AVPlayerItem.h>
 #import <AVFoundation/AVPlayerItemTrack.h>
 #import <objc/runtime.h>
+#import <pal/Logger.h>
 #import <wtf/SoftLinking.h>
 
 @class AVMediaSelectionOption;
index 8cff08d..e7685c5 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "InbandTextTrackPrivateClient.h"
 #include "Logging.h"
+#include "MediaPlayer.h"
 #include <CoreMedia/CoreMedia.h>
 #include <wtf/text/CString.h>
 #include <wtf/text/WTFString.h>
@@ -76,12 +77,12 @@ void InbandMetadataTextTrackPrivateAVF::updatePendingCueEndTimes(const MediaTime
     if (time >= m_currentCueStartTime) {
         if (client()) {
             for (auto& partialCue : m_incompleteCues) {
-                LOG(Media, "InbandMetadataTextTrackPrivateAVF::updatePendingCueEndTimes(%p) - updating cue: start=%s, end=%s", this, toString(partialCue.startTime).utf8().data(), toString(time).utf8().data());
+                INFO_LOG(LOGIDENTIFIER, "updating cue: start = ", partialCue.startTime, ", end = ", time);
                 client()->updateDataCue(partialCue.startTime, time, *partialCue.cueData);
             }
         }
     } else
-        LOG(Media, "InbandMetadataTextTrackPrivateAVF::updatePendingCueEndTimes negative length cue(s) ignored: start=%s, end=%s\n", toString(m_currentCueStartTime).utf8().data(), toString(time).utf8().data());
+        WARNING_LOG(LOGIDENTIFIER, "negative length cue(s) ignored: start = ", m_currentCueStartTime, ", end = ", time);
 
     m_incompleteCues.shrink(0);
     m_currentCueStartTime = MediaTime::zeroTime();
@@ -92,7 +93,7 @@ void InbandMetadataTextTrackPrivateAVF::updatePendingCueEndTimes(const MediaTime
 void InbandMetadataTextTrackPrivateAVF::flushPartialCues()
 {
     if (m_currentCueStartTime && m_incompleteCues.size())
-        LOG(Media, "InbandMetadataTextTrackPrivateAVF::resetCueValues flushing incomplete data for cues: start=%s\n", toString(m_currentCueStartTime).utf8().data());
+        INFO_LOG(LOGIDENTIFIER, "flushing incomplete data for cues: start = ", m_currentCueStartTime);
 
     if (client()) {
         for (auto& partialCue : m_incompleteCues)
index 7378974..17c8b50 100644 (file)
@@ -60,6 +60,10 @@ public:
 private:
     InbandMetadataTextTrackPrivateAVF(Kind, CueFormat, const AtomicString&);
 
+#if !RELEASE_LOG_DISABLED
+    const char* logClassName() const final { return "InbandMetadataTextTrackPrivateAVF"; }
+#endif
+
     Kind m_kind;
     AtomicString m_id;
     AtomicString m_inBandMetadataTrackDispatchType;
index 45f2617..8d45d37 100644 (file)
 
 #if ENABLE(VIDEO) && (USE(AVFOUNDATION) || PLATFORM(IOS))
 
-#include "CoreMediaSoftLink.h"
 #include "ISOVTTCue.h"
 #include "InbandTextTrackPrivateClient.h"
 #include "Logging.h"
+#include "MediaPlayer.h"
 #include "MediaTimeAVFoundation.h"
 #include <runtime/ArrayBuffer.h>
 #include <runtime/DataView.h>
@@ -43,6 +43,8 @@
 #include <wtf/unicode/CharacterNames.h>
 #include <wtf/StringPrintStream.h>
 
+#include "CoreMediaSoftLink.h"
+
 namespace WebCore {
 
 AVFInbandTrackParent::~AVFInbandTrackParent()
@@ -315,11 +317,13 @@ void InbandTextTrackPrivateAVF::processCue(CFArrayRef attributedStrings, CFArray
 
 void InbandTextTrackPrivateAVF::processAttributedStrings(CFArrayRef attributedStrings, const MediaTime& time)
 {
-    LOG(Media, "InbandTextTrackPrivateAVF::processCue - %li cues at time %s\n", attributedStrings ? CFArrayGetCount(attributedStrings) : 0, toString(time).utf8().data());
+    CFIndex count = attributedStrings ? CFArrayGetCount(attributedStrings) : 0;
+
+    if (count)
+        DEBUG_LOG(LOGIDENTIFIER, "added ", count, count > 1 ? " cues" : " cue", " at time ", time);
 
     Vector<Ref<GenericCueData>> arrivingCues;
-    if (attributedStrings) {
-        CFIndex count = CFArrayGetCount(attributedStrings);
+    if (count) {
         for (CFIndex i = 0; i < count; i++) {
             CFAttributedStringRef attributedString = static_cast<CFAttributedStringRef>(CFArrayGetValueAtIndex(attributedStrings, i));
 
@@ -339,8 +343,6 @@ void InbandTextTrackPrivateAVF::processAttributedStrings(CFArrayRef attributedSt
             if (cueData->position() >= 0 && cueData->size() > 0)
                 cueData->setPosition(cueData->position() - cueData->size() / 2);
 
-            LOG(Media, "InbandTextTrackPrivateAVF::processCue(%p) - considering cue (\"%s\") for time = %s, position =  %.2f, line =  %.2f", this, cueData->content().utf8().data(), toString(cueData->startTime()).utf8().data(), cueData->position(), cueData->line());
-
             cueData->setStatus(GenericCueData::Partial);
 
             arrivingCues.append(WTFMove(cueData));
@@ -359,7 +361,7 @@ void InbandTextTrackPrivateAVF::processAttributedStrings(CFArrayRef attributedSt
                     if (!arrivingCue->doesExtendCueData(*cueData))
                         nonExtensionCues.append(WTFMove(arrivingCue));
                     else
-                        LOG(Media, "InbandTextTrackPrivateAVF::processCue(%p) - found an extension cue (\"%s\") for time = %.2f, end = %.2f, position =  %.2f, line =  %.2f", this, arrivingCue->content().utf8().data(), arrivingCue->startTime().toDouble(), arrivingCue->endTime().toDouble(), arrivingCue->position(), arrivingCue->line());
+                        DEBUG_LOG(LOGIDENTIFIER, "found an extension cue: ", *cueData);
                 }
 
                 bool currentCueIsExtended = (arrivingCues.size() != nonExtensionCues.size());
@@ -373,16 +375,17 @@ void InbandTextTrackPrivateAVF::processAttributedStrings(CFArrayRef attributedSt
                     cueData->setEndTime(m_currentCueEndTime);
                     cueData->setStatus(GenericCueData::Complete);
 
-                    LOG(Media, "InbandTextTrackPrivateAVF::processCue(%p) - updating cue \"%s\": start=%.2f, end=%.2f", this, cueData->content().utf8().data(), cueData->startTime().toDouble(), m_currentCueEndTime.toDouble());
+                    DEBUG_LOG(LOGIDENTIFIER, "updating cue start = ", cueData->startTime(), ", end = ", cueData->endTime(), ", content = ", cueData->content());
+
                     client()->updateGenericCue(*cueData);
                 } else {
                     // We have to assume that the implicit duration is invalid for cues delivered during a seek because the AVF decode pipeline may not
                     // see every cue, so DO NOT update cue duration while seeking.
-                    LOG(Media, "InbandTextTrackPrivateAVF::processCue(%p) - ignoring cue delivered during seek: start=%s, end=%s, content=\"%s\"", this, toString(cueData->startTime()).utf8().data(), toString(m_currentCueEndTime).utf8().data(), cueData->content().utf8().data());
+                    DEBUG_LOG(LOGIDENTIFIER, "ignoring cue delivered during seek: ", *cueData);
                 }
             }
         } else
-            LOG(Media, "InbandTextTrackPrivateAVF::processCue negative length cue(s) ignored: start=%s, end=%s\n",  toString(m_currentCueStartTime).utf8().data(), toString(m_currentCueEndTime).utf8().data());
+            ERROR_LOG(LOGIDENTIFIER, "negative length cue(s): start = ", m_currentCueStartTime, ", end = ", m_currentCueEndTime);
 
         removeCompletedCues();
     }
@@ -394,9 +397,7 @@ void InbandTextTrackPrivateAVF::processAttributedStrings(CFArrayRef attributedSt
 
     for (auto& cueData : arrivingCues) {
         m_cues.append(cueData.ptr());
-        
-        LOG(Media, "InbandTextTrackPrivateAVF::processCue(%p) - adding cue \"%s\" for time = %.2f, end = %.2f, position =  %.2f, line =  %.2f", this, cueData->content().utf8().data(), cueData->startTime().toDouble(), cueData->endTime().toDouble(), cueData->position(), cueData->line());
-
+        DEBUG_LOG(LOGIDENTIFIER, "adding cue: ", cueData.get());
         client()->addGenericCue(cueData);
     }
 
@@ -423,10 +424,11 @@ void InbandTextTrackPrivateAVF::removeCompletedCues()
     if (client()) {
         long currentCue = m_cues.size() - 1;
         for (; currentCue >= 0; --currentCue) {
-            if (m_cues[currentCue]->status() != GenericCueData::Complete)
+            auto& cue = m_cues[currentCue];
+            if (cue->status() != GenericCueData::Complete)
                 continue;
 
-            LOG(Media, "InbandTextTrackPrivateAVF::removeCompletedCues(%p) - removing cue \"%s\": start=%.2f, end=%.2f", this, m_cues[currentCue]->content().utf8().data(), m_cues[currentCue]->startTime().toDouble(), m_cues[currentCue]->endTime().toDouble());
+            DEBUG_LOG(LOGIDENTIFIER, "removing cue: ", *cue);
 
             m_cues.remove(currentCue);
         }
@@ -442,7 +444,7 @@ void InbandTextTrackPrivateAVF::removeCompletedCues()
 void InbandTextTrackPrivateAVF::resetCueValues()
 {
     if (m_currentCueEndTime && m_cues.size())
-        LOG(Media, "InbandTextTrackPrivateAVF::resetCueValues flushing data for cues: start=%s\n", toString(m_currentCueStartTime).utf8().data());
+        INFO_LOG(LOGIDENTIFIER, "flushing data for cues: start = ", m_currentCueStartTime);
 
     if (auto* client = this->client()) {
         for (auto& cue : m_cues)
@@ -478,7 +480,7 @@ void InbandTextTrackPrivateAVF::processNativeSamples(CFArrayRef nativeSamples, c
     if (!count)
         return;
 
-    LOG(Media, "InbandTextTrackPrivateAVF::processNativeSamples - %li sample buffers at time %.2f\n", count, presentationTime.toDouble());
+    INFO_LOG(LOGIDENTIFIER, count, " sample buffers at time ", presentationTime);
 
     for (CFIndex i = 0; i < count; i++) {
         RefPtr<ArrayBuffer> buffer;
@@ -490,26 +492,14 @@ void InbandTextTrackPrivateAVF::processNativeSamples(CFArrayRef nativeSamples, c
         String type = ISOBox::peekType(buffer.get());
         size_t boxLength = ISOBox::peekLength(buffer.get());
         if (boxLength > buffer->byteLength()) {
-            LOG(Media, "InbandTextTrackPrivateAVF::processNativeSamples(%p) - ERROR: chunk '%s' size (%zu) larger than buffer length (%u)!!", this, type.utf8().data(), boxLength, buffer->byteLength());
+            ERROR_LOG(LOGIDENTIFIER, "chunk  type = '", type, "', size = ", boxLength, " larger than buffer length!");
             continue;
         }
 
-        LOG(Media, "InbandTextTrackPrivateAVF::processNativeSamples(%p) - chunk type = '%s', size = %zu", this, type.utf8().data(), boxLength);
-
-        if (type == ISOWebVTTCue::boxType()) {
-            ISOWebVTTCue cueData = ISOWebVTTCue(presentationTime, duration, buffer.get());
-            LOG(Media, "    sample presentation time = %.2f, duration = %.2f", cueData.presentationTime().toDouble(), cueData.duration().toDouble());
-            LOG(Media, "    id = \"%s\", settings = \"%s\", cue text = \"%s\"", cueData.id().utf8().data(), cueData.settings().utf8().data(), cueData.cueText().utf8().data());
-            LOG(Media, "    sourceID = \"%s\", originalStartTime = \"%s\"", cueData.sourceID().utf8().data(), cueData.originalStartTime().utf8().data());
-
-            client()->parseWebVTTCueData(cueData);
-        }
+        DEBUG_LOG(LOGIDENTIFIER, "chunk  type = '", type, "', size = ", boxLength);
 
         do {
-            if (m_haveReportedVTTHeader)
-                break;
-
-            if (!formatDescription)
+            if (m_haveReportedVTTHeader || !formatDescription)
                 break;
 
             CFDictionaryRef extensions = CMFormatDescriptionGetExtensions(formatDescription);
@@ -534,11 +524,17 @@ void InbandTextTrackPrivateAVF::processNativeSamples(CFArrayRef nativeSamples, c
             header.append(reinterpret_cast<const unsigned char*>(CFDataGetBytePtr(webvttHeaderData)), length);
             header.append("\n\n");
 
-            LOG(Media, "    vtt header = \n%s", header.toString().utf8().data());
+            DEBUG_LOG(LOGIDENTIFIER, "VTT header = ", &header);
             client()->parseWebVTTFileHeader(header.toString());
             m_haveReportedVTTHeader = true;
         } while (0);
 
+        if (type == ISOWebVTTCue::boxType()) {
+            ISOWebVTTCue cueData = ISOWebVTTCue(presentationTime, duration, buffer.get());
+            DEBUG_LOG(LOGIDENTIFIER, "sample presentation time = ", cueData.presentationTime(), ", duration = ", cueData.duration(), ", id = '", cueData.id(), "', settings = ", cueData.settings(), ", cue text = ", cueData.cueText(), ", sourceID = ", cueData.sourceID(), ", originalStartTime = ", cueData.originalStartTime());
+            client()->parseWebVTTCueData(cueData);
+        }
+
         m_sampleInputBuffer.remove(0, boxLength);
     }
 }
@@ -555,7 +551,7 @@ bool InbandTextTrackPrivateAVF::readNativeSampleBuffer(CFArrayRef nativeSamples,
     CMSampleTimingInfo timingInfo;
     OSStatus status = CMSampleBufferGetSampleTimingInfo(sampleBuffer, index, &timingInfo);
     if (status) {
-        LOG(Media, "InbandTextTrackPrivateAVF::readNativeSampleBuffer(%p) - CMSampleBufferGetSampleTimingInfo returned error %x for sample %li", this, static_cast<int>(status), index);
+        ERROR_LOG(LOGIDENTIFIER, "CMSampleBufferGetSampleTimingInfo returned error ", status, "' for sample ", index);
         return false;
     }
 
@@ -564,7 +560,7 @@ bool InbandTextTrackPrivateAVF::readNativeSampleBuffer(CFArrayRef nativeSamples,
     CMBlockBufferRef blockBuffer = CMSampleBufferGetDataBuffer(sampleBuffer);
     size_t bufferLength = CMBlockBufferGetDataLength(blockBuffer);
     if (bufferLength < ISOBox::boxHeaderSize()) {
-        LOG(Media, "InbandTextTrackPrivateAVF::readNativeSampleBuffer(%p) - ERROR: CMSampleBuffer size length unexpectedly small (%zu)!!", this, bufferLength);
+        ERROR_LOG(LOGIDENTIFIER, "CMSampleBuffer size length unexpectedly small: ", bufferLength);
         return false;
     }
 
index 9ceec60..6053d99 100644 (file)
@@ -86,6 +86,11 @@ protected:
     void processNativeSamples(CFArrayRef, const MediaTime&);
     void removeCompletedCues();
 
+private:
+#if !RELEASE_LOG_DISABLED
+    const char* logClassName() const final { return "InbandTextTrackPrivateAVF"; }
+#endif
+
     MediaTime m_currentCueStartTime;
     MediaTime m_currentCueEndTime;
 
index 117752e..970b91f 100644 (file)
@@ -3342,6 +3342,7 @@ NSArray* playerKVOProperties()
 
     bool willChange = [[change valueForKey:NSKeyValueChangeNotificationIsPriorKey] boolValue];
     bool shouldLogValue = true;
+    bool shouldLog = true;
     WTF::Function<void ()> function;
 
     if (context == MediaPlayerAVFoundationObservationContextAVPlayerLayer) {
@@ -3378,10 +3379,10 @@ NSArray* playerKVOProperties()
             shouldLogValue = false;
         } else if ([keyPath isEqualToString:@"loadedTimeRanges"]) {
             function = std::bind(&MediaPlayerPrivateAVFoundationObjC::loadedTimeRangesDidChange, m_callback, RetainPtr<NSArray>(newValue));
-            shouldLogValue = false;
+            shouldLog = false;
         } else if ([keyPath isEqualToString:@"seekableTimeRanges"]) {
             function = std::bind(&MediaPlayerPrivateAVFoundationObjC::seekableTimeRangesDidChange, m_callback, RetainPtr<NSArray>(newValue));
-            shouldLogValue = false;
+            shouldLog = false;
         } else if ([keyPath isEqualToString:@"tracks"]) {
             function = std::bind(&MediaPlayerPrivateAVFoundationObjC::tracksDidChange, m_callback, RetainPtr<NSArray>(newValue));
             shouldLogValue = false;
@@ -3419,7 +3420,7 @@ NSArray* playerKVOProperties()
     }
 
 #if !RELEASE_LOG_DISABLED
-    if (m_callback->logger().willLog(m_callback->logChannel(), WTFLogLevelDebug)) {
+    if (shouldLog && m_callback->logger().willLog(m_callback->logChannel(), WTFLogLevelDebug)) {
 
         if (willChange)
             m_callback->logger().debug(m_callback->logChannel(), PAL::Logger::LogSiteIdentifier("MediaPlayerPrivateAVFoundation", "observeValueForKeyPath", m_callback->logIdentifier()), "will change '", [keyPath UTF8String], "'");
index b953c0f..06dc1a3 100644 (file)
@@ -31,6 +31,7 @@
 #include "AudioSession.h"
 #include "CAAudioStreamDescription.h"
 #include "Logging.h"
+#include <pal/Logger.h>
 
 #include "CoreMediaSoftLink.h"
 
@@ -114,13 +115,13 @@ AudioComponentInstance AudioTrackPrivateMediaStreamCocoa::createAudioUnit(CAAudi
     AudioComponent ioComponent = AudioComponentFindNext(nullptr, &ioUnitDescription);
     ASSERT(ioComponent);
     if (!ioComponent) {
-        LOG(Media, "AudioTrackPrivateMediaStreamCocoa::createAudioUnit(%p) unable to find remote IO unit component", this);
+        ERROR_LOG(LOGIDENTIFIER, "unable to find remote IO unit component");
         return nullptr;
     }
 
     OSStatus err = AudioComponentInstanceNew(ioComponent, &remoteIOUnit);
     if (err) {
-        LOG(Media, "AudioTrackPrivateMediaStreamCocoa::createAudioUnit(%p) unable to open vpio unit, error %d (%.4s)", this, (int)err, (char*)&err);
+        ERROR_LOG(LOGIDENTIFIER, "unable to open vpio unit, error = ", err, " (", (const char*)&err, ")");
         return nullptr;
     }
 
@@ -128,7 +129,7 @@ AudioComponentInstance AudioTrackPrivateMediaStreamCocoa::createAudioUnit(CAAudi
     UInt32 param = 1;
     err = AudioUnitSetProperty(remoteIOUnit, kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Output, 0, &param, sizeof(param));
     if (err) {
-        LOG(Media, "AudioTrackPrivateMediaStreamCocoa::createAudioUnit(%p) unable to enable vpio unit output, error %d (%.4s)", this, (int)err, (char*)&err);
+        ERROR_LOG(LOGIDENTIFIER, "unable to enable vpio unit output, error = ", err, " (", (const char*)&err, ")");
         return nullptr;
     }
 #endif
@@ -136,14 +137,14 @@ AudioComponentInstance AudioTrackPrivateMediaStreamCocoa::createAudioUnit(CAAudi
     AURenderCallbackStruct callback = { inputProc, this };
     err = AudioUnitSetProperty(remoteIOUnit, kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Global, 0, &callback, sizeof(callback));
     if (err) {
-        LOG(Media, "AudioTrackPrivateMediaStreamCocoa::createAudioUnit(%p) unable to set vpio unit speaker proc, error %d (%.4s)", this, (int)err, (char*)&err);
+        ERROR_LOG(LOGIDENTIFIER, "unable to set vpio unit speaker proc, error = ", err, " (", (const char*)&err, ")");
         return nullptr;
     }
 
     UInt32 size = sizeof(outputDescription.streamDescription());
     err  = AudioUnitGetProperty(remoteIOUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0, &outputDescription.streamDescription(), &size);
     if (err) {
-        LOG(Media, "AudioTrackPrivateMediaStreamCocoa::createAudioUnits(%p) unable to get input stream format, error %d (%.4s)", this, (int)err, (char*)&err);
+        ERROR_LOG(LOGIDENTIFIER, "unable to get input stream format, error = ", err, " (", (const char*)&err, ")");
         return nullptr;
     }
 
@@ -151,13 +152,13 @@ AudioComponentInstance AudioTrackPrivateMediaStreamCocoa::createAudioUnit(CAAudi
 
     err = AudioUnitSetProperty(remoteIOUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0, &outputDescription.streamDescription(), sizeof(outputDescription.streamDescription()));
     if (err) {
-        LOG(Media, "AudioTrackPrivateMediaStreamCocoa::createAudioUnits(%p) unable to set input stream format, error %d (%.4s)", this, (int)err, (char*)&err);
+        ERROR_LOG(LOGIDENTIFIER, "unable to set input stream format, error = ", err, " (", (const char*)&err, ")");
         return nullptr;
     }
 
     err = AudioUnitInitialize(remoteIOUnit);
     if (err) {
-        LOG(Media, "AudioTrackPrivateMediaStreamCocoa::createAudioUnits(%p) AudioUnitInitialize() failed, error %d (%.4s)", this, (int)err, (char*)&err);
+        ERROR_LOG(LOGIDENTIFIER, "AudioUnitInitialize() failed, error = ", err, " (", (const char*)&err, ")");
         return nullptr;
     }
 
index 9326d58..8b6076b 100644 (file)
@@ -71,6 +71,11 @@ private:
     void zeroBufferList(AudioBufferList&, size_t);
     void playInternal();
 
+#if !RELEASE_LOG_DISABLED
+    const char* logClassName() const final { return "AudioTrackPrivateMediaStreamCocoa"; }
+#endif
+
+
     AudioComponentInstance m_remoteIOUnit { nullptr };
     std::unique_ptr<CAAudioStreamDescription> m_inputDescription;
     std::unique_ptr<CAAudioStreamDescription> m_outputDescription;