mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-02 04:22:27 +00:00
decodebin3: Only override the selection if needed
Whenever a new collection is calculated, the internal `select_streams_seqnum` variable is reset. This ensures that we reliably know whether a select-streams event has been received for that new collection. Use that to decide whether we should add previously un-selected streams or new streams in the current selection Fixes #784 Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/733>
This commit is contained in:
parent
2f83ca5c7f
commit
c9c93339fb
3 changed files with 27 additions and 3 deletions
|
@ -579,6 +579,10 @@ gst_decodebin3_class_init (GstDecodebin3Class * klass)
|
|||
* This signal is emitted whenever @decodebin needs to decide whether
|
||||
* to expose a @stream of a given @collection.
|
||||
*
|
||||
* Note that the prefered way to select streams is to listen to
|
||||
* GST_MESSAGE_STREAM_COLLECTION on the bus and send a
|
||||
* GST_EVENT_SELECT_STREAMS with the streams the user wants.
|
||||
*
|
||||
* Returns: 1 if the stream should be selected, 0 if it shouldn't be selected.
|
||||
* A value of -1 (default) lets @decodebin decide what to do with the stream.
|
||||
* */
|
||||
|
@ -922,6 +926,7 @@ gst_decodebin3_input_pad_unlink (GstPad * pad, GstObject * parent)
|
|||
if (dbin->collection)
|
||||
gst_object_unref (dbin->collection);
|
||||
dbin->collection = collection;
|
||||
dbin->select_streams_seqnum = GST_SEQNUM_INVALID;
|
||||
|
||||
msg =
|
||||
gst_message_new_stream_collection ((GstObject *) dbin,
|
||||
|
@ -1161,14 +1166,15 @@ update_requested_selection (GstDecodebin3 * dbin)
|
|||
}
|
||||
|
||||
/* 4. If the user didn't explicitly selected all streams, match one stream of each type */
|
||||
if (!all_user_selected && !dbin->requested_selection) {
|
||||
if (!all_user_selected && dbin->select_streams_seqnum == GST_SEQNUM_INVALID) {
|
||||
for (i = 0; i < nb; i++) {
|
||||
GstStream *stream = gst_stream_collection_get_stream (collection, i);
|
||||
GstStreamType curtype = gst_stream_get_stream_type (stream);
|
||||
if (!(used_types & curtype)) {
|
||||
const gchar *sid = gst_stream_get_stream_id (stream);
|
||||
GST_DEBUG_OBJECT (dbin, "Selecting stream '%s' of type %s",
|
||||
sid, gst_stream_type_get_name (curtype));
|
||||
GST_DEBUG_OBJECT (dbin,
|
||||
"Automatically selecting stream '%s' of type %s", sid,
|
||||
gst_stream_type_get_name (curtype));
|
||||
tmp = g_list_append (tmp, (gchar *) sid);
|
||||
used_types |= curtype;
|
||||
}
|
||||
|
@ -1453,6 +1459,7 @@ handle_stream_collection (GstDecodebin3 * dbin,
|
|||
/* dbin->pending_collection = */
|
||||
/* g_list_append (dbin->pending_collection, collection); */
|
||||
}
|
||||
dbin->select_streams_seqnum = GST_SEQNUM_INVALID;
|
||||
SELECTION_UNLOCK (dbin);
|
||||
}
|
||||
|
||||
|
|
|
@ -85,6 +85,19 @@
|
|||
* setting the format passed to GST_FORMAT_TIME. If the query was successful,
|
||||
* the duration or position will have been returned in units of nanoseconds.
|
||||
*
|
||||
* ## Selecting streams
|
||||
*
|
||||
* The recommended way to select streams (instead of the default selection) is
|
||||
* to listen to GST_MESSAGE_STREAM_COLLECTION messages on the GstBus and send a
|
||||
* GST_EVENT_SELECT_STREAMS on the pipeline with the selected streams. This
|
||||
* provides more information and flexibility compared to the legacy #GstPlayBin
|
||||
* property and signal-based mechanism.
|
||||
*
|
||||
* Note: The application should not assume that collections will not change
|
||||
* throughout a single file. If it wishes to modify the default selection, it
|
||||
* should always respond to new collections posted on the bus with a
|
||||
* GST_EVENT_SELECT_STREAMS.
|
||||
*
|
||||
* ## Advanced Usage: specifying the audio and video sink
|
||||
*
|
||||
* By default, if no audio sink or video sink has been specified via the
|
||||
|
|
|
@ -483,6 +483,10 @@ gst_uri_decode_bin3_class_init (GstURIDecodeBin3Class * klass)
|
|||
* This signal is emitted whenever @decodebin needs to decide whether
|
||||
* to expose a @stream of a given @collection.
|
||||
*
|
||||
* Note that the prefered way to select streams is to listen to
|
||||
* GST_MESSAGE_STREAM_COLLECTION on the bus and send a
|
||||
* GST_EVENT_SELECT_STREAMS with the streams the user wants.
|
||||
*
|
||||
* Returns: 1 if the stream should be selected, 0 if it shouldn't be selected.
|
||||
* A value of -1 (default) lets @decodebin decide what to do with the stream.
|
||||
* */
|
||||
|
|
Loading…
Reference in a new issue