[vlc-devel] commit: libvlc_MediaPlayerSnapshotTaken Event creation (basos )
git version control
git at videolan.org
Thu Dec 11 19:29:15 CET 2008
vlc | branch: master | basos <noxelia 4t gmail c0m> | Thu Oct 30 11:45:56 2008 +0200| [c2122ce3b13cc090590ed83159dd40f7f8fca17c] | committer: Rémi Denis-Courmont
libvlc_MediaPlayerSnapshotTaken Event creation
It is emmited whenever a snapshot is taken by any means
(gui, libvlc, button ) and also passes the full path of
the new image as event data. Rev 1
Signed-off-by: Rémi Denis-Courmont <rdenis at simphalempin.com>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c2122ce3b13cc090590ed83159dd40f7f8fca17c
---
include/vlc/libvlc_events.h | 9 ++++++++-
src/control/event.c | 4 +++-
src/control/media_player.c | 38 ++++++++++++++++++++++++++++++++++++++
src/video_output/vout_intf.c | 8 ++++++++
4 files changed, 57 insertions(+), 2 deletions(-)
diff --git a/include/vlc/libvlc_events.h b/include/vlc/libvlc_events.h
index f72ee6c..f18728e 100644
--- a/include/vlc/libvlc_events.h
+++ b/include/vlc/libvlc_events.h
@@ -84,7 +84,8 @@ typedef enum libvlc_event_type_t {
libvlc_MediaDiscovererStarted,
libvlc_MediaDiscovererEnded,
- libvlc_MediaPlayerTitleChanged
+ libvlc_MediaPlayerTitleChanged,
+ libvlc_MediaPlayerSnapshotTaken
} libvlc_event_type_t;
@@ -203,6 +204,12 @@ typedef struct libvlc_event_t
void * unused;
} media_media_discoverer_ended;
+ /* snapshot taken */
+ struct
+ {
+ char* psz_filename ;
+ } media_player_snapshot_taken ;
+
} u;
} libvlc_event_t;
diff --git a/src/control/event.c b/src/control/event.c
index e96db8f..d7f0b41 100644
--- a/src/control/event.c
+++ b/src/control/event.c
@@ -269,7 +269,9 @@ static const char event_type_to_name[][35] =
EVENT(libvlc_MediaListPlayerStopped),
EVENT(libvlc_MediaDiscovererStarted),
- EVENT(libvlc_MediaDiscovererEnded)
+ EVENT(libvlc_MediaDiscovererEnded),
+
+ EVENT(libvlc_MediaPlayerSnapshotTaken),
#undef EVENT
};
diff --git a/src/control/media_player.c b/src/control/media_player.c
index 0845d7e..733f2b3 100644
--- a/src/control/media_player.c
+++ b/src/control/media_player.c
@@ -45,6 +45,9 @@ input_event_changed( vlc_object_t * p_this, char const * psz_cmd,
vlc_value_t oldval, vlc_value_t newval,
void * p_userdata );
+static int SnapshotTakenCallback( vlc_object_t *p_this, char const *psz_cmd,
+ vlc_value_t oldval, vlc_value_t newval, void *p_data );
+
static const libvlc_state_t vlc_to_libvlc_state_array[] =
{
[INIT_S] = libvlc_NothingSpecial,
@@ -320,6 +323,16 @@ libvlc_media_player_new( libvlc_instance_t * p_libvlc_instance,
libvlc_event_manager_register_event_type( p_mi->p_event_manager,
libvlc_MediaPlayerPausableChanged, p_e );
+ /* Snapshot initialization */
+ libvlc_event_manager_register_event_type( p_mi->p_event_manager,
+ libvlc_MediaPlayerSnapshotTaken, p_e );
+ /* Attach a var callback to the global object to provide the glue between
+ vout_thread that generates the event and media_player that re-emits it
+ with its own event manager
+ */
+ var_Create( p_libvlc_instance->p_libvlc_int, "vout-snapshottaken", VLC_VAR_STRING | VLC_VAR_ISCOMMAND );
+ var_AddCallback( p_libvlc_instance->p_libvlc_int, "vout-snapshottaken", SnapshotTakenCallback, p_mi );
+
return p_mi;
}
@@ -398,6 +411,9 @@ void libvlc_media_player_destroy( libvlc_media_player_t *p_mi )
if( !p_mi )
return;
+ /* Detach Callback from the main libvlc object */
+ var_DelCallback( p_mi->p_libvlc_instance->p_libvlc_int, "vout-snapshottaken", SnapshotTakenCallback, p_mi );
+
p_input_thread = libvlc_get_input_thread( p_mi, &p_e );
if( libvlc_exception_raised( &p_e ) )
@@ -526,6 +542,28 @@ libvlc_media_player_event_manager(
}
/**************************************************************************
+ * Trigger a snapshot Taken Event
+ *************************************************************************/
+static int SnapshotTakenCallback( vlc_object_t *p_this, char const *psz_cmd,
+ vlc_value_t oldval, vlc_value_t newval, void *p_data )
+{
+ VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval);
+ VLC_UNUSED(p_this) ;
+
+ libvlc_media_player_t* p_mi = (libvlc_media_player_t*) p_data ;
+ libvlc_event_t event ;
+ event.type = libvlc_MediaPlayerSnapshotTaken ;
+ event.u.media_player_snapshot_taken.psz_filename = newval.psz_string ;
+ /* Snapshot psz data is a vlc_variable owned by libvlc object .
+ Its memmory management is taken care by the obj*/
+ msg_Dbg( p_this, "about to emit libvlc_snapshot_taken.make psz_str=0x%x (%s)",
+ event.u.media_player_snapshot_taken.psz_filename ,event.u.media_player_snapshot_taken.psz_filename );
+ libvlc_event_send( p_mi->p_event_manager, &event );
+
+ return VLC_SUCCESS;
+}
+
+/**************************************************************************
* Play
**************************************************************************/
void libvlc_media_player_play( libvlc_media_player_t *p_mi,
diff --git a/src/video_output/vout_intf.c b/src/video_output/vout_intf.c
index 7716cf1..ccba33e 100644
--- a/src/video_output/vout_intf.c
+++ b/src/video_output/vout_intf.c
@@ -793,6 +793,14 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic )
msg_Dbg( p_vout, "snapshot taken (%s)", psz_filename );
vout_OSDMessage( VLC_OBJECT( p_vout ), DEFAULT_CHAN,
"%s", psz_filename );
+
+ /* Generate a media player event - Right now just trigger a global libvlc var
+ CHECK: Could not find a more local object. The goal is to communicate
+ vout_thread with libvlc_media_player or its input_thread*/
+ val.psz_string = psz_filename ;
+
+ var_Set( p_vout->p_libvlc, "vout-snapshottaken", val );
+ /* var_Set duplicates data for transport so we can free*/
free( psz_filename );
/* */
More information about the vlc-devel
mailing list