WebKit Bugzilla
Attachment 342538 Details for
Bug 184925
: [GStreamer] Video freezes when GStreamerGL is not installed
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-184925-20180612162825.patch (text/plain), 11.90 KB, created by
Philippe Normand
on 2018-06-12 08:28:26 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Philippe Normand
Created:
2018-06-12 08:28:26 PDT
Size:
11.90 KB
patch
obsolete
>Subversion Revision: 232753 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index d131d3123c8a0304a018bf323ee63dfb6166e9fb..7be78278c0d9e88cf5b71743a6e470bb3d1d00b2 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,26 @@ >+2018-06-12 Philippe Normand <pnormand@igalia.com> >+ >+ [GStreamer] Video freezes when GStreamerGL is not installed >+ https://bugs.webkit.org/show_bug.cgi?id=184925 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ At runtime when the GStreamer opengl plugin isn't available the >+ player will fallback to the internal WebKit video sink. The >+ VideoFrameHolder was refactored to handle both cases (opengl, >+ non-opengl). >+ >+ * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp: >+ (WebCore::GstVideoFrameHolder::GstVideoFrameHolder): >+ (WebCore::GstVideoFrameHolder::~GstVideoFrameHolder): >+ (WebCore::GstVideoFrameHolder::frame const): >+ (WebCore::GstVideoFrameHolder::updateTexture): >+ (WebCore::MediaPlayerPrivateGStreamerBase::pushTextureToCompositor): >+ (WebCore::MediaPlayerPrivateGStreamerBase::triggerRepaint): >+ (WebCore::GstVideoFrameHolder::isValid const): Deleted. >+ (WebCore::MediaPlayerPrivateGStreamerBase::updateTexture): Deleted. >+ * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h: >+ > 2018-06-12 Philippe Normand <pnormand@igalia.com> > > Unreviewed WPE build fix after r232749. >diff --git a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp >index 041105840aba7ac0a40adba9643226e65e2f3349..3ce33e683daef1eb979c8aa9312c130793cffe9b 100644 >--- a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp >+++ b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp >@@ -199,29 +199,44 @@ static inline TextureMapperGL::Flags texMapFlagFromOrientation(const ImageOrient > } > #endif > >-#if USE(GSTREAMER_GL) >+#if USE(TEXTURE_MAPPER_GL) > class GstVideoFrameHolder : public TextureMapperPlatformLayerBuffer::UnmanagedBufferDataHolder { > public: >- explicit GstVideoFrameHolder(GstSample* sample, TextureMapperGL::Flags flags) >+ explicit GstVideoFrameHolder(GstSample* sample, TextureMapperGL::Flags flags, bool gstGLEnabled) > { > GstVideoInfo videoInfo; > if (UNLIKELY(!getSampleVideoInfo(sample, videoInfo))) > return; > > m_size = IntSize(GST_VIDEO_INFO_WIDTH(&videoInfo), GST_VIDEO_INFO_HEIGHT(&videoInfo)); >- m_flags = flags | (GST_VIDEO_INFO_HAS_ALPHA(&videoInfo) ? TextureMapperGL::ShouldBlend : 0) | TEXTURE_MAPPER_COLOR_CONVERT_FLAG; >+ m_buffer = gst_sample_get_buffer(sample); > >- GstBuffer* buffer = gst_sample_get_buffer(sample); >- if (UNLIKELY(!gst_video_frame_map(&m_videoFrame, &videoInfo, buffer, static_cast<GstMapFlags>(GST_MAP_READ | GST_MAP_GL)))) >- return; >+#if USE(GSTREAMER_GL) >+ m_flags = flags | TEXTURE_MAPPER_COLOR_CONVERT_FLAG; >+ >+ if (gstGLEnabled) { >+ m_isMapped = gst_video_frame_map(&m_videoFrame, &videoInfo, m_buffer, static_cast<GstMapFlags>(GST_MAP_READ | GST_MAP_GL)); >+ if (m_isMapped) >+ m_textureID = *reinterpret_cast<GLuint*>(m_videoFrame.data[0]); >+ } else >+#endif // USE(GSTREAMER_GL) > >- m_textureID = *reinterpret_cast<GLuint*>(m_videoFrame.data[0]); >- m_isValid = true; >+ { >+ m_textureID = 0; >+ m_flags = flags | (GST_VIDEO_INFO_HAS_ALPHA(&videoInfo) ? BitmapTexture::SupportsAlpha : BitmapTexture::NoFlag); >+ m_isMapped = gst_video_frame_map(&m_videoFrame, &videoInfo, m_buffer, GST_MAP_READ); >+ if (m_isMapped) { >+ // Right now the TextureMapper only supports chromas with one plane >+ ASSERT(GST_VIDEO_INFO_N_PLANES(&videoInfo) == 1); >+ } >+ } >+ >+ m_flags |= (GST_VIDEO_INFO_HAS_ALPHA(&videoInfo) ? TextureMapperGL::ShouldBlend : 0); > } > > virtual ~GstVideoFrameHolder() > { >- if (UNLIKELY(!m_isValid)) >+ if (UNLIKELY(!m_isMapped)) > return; > > gst_video_frame_unmap(&m_videoFrame); >@@ -230,16 +245,35 @@ public: > const IntSize& size() const { return m_size; } > TextureMapperGL::Flags flags() const { return m_flags; } > GLuint textureID() const { return m_textureID; } >- bool isValid() const { return m_isValid; } >+ GstVideoFrame frame() const { return m_videoFrame; } >+ >+ void updateTexture(BitmapTextureGL& texture) >+ { >+ ASSERT(!m_textureID); >+ GstVideoGLTextureUploadMeta* meta; >+ if ((meta = gst_buffer_get_video_gl_texture_upload_meta(m_buffer))) { >+ if (meta->n_textures == 1) { // BRGx & BGRA formats use only one texture. >+ guint ids[4] = { texture.id(), 0, 0, 0 }; >+ >+ if (gst_video_gl_texture_upload_meta_upload(meta, ids)) >+ return; >+ } >+ } >+ >+ int stride = GST_VIDEO_FRAME_PLANE_STRIDE(&m_videoFrame, 0); >+ const void* srcData = GST_VIDEO_FRAME_PLANE_DATA(&m_videoFrame, 0); >+ texture.updateContents(srcData, WebCore::IntRect(0, 0, m_size.width(), m_size.height()), WebCore::IntPoint(0, 0), stride); >+ } > > private: >+ GstBuffer* m_buffer; > GstVideoFrame m_videoFrame; > IntSize m_size; > TextureMapperGL::Flags m_flags; >- GLuint m_textureID; >- bool m_isValid { false }; >+ GLuint m_textureID { 0 }; >+ bool m_isMapped { false }; > }; >-#endif // USE(GSTREAMER_GL) >+#endif > > MediaPlayerPrivateGStreamerBase::MediaPlayerPrivateGStreamerBase(MediaPlayer* player) > : m_notifier(MainThreadNotifier<MainThreadNotification>::create()) >@@ -701,33 +735,6 @@ void MediaPlayerPrivateGStreamerBase::acceleratedRenderingStateChanged() > } > > #if USE(TEXTURE_MAPPER_GL) >-void MediaPlayerPrivateGStreamerBase::updateTexture(BitmapTextureGL& texture, GstVideoInfo& videoInfo) >-{ >- GstBuffer* buffer = gst_sample_get_buffer(m_sample.get()); >- >- GstVideoGLTextureUploadMeta* meta; >- if ((meta = gst_buffer_get_video_gl_texture_upload_meta(buffer))) { >- if (meta->n_textures == 1) { // BRGx & BGRA formats use only one texture. >- guint ids[4] = { texture.id(), 0, 0, 0 }; >- >- if (gst_video_gl_texture_upload_meta_upload(meta, ids)) >- return; >- } >- } >- >- // Right now the TextureMapper only supports chromas with one plane >- ASSERT(GST_VIDEO_INFO_N_PLANES(&videoInfo) == 1); >- >- GstVideoFrame videoFrame; >- if (!gst_video_frame_map(&videoFrame, &videoInfo, buffer, GST_MAP_READ)) >- return; >- >- int stride = GST_VIDEO_FRAME_PLANE_STRIDE(&videoFrame, 0); >- const void* srcData = GST_VIDEO_FRAME_PLANE_DATA(&videoFrame, 0); >- texture.updateContents(srcData, WebCore::IntRect(0, 0, GST_VIDEO_INFO_WIDTH(&videoInfo), GST_VIDEO_INFO_HEIGHT(&videoInfo)), WebCore::IntPoint(0, 0), stride); >- gst_video_frame_unmap(&videoFrame); >-} >- > RefPtr<TextureMapperPlatformLayerProxy> MediaPlayerPrivateGStreamerBase::proxy() const > { > return m_platformLayerProxy.copyRef(); >@@ -739,24 +746,6 @@ void MediaPlayerPrivateGStreamerBase::swapBuffersIfNeeded() > > void MediaPlayerPrivateGStreamerBase::pushTextureToCompositor() > { >-#if !USE(GSTREAMER_GL) >- class ConditionNotifier { >- public: >- ConditionNotifier(Lock& lock, Condition& condition) >- : m_locker(lock), m_condition(condition) >- { >- } >- ~ConditionNotifier() >- { >- m_condition.notifyOne(); >- } >- private: >- LockHolder m_locker; >- Condition& m_condition; >- }; >- ConditionNotifier notifier(m_drawMutex, m_drawCondition); >-#endif >- > auto sampleLocker = holdLock(m_sampleMutex); > if (!GST_IS_SAMPLE(m_sample.get())) > return; >@@ -766,30 +755,24 @@ void MediaPlayerPrivateGStreamerBase::pushTextureToCompositor() > if (!m_platformLayerProxy->isActive()) > return; > >-#if USE(GSTREAMER_GL) >- std::unique_ptr<GstVideoFrameHolder> frameHolder = std::make_unique<GstVideoFrameHolder>(m_sample.get(), texMapFlagFromOrientation(m_videoSourceOrientation)); >- if (UNLIKELY(!frameHolder->isValid())) >- return; >+ std::unique_ptr<GstVideoFrameHolder> frameHolder = std::make_unique<GstVideoFrameHolder>(m_sample.get(), texMapFlagFromOrientation(m_videoSourceOrientation), !m_usingFallbackVideoSink); > >- std::unique_ptr<TextureMapperPlatformLayerBuffer> layerBuffer = std::make_unique<TextureMapperPlatformLayerBuffer>(frameHolder->textureID(), frameHolder->size(), frameHolder->flags(), GraphicsContext3D::RGBA); >- layerBuffer->setUnmanagedBufferDataHolder(WTFMove(frameHolder)); >- m_platformLayerProxy->pushNextBuffer(WTFMove(layerBuffer)); >-#else >- GstVideoInfo videoInfo; >- if (UNLIKELY(!getSampleVideoInfo(m_sample.get(), videoInfo))) >- return; >- >- IntSize size = IntSize(GST_VIDEO_INFO_WIDTH(&videoInfo), GST_VIDEO_INFO_HEIGHT(&videoInfo)); >- std::unique_ptr<TextureMapperPlatformLayerBuffer> buffer = m_platformLayerProxy->getAvailableBuffer(size, GL_DONT_CARE); >- if (UNLIKELY(!buffer)) { >- auto texture = BitmapTextureGL::create(TextureMapperContextAttributes::get()); >- texture->reset(size, GST_VIDEO_INFO_HAS_ALPHA(&videoInfo) ? BitmapTexture::SupportsAlpha : BitmapTexture::NoFlag); >- buffer = std::make_unique<TextureMapperPlatformLayerBuffer>(WTFMove(texture)); >+ GLuint textureID = frameHolder->textureID(); >+ if (textureID) { >+ std::unique_ptr<TextureMapperPlatformLayerBuffer> layerBuffer = std::make_unique<TextureMapperPlatformLayerBuffer>(textureID, frameHolder->size(), frameHolder->flags(), GraphicsContext3D::RGBA); >+ layerBuffer->setUnmanagedBufferDataHolder(WTFMove(frameHolder)); >+ m_platformLayerProxy->pushNextBuffer(WTFMove(layerBuffer)); >+ } else { >+ std::unique_ptr<TextureMapperPlatformLayerBuffer> buffer = m_platformLayerProxy->getAvailableBuffer(frameHolder->size(), GL_DONT_CARE); >+ if (UNLIKELY(!buffer)) { >+ auto texture = BitmapTextureGL::create(TextureMapperContextAttributes::get()); >+ texture->reset(frameHolder->size(), frameHolder->flags()); >+ buffer = std::make_unique<TextureMapperPlatformLayerBuffer>(WTFMove(texture)); >+ } >+ frameHolder->updateTexture(buffer->textureGL()); >+ buffer->setExtraFlags(frameHolder->flags()); >+ m_platformLayerProxy->pushNextBuffer(WTFMove(buffer)); > } >- updateTexture(buffer->textureGL(), videoInfo); >- buffer->setExtraFlags(texMapFlagFromOrientation(m_videoSourceOrientation) | (GST_VIDEO_INFO_HAS_ALPHA(&videoInfo) ? TextureMapperGL::ShouldBlend : 0)); >- m_platformLayerProxy->pushNextBuffer(WTFMove(buffer)); >-#endif // USE(GSTREAMER_GL) > } > #endif // USE(TEXTURE_MAPPER_GL) > >@@ -830,16 +813,13 @@ void MediaPlayerPrivateGStreamerBase::triggerRepaint(GstSample* sample) > } > > #if USE(TEXTURE_MAPPER_GL) >-#if USE(GSTREAMER_GL) >- pushTextureToCompositor(); >-#else > { > LockHolder lock(m_drawMutex); > if (!m_platformLayerProxy->scheduleUpdateOnCompositorThread([this] { this->pushTextureToCompositor(); })) > return; >+ m_drawTimer.startOneShot(0_s); > m_drawCondition.wait(m_drawMutex); > } >-#endif > #endif // USE(TEXTURE_MAPPER_GL) > } > >diff --git a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h >index 7862a8cd5c235163e821706ee82c77e1fa47611b..30ca02e29d7a326c6d2b71a338bb194fa43b5e75 100644 >--- a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h >+++ b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h >@@ -175,7 +175,6 @@ protected: > #endif > > #if USE(TEXTURE_MAPPER_GL) >- void updateTexture(BitmapTextureGL&, GstVideoInfo&); > RefPtr<TextureMapperPlatformLayerProxy> proxy() const override; > void swapBuffersIfNeeded() override; > void pushTextureToCompositor();
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 184925
:
342538
|
342552
|
342637
|
342643
|
342644
|
342647