clapper: Post playlist message before setting next URI

Fixes a problem where error message from unplayable URI content
(e.g. non-existing file) arrives on pipeline bus before resolved
playlist which contains that URI.

With this change, a playlist can be resolved into individual items
which are put into queue even if first item of it is unplayable.
This commit is contained in:
Rafał Dzięgiel
2025-11-21 18:18:49 +01:00
parent 9e955f4e5f
commit 4acb3e38b3

View File

@@ -309,16 +309,32 @@ _filter_playlistables (ClapperPlaylistDemux *self, GstCaps *caps, ClapperEnhance
static inline gboolean
_handle_playlist (ClapperPlaylistDemux *self, GListStore *playlist, GCancellable *cancellable)
{
ClapperMediaItem *item = g_list_model_get_item (G_LIST_MODEL (playlist), 0);
ClapperMediaItem *item;
GstStructure *structure;
const gchar *uri;
gboolean success;
if (g_cancellable_is_cancelled (cancellable)) {
GST_ELEMENT_ERROR (self, RESOURCE, OPEN_READ,
("Playlist parsing was cancelled"), (NULL));
return FALSE;
}
item = g_list_model_get_item (G_LIST_MODEL (playlist), 0);
if (G_UNLIKELY (item == NULL)) {
GST_ELEMENT_ERROR (self, RESOURCE, OPEN_READ,
("This playlist appears to be empty"), (NULL));
return FALSE;
}
/* Post playlist before setting an URI, so it arrives
* before eventual error (e.g. non-existing file) */
structure = gst_structure_new ("ClapperPlaylistParsed",
"playlist", G_TYPE_LIST_STORE, playlist, NULL);
gst_element_post_message (GST_ELEMENT_CAST (self),
gst_message_new_element (GST_OBJECT_CAST (self), structure));
uri = clapper_media_item_get_uri (item);
success = clapper_uri_base_demux_set_uri (CLAPPER_URI_BASE_DEMUX_CAST (self), uri, NULL);
gst_object_unref (item);
@@ -329,14 +345,6 @@ _handle_playlist (ClapperPlaylistDemux *self, GListStore *playlist, GCancellable
return FALSE;
}
if (!g_cancellable_is_cancelled (cancellable)) {
GstStructure *structure = gst_structure_new ("ClapperPlaylistParsed",
"playlist", G_TYPE_LIST_STORE, playlist, NULL);
gst_element_post_message (GST_ELEMENT_CAST (self),
gst_message_new_element (GST_OBJECT_CAST (self), structure));
}
return TRUE;
}