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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM