Commit b69b0bd6 authored by Sébastien Escudier's avatar Sébastien Escudier Committed by Rémi Denis-Courmont

libvlc : handle VLM input events

Signed-off-by: default avatarRémi Denis-Courmont <remi@remlab.net>
parent 24c2dc91
...@@ -99,6 +99,12 @@ enum libvlc_event_type_t { ...@@ -99,6 +99,12 @@ enum libvlc_event_type_t {
libvlc_VlmMediaChanged, libvlc_VlmMediaChanged,
libvlc_VlmMediaInstanceStarted, libvlc_VlmMediaInstanceStarted,
libvlc_VlmMediaInstanceStopped, libvlc_VlmMediaInstanceStopped,
libvlc_VlmMediaInstanceStatusInit,
libvlc_VlmMediaInstanceStatusOpening,
libvlc_VlmMediaInstanceStatusPlaying,
libvlc_VlmMediaInstanceStatusPause,
libvlc_VlmMediaInstanceStatusEnd,
libvlc_VlmMediaInstanceStatusError,
/* New event types HERE */ /* New event types HERE */
}; };
...@@ -223,8 +229,8 @@ struct libvlc_event_t ...@@ -223,8 +229,8 @@ struct libvlc_event_t
struct struct
{ {
const char * psz_media_name; const char * psz_media_name;
const char * psz_instance_name;
} vlm_media_event; } vlm_media_event;
} u; } u;
}; };
......
...@@ -117,6 +117,7 @@ static int VlmEvent( vlc_object_t *p_this, const char * name, ...@@ -117,6 +117,7 @@ static int VlmEvent( vlc_object_t *p_this, const char * name,
VLC_UNUSED( name ); VLC_UNUSED( name );
VLC_UNUSED( old_val ); VLC_UNUSED( old_val );
libvlc_event.u.vlm_media_event.psz_instance_name = NULL;
libvlc_event.u.vlm_media_event.psz_media_name = event->psz_name; libvlc_event.u.vlm_media_event.psz_media_name = event->psz_name;
switch( event->i_type ) switch( event->i_type )
...@@ -136,6 +137,37 @@ static int VlmEvent( vlc_object_t *p_this, const char * name, ...@@ -136,6 +137,37 @@ static int VlmEvent( vlc_object_t *p_this, const char * name,
case VLM_EVENT_MEDIA_INSTANCE_STOPPED: case VLM_EVENT_MEDIA_INSTANCE_STOPPED:
libvlc_event.type = libvlc_VlmMediaInstanceStopped; libvlc_event.type = libvlc_VlmMediaInstanceStopped;
break; break;
case VLM_EVENT_MEDIA_INSTANCE_STATE:
libvlc_event.u.vlm_media_event.psz_instance_name =
event->psz_instance_name;
switch( event->input_state )
{
case INIT_S:
libvlc_event.type = libvlc_VlmMediaInstanceStatusInit;
break;
case OPENING_S:
libvlc_event.type =
libvlc_VlmMediaInstanceStatusOpening;
break;
case PLAYING_S:
libvlc_event.type =
libvlc_VlmMediaInstanceStatusPlaying;
break;
case PAUSE_S:
libvlc_event.type = libvlc_VlmMediaInstanceStatusPause;
break;
case END_S:
libvlc_event.type = libvlc_VlmMediaInstanceStatusEnd;
break;
case ERROR_S:
libvlc_event.type = libvlc_VlmMediaInstanceStatusError;
break;
default:
return 0;
}
break;
default:
return 0;
} }
libvlc_event_send( p_event_manager, &libvlc_event ); libvlc_event_send( p_event_manager, &libvlc_event );
return 0; return 0;
...@@ -164,18 +196,42 @@ static int libvlc_vlm_init( libvlc_instance_t *p_instance, ...@@ -164,18 +196,42 @@ static int libvlc_vlm_init( libvlc_instance_t *p_instance,
{ {
if( !p_instance->libvlc_vlm.p_event_manager ) if( !p_instance->libvlc_vlm.p_event_manager )
{ {
p_instance->libvlc_vlm.p_event_manager = libvlc_event_manager_new( p_instance->libvlc_vlm.p_vlm, p_instance->libvlc_vlm.p_event_manager =
p_instance, p_exception ); libvlc_event_manager_new( p_instance->libvlc_vlm.p_vlm,
libvlc_event_manager_register_event_type( p_instance->libvlc_vlm.p_event_manager, p_instance, p_exception );
libvlc_VlmMediaAdded, NULL ); libvlc_event_manager_register_event_type(
libvlc_event_manager_register_event_type( p_instance->libvlc_vlm.p_event_manager, p_instance->libvlc_vlm.p_event_manager,
libvlc_VlmMediaRemoved, NULL ); libvlc_VlmMediaAdded, NULL );
libvlc_event_manager_register_event_type( p_instance->libvlc_vlm.p_event_manager, libvlc_event_manager_register_event_type(
libvlc_VlmMediaChanged, NULL ); p_instance->libvlc_vlm.p_event_manager,
libvlc_event_manager_register_event_type( p_instance->libvlc_vlm.p_event_manager, libvlc_VlmMediaRemoved, NULL );
libvlc_VlmMediaInstanceStarted, NULL ); libvlc_event_manager_register_event_type(
libvlc_event_manager_register_event_type( p_instance->libvlc_vlm.p_event_manager, p_instance->libvlc_vlm.p_event_manager,
libvlc_VlmMediaInstanceStopped, NULL ); libvlc_VlmMediaChanged, NULL );
libvlc_event_manager_register_event_type(
p_instance->libvlc_vlm.p_event_manager,
libvlc_VlmMediaInstanceStarted, NULL );
libvlc_event_manager_register_event_type(
p_instance->libvlc_vlm.p_event_manager,
libvlc_VlmMediaInstanceStopped, NULL );
libvlc_event_manager_register_event_type(
p_instance->libvlc_vlm.p_event_manager,
libvlc_VlmMediaInstanceStatusInit, NULL );
libvlc_event_manager_register_event_type(
p_instance->libvlc_vlm.p_event_manager,
libvlc_VlmMediaInstanceStatusOpening, NULL );
libvlc_event_manager_register_event_type(
p_instance->libvlc_vlm.p_event_manager,
libvlc_VlmMediaInstanceStatusPlaying, NULL );
libvlc_event_manager_register_event_type(
p_instance->libvlc_vlm.p_event_manager,
libvlc_VlmMediaInstanceStatusPause, NULL );
libvlc_event_manager_register_event_type(
p_instance->libvlc_vlm.p_event_manager,
libvlc_VlmMediaInstanceStatusEnd, NULL );
libvlc_event_manager_register_event_type(
p_instance->libvlc_vlm.p_event_manager,
libvlc_VlmMediaInstanceStatusError, NULL );
} }
if( !p_instance->libvlc_vlm.p_vlm ) if( !p_instance->libvlc_vlm.p_vlm )
...@@ -187,7 +243,8 @@ static int libvlc_vlm_init( libvlc_instance_t *p_instance, ...@@ -187,7 +243,8 @@ static int libvlc_vlm_init( libvlc_instance_t *p_instance,
"Unable to create VLM." ); "Unable to create VLM." );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
var_AddCallback( (vlc_object_t *)p_instance->libvlc_vlm.p_vlm, "intf-event", VlmEvent, var_AddCallback( (vlc_object_t *)p_instance->libvlc_vlm.p_vlm,
"intf-event", VlmEvent,
p_instance->libvlc_vlm.p_event_manager ); p_instance->libvlc_vlm.p_event_manager );
p_instance->libvlc_vlm.pf_release = libvlc_vlm_release_internal; p_instance->libvlc_vlm.pf_release = libvlc_vlm_release_internal;
} }
......
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