[vlc-devel] [PATCH v2] player: add GetSelectedProgram() helper

Romain Vimont rom1v at videolabs.io
Thu May 2 13:36:59 CEST 2019


There were helpers for retrieving the selected title, chapter or track,
but a helper for the selected program was missing.
---

Big change from v1: "an helper" -> "a helper" in commit message.

 include/vlc_player.h | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/include/vlc_player.h b/include/vlc_player.h
index ad170f3306..a055c842cc 100644
--- a/include/vlc_player.h
+++ b/include/vlc_player.h
@@ -1965,6 +1965,24 @@ vlc_player_SelectNextProgram(vlc_player_t *player);
 VLC_API void
 vlc_player_SelectPrevProgram(vlc_player_t *player);
 
+/**
+ * Helper to get the current selected program
+ */
+static inline const struct vlc_player_program *
+vlc_player_GetSelectedProgram(vlc_player_t *player)
+{
+    size_t count = vlc_player_GetProgramCount(player);
+    for (size_t i = 0; i < count; ++i)
+    {
+        const struct vlc_player_program *program =
+            vlc_player_GetProgramAt(player, i);
+        assert(program);
+        if (program->selected)
+            return program;
+    }
+    return NULL;
+}
+
 /**
  * Check if the media has a teletext menu
  *
-- 
2.20.1



More information about the vlc-devel mailing list