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
ec1942fa
Commit
ec1942fa
authored
Sep 20, 2022
by
xiongguangjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
srt connection transfer support
parent
b77c19c9
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
42 行增加
和
3 行删除
+42
-3
srt/SrtSession.cpp
+2
-2
srt/SrtTransport.cpp
+22
-1
srt/SrtTransport.hpp
+8
-0
srt/SrtTransportImp.cpp
+9
-0
srt/SrtTransportImp.hpp
+1
-0
没有找到文件。
srt/SrtSession.cpp
查看文件 @
ec1942fa
...
@@ -128,9 +128,9 @@ void SrtSession::onError(const SockException &err) {
...
@@ -128,9 +128,9 @@ void SrtSession::onError(const SockException &err) {
// 防止互相引用导致不释放
// 防止互相引用导致不释放
auto
transport
=
std
::
move
(
_transport
);
auto
transport
=
std
::
move
(
_transport
);
getPoller
()
->
async
(
getPoller
()
->
async
(
[
transport
,
err
]
{
[
transport
]
{
//延时减引用,防止使用transport对象时,销毁对象
//延时减引用,防止使用transport对象时,销毁对象
transport
->
onShutdown
(
err
);
//
transport->onShutdown(err);
},
},
false
);
false
);
}
}
...
...
srt/SrtTransport.cpp
查看文件 @
ec1942fa
...
@@ -60,7 +60,29 @@ void SrtTransport::switchToOtherTransport(uint8_t *buf, int len, uint32_t socket
...
@@ -60,7 +60,29 @@ void SrtTransport::switchToOtherTransport(uint8_t *buf, int len, uint32_t socket
}
}
}
}
void
SrtTransport
::
createTimerForCheckAlive
(){
std
::
weak_ptr
<
SrtTransport
>
weak_self
=
std
::
static_pointer_cast
<
SrtTransport
>
(
shared_from_this
());
auto
timeoutSec
=
getTimeOutSec
();
_timer
=
std
::
make_shared
<
Timer
>
(
timeoutSec
/
2
,
[
weak_self
,
timeoutSec
]()
{
auto
strong_self
=
weak_self
.
lock
();
if
(
!
strong_self
)
{
return
false
;
}
if
(
strong_self
->
_alive_ticker
.
elapsedTime
()
>
timeoutSec
*
1000
)
{
strong_self
->
onShutdown
(
SockException
(
Err_timeout
,
"接收srt数据超时"
));
}
return
true
;
},
getPoller
());
}
void
SrtTransport
::
inputSockData
(
uint8_t
*
buf
,
int
len
,
struct
sockaddr_storage
*
addr
)
{
void
SrtTransport
::
inputSockData
(
uint8_t
*
buf
,
int
len
,
struct
sockaddr_storage
*
addr
)
{
_alive_ticker
.
resetTime
();
if
(
!
_timer
){
createTimerForCheckAlive
();
}
using
srt_control_handler
=
void
(
SrtTransport
::*
)(
uint8_t
*
buf
,
int
len
,
struct
sockaddr_storage
*
addr
);
using
srt_control_handler
=
void
(
SrtTransport
::*
)(
uint8_t
*
buf
,
int
len
,
struct
sockaddr_storage
*
addr
);
static
std
::
unordered_map
<
uint16_t
,
srt_control_handler
>
s_control_functions
;
static
std
::
unordered_map
<
uint16_t
,
srt_control_handler
>
s_control_functions
;
static
onceToken
token
([]()
{
static
onceToken
token
([]()
{
...
@@ -173,7 +195,6 @@ void SrtTransport::handleHandshakeInduction(HandshakePacket &pkt, struct sockadd
...
@@ -173,7 +195,6 @@ void SrtTransport::handleHandshakeInduction(HandshakePacket &pkt, struct sockadd
registerSelfHandshake
();
registerSelfHandshake
();
sendControlPacket
(
res
,
true
);
sendControlPacket
(
res
,
true
);
_handleshake_timer
=
std
::
make_shared
<
Timer
>
(
0.02
,[
this
]()
->
bool
{
_handleshake_timer
=
std
::
make_shared
<
Timer
>
(
0.02
,[
this
]()
->
bool
{
sendControlPacket
(
_handleshake_res
,
true
);
sendControlPacket
(
_handleshake_res
,
true
);
return
true
;
return
true
;
...
...
srt/SrtTransport.hpp
查看文件 @
ec1942fa
...
@@ -57,6 +57,7 @@ protected:
...
@@ -57,6 +57,7 @@ protected:
virtual
void
sendPacket
(
Buffer
::
Ptr
pkt
,
bool
flush
=
true
);
virtual
void
sendPacket
(
Buffer
::
Ptr
pkt
,
bool
flush
=
true
);
virtual
int
getLatencyMul
()
{
return
4
;
};
virtual
int
getLatencyMul
()
{
return
4
;
};
virtual
int
getPktBufSize
()
{
return
8192
;
};
virtual
int
getPktBufSize
()
{
return
8192
;
};
virtual
float
getTimeOutSec
(){
return
5.0
;};
private
:
private
:
void
registerSelf
();
void
registerSelf
();
...
@@ -88,6 +89,8 @@ private:
...
@@ -88,6 +89,8 @@ private:
size_t
getPayloadSize
();
size_t
getPayloadSize
();
void
createTimerForCheckAlive
();
protected
:
protected
:
void
sendDataPacket
(
DataPacket
::
Ptr
pkt
,
char
*
buf
,
int
len
,
bool
flush
=
false
);
void
sendDataPacket
(
DataPacket
::
Ptr
pkt
,
char
*
buf
,
int
len
,
bool
flush
=
false
);
void
sendControlPacket
(
ControlPacket
::
Ptr
pkt
,
bool
flush
=
true
);
void
sendControlPacket
(
ControlPacket
::
Ptr
pkt
,
bool
flush
=
true
);
...
@@ -144,6 +147,11 @@ private:
...
@@ -144,6 +147,11 @@ private:
Timer
::
Ptr
_handleshake_timer
;
Timer
::
Ptr
_handleshake_timer
;
ResourcePool
<
BufferRaw
>
_packet_pool
;
ResourcePool
<
BufferRaw
>
_packet_pool
;
//检测超时的定时器
Timer
::
Ptr
_timer
;
//刷新计时器
Ticker
_alive_ticker
;
};
};
class
SrtTransportManager
{
class
SrtTransportManager
{
...
...
srt/SrtTransportImp.cpp
查看文件 @
ec1942fa
...
@@ -340,6 +340,15 @@ int SrtTransportImp::getLatencyMul() {
...
@@ -340,6 +340,15 @@ int SrtTransportImp::getLatencyMul() {
return
latencyMul
;
return
latencyMul
;
}
}
float
SrtTransportImp
::
getTimeOutSec
()
{
GET_CONFIG
(
float
,
timeOutSec
,
kTimeOutSec
);
if
(
timeOutSec
<=
0
)
{
WarnL
<<
"config srt "
<<
kTimeOutSec
<<
" not vaild"
;
return
5.0
;
}
return
timeOutSec
;
}
int
SrtTransportImp
::
getPktBufSize
()
{
int
SrtTransportImp
::
getPktBufSize
()
{
// kPktBufSize
// kPktBufSize
GET_CONFIG
(
int
,
pktBufSize
,
kPktBufSize
);
GET_CONFIG
(
int
,
pktBufSize
,
kPktBufSize
);
...
...
srt/SrtTransportImp.hpp
查看文件 @
ec1942fa
...
@@ -37,6 +37,7 @@ protected:
...
@@ -37,6 +37,7 @@ protected:
///////SrtTransport override///////
///////SrtTransport override///////
int
getLatencyMul
()
override
;
int
getLatencyMul
()
override
;
int
getPktBufSize
()
override
;
int
getPktBufSize
()
override
;
float
getTimeOutSec
()
override
;
void
onSRTData
(
DataPacket
::
Ptr
pkt
)
override
;
void
onSRTData
(
DataPacket
::
Ptr
pkt
)
override
;
void
onShutdown
(
const
SockException
&
ex
)
override
;
void
onShutdown
(
const
SockException
&
ex
)
override
;
void
onHandShakeFinished
(
std
::
string
&
streamid
,
struct
sockaddr_storage
*
addr
)
override
;
void
onHandShakeFinished
(
std
::
string
&
streamid
,
struct
sockaddr_storage
*
addr
)
override
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论