Skip to content

Commit

Permalink
[GStreamer][WebRTC] Minor cleanups in IncomingSourceGStreamer
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=247423

Reviewed by Xabier Rodriguez-Calvar.

There is no need for a queue between the valve and the tee. Utility methods for opening/closing now
un-needed were removed as well.

* Source/WebCore/platform/mediastream/gstreamer/RealtimeIncomingSourceGStreamer.cpp:
(WebCore::RealtimeIncomingSourceGStreamer::RealtimeIncomingSourceGStreamer):
(WebCore::RealtimeIncomingSourceGStreamer::startProducingData):
(WebCore::RealtimeIncomingSourceGStreamer::stopProducingData):
(WebCore::RealtimeIncomingSourceGStreamer::closeValve const): Deleted.
(WebCore::RealtimeIncomingSourceGStreamer::openValve const): Deleted.
* Source/WebCore/platform/mediastream/gstreamer/RealtimeIncomingSourceGStreamer.h:
* Source/WebCore/platform/mediastream/gstreamer/RealtimeIncomingVideoSourceGStreamer.cpp:

Canonical link: https://commits.webkit.org/256393@main
  • Loading branch information
philn committed Nov 7, 2022
1 parent 678b80c commit 25fd484
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 26 deletions.
Expand Up @@ -39,10 +39,8 @@ RealtimeIncomingSourceGStreamer::RealtimeIncomingSourceGStreamer(const CaptureDe
m_tee = gst_element_factory_make("tee", nullptr);
g_object_set(m_tee.get(), "allow-not-linked", true, nullptr);

auto* queue = gst_element_factory_make("queue", nullptr);
gst_bin_add_many(GST_BIN_CAST(m_bin.get()), m_valve.get(), queue, m_tee.get(), nullptr);

gst_element_link_many(m_valve.get(), queue, m_tee.get(), nullptr);
gst_bin_add_many(GST_BIN_CAST(m_bin.get()), m_valve.get(), m_tee.get(), nullptr);
gst_element_link(m_valve.get(), m_tee.get());

auto sinkPad = adoptGRef(gst_element_get_static_pad(m_valve.get(), "sink"));
gst_element_add_pad(m_bin.get(), gst_ghost_pad_new("sink", sinkPad.get()));
Expand All @@ -51,34 +49,22 @@ RealtimeIncomingSourceGStreamer::RealtimeIncomingSourceGStreamer(const CaptureDe
void RealtimeIncomingSourceGStreamer::startProducingData()
{
GST_DEBUG_OBJECT(bin(), "Starting data flow");
openValve();
if (m_valve)
g_object_set(m_valve.get(), "drop", FALSE, nullptr);
}

void RealtimeIncomingSourceGStreamer::stopProducingData()
{
GST_DEBUG_OBJECT(bin(), "Stopping data flow");
closeValve();
if (m_valve)
g_object_set(m_valve.get(), "drop", TRUE, nullptr);
}

const RealtimeMediaSourceCapabilities& RealtimeIncomingSourceGStreamer::capabilities()
{
return RealtimeMediaSourceCapabilities::emptyCapabilities();
}

void RealtimeIncomingSourceGStreamer::closeValve() const
{
GST_DEBUG_OBJECT(m_bin.get(), "Closing valve");
if (m_valve)
g_object_set(m_valve.get(), "drop", true, nullptr);
}

void RealtimeIncomingSourceGStreamer::openValve() const
{
GST_DEBUG_OBJECT(m_bin.get(), "Opening valve");
if (m_valve)
g_object_set(m_valve.get(), "drop", false, nullptr);
}

void RealtimeIncomingSourceGStreamer::registerClient()
{
GST_DEBUG_OBJECT(m_bin.get(), "Registering new client");
Expand Down
Expand Up @@ -36,11 +36,6 @@ class RealtimeIncomingSourceGStreamer : public RealtimeMediaSource {
protected:
RealtimeIncomingSourceGStreamer(const CaptureDevice&);

void closeValve() const;
void openValve() const;

GRefPtr<GstElement> m_valve;

private:
// RealtimeMediaSource API
void startProducingData() final;
Expand All @@ -51,6 +46,7 @@ class RealtimeIncomingSourceGStreamer : public RealtimeMediaSource {
void handleDownstreamEvent(GRefPtr<GstEvent>&&);

GRefPtr<GstElement> m_bin;
GRefPtr<GstElement> m_valve;
GRefPtr<GstElement> m_tee;
};

Expand Down
Expand Up @@ -45,7 +45,7 @@ RealtimeIncomingVideoSourceGStreamer::RealtimeIncomingVideoSourceGStreamer(AtomS
m_currentSettings = RealtimeMediaSourceSettings { };
m_currentSettings->setSupportedConstraints(WTFMove(constraints));

auto sinkPad = adoptGRef(gst_element_get_static_pad(m_valve.get(), "sink"));
auto sinkPad = adoptGRef(gst_element_get_static_pad(bin(), "sink"));
gst_pad_add_probe(sinkPad.get(), static_cast<GstPadProbeType>(GST_PAD_PROBE_TYPE_BUFFER), [](GstPad*, GstPadProbeInfo* info, gpointer) -> GstPadProbeReturn {
auto videoFrameTimeMetadata = std::make_optional<VideoFrameTimeMetadata>({ });
videoFrameTimeMetadata->receiveTime = MonotonicTime::now().secondsSinceEpoch();
Expand Down

0 comments on commit 25fd484

Please sign in to comment.