本文来自csdn lidp http://blog.csdn.net/perfectpdl, 转载注明出处,谢谢。
基于 libvlc库的开发可以把vlc的功能嵌入我们自己的应用程序中,下面为linux平台(centos)使用libvlc库的开发过程。
1.安装libvlc sdk
linux平台直接可以 用命令安装,centos平台 命令为 yum install libvlc-devel
也可以基于官方源码安装(git://git.videolan.org/vlc.git)。
安装后会有动态库 libvlc,so和头文件。
2. 基于sdk api 开发
在程序中需要引入头文件 vlc.h
#include
#include
#include
int main(int argc, char* argv[])
{
libvlc_instance_t * inst;
libvlc_media_player_t *mp;
libvlc_media_t *m;
/* 加载 VLC 引擎 */
inst = libvlc_new (0, NULL);
/* Create a new item */
m = libvlc_media_new_path (inst, "http://mytest.mov");
/* Create a media player playing environement */
mp = libvlc_media_player_new_from_media (m);
/* No need to keep the media now */
libvlc_media_release (m);
#if 0
/* 下面的代码为具体平台上图像或声音渲染的句柄 */
libvlc_media_player_set_xdrawable (mp, xdrawable);
/* or on windows */
libvlc_media_player_set_hwnd (mp, hwnd);
/* or on mac os */
libvlc_media_player_set_nsobject (mp, view);
#endif
/* play the media_player */
libvlc_media_player_play (mp);
sleep (10); /* Let it play a bit */
/* Stop playing */
libvlc_media_player_stop (mp);
/* Free the media_player */
libvlc_media_player_release (mp);
libvlc_release (inst);
return 0;
}
需要引入库文件 libvlc.so
gcc -I ${VLC_SRC}/include/ -lvlc -L VLC_LIBS test.c -vlc -o test
4. 总结
上面只是使用libvlc的基本过程,libvlc sdk提供了很多api 给外部接口,比如指定音频或者视频流的回调等。
下面是我摘出来的可用的api
libvlc_errmsg
libvlc_clearerr
libvlc_printerr
libvlc_vprinterr
libvlc_add_intf
libvlc_audio_output_device_count
libvlc_audio_output_device_id
libvlc_audio_output_device_longname
libvlc_audio_output_device_set
libvlc_audio_output_get_device_type
libvlc_audio_output_list_get
libvlc_audio_output_list_release
libvlc_audio_output_set
libvlc_audio_output_set_device_type
libvlc_audio_get_channel
libvlc_audio_get_delay
libvlc_audio_get_mute
libvlc_audio_get_track
libvlc_audio_get_track_count
libvlc_audio_get_track_description
libvlc_audio_get_volume
libvlc_audio_set_channel
libvlc_audio_set_delay
libvlc_audio_set_mute
libvlc_audio_set_track
libvlc_audio_set_volume
libvlc_audio_toggle_mute
libvlc_audio_set_format
libvlc_audio_set_format_callbacks
libvlc_audio_set_callbacks
libvlc_audio_set_volume_callback
libvlc_clock
libvlc_event_attach
libvlc_event_detach
libvlc_event_manager_new
libvlc_event_manager_register_event_type
libvlc_event_manager_release
libvlc_event_type_name
libvlc_free
libvlc_get_changeset
libvlc_get_compiler
libvlc_get_fullscreen
libvlc_get_input_thread
libvlc_get_log_verbosity
libvlc_get_version
libvlc_log_clear
libvlc_log_close
libvlc_log_count
libvlc_log_get_iterator
libvlc_log_iterator_free
libvlc_log_iterator_has_next
libvlc_log_iterator_next
libvlc_log_open
libvlc_media_add_option
libvlc_media_add_option_flag
libvlc_media_discoverer_event_manager
libvlc_media_discoverer_is_running
libvlc_media_discoverer_localized_name
libvlc_media_discoverer_media_list
libvlc_media_discoverer_new_from_name
libvlc_media_discoverer_release
libvlc_media_duplicate
libvlc_media_event_manager
libvlc_media_get_duration
libvlc_media_get_meta
libvlc_media_get_mrl
libvlc_media_get_state
libvlc_media_get_stats
libvlc_media_get_user_data
libvlc_media_get_tracks_info
libvlc_media_is_parsed
libvlc_media_library_load
libvlc_media_library_media_list
libvlc_media_library_new
libvlc_media_library_release
libvlc_media_library_retain
libvlc_media_list_add_file_content
libvlc_media_list_add_media
libvlc_media_list_count
libvlc_media_list_event_manager
libvlc_media_list_index_of_item
libvlc_media_list_insert_media
libvlc_media_list_is_readonly
libvlc_media_list_item_at_index
libvlc_media_list_lock
libvlc_media_list_media
libvlc_media_list_new
libvlc_media_list_player_event_manager
libvlc_media_list_player_get_state
libvlc_media_list_player_is_playing
libvlc_media_list_player_new
libvlc_media_list_player_next
libvlc_media_list_player_pause
libvlc_media_list_player_play
libvlc_media_list_player_play_item
libvlc_media_list_player_play_item_at_index
libvlc_media_list_player_previous
libvlc_media_list_player_release
libvlc_media_list_player_retain
libvlc_media_list_player_set_media_list
libvlc_media_list_player_set_media_player
libvlc_media_list_player_set_playback_mode
libvlc_media_list_player_stop
libvlc_media_list_release
libvlc_media_list_remove_index
libvlc_media_list_retain
libvlc_media_list_set_media
libvlc_media_list_unlock
libvlc_media_new_fd
libvlc_media_new_location
libvlc_media_new_path
libvlc_media_new_as_node
libvlc_media_new_from_input_item
libvlc_media_parse
libvlc_media_parse_async
libvlc_media_player_can_pause
libvlc_media_player_next_frame
libvlc_media_player_event_manager
libvlc_media_player_get_agl
libvlc_media_player_get_chapter
libvlc_media_player_get_chapter_count
libvlc_media_player_get_chapter_count_for_title
libvlc_media_player_get_fps
libvlc_media_player_get_hwnd
libvlc_media_player_get_length
libvlc_media_player_get_media
libvlc_media_player_get_nsobject
libvlc_media_player_get_position
libvlc_media_player_get_rate
libvlc_media_player_get_state
libvlc_media_player_get_time
libvlc_media_player_get_title
libvlc_media_player_get_title_count
libvlc_media_player_get_xwindow
libvlc_media_player_has_vout
libvlc_media_player_is_seekable
libvlc_media_player_is_playing
libvlc_media_player_new
libvlc_media_player_new_from_media
libvlc_media_player_next_chapter
libvlc_media_player_set_pause
libvlc_media_player_pause
libvlc_media_player_play
libvlc_media_player_previous_chapter
libvlc_media_player_release
libvlc_media_player_retain
libvlc_media_player_set_agl
libvlc_media_player_set_chapter
libvlc_media_player_set_hwnd
libvlc_media_player_set_media
libvlc_media_player_set_nsobject
libvlc_media_player_set_position
libvlc_media_player_set_rate
libvlc_media_player_set_time
libvlc_media_player_set_title
libvlc_media_player_set_xwindow
libvlc_media_player_stop
libvlc_media_player_will_play
libvlc_media_player_navigate
libvlc_media_release
libvlc_media_retain
libvlc_media_save_meta
libvlc_media_set_meta
libvlc_media_set_state
libvlc_media_set_user_data
libvlc_media_subitems
libvlc_new
libvlc_playlist_play
libvlc_release
libvlc_retain
libvlc_set_fullscreen
libvlc_set_log_verbosity
libvlc_set_user_agent
libvlc_toggle_fullscreen
libvlc_toggle_teletext
libvlc_track_description_release
libvlc_track_description_list_release
libvlc_video_get_adjust_float
libvlc_video_get_adjust_int
libvlc_video_get_aspect_ratio
libvlc_video_get_chapter_description
libvlc_video_get_crop_geometry
libvlc_video_get_size
libvlc_video_get_height
libvlc_video_get_cursor
libvlc_video_get_logo_int
libvlc_video_get_marquee_int
libvlc_video_get_marquee_string
libvlc_video_get_scale
libvlc_video_get_spu
libvlc_video_get_spu_count
libvlc_video_get_spu_delay
libvlc_video_get_spu_description
libvlc_video_get_teletext
libvlc_video_get_title_description
libvlc_video_get_track
libvlc_video_get_track_count
libvlc_video_get_track_description
libvlc_video_get_width
libvlc_video_set_adjust_float
libvlc_video_set_adjust_int
libvlc_video_set_aspect_ratio
libvlc_video_set_callbacks
libvlc_video_set_crop_geometry
libvlc_video_set_deinterlace
libvlc_video_set_format
libvlc_video_set_format_callbacks
libvlc_video_set_key_input
libvlc_video_set_logo_int
libvlc_video_set_logo_string
libvlc_video_set_marquee_int
libvlc_video_set_marquee_string
libvlc_video_set_mouse_input
libvlc_video_set_scale
libvlc_video_set_spu
libvlc_video_set_spu_delay
libvlc_video_set_subtitle_file
libvlc_video_set_teletext
libvlc_video_set_track
libvlc_video_take_snapshot
libvlc_vlm_add_broadcast
libvlc_vlm_add_vod
libvlc_vlm_add_input
libvlc_vlm_change_media
libvlc_vlm_del_media
libvlc_vlm_get_event_manager
libvlc_vlm_get_media_instance_length
libvlc_vlm_get_media_instance_position
libvlc_vlm_get_media_instance_rate
libvlc_vlm_get_media_instance_time
libvlc_vlm_pause_media
libvlc_vlm_play_media
libvlc_vlm_release
libvlc_vlm_seek_media
libvlc_vlm_set_enabled
libvlc_vlm_set_input
libvlc_vlm_set_loop
libvlc_vlm_set_mux
libvlc_vlm_set_output
libvlc_vlm_show_media
libvlc_vlm_stop_media
libvlc_set_exit_handler
libvlc_wait
libvlc_audio_filter_list_get
libvlc_video_filter_list_get
libvlc_module_description_list_release