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
82da99ee
Commit
82da99ee
authored
Jun 03, 2022
by
xiongguangjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add shutdown packet and flow report
parent
b9f66ca1
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
57 行增加
和
3 行删除
+57
-3
srt/Packet.hpp
+28
-0
srt/SrtTransport.cpp
+9
-0
srt/SrtTransport.hpp
+2
-1
srt/SrtTransportImp.cpp
+12
-0
srt/SrtTransportImp.hpp
+6
-2
没有找到文件。
srt/Packet.hpp
查看文件 @
82da99ee
...
...
@@ -5,6 +5,7 @@
#include <vector>
#include "Network/Buffer.h"
#include "Util/logger.h"
#include "Common.hpp"
#include "HSExt.hpp"
...
...
@@ -312,6 +313,32 @@ class MsgDropReqPacket : public ControlPacket
uint32_t
last_pkt_seq_num
;
};
class
ShutDownPacket
:
public
ControlPacket
{
public
:
using
Ptr
=
std
::
shared_ptr
<
ShutDownPacket
>
;
ShutDownPacket
()
=
default
;
~
ShutDownPacket
()
=
default
;
///////ControlPacket override///////
bool
loadFromData
(
uint8_t
*
buf
,
size_t
len
)
override
{
if
(
len
<
HEADER_SIZE
)
{
WarnL
<<
"data size"
<<
len
<<
" less "
<<
HEADER_SIZE
;
return
false
;
}
_data
=
BufferRaw
::
create
();
_data
->
assign
((
char
*
)
buf
,
len
);
return
loadHeader
();
};
bool
storeToData
()
override
{
control_type
=
ControlPacket
::
SHUTDOWN
;
sub_type
=
0
;
_data
=
BufferRaw
::
create
();
_data
->
setCapacity
(
HEADER_SIZE
);
_data
->
setSize
(
HEADER_SIZE
);
return
storeToHeader
();
};
};
}
// namespace SRT
#endif //ZLMEDIAKIT_SRT_PACKET_H
\ No newline at end of file
srt/SrtTransport.cpp
查看文件 @
82da99ee
...
...
@@ -329,6 +329,14 @@ void SrtTransport::sendNAKPacket(std::list<PacketQueue::LostPair>& lost_list){
TraceL
<<
"send NAK "
<<
pkt
->
dump
();
sendControlPacket
(
pkt
,
true
);
}
void
SrtTransport
::
sendShutDown
(){
ShutDownPacket
::
Ptr
pkt
=
std
::
make_shared
<
ShutDownPacket
>
();
pkt
->
dst_socket_id
=
_peer_socket_id
;
pkt
->
timestamp
=
DurationCountMicroseconds
(
_now
-
_start_timestamp
);
pkt
->
storeToData
();
sendControlPacket
(
pkt
,
true
);
}
void
SrtTransport
::
handleDataPacket
(
uint8_t
*
buf
,
int
len
,
struct
sockaddr_storage
*
addr
){
DataPacket
::
Ptr
pkt
=
std
::
make_shared
<
DataPacket
>
();
pkt
->
loadFromData
(
buf
,
len
);
...
...
@@ -423,6 +431,7 @@ void SrtTransport::unregisterSelf() {
}
void
SrtTransport
::
onShutdown
(
const
SockException
&
ex
){
sendShutDown
();
WarnL
<<
ex
.
what
();
unregisterSelfHandshake
();
unregisterSelf
();
...
...
srt/SrtTransport.hpp
查看文件 @
82da99ee
...
...
@@ -36,7 +36,7 @@ public:
* @param len 数据长度
* @param addr 数据来源地址
*/
void
inputSockData
(
uint8_t
*
buf
,
int
len
,
struct
sockaddr_storage
*
addr
);
v
irtual
v
oid
inputSockData
(
uint8_t
*
buf
,
int
len
,
struct
sockaddr_storage
*
addr
);
std
::
string
getIdentifier
();
...
...
@@ -72,6 +72,7 @@ private:
void
sendACKPacket
();
void
sendLightACKPacket
();
void
sendKeepLivePacket
();
void
sendShutDown
();
protected
:
void
sendDataPacket
(
DataPacket
::
Ptr
pkt
,
char
*
buf
,
int
len
,
bool
flush
=
false
);
void
sendControlPacket
(
ControlPacket
::
Ptr
pkt
,
bool
flush
=
true
);
...
...
srt/SrtTransportImp.cpp
查看文件 @
82da99ee
...
...
@@ -9,6 +9,18 @@ SrtTransportImp::SrtTransportImp(const EventPoller::Ptr &poller)
SrtTransportImp
::~
SrtTransportImp
()
{
InfoP
(
this
);
uint64_t
duration
=
_alive_ticker
.
createdTime
()
/
1000
;
WarnP
(
this
)
<<
"srt 推流器("
<<
_media_info
.
_vhost
<<
"/"
<<
_media_info
.
_app
<<
"/"
<<
_media_info
.
_streamid
<<
")断开,耗时(s):"
<<
duration
;
//流量统计事件广播
GET_CONFIG
(
uint32_t
,
iFlowThreshold
,
General
::
kFlowThreshold
);
if
(
_total_bytes
>=
iFlowThreshold
*
1024
)
{
NoticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastFlowReport
,
_media_info
,
_total_bytes
,
duration
,
false
,
static_cast
<
SockInfo
&>
(
*
this
));
}
}
void
SrtTransportImp
::
onHandShakeFinished
(
std
::
string
&
streamid
,
struct
sockaddr_storage
*
addr
)
{
...
...
srt/SrtTransportImp.hpp
查看文件 @
82da99ee
...
...
@@ -17,7 +17,10 @@ class SrtTransportImp
public
:
SrtTransportImp
(
const
EventPoller
::
Ptr
&
poller
);
~
SrtTransportImp
();
void
inputSockData
(
uint8_t
*
buf
,
int
len
,
struct
sockaddr_storage
*
addr
){
SrtTransport
::
inputSockData
(
buf
,
len
,
addr
);
_total_bytes
+=
len
;
}
/// SockInfo override
std
::
string
get_local_ip
()
override
;
uint16_t
get_local_port
()
override
;
...
...
@@ -58,7 +61,8 @@ private:
private
:
bool
_is_pusher
=
true
;
MediaInfo
_media_info
;
uint64_t
_total_bytes
=
0
;
Ticker
_alive_ticker
;
std
::
unique_ptr
<
sockaddr_storage
>
_addr
;
// for pusher
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论