[vlc-commits] libvlc: libvlc_ScrambledChanged event type added
Julian Scheel
git at videolan.org
Fri Feb 7 22:15:20 CET 2014
vlc | branch: master | Julian Scheel <julian at jusst.de> | Thu Feb 6 22:03:24 2014 +0100| [8b9e6d1672f569aee20e663bd938266c1b73224b] | committer: 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: Rémi Denis-Courmont <remi at remlab.net>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8b9e6d1672f569aee20e663bd938266c1b73224b
---
include/vlc/libvlc_events.h | 5 +++++
include/vlc/libvlc_media_player.h | 9 ++++++++
lib/libvlc.sym | 1 +
lib/media_player.c | 41 +++++++++++++++++++++++++++++++++++++
4 files changed, 56 insertions(+)
diff --git a/include/vlc/libvlc_events.h b/include/vlc/libvlc_events.h
index ae1a94b..f268fb5 100644
--- a/include/vlc/libvlc_events.h
+++ b/include/vlc/libvlc_events.h
@@ -73,6 +73,7 @@ enum libvlc_event_e {
libvlc_MediaPlayerSnapshotTaken,
libvlc_MediaPlayerLengthChanged,
libvlc_MediaPlayerVout,
+ libvlc_MediaPlayerScrambledChanged,
libvlc_MediaListItemAdded=0x200,
libvlc_MediaListWillAddItem,
@@ -170,6 +171,10 @@ typedef struct libvlc_event_t
} media_player_pausable_changed;
struct
{
+ int new_scrambled;
+ } media_player_scrambled_changed;
+ struct
+ {
int new_count;
} media_player_vout;
diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index 27f7b97..85e39a3 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -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)
diff --git a/lib/libvlc.sym b/lib/libvlc.sym
index 7c99668..fdfd164 100644
--- a/lib/libvlc.sym
+++ b/lib/libvlc.sym
@@ -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
diff --git a/lib/media_player.c b/lib/media_player.c
index c23dd42..daa9def 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -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 );
@@ -212,6 +218,24 @@ input_pausable_changed( vlc_object_t * p_this, char const * psz_cmd,
}
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,
void * p_userdata )
@@ -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 );
More information about the vlc-commits
mailing list