Commit graph

226 commits

Author SHA1 Message Date
Guillaume Desmottes
d972acd3c5 uridecodebin3: fix deadlock when switching input item
There was a race between urisourcebin src pad handlers.
One was starting the next item before the other was blocked.

See
https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/3297#note_2288799
for details.

Fix #3297

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6145>
2024-02-19 16:22:12 +01:00
Philippe Normand
2834973d55 parsebin: Fix stream type for encrypted streams
Without this patch the stream type for encrypted streams would be 'unknown'.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6138>
2024-02-19 09:50:03 +00:00
Edward Hervey
d62c6e1084 urisourcebin: Don't acquire STATE_LOCK if shutting down
If we are shutting down (PAUSED->READY) we shouldn't take the STATE LOCK since
this function is being called from a streaming thread (which is trying to be
deactivated while the STATE LOCK is held)

Fixes #3292

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6121>
2024-02-15 10:09:10 +00:00
Thibault Saunier
e17c7a0b7f playbin3: Fix deadlock while selecting streams going to playing
In the following backtrace for the deadlock, we can see that:

- In T8 `uridecodebin3` is exposing a new pad, in `pad_added_cb`,
  `playbin3` is trying to get `GST_PLAY_BIN3_LOCK` in the callback. This
  threads holds its `SELECTION_LOCK` in F17 `reconfigure_output_stream`,
  which is looks right `decodebin3` is handling its selection state
  in that code path

- In T7 `playbin3` holds the `GST_PLAY_BIN3_LOCK` when calling
  `gst_element_post_message` in `gst_play_bin3_send_event` which is
  not necessary in that section of the code.

``` bt
Thread 8 (Thread 0x7f0b78ee36c0 (LWP 2952467) "multiqueue0:src"):
 #0  futex_wait (private=0, expected=2, futex_word=0x1fa6d60) at ../sysdeps/nptl/futex-internal.h:146
 #1  __GI___lll_lock_wait (futex=futex@entry=0x1fa6d60, private=0) at lowlevellock.c:49
 #2  0x00007f0b858cd46a in lll_mutex_lock_optimized (mutex=0x1fa6d60) at pthread_mutex_lock.c:48
 #3  ___pthread_mutex_lock (mutex=0x1fa6d60) at pthread_mutex_lock.c:128
 #4  0x00007f0b7e665720 in pad_added_cb (uridecodebin=0x1fb4050, pad=0x7f0b54022060, playbin=0x1fb00e0) at ../subprojects/gst-plugins-base/gst/playback/gstplaybin3.c:2463
 #5  0x00007f0b85c00060 in g_closure_invoke (closure=0x1fa9eb0, return_value=0x0, n_param_values=2, param_values=0x7f0b78ee1dd0, invocation_hint=0x7f0b78ee1d50) at ../gobject/gclosure.c:832
 #6  0x00007f0b85c2cf66 in signal_emit_unlocked_R.isra.0 (node=node@entry=0x1c5bf30, detail=detail@entry=0, instance=instance@entry=0x1fb4050, emission_return=emission_return@entry=0x0, instance_and_params=instance_and_params@entry=0x7f0b78ee1dd0) at ../gobject/gsignal.c:3796
 #7  0x00007f0b85c1d4da in g_signal_emit_valist (instance=<optimized out>, signal_id=<optimized out>, detail=<optimized out>, var_args=var_args@entry=0x7f0b78ee1f90) at ../gobject/gsignal.c:3549
 #8  0x00007f0b85c1d6f3 in g_signal_emit (instance=<optimized out>, signal_id=<optimized out>, detail=<optimized out>) at ../gobject/gsignal.c:3606
 #9  0x00007f0b85e20c3e in gst_element_add_pad (element=0x1fb4050, pad=0x7f0b54022060) at ../subprojects/gstreamer/gst/gstelement.c:802
 #10 0x00007f0b7e632620 in add_output_pad (dec=0x1fb4050, target_pad=0x7f0b6400fda0) at ../subprojects/gst-plugins-base/gst/playback/gsturidecodebin3.c:717
 #11 0x00007f0b7e632788 in db_pad_added_cb (element=0x1fb8020, pad=0x7f0b6400fda0, dec=0x1fb4050) at ../subprojects/gst-plugins-base/gst/playback/gsturidecodebin3.c:736
 #12 0x00007f0b85c00060 in g_closure_invoke (closure=0x1fb7fc0, return_value=0x0, n_param_values=2, param_values=0x7f0b78ee2300, invocation_hint=0x7f0b78ee2280) at ../gobject/gclosure.c:832
 #13 0x00007f0b85c2cf66 in signal_emit_unlocked_R.isra.0 (node=node@entry=0x1c5bf30, detail=detail@entry=0, instance=instance@entry=0x1fb8020, emission_return=emission_return@entry=0x0, instance_and_params=instance_and_params@entry=0x7f0b78ee2300) at ../gobject/gsignal.c:3796
 #14 0x00007f0b85c1d4da in g_signal_emit_valist (instance=<optimized out>, signal_id=<optimized out>, detail=<optimized out>, var_args=var_args@entry=0x7f0b78ee24c0) at ../gobject/gsignal.c:3549
 #15 0x00007f0b85c1d6f3 in g_signal_emit (instance=<optimized out>, signal_id=<optimized out>, detail=<optimized out>) at ../gobject/gsignal.c:3606
 #16 0x00007f0b85e20c3e in gst_element_add_pad (element=0x1fb8020, pad=0x7f0b6400fda0) at ../subprojects/gstreamer/gst/gstelement.c:802
 #17 0x00007f0b7e6260b4 in reconfigure_output_stream (output=0x7f0b5400def0, slot=0x7f0b64013dd0, msg=0x7f0b78ee26b8) at ../subprojects/gst-plugins-base/gst/playback/gstdecodebin3.c:3086
 #18 0x00007f0b7e623700 in check_slot_reconfiguration (dbin=0x1fb8020, slot=0x7f0b64013dd0) at ../subprojects/gst-plugins-base/gst/playback/gstdecodebin3.c:2455
 #19 0x00007f0b7e623e62 in multiqueue_src_probe (pad=0x7f0b6001e600, info=0x7f0b78ee2930, slot=0x7f0b64013dd0) at ../subprojects/gst-plugins-base/gst/playback/gstdecodebin3.c:2544
 #20 0x00007f0b85e53aaa in probe_hook_marshal (hook=0x7f0b74040500, data=0x7f0b78ee28c0) at ../subprojects/gstreamer/gst/gstpad.c:3669
 #21 0x00007f0b85c88a3e in g_hook_list_marshal (hook_list=0x7f0b6001e698, may_recurse=1, marshaller=0x7f0b85e53786 <probe_hook_marshal>, data=0x7f0b78ee28c0) at ../glib/ghook.c:674
 #22 0x00007f0b85e541be in do_probe_callbacks (pad=0x7f0b6001e600, info=0x7f0b78ee2930, defaultval=GST_FLOW_OK) at ../subprojects/gstreamer/gst/gstpad.c:3853
 #23 0x00007f0b85e5ac9c in gst_pad_push_event_unchecked (pad=0x7f0b6001e600, event=0x7f0b64002120, type=GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM) at ../subprojects/gstreamer/gst/gstpad.c:5538
 #24 0x00007f0b85e54bc2 in push_sticky (pad=0x7f0b6001e600, ev=0x7f0b78ee2a60, user_data=0x7f0b78ee2ac0) at ../subprojects/gstreamer/gst/gstpad.c:4057
 #25 0x00007f0b85e4a13c in events_foreach (pad=0x7f0b6001e600, func=0x7f0b85e54a8e <push_sticky>, user_data=0x7f0b78ee2ac0) at ../subprojects/gstreamer/gst/gstpad.c:613
 #26 0x00007f0b85e54f91 in check_sticky (pad=0x7f0b6001e600, event=0x7f0b64002120) at ../subprojects/gstreamer/gst/gstpad.c:4116
 #27 0x00007f0b85e5b65e in gst_pad_push_event (pad=0x7f0b6001e600, event=0x7f0b64002120) at ../subprojects/gstreamer/gst/gstpad.c:5706
 #28 0x00007f0b7e5888e7 in gst_single_queue_push_one (mq=0x1fbb000, sq=0x7f0b64013b70, object=0x7f0b64002120, allow_drop=0x7f0b78ee2c3c) at ../subprojects/gstreamer/plugins/elements/gstmultiqueue.c:2068
 #29 0x00007f0b7e58a1bc in gst_multi_queue_loop (pad=0x7f0b6001e600) at ../subprojects/gstreamer/plugins/elements/gstmultiqueue.c:2347
 #30 0x00007f0b85e96a36 in gst_task_func (task=0x7f0b64016050) at ../subprojects/gstreamer/gst/gsttask.c:399
 #31 0x00007f0b85e97e41 in default_func (tdata=0x7f0b640138d0, pool=0x1fbe9c0) at ../subprojects/gstreamer/gst/gsttaskpool.c:70
 #32 0x00007f0b85cd1ab2 in g_thread_pool_thread_proxy (data=<optimized out>) at ../glib/gthreadpool.c:352
 #33 0x00007f0b85ccc982 in g_thread_proxy (data=0x7f0b6006f640) at ../glib/gthread.c:831
 #34 0x00007f0b858ca12d in start_thread (arg=<optimized out>) at pthread_create.c:442
 #35 0x00007f0b8594bbc0 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81

Thread 7 (Thread 0x7f0b7a7646c0 (LWP 2952434) "multiqueue3:src"):
 #0  syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
 #1  0x00007f0b85cf470c in g_mutex_lock_slowpath (mutex=0x1fb81d0) at ../glib/gthread-posix.c:1494
 #2  0x00007f0b7e6281a2 in gst_decodebin3_send_event (element=0x1fb8020, event=0x7f0b6800a650) at ../subprojects/gst-plugins-base/gst/playback/gstdecodebin3.c:3561
 #3  0x00007f0b85e23ca3 in gst_element_send_event (element=0x1fb8020, event=0x7f0b6800a650) at ../subprojects/gstreamer/gst/gstelement.c:1994
 #4  0x00007f0b7e63806b in gst_uri_decodebin3_send_event (element=0x1fb4050, event=0x7f0b6800a650) at ../subprojects/gst-plugins-base/gst/playback/gsturidecodebin3.c:2227
 #5  0x00007f0b85e23ca3 in gst_element_send_event (element=0x1fb4050, event=0x7f0b6800a650) at ../subprojects/gstreamer/gst/gstelement.c:1994
 #6  0x00007f0b7e66375a in gst_play_bin3_send_event (element=0x1fb00e0, event=0x7f0b6800a650) at ../subprojects/gst-plugins-base/gst/playback/gstplaybin3.c:1863
 #7  0x00007f0b85e23ca3 in gst_element_send_event (element=0x1fb00e0, event=0x7f0b6800a650) at ../subprojects/gstreamer/gst/gstelement.c:1994
 #8  0x00007f0b85f61b5b in stream_selection_cb (bus=0x1dc2d80, message=0x7f0b68008b00, d=0x1d7de30) at ../subprojects/gst-devtools/validate/gst/validate/gst-validate-scenario.c:2235
 #9  0x00007f0b85c00060 in g_closure_invoke (closure=0x1d2a5b0, return_value=0x0, n_param_values=2, param_values=0x7f0b7a7627b0, invocation_hint=0x7f0b7a762730) at ../gobject/gclosure.c:832
 #10 0x00007f0b85c2cf66 in signal_emit_unlocked_R.isra.0 (node=node@entry=0x1c5e5f0, detail=detail@entry=235, instance=instance@entry=0x1dc2d80, emission_return=emission_return@entry=0x0, instance_and_params=instance_and_params@entry=0x7f0b7a7627b0) at ../gobject/gsignal.c:3796
 #11 0x00007f0b85c1d4da in g_signal_emit_valist (instance=<optimized out>, signal_id=<optimized out>, detail=<optimized out>, var_args=var_args@entry=0x7f0b7a762970) at ../gobject/gsignal.c:3549
 #12 0x00007f0b85c1d6f3 in g_signal_emit (instance=<optimized out>, signal_id=<optimized out>, detail=<optimized out>) at ../gobject/gsignal.c:3606
 #13 0x00007f0b85e05be9 in gst_bus_sync_signal_handler (bus=0x1dc2d80, message=0x7f0b68008b00, data=0x0) at ../subprojects/gstreamer/gst/gstbus.c:1307
 #14 0x00007f0b85e03834 in gst_bus_post (bus=0x1dc2d80, message=0x7f0b68008b00) at ../subprojects/gstreamer/gst/gstbus.c:364
 #15 0x00007f0b85e2436c in gst_element_post_message_default (element=0x1fb00e0, message=0x7f0b68008b00) at ../subprojects/gstreamer/gst/gstelement.c:2127
 #16 0x00007f0b85df42b1 in gst_bin_post_message (element=0x1fb00e0, msg=0x7f0b68008b00) at ../subprojects/gstreamer/gst/gstbin.c:2789
 #17 0x00007f0b85e24627 in gst_element_post_message (element=0x1fb00e0, message=0x7f0b68008b00) at ../subprojects/gstreamer/gst/gstelement.c:2170
 #18 0x00007f0b85df7c12 in gst_bin_handle_message_func (bin=0x1fb00e0, message=0x7f0b68008b00) at ../subprojects/gstreamer/gst/gstbin.c:4041
 #19 0x00007f0b85e61bd3 in gst_pipeline_handle_message (bin=0x1fb00e0, message=0x7f0b68008b00) at ../subprojects/gstreamer/gst/gstpipeline.c:669
 #20 0x00007f0b7e663fa4 in gst_play_bin3_handle_message (bin=0x1fb00e0, msg=0x7f0b68008b00) at ../subprojects/gst-plugins-base/gst/playback/gstplaybin3.c:2030
 #21 0x00007f0b85df5a98 in bin_bus_handler (bus=0x1dc2cc0, message=0x7f0b68008b00, bin=0x1fb00e0) at ../subprojects/gstreamer/gst/gstbin.c:3263
 #22 0x00007f0b85e037f1 in gst_bus_post (bus=0x1dc2cc0, message=0x7f0b68008b00) at ../subprojects/gstreamer/gst/gstbus.c:357
 #23 0x00007f0b85e2436c in gst_element_post_message_default (element=0x1fb4050, message=0x7f0b68008b00) at ../subprojects/gstreamer/gst/gstelement.c:2127
 #24 0x00007f0b85df42b1 in gst_bin_post_message (element=0x1fb4050, msg=0x7f0b68008b00) at ../subprojects/gstreamer/gst/gstbin.c:2789
 #25 0x00007f0b85e24627 in gst_element_post_message (element=0x1fb4050, message=0x7f0b68008b00) at ../subprojects/gstreamer/gst/gstelement.c:2170
 #26 0x00007f0b85df7c12 in gst_bin_handle_message_func (bin=0x1fb4050, message=0x7f0b68008b00) at ../subprojects/gstreamer/gst/gstbin.c:4041
 #27 0x00007f0b7e638005 in gst_uri_decode_bin3_handle_message (bin=0x1fb4050, msg=0x7f0b68008b00) at ../subprojects/gst-plugins-base/gst/playback/gsturidecodebin3.c:2218
 #28 0x00007f0b85df5a98 in bin_bus_handler (bus=0x1dc2e40, message=0x7f0b68008b00, bin=0x1fb4050) at ../subprojects/gstreamer/gst/gstbin.c:3263
 #29 0x00007f0b85e037f1 in gst_bus_post (bus=0x1dc2e40, message=0x7f0b68008b00) at ../subprojects/gstreamer/gst/gstbus.c:357
 #30 0x00007f0b85e2436c in gst_element_post_message_default (element=0x1fb8020, message=0x7f0b68008b00) at ../subprojects/gstreamer/gst/gstelement.c:2127
 #31 0x00007f0b85df42b1 in gst_bin_post_message (element=0x1fb8020, msg=0x7f0b68008b00) at ../subprojects/gstreamer/gst/gstbin.c:2789
 #32 0x00007f0b85e24627 in gst_element_post_message (element=0x1fb8020, message=0x7f0b68008b00) at ../subprojects/gstreamer/gst/gstelement.c:2170
 #33 0x00007f0b7e61ee43 in sink_event_function (sinkpad=0x7f0b6400f8c0, dbin=0x1fb8020, event=0x7f0b6c097870) at ../subprojects/gst-plugins-base/gst/playback/gstdecodebin3.c:1450
 #34 0x00007f0b85f51122 in gst_validate_pad_monitor_downstream_event_check (pad_monitor=0x7f0b6c094a80, parent=0x1fb8020, event=0x7f0b6c097870, handler=0x7f0b7e61e797 <sink_event_function>) at ../subprojects/gst-devtools/validate/gst/validate/gst-validate-pad-monitor.c:2101
 #35 0x00007f0b85f535bf in gst_validate_pad_monitor_sink_event_full_func (pad=0x7f0b6400f8c0, parent=0x1fb8020, event=0x7f0b6c097870) at ../subprojects/gst-devtools/validate/gst/validate/gst-validate-pad-monitor.c:2406
 #36 0x00007f0b85f537fa in gst_validate_pad_monitor_sink_event_func (pad=0x7f0b6400f8c0, parent=0x1fb8020, event=0x7f0b6c097870) at ../subprojects/gst-devtools/validate/gst/validate/gst-validate-pad-monitor.c:2418
 #37 0x00007f0b85e5c523 in gst_pad_send_event_unchecked (pad=0x7f0b6400f8c0, event=0x7f0b6c097870, type=GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM) at ../subprojects/gstreamer/gst/gstpad.c:5940
 #38 0x00007f0b85e5ae65 in gst_pad_push_event_unchecked (pad=0x7f0b6400f650, event=0x7f0b6c097870, type=GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM) at ../subprojects/gstreamer/gst/gstpad.c:5573
 #39 0x00007f0b85e54bc2 in push_sticky (pad=0x7f0b6400f650, ev=0x7f0b7a763620, user_data=0x7f0b7a763680) at ../subprojects/gstreamer/gst/gstpad.c:4057
 #40 0x00007f0b85e4a13c in events_foreach (pad=0x7f0b6400f650, func=0x7f0b85e54a8e <push_sticky>, user_data=0x7f0b7a763680) at ../subprojects/gstreamer/gst/gstpad.c:613
 #41 0x00007f0b85e54f91 in check_sticky (pad=0x7f0b6400f650, event=0x7f0b6c097870) at ../subprojects/gstreamer/gst/gstpad.c:4116
 #42 0x00007f0b85e5b65e in gst_pad_push_event (pad=0x7f0b6400f650, event=0x7f0b6c097870) at ../subprojects/gstreamer/gst/gstpad.c:5706
 #43 0x00007f0b85e523e7 in event_forward_func (pad=0x7f0b6400f650, data=0x7f0b7a763820) at ../subprojects/gstreamer/gst/gstpad.c:3130
 #44 0x00007f0b85e521e3 in gst_pad_forward (pad=0x7f0b6004f180, forward=0x7f0b85e522bd <event_forward_func>, user_data=0x7f0b7a763820) at ../subprojects/gstreamer/gst/gstpad.c:3084
 #45 0x00007f0b85e525ab in gst_pad_event_default (pad=0x7f0b6004f180, parent=0x7f0b6400f650, event=0x7f0b6c097870) at ../subprojects/gstreamer/gst/gstpad.c:3181
 #46 0x00007f0b85e5c523 in gst_pad_send_event_unchecked (pad=0x7f0b6004f180, event=0x7f0b6c097870, type=GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM) at ../subprojects/gstreamer/gst/gstpad.c:5940
 #47 0x00007f0b85e5ae65 in gst_pad_push_event_unchecked (pad=0x7f0b64008360, event=0x7f0b6c097870, type=GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM) at ../subprojects/gstreamer/gst/gstpad.c:5573
 #48 0x00007f0b85e54bc2 in push_sticky (pad=0x7f0b64008360, ev=0x7f0b7a763a60, user_data=0x7f0b7a763ac0) at ../subprojects/gstreamer/gst/gstpad.c:4057
 #49 0x00007f0b85e4a13c in events_foreach (pad=0x7f0b64008360, func=0x7f0b85e54a8e <push_sticky>, user_data=0x7f0b7a763ac0) at ../subprojects/gstreamer/gst/gstpad.c:613
 #50 0x00007f0b85e54f91 in check_sticky (pad=0x7f0b64008360, event=0x7f0b6c097870) at ../subprojects/gstreamer/gst/gstpad.c:4116
 #51 0x00007f0b85e5b65e in gst_pad_push_event (pad=0x7f0b64008360, event=0x7f0b6c097870) at ../subprojects/gstreamer/gst/gstpad.c:5706
 #52 0x00007f0b7e5888e7 in gst_single_queue_push_one (mq=0x7f0b60076540, sq=0x7f0b6c093300, object=0x7f0b6c097870, allow_drop=0x7f0b7a763c3c) at ../subprojects/gstreamer/plugins/elements/gstmultiqueue.c:2068
 #53 0x00007f0b7e58a1bc in gst_multi_queue_loop (pad=0x7f0b64008360) at ../subprojects/gstreamer/plugins/elements/gstmultiqueue.c:2347
 #54 0x00007f0b85e96a36 in gst_task_func (task=0x7f0b6c072050) at ../subprojects/gstreamer/gst/gsttask.c:399
 #55 0x00007f0b85e97e41 in default_func (tdata=0x7f0b6c093ef0, pool=0x1fbe9c0) at ../subprojects/gstreamer/gst/gsttaskpool.c:70
 #56 0x00007f0b85cd1ab2 in g_thread_pool_thread_proxy (data=<optimized out>) at ../glib/gthreadpool.c:352
 #57 0x00007f0b85ccc982 in g_thread_proxy (data=0x7f0b70033800) at ../glib/gthread.c:831
 #58 0x00007f0b858ca12d in start_thread (arg=<optimized out>) at pthread_create.c:442
 #59 0x00007f0b8594bbc0 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
```

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5982>
2024-01-29 19:46:45 +00:00
Edward Hervey
87bb3a8e2e subtitleoverlay: Handle video sink pad CAPS query earlier
The internal elements are only created when caps on both video and subtitle pads
are known.

Prior to that, a GST_QUERY_CAPS on a video sink pad would just return ANY
instead of giving a hint of what downstream can actually handle and
prefers. This could result in upstream elements (such as decoders) deciding on
chosing (in the best cases) a non-optimal caps or (in the worst case) caps that
couldn't be handled by the elements downstream of subtitleoverlay.

In order to fix that, we assume that all subtitle "elements" handle the subtitle
overlay composition feature/meta and handle `GST_QUERY_CAPS` ourselves if the
internal elements aren't present yet.

Fixes #3176

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5834>
2024-01-26 08:36:07 +00:00
Thibault Saunier
48c8dbd383 uridecodebin3: Protect set_uri with the PLAY_ITEMS_LOCK
We access fields that are protected by the lock and this was already
held in other places where we call the method. I have got cases where
we get the following stack/assertion:

```
 #0  g_logv (log_domain=0x7fb9d84e6cd5 "GStreamer", log_level=G_LOG_LEVEL_CRITICAL, format=<optimized out>, args=args@entry=0x7fb9d4de54e0) at ../glib/gmessages.c:1433
 #1  0x00007fb9d802d0f3 in g_log (log_domain=<optimized out>, log_level=<optimized out>, format=<optimized out>) at ../glib/gmessages.c:1471
 #2  0x00007fb9d845bc2c in gst_pad_send_event (pad=0x7fb98c01e050, event=0x7fb9c4105b90) at ../subprojects/gstreamer/gst/gstpad.c:6096
 #3  0x00007fb9d6541c35 in gst_uri_decode_bin3_set_uri (dec=0x7fb9bc450960 [GstURIDecodeBin3], uri=0x7fb9c40f5410 "file:///var/home/thiblahute/devel/gstreamer/gstreamer/subprojects/gst-integration-testsuites/medias/defaults/mp4/mp3_h264.0.mp4") at ../subprojects/gst-plugins-base/gst/playback/gsturidecodebin3.c:1918
 #4  0x00007fb9d6540c40 in gst_uri_decode_bin3_set_property (object=0x7fb9bc450960 [GstURIDecodeBin3], prop_id=1, value=0x7fb9d4de57b0, pspec=0x7fb9bcee5280 [GParamString]) at ../subprojects/gst-plugins-base/gst/playback/gsturidecodebin3.c:1569
 #5  0x00007fb9d7f8f73d in object_set_property (object=0x7fb9bc450960 [GstURIDecodeBin3], pspec=0x7fb9bcee5280 [GParamString], value=0x7fb9d4de57b0, nqueue=0x7fb9c40d0c40, user_specified=<optimized out>) at ../gobject/gobject.c:1794
```

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5968>
2024-01-24 11:40:05 +00:00
Philippe Normand
952f252104 decodebin3: Fix clean-up of EOS'd parsebin src pad
In `parse_chain_output_probe()` the corresponding input stream might receive EOS
and thus be removed before the actual pad is removed. So we cannot assert about
this in `parsebin_pad_removed_cb()`.

Also, driving-by, protect `find_input_stream_for_pad()` with the selection lock
similarly to other functions accessing the input streams list.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5887>
2024-01-09 19:00:38 +00:00
Edward Hervey
2d57bec920 decodebin3: Don't send sticky events to unlinked decoder
This causes a lot of nasty side effects (like decoders assuming they are
actually linked downstream).

The reason why this was done was to check whether a decoder could handle the
actual caps, but this is the wrong way to do it.

The proper way to query whether a decoder can handle certain caps is via
`GST_QUERY_ACCEPT_CAPS` which is already done just before.

Partially reverts !4677 and partially fixes #3160

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5821>
2023-12-18 09:29:52 +01:00
Jimmy Ohn
9c6b0f4615 decodebin2: Properly free when shutting down in gst_decode_bin_expose
missing_plugin_details causes memory leakages when shutting down.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5744>
2023-12-01 19:10:54 +09:00
Philippe Normand
ca18e48882 decodebin3: Tidy-up dispose function
Protect code with mutexes

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5607>
2023-11-06 13:07:54 +00:00
Philippe Normand
f0e1b4f415 parsebin: Fix a potential stream collection leak
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5607>
2023-11-06 13:07:54 +00:00
Philippe Normand
677b6f7148 decodebin3: Dispose decoder in case linking failed
Otherwise it will be leaked and remain forever in the bin when trying the next
decoder candidate.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5551>
2023-11-04 11:02:20 +00:00
Haihua Hu
4e381b8901 playback: Support runtime change connection-speed of adaptivedemux(2)
Update connection-speed at runtime in playbin, uridecodebin and decodebin
also do the same thing in urisourcebin.

With contributions from Philippe Normand <philn@igalia.com> (build fixes and
rebase on mono-repo).

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4713>
2023-10-12 16:06:42 +00:00
Guillaume Desmottes
0ae230c8be uridecodebin3: proxy urisourcebin::download-dir property
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5227>
2023-08-23 13:52:19 +00:00
Guillaume Desmottes
8263ce2a31 urisourcebin: add 'download-dir' property
The directory were buffers are downloaded was not documented and not
configurable. Users may want to ensure buffers are saved to a specific
partition for example.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5227>
2023-08-23 13:52:19 +00:00
Philippe Normand
1afeef0e8b decodebin3: Ensure the slot is unlinked before linking to decoder
When switching from a raw stream to an encoded stream we need to make sure the
slot is unlinked, there is code in place for this but it wasn't triggered
because the slot being reconfigured wasn't advertised as linked beforehand.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5126>
2023-08-01 20:16:59 +00:00
Philippe Normand
0d5f6f3d47 decodebin3: Prevent a critical warning when reassigning output slots
Do not attempt to send a streams-selected message when reassigning
an output slot in case upstream signalled that it is handling stream selection.
In this case decodebin3 doesn't keep track of stream
collections (`dbin->collection` is NULL).

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5059>
2023-07-19 15:17:46 +00:00
Philippe Normand
4404e7203c decodebin3: Fix slot input linking when the associated stream has changed
Setting the input field on the empty slot prevents future linking of it and will
result in flow errors later on.

This was observed in WebKit's MediaStream source element, when it changes the
caps on one of its associated streams, from an encoded format to a raw video
format. The associated stream-id on the sticky stream-start event doesn´t
change, but the element creates a new GstStream with a different ID and sets it
on the stream-start event. Stream parsing is disabled in urisourcebin, so
decodebin3 handles the parsing. Without this patch we would end-up with unlinked
pads in decodebin3 after switching to the raw video format.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5048>
2023-07-19 01:24:30 +00:00
Edward Hervey
7e7f02f4f4 decodebin3: Rename and refactor function
It was doing a bit more than it did initially, update the name accordingly.

Refactor slightly for visibility

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5052>
2023-07-18 11:42:13 +02:00
Edward Hervey
1fd7c2c17a decodebin3: Remove dead code
Was never used since initial commit

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5052>
2023-07-18 11:42:13 +02:00
Philippe Normand
4dc503e1e4 decodebin3: Remove spurious input locking during parsebin reconfiguration
Commit 22917b140f added extra locks in
`reset_input_parsebin()` but all call sites of that function already take the
input lock.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5022>
2023-07-12 18:33:00 +00:00
Guillaume Desmottes
1027180960 subtitleoverlay: fix mutex error if sink caps is not video
We were trying to unlock a mutex that was not locked.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4964>
2023-07-05 10:34:21 +00:00
Edward Hervey
f825b7aba3 uridecodebin3: Refuse sub uri in gapless mode
This is too problematic to handle properly right now.

See https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/2550 and
https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/2605

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4958>
2023-07-03 16:02:40 +02:00
Hou Qi
dbdbf2d256 decodebin3: fix memory leak when remove candidate decoder
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4955>
2023-07-03 07:13:13 +00:00
Thibault Saunier
c5304751ab uridecodebin: Handle non dynamic sources with several source pads
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4881>
2023-06-30 01:00:34 +00:00
Xabier Rodriguez Calvar
4769a2ab97 playbin2: improve transference doc of get-*-pad actions
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2081>
2023-06-12 10:26:26 +00:00
Hou Qi
95ac8b0cea decodebin3: filter error message and store latency message for candidate decoder
If the GST_MESSAGE_SRC of error message belongs to candidate decoders,
filter the error message and don't forward it as there might be a
following candidate decoder that can be used.

If the GST_MESSAGE_SRC of error message belongs to candidate decoders,
store the latency message and handle it after decoder is accepted.
This is to avoid the selection lock failure if decodebin3 needs to
handle latency message for candidate decoders when sending sticky event.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4677>
2023-06-02 14:51:38 +00:00
Hou Qi
887ae4d9e0 decodebin3: try candidate decoders to select the first one that works
Send sticky events to the new created decoder after it switches
to PAUSED state. It it fails, just skip this decoder and try the
next one until finding one that works. Otherwise remove this
failing stream after trying all decoders and no one can work.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4677>
2023-06-02 14:51:38 +00:00
Hou Qi
6fc6e934aa decodebin3: send sticky event to decoder after setting it to PAUSED
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4677>
2023-06-02 14:51:38 +00:00
Hou Qi
837169a221 decodebin3: add function remove_decoder_link()
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4677>
2023-06-02 14:51:38 +00:00
Hou Qi
536c344111 decodebin3: copy sticky event
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4677>
2023-06-02 14:51:38 +00:00
Edward Hervey
9befb81036 urisourcebin: Set source element to READY before querying it
Generating the source element is done when urisourcebin is doing the READY to
PAUSED state change, so it is reasonable to set the new source element to that
state.

This also allows detecting early failures with backing libraries or
hardware (checks done in NULL->READY).

Finally it makes more sense to have an element in READY when attempting to query
information from it (such as SCHEDULING queries or probing live-ness).

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3856>
2023-06-02 07:00:43 +00:00
Guillaume Desmottes
b3d27da397 streamsynchronizer: check reset-time when handling FLUSH_STOP
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4749>
2023-06-01 09:45:50 +02:00
Guillaume Desmottes
c2d8f4f729 streamsynchronizer: reset eos on STREAM_START
self->eos was never reset after streamsynchronizer has sent EOS
(except on explicit flush or switching back to PAUSED).
As a result, synchronization was broken if new streams were pushed later
as gst_stream_synchronizer_wait() does not wait if self->eos is set.

Fix this by reseting self->eos on STREAM_START as that means a new
stream is being sent upstream and so a new EOS will follow later on.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4749>
2023-06-01 09:45:15 +02:00
Edward Hervey
d6f1c517f3 decodebin3: Handle changes in stream type
While decodebin3 could handle changes in inputs (ex: changing codecs), there was
still one limitation which was when changing between sources which had
non-intersecting stream types (ex: switching from a video-only source to a
audio-only source). While the decoder *could* change to the proper codec ... it
would carry on using a `DecodebinOutputStream` associated to that stream
type (and therefore with pads with the wrong name).

In order to handle this:

* We notify the `MultiQueueSlot` of the change in `GstStreamType` if it already
  had an associated inputstream (ex: the one associated with the static sink
  pad)

* We detect such changes on the output of multiqueue as soon as
  possible (i.e. when we get the GST_EVENT_STREAM_START for the new stream type)
  by discarding the associated output.

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/1669

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4703>
2023-05-25 21:23:21 +00:00
Edward Hervey
f51283b57b uridecodebin3: Also re-use decodebin3 static sink pad
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4703>
2023-05-25 21:23:21 +00:00
Guillaume Desmottes
58f80c180c uridecodebin3: notify when 'current-(sub)uri' properties are updated
Assume both uri and suburi are changed when the main item changes.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4543>
2023-05-24 09:28:58 +00:00
Haihua Hu
9f67b866b9 decodebin3: avoid identity, sinkpad, parsebin leakage when reset input
when reset_input, need remove identity/parsebin from decodebin3
when release_pad, need call free or reset input if collection
didn't change

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4664>
2023-05-19 16:24:08 +00:00
Haihua Hu
36333a5152 decodebin3: fix random hang when remove failing stream
When reconfigure_output_stream entry missing decoder path,
requested_selection should been update with what is really
active/selected immdiately with SELECTION_LOCK hold. So
use an optional message return from reconfigure_output_stream
and post it after release SELECTION_LOCK. This can make sure
other thread call to check_slot_reconfiguration will got
a correct requested_selection.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4599>
2023-05-16 12:43:12 +00:00
Edward Hervey
0db6149880 decodebin3: Handle streams without CAPS or TIME segment
decodebin3 will do its best to figure out whether a parsebin is required to
process the incoming stream.

The problem is that for push-based stream it could happen that the stream would
not provide any caps, resulting in nothing being linked internally.

Furthermore, there is the possibility that a stream *with* caps would not be
using a TIME segment, which is required for multiqueue to properly work.

In order to fix those two issues, we force the usage of parsebin on push-based
streams:
* When the pad is linked, if upstream can't provide any caps
* When we get a non-TIME segment

Fixes #2521

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4492>
2023-04-27 12:50:21 +00:00
Hou Qi
aed4d31e67 decodebin3: fix segment fault when print decoder log
Segment fault happens when cannot find decoder but try to print
decoder name. Need to check the decoder.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4461>
2023-04-25 21:42:15 +08:00
Patricia Muscalu
c6bb20bba8 playsink: Fix volume leak
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4459>
2023-04-20 14:21:15 +00:00
Haihua Hu
8541d6b990 decodebin3: fix hang issue when remove failing stream
Need mark selection_update to true when update selection,
otherwise, pipeline will not handle this selection update
sometimes when this flag has been reset

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4277>
2023-03-27 13:52:42 +00:00
Edward Hervey
0be233a446 uridecodebin3: Remove play items that were never connected
This is a follow-up of the previous commit that enabled support for redirection.

The problem is that the urisourcebin that emitted the error redirection never
produced any pads, and therefore was never linked to decodebin3. This resulted
in the code waiting for that (output) item to finally switch over ... which will
never happen.

The fix is done by removing it early if it was never connected to decodebin3.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4252>
2023-03-23 07:39:48 +01:00
Edward Hervey
133c4b2ff9 uridecodebin3: Handle redirection errors
This is done by doing an immediate switch to the redirection URI if compatible.

Fixes #1562

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4242>
2023-03-22 11:28:47 +00:00
Edward Hervey
095356b67e parsebin: Improve elementary stream handling
The goal of parsebin is to figure out which elements to link together in order
to provide elementary streams given any random input.

The problem is that deciding whether a given stream should still have more
elements plugged in or not was dependent on ... the presence of compatible
decoders (sic).

Instead of that, if we can't plug anymore elements on a given stream *and* it is
detected as being an elementary stream, expose it.

Fixes #2118

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4231>
2023-03-21 07:26:37 +00:00
Edward Hervey
cf3adbcfb3 urisourcebin: Activate pad before transferring sticky events
Otherwise they get refused since the pad is flushing

Fixes #2384 for good

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4226>
2023-03-20 18:11:26 +00:00
Edward Hervey
7f1c5e2ef3 urisourcebin: Propagate sticky events from parsebin
If sticky events are present on parsebin source pads, we propagate them to the
multiqueue source pads. Those will be propagated on the new urisourcebin source
pads like in the other code paths.

This ensures that STREAM_START event are present on new source pads. If CAPS
event are also present (not guaranteed), they will also be available.

Fixes #2384

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4203>
2023-03-17 23:48:43 +00:00
Tim-Philipp Müller
8759b77a50 gst-plugins-base: re-indent with GNU indent 2.2.12
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4182>
2023-03-17 03:18:53 +00:00
Edward Hervey
b4cadf35bd uridecodebin3: Ensure atomic urisourcebin state change
When dynamically adding and synchronizing the state of urisourcebin, we need to
ensure that no-one else attempts to change the state in case of failures

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/1803

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4125>
2023-03-08 09:29:57 +00:00
Thibault Saunier
4067bbdd91 uridecodebin: Set source element to READY before querying it
Generating the source element is done when uridecodebin is doing the
READY to PAUSED state change, so it is reasonable to set the new source
element to that state.

This also allows detecting early failures with backing libraries or
hardware (checks done in NULL->READY).

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3857>
2023-02-08 11:07:21 +00:00
Tim-Philipp Müller
165fdac5c6 playback: drop use of GSlice
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3695>
2023-01-24 15:25:06 +00:00
Edward Hervey
4c1d01ff57 playback: New playback elements are no longer experimental
The API is not expected to change and it has been used extensively since 1.18.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3761>
2023-01-21 12:28:21 +00:00
Edward Hervey
e2773304a2 decodebin3: Remove failing stream from selection
If no decoder is present for a given stream, remove it from the requested
selection.

Fixes #1581 and #1662

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3754>
2023-01-20 08:54:00 +00:00
Edward Hervey
34ea792881 decodebin3: Don't intercept queries if no parsebin present
If we don't use a parsebin, we forward the queries as-is from upstream. There is
no reconfiguration possible within identity.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3754>
2023-01-20 08:54:00 +00:00
Edward Hervey
1a30ed8113 decodebin3: Don't insert parsebin if input is already parsed
This is a temporary workaround until we find a generic solution to indicate that
a stream has already been "parsed".

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3754>
2023-01-20 08:54:00 +00:00
Tim-Philipp Müller
64c4bfdf7e uridecodebin3: clear subitem if suburi is set to NULL
Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/1649

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3730>
2023-01-18 11:43:31 +00:00
Edward Hervey
13ad8c8e4e urisourcebin: Cleanup on failure
This ensures there is a source present/valid *ONLY* in PAUSED and above.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3720>
2023-01-13 16:41:53 +01:00
Edward Hervey
1546ab0d0f urisourcebin: Unset locked state
Some elements still had it in failure cases

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3720>
2023-01-13 16:41:53 +01:00
Edward Hervey
f444e62672 uridecodebin3: Handle state synchronization failures
Properly reset and remove the failing urisourcebin if we failed bringing them up
to the same state as ourselves.

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/1708

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3720>
2023-01-13 16:41:53 +01:00
Edward Hervey
1fe99ebae1 decodebin3: Fix global group-id handling
The goal of the "global" group-id is to fix new inputs that do not come from the
same "source" as others. In order to ensure all "current" streams have the same
group-id we distribute the first valid group-id to all streams.

This commit fixes two issues with that:

* When inputs are unlinked they weren't always properly resetted (it would only
  work if parsebin is used, which is no longer the default in
  uridecodebin3/playbin3).

* When computing the global group-id, take into account unset
  group-id (i.e. GST_GROUP_ID_INVALID).

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/1698

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3712>
2023-01-11 23:29:05 +00:00
Guillaume Desmottes
22917b140f decodebin3: ensure recalculate_group_id() is called with INPUT lock
This function uses main_input and current_group_id which are protected
by the input lock.
Some calls were already safe but not all.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3702>
2023-01-11 18:37:05 +00:00
Guillaume Desmottes
cad0768191 uridecodebin3: fix stream leak
GstSourcePad owns the GstStream but was not unreffing it when being
disposed.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3617>
2023-01-11 16:44:21 +00:00
Guillaume Desmottes
da696477c6 decodebin3: fix dead lock when removing pad
gst_element_remove_pad() is triggering a call to
gst_decodebin3_input_pad_unlink() which needs the input lock as well,
resulting in a dead lock.

Fix #1667

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3614>
2023-01-11 15:06:37 +00:00
Edward Hervey
6beca9f055 urisourcebin: Fix parsebin handling
The goal of !3601 was to make sure we don't end up with non-streams-aware
adaptive demuxers. Since we know that parsebin is streams-aware, just remember
that and handle them that way.

Fixes issues with some scenarios where parsebin might add pads *before* the
collection is posted on the bus

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/1675

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3658>
2022-12-30 08:46:14 +01:00
Edward Hervey
66b96baf23 uridecodebin3: Fix handling of "expected" pads
The number of expected pads was:
* Defaulting to 1
* Or being overriden by GST_MESSAGE_STREAMS_SELECTED

This fails if upstream isn't a selectable source and has multiple streams, and
would therefore cause failures with multi-stream gapless playback

Fixes #1672

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3658>
2022-12-30 08:46:14 +01:00
Edward Hervey
80e7c31514 uridecodebin3: Avoid repeatedly calling the blocking probe
When skipping an event, we want to unref it and say we handled it. This avoids
being repeatedly called for the same (sticky) events.

The events will be properly propagated once the pad is linked.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3658>
2022-12-30 08:46:13 +01:00
Edward Hervey
a0655d5131 uridecodebin3: Handle multiple pending pad block probes
It is quite possible to have the blocking probe called from different streaming
threads when all expected pads are present.

* Notify all waiters by using g_cond_broadcast instead of g_cond_signal
* Properly remove the probe after waiting

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3658>
2022-12-30 08:46:13 +01:00
Edward Hervey
74a503c197 urisourcebin: Modify check for streams-aware adaptive demuxers
Using the "GstBin" flags to check if an adaptive demuxer is streams-aware isn't
a good idea since it prevents using elements which aren't bins.

Instead we see if a collection was posted by the demuxer by the time a pad is
added.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3601>
2022-12-19 15:23:32 +00:00
Guillaume Desmottes
1f929ba32f uridecodebin3: fix typo in doc
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3602>
2022-12-19 14:24:06 +01:00
Edward Hervey
36c3bb0d05 uridecodebin3: Protect against NULL uri/suburi
Fixes #1625

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3511>
2022-12-02 16:55:05 +00:00
Edward Hervey
41017e6c34 uridecodebin3: Always store pending buffering messages
Fixes #1586

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3487>
2022-12-02 09:22:41 +00:00
Edward Hervey
3a63eab2fa uridecodebin3: propagate about-to-finish for new inputs
If the pending next urisourcebin is already draining, make sure we propagate it
when activating it.

Fixes gapless playback of small entries

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/1588

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3457>
2022-11-23 12:19:22 +00:00
Edward Hervey
def2515ae2 uridecodebin3: Remove old fixme
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3457>
2022-11-23 12:19:22 +00:00
Edward Hervey
734a4554f3 (uri)decodebin3: Ensure group-id consistency
Make sure that group-id of a given play item are made consistent from the
start (sources) and all the way through the output.

This ensures that we can reliably detect that we have switched to the next play
item on the output of decodebin3 (and we can therefore properly free/release it)

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3457>
2022-11-23 12:19:21 +00:00
Edward Hervey
353691602e uridecodebin3: Fix shutdown procedures in probe
When shutting down, we want to remove the urisourcebin blocking probes ... but
we also want to propagate a GST_FLOW_FLUSHING upstream (and not
GST_FLOW_NOT_LINKED) to make the upstream task gracefully stop instead of
posting an error message.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3457>
2022-11-23 12:19:21 +00:00
Edward Hervey
7f5f7b3a77 decodebin3: Properly reset when going back to READY
Clear the remaining stream-related fields when going from PAUSED to READY, and
use when disposing.

Fixes various issues when re-using decodebin3/playbin3

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3457>
2022-11-23 12:19:21 +00:00
Edward Hervey
d12534d21d decodebin3: Don't output bogus GST_MESSAGE_STREAMS_SELECTED
When `is_selection_done` is called, it checks that all the requested streams are
present in the active stream list ...

... except there could very well be a (about to be removed) stream from the
previous selection present.

Therefore filter the list of streams we add to the message by the streams which
are actually requested.

Fixes issues when switching between different stream types (ex: video-only to
audio-only).

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3457>
2022-11-23 12:19:21 +00:00
Edward Hervey
1774d5c87a parsebin: Don't leak parsepad list on shutdown
Free it as it is down in other cases

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3443>
2022-11-21 19:02:44 +00:00
Edward Hervey
db2146d0ea decodebin2: Minor debug fix for decodepad
decodedad might have their name changed when exposing, causing a race when
trying to get their name without taking a lock. Just use GST_PTR_POINTER in
debug statements instead

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3428>
2022-11-18 07:22:23 +00:00
Edward Hervey
92abb8daec urisourcebin: Remove un-needed define
This code hasn't use GValueArray in ages

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2784>
2022-11-16 14:01:47 +00:00
Edward Hervey
5702568a7e urisourcebin: Use a non-buffering multiqueue for non-streamable URI
Even though buffering is not required, we need to ensure we are dealing with the
interleave (if any) before pushing the elementary streams further downstream.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2784>
2022-11-16 14:01:47 +00:00
Edward Hervey
c59397354c urisourcebin: Minor doc fix
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2784>
2022-11-16 14:01:47 +00:00
Jan Schmidt
6e549b2fe5 uridecodebin3: Don't leak EOS event
Make sure to unref the EOS event in all code paths
when returning GST_PAD_PROBE_HANDLED

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2784>
2022-11-16 14:01:47 +00:00
Edward Hervey
6bffbe283a playbin3: Move gapless to uridecodebin3
This was the intention from the start, just took me a few years *cough* to
actually implement it properly.

Gapless is handled by re-using as much as possible the same decoders and sinks
if present, and only pre-rolling switching at the sources level (with buffering
if/when needed).

In order to enable "gapless" playback, the "next" uri should be set at any time
between the moment the `about-to-finish` signal is emitted and the moment the
current play item is done. Previously this could only be done with the signal
emission.

This new implementation also allows "Instantaneous URI switching". This allows a
much faster way of switching playback entries while re-using as many elements as
possible. To enable this set `instant-uri` property to TRUE, the default being
FALSE.

API: instant-uri properties
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2784>
2022-11-16 14:01:47 +00:00
Edward Hervey
1f2d98028b playbin3: Remove unused code
This was never used, and if ever it's needed at some point for reference it's
available in gstplaybin.c

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2784>
2022-11-16 14:01:47 +00:00
Edward Hervey
78e43a6319 decodebin3: Clear input collection when linked again
The previous collection no longer applies to this input

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2784>
2022-11-16 14:01:47 +00:00
Edward Hervey
8ce0a23a5e decodebin3: Improve collection merging
If the collections are the same, don't merge them

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2784>
2022-11-16 14:01:47 +00:00
Edward Hervey
0bb2026890 decodebin3: doc cleanup
Remove old/invalid FIXME and cleanup some logs

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2784>
2022-11-16 14:01:47 +00:00
Edward Hervey
4bfbc72663 decodebin3: Remove unused variable
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2784>
2022-11-16 14:01:46 +00:00
Edward Hervey
f785b3d584 decodebin3: Allow re-using inputs
DecodebinInput (and their backing parsebin or identity) are no longer released
when the corresponding sinkpad is unlinked, but when it's released.

The parsebin element will be resetted:
* If incoming caps are incompatible (was the case before)
* Or when unlinking and it was previously pull-based

This opens the way to use decodebin3 with changing inputs (i.e. gapless)

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2784>
2022-11-16 14:01:46 +00:00
Edward Hervey
1f8d8b2df6 uridecodebin3: use urisourcebin parse-streams property
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2784>
2022-11-16 14:01:46 +00:00
Edward Hervey
412c4cbca3 urisourcebin: Improve buffering handling
Introduce the option to have the streams be parsed with `parsebin` for
compatible sources (i.e. which are eligible for buffering in the same way as
before this commit).

By parsing the inputs directly, this allows more accurate buffering control:
* Instead of relying on potential bitrate information coming from somewhere
* and *without* being linked downstream

If `parse-streams` is activated and the stream is eligible for buffering, then a
`multiqueue` will be used on the output of `parsebin` in order to handle the
buffering.

API: `parse-streams`
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2784>
2022-11-16 14:01:46 +00:00
Edward Hervey
fa4a70d7fe parsebin: avoid bogus processing
If a parsebin pad is already exposed, don't try to rename it or cause extra
processing which isn't needed

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2784>
2022-11-16 14:01:46 +00:00
Edward Hervey
5e2606cacd decodebin3: Avoid parsebin usage if not needed
If the incoming streams are already parsed, there is no need to add yet-another
parsebin to process it *IF* that stream is compatible with a decoder or the
decodebin3 output caps.

This only applies if all the following conditions are met:
* The incoming stream can *NOT* do pull-based scheduling
* The incoming stream provides a `GstStream` and `GstStreamCollection`
* The caps are compatible with either the decodebin3 output caps or a decoder
  input

If all those conditions are met, a identity element is used instead of a
parsebin element and the same code paths are taken.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2784>
2022-11-16 14:01:46 +00:00
Edward Hervey
f010dce6e7 decodebin3: DecodebinInputStream: Hold a ref to srcpad
And move the locking outside of the input stream creation function

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2784>
2022-11-16 14:01:46 +00:00
Edward Hervey
e8f768212c urisourcebin: Bring high-watermark level in sync with legacy values
It was always 60%. For some reason this crept in during the initial urisourcebin
refactoring.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2784>
2022-11-16 14:01:46 +00:00
Edward Hervey
b589cf12f2 decodebin3: Don't leak collection when releasing inputs
And refactor the function slightly for clarity

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2784>
2022-11-16 14:01:46 +00:00
Edward Hervey
e276d3c836 decodebin3: Protect input freeing with the input lock
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2784>
2022-11-16 14:01:46 +00:00
Edward Hervey
f091d2445f decodebin3: Refactor parsebin output handling
* Instead of creating temporary `PendingPad` structures, always create a
  DecodebinInputStream for every pad of parsebin
* Remove never used `pending_stream` field from DecodebinInputStream
* When unblocking a given DecodebinInput (i.e. wrapping a parsebin), also make
  sure that other parsebins from the same GstStreamCollection are unblocked
  since they come from the same source

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2784>
2022-11-16 14:01:46 +00:00