mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
uvcsink: extract helper function for updating the stream state
The uvcsink may switch to the v4l2sink after a STREAMON either on a caps event or on a caps query. Extract the code that handles the STREAMON into a helper function, as this is the same code. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4994>
This commit is contained in:
parent
24daf9ea3d
commit
6637343980
1 changed files with 22 additions and 28 deletions
|
@ -227,6 +227,25 @@ static gboolean gst_uvc_sink_to_v4l2sink (GstUvcSink * self);
|
||||||
static GstPadProbeReturn gst_uvc_sink_sinkpad_event_peer_probe (GstPad * pad,
|
static GstPadProbeReturn gst_uvc_sink_sinkpad_event_peer_probe (GstPad * pad,
|
||||||
GstPadProbeInfo * info, GstUvcSink * self);
|
GstPadProbeInfo * info, GstUvcSink * self);
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_uvc_sink_update_streaming (GstUvcSink * self)
|
||||||
|
{
|
||||||
|
if (self->streamon) {
|
||||||
|
g_atomic_int_set (&self->streamon, FALSE);
|
||||||
|
gst_uvc_sink_to_v4l2sink (self);
|
||||||
|
|
||||||
|
if (!self->streaming)
|
||||||
|
GST_DEBUG_OBJECT (self, "something went wrong!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (self->streamoff) {
|
||||||
|
g_atomic_int_set (&self->streamoff, FALSE);
|
||||||
|
|
||||||
|
if (self->streaming)
|
||||||
|
GST_DEBUG_OBJECT (self, "something went wrong!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_uvc_sink_query (GstPad * pad, GstObject * parent, GstQuery * query)
|
gst_uvc_sink_query (GstPad * pad, GstObject * parent, GstQuery * query)
|
||||||
{
|
{
|
||||||
|
@ -247,21 +266,9 @@ gst_uvc_sink_query (GstPad * pad, GstObject * parent, GstQuery * query)
|
||||||
(GstPadProbeCallback) gst_uvc_sink_sinkpad_event_peer_probe,
|
(GstPadProbeCallback) gst_uvc_sink_sinkpad_event_peer_probe,
|
||||||
self, NULL);
|
self, NULL);
|
||||||
} else {
|
} else {
|
||||||
if (self->streamon) {
|
gst_uvc_sink_update_streaming (self);
|
||||||
g_atomic_int_set (&self->streamon, FALSE);
|
|
||||||
gst_uvc_sink_to_v4l2sink (self);
|
|
||||||
|
|
||||||
if (!self->streaming)
|
|
||||||
GST_DEBUG_OBJECT (self, "something went wrong!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (self->streamoff) {
|
|
||||||
g_atomic_int_set (&self->streamoff, FALSE);
|
|
||||||
|
|
||||||
if (self->streaming)
|
|
||||||
GST_DEBUG_OBJECT (self, "something went wrong!");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
case GST_QUERY_ALLOCATION:
|
case GST_QUERY_ALLOCATION:
|
||||||
|
@ -366,20 +373,7 @@ gst_uvc_sink_sinkpad_event_peer_probe (GstPad * pad,
|
||||||
if (self->streamon || self->streamoff)
|
if (self->streamon || self->streamoff)
|
||||||
g_atomic_int_set (&self->caps_changed, FALSE);
|
g_atomic_int_set (&self->caps_changed, FALSE);
|
||||||
|
|
||||||
if (self->streamon) {
|
gst_uvc_sink_update_streaming (self);
|
||||||
g_atomic_int_set (&self->streamon, FALSE);
|
|
||||||
gst_uvc_sink_to_v4l2sink (self);
|
|
||||||
|
|
||||||
if (!self->streaming)
|
|
||||||
GST_DEBUG_OBJECT (self, "something went wrong!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (self->streamoff) {
|
|
||||||
g_atomic_int_set (&self->streamoff, FALSE);
|
|
||||||
|
|
||||||
if (self->streaming)
|
|
||||||
GST_DEBUG_OBJECT (self, "something went wrong!");
|
|
||||||
}
|
|
||||||
|
|
||||||
return GST_PAD_PROBE_REMOVE;
|
return GST_PAD_PROBE_REMOVE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue