[vlc-commits] player: add vlc_player_input_GetSelectedTrackStringIds
Thomas Guillem
git at videolan.org
Fri Feb 28 20:46:46 CET 2020
vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Fri Feb 28 13:30:44 2020 +0100| [bbf542817d46aa31eca0d19a29af847a636034b3] | committer: Thomas Guillem
player: add vlc_player_input_GetSelectedTrackStringIds
It returns the list of selected tracks that can be saved to later usage.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=bbf542817d46aa31eca0d19a29af847a636034b3
---
src/player/input.c | 33 +++++++++++++++++++++++++++++++++
src/player/player.h | 4 ++++
2 files changed, 37 insertions(+)
diff --git a/src/player/input.c b/src/player/input.c
index 7fccd70b91..59c2d5655e 100644
--- a/src/player/input.c
+++ b/src/player/input.c
@@ -24,6 +24,7 @@
#include <vlc_common.h>
#include <vlc_interface.h>
+#include <vlc_memstream.h>
#include "player.h"
struct vlc_player_track_priv *
@@ -842,6 +843,38 @@ vlc_player_input_SelectTracksByStringIds(struct vlc_player_input *input,
input_SetEsCatIds(input->thread, cat, str_ids);
}
+char *
+vlc_player_input_GetSelectedTrackStringIds(struct vlc_player_input *input,
+ enum es_format_category_e cat)
+{
+ vlc_player_track_vector *vec = vlc_player_input_GetTrackVector(input, cat);
+ assert(vec);
+ bool first_track = true;
+ struct vlc_memstream ms;
+
+ struct vlc_player_track_priv* t;
+ vlc_vector_foreach(t, vec)
+ {
+ if (t->selected_by_user && vlc_es_id_IsStrIdStable(t->t.es_id))
+ {
+ if (first_track)
+ {
+ int ret = vlc_memstream_open(&ms);
+ if (ret != 0)
+ return NULL;
+ }
+ const char *str_id = vlc_es_id_GetStrId(t->t.es_id);
+ assert(str_id);
+
+ if (!first_track)
+ vlc_memstream_putc(&ms, ',');
+ vlc_memstream_puts(&ms, str_id);
+ first_track = false;
+ }
+ }
+ return !first_track && vlc_memstream_close(&ms) == 0 ? ms.ptr : NULL;
+}
+
struct vlc_player_input *
vlc_player_input_New(vlc_player_t *player, input_item_t *item)
{
diff --git a/src/player/player.h b/src/player/player.h
index 8148d6cb62..2583ab8436 100644
--- a/src/player/player.h
+++ b/src/player/player.h
@@ -404,6 +404,10 @@ vlc_player_input_SelectTracksByStringIds(struct vlc_player_input *input,
enum es_format_category_e cat,
const char *str_ids);
+char *
+vlc_player_input_GetSelectedTrackStringIds(struct vlc_player_input *input,
+ enum es_format_category_e cat);
+
vlc_tick_t
vlc_player_input_GetTime(struct vlc_player_input *input);
More information about the vlc-commits
mailing list