Commit graph

237 commits

Author SHA1 Message Date
Edward Hervey
7546975856 urisourcebin: Don't hold lock when emitting about-to-finish
This could trigger actions that re-enter this element

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7368>
2024-08-17 05:50:26 +00:00
Edward Hervey
701165227f decodebin3: Remove custom EOS handling
Initially introduced in 2017 by 4fcbcf4e48 (and
follow up commits) and ec7d81f67c

See https://bugzilla.gnome.org/show_bug.cgi?id=773341 and
https://bugzilla.gnome.org/show_bug.cgi?id=792693 for more details.

This was made to support the legacy behaviour of adaptive demuxers (regarding
streams added/removed dynamically).

Since then, a lot of things have changed in decodebin3 and related elements
regarding how dynamic streams are handled and this custom behaviour is no longer
needed.

This also removes weird behaviours like EOS being delayed until *all* streams
were EOS, which could cause deadlocks downstream.

Fixes #3666

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7194>
2024-08-16 13:26:14 +00:00
Alicia Boya García
9b0e951512 streamsynchronizer: Add documentation
I didn't find the behavior and purpose of streamsynchronizer documented
or intuitive. Eventually I got Edward to explain it to me, which was
very helpful. Now I'm contributing some docs so that the next person
doesn't have to figure it out by asking around and hoping for an answer.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7084>
2024-08-14 13:55:37 +00:00
Philippe Normand
bd64374174 parsebin: accept-caps handling for elements with unusual pad names
In case the last element of the parse chain doesn´t have a sink pad named
"sink", send the accept-caps query to the first sink pad of the element.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7255>
2024-07-29 12:41:33 +00:00
George Hazan
9e1abc0797 parsebin: fix compilation problem with Visual C++ 2017
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7089>
2024-06-22 20:56:03 +03:00
Edward Hervey
11ff2b2835 decodebin3: Fix keyframe drop probe handling
We were storing the probe id in a different structure (DecodebinOutputStream)
than the pad it is targetting (which is in MultiQueueSlot).

The problem is that when re-targetting outputs (to a different slot)... we would
end up having an invalid probe id, or not have a reference to an existing one.

Instead, store the probe id in the same structure as the pad it's targetting

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7069>
2024-06-20 12:56:46 +00:00
Edward Hervey
6aa0c8442d decodebin3: Fix detection of selection done
We should not assert if there are still some old streams that are waiting to be
deactivated.

Instead wait for them to be gone before posting the selection done message

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7069>
2024-06-20 12:56:46 +00:00
Alicia Boya García
223b63b1d2 decodebin3: Add missing INPUT_LOCK() before ensure_input_parsebin()
ensure_input_parsebin() has a top comment saying it must be called with
INPUT_LOCK taken, but 2 out of 3 usages of the function call it without
taking that mutex.

This patch adds locking in these two remaining usages.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5279>
2024-06-17 10:15:28 +00:00
Edward Hervey
c5a39f2dfa uridecodebin3: Don't hold PLAY_ITEMS lock when activating them
Once the item is configured it can be activated without holding that lock

Fixes #3610

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7015>
2024-06-11 16:42:27 +00:00
Edward Hervey
74dbbe0091 decodebin3: Always ensure we end up with parsebin or identity
This fixes a regression introduced by 6c4f52ea20

There are cases where the input stream will be push-based, time-segment and not
have a collection nor caps. This means the event-based checks are not sufficient
to decide when/where to plug in a identity or parsebin to process the input.

For those corner cases we setup a buffer probe to ensure we always end up with
at least a parsebin

Fixes #3609

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7010>
2024-06-11 14:57:34 +00:00
Edward Hervey
6c4f52ea20 decodebin3: Avoid usage of parsebin even more
When dealing with push-based inputs, we are now delaying the creation of
parsebin/identity until we get all pre-buffer events.

We therefore can simplify the handling of new pads being linked and only have to
check if upstream can handle pull-based or not.

Avoids creating parsebin for parsed upstream data altogether

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6953>
2024-06-04 14:44:14 +00:00
Edward Hervey
cb95ba72cf decodebin3: Include the stream-id in ERROR/WARNING/INFO messages
Allows application and other users to know to which stream the
error/warning/info message originated from.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6964>
2024-05-31 11:58:21 +00:00
Edward Hervey
686d980955 uridecodebin3: Specify URI for INFO/WARNING/ERROR messages
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6929>
2024-05-29 22:24:07 +00:00
Edward Hervey
94646c642d decodebin3: Specify stream-id for missing decoder
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6886>
2024-05-29 11:44:06 +00:00
Edward Hervey
39f62862d8 decodebin3: Ensure we get a collection for parsed inputs
When we are dealing with parsed inputs (i.e. using identity), we need to ensure
that we have a valid stream collection (and therefore DBCollection) before
anything flows dowsntream.

In those cases, we hold onto those events until we get such a collection.

Fixes #3356

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6774>
2024-05-28 08:31:17 +00:00
Edward Hervey
daa022b9ee decodebin3: New mechanism for handling collection and selections
This commit separates collection and selections into a new separate structure:
DecodebinCollection.

This provides a much cleaner/saner way of dealing with collections being
updated, gapless playback, etc...

There is now a list of DecodebinCollection in flight, of which two are special:
* input_collection, the currently inputted/merged collection
* output_collection, the currently active collection on the output of multiqueue

Handling GST_EVENT_SELECT_STREAMS is split, by looking for the collection to
which it applies. And the requested streams are stored in it. IIF that
collection is output_collection we can do the switch, else it will be updated
when it becomes active.

Detecting which collection/selection is active is done by looking at the
GST_EVENT_STREAM_START on the output of the multiqueue.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6774>
2024-05-28 08:31:17 +00:00
Edward Hervey
c4b625a3fe decodebin3: minor refactoring to identify selected stream
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6774>
2024-05-28 08:31:17 +00:00
Edward Hervey
bfb64f7f44 decodebin3: Debug line cleanups
Use identifiable items in log lines instead of random pointers

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6774>
2024-05-28 08:31:17 +00:00
Edward Hervey
39f2d96105 decodebin: Remove unused includes
* config.h is not used, plugin/element is registered in another file
* play-enum.h is not used

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6774>
2024-05-28 08:31:17 +00:00
Edward Hervey
48cbb1c96f decodebin3: Remove un-needed variable
We don't do anything with the unknown streams. Detecting that a list of
requested streams don't apply to a given collection should be handled
before-hand

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6774>
2024-05-28 08:31:17 +00:00
Edward Hervey
3acb219b76 decodebin3: Remove un-needed variable
pending_select_streams was only set just before releasing/taking the selection
lock in a single place. That temporary lock release is not needed and therefore
the variable isn't needed either

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6774>
2024-05-28 08:31:17 +00:00
Edward Hervey
1ab0936196 decodebin3: Remove active_selection list
It's a duplicate of the list of slots which have an output. Use that instead.

Also when we fail to (re)configure an output, remove it.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6774>
2024-05-28 08:31:17 +00:00
Edward Hervey
ec468e9524 decodebin3: Cache slot stream_id and rename more variables
* Move the handling of GST_EVENT_STREAM_START on a slot to a separate function

* There was a lot of usage of `gst_stream_get_stream_id()` for the slot
active_stream. Cache that instead of constantly querying it.

* Rename the variables in `handle_stream_switch()` to be clearer

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6774>
2024-05-28 08:31:16 +00:00
Edward Hervey
49cd8213bf decodebin3: Refactor slot/output (re)configuration
* Re-use existing function where possible
* Only set/reset keyframe probe at unique places

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6774>
2024-05-28 08:31:16 +00:00
Edward Hervey
faaedd2bb9 decodebin3: Refactor linking input to slot
The same sequence of calls was done when doing that

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6774>
2024-05-28 08:31:16 +00:00
Edward Hervey
a96c761ed7 decodebin3: input_unblock_streams: Clarify variable
It's a list of pads, not slots

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6774>
2024-05-28 08:31:16 +00:00
Edward Hervey
ceeea8afd6 decodebin3: Rename multiqueue related functions
To make clear on what they apply

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6774>
2024-05-28 08:31:16 +00:00
Edward Hervey
fc96e29606 decodebin3: Refactor/rename slot/output
* Centralize associating an output to a slot in one function, including properly
  resetting those fields
* Rename functions to be more explicit
* Move code to "reset" an output stream into a dedicated function (will be used
later)

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6774>
2024-05-28 08:31:16 +00:00
Edward Hervey
1185a560c2 decodebin3: Refactor removal of slot/output from streaming thread
The code was identical in several places

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6774>
2024-05-28 08:31:16 +00:00
Edward Hervey
b825b3547c decodebin3: rename/clarify eos and draining usage around multiqueue
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6774>
2024-05-28 08:31:16 +00:00
Edward Hervey
f7207c24ff decodebin3: Document/refactor DecodebinInput handling
* Rename the function names to be clearer, with prefixes
* Pass the input (or stream) directly where appropriate
* Document usage, inputs, ownership
* Rename variables for clarity where applicable
* Avoid double lock/unlock if callee can handle it directly

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6774>
2024-05-28 08:31:16 +00:00
Edward Hervey
8fd4502ebc decodebin3: Move gstdecodebin3-parse.c into gstdecodebin3.c
Makes it easier to work with LSP

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6774>
2024-05-28 08:31:16 +00:00
Edward Hervey
aeea856f4e decodebin3: Refactor incoming collection handling
Simplify its usage by having it directly create the message if the collection
changed. This is what caller were always doing and avoids releasing selection
locks yet-another-time

Also use it in more places to avoid code repetition

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6774>
2024-05-28 08:31:16 +00:00
Edward Hervey
17e385a6ff decodebin3: Rename variable for clarity
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6774>
2024-05-28 08:31:16 +00:00
Edward Hervey
c0c62388a3 decodebin3: Refactor GST_EVENT_SELECT_STREAMS handling
* The same code is used for the event, regardless of whether it's coming from
via a pad or directly on the element
* The pending_select_streams list content was never used, switch it to a boolean

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6774>
2024-05-28 08:31:16 +00:00
Edward Hervey
dadaa33749 decodebin3: Don't forward select streams if we are handling it
Since the introduction of the "SELECTABLE" query, the usage of selection was
clarified. We don't need to forward the GST_EVENT_SELECT_STREAMS at this point.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6774>
2024-05-28 08:31:15 +00:00
Yacine Bandou
03febb5048 streamsynchronizer: Fix deadlock when streams have been flushed before others start
To simplify the description, I'm assuming we only have two streams: video and audio.

For the video stream, we have the following events :
- STREAM_START => stream->wait set to true
- NEW_SEGMENT(1) => blocked waiting in gst_stream_synchronizer_wait
- FLUSH_START => unblocked
- FLUSH_STOP => stream->wait reset to false
- NEW_SEGMENT(2) => not waiting, since stream->wait is false

Then for the audio stream, we have the following events :
- STREAM_START => stream->wait set to true
- NEW_SEGMENT(2) => blocked waiting in gst_stream_synchronizer_wait for ever.

Note: The first NEW_SEGMENT event and the FLUSH_START, FLUSH_STOP events of the audio stream
are dropped before being received by the streamsynchronizer element, because the decodebin audio pad src
is not yet linked to the playsink audio pad sink.

To fix this deadlock, we don't reset stream->wait to false in the FLUSH_STOP event when it is not
waiting for the EOS of the other streams.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6763>
2024-05-20 20:31:11 +00:00
Edward Hervey
afc1eadfdc streamsynchronizer: Split up event handler code
No changes to behaviour, just split up the big parts into dedicated function for
readability

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6825>
2024-05-17 13:13:41 +00:00
Seungha Yang
b01305f60c decodebin3: Fix caps and stream leaks
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6858>
2024-05-16 10:46:33 +00:00
Edward Hervey
8737b9ca84 playbin3: Handle combiner update in case of errors
The assertion that was present before is a bit too harsh, since there is now
a (understandable) use-case where this could happen.

In gapless use-case, with two files containing the same type (ex:audio). The
first one *does* expose a collection with an audio stream, but decoding
fails (for whatever reason).

That would cause us to have configured a audio combiner, which was never
used (i.e. not active).

Then the second file plays and we (wrongly) assume it should be activated
... whereas the combiner was indeed present.

Demote the assertion to a warning and properly handle it

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

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6737>
2024-04-26 11:31:32 +00:00
Edward Hervey
376aaa828d decodebin3: Remove custom stream-start field if present
This field is added by urisourcebin so that we can avoid double-parsing. It's no
longer needed after.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6690>
2024-04-23 07:09:21 +00:00
Edward Hervey
049665ccaa urisourcebin2: Adaptive demuxers don't require another parsebin
By setting the same field on the GST_EVENT_STREAM_START decodebin3 will be able
to avoid plugging in an extra parsebin

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6690>
2024-04-23 07:09:21 +00:00
Edward Hervey
24c0dc9602 parsebin: Ensure non-time subtitle streams get "parsed"
Since https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6153 ,
subtitle "decoders" (i.e. which decode to raw text) are no longer auto-plugged
by parsebin.

But if a given format does not have a parser at all, we would end up outputting
non-time/non-parsed outputs.

In order to mitigate the issue, until such parsers are available, we check if
the subtitle stream is in TIME format or not (i.e. whether it comes from a
parser or demuxer). If not, we attempt to plug in a subtitle "decoder".

Fixes #3463

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6592>
2024-04-10 09:40:54 +02:00
Edward Hervey
42e24c32e5 uridecodebin3: Don't hold lock when posting messages or signals
There's a very good chance that the receiver might react on those synchronously
and call back into uridecodebin3 (ex: for setting the next URI).

Make sure we release the lock if we need to do that.

Fixes #3400

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6402>
2024-03-19 09:34:18 +01:00
Edward Hervey
c1ac015325 uridecodebin3: Handle potential double redirection errors
Some elements (like qtdemux) might post a redirection error message twice. We
only want to handle it once.

Fixes #3390

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6389>
2024-03-18 13:30:24 +00:00
Edward Hervey
b1f4dcb068 decodebin3: Post error messages if there are no streams to output
This could happen because:
* No streams were selected
* Or we end up with no stream selected

Also post a warning message if we are missing plugins but there are other
streams to output

Fixes #3360

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6323>
2024-03-14 18:15:33 +00:00
Edward Hervey
11b1f70aea decodebin3: Remove failing stream from active selection also
It gets added in get_output_slot()

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6323>
2024-03-14 18:15:33 +00:00
Edward Hervey
0f1dfc2db0 playbin3: Remove un-needed URI NULL check
This will mimic the playbin2 behaviour, which sets the "next" entry to be
NULL.

The biggest impact this has is that when going back to READY the current play
entry will be discarded (instead of being kept around for when you go back to
PAUSED/PLAYING).

Fixes #3371

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6324>
2024-03-11 17:33:04 +00:00
Edward Hervey
5f7062136d decodebin3: Handle race switching on pending streams
find_slot_for_stream_id() will return a slot which has the request stream-id as
active_stream *or* pending_stream (i.e. the slot on which that stream is
currently being outputted or will be outputted).

When figuring out which slot to use (if any) we want to consider stream-id
which *will* appear on a given slot which isn't outputting anything yet the same
way as if we didn't find a slot yet.

Fixes races when doing intensive state changes

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6270>
2024-03-11 11:13:59 +00:00
Edward Hervey
e03e2308d7 decodebin3: Clear select streams seqnum when resetting
At this point there's definitely no pending select streams

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6270>
2024-03-11 11:13:59 +00:00