VLC Overview

简介: LibVLC LibVLC is the core part of VLC. It is a library providing an interface for programs such as VLC to a lot of functionalities such...

LibVLC

LibVLC is the core part of VLC. It is a library providing an interface for programs such as VLC to a lot of functionalitieswps_clip_image1 such as stream access, audio and video output, plugin handling, a thread system. All the LibVLC source files are located in the src/ directory and its subdirectories:

· interface/: contains code for user interaction wps_clip_image2such as key presses and device ejectionwps_clip_image3.

· playlist/: manages playlist interaction such as stop, play, next, or random playbackwps_clip_image4.

· input/: opens an input module, reads packets, parses them and passes reconstitutedwps_clip_image5 elementarywps_clip_image6 streams to the decoder(s).

· video_output/: initializes the video display, gets all pictures and subpictures (ie. subtitles) from the decoder(s), optionally converts them to another format (such as YUV to RGB), and displays them.

· audio_output/: initializes the audio mixerwps_clip_image7, ie. finds the right playing frequency, and then resampleswps_clip_image8 audio frames received from the decoder(s).

· stream_output/: TODO

· misc/: miscellaneouswps_clip_image9 utilitieswps_clip_image10 used in other parts of libvlc, such as the thread system, the message queue, CPU detectionwps_clip_image11, the object lookup system, or platform-specific code.

VLC

VLC is a simple program written around LibVLC. It is very small, but is a fully featured multimedia player thanks to LibVLC's support for dynamic modules.

Modules

Modules are located in the modules/ subdirectory and are loaded at runtime. Every module may offer different features that will best suit a particular file or a particular environment. Besides, most portabilitywps_clip_image12 works result in the writing of an audio_output/video_output/interface module to support a new platform (eg. BeOS or MacOS X).

Plugin modules are loaded and unloaded dynamically by functions in src/misc/modules.c and include/modules*.h. The API for writing modules will be discussed in a following chapter.

Modules can also be built directly into the application which uses LibVLC, for instance on an operating system that does not have support for dynamically loadable code. Modules statically wps_clip_image13built into the application are called builtins.

Threads Thread management

VLC is heavily multi-threaded. We chose against a single-thread approachwps_clip_image14,入口 because decoder preemptibilitywps_clip_image15 and scheduling wps_clip_image16would be a mastermind wps_clip_image17(for instance decoders and outputs have to be separated, otherwise it cannot be warrantiedwps_clip_image18 that a frame will be played at the exact presentationwps_clip_image19 time), and we currently have no plan to support a single-threaded client. Multi-process decoders usually imply wps_clip_image20more overhead wps_clip_image21(problems of shared memory) and communication between processes is harder.

Our threading structure is modeled on pthreads. However, for portability reasons, we don't call pthread_* functions directly, but use a similar wrapperwps_clip_image22, made of vlc_thread_create, vlc_thread_exit, vlc_thread_join, vlc_mutex_init, vlc_mutex_lock, vlc_mutex_unlock, vlc_mutex_destroy, vlc_cond_init, vlc_cond_signal, vlc_cond_broadcast, vlc_cond_wait, vlc_cond_destroy, and structures vlc_thread_t, vlc_mutex_t, and vlc_cond_t.

Synchronization wps_clip_image23

Another key feature of VLC is that decoding and playing are asynchronous:wps_clip_image24 decoding is done by a decoder thread, playing is done by audio_output or video_output thread. The design goal is to ensure that an audio or video frame is played exactly at the right time, without blocking any of the decoder threads. This leads to a complex communication structure between the interface, the input, the decoders and the outputs.

Having several input and video_output threads reading multiple files at the same time is permitted, despite the fact that the current interface doesn't allow any way to do it [this is subject to change in the near future]. Anyway the client has been written from the ground up with this in mind. This also implies that a non-reentrantwps_clip_image25 library (including in particular liba52) cannot be used without using a global lock.

Presentation Time Stamps located in the system layer of the stream are passed to the decoders, and all resulting samples are dated accordingly.wps_clip_image26 The output layerswps_clip_image27 are supposed to play them at the right time. Dates are converted to microseconds ; an absolute date is the number of microseconds since Epoch (Jan 1st, 1970). The mtime_t type is a signed 64-bit integer.

The current date can be retrieved with mdate(). The execution of a thread can be suspended wps_clip_image28until a certain date via mwait ( mtime_t date ). You can sleep for a fixed wps_clip_image29number of microseconds with msleep ( mtime_t delay ).

Warning

Please remember to wake up slightlywps_clip_image30 before the presentation date, if some particular treatmentwps_clip_image31 needs to be done (e.g. a chromawps_clip_image32 transformation). For instance in modules/codec/mpeg_video/synchro.c, track of the average decoding times is kept to ensure pictures are not decoded too late.

Code conventions Function naming

All functions are named accordingly : module name (in lower case) + _ + function name (in mixed case, without underscores). For instance : intf_FooFunction. Static functions don't need usage of the module name.

Variable naming

Hungarianwps_clip_image33 notationswps_clip_image34 are used, that means we have the following prefixes :

· i_ for integers wps_clip_image35(sometimes l_ for long integers) ;

· b_ for booleans ;

· d_ for doubles (sometimes f_ for floats) ;

· pf_ for function pointers ;

· psz_ for a Pointer to a String terminatedwps_clip_image36 by a Zero (C-string) ;

· More generally, we add a p when the variable is a pointer to a type.

If one variable has no basic type (for instance a complex structure), don't put any prefix (except p_* if it's a pointer). After one prefix, put an explicitwps_clip_image37 variable name in lower case. If several words are required, join them with an underscore (no mixed case). Examples :

· data_packet_t * p_buffer;

· char psz_msg_date[42];

· int pi_es_refcount[MAX_ES];

· void (* pf_next_data_packet)( int * );

A few words about white spaces

First, never use tabs in the source (you're entitled to use them in the Makefile :-). Use set expandtab under vim or the equivalentwps_clip_image38 under emacs. Indents are 4 spaces long.

Second, put spaces before and after operators, and inside brackets. For instance :

for( i = 0; i

Third, leave braces alone on their lines (GNU style). For instance :

if( i_es == 42 )

{

    p_buffer[0] = 0x12;

}

We write C, so use C-style comments /* ... */.

Prev

Next

Glossary

Home

Chapter 2.  VLC interface

相关文章
|
Web App开发 数据安全/隐私保护 iOS开发
IDM (Internet Download Manager)6.41最新版真正免费下载器
一款真正老牌经典、强大实用、干净无打扰、而且仅需一次性付费即可终生使用的下载工具更加适合你。而大名鼎鼎的 IDM (Internet Download Manager) 正是这样的一款“将下载加速做到极致、安静纯粹、无广告、免打扰、静默下载”的下载软件!
1993 0
|
异构计算
好工具推荐系列:OpenGL Extensions Viewer
好工具推荐系列:OpenGL Extensions Viewer
221 0
|
移动开发 HTML5 数据可视化
IsoAlgo3d - A PCF 3D Viewer for Desktop, Tablet and Smart phone
IsoAlgo3d - A PCF 3D Viewer for Desktop, Tablet and Smart phone eryar@163.com Abstract. IsoAlgo3d 通过将PCF三维可视化,并导出HTML文件。
2185 0
|
编解码 算法
Skype SILK codec overview
最近简单看了一下Skype SILK codec 算法, 基本原理和流程大体明白了, 以后有时间再仔细研究一下细节,今天就简单说说. SILK Codec是一个语音和音频编解码算法, 对于音频带宽、网络带宽和算法复杂度都具有很好的弹性。
1667 0