[vlc-devel] commit: libvlc : handle VLM input events ( Sébastien Escudier )

git version control git at videolan.org
Sat Jul 25 18:59:11 CEST 2009


vlc | branch: master | Sébastien Escudier <sebastien-devel at celeos.eu> | Tue Jul  7 14:12:40 2009 +0200| [b69b0bd6e6912b338bb991d97b92ea9acb29c656] | committer: Rémi Denis-Courmont 

libvlc : handle VLM input events

Signed-off-by: Rémi Denis-Courmont <remi at remlab.net>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b69b0bd6e6912b338bb991d97b92ea9acb29c656
---

 include/vlc/libvlc_events.h |    8 ++++-
 src/control/vlm.c           |   83 ++++++++++++++++++++++++++++++++++++-------
 2 files changed, 77 insertions(+), 14 deletions(-)

diff --git a/include/vlc/libvlc_events.h b/include/vlc/libvlc_events.h
index 9373896..f1fc40f 100644
--- a/include/vlc/libvlc_events.h
+++ b/include/vlc/libvlc_events.h
@@ -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;
 };
 
diff --git a/src/control/vlm.c b/src/control/vlm.c
index b0b9393..e8312d9 100644
--- a/src/control/vlm.c
+++ b/src/control/vlm.c
@@ -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;
     }




More information about the vlc-devel mailing list