📄 media.c
字号:
libvlc_exception_raise( p_e, "Can't create md's input_item" ); return NULL; } p_md = libvlc_media_new_from_input_item( p_instance, p_input_item, p_e ); /* The p_input_item is retained in libvlc_media_new_from_input_item */ vlc_gc_decref( p_input_item ); return p_md;}/************************************************************************** * Create a new media descriptor object **************************************************************************/libvlc_media_t * libvlc_media_new_as_node( libvlc_instance_t *p_instance, const char * psz_name, libvlc_exception_t *p_e ){ input_item_t * p_input_item; libvlc_media_t * p_md; p_input_item = input_item_New( p_instance->p_libvlc_int, "vlc://nop", psz_name ); if (!p_input_item) { libvlc_exception_raise( p_e, "Can't create md's input_item" ); return NULL; } p_md = libvlc_media_new_from_input_item( p_instance, p_input_item, p_e ); p_md->p_subitems = libvlc_media_list_new( p_md->p_libvlc_instance, NULL ); return p_md;}/************************************************************************** * Add an option to the media descriptor, * that will be used to determine how the media_player will read the * media. This allow to use VLC advanced reading/streaming * options in a per-media basis * * The options are detailled in vlc --long-help, for instance "--sout-all" **************************************************************************/void libvlc_media_add_option( libvlc_media_t * p_md, const char * ppsz_option, libvlc_exception_t *p_e ){ VLC_UNUSED(p_e); input_item_AddOpt( p_md->p_input_item, ppsz_option, VLC_INPUT_OPTION_UNIQUE|VLC_INPUT_OPTION_TRUSTED );}/************************************************************************** * Delete a media descriptor object **************************************************************************/void libvlc_media_release( libvlc_media_t *p_md ){ if (!p_md) return; p_md->i_refcount--; if( p_md->i_refcount > 0 ) return; if( p_md->p_subitems ) libvlc_media_list_release( p_md->p_subitems ); uninstall_input_item_observer( p_md ); vlc_gc_decref( p_md->p_input_item ); /* Construct the event */ libvlc_event_t event; event.type = libvlc_MediaFreed; event.u.media_freed.md = p_md; /* Send the event */ libvlc_event_send( p_md->p_event_manager, &event ); libvlc_event_manager_release( p_md->p_event_manager ); free( p_md );}/************************************************************************** * Retain a media descriptor object **************************************************************************/void libvlc_media_retain( libvlc_media_t *p_md ){ if (!p_md) return; p_md->i_refcount++;}/************************************************************************** * Duplicate a media descriptor object **************************************************************************/libvlc_media_t *libvlc_media_duplicate( libvlc_media_t *p_md_orig ){ return libvlc_media_new_from_input_item( p_md_orig->p_libvlc_instance, p_md_orig->p_input_item, NULL );}/************************************************************************** * Get mrl from a media descriptor object **************************************************************************/char *libvlc_media_get_mrl( libvlc_media_t * p_md, libvlc_exception_t * p_e ){ VLC_UNUSED(p_e); return input_item_GetURI( p_md->p_input_item );}/************************************************************************** * Getter for meta information **************************************************************************/char * libvlc_media_get_meta( libvlc_media_t *p_md, libvlc_meta_t e_meta, libvlc_exception_t *p_e ){ char * psz_meta; VLC_UNUSED(p_e); /* XXX: locking */ preparse_if_needed( p_md ); psz_meta = input_item_GetMeta( p_md->p_input_item, libvlc_to_vlc_meta[e_meta] ); if( e_meta == libvlc_meta_ArtworkURL && !psz_meta ) { playlist_AskForArtEnqueue( libvlc_priv(p_md->p_libvlc_instance->p_libvlc_int)->p_playlist, p_md->p_input_item ); } /* Should be integrated in core */ if( !psz_meta && e_meta == libvlc_meta_Title && p_md->p_input_item->psz_name ) { free( psz_meta ); return strdup( p_md->p_input_item->psz_name ); } return psz_meta;}/************************************************************************** * Getter for state information * Can be error, playing, buffering, NothingSpecial. **************************************************************************/libvlc_state_tlibvlc_media_get_state( libvlc_media_t *p_md, libvlc_exception_t *p_e ){ VLC_UNUSED(p_e); return p_md->state;}/************************************************************************** * Setter for state information (LibVLC Internal) **************************************************************************/voidlibvlc_media_set_state( libvlc_media_t *p_md, libvlc_state_t state, libvlc_exception_t *p_e ){ libvlc_event_t event; VLC_UNUSED(p_e); p_md->state = state; /* Construct the event */ event.type = libvlc_MediaStateChanged; event.u.media_state_changed.new_state = state; /* Send the event */ libvlc_event_send( p_md->p_event_manager, &event );}/************************************************************************** * subitems **************************************************************************/libvlc_media_list_t *libvlc_media_subitems( libvlc_media_t * p_md, libvlc_exception_t * p_e ){ VLC_UNUSED(p_e); if( p_md->p_subitems ) libvlc_media_list_retain( p_md->p_subitems ); return p_md->p_subitems;}/************************************************************************** * event_manager **************************************************************************/libvlc_event_manager_t *libvlc_media_event_manager( libvlc_media_t * p_md, libvlc_exception_t * p_e ){ VLC_UNUSED(p_e); return p_md->p_event_manager;}/************************************************************************** * Get duration of media object. **************************************************************************/int64_tlibvlc_media_get_duration( libvlc_media_t * p_md, libvlc_exception_t * p_e ){ VLC_UNUSED(p_e); if( !p_md || !p_md->p_input_item) { libvlc_exception_raise( p_e, "No input item" ); return -1; } return input_item_GetDuration( p_md->p_input_item );}/************************************************************************** * Get preparsed status for media object. **************************************************************************/intlibvlc_media_is_preparsed( libvlc_media_t * p_md, libvlc_exception_t * p_e ){ VLC_UNUSED(p_e); if( !p_md || !p_md->p_input_item) { libvlc_exception_raise( p_e, "No input item" ); return false; } return input_item_IsPreparsed( p_md->p_input_item );}/************************************************************************** * Sets media descriptor's user_data. user_data is specialized data * accessed by the host application, VLC.framework uses it as a pointer to * an native object that references a libvlc_media_t pointer **************************************************************************/void libvlc_media_set_user_data( libvlc_media_t * p_md, void * p_new_user_data, libvlc_exception_t * p_e ){ VLC_UNUSED(p_e); if( p_md ) { p_md->p_user_data = p_new_user_data; }}/************************************************************************** * Get media descriptor's user_data. user_data is specialized data * accessed by the host application, VLC.framework uses it as a pointer to * an native object that references a libvlc_media_t pointer **************************************************************************/void *libvlc_media_get_user_data( libvlc_media_t * p_md, libvlc_exception_t * p_e ){ VLC_UNUSED(p_e); if( p_md ) { return p_md->p_user_data; } else { return NULL; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -