Libvlc API analysis for VLC player in Windows

Source: Internet
Author: User

 

API
    • Libvlc_instance_t *Libvlc_new(INT argc, const char * const * argv)

  libvlc_instance_t   *   libvlc_new (  int   argc,   const     char   *     const   *   argv) 
Create and initialize a libvlc instance
This function accepts a command line parameter list, which affects the default configuration of libvlc instance.
Version:
the parameter indicates that it is passed to libvlc from the command line, just as the VLC Media Player does. The valid parameter list depends on the version, operating system, platform, and plug-in set of libvlc. Invalid or unsupported parameters will cause the API to fail ( return null ). In addition, some parameters may change the behavior of libvlc or interfere with other functions of libvlc in other ways.
parameters:
argc: Number of command line parameters
argv: command line type parameter
Returns:
If the libvlc instance is successful, null is returned if the libvlc instance fails.

Vlc_public_api voidLibvlc_release(Libvlc_instance_t * p_instance );

 
Reduce the reference count of libvlc instance, and destroy it if the count is zero.
(Decrement the reference count of a libvlc instance, and destroy itIfIt reaches zero)

Param:
Libvlc instance to be destroyed

Vlc_public_api libvlc_media_player_t *Libvlc_media_player_new(Libvlc_instance_t * p_libvlc_instance );

 
Create an empty Media Player Object

Parameters:
P_libvlc_instance: The instance to which the created Media Player belongs.

Return:
A New Media Player Object. If an error occurs, null is returned.

vlc_public_api void libvlc_media_player_release (libvlc_media_player_t * p_mi);

Release the Media Player Object after use to reduce the number of times the Media Player Object is referenced. If the count is already zero, this method releases the Media Player Object. If the Media Player Object is already released, this method should not be called again (release a media_player after use decrement the reference count of a Media PlayerObject. If the reference countIs 0, Then libvlc_media_player_release () will release the Media PlayerObject. If the Media PlayerObjectHas been released, then it shoshould not be used again .)

Param:
P_mi: Media Player Object to be released

Vlc_public_api libvlc_event_manager_t *Libvlc_media_player_event_manager(Libvlc_media_player_t * p_mi );

 
Obtain an event manager from the Media Player Object that sends the event
(Get the event manager from which the media player sendEvent)

Param:
P_mi: Media Player Object

Return:
Returns the event manager associated with the specified Media Player Object.

vlc_public_api int libvlc_event_attach (optional * p_event_manager,
polici_event_type,
libvlc_callback_t f_callback,
void * user_data );

Event Notification Registrar (RegisterForAnEventNotification), set the event Processor

Param:
P_event_manager: The event manager you want to associate
I _event_type: Specifies the event type.
F_callback: the callback function when an event occurs.
User_data: user provided data to carry withEvent(
This parameter is not understood yet)

Return:
Successful:0; Failed: enomem

Vlc_public_api voidLibvlc_media_player_set_hwnd(Libvlc_media_player_t * p_mi, void * drawable );

Set Win32 for media output to the media player./Win64 window handle. If the libvlc is built without Win32/Built-in support for win64 API output, this method will not work (if libvlc was built without Win32/Win64 API output support, thenThisHas no effects)

Param:
P_mi: Media Player
Drawable: draws the window handle of a media output.

The libvlc_log _ * function provides access to libvlc message logs for debugging or advanced users.

Vlc_public_api unsigned libvlc_get_log_verbosity (const libvlc_instance_t * p_instance );

 
Returns the Log Level of libvlc.
Param:
P_instance: libvlc instance
Return:
Log Level

Vlc_public_api unsigned libvlc_get_log_verbosity (const libvlc_instance_t * p_instance );

 
Set the Log Level of libvlc
Param:
P_instance: libvlc instance
Level: Log Level

Vlc_public_api libvlc_log_t * libvlc_log_open (libvlc_instance_t * p_instance );

 
Open a VLC Message Log handle
Param:
P_instance: libvlc instance
Return:
Success: Log message instance is returned; Failure: NULL is returned if an error occurs;

Vlc_public_api void libvlc_log_close (libvlc_log_t * p_log );

 
Disable a VLC Message Log instance
Param:
P_log: libvlc log instance or null

Vlc_public_api unsigned libvlc_log_count (const libvlc_log_t * p_log );

Returns the number of messages in a log instance.
Param:
P_log: libvlc log instance or NULL;
Return:
Returns the number of log messages. If p_log is null, 0 is returned;

Vlc_public_api void libvlc_log_clear (libvlc_log_t * p_log );

 
Clear a log instance
All messages in the log instance are cleared. Logs should be cleared regularly to avoid congestion.
Param:
P_log: libvlc log instance or NULL;

Vlc_public_api libvlc_log_iterator_t * libvlc_log_get_iterator (const libvlc_log_t * p_log );

Allocate or return a new iterator pointing to the log message
Param:
P_log: libvlc log instance
Return:
Log iterator object or error return null

Vlc_public_api void libvlc_log_iterator_free (libvlc_log_iterator_t * p_iter );

 
Release the previously assigned Log message iterator
Param:
P_iter: libvlc log iterator or null

Vlc_public_api int libvlc_log_iterator_has_next (const libvlc_log_iterator_t * p_iter );

Whether the iterator returns more messages in the log
Param:
P_iter: libvlc log iterator or NULL;
Return:
Yes: Return true; NO: Return false;

Vlc_public_api libvlc_log_message_t * libvlc_log_iterator_next (libvlc_log_iterator_t * p_iter,
Libvlc_log_message_t * p_buffer );

Returns the next log message.
The message content cannot be released.
Param:
P_iter: libvlc log iterator or NULL;
P_buffer: log buffer;
Return:
Log message object or NULL;

Routine

As mentioned earlier, Dalong needs to process logs in a simple player. As mentioned above, the following is a simple example:

Background: for simple libvlc log processing, we have three unknown points:

1. When: When the libvlc logs are generated when the player is running;

2. Where: We should applyCodeWhere to log;

3. How: Use the above log API provided by libvlc to log;

Based on the above three points, my idea is to open a separate thread and check whether there are logs every second.

Body

Note: Some libvlc objects, such as libvlc instances, and libvlc players generate asynchronous signals. Each object provides an event manager. you can associate an object event with the event manager of the corresponding libvlc object to process or disassociate the event manager.

Related Structure

Event manager: The event manager belongs to a libvlc object. The manager can receive event signals from the object.
Typedef struce libvlc_event_manager_t; --------- Event manager Structure
< P > Struct Libvlc_event_t; ------------------------------------------------ Event Structure </ P >
Typedef Int Libvlc_event_type_t; -------------------------------------- Event Type Structure
Typedef Void ( * Libvlc_callback_t )( Const Struct Libvlc_event_t * , Void * ) -- Event Callback Function

API
  • Register event manager
     
    Vlc_public_apiIntLibvlc_event_attach (
    Libvlc_event_manager_t*P_event_manager,
    Libvlc_event_type_t I _event_type,
    Libvlc_callback_t f_callback,
    Void *User_data );

    Param:
    P_event_manager: The event manager to bind
    I _event_type: Event Type
    F_callback: callback function pointer
    User_data: the data provided by the user, which is brought back by the event

    Log out of the event manager

     
    Vlc_public_apiVoidLibvlc_event_detach (
    Libvlc_event_manager_t*P_event_manager,
    Libvlc_event_type_t I _event_type,
    Libvlc_callback_t f_callback,
    Void *P_user_data );

    Param:
    P_event_manager: The event manager to bind
    I _event_type: Event Type
    F_callback: callback function pointer
    User_data: the data provided by the user, which is brought back by the event

    Others

     1 . Get event type name
    Vlc_public_api Const Char * Libvlc_event_type_name (libvlc_event_type_t event_type );
    Param:
    Event_type: Event Type
    2 . Obtain the player event manager.
    Vlc_public_api libvlc_event_manager_t * Libvlc_media_player_event_manager (libvlc_media_player_t * P_mi );
    Param:
    P_mi: Media Player
    Return :
    Returns the event manager associated with p_mi.
    3 . Get Media descriptor object event manager
    Vlc_public_api libvlc_event_manager_t *
    Libvlc_media_event_manager (libvlc_media_t * P_md );
    4 . Get Media Service discover object event manager
    Vlc_public_api libvlc_event_manager_t *
    Libvlc_media_discoverer_event_manager (libvlc_media_discoverer_t * P_mdis );
    5 . Get the event manager of the media list instance
    Vlc_public_api libvlc_event_manager_t * Libvlc_media_list_event_manager (libvlc_media_list_t * P_ml );
    Param:
    P_ml: media list instance
    6 . Get vlm media event manager
    Vlc_public_api libvlc_event_manager_t * Libvlc_vlm_get_event_manager (libvlc_instance_t * P_instance );
    Param:
    P_instance: libvlc instance

    Note:

    Generally, we need "release" after "get", such as getdc () of Windows API and corresponding releasedc, there is also a corresponding "release" for obtaining the event manager here ".

     
    VoidLibvlc_event_manager_release (libvlc_event_manager_t*P_em );

    However, we do not need to call this method explicitly, because "for some libvlc objects, the 'event Manager' is in its structure '----

     
    Libvlc_event_manager_t*P_event_manager;

    When an object is released or destroyed, this method is called to destroy the 'event manager' of the corresponding object at the same time. For example, when libvlc_media_player_release () is called () this method is called to release the Media Player event manager when a Media Player is released.



















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.