[WinCairo][MediaFoundation] Current playback time is not shown.
authorpeavo@outlook.com <peavo@outlook.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 17 Nov 2015 22:41:24 +0000 (22:41 +0000)
committerpeavo@outlook.com <peavo@outlook.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 17 Nov 2015 22:41:24 +0000 (22:41 +0000)
https://bugs.webkit.org/show_bug.cgi?id=151357

Reviewed by Alex Christensen.

We need to implement the currentTime() method.

* platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp:
(WebCore::MediaPlayerPrivateMediaFoundation::durationDouble):
(WebCore::MediaPlayerPrivateMediaFoundation::currentTime):
(WebCore::MediaPlayerPrivateMediaFoundation::paused):
(WebCore::MediaPlayerPrivateMediaFoundation::CustomVideoPresenter::paintCurrentFrame):
(WebCore::MediaPlayerPrivateMediaFoundation::CustomVideoPresenter::currentTime):
(WebCore::MediaPlayerPrivateMediaFoundation::CustomVideoPresenter::isActive):
* platform/graphics/win/MediaPlayerPrivateMediaFoundation.h:

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

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp
Source/WebCore/platform/graphics/win/MediaPlayerPrivateMediaFoundation.h

index 99ad87d..157a126 100644 (file)
@@ -1,3 +1,21 @@
+2015-11-17  Per Arne Vollan  <peavo@outlook.com>
+
+        [WinCairo][MediaFoundation] Current playback time is not shown.
+        https://bugs.webkit.org/show_bug.cgi?id=151357
+
+        Reviewed by Alex Christensen.
+
+        We need to implement the currentTime() method.
+
+        * platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp:
+        (WebCore::MediaPlayerPrivateMediaFoundation::durationDouble):
+        (WebCore::MediaPlayerPrivateMediaFoundation::currentTime):
+        (WebCore::MediaPlayerPrivateMediaFoundation::paused):
+        (WebCore::MediaPlayerPrivateMediaFoundation::CustomVideoPresenter::paintCurrentFrame):
+        (WebCore::MediaPlayerPrivateMediaFoundation::CustomVideoPresenter::currentTime):
+        (WebCore::MediaPlayerPrivateMediaFoundation::CustomVideoPresenter::isActive):
+        * platform/graphics/win/MediaPlayerPrivateMediaFoundation.h:
+
 2015-11-17  Zalan Bujtas  <zalan@apple.com>
 
         Split SimpleLineLayout::canUseFor into canUseForStyle and canUseForFontAndText.
index 7a34d57..f24fa65 100644 (file)
@@ -90,6 +90,8 @@ static const GUID MFSamplePresenterSampleCounter =
 static const GUID MFSamplePresenterSampleSwapChain =
 { 0x24a2e076, 0x3673, 0x433d, { 0x87, 0x4, 0x55, 0x2b, 0x1f, 0x5c, 0x16, 0x8c } };
 
+static const double tenMegahertz = 10000000;
+
 namespace WebCore {
 
 MediaPlayerPrivateMediaFoundation::MediaPlayerPrivateMediaFoundation(MediaPlayer* player) 
@@ -207,7 +209,6 @@ bool MediaPlayerPrivateMediaFoundation::seeking() const
 
 void MediaPlayerPrivateMediaFoundation::seekDouble(double time)
 {
-    const double tenMegahertz = 10000000;
     PROPVARIANT propVariant;
     PropVariantInit(&propVariant);
     propVariant.vt = VT_I8;
@@ -220,7 +221,6 @@ void MediaPlayerPrivateMediaFoundation::seekDouble(double time)
 
 double MediaPlayerPrivateMediaFoundation::durationDouble() const
 {
-    const double tenMegahertz = 10000000;
     if (!m_mediaSource)
         return 0;
 
@@ -236,6 +236,14 @@ double MediaPlayerPrivateMediaFoundation::durationDouble() const
     return static_cast<double>(duration) / tenMegahertz;
 }
 
+float MediaPlayerPrivateMediaFoundation::currentTime() const
+{
+    if (!m_presenter)
+        return 0.0f;
+
+    return m_presenter->currentTime();
+}
+
 bool MediaPlayerPrivateMediaFoundation::paused() const
 {
     return m_paused;
@@ -1258,6 +1266,22 @@ void MediaPlayerPrivateMediaFoundation::CustomVideoPresenter::paintCurrentFrame(
         m_presenterEngine->paintCurrentFrame(context, r);
 }
 
+float MediaPlayerPrivateMediaFoundation::CustomVideoPresenter::currentTime()
+{
+    if (!m_clock)
+        return 0.0f;
+
+    LONGLONG clockTime;
+    MFTIME systemTime;
+    HRESULT hr = m_clock->GetCorrelatedTime(0, &clockTime, &systemTime);
+
+    if (FAILED(hr))
+        return 0.0f;
+
+    // clockTime is in 100 nanoseconds, we need to convert to seconds.
+    return clockTime / tenMegahertz;
+}
+
 bool MediaPlayerPrivateMediaFoundation::CustomVideoPresenter::isActive() const
 {
     return ((m_renderState == RenderStateStarted) || (m_renderState == RenderStatePaused));
index 4a6b532..3bf4dee 100644 (file)
@@ -74,6 +74,8 @@ public:
     virtual void seekDouble(double) override;
     virtual double durationDouble() const override;
 
+    virtual float currentTime() const override;
+
     virtual bool paused() const;
 
     virtual MediaPlayer::NetworkState networkState() const;
@@ -388,6 +390,8 @@ private:
 
         void paintCurrentFrame(GraphicsContext&, const FloatRect&);
 
+        float currentTime();
+
     private:
         ULONG m_refCount { 0 };
         Lock m_lock;