<html><head></head><body>Hi,<br><br>You could use memstream_puts directly here.<br><br><div class="gmail_quote">Le 20 juin 2019 18:23:49 GMT+03:00, Thomas Guillem <thomas@gllm.fr> a écrit :<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="k9mail">From: Roland Bewick <roland.bewick@gmail.com><br><br>Signed-off-by: Thomas Guillem <thomas@gllm.fr><hr> include/vlc_player.h | 26 +++++++++++++++++<br> src/input/player.c | 68 ++++++++++++++++++++++++++++++++++++++++++++<br> src/libvlccore.sym | 1 +<br> 3 files changed, 95 insertions(+)<br><br>diff --git a/include/vlc_player.h b/include/vlc_player.h<br>index 225051447a..4fcf4f0bb7 100644<br>--- a/include/vlc_player.h<br>+++ b/include/vlc_player.h<br>@@ -1749,6 +1749,32 @@ vlc_player_SelectTrack(vlc_player_t *player,<br> vlc_player_SelectEsId(player, track->es_id);<br> }<br> <br>+/**<br>+ * Select multiple tracks from a list of ES identifiers.<br>+ *<br>+ * Any tracks of the category, not referenced in the list will be unselected.<br>+ *<br>+ * @warning there is no guarantee all requested tracks will be selected.<br>+ * Only one audio track can be selected at a time. Two subtitle tracks<br>+ * can be selected simultaneously.<br>+ *<br>+ * @warning behaviour is undefined if the list is not null-terminated.<br>+ *<br>+ * @note A successful call will trigger the<br>+ * vlc_player_cbs.on_track_selection_changed event for each track that has<br>+ * its selection state changed.<br>+ *<br>+ * @param player locked player instance<br>+ * @param cat VIDEO_ES, AUDIO_ES or SPU_ES<br>+ * @param es_id_list a null-terminated list of ES identifiers.<br>+ * (ES IDs can be retrieved from vlc_player_cbs.on_track_list_changed or<br>+ * vlc_player_GetTrackAt())<br>+ */<br>+VLC_API void<br>+vlc_player_SelectEsIdList(vlc_player_t *player,<br>+ enum es_format_category_e cat,<br>+ vlc_es_id_t *const es_id_list[]);<br>+<br> /**<br> * Select the next track<br> *<br>diff --git a/src/input/player.c b/src/input/player.c<br>index fd0ef7f8ea..358502d21b 100644<br>--- a/src/input/player.c<br>+++ b/src/input/player.c<br>@@ -32,6 +32,7 @@<br> #include <vlc_atomic.h><br> #include <vlc_tick.h><br> #include <vlc_decoder.h><br>+#include <vlc_memstream.h><br> <br> #include "libvlc.h"<br> #include "input_internal.h"<br>@@ -1394,6 +1395,73 @@ vlc_player_SelectEsId(vlc_player_t *player, vlc_es_id_t *id)<br> vlc_player_vout_OSDTrack(player, id, true);<br> }<br> <br>+void<br>+vlc_player_SelectEsIdList(vlc_player_t *player,<br>+ enum es_format_category_e cat,<br>+ vlc_es_id_t *const es_id_list[])<br>+{<br>+ struct vlc_player_input *input = vlc_player_get_input_locked(player);<br>+ if (!input)<br>+ return;<br>+<br>+ /* First, count and hold all the ES Ids.<br>+ Ids will be released in input.c:ControlRelease */<br>+ size_t id_count;<br>+ for (id_count = 0; es_id_list[id_count] != NULL; id_count++);<br>+<br>+ /* Copy es_id_list into an allocated list so that it remains in memory until<br>+ selection completes. The list will be freed in input.c:ControlRelease */<br>+ struct vlc_es_id_t **allocated_ids =<br>+ vlc_alloc(id_count + 1, sizeof(vlc_es_id_t *));<br>+<br>+ if (allocated_ids == NULL)<br>+ return;<br>+<br>+ for (size_t i = 0; i < id_count; i++)<br>+ {<br>+ vlc_es_id_t *es_id = es_id_list[i];<br>+<br>+ vlc_es_id_Hold(es_id);<br>+ allocated_ids[i] = es_id;<br>+ }<br>+ allocated_ids[id_count] = NULL;<br>+<br>+ /* Attempt to select all the requested tracks */<br>+ input_ControlPush(input->thread, INPUT_CONTROL_SET_ES_LIST,<br>+ &(input_control_param_t) {<br>+ .list.cat = cat,<br>+ .list.ids = allocated_ids,<br>+ });<br>+<br>+ /* Display track selection message */<br>+ const char *cat_name = es_format_category_to_string(cat);<br>+ if (id_count == 0)<br>+ vlc_player_vout_OSDMessage(player, _("%s track: %s"), cat_name,<br>+ _("N/A"));<br>+ else if (id_count == 1)<br>+ vlc_player_vout_OSDTrack(player, es_id_list[0], true);<br>+ else<br>+ {<br>+ struct vlc_memstream stream;<br>+ vlc_memstream_open(&stream);<br>+ for (size_t i = 0; i < id_count; i++)<br>+ {<br>+ const struct vlc_player_track *track =<br>+ vlc_player_GetTrack(player, es_id_list[i]);<br>+<br>+ if (track)<br>+ vlc_memstream_printf(&stream, "%s%s",<br>+ i == 0 ? "" : ", ", track->name);<br>+ }<br>+ if (vlc_memstream_close(&stream) == 0)<br>+ {<br>+ vlc_player_vout_OSDMessage(player, _("%s tracks: %s"), cat_name,<br>+ stream.ptr);<br>+ free(stream.ptr);<br>+ }<br>+ }<br>+}<br>+<br> static void<br> vlc_player_CycleTrack(vlc_player_t *player, enum es_format_category_e cat,<br> bool next)<br>diff --git a/src/libvlccore.sym b/src/libvlccore.sym<br>index 7432848866..3c11a9fefd 100644<br>--- a/src/libvlccore.sym<br>+++ b/src/libvlccore.sym<br>@@ -834,6 +834,7 @@ vlc_player_SelectCategoryLanguage<br> vlc_player_SelectChapter<br> vlc_player_SelectChapterIdx<br> vlc_player_SelectEsId<br>+vlc_player_SelectEsIdList<br> vlc_player_SelectNextChapter<br> vlc_player_SelectNextTitle<br> vlc_player_SelectNextTrack</pre></blockquote></div><br>-- <br>Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.</body></html>