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
9f223bc7
Commit
9f223bc7
authored
May 22, 2021
by
xiongziliang
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://github.com/xia-chu/ZLMediaKit
into dev
parents
08d4eddd
975c11b7
隐藏空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
38 行增加
和
10 行删除
+38
-10
3rdpart/ZLToolKit
+1
-1
conf/config.ini
+2
-0
server/WebApi.cpp
+3
-1
server/WebHook.cpp
+19
-4
src/Common/MediaSink.cpp
+5
-0
src/Common/config.cpp
+2
-0
src/Common/config.h
+2
-0
src/Http/HttpRequester.cpp
+1
-2
src/Rtsp/RtspSession.cpp
+3
-2
没有找到文件。
ZLToolKit
@
b04d1321
Subproject commit b
678e474f8ba8c9f3e6efd9cec6e4c517e80209d
Subproject commit b
04d132139399637cbb201c2832dd98dc2786e82
conf/config.ini
查看文件 @
9f223bc7
...
...
@@ -61,6 +61,8 @@ mergeWriteMS=0
modifyStamp
=
0
#服务器唯一id,用于触发hook时区别是哪台服务器
mediaServerId
=
your_server_id
#转协议是否全局开启或关闭音频
enable_audio
=
1
###### 以下是按需转协议的开关,在测试ZLMediaKit的接收推流性能时,请把下面开关置1
###### 如果某种协议你用不到,你可以把以下开关置1以便节省资源(但是还是可以播放,只是第一个播放者体验稍微差点),
...
...
server/WebApi.cpp
查看文件 @
9f223bc7
...
...
@@ -281,7 +281,7 @@ static inline string getProxyKey(const string &vhost,const string &app,const str
Value
makeMediaSourceJson
(
MediaSource
&
media
){
Value
item
;
item
[
"schema"
]
=
media
.
getSchema
();
item
[
"vhost"
]
=
media
.
getVhost
();
item
[
VHOST_KEY
]
=
media
.
getVhost
();
item
[
"app"
]
=
media
.
getApp
();
item
[
"stream"
]
=
media
.
getId
();
item
[
"createStamp"
]
=
(
Json
::
UInt64
)
media
.
getCreateStamp
();
...
...
@@ -292,6 +292,8 @@ Value makeMediaSourceJson(MediaSource &media){
item
[
"originType"
]
=
(
int
)
media
.
getOriginType
();
item
[
"originTypeStr"
]
=
getOriginTypeString
(
media
.
getOriginType
());
item
[
"originUrl"
]
=
media
.
getOriginUrl
();
item
[
"isRecordingMP4"
]
=
media
.
isRecording
(
Recorder
::
type_mp4
);
item
[
"isRecordingHLS"
]
=
media
.
isRecording
(
Recorder
::
type_hls
);
auto
originSock
=
media
.
getOriginSock
();
if
(
originSock
)
{
item
[
"originSock"
][
"local_ip"
]
=
originSock
->
get_local_ip
();
...
...
server/WebHook.cpp
查看文件 @
9f223bc7
...
...
@@ -113,6 +113,17 @@ const char *getContentType(const HttpArgs &value){
return
"application/x-www-form-urlencoded"
;
}
string
getVhost
(
const
Value
&
value
)
{
const
char
*
key
=
VHOST_KEY
;
auto
val
=
value
.
find
(
key
,
key
+
sizeof
(
VHOST_KEY
)
-
1
);
return
val
?
val
->
asString
()
:
""
;
}
string
getVhost
(
const
HttpArgs
&
value
)
{
auto
val
=
value
.
find
(
VHOST_KEY
);
return
val
!=
value
.
end
()
?
val
->
second
:
""
;
}
void
do_http_hook
(
const
string
&
url
,
const
ArgsType
&
body
,
const
function
<
void
(
const
Value
&
,
const
string
&
)
>
&
func
){
GET_CONFIG
(
string
,
mediaServerId
,
General
::
kMediaServerId
);
GET_CONFIG
(
float
,
hook_timeoutSec
,
Hook
::
kTimeoutSec
);
...
...
@@ -123,6 +134,10 @@ void do_http_hook(const string &url,const ArgsType &body,const function<void(con
auto
bodyStr
=
to_string
(
body
);
requester
->
setBody
(
bodyStr
);
requester
->
addHeader
(
"Content-Type"
,
getContentType
(
body
));
auto
vhost
=
getVhost
(
body
);
if
(
!
vhost
.
empty
())
{
requester
->
addHeader
(
"X-VHOST"
,
vhost
);
}
std
::
shared_ptr
<
Ticker
>
pTicker
(
new
Ticker
);
requester
->
startRequester
(
url
,
[
url
,
func
,
bodyStr
,
requester
,
pTicker
](
const
SockException
&
ex
,
const
string
&
status
,
...
...
@@ -147,7 +162,7 @@ void do_http_hook(const string &url,const ArgsType &body,const function<void(con
static
ArgsType
make_json
(
const
MediaInfo
&
args
){
ArgsType
body
;
body
[
"schema"
]
=
args
.
_schema
;
body
[
"vhost"
]
=
args
.
_vhost
;
body
[
VHOST_KEY
]
=
args
.
_vhost
;
body
[
"app"
]
=
args
.
_app
;
body
[
"stream"
]
=
args
.
_streamid
;
body
[
"params"
]
=
args
.
_param_strs
;
...
...
@@ -306,7 +321,7 @@ void installWebHook(){
body
[
"regist"
]
=
bRegist
;
}
else
{
body
[
"schema"
]
=
sender
.
getSchema
();
body
[
"vhost"
]
=
sender
.
getVhost
();
body
[
VHOST_KEY
]
=
sender
.
getVhost
();
body
[
"app"
]
=
sender
.
getApp
();
body
[
"stream"
]
=
sender
.
getId
();
body
[
"regist"
]
=
bRegist
;
...
...
@@ -342,7 +357,7 @@ void installWebHook(){
body
[
"url"
]
=
info
.
url
;
body
[
"app"
]
=
info
.
app
;
body
[
"stream"
]
=
info
.
stream
;
body
[
"vhost"
]
=
info
.
vhost
;
body
[
VHOST_KEY
]
=
info
.
vhost
;
return
body
;
};
...
...
@@ -394,7 +409,7 @@ void installWebHook(){
ArgsType
body
;
body
[
"schema"
]
=
sender
.
getSchema
();
body
[
"vhost"
]
=
sender
.
getVhost
();
body
[
VHOST_KEY
]
=
sender
.
getVhost
();
body
[
"app"
]
=
sender
.
getApp
();
body
[
"stream"
]
=
sender
.
getId
();
weak_ptr
<
MediaSource
>
weakSrc
=
sender
.
shared_from_this
();
...
...
src/Common/MediaSink.cpp
查看文件 @
9f223bc7
...
...
@@ -22,6 +22,11 @@ static size_t constexpr kMaxUnreadyFrame = 100;
namespace
mediakit
{
void
MediaSink
::
addTrack
(
const
Track
::
Ptr
&
track_in
)
{
GET_CONFIG
(
bool
,
enabel_audio
,
General
::
kEnableAudio
);
if
(
!
enabel_audio
&&
track_in
->
getTrackType
()
==
TrackAudio
)
{
//音频被全局忽略
return
;
}
lock_guard
<
recursive_mutex
>
lck
(
_mtx
);
if
(
_all_track_ready
)
{
WarnL
<<
"all track is ready, add this track too late!"
;
...
...
src/Common/config.cpp
查看文件 @
9f223bc7
...
...
@@ -74,6 +74,7 @@ const string kRtspDemand = GENERAL_FIELD"rtsp_demand";
const
string
kRtmpDemand
=
GENERAL_FIELD
"rtmp_demand"
;
const
string
kTSDemand
=
GENERAL_FIELD
"ts_demand"
;
const
string
kFMP4Demand
=
GENERAL_FIELD
"fmp4_demand"
;
const
string
kEnableAudio
=
GENERAL_FIELD
"enable_audio"
;
onceToken
token
([](){
mINI
::
Instance
()[
kFlowThreshold
]
=
1024
;
...
...
@@ -92,6 +93,7 @@ onceToken token([](){
mINI
::
Instance
()[
kRtmpDemand
]
=
0
;
mINI
::
Instance
()[
kTSDemand
]
=
0
;
mINI
::
Instance
()[
kFMP4Demand
]
=
0
;
mINI
::
Instance
()[
kEnableAudio
]
=
1
;
},
nullptr
);
...
...
src/Common/config.h
查看文件 @
9f223bc7
...
...
@@ -187,6 +187,8 @@ extern const string kRtspDemand;
extern
const
string
kRtmpDemand
;
extern
const
string
kTSDemand
;
extern
const
string
kFMP4Demand
;
//转协议是否全局开启或忽略音频
extern
const
string
kEnableAudio
;
}
//namespace General
...
...
src/Http/HttpRequester.cpp
查看文件 @
9f223bc7
...
...
@@ -21,8 +21,7 @@ HttpRequester::~HttpRequester(){
ssize_t
HttpRequester
::
onResponseHeader
(
const
string
&
status
,
const
HttpHeader
&
headers
)
{
_strRecvBody
.
clear
();
//无Content-Length字段时默认后面没有content
return
0
;
return
HttpClientImp
::
onResponseHeader
(
status
,
headers
);
}
void
HttpRequester
::
onResponseBody
(
const
char
*
buf
,
size_t
size
,
size_t
recvedSize
,
size_t
totalSize
)
{
...
...
src/Rtsp/RtspSession.cpp
查看文件 @
9f223bc7
...
...
@@ -213,6 +213,7 @@ void RtspSession::handleReq_ANNOUNCE(const Parser &parser) {
}
auto
full_url
=
parser
.
FullUrl
();
_content_base
=
full_url
;
if
(
end_with
(
full_url
,
".sdp"
))
{
//去除.sdp后缀,防止EasyDarwin推流器强制添加.sdp后缀
full_url
=
full_url
.
substr
(
0
,
full_url
.
length
()
-
4
);
...
...
@@ -252,7 +253,7 @@ void RtspSession::handleReq_ANNOUNCE(const Parser &parser) {
_push_src
->
setListener
(
dynamic_pointer_cast
<
MediaSourceEvent
>
(
shared_from_this
()));
_push_src
->
setProtocolTranslation
(
enableHls
,
enableMP4
);
_push_src
->
setSdp
(
sdpParser
.
toString
());
sendRtspResponse
(
"200 OK"
,
{
"Content-Base"
,
_content_base
+
"/"
}
);
sendRtspResponse
(
"200 OK"
);
};
weak_ptr
<
RtspSession
>
weakSelf
=
dynamic_pointer_cast
<
RtspSession
>
(
shared_from_this
());
...
...
@@ -613,7 +614,7 @@ void RtspSession::send_SessionNotFound() {
void
RtspSession
::
handleReq_Setup
(
const
Parser
&
parser
)
{
//处理setup命令,该函数可能进入多次
int
trackIdx
=
getTrackIndexByControlUrl
(
parser
.
Url
());
int
trackIdx
=
getTrackIndexByControlUrl
(
parser
.
Full
Url
());
SdpTrack
::
Ptr
&
trackRef
=
_sdp_track
[
trackIdx
];
if
(
trackRef
->
_inited
)
{
//已经初始化过该Track
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论