[vlc-devel] [PATCH 3/3] lib: add libvlc_media_player_(get|set)_role

Rémi Denis-Courmont remi at remlab.net
Sun Jun 5 10:28:48 CEST 2016


---
 include/vlc/libvlc_media_player.h | 18 ++++++++++++++++++
 lib/libvlc.sym                    |  2 ++
 lib/media_player.c                | 11 +++++++++++
 3 files changed, 31 insertions(+)

diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index f047c4d..e761d8b 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -1967,6 +1967,24 @@ LIBVLC_API float libvlc_audio_equalizer_get_amp_at_index( libvlc_equalizer_t *p_
  */
 LIBVLC_API int libvlc_media_player_set_equalizer( libvlc_media_player_t *p_mi, libvlc_equalizer_t *p_equalizer );
 
+/**
+ * Get the media role.
+ *
+ * \return a heap-allocated string for the currently set role,
+ * or NULL on error. The caller must free the string with with free().
+ */
+LIBVLC_API char *libvlc_media_player_get_role(libvlc_media_player_t *);
+
+/**
+ * Set the media role.
+ *
+ * \param role media role ("music", "video", "communication", "game",
+ *             "notification", "animation", "production", "accessibility"
+ *             or "test")
+ */
+LIBVLC_API void libvlc_media_player_set_role(libvlc_media_player_t *,
+                                             const char *role);
+
 /** @} audio */
 
 /** @} media_player */
diff --git a/lib/libvlc.sym b/lib/libvlc.sym
index 816025d..d644863 100644
--- a/lib/libvlc.sym
+++ b/lib/libvlc.sym
@@ -165,6 +165,7 @@ libvlc_media_player_get_media
 libvlc_media_player_get_nsobject
 libvlc_media_player_get_position
 libvlc_media_player_get_rate
+libvlc_media_player_get_role
 libvlc_media_player_get_state
 libvlc_media_player_get_time
 libvlc_media_player_get_title
@@ -192,6 +193,7 @@ libvlc_media_player_set_media
 libvlc_media_player_set_nsobject
 libvlc_media_player_set_position
 libvlc_media_player_set_rate
+libvlc_media_player_set_role
 libvlc_media_player_set_time
 libvlc_media_player_set_title
 libvlc_media_player_set_xwindow
diff --git a/lib/media_player.c b/lib/media_player.c
index e56f63f..e58bcd9 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -677,6 +677,7 @@ libvlc_media_player_new( libvlc_instance_t *instance )
     var_Create (mp, "volume", VLC_VAR_FLOAT);
     var_Create (mp, "corks", VLC_VAR_INTEGER);
     var_Create (mp, "audio-filter", VLC_VAR_STRING);
+    var_Create (mp, "role", VLC_VAR_STRING | VLC_VAR_DOINHERIT);
     var_Create (mp, "amem-data", VLC_VAR_ADDRESS);
     var_Create (mp, "amem-setup", VLC_VAR_ADDRESS);
     var_Create (mp, "amem-cleanup", VLC_VAR_ADDRESS);
@@ -1962,3 +1963,13 @@ int libvlc_media_player_set_equalizer( libvlc_media_player_t *p_mi, libvlc_equal
 
     return 0;
 }
+
+void libvlc_media_player_set_role(libvlc_media_player_t *mp, const char *role)
+{
+    var_SetString(mp, "role", role);
+}
+
+char *libvlc_media_player_get_role(libvlc_media_player_t *mp)
+{
+    return var_GetString(mp, "role");
+}
-- 
1.9.1



More information about the vlc-devel mailing list