libEasyPlayer RTSP播放器庫API接口說明

概述
libEasyPlayer實現對RTSP直播流進行實時採集和解碼顯示,穩定,高效,低延時;解碼可採用intel硬件解碼和軟件解碼兩種方式,能實時進行錄像和快照抓圖,OSD疊加等功能。

API接口函數定義
 int EasyPlayer_Init();
函數說明:
播放器初始化,播放器使用之前調用;
參數說明:

 void EasyPlayer_Release();
函數說明:
播放器資源釋放,播放器不再使用以後調用;
參數說明:

int EasyPlayer_OpenStream(const char *url, HWND hWnd, RENDER_FORMAT renderFormat, int rtpovertcp, const char *username, const char *password, MediaSourceCallBack callback, void *userPtr, bool bHardDecode);
函數說明:
播放器開始進行流播放;返回值爲當前播放的通道ID,該ID在停止推流時需要用到;
參數說明:
Url:[IN] 字符串類型,表示當前要播放的流地址,Eg: rtsp://127.0.0.1:554/stream.sdp
HWnd: [IN] 窗口句柄類型,表示爲當前播放器將顯示的窗口的句柄;
renderFormat:[IN] 播放渲染類型,詳見RENDER_FORMAT結構;
Rtpovertcp:[IN] 整數型,拉取流的傳輸模式,0=udp, 1=tcp
Username:[IN] 字符串,訪問流的用戶名(如果存在)
Password:[IN] 字符串,訪問流的用戶名(如果存在)
Callback:[IN] 播放器回調音視頻數據回調函數
userPtr:[IN] 用戶自定義傳入數據
bHardDecode:[IN] 是否採用硬件解碼 1=是,0=否

void EasyPlayer_CloseStream(int channelId);
函數說明:
播放器停止流播放;
參數說明:
channelId [IN] 當前播放的流通道ID,該ID是EasyPlayer_OpenStream函數打開流的返回值;
int EasyPlayer_SetFrameCache(int channelId, int cache);
函數說明:
播放器設置當前流播放緩存幀數;
參數說明:
channelId [IN] 當前播放的流通道ID,該ID是EasyPlayer_OpenStream()函數打開 流的返回值;
cache [IN] 當前通道的流播放設置的緩存的視頻幀數,Eg: 緩存10幀,則cache = 10;

int EasyPlayer_SetShownToScale(int channelId, int shownToScale);
函數說明:
播放器按比例進行顯示;
參數說明:
channelId [IN] 當前播放的流通道ID,該ID是EasyPlayer_OpenStream()函數打開 流的返回值;
shownToScale [IN] 0=整個窗口區域顯示,1=按比例顯示;

int EasyPlayer_SetDecodeType(int channelId, int decodeKeyframeOnly);<不常用>
函數說明:
播放器設置解碼類型;分爲所有幀解碼和只解碼關鍵幀;
參數說明:
channelId [IN] 當前播放的流通道ID,該ID是EasyPlayer_OpenStream()函數打開 流的返回值;
decodeKeyframeOnly [IN] 0=所有幀解碼,1=只解碼關鍵幀;

int EasyPlayer_SetRenderRect(int channelId, LPRECT lpSrcRect);<不常用>
函數說明:設置視頻顯示時渲染區域
參數說明:
channelId [IN] 當前播放的流通道ID,該ID是EasyPlayer_OpenStream函數打開 流的返回值;
lpSrcRect [IN] 矩形框結構體指針,指向設置渲染區域的矩形結構體;

int EasyPlayer_ShowStatisticalInfo(int channelId, int show);
函數說明:
播放器設置是否顯示碼流信息;
參數說明:
channelId [IN] 當前播放的流通道ID,該ID是EasyPlayer_OpenStream()函數打開 流的返回值;
Show [IN] 0=不顯示,1=顯示;

int EasyPlayer_ShowOSD(int channelId, int show, EASY_PALYER_OSD osd);
函數說明:
播放器設置自定義顯示OSD信息;
參數說明:
channelId [IN] 當前播放的流通道ID,該ID是EasyPlayer_OpenStream()函數打開 流的返回值;
Show [IN] 0=不顯示,1=顯示;
Osd [IN] osd顯示信息填充結構,定義如下:
typedef struct tagEASY_PALYER_OSD
{
char stOSD[1024]; //OSD字幕信息
DWORD alpha; //透明通到0-255
DWORD color; //RGB(0xf9,0xf9,0xf9)
DWORD shadowcolor; //OSD背景顏色RGB(0x4d,0x4d,0x4d) 全爲0背景透明
RECT rect; //OSD基於圖像右上角顯示區域
int size; //OSD字體的大小
}EASY_PALYER_OSD;
注意:osd字幕疊加通過”\r\n“結束符進行換行,一行的長度不能超過128個字節,總的OSD疊加不能超過1024個字節。其中OSD大小設置只有D3D渲染模式才能生效;

int EasyPlayer_SetDragStartPoint(int channelId, POINT pt);<不可用>
函數說明:
參數說明:

int EasyPlayer_SetDragEndPoint(int channelId, POINT pt);<不可用>
函數說明:
參數說明:

int EasyPlayer_ResetDragPoint(int channelId);<不可用>
函數說明:
參數說明:

int EasyPlayer_StartManuRecording(int channelId);
函數說明:
播放器開始將流音視頻數據進行錄製,錄製格式爲MP4;
參數說明:
channelId [IN] 當前播放的流通道ID,該ID是EasyPlayer_OpenStream函數打開 流的返回值;

int EasyPlayer_StopManuRecording(int channelId);
函數說明:
播放器停止錄製MP4;
參數說明:
channelId [IN] 當前播放的流通道ID,該ID是EasyPlayer_OpenStream函數打開 流的返回值;

int EasyPlayer_PlaySound(int channelId);
函數說明:
播放器開始播放音頻;
參數說明:
channelId [IN] 當前播放的流通道ID,該ID是EasyPlayer_OpenStream函數打開 流的返回值;

int EasyPlayer_StopSound();
函數說明:
播放器停止播放音頻;

int EasyPlayer_GetMediaInfo(int channelId, MEDIA_INFO& mediaInfo);
函數說明:
播放器獲取流媒體信息;
注意:該函數需要在拉到流信息以後才能準確的返回流媒體信息,否則返回數據均爲空值。
參數說明:
channelId [IN] 當前播放的流通道ID,該ID是EasyPlayer_OpenStream()函數打開 流的返回值;
mediaInfo[OUT] 獲取的媒體信息結構,參考MEDIA_INFO的聲明如下:

typedef struct tagMEDIA_INFO
{
    unsigned int    video_codec;        /* 視頻編碼格式 */
    unsigned char   fps;                /* 視頻幀率 */
    unsigned short  width;              /* 視頻寬 */
    unsigned short  height;             /* 視頻高 */
    unsigned int    audio_codec;        /* 音頻編碼格式 */
    unsigned int    sample_rate;        /* 音頻採樣率 */
    unsigned int    channels;           /* 音頻聲道數 */
    unsigned int    bits_per_sample;    /* 音頻採樣精度 */
    unsigned int    reserved1;          /* 保留參數1 */
    unsigned int    reserved2;          /* 保留參數2 */
}MEDIA_INFO;
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章