Changeset 242701 in webkit
- Timestamp:
- Mar 11, 2019 7:41:39 AM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r242700 r242701 1 2019-03-11 Philippe Normand <pnormand@igalia.com> 2 3 [GStreamer][v4l2] Synchronous video texture flushing support 4 https://bugs.webkit.org/show_bug.cgi?id=195453 5 6 Reviewed by Xabier Rodriguez-Calvar. 7 8 The v4l2 video decoder currently requires that downstream users of 9 the graphics resources complete any pending draw call and release 10 resources before returning from the DRAIN query. 11 12 To accomplish this the player monitors the pipeline and whenever a 13 v4l2 decoder is added, synchronous video texture flushing support 14 is enabled. Additionally and for all decoder configurations, a 15 flush is performed before disposing of the player. 16 17 * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp: 18 (WebCore::MediaPlayerPrivateGStreamer::playbinDeepElementAddedCallback): 19 Monitor elements added to the decodebin bin. 20 (WebCore::MediaPlayerPrivateGStreamer::decodebinElementAdded): Set 21 a flag if a v4l2 decoder was added in decodebin. 22 (WebCore::MediaPlayerPrivateGStreamer::createGSTPlayBin): Connect 23 to the deep-element-added signal so as to monitor pipeline 24 topology updates. 25 * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h: 26 * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp: 27 (WebCore::MediaPlayerPrivateGStreamerBase::~MediaPlayerPrivateGStreamerBase): 28 Flush video texture before disposing of the player. 29 (WebCore::MediaPlayerPrivateGStreamerBase::flushCurrentBuffer): 30 Synchronously flush if the pipeline contains a v4l2 decoder. 31 (WebCore::MediaPlayerPrivateGStreamerBase::createGLAppSink): Monitor push events only. 32 * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h: 33 * platform/graphics/texmap/TextureMapperPlatformLayerProxy.cpp: 34 (WebCore::TextureMapperPlatformLayerProxy::pushNextBuffer): New 35 boolean flag used mostly to trigger synchronous flush conditions. 36 (WebCore::TextureMapperPlatformLayerProxy::dropCurrentBufferWhilePreservingTexture): 37 Optionally drop the current buffer in a synchronous manner. By 38 default the method keeps operating asynchronously. 39 * platform/graphics/texmap/TextureMapperPlatformLayerProxy.h: 40 1 41 2019-03-11 Antti Koivisto <antti@apple.com> 2 42 -
trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp
r241751 r242701 2446 2446 g_object_set(m_pipeline.get(), "mute", m_player->muted(), nullptr); 2447 2447 2448 g_signal_connect(GST_BIN_CAST(m_pipeline.get()), "deep-element-added", G_CALLBACK(+[](GstBin*, GstBin* subBin, GstElement* element, MediaPlayerPrivateGStreamer* player) { 2449 GUniquePtr<char> binName(gst_element_get_name(GST_ELEMENT_CAST(subBin))); 2450 if (!g_str_has_prefix(binName.get(), "decodebin")) 2451 return; 2452 2453 GUniquePtr<char> elementName(gst_element_get_name(element)); 2454 player->m_isVideoDecoderVideo4Linux = g_str_has_prefix(elementName.get(), "v4l2"); 2455 }), this); 2456 2448 2457 g_signal_connect_swapped(m_pipeline.get(), "source-setup", G_CALLBACK(sourceSetupCallback), this); 2449 2458 if (m_isLegacyPlaybin) { -
trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp
r241120 r242701 270 270 MediaPlayerPrivateGStreamerBase::~MediaPlayerPrivateGStreamerBase() 271 271 { 272 flushCurrentBuffer(); 272 273 #if USE(TEXTURE_MAPPER_GL) && USE(NICOSIA) 273 274 downcast<Nicosia::ContentLayerTextureMapperImpl>(m_nicosiaLayer->impl()).invalidateClient(); … … 847 848 void MediaPlayerPrivateGStreamerBase::flushCurrentBuffer() 848 849 { 849 GST_DEBUG_OBJECT(pipeline(), "Flushing video sample");850 850 auto sampleLocker = holdLock(m_sampleMutex); 851 851 … … 859 859 860 860 auto proxyOperation = 861 [ ](TextureMapperPlatformLayerProxy& proxy)861 [shouldWait = m_isVideoDecoderVideo4Linux, pipeline = pipeline()](TextureMapperPlatformLayerProxy& proxy) 862 862 { 863 LockHolder locker(proxy.lock()); 863 GST_DEBUG_OBJECT(pipeline, "Flushing video sample %s", shouldWait ? "synchronously" : ""); 864 if (!shouldWait) 865 proxy.lock().lock(); 864 866 865 867 if (proxy.isActive()) 866 proxy.dropCurrentBufferWhilePreservingTexture( );868 proxy.dropCurrentBufferWhilePreservingTexture(shouldWait); 867 869 }; 868 870 … … 1011 1013 1012 1014 GRefPtr<GstPad> pad = adoptGRef(gst_element_get_static_pad(appsink, "sink")); 1013 gst_pad_add_probe(pad.get(), static_cast<GstPadProbeType>(GST_PAD_PROBE_TYPE_ QUERY_DOWNSTREAM | GST_PAD_PROBE_TYPE_EVENT_FLUSH), [] (GstPad*, GstPadProbeInfo* info, gpointer userData) -> GstPadProbeReturn {1015 gst_pad_add_probe(pad.get(), static_cast<GstPadProbeType>(GST_PAD_PROBE_TYPE_PUSH | GST_PAD_PROBE_TYPE_QUERY_DOWNSTREAM | GST_PAD_PROBE_TYPE_EVENT_FLUSH), [] (GstPad*, GstPadProbeInfo* info, gpointer userData) -> GstPadProbeReturn { 1014 1016 // In some platforms (e.g. OpenMAX on the Raspberry Pi) when a resolution change occurs the 1015 1017 // pipeline has to be drained before a frame with the new resolution can be decoded. -
trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h
r241120 r242701 283 283 bool m_waitingForKey { false }; 284 284 #endif 285 286 mutable bool m_isVideoDecoderVideo4Linux { false }; 285 287 }; 286 288 -
trunk/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerProxy.cpp
r242205 r242701 37 37 #include <wtf/glib/RunLoopSourcePriority.h> 38 38 #endif 39 #include <wtf/Scope.h> 39 40 40 41 static const Seconds releaseUnusedSecondsTolerance { 1_s }; … … 114 115 ASSERT(m_lock.isHeld()); 115 116 m_pendingBuffer = WTFMove(newBuffer); 117 m_wasBufferDropped = false; 116 118 117 119 if (m_compositor) … … 188 190 } 189 191 190 void TextureMapperPlatformLayerProxy::dropCurrentBufferWhilePreservingTexture() 191 { 192 ASSERT(m_lock.isHeld()); 192 void TextureMapperPlatformLayerProxy::dropCurrentBufferWhilePreservingTexture(bool shouldWait) 193 { 194 if (!shouldWait) 195 ASSERT(m_lock.isHeld()); 193 196 194 197 if (m_pendingBuffer && m_pendingBuffer->hasManagedTexture()) { … … 201 204 202 205 m_compositorThreadUpdateFunction = 203 [this ] {206 [this, shouldWait] { 204 207 LockHolder locker(m_lock); 208 209 auto maybeNotifySynchronousOperation = WTF::makeScopeExit([this, shouldWait]() { 210 if (shouldWait) { 211 LockHolder holder(m_wasBufferDroppedLock); 212 m_wasBufferDropped = true; 213 m_wasBufferDroppedCondition.notifyAll(); 214 } 215 }); 205 216 206 217 if (!m_compositor || !m_targetLayer || !m_currentBuffer) … … 215 226 appendToUnusedBuffers(WTFMove(prevBuffer)); 216 227 }; 228 229 if (shouldWait) { 230 LockHolder holder(m_wasBufferDroppedLock); 231 m_wasBufferDropped = false; 232 } 233 217 234 m_compositorThreadUpdateTimer->startOneShot(0_s); 235 if (shouldWait) { 236 LockHolder holder(m_wasBufferDroppedLock); 237 m_wasBufferDroppedCondition.wait(m_wasBufferDroppedLock, [this] { 238 return m_wasBufferDropped; 239 }); 240 } 218 241 } 219 242 -
trunk/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerProxy.h
r242205 r242701 29 29 30 30 #include "TextureMapperGLHeaders.h" 31 #include <wtf/Condition.h> 31 32 #include <wtf/Function.h> 32 33 #include <wtf/Lock.h> … … 69 70 70 71 WEBCORE_EXPORT void swapBuffer(); 71 void dropCurrentBufferWhilePreservingTexture( );72 void dropCurrentBufferWhilePreservingTexture(bool shouldWait = false); 72 73 73 74 bool scheduleUpdateOnCompositorThread(Function<void()>&&); … … 86 87 Lock m_lock; 87 88 89 Lock m_wasBufferDroppedLock; 90 Condition m_wasBufferDroppedCondition; 91 bool m_wasBufferDropped { false }; 92 88 93 Vector<std::unique_ptr<TextureMapperPlatformLayerBuffer>> m_usedBuffers; 89 94 std::unique_ptr<RunLoop::Timer<TextureMapperPlatformLayerProxy>> m_releaseUnusedBuffersTimer;
Note: See TracChangeset
for help on using the changeset viewer.