• vlc api整理


    1.typedef void(* libvlc_audio_cleanup_cb) (void *opaque)//播放器不需要音频输出的时候,这个函数会被调用

    其中opaque数据指针通过libvlc_audio_set_callbacks()传递

    2.typedef void(* libvlc_audio_drain_cb) (void *data)//vlc在解码音轨的末尾调用这个函数

    音轨已经没有更多的解码采样,但是播放仍要继续,直到所有的视频数据渲染完毕

    3.typedef void(* libvlc_audio_flush_cb) (void *data, int64_t pts)//当vlc需要丢弃所有的挂起的缓冲器,通常发生在媒体被停止的时候

    data通过传递给libvlc_audio_set_callbacks()

    4.typedef void(* libvlc_audio_pause_cb) (void *data, int64_t pts)//调用它暂停音频播放,如果音频已经暂停了,就不会调用它

    data通过传递给libvlc_audio_set_callbacks()

    pts 暂停请求的时间戳,应该是过去时

    5.typedef void(* libvlc_audio_play_cb) (void *data, const void *samples, unsigned count, int64_t pts)

    libvlc在一个内部线程,异步解码和后处理音频信号,每当音频数据排队输出时,会被调用。每次调用提供的样本数可能取决于文件格式、音频编码算法、解码器插件、后处理过滤器和定时

    应用程序不得假设确定数量的样本。音频样本的确切格式由libvlc_audio_set_format()或libvlc_audio_set_format_callbacks()决定,就像频道布局一样。请注意,采样数为每个通道。

    例如,如果音频轨道采样率为48000 Hz,则1200个采样代表25毫秒的音频信号,而与音频通道的数量无关。

    data 通过传递给libvlc_audio_set_callbacks()

    samples 指向要播放的音频样本表的指针

    count 要播放的音频样本数

    pts 预期的播放时间戳 (see libvlc_delay())

    6.  typedef void(* libvlc_audio_resume_cb) (void *data, int64_t pts)

    LibVLC调用此回调以在先前暂停后恢复音频播放。

    data 通过传递给libvlc_audio_set_callbacks()

    pts恢复播放的时间戳

    7.typedef void(* libvlc_audio_set_volume_cb) (void *data, float volume, bool mute

    volume:software volume (1. = nominal, 0. = mute)

    mute:muted flag

    8.typedef int(* libvlc_audio_setup_cb) (void **opaque, char *format, unsigned *rate, unsigned *channels)
    当媒体播放器需要创建新的音频输出时,会调用此选项。

    opaque:pointer to the data pointer passed to libvlc_audio_set_callbacks() [IN/OUT]

    format:4 bytes sample format [IN/OUT]

    rate:sample rate [IN/OUT]

    channels:channels count [IN/OUT]

    Returns:0 on success, anything else to skip audio playbackReturns

    9.  typedef void(* libvlc_video_cleanup_cb) (void *opaque)

    配置图片缓冲区格式

     opaque private pointer as passed to libvlc_video_set_format_callbacks() (and possibly modified by libvlc_video_format_cb) [IN]

    10 typedef void(* libvlc_video_display_cb) (void *opaque, void *picture)

    当需要显示视频帧时(由媒体播放时钟确定),将调用显示回调。

    opaque private pointer as passed to libvlc_video_set_callbacks() [IN]

    picture private pointer returned from the libvlc_video_lock_cb callback [IN]

    11.  typedef unsigned(* libvlc_video_format_cb) (void **opaque, char *chroma, unsigned *width, unsigned *height, unsigned *pitches, unsigned *lines)

    配置图片缓冲区格式
    此回调通过视频解码器和视频过滤器,获取输出的视频格式

    它可以根据需要选择更改任何参数。在这种情况下,LibVLC将尝试转换视频格式(重缩放和色度转换),但这些操作可能会占用大量CPU

    12.typedef void*(* libvlc_video_lock_cb) (void *opaque, void **planes)

    分配和锁定一个图片缓冲区。

    每当需要解码新视频帧时,就会调用锁回调。根据视频色度,必须通过第二个参数返回一个或三个足够尺寸的像素平面。这些平面必须在32字节的边界上对齐。

    opaque:   private pointer as passed to libvlc_video_set_callbacks() 

    Returns:private pointer for the display and unlock callbacks to identify the picture buffers

    13.  typedef void(* libvlc_video_unlock_cb) (void *opaque, void *picture, void *const *planes)//解锁图片缓冲区

    视频帧解码完成后,将调用解锁回调。这个回调可能根本不需要。这只是表明应用程序现在可以在需要时读取像素值

    A picture buffer is unlocked after the picture is decoded, but before the picture is displayed

    opaque  private pointer as passed to libvlc_video_set_callbacks() [IN]

    picture   private pointer returned from the libvlc_video_lock_cb callback [IN]

    planes    pixel planes as defined by the libvlc_video_lock_cb callback (this parameter is only for convenience) [IN]14.

    14   LIBVLC_API void libvlc_audio_set_callbacks ( libvlc_media_player_t * mp,

    libvlc_audio_play_cb play,
    libvlc_audio_pause_cb pause,
    libvlc_audio_resume_cb resume,
    libvlc_audio_flush_cb flush,
    libvlc_audio_drain_cb drain,
    void * opaque
    )

    设置解码音频的回调和私有数据。

    使用libvlc_audio_set_format()或libvlc_audio_set_format_callbacks()来配置解码的音频格式。

    音频回调覆盖任何其他音频输出机制。如果设置了回调,LibVLC将不会以任何方式输出音频。

    15   LIBVLC_API void libvlc_audio_set_format ( libvlc_media_player_t * mp,

    const char * format,
    unsigned rate,
    unsigned channels
    )

    设置固定的解码音频格式

    这只适用于libvlc_audio_set_callbacks(),与libvlc_audio_set_format_callbacks()是互斥的。

    mp the media player
    format a four-characters string identifying the sample format (e.g. "S16N" or "f32l")
    rate sample rate (expressed in Hz)
    channels channels count

    16   LIBVLC_API void libvlc_audio_set_format_callbacks ( libvlc_media_player_t * mp,

    libvlc_audio_setup_cb setup,
    libvlc_audio_cleanup_cb cleanup
    )

    通过回调设置解码音频格式。

    mp the media player
    setup callback to select the audio format (cannot be NULL)
    cleanup callback to release any allocated resources (or NULL)

    17   LIBVLC_API void libvlc_audio_set_volume_callback ( libvlc_media_player_t * mp,

    libvlc_audio_set_volume_cb set_volume
    )

    为解码音频设置回调和私有数据。

    18   LIBVLC_API int libvlc_media_player_add_slave ( libvlc_media_player_t * p_mi,

    libvlc_media_slave_type_t i_type,
    const char * psz_uri,
    bool b_select
    )

    添加一个从属设备到当前媒体播放器。

    See also
    libvlc_media_slaves_add
    Parameters
    p_mi the media player
    i_type subtitle or audio
    psz_uri Uri of the slave (should contain a valid scheme).
    b_select True if this slave should be selected when it's loaded
    Returns
    0 on success, -1 on error.

    19   LIBVLC_API bool libvlc_media_player_can_pause ( libvlc_media_player_t * p_mi )

    Return values
    true media player can be paused
    false media player cannot be paused

    20 LIBVLC_API libvlc_event_manager_t* libvlc_media_player_event_manager ( libvlc_media_player_t * p_mi )

    获取媒体播放器发送事件的事件管理器。

    21   LIBVLC_API int libvlc_media_player_get_chapter ( libvlc_media_player_t * p_mi )

    Get movie chapter. 

    Returns  chapter number currently playing, or -1 if there is no media.

    22   LIBVLC_API int libvlc_media_player_get_chapter_count ( libvlc_media_player_t * p_mi )

    Get movie chapter count.

    Returns number of chapters in movie, or -1.

    23   LIBVLC_API int libvlc_media_player_get_chapter_count_for_title ( libvlc_media_player_t * p_mi, int i_title)

    Get movie chapter count.

    Returns number of chapters in movie, or -1.

    24   LIBVLC_API void* libvlc_media_player_get_hwnd ( libvlc_media_player_t * p_mi )

    Get the Windows API window handle (HWND) previously set with libvlc_media_player_set_hwnd().

    The handle will be returned even if LibVLC is not currently outputting any video to it.

    Returns a window handle or NULL if there are none.

    25   LIBVLC_API libvlc_time_t libvlc_media_player_get_length(libvlc_media_player_t * p_mi)

    Get the current movie length (in ms).

    Returns the movie length (in ms), or -1 if there is no media.

    26   LIBVLC_API libvlc_media_t* libvlc_media_player_get_media(libvlc_media_player_t * p_mi)

    获取媒体播放器使用的媒体。

    在libvlc_media_player_set_media()之后调用此函数将返回刚刚设置的媒体,但播放机当前可能未在内部使用此媒体。要检测这种情况,用户应该监听libvlc_mediaplayermdiachanged事件

    Returns  the media associated with p_mi, or NULL if no media is associated

    27. LIBVLC_API float libvlc_media_player_get_position(libvlc_media_player_t * p_mi)

    Get movie position as percentage between 0.0 and 1.0.

    Returns movie position, or -1. in case of error

    28.  LIBVLC_API float libvlc_media_player_get_rate ( libvlc_media_player_t * p_mi )

    Get the requested movie play rate
    根据基础媒体的不同,请求的播放速率可能不同于实际播放速率

    Returns movie play rate

    29   LIBVLC_API libvlc_state_t libvlc_media_player_get_state ( libvlc_media_player_t * p_mi )

    Get current movie state.

    typedef enum libvlc_state_t
    {
    libvlc_NothingSpecial=0,
    libvlc_Opening,
    libvlc_Buffering, /* XXX: Deprecated value. Check the
    * libvlc_MediaPlayerBuffering event to know the
    * buffering state of a libvlc_media_player */
    libvlc_Playing,
    libvlc_Paused,
    libvlc_Stopped,
    libvlc_Ended,
    libvlc_Error
    } libvlc_state_t;

    30   LIBVLC_API libvlc_time_t libvlc_media_player_get_time ( libvlc_media_player_t * p_mi )

    Get the current movie time (in ms).

    Returns the movie time (in ms), or -1 if there is no media.

    31   LIBVLC_API int libvlc_media_player_get_title_count(libvlc_media_player_t * p_mi)

    Get movie title count.

    Returns title number count, or -1

    32   LIBVLC_API uint32_t libvlc_media_player_get_xwindow(libvlc_media_player_t * p_mi)

    获取以前使用libvlc_media_player_set_xwindow()设置的X Window系统窗口标识符。
    请注意,即使VLC当前未使用该标识符(例如,如果它正在播放仅音频输入),它也会返回该标识符。

    Returns an X window ID, or 0 if none where set.

    33   LIBVLC_API unsigned libvlc_media_player_has_vout ( libvlc_media_player_t * p_mi )

    这个媒体播放器有多少视频输出?

    Returns the number of video outputs

    34   LIBVLC_API bool libvlc_media_player_is_playing ( libvlc_media_player_t * p_mi )

    Return values
    true media player is playing
    false media player is not playing

    35   LIBVLC_API bool libvlc_media_player_is_seekable(libvlc_media_player_t * p_mi)

    Return values
    true media player can seek
    false media player cannot seek

    36   LIBVLC_API libvlc_media_player_t* libvlc_media_player_new(libvlc_instance_t * p_libvlc_instance)

    Create an empty Media Player object.

    Returns a new media player object, or NULL on error. It must be released by libvlc_media_player_release().

    37   LIBVLC_API libvlc_media_player_t* libvlc_media_player_new_from_media(libvlc_media_t * p_md)

    Create a Media Player object from a Media.

    Returns a new media player object, or NULL on error. It must be released by libvlc_media_player_release().

    38   LIBVLC_API void libvlc_media_player_next_chapter ( libvlc_media_player_t * p_mi )

    Set next chapter

    39   LIBVLC_API void libvlc_media_player_next_frame ( libvlc_media_player_t * p_mi )

    Display the next frame

    40   LIBVLC_API void libvlc_media_player_pause(libvlc_media_player_t * p_mi)

    Toggle pause

    41   LIBVLC_API int libvlc_media_player_play ( libvlc_media_player_t * p_mi )

    Play.

    Returns 0 if playback started (and was already started), or -1 on error.

    42   LIBVLC_API void libvlc_media_player_previous_chapter ( libvlc_media_player_t * p_mi )

    Set previous chapter (if applicable)

    43   LIBVLC_API bool libvlc_media_player_program_scrambled(libvlc_media_player_t * p_mi)

    Check if the current program is scrambled.抢占

    Return values
    true current program is scrambled
    false current program is not scrambled

    44   LIBVLC_API void libvlc_media_player_release ( libvlc_media_player_t * p_mi )

    使用后释放媒体播放器,减少媒体播放器对象的引用计数。

    如果引用计数为0,则libvlc_media_player_release()将释放媒体播放器对象。如果媒体播放器对象已被释放,则不应再次使用。

    45   LIBVLC_API void libvlc_media_player_retain(libvlc_media_player_t * p_mi)

    Retain a reference to a media player object.

    Use libvlc_media_player_release() to decrement reference count.

    46   LIBVLC_API void libvlc_media_player_set_chapter ( libvlc_media_player_t * p_mi, int i_chapter)

      Set movie chapter 

    47   LIBVLC_API void libvlc_media_player_set_hwnd ( libvlc_media_player_t * p_mi,void * drawable )

    设置Win32/Win64 API窗口句柄(HWND),媒体播放器应在其中呈现其视频输出。

    Parameters
    p_mi the Media Player
    drawable windows handle of the drawable

    48   LIBVLC_API void libvlc_media_player_set_media ( libvlc_media_player_t * p_mi,libvlc_media_t * p_md )

     Set the media that will be used by the media_player.

    If any, previous md will be released.

    The user should listen to the libvlc_MediaPlayerMediaChanged event, to know when the new media is actually used by the player (or to known that the older media is no longer used).

    49   LIBVLC_API void libvlc_media_player_set_pause ( libvlc_media_player_t * mp,int do_pause )

     mp:the Media Player

    do_pause :play/resume if zero, pause if non-zero

    50   LIBVLC_API int libvlc_media_player_set_position ( libvlc_media_player_t * p_mi,float f_pos, bool b_fast )

      Set movie position as percentage between 0.0 and 1.0.

    如果未启用播放,则此选项无效。这可能不起作用,具体取决于底层的输入格式和协议。

    51   LIBVLC_API int libvlc_media_player_set_rate ( libvlc_media_player_t * p_mi,float rate )

     设定电影播放率。

    Returns -1 if an error was detected, 0 otherwise (but even then, it might not actually work depending on the underlying media protocol)

    52   LIBVLC_API int libvlc_media_player_set_renderer ( libvlc_media_player_t * p_mi,libvlc_renderer_item_t * p_item )

     Set a renderer to the media player.

    必须在第一次调用libvlc_media_player_play()之前调用才能生效

     0 on success, -1 on error.

    53   LIBVLC_API int libvlc_media_player_set_time ( libvlc_media_player_t * p_mi,libvlc_time_t i_time, bool b_fast )

    Set the movie time (in ms).

    如果没有播放媒体,则此操作无效。并非所有格式和协议都支持这一点

    p_mi the Media Player
    b_fast prefer fast seeking or precise seeking
    i_time the movie time (in ms).

    54   LIBVLC_API void libvlc_media_player_set_title ( libvlc_media_player_t * p_mi,int i_title )

    Set movie title.

    i_titletitle number to play

    55   LIBVLC_API void libvlc_media_player_set_video_title_display ( libvlc_media_player_t * p_mi,

    libvlc_position_t position,
    unsigned int timeout
    )

    设置播放媒体时是否显示视频标题以及显示方式。

    56    LIBVLC_API void libvlc_media_player_set_video_title_display ( libvlc_media_player_t * p_mi,

    libvlc_position_t position,
    unsigned int timeout
    )

    position position at which to display the title, or libvlc_position_disable to prevent the title from being displayed
    timeout title display timeout in milliseconds (ignored if libvlc_position_disable)

    57   LIBVLC_API void libvlc_media_player_set_xwindow ( libvlc_media_player_t * p_mi,

    uint32_t drawable
    )

    设置一个X窗口系统可绘制,媒体播放器应在其中呈现其视频输出。

    默认情况下,LibVLC将捕获视频渲染区域上的输入事件。使用libvlc_video_set_mouse_input()和libvlc_video_set_key_input()禁用该功能,并将事件传递到父窗口/应用程序。根据设计,X11协议只向一个接收者发送输入事件

    在libvlc_new()之前,应用程序必须从Xlib调用XInitThreads()函数,在直接或通过任何其他库调用XOpenDisplay()之前。调用XInitThreads()失败将严重影响LibVLC的性能。在XInitThreads()之前调用XOpenDisplay()最终会导致进程崩溃。这是Xlib的一个限制。

    drawableX11 window ID

    58  LIBVLC_API void libvlc_video_set_callbacks ( libvlc_media_player_t * mp,

    libvlc_video_lock_cb lock,
    libvlc_video_unlock_cb unlock,
    libvlc_video_display_cb display,
    void * opaque
    )

    设置回调和私有数据,将解码视频呈现到内存中的自定义区域。

    使用libvlc_video_set_format()或libvlc_video_set_format_callbacks()配置解码格式。

    将视频渲染到自定义内存缓冲区的效率远远低于在a custom window中正常渲染的效率。

    为了获得最佳性能,VLC media player将渲染到自定义窗口中,并且不使用此函数和相关回调。

    强烈建议其他基于LibVLC的应用程序也这样做,要在窗口中嵌入视频,请根据操作系统使用libvlc_media_player_set_xwindow()或等效工具。

    如果窗口嵌入不适合应用程序用例,则需要一个自定义的LibVLC视频输出显示插件来保持最佳的视频渲染性能。

    以下限制会影响性能:

    Hardware video decoding acceleration will either be disabled completely, or require (relatively slow) copy from video/DSP memory to main memory.
    Sub-pictures (subtitles, on-screen display, etc.) must be blent into the main picture by the CPU instead of the GPU.
    Depending on the video format, pixel format conversion, picture scaling, cropping and/or picture re-orientation, must be performed by the CPU instead of the GPU.
    Memory copying is required between LibVLC reference picture buffers and application buffers (between lock and unlock callbacks).

    硬件视频解码加速将被完全禁用,或者需要(相对较慢)从视频/DSP内存复制到主内存。

    子图片(字幕、屏幕显示等)必须由CPU而不是GPU混合到主图片中。

    根据视频格式,像素格式转换、图片缩放、裁剪和/或图片重新定向必须由CPU而不是GPU执行。

    需要在LibVLC参考图片缓冲区和应用程序缓冲区之间(在锁定和解锁回调之间)进行内存复制。

    Parameters
    mp the media player
    lock callback to lock video memory (must not be NULL)
    unlock callback to unlock video memory (or NULL if not needed)
    display callback to display video (or NULL if not needed)
    opaque private pointer for the three callbacks (as first parameter)

    59   LIBVLC_API void libvlc_video_set_format ( libvlc_media_player_t * mp,

    const char * chroma,
    unsigned width,
    unsigned height,
    unsigned pitch
    )

    设置解码视频的色度和尺寸(维度)。

    This only works in combination with libvlc_video_set_callbacks(), and is mutually exclusive with libvlc_video_set_format_callbacks().

    chroma a four-characters string identifying the chroma (e.g. "RV32" or "YUYV")
    width pixel width
    height pixel height
    pitch line pitch (in bytes)

    60  LIBVLC_API void libvlc_video_set_format_callbacks ( libvlc_media_player_t * mp,

    libvlc_video_format_cb setup,
    libvlc_video_cleanup_cb cleanup
    )

    设置解码视频的色度和尺寸(维度)。

    This only works in combination with libvlc_video_set_callbacks().

    setupcallback to select the video format (cannot be NULL)cleanupcallback to release any allocated resources (or NULL)

    61   LIBVLC_API bool libvlc_video_set_output_callbacks ( libvlc_media_player_t * mp,

    libvlc_video_engine_t engine,
    libvlc_video_output_setup_cb setup_cb,
    libvlc_video_output_cleanup_cb cleanup_cb,
    libvlc_video_output_set_resize_cb resize_cb,
    libvlc_video_update_output_cb update_output_cb,
    libvlc_video_swap_cb swap_cb,
    libvlc_video_makeCurrent_cb makeCurrent_cb,
    libvlc_video_getProcAddress_cb getProcAddress_cb,
    libvlc_video_frameMetadata_cb metadata_cb,
    libvlc_video_output_select_plane_cb select_plane_cb,
    void * opaque
    )

    设置回调和数据以将解码视频渲染为自定义纹理。

    VLC将在自己的线程中以自己的速率执行视频渲染,您需要提供自己的同步机制。

    Parameters
    mp the media player
    engine the GPU engine to use
    setup_cb callback called to initialize user data
    cleanup_cb callback called to clean up user data
    resize_cb callback to set the resize callback
    update_output_cb callback to get the rendering format of the host (cannot be NULL)
    swap_cb callback called after rendering a video frame (cannot be NULL)
    makeCurrent_cb callback called to enter/leave the rendering context (cannot be NULL)
    getProcAddress_cb opengl function loading callback (cannot be NULL for libvlc_video_engine_opengl and for libvlc_video_engine_gles2)
    metadata_cb callback to provide frame metadata (D3D11 only)
    select_plane_cb callback to select different D3D11 rendering targets
    opaque private pointer passed to callbacks

    每次播放时,可能会多次调用setup_cb和cleanup_cb。

    true engine selected and callbacks set

    false engine type unknown, callbacks not set

  • 相关阅读:
    关于 setColorFilter 和 PorterDuff.Mode
    下拉刷新 SwipRefreshLayout
    from athletelist import AthleteList出现红色下滑波浪线警告
    IndentationError: unindent does not match any outer indentation level
    定制数据对象2
    定制数据对象
    数据处理02
    数据处理
    python 工具箱
    嵌套列表的格式打印
  • 原文地址:https://www.cnblogs.com/xpylovely/p/15988701.html
Copyright © 2020-2023  润新知