[macOS,iOS] Add always-on logging for AVPlayerTimeControlStatus changes
authoreric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 May 2019 19:12:22 +0000 (19:12 +0000)
committereric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 May 2019 19:12:22 +0000 (19:12 +0000)
https://bugs.webkit.org/show_bug.cgi?id=197946
<rdar://problem/50627457>

Reviewed by Jon Lee.

* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::convertEnumerationToString):
(WTF::LogArgument<AVPlayerTimeControlStatus>::toString):
(WebCore::MediaPlayerPrivateAVFoundationObjC::timeControlStatusDidChange):

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

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm

index 2647ae5..0437901 100644 (file)
@@ -1,3 +1,16 @@
+2019-05-23  Eric Carlson  <eric.carlson@apple.com>
+
+        [macOS,iOS] Add always-on logging for AVPlayerTimeControlStatus changes
+        https://bugs.webkit.org/show_bug.cgi?id=197946
+        <rdar://problem/50627457>
+
+        Reviewed by Jon Lee.
+
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+        (WebCore::convertEnumerationToString):
+        (WTF::LogArgument<AVPlayerTimeControlStatus>::toString):
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::timeControlStatusDidChange):
+
 2019-05-23  Antoine Quint  <graouts@apple.com>
 
         [Pointer Events] Compatibility mouse events can only be prevented while the pointer is pressed
index 5afd8cb..c123ed5 100644 (file)
@@ -201,6 +201,35 @@ enum MediaPlayerAVFoundationObservationContext {
 #endif
 
 namespace WebCore {
+static String convertEnumerationToString(AVPlayerTimeControlStatus enumerationValue)
+{
+    static const NeverDestroyed<String> values[] = {
+        MAKE_STATIC_STRING_IMPL("AVPlayerTimeControlStatusPaused"),
+        MAKE_STATIC_STRING_IMPL("AVPlayerTimeControlStatusWaitingToPlayAtSpecifiedRate"),
+        MAKE_STATIC_STRING_IMPL("AVPlayerTimeControlStatusPlaying"),
+    };
+    static_assert(!static_cast<size_t>(AVPlayerTimeControlStatusPaused), "AVPlayerTimeControlStatusPaused is not 0 as expected");
+    static_assert(static_cast<size_t>(AVPlayerTimeControlStatusWaitingToPlayAtSpecifiedRate) == 1, "AVPlayerTimeControlStatusWaitingToPlayAtSpecifiedRate is not 1 as expected");
+    static_assert(static_cast<size_t>(AVPlayerTimeControlStatusPlaying) == 2, "AVPlayerTimeControlStatusPlaying is not 2 as expected");
+    ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values));
+    return values[static_cast<size_t>(enumerationValue)];
+}
+}
+
+namespace WTF {
+template<typename Type>
+struct LogArgument;
+
+template <>
+struct LogArgument<AVPlayerTimeControlStatus> {
+    static String toString(const AVPlayerTimeControlStatus status)
+    {
+        return convertEnumerationToString(status);
+    }
+};
+}; // namespace WTF
+
+namespace WebCore {
 using namespace PAL;
 
 static NSArray *assetMetadataKeyNames();
@@ -3046,6 +3075,8 @@ void MediaPlayerPrivateAVFoundationObjC::timeControlStatusDidChange(int timeCont
     if (m_cachedTimeControlStatus == timeControlStatus)
         return;
 
+    ALWAYS_LOG(LOGIDENTIFIER, static_cast<AVPlayerTimeControlStatus>(timeControlStatus), ", observing = ", m_shouldObserveTimeControlStatus);
+
     if (!m_shouldObserveTimeControlStatus)
         return;