Commit 8b9e6d16 authored by Julian Scheel's avatar Julian Scheel Committed by Rémi Denis-Courmont

libvlc: libvlc_ScrambledChanged event type added

Expose an event to libvlc users which allows them to get notified about the
current program scrambling status.
Signed-off-by: default avatarRémi Denis-Courmont <remi@remlab.net>
parent 23ca8078
......@@ -73,6 +73,7 @@ enum libvlc_event_e {
libvlc_MediaPlayerSnapshotTaken,
libvlc_MediaPlayerLengthChanged,
libvlc_MediaPlayerVout,
libvlc_MediaPlayerScrambledChanged,
libvlc_MediaListItemAdded=0x200,
libvlc_MediaListWillAddItem,
......@@ -169,6 +170,10 @@ typedef struct libvlc_event_t
int new_pausable;
} media_player_pausable_changed;
struct
{
int new_scrambled;
} media_player_scrambled_changed;
struct
{
int new_count;
} media_player_vout;
......
......@@ -828,6 +828,15 @@ LIBVLC_API int libvlc_media_player_is_seekable( libvlc_media_player_t *p_mi );
*/
LIBVLC_API int libvlc_media_player_can_pause( libvlc_media_player_t *p_mi );
/**
* Check if the current program is scrambled
*
* \param p_mi the media player
* \return true if the current program is scrambled
*
* \libvlc_return_bool
*/
LIBVLC_API int libvlc_media_player_program_scrambled( libvlc_media_player_t *p_mi );
/**
* Display the next frame (if supported)
......
......@@ -132,6 +132,7 @@ libvlc_media_new_from_input_item
libvlc_media_parse
libvlc_media_parse_async
libvlc_media_player_can_pause
libvlc_media_player_program_scrambled
libvlc_media_player_next_frame
libvlc_media_player_event_manager
libvlc_media_player_get_agl
......
......@@ -49,6 +49,10 @@ input_pausable_changed( vlc_object_t * p_this, char const * psz_cmd,
vlc_value_t oldval, vlc_value_t newval,
void * p_userdata );
static int
input_scrambled_changed( vlc_object_t * p_this, char const * psz_cmd,
vlc_value_t oldval, vlc_value_t newval,
void * p_userdata );
static int
input_event_changed( vlc_object_t * p_this, char const * psz_cmd,
vlc_value_t oldval, vlc_value_t newval,
void * p_userdata );
......@@ -117,6 +121,8 @@ static void release_input_thread( libvlc_media_player_t *p_mi, bool b_input_abor
input_seekable_changed, p_mi );
var_DelCallback( p_input_thread, "can-pause",
input_pausable_changed, p_mi );
var_DelCallback( p_input_thread, "program-scrambled",
input_scrambled_changed, p_mi );
var_DelCallback( p_input_thread, "intf-event",
input_event_changed, p_mi );
......@@ -211,6 +217,24 @@ input_pausable_changed( vlc_object_t * p_this, char const * psz_cmd,
return VLC_SUCCESS;
}
static int
input_scrambled_changed( vlc_object_t * p_this, char const * psz_cmd,
vlc_value_t oldval, vlc_value_t newval,
void * p_userdata )
{
VLC_UNUSED(oldval);
VLC_UNUSED(p_this);
VLC_UNUSED(psz_cmd);
libvlc_media_player_t * p_mi = p_userdata;
libvlc_event_t event;
event.type = libvlc_MediaPlayerScrambledChanged;
event.u.media_player_scrambled_changed.new_scrambled = newval.b_bool;
libvlc_event_send( p_mi->p_event_manager, &event );
return VLC_SUCCESS;
}
static int
input_event_changed( vlc_object_t * p_this, char const * psz_cmd,
vlc_value_t oldval, vlc_value_t newval,
......@@ -507,6 +531,7 @@ libvlc_media_player_new( libvlc_instance_t *instance )
register_event(mp, PausableChanged);
register_event(mp, Vout);
register_event(mp, ScrambledChanged);
/* Snapshot initialization */
register_event(mp, SnapshotTaken);
......@@ -717,6 +742,7 @@ int libvlc_media_player_play( libvlc_media_player_t *p_mi )
var_AddCallback( p_input_thread, "can-seek", input_seekable_changed, p_mi );
var_AddCallback( p_input_thread, "can-pause", input_pausable_changed, p_mi );
var_AddCallback( p_input_thread, "program-scrambled", input_scrambled_changed, p_mi );
var_AddCallback( p_input_thread, "intf-event", input_event_changed, p_mi );
if( input_Start( p_input_thread ) )
......@@ -724,6 +750,7 @@ int libvlc_media_player_play( libvlc_media_player_t *p_mi )
unlock_input(p_mi);
var_DelCallback( p_input_thread, "intf-event", input_event_changed, p_mi );
var_DelCallback( p_input_thread, "can-pause", input_pausable_changed, p_mi );
var_DelCallback( p_input_thread, "program-scrambled", input_scrambled_changed, p_mi );
var_DelCallback( p_input_thread, "can-seek", input_seekable_changed, p_mi );
vlc_object_release( p_input_thread );
libvlc_printerr( "Input initialization failure" );
......@@ -1380,6 +1407,20 @@ int libvlc_media_player_can_pause( libvlc_media_player_t *p_mi )
return b_can_pause;
}
int libvlc_media_player_program_scrambled( libvlc_media_player_t *p_mi )
{
input_thread_t *p_input_thread;
bool b_program_scrambled;
p_input_thread = libvlc_get_input_thread ( p_mi );
if ( !p_input_thread )
return false;
b_program_scrambled = var_GetBool( p_input_thread, "program-scrambled" );
vlc_object_release( p_input_thread );
return b_program_scrambled;
}
void libvlc_media_player_next_frame( libvlc_media_player_t *p_mi )
{
input_thread_t *p_input_thread = libvlc_get_input_thread ( p_mi );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment