Commit c2122ce3 authored by basos's avatar basos Committed by 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: default avatarRémi Denis-Courmont <rdenis@simphalempin.com>
parent 44b8cd07
......@@ -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;
......
......@@ -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
};
......
......@@ -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 ) )
......@@ -525,6 +541,28 @@ libvlc_media_player_event_manager(
return p_mi->p_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
**************************************************************************/
......
......@@ -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 );
/* */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment