]> git.sesse.net Git - vlc/commitdiff
libvlc : handle VLM input events
authorSébastien Escudier <sebastien-devel@celeos.eu>
Tue, 7 Jul 2009 12:12:40 +0000 (14:12 +0200)
committerRémi Denis-Courmont <remi@remlab.net>
Sat, 25 Jul 2009 16:59:01 +0000 (19:59 +0300)
Signed-off-by: Rémi Denis-Courmont <remi@remlab.net>
include/vlc/libvlc_events.h
src/control/vlm.c

index 9373896861d48bad3a496ab5a51fe55655728e52..f1fc40fec3da329ca79fe8dcb0f7abf73643ca53 100644 (file)
@@ -99,6 +99,12 @@ enum libvlc_event_type_t {
     libvlc_VlmMediaChanged,
     libvlc_VlmMediaInstanceStarted,
     libvlc_VlmMediaInstanceStopped,
+    libvlc_VlmMediaInstanceStatusInit,
+    libvlc_VlmMediaInstanceStatusOpening,
+    libvlc_VlmMediaInstanceStatusPlaying,
+    libvlc_VlmMediaInstanceStatusPause,
+    libvlc_VlmMediaInstanceStatusEnd,
+    libvlc_VlmMediaInstanceStatusError,
     /* New event types HERE */
 };
 
@@ -223,8 +229,8 @@ struct libvlc_event_t
         struct
         {
             const char * psz_media_name;
+            const char * psz_instance_name;
         } vlm_media_event;
-
     } u;
 };
 
index b0b939352acf8086429b67f5f9d1125531ff2a92..e8312d9e7515516026e264b88bd81fafae072f0e 100644 (file)
@@ -117,6 +117,7 @@ static int VlmEvent( vlc_object_t *p_this, const char * name,
     VLC_UNUSED( name );
     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;
 
     switch( event->i_type )
@@ -136,6 +137,37 @@ static int VlmEvent( vlc_object_t *p_this, const char * name,
     case VLM_EVENT_MEDIA_INSTANCE_STOPPED:
         libvlc_event.type = libvlc_VlmMediaInstanceStopped;
         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 );
     return 0;
@@ -164,18 +196,42 @@ static int libvlc_vlm_init( libvlc_instance_t *p_instance,
 {
     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, p_exception );
-        libvlc_event_manager_register_event_type( p_instance->libvlc_vlm.p_event_manager,
-                                                  libvlc_VlmMediaAdded, NULL );
-        libvlc_event_manager_register_event_type( p_instance->libvlc_vlm.p_event_manager,
-                                                  libvlc_VlmMediaRemoved, NULL );
-        libvlc_event_manager_register_event_type( p_instance->libvlc_vlm.p_event_manager,
-                                                  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 );
+        p_instance->libvlc_vlm.p_event_manager =
+            libvlc_event_manager_new( p_instance->libvlc_vlm.p_vlm,
+                                      p_instance, p_exception );
+        libvlc_event_manager_register_event_type(
+            p_instance->libvlc_vlm.p_event_manager,
+            libvlc_VlmMediaAdded, NULL );
+        libvlc_event_manager_register_event_type(
+            p_instance->libvlc_vlm.p_event_manager,
+            libvlc_VlmMediaRemoved, NULL );
+        libvlc_event_manager_register_event_type(
+            p_instance->libvlc_vlm.p_event_manager,
+            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 )
@@ -187,7 +243,8 @@ static int libvlc_vlm_init( libvlc_instance_t *p_instance,
                                     "Unable to create VLM." );
             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.pf_release = libvlc_vlm_release_internal;
     }