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
7ee2d66e
Unverified
Commit
7ee2d66e
authored
Oct 19, 2023
by
ljx0305
Committed by
GitHub
Oct 19, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
统一代码命名风格 (#2910)
openRtpServer时,如果开启tcp模式,从tcp端口池获取
parent
b8cb8957
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
47 行增加
和
14 行删除
+47
-14
.github/workflows/c-cpp.yml
+34
-0
server/WebHook.cpp
+2
-3
src/Common/config.cpp
+1
-1
src/Common/config.h
+1
-1
src/Http/HttpSession.cpp
+6
-6
src/Http/HttpSession.h
+1
-1
src/Rtp/RtpServer.cpp
+2
-2
没有找到文件。
.github/workflows/c-cpp.yml
0 → 100644
查看文件 @
7ee2d66e
name
:
Linux
on
:
[
push
,
pull_request
]
jobs
:
build
:
runs-on
:
ubuntu-20.04
steps
:
-
uses
:
actions/checkout@v1
-
name
:
下载submodule源码
run
:
mv -f .gitmodules_github .gitmodules && git submodule sync && git submodule update --init
-
name
:
apt-get安装依赖库(非必选)
run
:
sudo apt-get update && sudo apt-get install -y cmake libssl-dev libsdl-dev libavcodec-dev libavutil-dev libswscale-dev libresample-dev libusrsctp-dev
-
name
:
下载 SRTP
uses
:
actions/checkout@v2
with
:
repository
:
cisco/libsrtp
fetch-depth
:
1
ref
:
v2.3.0
path
:
3rdpart/libsrtp
-
name
:
编译 SRTP
run
:
cd 3rdpart/libsrtp && ./configure --enable-openssl && make -j4 && sudo make install
-
name
:
编译
run
:
mkdir -p linux_build && cd linux_build && cmake .. -DENABLE_WEBRTC=true -DENABLE_FFMPEG=true && make -j $(nproc)
-
name
:
运行MediaServer
run
:
pwd && cd release/linux/Debug && sudo ./MediaServer -d &
server/WebHook.cpp
查看文件 @
7ee2d66e
...
@@ -674,7 +674,7 @@ void installWebHook() {
...
@@ -674,7 +674,7 @@ void installWebHook() {
});
});
});
});
NoticeCenter
::
Instance
().
addListener
(
&
web_hook_tag
,
Broadcast
::
K
BroadcastRtpServerTimeout
,
[](
BroadcastRtpServerTimeoutArgs
)
{
NoticeCenter
::
Instance
().
addListener
(
&
web_hook_tag
,
Broadcast
::
k
BroadcastRtpServerTimeout
,
[](
BroadcastRtpServerTimeoutArgs
)
{
GET_CONFIG
(
string
,
rtp_server_timeout
,
Hook
::
kOnRtpServerTimeout
);
GET_CONFIG
(
string
,
rtp_server_timeout
,
Hook
::
kOnRtpServerTimeout
);
if
(
!
hook_enable
||
rtp_server_timeout
.
empty
())
{
if
(
!
hook_enable
||
rtp_server_timeout
.
empty
())
{
return
;
return
;
...
@@ -703,4 +703,4 @@ void unInstallWebHook() {
...
@@ -703,4 +703,4 @@ void unInstallWebHook() {
void
onProcessExited
()
{
void
onProcessExited
()
{
reportServerExited
();
reportServerExited
();
}
}
\ No newline at end of file
src/Common/config.cpp
查看文件 @
7ee2d66e
...
@@ -57,7 +57,7 @@ const string kBroadcastNotFoundStream = "kBroadcastNotFoundStream";
...
@@ -57,7 +57,7 @@ const string kBroadcastNotFoundStream = "kBroadcastNotFoundStream";
const
string
kBroadcastStreamNoneReader
=
"kBroadcastStreamNoneReader"
;
const
string
kBroadcastStreamNoneReader
=
"kBroadcastStreamNoneReader"
;
const
string
kBroadcastHttpBeforeAccess
=
"kBroadcastHttpBeforeAccess"
;
const
string
kBroadcastHttpBeforeAccess
=
"kBroadcastHttpBeforeAccess"
;
const
string
kBroadcastSendRtpStopped
=
"kBroadcastSendRtpStopped"
;
const
string
kBroadcastSendRtpStopped
=
"kBroadcastSendRtpStopped"
;
const
string
KBroadcastRtpServerTimeout
=
"K
BroadcastRtpServerTimeout"
;
const
string
kBroadcastRtpServerTimeout
=
"k
BroadcastRtpServerTimeout"
;
}
// namespace Broadcast
}
// namespace Broadcast
...
...
src/Common/config.h
查看文件 @
7ee2d66e
...
@@ -106,7 +106,7 @@ extern const std::string kBroadcastReloadConfig;
...
@@ -106,7 +106,7 @@ extern const std::string kBroadcastReloadConfig;
#define BroadcastReloadConfigArgs void
#define BroadcastReloadConfigArgs void
// rtp server 超时
// rtp server 超时
extern
const
std
::
string
K
BroadcastRtpServerTimeout
;
extern
const
std
::
string
k
BroadcastRtpServerTimeout
;
#define BroadcastRtpServerTimeoutArgs uint16_t &local_port, const string &stream_id,int &tcp_mode, bool &re_use_port, uint32_t &ssrc
#define BroadcastRtpServerTimeoutArgs uint16_t &local_port, const string &stream_id,int &tcp_mode, bool &re_use_port, uint32_t &ssrc
#define ReloadConfigTag ((void *)(0xFF))
#define ReloadConfigTag ((void *)(0xFF))
...
...
src/Http/HttpSession.cpp
查看文件 @
7ee2d66e
...
@@ -166,11 +166,11 @@ void HttpSession::onError(const SockException &err) {
...
@@ -166,11 +166,11 @@ void HttpSession::onError(const SockException &err) {
if
(
_is_live_stream
)
{
if
(
_is_live_stream
)
{
// flv/ts播放器
// flv/ts播放器
uint64_t
duration
=
_ticker
.
createdTime
()
/
1000
;
uint64_t
duration
=
_ticker
.
createdTime
()
/
1000
;
WarnP
(
this
)
<<
"FLV/TS/FMP4播放器("
<<
_media
I
nfo
.
shortUrl
()
<<
")断开:"
<<
err
<<
",耗时(s):"
<<
duration
;
WarnP
(
this
)
<<
"FLV/TS/FMP4播放器("
<<
_media
_i
nfo
.
shortUrl
()
<<
")断开:"
<<
err
<<
",耗时(s):"
<<
duration
;
GET_CONFIG
(
uint32_t
,
iFlowThreshold
,
General
::
kFlowThreshold
);
GET_CONFIG
(
uint32_t
,
iFlowThreshold
,
General
::
kFlowThreshold
);
if
(
_total_bytes_usage
>=
iFlowThreshold
*
1024
)
{
if
(
_total_bytes_usage
>=
iFlowThreshold
*
1024
)
{
NOTICE_EMIT
(
BroadcastFlowReportArgs
,
Broadcast
::
kBroadcastFlowReport
,
_media
I
nfo
,
_total_bytes_usage
,
duration
,
true
,
*
this
);
NOTICE_EMIT
(
BroadcastFlowReportArgs
,
Broadcast
::
kBroadcastFlowReport
,
_media
_i
nfo
,
_total_bytes_usage
,
duration
,
true
,
*
this
);
}
}
return
;
return
;
}
}
...
@@ -263,9 +263,9 @@ bool HttpSession::checkLiveStream(const string &schema, const string &url_suffix
...
@@ -263,9 +263,9 @@ bool HttpSession::checkLiveStream(const string &schema, const string &url_suffix
}
}
// 解析带上协议+参数完整的url
// 解析带上协议+参数完整的url
_media
I
nfo
.
parse
(
schema
+
"://"
+
_parser
[
"Host"
]
+
url
);
_media
_i
nfo
.
parse
(
schema
+
"://"
+
_parser
[
"Host"
]
+
url
);
if
(
_media
Info
.
app
.
empty
()
||
_mediaI
nfo
.
stream
.
empty
())
{
if
(
_media
_info
.
app
.
empty
()
||
_media_i
nfo
.
stream
.
empty
())
{
// url不合法
// url不合法
return
false
;
return
false
;
}
}
...
@@ -288,7 +288,7 @@ bool HttpSession::checkLiveStream(const string &schema, const string &url_suffix
...
@@ -288,7 +288,7 @@ bool HttpSession::checkLiveStream(const string &schema, const string &url_suffix
}
}
// 异步查找直播流
// 异步查找直播流
MediaSource
::
findAsync
(
strong_self
->
_media
I
nfo
,
strong_self
,
[
weak_self
,
close_flag
,
cb
](
const
MediaSource
::
Ptr
&
src
)
{
MediaSource
::
findAsync
(
strong_self
->
_media
_i
nfo
,
strong_self
,
[
weak_self
,
close_flag
,
cb
](
const
MediaSource
::
Ptr
&
src
)
{
auto
strong_self
=
weak_self
.
lock
();
auto
strong_self
=
weak_self
.
lock
();
if
(
!
strong_self
)
{
if
(
!
strong_self
)
{
// 本对象已经销毁
// 本对象已经销毁
...
@@ -311,7 +311,7 @@ bool HttpSession::checkLiveStream(const string &schema, const string &url_suffix
...
@@ -311,7 +311,7 @@ bool HttpSession::checkLiveStream(const string &schema, const string &url_suffix
}
}
};
};
auto
flag
=
NOTICE_EMIT
(
BroadcastMediaPlayedArgs
,
Broadcast
::
kBroadcastMediaPlayed
,
_media
I
nfo
,
invoker
,
*
this
);
auto
flag
=
NOTICE_EMIT
(
BroadcastMediaPlayedArgs
,
Broadcast
::
kBroadcastMediaPlayed
,
_media
_i
nfo
,
invoker
,
*
this
);
if
(
!
flag
)
{
if
(
!
flag
)
{
// 该事件无人监听,默认不鉴权
// 该事件无人监听,默认不鉴权
onRes
(
""
);
onRes
(
""
);
...
...
src/Http/HttpSession.h
查看文件 @
7ee2d66e
...
@@ -124,7 +124,7 @@ private:
...
@@ -124,7 +124,7 @@ private:
void
setSocketFlags
();
void
setSocketFlags
();
protected
:
protected
:
MediaInfo
_media
I
nfo
;
MediaInfo
_media
_i
nfo
;
private
:
private
:
bool
_is_live_stream
=
false
;
bool
_is_live_stream
=
false
;
...
...
src/Rtp/RtpServer.cpp
查看文件 @
7ee2d66e
...
@@ -102,7 +102,7 @@ public:
...
@@ -102,7 +102,7 @@ public:
process
->
setOnDetach
(
std
::
move
(
strong_self
->
_on_detach
));
process
->
setOnDetach
(
std
::
move
(
strong_self
->
_on_detach
));
}
}
if
(
!
process
)
{
// process 未创建,触发rtp server 超时事件
if
(
!
process
)
{
// process 未创建,触发rtp server 超时事件
NOTICE_EMIT
(
BroadcastRtpServerTimeoutArgs
,
Broadcast
::
K
BroadcastRtpServerTimeout
,
strong_self
->
_local_port
,
strong_self
->
_stream_id
,
NOTICE_EMIT
(
BroadcastRtpServerTimeoutArgs
,
Broadcast
::
k
BroadcastRtpServerTimeout
,
strong_self
->
_local_port
,
strong_self
->
_stream_id
,
(
int
)
strong_self
->
_tcp_mode
,
strong_self
->
_re_use_port
,
strong_self
->
_ssrc
);
(
int
)
strong_self
->
_tcp_mode
,
strong_self
->
_re_use_port
,
strong_self
->
_ssrc
);
}
}
}
}
...
@@ -161,7 +161,7 @@ void RtpServer::start(uint16_t local_port, const string &stream_id, TcpMode tcp_
...
@@ -161,7 +161,7 @@ void RtpServer::start(uint16_t local_port, const string &stream_id, TcpMode tcp_
if
(
local_port
==
0
)
{
if
(
local_port
==
0
)
{
//随机端口,rtp端口采用偶数
//随机端口,rtp端口采用偶数
auto
pair
=
std
::
make_pair
(
rtp_socket
,
rtcp_socket
);
auto
pair
=
std
::
make_pair
(
rtp_socket
,
rtcp_socket
);
makeSockPair
(
pair
,
local_ip
,
re_use_port
);
makeSockPair
(
pair
,
local_ip
,
re_use_port
,
TcpMode
::
NONE
==
tcp_mode
);
local_port
=
rtp_socket
->
get_local_port
();
local_port
=
rtp_socket
->
get_local_port
();
}
else
if
(
!
rtp_socket
->
bindUdpSock
(
local_port
,
local_ip
,
re_use_port
))
{
}
else
if
(
!
rtp_socket
->
bindUdpSock
(
local_port
,
local_ip
,
re_use_port
))
{
//用户指定端口
//用户指定端口
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论