mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-03-28 20:05:38 +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,
|
||||
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
|
||||
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,
|
||||
self, NULL);
|
||||
} else {
|
||||
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!");
|
||||
}
|
||||
gst_uvc_sink_update_streaming (self);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
case GST_QUERY_ALLOCATION:
|
||||
|
@ -366,20 +373,7 @@ gst_uvc_sink_sinkpad_event_peer_probe (GstPad * pad,
|
|||
if (self->streamon || self->streamoff)
|
||||
g_atomic_int_set (&self->caps_changed, FALSE);
|
||||
|
||||
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!");
|
||||
}
|
||||
gst_uvc_sink_update_streaming (self);
|
||||
|
||||
return GST_PAD_PROBE_REMOVE;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue