LGPL
[vlc.git] / include / vlc_events.h
index e117b2b..842e204 100644 (file)
@@ -2,30 +2,31 @@
  * events.h: events definitions
  * Interface used to send events.
  *****************************************************************************
- * Copyright (C) 2007 the VideoLAN team
+ * Copyright (C) 2007 VLC authors and VideoLAN
  * $Id$
  *
  * Authors: Pierre d'Herbemont
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 #ifndef VLC_EVENTS_H
 # define VLC_EVENTS_H
 
 #include <vlc_arrays.h>
+#include <vlc_meta.h>
 
 /**
  * \file
@@ -41,7 +42,7 @@
  *
  * This implements a way to send and receive event for an object (which can be
  * a simple C struct or less).
- * 
+ *
  * This is in direct concurrency with the Variable based Callback
  * (see src/misc/variables.c).
  *
@@ -58,7 +59,7 @@
  *
  * (vlc_cool_object_t doesn't need to have the VLC_COMMON_MEMBERS.)
  *
- * struct vlc_cool_object_t 
+ * struct vlc_cool_object_t
  * {
  *        ...
  *        vlc_event_manager_t p_event_manager;
@@ -68,7 +69,7 @@
  * vlc_my_cool_object_new()
  * {
  *        ...
- *        vlc_event_manager_Create( &p_self->p_event_manager, p_this );
+ *        vlc_event_manager_init( &p_self->p_event_manager, p_self, p_a_libvlc_object );
  *        vlc_event_manager_register_event_type(p_self->p_event_manager,
  *                vlc_MyCoolObjectDidSomething, p_e)
  *        ...
@@ -77,7 +78,7 @@
  * vlc_my_cool_object_release()
  * {
  *         ...
- *         vlc_event_manager_release( p_self->p_event_manager );
+ *         vlc_event_manager_fini( &p_self->p_event_manager );
  *         ...
  * }
  *
  *        vlc_event_t event;
  *        event.type = vlc_MyCoolObjectDidSomething;
  *        event.u.my_cool_object_did_something.what_it_did = kSomething;
- *        vlc_event_send( p_self->p_event_manager, &event );
+ *        vlc_event_send( &p_self->p_event_manager, &event );
  * }
  * */
+
   /*****************************************************************************
  * Event Type
  *****************************************************************************/
@@ -102,25 +103,104 @@ struct vlc_event_listeners_group_t;
 typedef struct vlc_event_manager_t
 {
     void * p_obj;
+    vlc_mutex_t object_lock;
+    vlc_mutex_t event_sending_lock;
     DECL_ARRAY(struct vlc_event_listeners_group_t *) listeners_groups;
 } vlc_event_manager_t;
 
 /* List of event */
 typedef enum vlc_event_type_t {
-    vlc_InputItemMetaChanged
+    /* Input (thread) events */
+    vlc_InputStateChanged,
+    vlc_InputSelectedStreamChanged,
+
+    /* Input item events */
+    vlc_InputItemMetaChanged,
+    vlc_InputItemSubItemAdded,
+    vlc_InputItemSubItemTreeAdded,
+    vlc_InputItemDurationChanged,
+    vlc_InputItemPreparsedChanged,
+    vlc_InputItemNameChanged,
+    vlc_InputItemInfoChanged,
+    vlc_InputItemErrorWhenReadingChanged,
+
+    /* Service Discovery event */
+    vlc_ServicesDiscoveryItemAdded,
+    vlc_ServicesDiscoveryItemRemoved,
+    vlc_ServicesDiscoveryStarted,
+    vlc_ServicesDiscoveryEnded
 } vlc_event_type_t;
 
 /* Event definition */
 typedef struct vlc_event_t
 {
     vlc_event_type_t type;
-    void * p_obj; /* Sender object, automatically filled by event_Send() */
-    union event_type_specific
+    void * p_obj; /* Sender object, automatically filled by vlc_event_send() */
+    union vlc_event_type_specific
     {
-        struct
+        /* Input (thread) events */
+        struct vlc_input_state_changed
+        {
+            int new_state;
+        } input_state_changed;
+        struct vlc_input_selected_stream_changed
+        {
+            void * unused;
+        } input_selected_stream_changed;
+
+        /* Input item events */
+        struct vlc_input_item_meta_changed
         {
-            int meta; /* One of the meta identified in include/vlc_meta.h */
+            vlc_meta_type_t meta_type;
         } input_item_meta_changed;
+        struct vlc_input_item_subitem_added
+        {
+            input_item_t * p_new_child;
+        } input_item_subitem_added;
+        struct vlc_input_item_subitem_tree_added
+        {
+            input_item_node_t * p_root;
+        } input_item_subitem_tree_added;
+        struct vlc_input_item_duration_changed
+        {
+            mtime_t new_duration;
+        } input_item_duration_changed;
+        struct vlc_input_item_preparsed_changed
+        {
+            int new_status;
+        } input_item_preparsed_changed;
+        struct vlc_input_item_name_changed
+        {
+            const char * new_name;
+        } input_item_name_changed;
+        struct vlc_input_item_info_changed
+        {
+            void * unused;
+        } input_item_info_changed;
+        struct input_item_error_when_reading_changed
+        {
+            bool new_value;
+        } input_item_error_when_reading_changed;
+
+        /* Service discovery events */
+        struct vlc_services_discovery_item_added
+        {
+            input_item_t * p_new_item;
+            const char * psz_category;
+        } services_discovery_item_added;
+        struct vlc_services_discovery_item_removed
+        {
+            input_item_t * p_item;
+        } services_discovery_item_removed;
+        struct vlc_services_discovery_started
+        {
+            void * unused;
+        } services_discovery_started;
+        struct vlc_services_discovery_ended
+        {
+            void * unused;
+        } services_discovery_ended;
+
     } u;
 } vlc_event_t;
 
@@ -135,38 +215,38 @@ typedef void ( *vlc_event_callback_t )( const vlc_event_t *, void * );
  * p_obj points to the object that owns the event manager, and from
  * which events are sent
  */
-int event_manager_Create( vlc_event_manager_t * p_em, void * p_obj );
+VLC_API int vlc_event_manager_init( vlc_event_manager_t * p_em, void * p_obj );
 
 /*
  * Destroy
  */
-void event_manager_Destroy( vlc_event_manager_t * p_em );
+VLC_API void vlc_event_manager_fini( vlc_event_manager_t * p_em );
 
 /*
  * Tells a specific event manager that it will handle event_type object
  */
-int event_manager_RegisterEventType( vlc_event_manager_t * p_em,
-                                     vlc_event_type_t event_type );
+VLC_API int vlc_event_manager_register_event_type( vlc_event_manager_t * p_em,
+                                                   vlc_event_type_t );
 
 /*
  * Send an event to the listener attached to this p_em.
  */
-void event_Send( vlc_event_manager_t * p_em, vlc_event_t * p_event );
+VLC_API void vlc_event_send( vlc_event_manager_t * p_em, vlc_event_t * );
 
 /*
  * Add a callback for an event.
  */
-int event_Attach( vlc_event_manager_t * p_event_manager,
-                  vlc_event_type_t event_type,
-                  vlc_event_callback_t pf_callback,
-                  void *p_user_data );
+VLC_API int vlc_event_attach( vlc_event_manager_t * p_event_manager,
+                              vlc_event_type_t event_type,
+                              vlc_event_callback_t pf_callback,
+                              void *p_user_data );
 
 /*
  * Remove a callback for an event.
  */
-int event_Detach( vlc_event_manager_t *p_event_manager,
-                   vlc_event_type_t event_type,
-                   vlc_event_callback_t pf_callback,
-                   void *p_user_data );
+VLC_API void vlc_event_detach( vlc_event_manager_t *p_event_manager,
+                               vlc_event_type_t event_type,
+                               vlc_event_callback_t pf_callback,
+                               void *p_user_data );
 
 #endif /* VLC_EVENTS_H */