[vlc-devel] [PATCH 4/4] libvlc: add 3 libvlc events: MediaPlayerESAdded, MediaPlayerESDeleted, MediaPlayerESSelected
Felix Abecassis
felix.abecassis at gmail.com
Fri Jul 18 19:40:52 CEST 2014
---
include/vlc/libvlc_events.h | 9 +++++++++
lib/event.c | 3 +++
lib/media_player.c | 39 +++++++++++++++++++++++++++++++++++++++
3 files changed, 51 insertions(+)
diff --git a/include/vlc/libvlc_events.h b/include/vlc/libvlc_events.h
index f268fb5..963163a 100644
--- a/include/vlc/libvlc_events.h
+++ b/include/vlc/libvlc_events.h
@@ -74,6 +74,9 @@ enum libvlc_event_e {
libvlc_MediaPlayerLengthChanged,
libvlc_MediaPlayerVout,
libvlc_MediaPlayerScrambledChanged,
+ libvlc_MediaPlayerESAdded,
+ libvlc_MediaPlayerESDeleted,
+ libvlc_MediaPlayerESSelected,
libvlc_MediaListItemAdded=0x200,
libvlc_MediaListWillAddItem,
@@ -230,6 +233,12 @@ typedef struct libvlc_event_t
{
libvlc_media_t * new_media;
} media_player_media_changed;
+
+ struct
+ {
+ libvlc_track_type_t i_type;
+ int i_id;
+ } media_player_es_changed;
} u; /**< Type-dependent event description */
} libvlc_event_t;
diff --git a/lib/event.c b/lib/event.c
index aa285f9..7cc17bf 100644
--- a/lib/event.c
+++ b/lib/event.c
@@ -281,6 +281,9 @@ static const event_name_t event_list[] = {
DEF(MediaPlayerLengthChanged)
DEF(MediaPlayerVout)
DEF(MediaPlayerScrambledChanged)
+ DEF(MediaPlayerESAdded)
+ DEF(MediaPlayerESDeleted)
+ DEF(MediaPlayerESSelected)
DEF(MediaListItemAdded)
DEF(MediaListWillAddItem)
diff --git a/lib/media_player.c b/lib/media_player.c
index b31a832..47aa828 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -235,6 +235,21 @@ input_scrambled_changed( vlc_object_t * p_this, char const * psz_cmd,
return VLC_SUCCESS;
}
+static libvlc_track_type_t get_libvlc_track_type(int i_cat)
+{
+ switch ( i_cat )
+ {
+ case VIDEO_ES:
+ return libvlc_track_video;
+ case AUDIO_ES:
+ return libvlc_track_audio;
+ case SPU_ES:
+ return libvlc_track_text;
+ default:
+ return libvlc_track_unknown;
+ }
+}
+
static int
input_event_changed( vlc_object_t * p_this, char const * psz_cmd,
vlc_value_t oldval, vlc_value_t newval,
@@ -343,6 +358,27 @@ input_event_changed( vlc_object_t * p_this, char const * psz_cmd,
event.u.media_player_vout.new_count = i_vout;
libvlc_event_send( p_mi->p_event_manager, &event );
}
+ else if( newval.i_int == INPUT_EVENT_ES_ADD ||
+ newval.i_int == INPUT_EVENT_ES_DELETE ||
+ newval.i_int == INPUT_EVENT_ES_SELECT)
+ {
+ switch( newval.i_int )
+ {
+ case INPUT_EVENT_ES_ADD:
+ event.type = libvlc_MediaPlayerESAdded;
+ break;
+ case INPUT_EVENT_ES_DELETE:
+ event.type = libvlc_MediaPlayerESDeleted;
+ break;
+ case INPUT_EVENT_ES_SELECT:
+ event.type = libvlc_MediaPlayerESSelected;
+ break;
+ }
+ int i_cat = var_GetInteger( p_input, "es-type" );
+ event.u.media_player_es_changed.i_type = get_libvlc_track_type( i_cat );
+ event.u.media_player_es_changed.i_id = var_GetInteger( p_input, "track-id" );
+ libvlc_event_send( p_mi->p_event_manager, &event );
+ }
return VLC_SUCCESS;
}
@@ -538,6 +574,9 @@ libvlc_media_player_new( libvlc_instance_t *instance )
register_event(mp, Vout);
register_event(mp, ScrambledChanged);
+ register_event(mp, ESAdded);
+ register_event(mp, ESDeleted);
+ register_event(mp, ESSelected);
/* Snapshot initialization */
register_event(mp, SnapshotTaken);
--
1.9.1
More information about the vlc-devel
mailing list