Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Z
ZLMediaKit
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
张翔宇
ZLMediaKit
Commits
6ff01f55
Commit
6ff01f55
authored
Dec 19, 2017
by
xiongziliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加adts头相关接口
parent
68bc9b6a
显示空白字符变更
内嵌
并排
正在显示
12 个修改的文件
包含
148 行增加
和
112 行删除
+148
-112
c_wrapper/src/common.cpp
+14
-12
c_wrapper/src/common.h
+17
-16
c_wrapper/src/httpdownloader.cpp
+3
-3
c_wrapper/src/httpdownloader.h
+4
-4
c_wrapper/src/media.cpp
+21
-6
c_wrapper/src/media.h
+22
-6
c_wrapper/src/player.cpp
+26
-26
c_wrapper/src/player.h
+29
-29
c_wrapper/src/proxyplayer.cpp
+3
-3
c_wrapper/src/proxyplayer.h
+3
-3
src/Device/Device.cpp
+5
-3
src/Device/Device.h
+1
-1
没有找到文件。
c_wrapper/src/common.cpp
查看文件 @
6ff01f55
...
...
@@ -50,7 +50,7 @@ static TcpServer<HttpSession>::Ptr s_pHttpSrv;
//////////////////////////environment init///////////////////////////
API_EXPORT
void
CALLTYPE
onAppStart
(){
API_EXPORT
void
API_CALL
onAppStart
(){
static
onceToken
s_token
([](){
Logger
::
Instance
().
add
(
std
::
make_shared
<
ConsoleChannel
>
(
"stdout"
,
LTrace
));
EventPoller
::
Instance
(
true
);
...
...
@@ -70,11 +70,13 @@ API_EXPORT void CALLTYPE onAppStart(){
}
API_EXPORT
void
CALLTYPE
onAppExit
(){
API_EXPORT
void
API_CALL
onAppExit
(){
cleaner
::
Destory
();
}
API_EXPORT
int
CALLTYPE
initHttpServer
(
unsigned
short
port
){
API_EXPORT
void
API_CALL
setGlobalOptionString
(
const
char
*
key
,
const
char
*
val
){
mINI
::
Instance
()[
key
]
=
val
;
}
API_EXPORT
int
API_CALL
initHttpServer
(
unsigned
short
port
){
s_pHttpSrv
.
reset
(
new
TcpServer
<
HttpSession
>
());
try
{
s_pHttpSrv
->
start
(
port
);
...
...
@@ -85,7 +87,7 @@ API_EXPORT int CALLTYPE initHttpServer(unsigned short port){
return
-
1
;
}
}
API_EXPORT
int
CALLTYPE
initRtspServer
(
unsigned
short
port
)
{
API_EXPORT
int
API_CALL
initRtspServer
(
unsigned
short
port
)
{
s_pRtspSrv
.
reset
(
new
TcpServer
<
RtspSession
>
());
try
{
s_pRtspSrv
->
start
(
port
);
...
...
@@ -97,7 +99,7 @@ API_EXPORT int CALLTYPE initRtspServer(unsigned short port) {
}
}
API_EXPORT
int
CALLTYPE
initRtmpServer
(
unsigned
short
port
)
{
API_EXPORT
int
API_CALL
initRtmpServer
(
unsigned
short
port
)
{
s_pRtmpSrv
.
reset
(
new
TcpServer
<
RtmpSession
>
());
try
{
s_pRtmpSrv
->
start
(
port
);
...
...
@@ -109,7 +111,7 @@ API_EXPORT int CALLTYPE initRtmpServer(unsigned short port) {
}
}
API_EXPORT
void
CALLTYPE
listenEvent_onPlay
(
onEventPlay
cb
,
void
*
userData
){
API_EXPORT
void
API_CALL
listenEvent_onPlay
(
onEventPlay
cb
,
void
*
userData
){
NoticeCenter
::
Instance
().
addListener
((
void
*
)(
cb
),
Config
::
Broadcast
::
kBroadcastRtspSessionPlay
,
[
cb
,
userData
](
BroadcastRtspSessionPlayArgs
){
static
unordered_map
<
string
,
void
*>
s_timerKeyMap
;
...
...
@@ -132,14 +134,14 @@ API_EXPORT void CALLTYPE listenEvent_onPlay(onEventPlay cb,void *userData){
});
}
API_EXPORT
void
CALLTYPE
listenEvent_onRegistRtsp
(
onEventRegistMediaSrc
cb
,
void
*
userData
){
API_EXPORT
void
API_CALL
listenEvent_onRegistRtsp
(
onEventRegistMediaSrc
cb
,
void
*
userData
){
NoticeCenter
::
Instance
().
addListener
((
void
*
)(
cb
),
Config
::
Broadcast
::
kBroadcastRtspSrcRegisted
,
[
cb
,
userData
](
BroadcastRtspSrcRegistedArgs
){
cb
(
userData
,
app
,
stream
);
});
}
API_EXPORT
void
CALLTYPE
listenEvent_onRegistRtmp
(
onEventRegistMediaSrc
cb
,
void
*
userData
){
API_EXPORT
void
API_CALL
listenEvent_onRegistRtmp
(
onEventRegistMediaSrc
cb
,
void
*
userData
){
NoticeCenter
::
Instance
().
addListener
((
void
*
)(
cb
),
Config
::
Broadcast
::
kBroadcastRtmpSrcRegisted
,
[
cb
,
userData
](
BroadcastRtmpSrcRegistedArgs
){
cb
(
userData
,
app
,
stream
);
...
...
@@ -147,7 +149,7 @@ API_EXPORT void CALLTYPE listenEvent_onRegistRtmp(onEventRegistMediaSrc cb,void
}
API_EXPORT
void
CALLTYPE
log_printf
(
LogType
level
,
const
char
*
file
,
const
char
*
function
,
int
line
,
const
char
*
fmt
,...){
API_EXPORT
void
API_CALL
log_printf
(
LogType
level
,
const
char
*
file
,
const
char
*
function
,
int
line
,
const
char
*
fmt
,...){
LogInfoMaker
info
((
LogLevel
)
level
,
file
,
function
,
line
);
va_list
pArg
;
va_start
(
pArg
,
fmt
);
...
...
@@ -157,7 +159,7 @@ API_EXPORT void CALLTYPE log_printf(LogType level,const char* file, const char*
va_end
(
pArg
);
info
<<
buf
;
}
API_EXPORT
void
CALLTYPE
log_setLevel
(
LogType
level
){
API_EXPORT
void
API_CALL
log_setLevel
(
LogType
level
){
Logger
::
Instance
().
setLevel
((
LogLevel
)
level
);
}
...
...
@@ -183,7 +185,7 @@ private:
onLogOut
_cb
=
nullptr
;
};
API_EXPORT
void
CALLTYPE
log_setOnLogOut
(
onLogOut
cb
){
API_EXPORT
void
API_CALL
log_setOnLogOut
(
onLogOut
cb
){
std
::
shared_ptr
<
LogoutChannel
>
chn
(
new
LogoutChannel
(
"LogoutChannel"
,
cb
,
LTrace
));
Logger
::
Instance
().
add
(
chn
);
}
...
...
c_wrapper/src/common.h
查看文件 @
6ff01f55
...
...
@@ -36,10 +36,10 @@
#define API_EXPORT __declspec(dllimport)
#endif
#define
CALLTYPE
__cdecl
#define
API_CALL
__cdecl
#else
#define API_EXPORT
#define
CALLTYPE
#define
API_CALL
#endif
...
...
@@ -50,62 +50,63 @@ extern "C" {
/////////////////////////environment init////////////////////////////////
API_EXPORT
void
CALLTYPE
onAppStart
();
API_EXPORT
void
CALLTYPE
onAppExit
();
API_EXPORT
void
API_CALL
onAppStart
();
API_EXPORT
void
API_CALL
onAppExit
();
API_EXPORT
void
API_CALL
setGlobalOptionString
(
const
char
*
key
,
const
char
*
val
);
/*
* 描述:创建Http服务器
* 参数:port:htt监听端口,推荐80
* 返回值:0:成功;-1:失败
*/
API_EXPORT
int
CALLTYPE
initHttpServer
(
unsigned
short
port
);
API_EXPORT
int
API_CALL
initHttpServer
(
unsigned
short
port
);
/*
* 描述:创建RTSP服务器
* 参数:port:rtsp监听端口,推荐554
* 返回值:0:成功;-1:失败
*/
API_EXPORT
int
CALLTYPE
initRtspServer
(
unsigned
short
port
);
API_EXPORT
int
API_CALL
initRtspServer
(
unsigned
short
port
);
/*
* 描述:创建RTMP服务器
* 参数:port:rtmp监听端口,推荐1935
* 返回值:0:成功;-1:失败
*/
API_EXPORT
int
CALLTYPE
initRtmpServer
(
unsigned
short
port
);
API_EXPORT
int
API_CALL
initRtmpServer
(
unsigned
short
port
);
/*
* 描述:播放事件回调函数定义
* 参数:userData:用户数据指针strApp:应用名,strStream:流名称
*/
typedef
void
(
CALLTYPE
*
onEventPlay
)(
void
*
userData
,
const
char
*
strApp
,
const
char
*
strStream
);
typedef
void
(
API_CALL
*
onEventPlay
)(
void
*
userData
,
const
char
*
strApp
,
const
char
*
strStream
);
/*
* 描述:监听事件
* 参数:cb:回调函数指针,userData:用户数据指针
* 返回值:无
*/
API_EXPORT
void
CALLTYPE
listenEvent_onPlay
(
onEventPlay
cb
,
void
*
userData
);
API_EXPORT
void
API_CALL
listenEvent_onPlay
(
onEventPlay
cb
,
void
*
userData
);
/*
* 描述:注册RTSP事件
* 参数:userData:用户数据指针strApp:应用名,strStream:流名称
*/
typedef
void
(
CALLTYPE
*
onEventRegistMediaSrc
)(
void
*
userData
,
const
char
*
strApp
,
const
char
*
strStream
);
typedef
void
(
API_CALL
*
onEventRegistMediaSrc
)(
void
*
userData
,
const
char
*
strApp
,
const
char
*
strStream
);
/*
* 描述:监听事件
* 参数:cb:回调函数指针,userData:用户数据指针
* 返回值:无
*/
API_EXPORT
void
CALLTYPE
listenEvent_onRegistRtsp
(
onEventRegistMediaSrc
cb
,
void
*
userData
);
API_EXPORT
void
API_CALL
listenEvent_onRegistRtsp
(
onEventRegistMediaSrc
cb
,
void
*
userData
);
/*
* 描述:监听事件
* 参数:cb:回调函数指针,userData:用户数据指针
* 返回值:无
*/
API_EXPORT
void
CALLTYPE
listenEvent_onRegistRtmp
(
onEventRegistMediaSrc
cb
,
void
*
userData
);
API_EXPORT
void
API_CALL
listenEvent_onRegistRtmp
(
onEventRegistMediaSrc
cb
,
void
*
userData
);
/////////////////////////日志////////////////////////////////
...
...
@@ -115,28 +116,28 @@ typedef enum {
LogTrace
=
0
,
LogDebug
,
LogInfo
,
LogWarn
,
LogError
,
LogFatal
,
}
LogType
;
typedef
void
(
CALLTYPE
*
onLogOut
)(
const
char
*
strLog
,
int
iLogLen
);
typedef
void
(
API_CALL
*
onLogOut
)(
const
char
*
strLog
,
int
iLogLen
);
/*
* 描述:设置Log输出回调
* 参数:onLogOut:回调函数
* 返回值:无
*/
API_EXPORT
void
CALLTYPE
log_setOnLogOut
(
onLogOut
);
API_EXPORT
void
API_CALL
log_setOnLogOut
(
onLogOut
);
/*
* 描述:设在日志显示级别
* 参数:level:日志级别
* 返回值:无
*/
API_EXPORT
void
CALLTYPE
log_setLevel
(
LogType
level
);
API_EXPORT
void
API_CALL
log_setLevel
(
LogType
level
);
/*
* 描述:打印日志
* 参数:level:日志级别;file:文件名称,function:函数名称,line:所在行数,fmt:格式化字符串
* 返回值:无
*/
API_EXPORT
void
CALLTYPE
log_printf
(
LogType
level
,
const
char
*
file
,
const
char
*
function
,
int
line
,
const
char
*
fmt
,
...);
API_EXPORT
void
API_CALL
log_printf
(
LogType
level
,
const
char
*
file
,
const
char
*
function
,
int
line
,
const
char
*
fmt
,
...);
#define log_trace(fmt,...) log_printf(LogTrace,__FILE__,__FUNCTION__,__LINE__,fmt,__VA_ARGS__)
...
...
c_wrapper/src/httpdownloader.cpp
查看文件 @
6ff01f55
...
...
@@ -50,13 +50,13 @@ static onceToken s_token([](){
API_EXPORT
HttpDownloaderContex
CALLTYPE
createDownloader
(){
API_EXPORT
HttpDownloaderContex
API_CALL
createDownloader
(){
HttpDownloader
::
Ptr
ret
(
new
HttpDownloader
());
lock_guard
<
recursive_mutex
>
lck
(
s_mtxMapDownloader
);
s_mapDownloader
.
emplace
(
ret
.
get
(),
ret
);
return
ret
.
get
();
}
API_EXPORT
void
CALLTYPE
downloader_startDownload
(
HttpDownloaderContex
ctx
,
const
char
*
url
,
downloader_onResult
cb
,
void
*
userData
){
API_EXPORT
void
API_CALL
downloader_startDownload
(
HttpDownloaderContex
ctx
,
const
char
*
url
,
downloader_onResult
cb
,
void
*
userData
){
HttpDownloader
*
ptr
=
(
HttpDownloader
*
)
ctx
;
string
urlTmp
(
url
);
ptr
->
startDownload
(
url
,
[
cb
,
userData
,
urlTmp
](
int
code
,
const
char
*
errMsg
,
const
char
*
filePath
){
...
...
@@ -66,7 +66,7 @@ API_EXPORT void CALLTYPE downloader_startDownload(HttpDownloaderContex ctx,const
}
});
}
API_EXPORT
void
CALLTYPE
releaseDownloader
(
HttpDownloaderContex
ctx
){
API_EXPORT
void
API_CALL
releaseDownloader
(
HttpDownloaderContex
ctx
){
lock_guard
<
recursive_mutex
>
lck
(
s_mtxMapDownloader
);
s_mapDownloader
.
erase
(
ctx
);
}
...
...
c_wrapper/src/httpdownloader.h
查看文件 @
6ff01f55
...
...
@@ -35,11 +35,11 @@ extern "C" {
////////////////////////////////////////Httpdownloader/////////////////////////////////////////////////
typedef
void
*
HttpDownloaderContex
;
typedef
void
(
CALLTYPE
*
downloader_onResult
)(
void
*
userData
,
int
code
,
const
char
*
errMsg
,
const
char
*
filePath
);
typedef
void
(
API_CALL
*
downloader_onResult
)(
void
*
userData
,
int
code
,
const
char
*
errMsg
,
const
char
*
filePath
);
API_EXPORT
HttpDownloaderContex
CALLTYPE
createDownloader
();
API_EXPORT
void
CALLTYPE
downloader_startDownload
(
HttpDownloaderContex
ctx
,
const
char
*
url
,
downloader_onResult
cb
,
void
*
userData
);
API_EXPORT
void
CALLTYPE
releaseDownloader
(
HttpDownloaderContex
ctx
);
API_EXPORT
HttpDownloaderContex
API_CALL
createDownloader
();
API_EXPORT
void
API_CALL
downloader_startDownload
(
HttpDownloaderContex
ctx
,
const
char
*
url
,
downloader_onResult
cb
,
void
*
userData
);
API_EXPORT
void
API_CALL
releaseDownloader
(
HttpDownloaderContex
ctx
);
#ifdef __cplusplus
...
...
c_wrapper/src/media.cpp
查看文件 @
6ff01f55
...
...
@@ -49,18 +49,18 @@ static onceToken s_token([](){
//////////////////////////Rtsp media///////////////////////////
API_EXPORT
MediaContext
CALLTYPE
createMedia
(
const
char
*
appName
,
const
char
*
mediaName
)
{
API_EXPORT
MediaContext
API_CALL
createMedia
(
const
char
*
appName
,
const
char
*
mediaName
)
{
DevChannel
::
Ptr
ret
(
new
DevChannel
(
appName
,
mediaName
));
lock_guard
<
recursive_mutex
>
lck
(
s_mtxMapMedia
);
s_mapMedia
.
emplace
((
void
*
)
(
ret
.
get
()),
ret
);
return
ret
.
get
();
}
API_EXPORT
void
CALLTYPE
releaseMedia
(
MediaContext
ctx
)
{
API_EXPORT
void
API_CALL
releaseMedia
(
MediaContext
ctx
)
{
lock_guard
<
recursive_mutex
>
lck
(
s_mtxMapMedia
);
s_mapMedia
.
erase
(
ctx
);
}
API_EXPORT
void
CALLTYPE
media_initVideo
(
MediaContext
ctx
,
int
width
,
int
height
,
int
frameRate
)
{
API_EXPORT
void
API_CALL
media_initVideo
(
MediaContext
ctx
,
int
width
,
int
height
,
int
frameRate
)
{
DevChannel
*
ptr
=
(
DevChannel
*
)
ctx
;
VideoInfo
info
;
info
.
iFrameRate
=
frameRate
;
...
...
@@ -68,7 +68,7 @@ API_EXPORT void CALLTYPE media_initVideo(MediaContext ctx, int width, int height
info
.
iHeight
=
height
;
ptr
->
initVideo
(
info
);
}
API_EXPORT
void
CALLTYPE
media_initAudio
(
MediaContext
ctx
,
int
channel
,
int
sampleBit
,
int
sampleRate
)
{
API_EXPORT
void
API_CALL
media_initAudio
(
MediaContext
ctx
,
int
channel
,
int
sampleBit
,
int
sampleRate
)
{
DevChannel
*
ptr
=
(
DevChannel
*
)
ctx
;
AudioInfo
info
;
info
.
iSampleRate
=
sampleRate
;
...
...
@@ -76,15 +76,30 @@ API_EXPORT void CALLTYPE media_initAudio(MediaContext ctx, int channel, int samp
info
.
iSampleBit
=
sampleBit
;
ptr
->
initAudio
(
info
);
}
API_EXPORT
void
CALLTYPE
media_inputH264
(
MediaContext
ctx
,
void
*
data
,
int
len
,
unsigned
long
stamp
)
{
API_EXPORT
void
API_CALL
media_inputH264
(
MediaContext
ctx
,
void
*
data
,
int
len
,
unsigned
long
stamp
)
{
//TimeTicker();
DevChannel
*
ptr
=
(
DevChannel
*
)
ctx
;
ptr
->
inputH264
((
char
*
)
data
,
len
,
stamp
);
}
API_EXPORT
void
CALLTYPE
media_inputAAC
(
MediaContext
ctx
,
void
*
data
,
int
len
,
unsigned
long
stamp
)
{
API_EXPORT
void
API_CALL
media_inputAAC
(
MediaContext
ctx
,
void
*
data
,
int
len
,
unsigned
long
stamp
)
{
//TimeTicker();
DevChannel
*
ptr
=
(
DevChannel
*
)
ctx
;
ptr
->
inputAAC
((
char
*
)
data
,
len
,
stamp
);
}
API_EXPORT
void
API_CALL
media_inputAAC1
(
MediaContext
ctx
,
void
*
data
,
int
len
,
unsigned
long
stamp
,
void
*
adts
){
DevChannel
*
ptr
=
(
DevChannel
*
)
ctx
;
ptr
->
inputAAC
((
char
*
)
data
,
len
,
stamp
,(
char
*
)
adts
);
}
API_EXPORT
void
API_CALL
media_inputAAC2
(
MediaContext
ctx
,
void
*
data
,
int
len
,
unsigned
long
stamp
,
void
*
aac_cfg
){
DevChannel
*
ptr
=
(
DevChannel
*
)
ctx
;
AdtsFrame
frame
;
makeAdtsHeader
((
char
*
)
aac_cfg
,
frame
);
char
adts
[
8
];
writeAdtsHeader
(
frame
,
(
uint8_t
*
)
adts
);
ptr
->
inputAAC
((
char
*
)
data
,
len
,
stamp
,(
char
*
)
adts
);
}
c_wrapper/src/media.h
查看文件 @
6ff01f55
...
...
@@ -42,42 +42,58 @@ typedef void* MediaContext;
* 参数:mediaName:媒体名称,url地址的一部分
* 返回值:媒体源句柄
*/
API_EXPORT
MediaContext
CALLTYPE
createMedia
(
const
char
*
appName
,
const
char
*
mediaName
);
API_EXPORT
MediaContext
API_CALL
createMedia
(
const
char
*
appName
,
const
char
*
mediaName
);
/*
* 描述:销毁媒体源
* 参数:ctx:媒体源句柄
* 返回值:无
*/
API_EXPORT
void
CALLTYPE
releaseMedia
(
MediaContext
ctx
);
API_EXPORT
void
API_CALL
releaseMedia
(
MediaContext
ctx
);
/*
* 描述:初始化媒体源的视频信息
* 参数:ctx:媒体源句柄;width:视频宽度;height:视频高度;frameRate:视频fps
* 返回值:无
*/
API_EXPORT
void
CALLTYPE
media_initVideo
(
MediaContext
ctx
,
int
width
,
int
height
,
int
frameRate
);
API_EXPORT
void
API_CALL
media_initVideo
(
MediaContext
ctx
,
int
width
,
int
height
,
int
frameRate
);
/*
* 描述:初始化媒体源的音频信息
* 参数:ctx:媒体源句柄;channel:声道数;sampleBit:音频采样位数,支持16bit;sampleRate:音频采样率
* 返回值:无
*/
API_EXPORT
void
CALLTYPE
media_initAudio
(
MediaContext
ctx
,
int
channel
,
int
sampleBit
,
int
sampleRate
);
API_EXPORT
void
API_CALL
media_initAudio
(
MediaContext
ctx
,
int
channel
,
int
sampleBit
,
int
sampleRate
);
/*
* 描述:输入单帧H264视频,需要输入SPS和PPS帧,帧起始字节00 00 01,00 00 00 01均可
* 参数:ctx:媒体源句柄;data:单帧H264数据;len:单帧H264数据字节数;stamp:时间戳,毫秒
* 返回值:无
*/
API_EXPORT
void
CALLTYPE
media_inputH264
(
MediaContext
ctx
,
void
*
data
,
int
len
,
unsigned
long
stamp
);
API_EXPORT
void
API_CALL
media_inputH264
(
MediaContext
ctx
,
void
*
data
,
int
len
,
unsigned
long
stamp
);
/*
* 描述:输入单帧AAC音频(有adts头)
* 参数:ctx:媒体源句柄;data:单帧AAC数据;len:单帧AAC数据字节数;stamp:时间戳,毫秒
* 返回值:无
*/
API_EXPORT
void
CALLTYPE
media_inputAAC
(
MediaContext
ctx
,
void
*
data
,
int
len
,
unsigned
long
stamp
);
API_EXPORT
void
API_CALL
media_inputAAC
(
MediaContext
ctx
,
void
*
data
,
int
len
,
unsigned
long
stamp
);
/*
* 描述:输入单帧AAC音频(单独指定adts头)
* 参数:ctx:媒体源句柄;data:单帧AAC数据;len:单帧AAC数据字节数;stamp:时间戳,毫秒;adts:adts头指针
* 返回值:无
*/
API_EXPORT
void
API_CALL
media_inputAAC1
(
MediaContext
ctx
,
void
*
data
,
int
len
,
unsigned
long
stamp
,
void
*
adts
);
/*
* 描述:输入单帧AAC音频(指定2个字节的aac配置)
* 参数:ctx:媒体源句柄;data:单帧AAC数据;len:单帧AAC数据字节数;stamp:时间戳,毫秒;adts:adts头指针;aac_cfg:aac配置
* 返回值:无
*/
API_EXPORT
void
API_CALL
media_inputAAC2
(
MediaContext
ctx
,
void
*
data
,
int
len
,
unsigned
long
stamp
,
void
*
aac_cfg
);
#ifdef __cplusplus
...
...
c_wrapper/src/player.cpp
查看文件 @
6ff01f55
...
...
@@ -63,7 +63,7 @@ static onceToken s_token([](){
player = it->second;\
}\
}
API_EXPORT
PlayerContext
CALLTYPE
createPlayer
()
{
API_EXPORT
PlayerContext
API_CALL
createPlayer
()
{
lock_guard
<
recursive_mutex
>
lck
(
s_mtxMapPlayer
);
MediaPlayer
::
Ptr
ret
(
new
MediaPlayer
());
s_mapPlayer
.
emplace
(
ret
.
get
(),
ret
);
...
...
@@ -72,7 +72,7 @@ API_EXPORT PlayerContext CALLTYPE createPlayer() {
}
return
ret
.
get
();
}
API_EXPORT
void
CALLTYPE
releasePlayer
(
PlayerContext
ctx
)
{
API_EXPORT
void
API_CALL
releasePlayer
(
PlayerContext
ctx
)
{
getPlayer
(
ctx
);
if
(
!
player
)
{
return
;
...
...
@@ -90,7 +90,7 @@ API_EXPORT void CALLTYPE releasePlayer(PlayerContext ctx) {
});
}
API_EXPORT
void
CALLTYPE
player_setOptionInt
(
PlayerContext
ctx
,
const
char
*
key
,
int
val
){
API_EXPORT
void
API_CALL
player_setOptionInt
(
PlayerContext
ctx
,
const
char
*
key
,
int
val
){
string
keyTmp
(
key
);
ASYNC_TRACE
([
ctx
,
keyTmp
,
val
](){
getPlayer
(
ctx
);
...
...
@@ -100,7 +100,7 @@ API_EXPORT void CALLTYPE player_setOptionInt(PlayerContext ctx,const char* key,i
(
*
player
)[
keyTmp
]
=
val
;
});
}
API_EXPORT
void
CALLTYPE
player_setOptionString
(
PlayerContext
ctx
,
const
char
*
key
,
const
char
*
val
){
API_EXPORT
void
API_CALL
player_setOptionString
(
PlayerContext
ctx
,
const
char
*
key
,
const
char
*
val
){
string
keyTmp
(
key
);
string
valTmp
(
val
);
ASYNC_TRACE
([
ctx
,
keyTmp
,
valTmp
](){
...
...
@@ -111,7 +111,7 @@ API_EXPORT void CALLTYPE player_setOptionString(PlayerContext ctx,const char* ke
(
*
player
)[
keyTmp
]
=
valTmp
;
});
}
API_EXPORT
void
CALLTYPE
player_play
(
PlayerContext
ctx
,
const
char
*
url
)
{
API_EXPORT
void
API_CALL
player_play
(
PlayerContext
ctx
,
const
char
*
url
)
{
string
urlTmp
(
url
);
ASYNC_TRACE
([
ctx
,
urlTmp
](){
getPlayer
(
ctx
);
...
...
@@ -122,7 +122,7 @@ API_EXPORT void CALLTYPE player_play(PlayerContext ctx, const char* url) {
});
}
API_EXPORT
void
CALLTYPE
player_pause
(
PlayerContext
ctx
,
int
pause
)
{
API_EXPORT
void
API_CALL
player_pause
(
PlayerContext
ctx
,
int
pause
)
{
ASYNC_TRACE
([
ctx
,
pause
](){
getPlayer
(
ctx
);
if
(
!
player
)
{
...
...
@@ -132,7 +132,7 @@ API_EXPORT void CALLTYPE player_pause(PlayerContext ctx, int pause) {
});
}
API_EXPORT
void
CALLTYPE
player_seekTo
(
PlayerContext
ctx
,
float
fProgress
)
{
API_EXPORT
void
API_CALL
player_seekTo
(
PlayerContext
ctx
,
float
fProgress
)
{
ASYNC_TRACE
([
ctx
,
fProgress
]()
{
getPlayer
(
ctx
);
if
(
!
player
)
{
...
...
@@ -141,7 +141,7 @@ API_EXPORT void CALLTYPE player_seekTo(PlayerContext ctx, float fProgress) {
return
player
->
seekTo
(
fProgress
);
});
}
API_EXPORT
void
CALLTYPE
player_setOnShutdown
(
PlayerContext
ctx
,
player_onResult
cb
,
void
*
userData
)
{
API_EXPORT
void
API_CALL
player_setOnShutdown
(
PlayerContext
ctx
,
player_onResult
cb
,
void
*
userData
)
{
getPlayer
(
ctx
);
if
(
!
player
)
{
return
;
...
...
@@ -159,7 +159,7 @@ API_EXPORT void CALLTYPE player_setOnShutdown(PlayerContext ctx, player_onResult
}
}
API_EXPORT
void
CALLTYPE
player_setOnPlayResult
(
PlayerContext
ctx
,
player_onResult
cb
,
void
*
userData
)
{
API_EXPORT
void
API_CALL
player_setOnPlayResult
(
PlayerContext
ctx
,
player_onResult
cb
,
void
*
userData
)
{
getPlayer
(
ctx
);
if
(
!
player
)
{
return
;
...
...
@@ -177,7 +177,7 @@ API_EXPORT void CALLTYPE player_setOnPlayResult(PlayerContext ctx, player_onResu
}
}
API_EXPORT
void
CALLTYPE
player_setOnGetVideo
(
PlayerContext
ctx
,
player_onGetH264
cb
,
API_EXPORT
void
API_CALL
player_setOnGetVideo
(
PlayerContext
ctx
,
player_onGetH264
cb
,
void
*
userData
)
{
getPlayer
(
ctx
);
if
(
!
player
)
{
...
...
@@ -198,7 +198,7 @@ API_EXPORT void CALLTYPE player_setOnGetVideo(PlayerContext ctx, player_onGetH26
}
}
API_EXPORT
void
CALLTYPE
player_setOnGetAudio
(
PlayerContext
ctx
,
player_onGetAAC
cb
,
API_EXPORT
void
API_CALL
player_setOnGetAudio
(
PlayerContext
ctx
,
player_onGetAAC
cb
,
void
*
userData
)
{
getPlayer
(
ctx
);
if
(
!
player
)
{
...
...
@@ -217,7 +217,7 @@ API_EXPORT void CALLTYPE player_setOnGetAudio(PlayerContext ctx, player_onGetAAC
}
}
API_EXPORT
int
CALLTYPE
player_getVideoWidth
(
PlayerContext
ctx
)
{
API_EXPORT
int
API_CALL
player_getVideoWidth
(
PlayerContext
ctx
)
{
getPlayer
(
ctx
);
if
(
!
player
)
{
return
-
1
;
...
...
@@ -225,7 +225,7 @@ API_EXPORT int CALLTYPE player_getVideoWidth(PlayerContext ctx) {
return
player
->
getVideoWidth
();
}
API_EXPORT
int
CALLTYPE
player_getVideoHeight
(
PlayerContext
ctx
)
{
API_EXPORT
int
API_CALL
player_getVideoHeight
(
PlayerContext
ctx
)
{
getPlayer
(
ctx
);
if
(
!
player
)
{
return
-
1
;
...
...
@@ -233,7 +233,7 @@ API_EXPORT int CALLTYPE player_getVideoHeight(PlayerContext ctx) {
return
player
->
getVideoHeight
();
}
API_EXPORT
int
CALLTYPE
player_getVideoFps
(
PlayerContext
ctx
)
{
API_EXPORT
int
API_CALL
player_getVideoFps
(
PlayerContext
ctx
)
{
getPlayer
(
ctx
);
if
(
!
player
)
{
return
-
1
;
...
...
@@ -241,7 +241,7 @@ API_EXPORT int CALLTYPE player_getVideoFps(PlayerContext ctx) {
return
player
->
getVideoFps
();
}
API_EXPORT
int
CALLTYPE
player_getAudioSampleRate
(
PlayerContext
ctx
)
{
API_EXPORT
int
API_CALL
player_getAudioSampleRate
(
PlayerContext
ctx
)
{
getPlayer
(
ctx
);
if
(
!
player
)
{
return
-
1
;
...
...
@@ -249,7 +249,7 @@ API_EXPORT int CALLTYPE player_getAudioSampleRate(PlayerContext ctx) {
return
player
->
getAudioSampleRate
();
}
API_EXPORT
int
CALLTYPE
player_getAudioSampleBit
(
PlayerContext
ctx
)
{
API_EXPORT
int
API_CALL
player_getAudioSampleBit
(
PlayerContext
ctx
)
{
getPlayer
(
ctx
);
if
(
!
player
)
{
return
-
1
;
...
...
@@ -257,7 +257,7 @@ API_EXPORT int CALLTYPE player_getAudioSampleBit(PlayerContext ctx) {
return
player
->
getAudioSampleBit
();
}
API_EXPORT
int
CALLTYPE
player_getAudioChannel
(
PlayerContext
ctx
)
{
API_EXPORT
int
API_CALL
player_getAudioChannel
(
PlayerContext
ctx
)
{
getPlayer
(
ctx
);
if
(
!
player
)
{
return
-
1
;
...
...
@@ -265,7 +265,7 @@ API_EXPORT int CALLTYPE player_getAudioChannel(PlayerContext ctx) {
return
player
->
getAudioChannel
();
}
API_EXPORT
int
CALLTYPE
player_getH264PPS
(
PlayerContext
ctx
,
char
*
buf
,
int
bufsize
)
{
API_EXPORT
int
API_CALL
player_getH264PPS
(
PlayerContext
ctx
,
char
*
buf
,
int
bufsize
)
{
getPlayer
(
ctx
);
if
(
!
player
)
{
return
-
1
;
...
...
@@ -276,7 +276,7 @@ API_EXPORT int CALLTYPE player_getH264PPS(PlayerContext ctx, char *buf, int bufs
memcpy
(
buf
,
player
->
getPps
().
data
(),
player
->
getPps
().
size
());
return
player
->
getPps
().
size
();
}
API_EXPORT
int
CALLTYPE
player_getH264SPS
(
PlayerContext
ctx
,
char
*
buf
,
int
bufsize
)
{
API_EXPORT
int
API_CALL
player_getH264SPS
(
PlayerContext
ctx
,
char
*
buf
,
int
bufsize
)
{
getPlayer
(
ctx
);
if
(
!
player
)
{
return
-
1
;
...
...
@@ -288,7 +288,7 @@ API_EXPORT int CALLTYPE player_getH264SPS(PlayerContext ctx, char *buf, int bufs
return
player
->
getSps
().
size
();
}
API_EXPORT
int
CALLTYPE
player_getAacCfg
(
PlayerContext
ctx
,
char
*
buf
,
int
bufsize
)
{
API_EXPORT
int
API_CALL
player_getAacCfg
(
PlayerContext
ctx
,
char
*
buf
,
int
bufsize
)
{
getPlayer
(
ctx
);
if
(
!
player
)
{
return
-
1
;
...
...
@@ -300,7 +300,7 @@ API_EXPORT int CALLTYPE player_getAacCfg(PlayerContext ctx, char *buf, int bufsi
return
player
->
getAudioCfg
().
size
();
}
API_EXPORT
int
CALLTYPE
player_containAudio
(
PlayerContext
ctx
)
{
API_EXPORT
int
API_CALL
player_containAudio
(
PlayerContext
ctx
)
{
getPlayer
(
ctx
);
if
(
!
player
)
{
return
-
1
;
...
...
@@ -308,7 +308,7 @@ API_EXPORT int CALLTYPE player_containAudio(PlayerContext ctx) {
return
player
->
containAudio
();
}
API_EXPORT
int
CALLTYPE
player_containVideo
(
PlayerContext
ctx
)
{
API_EXPORT
int
API_CALL
player_containVideo
(
PlayerContext
ctx
)
{
getPlayer
(
ctx
);
if
(
!
player
)
{
return
-
1
;
...
...
@@ -316,14 +316,14 @@ API_EXPORT int CALLTYPE player_containVideo(PlayerContext ctx) {
return
player
->
containVideo
();
}
API_EXPORT
int
CALLTYPE
player_isInited
(
PlayerContext
ctx
)
{
API_EXPORT
int
API_CALL
player_isInited
(
PlayerContext
ctx
)
{
getPlayer
(
ctx
);
if
(
!
player
)
{
return
-
1
;
}
return
player
->
isInited
();
}
API_EXPORT
float
CALLTYPE
player_getDuration
(
PlayerContext
ctx
)
{
API_EXPORT
float
API_CALL
player_getDuration
(
PlayerContext
ctx
)
{
getPlayer
(
ctx
);
if
(
!
player
)
{
return
-
1
;
...
...
@@ -331,7 +331,7 @@ API_EXPORT float CALLTYPE player_getDuration(PlayerContext ctx) {
return
player
->
getDuration
();
}
API_EXPORT
float
CALLTYPE
player_getProgress
(
PlayerContext
ctx
)
{
API_EXPORT
float
API_CALL
player_getProgress
(
PlayerContext
ctx
)
{
getPlayer
(
ctx
);
if
(
!
player
)
{
return
-
1
;
...
...
@@ -339,7 +339,7 @@ API_EXPORT float CALLTYPE player_getProgress(PlayerContext ctx) {
return
player
->
getProgress
();
}
API_EXPORT
float
CALLTYPE
player_getLossRate
(
PlayerContext
ctx
,
int
trackId
)
{
API_EXPORT
float
API_CALL
player_getLossRate
(
PlayerContext
ctx
,
int
trackId
)
{
getPlayer
(
ctx
);
if
(
!
player
)
{
return
-
1
;
...
...
c_wrapper/src/player.h
查看文件 @
6ff01f55
...
...
@@ -36,22 +36,22 @@ extern "C" {
////////////////////////////////////////RTSP Player/////////////////////////////////////////////////
typedef
void
*
PlayerContext
;
typedef
void
(
CALLTYPE
*
player_onResult
)(
void
*
userData
,
int
errCode
,
const
char
*
errMsg
);
typedef
void
(
CALLTYPE
*
player_onGetAAC
)(
void
*
userData
,
void
*
data
,
int
len
,
unsigned
long
timeStamp
);
typedef
void
(
CALLTYPE
*
player_onGetH264
)(
void
*
userData
,
void
*
data
,
int
len
,
unsigned
long
dts
,
unsigned
long
pts
);
typedef
void
(
API_CALL
*
player_onResult
)(
void
*
userData
,
int
errCode
,
const
char
*
errMsg
);
typedef
void
(
API_CALL
*
player_onGetAAC
)(
void
*
userData
,
void
*
data
,
int
len
,
unsigned
long
timeStamp
);
typedef
void
(
API_CALL
*
player_onGetH264
)(
void
*
userData
,
void
*
data
,
int
len
,
unsigned
long
dts
,
unsigned
long
pts
);
/*
* 描述:创建一个Rtsp播放器
* 参数:无
* 返回值:Rtsp播放器句柄
*/
API_EXPORT
PlayerContext
CALLTYPE
createPlayer
();
API_EXPORT
PlayerContext
API_CALL
createPlayer
();
/*
* 描述:销毁一个播放器
* 参数:ctx:播放器句柄
* 返回值:无
*/
API_EXPORT
void
CALLTYPE
releasePlayer
(
PlayerContext
ctx
);
API_EXPORT
void
API_CALL
releasePlayer
(
PlayerContext
ctx
);
/*
...
...
@@ -61,8 +61,8 @@ API_EXPORT void CALLTYPE releasePlayer(PlayerContext ctx);
* val:值,例如 //设置rtp传输类型,可选项有0(tcp,默认)、1(udp)、2(组播)
* 返回值:无
*/
API_EXPORT
void
CALLTYPE
player_setOptionInt
(
PlayerContext
ctx
,
const
char
*
key
,
int
val
);
API_EXPORT
void
CALLTYPE
player_setOptionString
(
PlayerContext
ctx
,
const
char
*
key
,
const
char
*
val
);
API_EXPORT
void
API_CALL
player_setOptionInt
(
PlayerContext
ctx
,
const
char
*
key
,
int
val
);
API_EXPORT
void
API_CALL
player_setOptionString
(
PlayerContext
ctx
,
const
char
*
key
,
const
char
*
val
);
/*
...
...
@@ -71,35 +71,35 @@ API_EXPORT void CALLTYPE player_setOptionString(PlayerContext ctx,const char* ke
* url:rtsp链接
* 返回值:无
*/
API_EXPORT
void
CALLTYPE
player_play
(
PlayerContext
ctx
,
const
char
*
url
);
API_EXPORT
void
API_CALL
player_play
(
PlayerContext
ctx
,
const
char
*
url
);
/*
* 描述:暂停播放RTSP
* 参数:ctx:播放器句柄;pause:1:暂停播放,0:恢复播放
* 返回值:无
*/
API_EXPORT
void
CALLTYPE
player_pause
(
PlayerContext
ctx
,
int
pause
);
API_EXPORT
void
API_CALL
player_pause
(
PlayerContext
ctx
,
int
pause
);
/*
* 描述:设置播放器异常停止回调函数
* 参数:ctx:播放器句柄;cb:回调函数指针;userData:用户数据指针
* 返回值:无
*/
API_EXPORT
void
CALLTYPE
player_setOnShutdown
(
PlayerContext
ctx
,
player_onResult
cb
,
void
*
userData
);
API_EXPORT
void
API_CALL
player_setOnShutdown
(
PlayerContext
ctx
,
player_onResult
cb
,
void
*
userData
);
/*
* 描述:设置播放器播放结果回调函数
* 参数:ctx:播放器句柄,cb:回调函数指针;userData:用户数据指针
* 返回值:无
*/
API_EXPORT
void
CALLTYPE
player_setOnPlayResult
(
PlayerContext
ctx
,
player_onResult
cb
,
void
*
userData
);
API_EXPORT
void
API_CALL
player_setOnPlayResult
(
PlayerContext
ctx
,
player_onResult
cb
,
void
*
userData
);
/*
* 描述:设置播放器收到视频帧回调,I帧前为SPS,PPS帧;每帧包含00 00 00 01的帧头
* 参数:ctx:播放器句柄,cb:回调函数指针;userData:用户数据指针
* 返回值:无
*/
API_EXPORT
void
CALLTYPE
player_setOnGetVideo
(
PlayerContext
ctx
,
player_onGetH264
cb
,
void
*
userData
);
API_EXPORT
void
API_CALL
player_setOnGetVideo
(
PlayerContext
ctx
,
player_onGetH264
cb
,
void
*
userData
);
/*
...
...
@@ -107,49 +107,49 @@ API_EXPORT void CALLTYPE player_setOnGetVideo(PlayerContext ctx,player_onGetH264
* 参数:ctx:播放器句柄,cb:回调函数指针;userData:用户数据指针
* 返回值:无
*/
API_EXPORT
void
CALLTYPE
player_setOnGetAudio
(
PlayerContext
ctx
,
player_onGetAAC
cb
,
void
*
userData
);
API_EXPORT
void
API_CALL
player_setOnGetAudio
(
PlayerContext
ctx
,
player_onGetAAC
cb
,
void
*
userData
);
/*
* 描述:获取视频宽度
* 参数:ctx:播放器句柄
* 返回值:视频宽度
*/
API_EXPORT
int
CALLTYPE
player_getVideoWidth
(
PlayerContext
ctx
);
API_EXPORT
int
API_CALL
player_getVideoWidth
(
PlayerContext
ctx
);
/*
* 描述:获取视频高度
* 参数:ctx:播放器句柄
* 返回值:视频高度
*/
API_EXPORT
int
CALLTYPE
CALLTYPE
player_getVideoHeight
(
PlayerContext
ctx
);
API_EXPORT
int
API_CALL
API_CALL
player_getVideoHeight
(
PlayerContext
ctx
);
/*
* 描述:获取视频帧率
* 参数:ctx:播放器句柄
* 返回值:视频帧率
*/
API_EXPORT
int
CALLTYPE
player_getVideoFps
(
PlayerContext
ctx
);
API_EXPORT
int
API_CALL
player_getVideoFps
(
PlayerContext
ctx
);
/*
* 描述:获取音频采样率
* 参数:ctx:播放器句柄
* 返回值:音频采样率
*/
API_EXPORT
int
CALLTYPE
player_getAudioSampleRate
(
PlayerContext
ctx
);
API_EXPORT
int
API_CALL
player_getAudioSampleRate
(
PlayerContext
ctx
);
/*
* 描述:获取音频采样位数(8bit或16bit)
* 参数:ctx:播放器句柄
* 返回值:音频采样位数
*/
API_EXPORT
int
CALLTYPE
player_getAudioSampleBit
(
PlayerContext
ctx
);
API_EXPORT
int
API_CALL
player_getAudioSampleBit
(
PlayerContext
ctx
);
/*
* 描述:获取音频通道数(单声道1,双声道2)
* 参数:ctx:播放器句柄
* 返回值:音频通道数
*/
API_EXPORT
int
CALLTYPE
player_getAudioChannel
(
PlayerContext
ctx
);
API_EXPORT
int
API_CALL
player_getAudioChannel
(
PlayerContext
ctx
);
/*
...
...
@@ -157,7 +157,7 @@ API_EXPORT int CALLTYPE player_getAudioChannel(PlayerContext ctx);
* 参数:ctx:播放器句柄,buf:存放PPS数据的缓存;bufsize:缓存大小
* 返回值:帧数据长度
*/
API_EXPORT
int
CALLTYPE
player_getH264PPS
(
PlayerContext
ctx
,
char
*
buf
,
int
bufsize
);
API_EXPORT
int
API_CALL
player_getH264PPS
(
PlayerContext
ctx
,
char
*
buf
,
int
bufsize
);
/*
...
...
@@ -165,7 +165,7 @@ API_EXPORT int CALLTYPE player_getH264PPS(PlayerContext ctx,char *buf,int bufsiz
* 参数:ctx:播放器句柄,buf:存放SPS数据的缓存;bufsize:缓存大小
* 返回值:帧数据长度
*/
API_EXPORT
int
CALLTYPE
player_getH264SPS
(
PlayerContext
ctx
,
char
*
buf
,
int
bufsize
);
API_EXPORT
int
API_CALL
player_getH264SPS
(
PlayerContext
ctx
,
char
*
buf
,
int
bufsize
);
/*
...
...
@@ -173,7 +173,7 @@ API_EXPORT int CALLTYPE player_getH264SPS(PlayerContext ctx,char *buf,int bufsiz
* 参数:ctx:播放器句柄;buf:存放CFG数据的缓存;bufsize:缓存大小
* 返回值:CFG数据长度
*/
API_EXPORT
int
CALLTYPE
player_getAacCfg
(
PlayerContext
ctx
,
char
*
buf
,
int
bufsize
);
API_EXPORT
int
API_CALL
player_getAacCfg
(
PlayerContext
ctx
,
char
*
buf
,
int
bufsize
);
/*
...
...
@@ -181,7 +181,7 @@ API_EXPORT int CALLTYPE player_getAacCfg(PlayerContext ctx,char *buf,int bufsize
* 参数:ctx:播放器句柄
* 返回值:1:包含,0:不包含
*/
API_EXPORT
int
CALLTYPE
player_containAudio
(
PlayerContext
ctx
);
API_EXPORT
int
API_CALL
player_containAudio
(
PlayerContext
ctx
);
/*
...
...
@@ -189,7 +189,7 @@ API_EXPORT int CALLTYPE player_containAudio(PlayerContext ctx);
* 参数:ctx:播放器句柄
* 返回值:1:包含,0:不包含
*/
API_EXPORT
int
CALLTYPE
player_containVideo
(
PlayerContext
ctx
);
API_EXPORT
int
API_CALL
player_containVideo
(
PlayerContext
ctx
);
/*
...
...
@@ -197,35 +197,35 @@ API_EXPORT int CALLTYPE player_containVideo(PlayerContext ctx);
* 参数:ctx:播放器句柄
* 返回值:1:初始化完成,0:未完成
*/
API_EXPORT
int
CALLTYPE
player_isInited
(
PlayerContext
ctx
);
API_EXPORT
int
API_CALL
player_isInited
(
PlayerContext
ctx
);
/*
* 描述:获取点播的时间长度,单位为秒(小于等于0,说明是直播,否则为点播)
* 参数:ctx:播放器句柄
* 返回值:点播的时间长度,单位秒
*/
API_EXPORT
float
CALLTYPE
player_getDuration
(
PlayerContext
ctx
);
API_EXPORT
float
API_CALL
player_getDuration
(
PlayerContext
ctx
);
/*
* 描述:获取点播播放进度
* 参数:ctx:播放器句柄
* 返回值:点播播放进度,取值范围未 0.0~1.0
*/
API_EXPORT
float
CALLTYPE
player_getProgress
(
PlayerContext
ctx
);
API_EXPORT
float
API_CALL
player_getProgress
(
PlayerContext
ctx
);
/*
* 描述:设置点播播放进度
* 参数:ctx:播放器句柄;fProgress:播放进度,取值范围未 0.0~1.0
* 返回值:无
*/
API_EXPORT
void
CALLTYPE
player_seekTo
(
PlayerContext
ctx
,
float
fProgress
);
API_EXPORT
void
API_CALL
player_seekTo
(
PlayerContext
ctx
,
float
fProgress
);
/*
* 描述:获取丢包率
* 参数:ctx:播放器句柄;trackId:如果是-1,则返回总丢包率,否则返回视频或者音频的丢包率
* 返回值:丢包率
*/
API_EXPORT
float
CALLTYPE
player_getLossRate
(
PlayerContext
ctx
,
int
trackId
);
API_EXPORT
float
API_CALL
player_getLossRate
(
PlayerContext
ctx
,
int
trackId
);
#ifdef __cplusplus
...
...
c_wrapper/src/proxyplayer.cpp
查看文件 @
6ff01f55
...
...
@@ -42,7 +42,7 @@ static onceToken s_token([](){
});
},
nullptr
);
API_EXPORT
ProxyPlayerContext
CALLTYPE
createProxyPlayer
(
const
char
*
app
,
const
char
*
stream
,
int
rtp_type
){
API_EXPORT
ProxyPlayerContext
API_CALL
createProxyPlayer
(
const
char
*
app
,
const
char
*
stream
,
int
rtp_type
){
PlayerProxy
::
Ptr
ret
(
new
PlayerProxy
(
app
,
stream
));
(
*
ret
)[
RtspPlayer
::
kRtpType
]
=
rtp_type
;
...
...
@@ -50,11 +50,11 @@ API_EXPORT ProxyPlayerContext CALLTYPE createProxyPlayer(const char *app,const c
s_mapProxyPlayer
.
emplace
(
ret
.
get
(),
ret
);
return
ret
.
get
();
}
API_EXPORT
void
CALLTYPE
releaseProxyPlayer
(
ProxyPlayerContext
ctx
){
API_EXPORT
void
API_CALL
releaseProxyPlayer
(
ProxyPlayerContext
ctx
){
lock_guard
<
recursive_mutex
>
lck
(
s_mtxMapProxyPlayer
);
s_mapProxyPlayer
.
erase
(
ctx
);
}
API_EXPORT
void
CALLTYPE
proxyPlayer_play
(
ProxyPlayerContext
ctx
,
const
char
*
url
){
API_EXPORT
void
API_CALL
proxyPlayer_play
(
ProxyPlayerContext
ctx
,
const
char
*
url
){
PlayerProxy
*
ptr
=
(
PlayerProxy
*
)
ctx
;
ptr
->
play
(
url
);
}
c_wrapper/src/proxyplayer.h
查看文件 @
6ff01f55
...
...
@@ -42,14 +42,14 @@ typedef void* ProxyPlayerContext;
* rtp_type:如果播放的是rtsp连接则通过该参数配置设置rtp传输方式:RTP_TCP = 0, RTP_UDP = 1, RTP_MULTICAST = 2
* 返回值:代理播放器句柄
*/
API_EXPORT
ProxyPlayerContext
CALLTYPE
createProxyPlayer
(
const
char
*
app
,
const
char
*
stream
,
int
rtp_type
);
API_EXPORT
ProxyPlayerContext
API_CALL
createProxyPlayer
(
const
char
*
app
,
const
char
*
stream
,
int
rtp_type
);
/*
* 描述:销毁代理播放器
* 参数:ctx:代理播放器句柄
* 返回值:无
*/
API_EXPORT
void
CALLTYPE
releaseProxyPlayer
(
ProxyPlayerContext
ctx
);
API_EXPORT
void
API_CALL
releaseProxyPlayer
(
ProxyPlayerContext
ctx
);
/*
...
...
@@ -57,7 +57,7 @@ API_EXPORT void CALLTYPE releaseProxyPlayer(ProxyPlayerContext ctx);
* 参数:url:rtsp/rtmp连接
* 返回值:无
*/
API_EXPORT
void
CALLTYPE
proxyPlayer_play
(
ProxyPlayerContext
ctx
,
const
char
*
url
);
API_EXPORT
void
API_CALL
proxyPlayer_play
(
ProxyPlayerContext
ctx
,
const
char
*
url
);
#ifdef __cplusplus
...
...
src/Device/Device.cpp
查看文件 @
6ff01f55
...
...
@@ -138,10 +138,12 @@ void DevChannel::inputAAC(char *pcDataWithoutAdts,int iDataLen, uint32_t uiStamp
static
uint32_t
audioMtu
=
mINI
::
Instance
()[
Config
::
Rtp
::
kAudioMtuSize
].
as
<
uint32_t
>
();
m_pRtpMaker_aac
.
reset
(
new
RtpMaker_AAC
(
lam
,
ssrc
,
audioMtu
,
m_audio
->
iSampleRate
));
}
if
(
!
m_bSdp_gotAAC
&&
m_audio
)
{
makeSDP_AAC
((
unsigned
char
*
)
pcAdtsHeader
,
iDataLen
);
if
(
!
m_bSdp_gotAAC
&&
m_audio
&&
pcAdtsHeader
)
{
makeSDP_AAC
((
unsigned
char
*
)
pcAdtsHeader
);
}
if
(
pcDataWithoutAdts
&&
iDataLen
){
m_pRtpMaker_aac
->
makeRtp
(
pcDataWithoutAdts
,
iDataLen
,
uiStamp
);
}
}
inline
void
DevChannel
::
makeSDP_264
(
unsigned
char
*
pcData
,
int
iDataLen
)
{
...
...
@@ -226,7 +228,7 @@ inline void DevChannel::makeSDP_264(unsigned char *pcData, int iDataLen) {
}
}
inline
void
DevChannel
::
makeSDP_AAC
(
unsigned
char
*
fixedHeader
,
int
dataLen
)
{
inline
void
DevChannel
::
makeSDP_AAC
(
unsigned
char
*
fixedHeader
)
{
auto
audioSpecificConfig
=
makeAdtsConfig
(
fixedHeader
);
if
(
audioSpecificConfig
.
size
()
!=
2
)
{
return
;
...
...
src/Device/Device.h
查看文件 @
6ff01f55
...
...
@@ -96,7 +96,7 @@ public:
}
private
:
inline
void
makeSDP_264
(
unsigned
char
*
pucData
,
int
iDataLen
);
inline
void
makeSDP_AAC
(
unsigned
char
*
pucData
,
int
iDataLen
);
inline
void
makeSDP_AAC
(
unsigned
char
*
pucData
);
inline
void
makeSDP
(
const
string
&
strSdp
);
#ifdef ENABLE_X264
std
::
shared_ptr
<
H264Encoder
>
m_pH264Enc
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论