/** * This function will handle a snapshot request and provide the image pointer */ static void VoutSnapshotAddr( vout_thread_t *p_vout ) { char *psz_format = var_GetNonEmptyString( p_vout, "snapshot-format" ); char *psz_prefix = var_GetNonEmptyString( p_vout, "snapshot-prefix" ); /* */ picture_t *p_picture; block_t *p_image; video_format_t fmt; /* 500ms timeout * XXX it will cause trouble with low fps video (< 2fps) */ if( vout_GetSnapshot( p_vout, &p_image, &p_picture, &fmt, psz_format, 500*1000 ) ) { p_picture = NULL; p_image = NULL; goto exit; } msg_Dbg( p_vout, "p_image addr: %i", p_image ); var_Create( p_vout, "snapshot-addr", VLC_VAR_ADDRESS ); var_SetAddress( p_vout, "snapshot-addr", (void *) p_image ); exit: if( p_picture ) picture_Release( p_picture ); free( psz_prefix ); free( psz_format ); }
/** * This function will handle a snapshot request */ static void VoutSaveSnapshot( vout_thread_t *p_vout ) { char *psz_path = var_GetNonEmptyString( p_vout, "snapshot-path" ); char *psz_format = var_GetNonEmptyString( p_vout, "snapshot-format" ); char *psz_prefix = var_GetNonEmptyString( p_vout, "snapshot-prefix" ); /* */ picture_t *p_picture; block_t *p_image; video_format_t fmt; /* 500ms timeout * XXX it will cause trouble with low fps video (< 2fps) */ if( vout_GetSnapshot( p_vout, &p_image, &p_picture, &fmt, psz_format, 500*1000 ) ) { p_picture = NULL; p_image = NULL; goto exit; } if( !psz_path ) { psz_path = VoutSnapshotGetDefaultDirectory(); if( !psz_path ) { msg_Err( p_vout, "no path specified for snapshots" ); goto exit; } } char *psz_filename; if( VoutWriteSnapshot( p_vout, &psz_filename, p_image, psz_path, psz_format, psz_prefix ) ) goto exit; VoutOsdSnapshot( p_vout, p_picture, 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 */ var_SetString( p_vout->p_libvlc, "vout-snapshottaken", psz_filename ); free( psz_filename ); exit: if( p_image ) block_Release( p_image ); if( p_picture ) picture_Release( p_picture ); free( psz_prefix ); free( psz_format ); free( psz_path ); }
mediacontrol_RGBPicture * mediacontrol_snapshot( mediacontrol_Instance *self, const mediacontrol_Position * a_position, mediacontrol_Exception *exception ) { (void)a_position; vout_thread_t* p_vout; input_thread_t *p_input; mediacontrol_RGBPicture *p_pic; libvlc_exception_t ex; libvlc_exception_init( &ex ); mediacontrol_exception_init( exception ); p_input = libvlc_get_input_thread( self->p_media_player ); if( ! p_input ) { RAISE_NULL( mediacontrol_InternalException, "No input" ); } p_vout = input_GetVout( p_input ); vlc_object_release( p_input ); if( ! p_vout ) { RAISE_NULL( mediacontrol_InternalException, "No video output" ); } block_t *p_image; video_format_t fmt; if( vout_GetSnapshot( p_vout, &p_image, NULL, &fmt, "png", 500*1000 ) ) { vlc_object_release( p_vout ); RAISE_NULL( mediacontrol_InternalException, "Snapshot exception" ); return NULL; } /* */ char *p_data = malloc( p_image->i_buffer ); if( p_data ) { memcpy( p_data, p_image->p_buffer, p_image->i_buffer ); p_pic = private_mediacontrol_createRGBPicture( fmt.i_width, fmt.i_height, fmt.i_chroma, p_image->i_pts, p_data, p_image->i_buffer ); } else { p_pic = NULL; } block_Release( p_image ); if( !p_pic ) RAISE_NULL( mediacontrol_InternalException, "Out of memory" ); vlc_object_release( p_vout ); return p_pic; }
/** * This function will handle a snapshot request */ static void VoutSaveSnapshot( vout_thread_t *p_vout ) { char *psz_path = var_InheritString( p_vout, "snapshot-path" ); char *psz_format = var_InheritString( p_vout, "snapshot-format" ); char *psz_prefix = var_InheritString( p_vout, "snapshot-prefix" ); /* */ picture_t *p_picture; block_t *p_image; video_format_t fmt; /* 500ms timeout * XXX it will cause trouble with low fps video (< 2fps) */ if( vout_GetSnapshot( p_vout, &p_image, &p_picture, &fmt, psz_format, 500*1000 ) ) { p_picture = NULL; p_image = NULL; goto exit; } if( !psz_path ) { psz_path = vout_snapshot_GetDirectory(); if( !psz_path ) { msg_Err( p_vout, "no path specified for snapshots" ); goto exit; } } vout_snapshot_save_cfg_t cfg; memset( &cfg, 0, sizeof(cfg) ); cfg.is_sequential = var_InheritBool( p_vout, "snapshot-sequential" ); cfg.sequence = var_GetInteger( p_vout, "snapshot-num" ); cfg.path = psz_path; cfg.format = psz_format; cfg.prefix_fmt = psz_prefix; char *psz_filename; int i_sequence; if (vout_snapshot_SaveImage( &psz_filename, &i_sequence, p_image, VLC_OBJECT(p_vout), &cfg ) ) goto exit; if( cfg.is_sequential ) var_SetInteger( p_vout, "snapshot-num", i_sequence + 1 ); VoutOsdSnapshot( p_vout, p_picture, psz_filename ); /* signal creation of a new snapshot file */ var_SetString( p_vout->p_libvlc, "snapshot-file", psz_filename ); free( psz_filename ); exit: if( p_image ) block_Release( p_image ); if( p_picture ) picture_Release( p_picture ); free( psz_prefix ); free( psz_format ); free( psz_path ); }