00001 /***************************************************************************** 00002 * libvlc_internal.h : Definition of opaque structures for libvlc exported API 00003 * Also contains some internal utility functions 00004 ***************************************************************************** 00005 * Copyright (C) 2005-2009 the VideoLAN team 00006 * $Id: b7df2cbfbfda673df8ab71c88a71080412d82c4a $ 00007 * 00008 * Authors: Clément Stenac <zorglub@videolan.org> 00009 * 00010 * This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. 00014 * 00015 * This program is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 * GNU General Public License for more details. 00019 * 00020 * You should have received a copy of the GNU General Public License 00021 * along with this program; if not, write to the Free Software 00022 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. 00023 *****************************************************************************/ 00024 00025 #ifndef _LIBVLC_EVENT_H 00026 #define _LIBVLC_EVENT_H 1 00027 00028 #ifdef HAVE_CONFIG_H 00029 # include "config.h" 00030 #endif 00031 00032 #include <vlc/libvlc_structures.h> 00033 #include <vlc/libvlc.h> 00034 #include <vlc/libvlc_events.h> 00035 00036 #include <vlc_common.h> 00037 00038 00039 /* 00040 * Event Handling 00041 */ 00042 00043 /* Example usage 00044 * 00045 * struct libvlc_cool_object_t 00046 * { 00047 * ... 00048 * libvlc_event_manager_t * p_event_manager; 00049 * ... 00050 * } 00051 * 00052 * libvlc_my_cool_object_new() 00053 * { 00054 * ... 00055 * p_self->p_event_manager = libvlc_event_manager_new( p_self, 00056 * p_self->p_libvlc_instance, p_e); 00057 * libvlc_event_manager_register_event_type(p_self->p_event_manager, 00058 * libvlc_MyCoolObjectDidSomething, p_e) 00059 * ... 00060 * } 00061 * 00062 * libvlc_my_cool_object_release() 00063 * { 00064 * ... 00065 * libvlc_event_manager_release( p_self->p_event_manager ); 00066 * ... 00067 * } 00068 * 00069 * libvlc_my_cool_object_do_something() 00070 * { 00071 * ... 00072 * libvlc_event_t event; 00073 * event.type = libvlc_MyCoolObjectDidSomething; 00074 * event.u.my_cool_object_did_something.what_it_did = kSomething; 00075 * libvlc_event_send( p_self->p_event_manager, &event ); 00076 * } 00077 * */ 00078 00079 typedef struct libvlc_event_listener_t 00080 { 00081 libvlc_event_type_t event_type; 00082 void * p_user_data; 00083 libvlc_callback_t pf_callback; 00084 bool is_asynchronous; 00085 } libvlc_event_listener_t; 00086 00087 typedef struct libvlc_event_manager_t 00088 { 00089 void * p_obj; 00090 struct libvlc_instance_t * p_libvlc_instance; 00091 vlc_array_t listeners_groups; 00092 vlc_mutex_t object_lock; 00093 vlc_mutex_t event_sending_lock; 00094 struct libvlc_event_async_queue * async_event_queue; 00095 } libvlc_event_sender_t; 00096 00097 00098 static inline bool 00099 listeners_are_equal( libvlc_event_listener_t * listener1, 00100 libvlc_event_listener_t * listener2 ) 00101 { 00102 return listener1->event_type == listener2->event_type && 00103 listener1->pf_callback == listener2->pf_callback && 00104 listener1->p_user_data == listener2->p_user_data && 00105 listener1->is_asynchronous == listener2->is_asynchronous; 00106 } 00107 00108 /* event_async.c */ 00109 void libvlc_event_async_fini(libvlc_event_manager_t * p_em); 00110 void libvlc_event_async_dispatch(libvlc_event_manager_t * p_em, libvlc_event_listener_t * listener, libvlc_event_t * event); 00111 void libvlc_event_async_ensure_listener_removal(libvlc_event_manager_t * p_em, libvlc_event_listener_t * listener); 00112 00113 #endif
1.7.1