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