Initial analysis of VLC Architecture

Source: Internet
Author: User

 

The large architecture of VLC player is not hard to understand. What is hard to understand is the role of its object meta system, the Inheritance Mechanism of the class, the hierarchical relationship of the class, and the message transmission route.

 

Meta System

VLC implements the object meta system. I initially think its role is:

• Attributes can be easily extended and can be combined with the original configuration file.

• Dynamic attributes

• Many processes or message-driven mechanisms are implemented by the considerable attribute query mechanism.

Class (structure) Inheritance

• Most classes are inherited from vlc_object_t.

• Vlc_object_t implements the parent-child relationship between objects (different from inheritance ).

• The inheritance form is not like a real class or the vlc_object_t variable is put at the beginning of the structure, but a macro: vlc_common_members is used at the beginning of the class.

• Private Data implemented by each plug-in is stored in the public class variables of the plug-in with the "sys" or "priv" string.

Class hierarchy

• The highest external class is libvlc_instance_t. The main parameter used by the external interface is the libvlc_instance_t object, which is created by libvlc_new.

• The main objects of internal operations are libvlc_int_t, but they are actually libvlc_priv_t. Actually, libvlc_priv_t, libvlc_int_t, and libvlc_instance_t are the same objects. However, to achieve encapsulation, it is better to put a piece of data and describe it with comments.

• Libvlc_priv_t contains many things that should be included in an instance, such as the playlist, media_library, Streaming Media Server Object, hotkey ing action list, and interface object. Therefore, if you obtain the libvlc_int_t object, you can obtain all other objects.

 

Message transmission route

• The considerable meta query mechanism is the basis of message-driven systems.

• For example, The playlist_t object will check the input_thread_t object. The input_thread_t object represents an input stream. When input_thread_t changes some dynamic attributes of the image, playlist_t is notified. If playlist_t is listened to on the interface, these changes can be displayed. If playlist_t needs to operate input_thread_t, it is also done by setting the value of input_thread_t's dynamic attribute.

 

Process rough analysis

 

Cooperation between QT messages and meta notifications

• The main function of the interface is to provide user interfaces for users to control libvlc core objects, and to display the status of core objects to users.

• To control core objects through the interface, you only need to obtain libvlc_int_t within the interface plug-in, and then you can obtain any other objects, and then use existing functions or directly operate on its dynamic attributes.

• To reflect the status of core objects to the interface, the interface plug-in needs to view the dynamic attributes of these objects. For example, input_thread_t centrally notifies the viewer of the occurrence of an event through a dynamic attribute. This attribute is called "INTF-Event ".

• Input_event_type_e defines the event notifications that can be sent by all inputs.

• The QT interface plug-in uses a global function inputevent () as the callback function for the "INTF-Event" dynamic attribute to respond to the "INTF-Event" event.

• Playlist objects manage input objects because a new input object needs to be created for each playlist entry. The QT interface plug-in uses an inputmanager object to correspond to an input object, and a maininputmanager object to correspond to a (unique) playlist object.

• The inputmanager object is responsible for receiving events from the input object, converting "INTF-Event" to QT events through inputevent (), and then post the events to its customevent () function, in this example, it is converted to signal. However, this class is not responsible for manipulating input objects. It should be the responsibility of playlist objects.

• The maininputmanager object receives events from the playlist object and listens on multiple attributes of playlist. In the callback function, convert the attribute change to a QT event, mail the event to yourself, and send the event to signal in the receiving Letter Number. In addition, the maininputmanager object also loads playlist objects.

• The ing between the keyboard and the response function has been completed in libvlc. The caller must convert the key value to the key value defined in libvlc, and then pass it to libvlc using the "key-pressed" attribute of the libvlc_int_t object. Internally, the listener function of this attribute is called to correctly reflect Keyboard Events.

Analysis of QT interface plug-ins

• Added when libvlc_add_intf () is called after libvlc Initialization is complete.

• Create and initialize private data in the open () function of the plug-in: intf_sys_t. Then, the thread where the interface is located is created.

• Create a qapp instance in the interface thread, create the main interface window, and enter the message cycle.

• The main window consists of three functions: menu bar, central area, and status bar, which are created by vlcmenubar: createmenubar (), createmainwidget (), and createstatusbar.

• The Central area contains many controls, including control bar, input bar, advanced control bar, video display control, background control, and playback list control. Of course, some controls are mutually exclusive.

• Controls that contain multiple controls, such as the control bar, input bar, and advanced control bar. Their internal controls are created in sequence with entries in the configuration file. Each control in the configuration file corresponds to a type, which directly specifies the function of the control.

• All controls that contain multiple controls are derived from abstractcontroller, which uses qsignalmapper to process the signals of all controls that they contain in a unified manner to support programmability. All controls add their own signals to Mapper, connect the Mapper signal to the actionsmanager object, and process the signals of all controls in the doaction () of actionsmanager.

Thoughts on synchronous playback

• Extended QT interface plug-in

• Use non-blocking QT socket: qtcpsocket.

• The socket is in the thread of the interface.

• Create a TCP socket immediately after creating the main interface window

• When the user input or libvlc signal is received on the interface, the command package is sent to another terminal.

• After receiving the command package from the other end, the socket directly calls libvlc related functions based on the command content.

 

How to add a new interface to the Project

• Add the header file and source code file for the definition interface under src/modules/GUI/qt4/dialogs.

• Modify the makefile. Am file in src/modules/GUI/qt4.

• Add an item to nodist_sources_qt4.

• Add items to sources_qt4.

• Add an item to noinst_headers.

• If you want to link a new QT library, modify src/configure. ac. For example, if you add a link to the qtnetwork library, find the row pkg_check_modules (qt4, [qtcore qtgui> = 4.6.0], [change to pkg_check_modules (qt4, [qtcore qtgui qtnetwork> = 4.6.0], [

• Execute the autoreconf command

•./Configure

• Make

 

How to add image resources to projects

• Place image files such as a.png under/modules/GUI/qt4/pixmaps.

• Add pixmaps/a.png to the deps_res area of modules/GUI/qt4/modules. am.

• Add one in the <qresource prefix = "/"> area of modules/GUI/qt4/modules. AM: <filealias = "a_icon"> pixmaps/a.png </File>

• Autoreconf, configure

• Use qicon (": a_icon") in the source file as follows ");

• Make

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.