mirror of https://code.videolan.org/videolan/vlc
lib: add libvlc_media_player_(get|set)_role
This commit is contained in:
parent
9670e5d983
commit
c659faff1d
|
@ -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 */
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue