From: Laurent Aimar Date: Sun, 8 Mar 2009 19:25:52 +0000 (+0100) Subject: Added basic VLM events. X-Git-Tag: 1.0.0-pre1~200 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=3d82199341fe58cf2a451a1f700d0404e31da557;p=vlc Added basic VLM events. You need to attach a callback on the variable 'intf-event' of the vlm object. Becarefull, as (always) inside an event callback you cannot call back the object (here vlm). --- diff --git a/include/vlc_vlm.h b/include/vlc_vlm.h index 4abe29aa27..4be26edb3e 100644 --- a/include/vlc_vlm.h +++ b/include/vlc_vlm.h @@ -87,6 +87,29 @@ typedef struct } vlm_schedule_t #endif +/** VLM events + * You can catch vlm event by adding a callback on the variable "intf-event" + * of the VLM object. + * This variable is an address that will hold a vlm_event_t* value. + */ +enum vlm_event_type_e +{ + /* */ + VLM_EVENT_MEDIA_ADDED = 0x100, + VLM_EVENT_MEDIA_REMOVED, + VLM_EVENT_MEDIA_CHANGED, + + /* */ + VLM_EVENT_MEDIA_INSTANCE_STARTED = 0x200, + VLM_EVENT_MEDIA_INSTANCE_STOPPED, +}; + +typedef struct +{ + int i_type; /* a vlm_event_type_e value */ + int64_t id; /* Media ID */ +} vlm_event_t; + /** VLM control query */ enum vlm_query_e { diff --git a/src/Makefile.am b/src/Makefile.am index fbbe92ceee..32206ec263 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -310,6 +310,7 @@ SOURCES_libvlc_common = \ input/input_internal.h \ input/input_interface.h \ input/vlm_internal.h \ + input/vlm_event.h \ input/resource.h \ input/resource.c \ input/stream.c \ @@ -403,6 +404,7 @@ SOURCES_libvlc_sout = \ SOURCES_libvlc_vlm = \ input/vlm.c \ + input/vlm_event.c \ input/vlmshell.c \ $(NULL) diff --git a/src/input/vlm.c b/src/input/vlm.c index 03cad445c6..d611eb86a6 100644 --- a/src/input/vlm.c +++ b/src/input/vlm.c @@ -52,9 +52,9 @@ #endif #include -#include "input_internal.h" #include #include "vlm_internal.h" +#include "vlm_event.h" #include #include #include @@ -110,6 +110,7 @@ vlm_t *__vlm_New ( vlc_object_t *p_this ) TAB_INIT( p_vlm->i_schedule, p_vlm->schedule ); p_vlm->i_vod = 0; p_vlm->p_vod = NULL; + var_Create( p_vlm, "intf-event", VLC_VAR_ADDRESS ); vlc_object_attach( p_vlm, p_this->p_libvlc ); if( vlc_clone( &p_vlm->thread, Manage, p_vlm, VLC_THREAD_PRIORITY_LOW ) ) @@ -574,6 +575,7 @@ static int vlm_OnMediaUpdate( vlm_t *p_vlm, vlm_media_sys_t *p_media ) /* TODO add support of var vlm_media_broadcast/vlm_media_vod */ + vlm_SendEventMediaChanged( p_vlm, p_cfg->id ); return VLC_SUCCESS; } static int vlm_ControlMediaChange( vlm_t *p_vlm, vlm_media_t *p_cfg ) @@ -648,6 +650,8 @@ static int vlm_ControlMediaAdd( vlm_t *p_vlm, vlm_media_t *p_cfg, int64_t *p_id if( p_id ) *p_id = p_media->cfg.id; + /* */ + vlm_SendEventMediaAdded( p_vlm, p_media->cfg.id ); return vlm_OnMediaUpdate( p_vlm, p_media ); } @@ -684,6 +688,9 @@ static int vlm_ControlMediaDel( vlm_t *p_vlm, int64_t id ) vlc_object_release( p_vlm->p_vod ); p_vlm->p_vod = NULL; } + + /* */ + vlm_SendEventMediaRemoved( p_vlm, id ); return VLC_SUCCESS; } @@ -763,7 +770,7 @@ static vlm_media_instance_sys_t *vlm_MediaInstanceNew( vlm_t *p_vlm, const char return p_instance; } -static void vlm_MediaInstanceDelete( vlm_media_instance_sys_t *p_instance ) +static void vlm_MediaInstanceDelete( vlm_t *p_vlm, int64_t id, vlm_media_instance_sys_t *p_instance ) { input_thread_t *p_input = p_instance->p_input; if( p_input ) @@ -777,6 +784,8 @@ static void vlm_MediaInstanceDelete( vlm_media_instance_sys_t *p_instance ) input_resource_Delete( p_resource ); vlc_object_release( p_input ); + + vlm_SendEventMediaInstanceStopped( p_vlm, id ); } if( p_instance->p_input_resource ) input_resource_Delete( p_instance->p_input_resource ); @@ -861,6 +870,8 @@ static int vlm_ControlMediaInstanceStart( vlm_t *p_vlm, int64_t id, const char * if( !p_instance->b_sout_keep ) input_resource_TerminateSout( p_instance->p_input_resource ); input_resource_TerminateVout( p_instance->p_input_resource ); + + vlm_SendEventMediaInstanceStopped( p_vlm, id ); } /* Start new one */ @@ -876,7 +887,11 @@ static int vlm_ControlMediaInstanceStart( vlm_t *p_vlm, int64_t id, const char * if( !p_instance->p_input ) { TAB_REMOVE( p_media->i_instance, p_media->instance, p_instance ); - vlm_MediaInstanceDelete( p_instance ); + vlm_MediaInstanceDelete( p_vlm, id, p_instance ); + } + else + { + vlm_SendEventMediaInstanceStarted( p_vlm, id ); } free( psz_log ); } @@ -898,7 +913,7 @@ static int vlm_ControlMediaInstanceStop( vlm_t *p_vlm, int64_t id, const char *p TAB_REMOVE( p_media->i_instance, p_media->instance, p_instance ); - vlm_MediaInstanceDelete( p_instance ); + vlm_MediaInstanceDelete( p_vlm, id, p_instance ); return VLC_SUCCESS; } diff --git a/src/input/vlm_internal.h b/src/input/vlm_internal.h index 67462f5268..a8c72fc714 100644 --- a/src/input/vlm_internal.h +++ b/src/input/vlm_internal.h @@ -29,6 +29,7 @@ #define _VLM_INTERNAL_H 1 #include +#include "input_internal.h" /* Private */ typedef struct