mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-20 13:06:23 +00:00
uridecodebin3: Don't use decodebin3 static sink pad
Makes the code leaner, and fixes the issue which would happen when the urisourcebin stream that was linked to the sink pad goes away (without any replacement). Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7949>
This commit is contained in:
parent
eb24c0eabc
commit
18d83192be
1 changed files with 3 additions and 47 deletions
|
@ -167,9 +167,6 @@ struct _GstSourcePad
|
|||
/* Decodebin3 pad to which src_pad is linked to */
|
||||
GstPad *db3_sink_pad;
|
||||
|
||||
/* TRUE if db3_sink_pad is a request pad */
|
||||
gboolean db3_pad_is_request;
|
||||
|
||||
/* TRUE if EOS went through the source pad. Marked as TRUE if decodebin3
|
||||
* notified `about-to-finish` for pull mode */
|
||||
gboolean saw_eos;
|
||||
|
@ -981,20 +978,7 @@ link_src_pad_to_db3 (GstURIDecodeBin3 * uridecodebin, GstSourcePad * spad)
|
|||
GstSourceHandler *handler = spad->handler;
|
||||
GstPad *sinkpad = NULL;
|
||||
|
||||
/* Try to link to main sink pad only if it's from a main handler */
|
||||
if (handler->is_main_source) {
|
||||
sinkpad = gst_element_get_static_pad (uridecodebin->decodebin, "sink");
|
||||
if (gst_pad_is_linked (sinkpad)) {
|
||||
gst_object_unref (sinkpad);
|
||||
sinkpad = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (sinkpad == NULL) {
|
||||
sinkpad =
|
||||
gst_element_request_pad_simple (uridecodebin->decodebin, "sink_%u");
|
||||
spad->db3_pad_is_request = TRUE;
|
||||
}
|
||||
sinkpad = gst_element_request_pad_simple (uridecodebin->decodebin, "sink_%u");
|
||||
|
||||
if (sinkpad) {
|
||||
GstPadLinkReturn res;
|
||||
|
@ -1122,7 +1106,6 @@ switch_and_activate_input_locked (GstURIDecodeBin3 * uridecodebin,
|
|||
GST_DEBUG_PAD_NAME (new_spad->src_pad));
|
||||
gst_pad_unlink (old_spad->src_pad, old_spad->db3_sink_pad);
|
||||
new_spad->db3_sink_pad = old_spad->db3_sink_pad;
|
||||
new_spad->db3_pad_is_request = old_spad->db3_pad_is_request;
|
||||
old_spad->db3_sink_pad = NULL;
|
||||
|
||||
/* NOTE : Pad will be linked further down */
|
||||
|
@ -1133,37 +1116,10 @@ switch_and_activate_input_locked (GstURIDecodeBin3 * uridecodebin,
|
|||
}
|
||||
}
|
||||
|
||||
/* If the old pads contains the static decodebin3 sinkpad *and* we have a new
|
||||
* pad to activate, we re-use it */
|
||||
if (to_activate) {
|
||||
/* Remove unmatched old source pads */
|
||||
for (iterold = old_pads; iterold; iterold = iterold->next) {
|
||||
GstSourcePad *old_spad = iterold->data;
|
||||
if (old_spad->db3_sink_pad && !old_spad->db3_pad_is_request) {
|
||||
GstSourcePad *new_spad = to_activate->data;
|
||||
|
||||
GST_DEBUG_OBJECT (uridecodebin, "Static sinkpad can be re-used");
|
||||
GST_DEBUG_OBJECT (uridecodebin, "Relinking %s:%s from %s:%s to %s:%s",
|
||||
GST_DEBUG_PAD_NAME (old_spad->db3_sink_pad),
|
||||
GST_DEBUG_PAD_NAME (old_spad->src_pad),
|
||||
GST_DEBUG_PAD_NAME (new_spad->src_pad));
|
||||
gst_pad_unlink (old_spad->src_pad, old_spad->db3_sink_pad);
|
||||
new_spad->db3_sink_pad = old_spad->db3_sink_pad;
|
||||
new_spad->db3_pad_is_request = old_spad->db3_pad_is_request;
|
||||
old_spad->db3_sink_pad = NULL;
|
||||
|
||||
/* NOTE : Pad will be linked further down */
|
||||
old_pads = g_list_remove (old_pads, old_spad);
|
||||
to_activate = g_list_remove (to_activate, new_spad);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Remove unmatched old source pads */
|
||||
for (iterold = old_pads; iterold; iterold = iterold->next) {
|
||||
GstSourcePad *old_spad = iterold->data;
|
||||
if (old_spad->db3_sink_pad && old_spad->db3_pad_is_request) {
|
||||
if (old_spad->db3_sink_pad) {
|
||||
GST_DEBUG_OBJECT (uridecodebin, "Releasing no longer used db3 pad");
|
||||
gst_element_release_request_pad (uridecodebin->decodebin,
|
||||
old_spad->db3_sink_pad);
|
||||
|
@ -1499,7 +1455,7 @@ src_pad_removed_cb (GstElement * element, GstPad * pad,
|
|||
"Source %" GST_PTR_FORMAT " removed pad %" GST_PTR_FORMAT " peer %"
|
||||
GST_PTR_FORMAT, element, pad, spad->db3_sink_pad);
|
||||
|
||||
if (spad->db3_sink_pad && spad->db3_pad_is_request)
|
||||
if (spad->db3_sink_pad)
|
||||
gst_element_release_request_pad (uridecodebin->decodebin,
|
||||
spad->db3_sink_pad);
|
||||
|
||||
|
|
Loading…
Reference in a new issue