[vlc-commits] lib: add libvlc_media_player_(get|set)_role
Rémi Denis-Courmont
git at videolan.org
Sun Jun 5 11:27:36 CEST 2016
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Jun 4 18:02:05 2016 +0300| [c659faff1dcf707208b95fd1ccd5408708a3fc91] | committer: Rémi Denis-Courmont
lib: add libvlc_media_player_(get|set)_role
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c659faff1dcf707208b95fd1ccd5408708a3fc91
---
include/vlc/libvlc_media_player.h | 33 ++++++++++++++++++++++++++++++
lib/libvlc.sym | 2 ++
lib/media_player.c | 40 +++++++++++++++++++++++++++++++++++++
3 files changed, 75 insertions(+)
diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index f047c4d..85b0155 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -1967,6 +1967,39 @@ 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 );
+/**
+ * Media player roles.
+ *
+ * See \ref libvlc_media_player_set_role()
+ */
+typedef enum libvlc_media_player_role {
+ libvlc_role_Music=1 /**< Music (or radio) playback */,
+ libvlc_role_Video /**< Video playback */,
+ libvlc_role_Communication /**< Speech, real-time communication */,
+ libvlc_role_Game /**< Video game */,
+ liblvc_role_Notification /**< User interaction feedback */,
+ libvlc_role_Animation /**< Embedded animation (e.g. in web page) */,
+ libvlc_role_Production /**< Audio editting/production */,
+ libvlc_role_Accessibility /**< Accessibility */,
+ libvlc_role_Test /** Testing */,
+} libvlc_media_player_role_t;
+
+/**
+ * Gets the media role.
+ *
+ * \return the media player role (\ref libvlc_media_player_role_t)
+ */
+LIBVLC_API int libvlc_media_player_get_role(libvlc_media_player_t *);
+
+/**
+ * Sets the media role.
+ *
+ * \param role the media player role (\ref libvlc_media_player_role_t)
+ * \return 0 on success, -1 on error
+ */
+LIBVLC_API int libvlc_media_player_set_role(libvlc_media_player_t *,
+ unsigned 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..e740705 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,42 @@ int libvlc_media_player_set_equalizer( libvlc_media_player_t *p_mi, libvlc_equal
return 0;
}
+
+static const char roles[][16] =
+{
+ [libvlc_role_Music] = "music",
+ [libvlc_role_Video] = "video",
+ [libvlc_role_Communication] = "communication",
+ [libvlc_role_Game] = "game",
+ [liblvc_role_Notification] = "notification",
+ [libvlc_role_Animation] = "animation",
+ [libvlc_role_Production] = "production",
+ [libvlc_role_Accessibility] = "accessibility",
+ [libvlc_role_Test] = "test",
+};
+
+int libvlc_media_player_set_role(libvlc_media_player_t *mp, unsigned role)
+{
+ if (role >= ARRAY_SIZE(roles)
+ || var_SetString(mp, "role", roles[role]) != VLC_SUCCESS)
+ return -1;
+ return 0;
+}
+
+int libvlc_media_player_get_role(libvlc_media_player_t *mp)
+{
+ int ret = -1;
+ char *str = var_GetString(mp, "role");
+ if (str == NULL)
+ return 0;
+
+ for (size_t i = 0; i < ARRAY_SIZE(roles); i++)
+ if (!strcmp(roles[i], str))
+ {
+ ret = i;
+ break;
+ }
+
+ free(str);
+ return ret;
+}
More information about the vlc-commits
mailing list