Title: [221046] trunk/Source/WebCore
Revision
221046
Author
[email protected]
Date
2017-08-22 14:04:59 -0700 (Tue, 22 Aug 2017)

Log Message

Refactor videoPerformanceQuality() MediaPlayer methods into single call.
https://bugs.webkit.org/show_bug.cgi?id=175830

Reviewed by Eric Carlson.

Allow MediaPlayerPrivate subclasses to return all the metrics required for VideoPerformanceQuality in
a single call. For clients which incur significant overhead to request this data, this reduces the cost
of requesting data by the number of calls removed.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::getVideoPlaybackQuality):
* platform/graphics/MediaPlayer.cpp:
(WebCore::MediaPlayer::videoPlaybackQualityMetrics):
(WebCore::MediaPlayer::totalVideoFrames): Deleted.
(WebCore::MediaPlayer::droppedVideoFrames): Deleted.
(WebCore::MediaPlayer::corruptedVideoFrames): Deleted.
(WebCore::MediaPlayer::totalFrameDelay): Deleted.
* platform/graphics/MediaPlayer.h:
(WebCore::PlatformVideoPlaybackQualityMetrics::PlatformVideoPlaybackQualityMetrics):
* platform/graphics/MediaPlayerPrivate.h:
(WebCore::MediaPlayerPrivateInterface::videoPlaybackQualityMetrics):
(WebCore::MediaPlayerPrivateInterface::totalVideoFrames): Deleted.
(WebCore::MediaPlayerPrivateInterface::droppedVideoFrames): Deleted.
(WebCore::MediaPlayerPrivateInterface::corruptedVideoFrames): Deleted.
(WebCore::MediaPlayerPrivateInterface::totalFrameDelay): Deleted.
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::videoPlaybackQualityMetrics):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::totalVideoFrames): Deleted.
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::droppedVideoFrames): Deleted.
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::corruptedVideoFrames): Deleted.
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::totalFrameDelay): Deleted.
* platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.h:
* platform/mock/mediasource/MockMediaPlayerMediaSource.cpp:
(WebCore::MockMediaPlayerMediaSource::videoPlaybackQualityMetrics):
(WebCore::MockMediaPlayerMediaSource::totalVideoFrames): Deleted.
(WebCore::MockMediaPlayerMediaSource::droppedVideoFrames): Deleted.
(WebCore::MockMediaPlayerMediaSource::corruptedVideoFrames): Deleted.
(WebCore::MockMediaPlayerMediaSource::totalFrameDelay): Deleted.
* platform/mock/mediasource/MockMediaPlayerMediaSource.h:
* platform/mock/mediasource/MockMediaSourcePrivate.cpp:
(WebCore::MockMediaSourcePrivate::videoPlaybackQualityMetrics):
* platform/mock/mediasource/MockMediaSourcePrivate.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (221045 => 221046)


--- trunk/Source/WebCore/ChangeLog	2017-08-22 21:03:53 UTC (rev 221045)
+++ trunk/Source/WebCore/ChangeLog	2017-08-22 21:04:59 UTC (rev 221046)
@@ -1,3 +1,49 @@
+2017-08-22  Jer Noble  <[email protected]>
+
+        Refactor videoPerformanceQuality() MediaPlayer methods into single call.
+        https://bugs.webkit.org/show_bug.cgi?id=175830
+
+        Reviewed by Eric Carlson.
+
+        Allow MediaPlayerPrivate subclasses to return all the metrics required for VideoPerformanceQuality in
+        a single call. For clients which incur significant overhead to request this data, this reduces the cost
+        of requesting data by the number of calls removed.
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::getVideoPlaybackQuality):
+        * platform/graphics/MediaPlayer.cpp:
+        (WebCore::MediaPlayer::videoPlaybackQualityMetrics):
+        (WebCore::MediaPlayer::totalVideoFrames): Deleted.
+        (WebCore::MediaPlayer::droppedVideoFrames): Deleted.
+        (WebCore::MediaPlayer::corruptedVideoFrames): Deleted.
+        (WebCore::MediaPlayer::totalFrameDelay): Deleted.
+        * platform/graphics/MediaPlayer.h:
+        (WebCore::PlatformVideoPlaybackQualityMetrics::PlatformVideoPlaybackQualityMetrics):
+        * platform/graphics/MediaPlayerPrivate.h:
+        (WebCore::MediaPlayerPrivateInterface::videoPlaybackQualityMetrics):
+        (WebCore::MediaPlayerPrivateInterface::totalVideoFrames): Deleted.
+        (WebCore::MediaPlayerPrivateInterface::droppedVideoFrames): Deleted.
+        (WebCore::MediaPlayerPrivateInterface::corruptedVideoFrames): Deleted.
+        (WebCore::MediaPlayerPrivateInterface::totalFrameDelay): Deleted.
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::videoPlaybackQualityMetrics):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::totalVideoFrames): Deleted.
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::droppedVideoFrames): Deleted.
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::corruptedVideoFrames): Deleted.
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::totalFrameDelay): Deleted.
+        * platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.h:
+        * platform/mock/mediasource/MockMediaPlayerMediaSource.cpp:
+        (WebCore::MockMediaPlayerMediaSource::videoPlaybackQualityMetrics):
+        (WebCore::MockMediaPlayerMediaSource::totalVideoFrames): Deleted.
+        (WebCore::MockMediaPlayerMediaSource::droppedVideoFrames): Deleted.
+        (WebCore::MockMediaPlayerMediaSource::corruptedVideoFrames): Deleted.
+        (WebCore::MockMediaPlayerMediaSource::totalFrameDelay): Deleted.
+        * platform/mock/mediasource/MockMediaPlayerMediaSource.h:
+        * platform/mock/mediasource/MockMediaSourcePrivate.cpp:
+        (WebCore::MockMediaSourcePrivate::videoPlaybackQualityMetrics):
+        * platform/mock/mediasource/MockMediaSourcePrivate.h:
+
 2017-08-22  Brent Fulgham  <[email protected]>
 
         Ensure media controls host exists before using it

Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (221045 => 221046)


--- trunk/Source/WebCore/html/HTMLMediaElement.cpp	2017-08-22 21:03:53 UTC (rev 221045)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp	2017-08-22 21:04:59 UTC (rev 221046)
@@ -6902,14 +6902,15 @@
     DOMWindow* domWindow = document().domWindow();
     double timestamp = domWindow ? 1000 * domWindow->nowTimestamp() : 0;
 
-    if (!m_player)
+    auto metrics = m_player ? m_player->videoPlaybackQualityMetrics() : std::nullopt;
+    if (!metrics)
         return VideoPlaybackQuality::create(timestamp, 0, 0, 0, 0);
 
     return VideoPlaybackQuality::create(timestamp,
-        m_droppedVideoFrames + m_player->totalVideoFrames(),
-        m_droppedVideoFrames + m_player->droppedVideoFrames(),
-        m_player->corruptedVideoFrames(),
-        m_player->totalFrameDelay().toDouble());
+        metrics.value().totalVideoFrames + m_droppedVideoFrames,
+        metrics.value().droppedVideoFrames + m_droppedVideoFrames,
+        metrics.value().corruptedVideoFrames,
+        metrics.value().totalFrameDelay);
 }
 #endif
 

Modified: trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp (221045 => 221046)


--- trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp	2017-08-22 21:03:53 UTC (rev 221045)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp	2017-08-22 21:04:59 UTC (rev 221046)
@@ -1408,37 +1408,13 @@
 }
 
 #if ENABLE(MEDIA_SOURCE)
-unsigned long MediaPlayer::totalVideoFrames()
+std::optional<PlatformVideoPlaybackQualityMetrics> MediaPlayer::videoPlaybackQualityMetrics()
 {
     if (!m_private)
-        return 0;
+        return std::nullopt;
 
-    return m_private->totalVideoFrames();
+    return m_private->videoPlaybackQualityMetrics();
 }
-
-unsigned long MediaPlayer::droppedVideoFrames()
-{
-    if (!m_private)
-        return 0;
-
-    return m_private->droppedVideoFrames();
-}
-
-unsigned long MediaPlayer::corruptedVideoFrames()
-{
-    if (!m_private)
-        return 0;
-
-    return m_private->corruptedVideoFrames();
-}
-
-MediaTime MediaPlayer::totalFrameDelay()
-{
-    if (!m_private)
-        return MediaTime::zeroTime();
-
-    return m_private->totalFrameDelay();
-}
 #endif
 
 bool MediaPlayer::shouldWaitForResponseToAuthenticationChallenge(const AuthenticationChallenge& challenge)

Modified: trunk/Source/WebCore/platform/graphics/MediaPlayer.h (221045 => 221046)


--- trunk/Source/WebCore/platform/graphics/MediaPlayer.h	2017-08-22 21:03:53 UTC (rev 221045)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayer.h	2017-08-22 21:04:59 UTC (rev 221046)
@@ -121,6 +121,21 @@
     Vector<ContentType> contentTypesRequiringHardwareSupport;
 };
 
+struct PlatformVideoPlaybackQualityMetrics {
+    PlatformVideoPlaybackQualityMetrics(unsigned long totalVideoFrames, unsigned long droppedVideoFrames, unsigned long corruptedVideoFrames, double totalFrameDelay)
+        : totalVideoFrames(totalVideoFrames)
+        , droppedVideoFrames(droppedVideoFrames)
+        , corruptedVideoFrames(corruptedVideoFrames)
+        , totalFrameDelay(totalFrameDelay)
+    {
+    }
+
+    unsigned long totalVideoFrames;
+    unsigned long droppedVideoFrames;
+    unsigned long corruptedVideoFrames;
+    double totalFrameDelay;
+};
+
 extern const PlatformMedia NoPlatformMedia;
 
 class CDMSessionClient;
@@ -583,10 +598,7 @@
     unsigned long long fileSize() const;
 
 #if ENABLE(MEDIA_SOURCE)
-    unsigned long totalVideoFrames();
-    unsigned long droppedVideoFrames();
-    unsigned long corruptedVideoFrames();
-    MediaTime totalFrameDelay();
+    std::optional<PlatformVideoPlaybackQualityMetrics> videoPlaybackQualityMetrics();
 #endif
 
     bool shouldWaitForResponseToAuthenticationChallenge(const AuthenticationChallenge&);

Modified: trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h (221045 => 221046)


--- trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h	2017-08-22 21:03:53 UTC (rev 221045)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h	2017-08-22 21:04:59 UTC (rev 221046)
@@ -270,10 +270,7 @@
     virtual bool ended() const { return false; }
 
 #if ENABLE(MEDIA_SOURCE)
-    virtual unsigned long totalVideoFrames() { return 0; }
-    virtual unsigned long droppedVideoFrames() { return 0; }
-    virtual unsigned long corruptedVideoFrames() { return 0; }
-    virtual MediaTime totalFrameDelay() { return MediaTime::zeroTime(); }
+    virtual std::optional<PlatformVideoPlaybackQualityMetrics> videoPlaybackQualityMetrics() { return std::nullopt; }
 #endif
 
 #if ENABLE(AVF_CAPTIONS)

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h (221045 => 221046)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h	2017-08-22 21:03:53 UTC (rev 221045)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h	2017-08-22 21:04:59 UTC (rev 221046)
@@ -216,10 +216,7 @@
 
     size_t extraMemoryCost() const override;
 
-    unsigned long totalVideoFrames() override;
-    unsigned long droppedVideoFrames() override;
-    unsigned long corruptedVideoFrames() override;
-    MediaTime totalFrameDelay() override;
+    std::optional<PlatformVideoPlaybackQualityMetrics> videoPlaybackQualityMetrics() override;
 
 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
     bool isCurrentPlaybackTargetWireless() const override;

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm (221045 => 221046)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm	2017-08-22 21:03:53 UTC (rev 221045)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm	2017-08-22 21:04:59 UTC (rev 221046)
@@ -687,26 +687,21 @@
     return 0;
 }
 
-unsigned long MediaPlayerPrivateMediaSourceAVFObjC::totalVideoFrames()
+std::optional<PlatformVideoPlaybackQualityMetrics> MediaPlayerPrivateMediaSourceAVFObjC::videoPlaybackQualityMetrics()
 {
-    return [[m_sampleBufferDisplayLayer videoPerformanceMetrics] totalNumberOfVideoFrames];
-}
 
-unsigned long MediaPlayerPrivateMediaSourceAVFObjC::droppedVideoFrames()
-{
-    return [[m_sampleBufferDisplayLayer videoPerformanceMetrics] numberOfDroppedVideoFrames];
-}
+    auto metrics = [m_sampleBufferDisplayLayer videoPerformanceMetrics];
+    if (!metrics)
+        return std::nullopt;
 
-unsigned long MediaPlayerPrivateMediaSourceAVFObjC::corruptedVideoFrames()
-{
-    return [[m_sampleBufferDisplayLayer videoPerformanceMetrics] numberOfCorruptedVideoFrames];
+    return PlatformVideoPlaybackQualityMetrics(
+        [metrics totalNumberOfVideoFrames],
+        [metrics numberOfDroppedVideoFrames],
+        [metrics numberOfCorruptedVideoFrames],
+        [metrics totalFrameDelay]
+    );
 }
 
-MediaTime MediaPlayerPrivateMediaSourceAVFObjC::totalFrameDelay()
-{
-    return MediaTime::createWithDouble([[m_sampleBufferDisplayLayer videoPerformanceMetrics] totalFrameDelay]);
-}
-
 #pragma mark -
 #pragma mark Utility Methods
 

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.h (221045 => 221046)


--- trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.h	2017-08-22 21:03:53 UTC (rev 221045)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.h	2017-08-22 21:04:59 UTC (rev 221046)
@@ -101,10 +101,7 @@
     void asyncStateChangeDone() override;
 
     // FIXME: Implement.
-    unsigned long totalVideoFrames() override { return 0; }
-    unsigned long droppedVideoFrames() override { return 0; }
-    unsigned long corruptedVideoFrames() override { return 0; }
-    MediaTime totalFrameDelay() override { return MediaTime::zeroTime(); }
+    std::optional<PlatformVideoPlaybackQualityMetrics> videoPlaybackQualityMetrics() override { return std::nullopt; }
     bool isTimeBuffered(const MediaTime&) const;
 
     bool isMediaSource() const override { return true; }

Modified: trunk/Source/WebCore/platform/mock/mediasource/MockMediaPlayerMediaSource.cpp (221045 => 221046)


--- trunk/Source/WebCore/platform/mock/mediasource/MockMediaPlayerMediaSource.cpp	2017-08-22 21:03:53 UTC (rev 221045)
+++ trunk/Source/WebCore/platform/mock/mediasource/MockMediaPlayerMediaSource.cpp	2017-08-22 21:04:59 UTC (rev 221046)
@@ -270,26 +270,11 @@
         });
 }
 
-unsigned long MockMediaPlayerMediaSource::totalVideoFrames()
+std::optional<PlatformVideoPlaybackQualityMetrics> MockMediaPlayerMediaSource::videoPlaybackQualityMetrics()
 {
-    return m_mediaSourcePrivate ? m_mediaSourcePrivate->totalVideoFrames() : 0;
+    return m_mediaSourcePrivate ? m_mediaSourcePrivate->videoPlaybackQualityMetrics() : std::nullopt;
 }
 
-unsigned long MockMediaPlayerMediaSource::droppedVideoFrames()
-{
-    return m_mediaSourcePrivate ? m_mediaSourcePrivate->droppedVideoFrames() : 0;
 }
 
-unsigned long MockMediaPlayerMediaSource::corruptedVideoFrames()
-{
-    return m_mediaSourcePrivate ? m_mediaSourcePrivate->corruptedVideoFrames() : 0;
-}
-
-MediaTime MockMediaPlayerMediaSource::totalFrameDelay()
-{
-    return m_mediaSourcePrivate ? m_mediaSourcePrivate->totalFrameDelay() : MediaTime::zeroTime();
-}
-
-}
-
 #endif

Modified: trunk/Source/WebCore/platform/mock/mediasource/MockMediaPlayerMediaSource.h (221045 => 221046)


--- trunk/Source/WebCore/platform/mock/mediasource/MockMediaPlayerMediaSource.h	2017-08-22 21:03:53 UTC (rev 221045)
+++ trunk/Source/WebCore/platform/mock/mediasource/MockMediaPlayerMediaSource.h	2017-08-22 21:04:59 UTC (rev 221046)
@@ -81,10 +81,7 @@
     MediaTime currentMediaTime() const override;
     MediaTime durationMediaTime() const override;
     void seekWithTolerance(const MediaTime&, const MediaTime&, const MediaTime&) override;
-    unsigned long totalVideoFrames() override;
-    unsigned long droppedVideoFrames() override;
-    unsigned long corruptedVideoFrames() override;
-    MediaTime totalFrameDelay() override;
+    std::optional<PlatformVideoPlaybackQualityMetrics> videoPlaybackQualityMetrics() override;
 
     MediaPlayer* m_player;
     RefPtr<MockMediaSourcePrivate> m_mediaSourcePrivate;

Modified: trunk/Source/WebCore/platform/mock/mediasource/MockMediaSourcePrivate.cpp (221045 => 221046)


--- trunk/Source/WebCore/platform/mock/mediasource/MockMediaSourcePrivate.cpp	2017-08-22 21:03:53 UTC (rev 221045)
+++ trunk/Source/WebCore/platform/mock/mediasource/MockMediaSourcePrivate.cpp	2017-08-22 21:04:59 UTC (rev 221046)
@@ -183,6 +183,16 @@
     return seekTime;
 }
 
+std::optional<PlatformVideoPlaybackQualityMetrics> MockMediaSourcePrivate::videoPlaybackQualityMetrics()
+{
+    return PlatformVideoPlaybackQualityMetrics(
+        m_totalVideoFrames,
+        m_droppedVideoFrames,
+        m_corruptedVideoFrames,
+        m_totalFrameDelay.toDouble()
+    );
+}
+
 };
 
 #endif

Modified: trunk/Source/WebCore/platform/mock/mediasource/MockMediaSourcePrivate.h (221045 => 221046)


--- trunk/Source/WebCore/platform/mock/mediasource/MockMediaSourcePrivate.h	2017-08-22 21:03:53 UTC (rev 221045)
+++ trunk/Source/WebCore/platform/mock/mediasource/MockMediaSourcePrivate.h	2017-08-22 21:04:59 UTC (rev 221046)
@@ -55,10 +55,7 @@
     void seekToTime(const MediaTime&);
     MediaTime seekToTime(const MediaTime&, const MediaTime& negativeThreshold, const MediaTime& positiveThreshold);
 
-    unsigned long totalVideoFrames() const { return m_totalVideoFrames; }
-    unsigned long droppedVideoFrames() const  { return m_droppedVideoFrames; }
-    unsigned long corruptedVideoFrames() const { return m_corruptedVideoFrames; }
-    MediaTime totalFrameDelay() const { return m_totalFrameDelay; }
+    std::optional<PlatformVideoPlaybackQualityMetrics> videoPlaybackQualityMetrics();
 
     void incrementTotalVideoFrames() { ++m_totalVideoFrames; }
     void incrementDroppedFrames() { ++m_droppedVideoFrames; }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to