Skip to content

Commit

Permalink
[GStreamer] Harness: Basic GstStream handling
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=269056

Reviewed by Xabier Rodriguez-Calvar.

When fetching the Stream caps, first check if there is an associated GstStream, because its caps
might be more accurate than the ones sticked on the corresponding pad.

* Source/WebCore/platform/gstreamer/GStreamerElementHarness.cpp:
(WebCore::GStreamerElementHarness::Stream::outputCaps):
(WebCore::GStreamerElementHarness::Stream::sinkEvent):

Canonical link: https://commits.webkit.org/274456@main
  • Loading branch information
philn committed Feb 12, 2024
1 parent 21b6595 commit 8cf5489
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions Source/WebCore/platform/gstreamer/GStreamerElementHarness.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,11 @@ const GRefPtr<GstCaps>& GStreamerElementHarness::Stream::outputCaps()
if (m_outputCaps)
return m_outputCaps;

m_outputCaps = adoptGRef(gst_pad_get_current_caps(m_pad.get()));
auto stream = adoptGRef(gst_pad_get_stream(m_pad.get()));
if (stream)
m_outputCaps = adoptGRef(gst_stream_get_caps(stream.get()));
else
m_outputCaps = adoptGRef(gst_pad_get_current_caps(m_pad.get()));
GST_DEBUG_OBJECT(m_pad.get(), "Output caps: %" GST_PTR_FORMAT, m_outputCaps.get());
return m_outputCaps;
}
Expand All @@ -365,8 +369,9 @@ bool GStreamerElementHarness::Stream::sinkEvent(GstEvent* event)
{
Locker locker { m_sinkEventQueueLock };

// Clear cached output caps when the pad receives a new caps event.
if (GST_EVENT_TYPE(event) == GST_EVENT_CAPS)
// Clear cached output caps when the pad receives a new caps event or stream-start (potentially
// storing a GstStream).
if (GST_EVENT_TYPE(event) == GST_EVENT_CAPS || GST_EVENT_TYPE(event) == GST_EVENT_STREAM_START)
m_outputCaps = nullptr;

m_sinkEventQueue.prepend(GRefPtr<GstEvent>(event));
Expand Down

0 comments on commit 8cf5489

Please sign in to comment.