Title: [221116] trunk/Source/WebCore
Revision
221116
Author
[email protected]
Date
2017-08-23 16:23:21 -0700 (Wed, 23 Aug 2017)

Log Message

[EME] WebCoreDecompressionSession should only report having an available frame if it has one for the current time.
https://bugs.webkit.org/show_bug.cgi?id=175901

Reviewed by Eric Carlson.

The WebCoreDecompressionSession will trigger the hasAvailableFrame callback whenever a frame is decoded,
regardless of its presentation time. For formats which have out-of-order decoding, the newly decoded frame could
have a presentation time far in the future. Instead, only fire the callback if the decoded frame's presentation
times contains the timebase's current time.

* platform/graphics/cocoa/WebCoreDecompressionSession.mm:
(WebCore::WebCoreDecompressionSession::enqueueDecodedSample):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (221115 => 221116)


--- trunk/Source/WebCore/ChangeLog	2017-08-23 23:06:43 UTC (rev 221115)
+++ trunk/Source/WebCore/ChangeLog	2017-08-23 23:23:21 UTC (rev 221116)
@@ -1,3 +1,18 @@
+2017-08-23  Jer Noble  <[email protected]>
+
+        [EME] WebCoreDecompressionSession should only report having an available frame if it has one for the current time.
+        https://bugs.webkit.org/show_bug.cgi?id=175901
+
+        Reviewed by Eric Carlson.
+
+        The WebCoreDecompressionSession will trigger the hasAvailableFrame callback whenever a frame is decoded,
+        regardless of its presentation time. For formats which have out-of-order decoding, the newly decoded frame could
+        have a presentation time far in the future. Instead, only fire the callback if the decoded frame's presentation
+        times contains the timebase's current time.
+
+        * platform/graphics/cocoa/WebCoreDecompressionSession.mm:
+        (WebCore::WebCoreDecompressionSession::enqueueDecodedSample):
+
 2017-08-23  Youenn Fablet  <[email protected]>
 
         [Cache API] Unify WebCore and WebKit error handling

Modified: trunk/Source/WebCore/platform/graphics/cocoa/WebCoreDecompressionSession.mm (221115 => 221116)


--- trunk/Source/WebCore/platform/graphics/cocoa/WebCoreDecompressionSession.mm	2017-08-23 23:06:43 UTC (rev 221115)
+++ trunk/Source/WebCore/platform/graphics/cocoa/WebCoreDecompressionSession.mm	2017-08-23 23:23:21 UTC (rev 221116)
@@ -355,14 +355,20 @@
     if (m_timebase)
         CMTimebaseSetTimerDispatchSourceToFireImmediately(m_timebase.get(), m_timerSource.get());
 
-    if (m_hasAvailableFrameCallback) {
-        std::function<void()> callback { m_hasAvailableFrameCallback };
-        m_hasAvailableFrameCallback = nullptr;
-        RefPtr<WebCoreDecompressionSession> protectedThis { this };
-        dispatch_async(dispatch_get_main_queue(), [protectedThis, callback] {
-            callback();
-        });
+    if (!m_hasAvailableFrameCallback)
+        return;
+
+    if (m_timebase) {
+        auto currentTime = toMediaTime(CMTimebaseGetTime(m_timebase.get()));
+        auto presentationStartTime = toMediaTime(CMSampleBufferGetPresentationTimeStamp(sample));
+        auto presentationEndTime = presentationStartTime + toMediaTime(CMSampleBufferGetDuration(sample));
+        if (currentTime < presentationStartTime || currentTime >= presentationEndTime)
+            return;
     }
+
+    dispatch_async(dispatch_get_main_queue(), [protectedThis = makeRefPtr(this), callback = WTFMove(m_hasAvailableFrameCallback)] {
+        callback();
+    });
 }
 
 bool WebCoreDecompressionSession::isReadyForMoreMediaData() const
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to