Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
abdc9ff0
提交
abdc9ff0
authored
10月 04, 2017
作者:
José Luis Millán
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
UdpSocket/TcpConnection: Add RecvBytes() and SentBytes() methods
上级
744ad61b
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
71 行增加
和
1 行删除
+71
-1
TcpConnection.hpp
worker/include/RTC/TcpConnection.hpp
+14
-0
TransportTuple.hpp
worker/include/RTC/TransportTuple.hpp
+18
-0
UdpSocket.hpp
worker/include/handles/UdpSocket.hpp
+14
-0
TcpConnection.cpp
worker/src/RTC/TcpConnection.cpp
+7
-1
TransportTuple.cpp
worker/src/RTC/TransportTuple.cpp
+4
-0
UdpSocket.cpp
worker/src/handles/UdpSocket.cpp
+14
-0
没有找到文件。
worker/include/RTC/TcpConnection.hpp
浏览文件 @
abdc9ff0
...
...
@@ -23,6 +23,8 @@ namespace RTC
public
:
void
Send
(
const
uint8_t
*
data
,
size_t
len
);
size_t
GetRecvBytes
()
const
;
size_t
GetSentBytes
()
const
;
/* Pure virtual methods inherited from ::TcpConnection. */
public
:
...
...
@@ -33,7 +35,19 @@ namespace RTC
Listener
*
listener
{
nullptr
};
// Others.
size_t
frameStart
{
0
};
// Where the latest frame starts.
size_t
recvBytes
{
0
};
size_t
sentBytes
{
0
};
};
inline
size_t
TcpConnection
::
GetRecvBytes
()
const
{
return
this
->
recvBytes
;
}
inline
size_t
TcpConnection
::
GetSentBytes
()
const
{
return
this
->
sentBytes
;
}
}
// namespace RTC
#endif
worker/include/RTC/TransportTuple.hpp
浏览文件 @
abdc9ff0
...
...
@@ -30,6 +30,8 @@ namespace RTC
Protocol
GetProtocol
()
const
;
const
struct
sockaddr
*
GetLocalAddress
()
const
;
const
struct
sockaddr
*
GetRemoteAddress
()
const
;
size_t
GetRecvBytes
()
const
;
size_t
GetSentBytes
()
const
;
private
:
// Passed by argument.
...
...
@@ -107,6 +109,22 @@ namespace RTC
else
return
this
->
tcpConnection
->
GetPeerAddress
();
}
inline
size_t
TransportTuple
::
GetRecvBytes
()
const
{
if
(
this
->
protocol
==
Protocol
::
UDP
)
return
this
->
udpSocket
->
GetRecvBytes
();
else
return
this
->
tcpConnection
->
GetRecvBytes
();
}
inline
size_t
TransportTuple
::
GetSentBytes
()
const
{
if
(
this
->
protocol
==
Protocol
::
UDP
)
return
this
->
udpSocket
->
GetSentBytes
();
else
return
this
->
tcpConnection
->
GetSentBytes
();
}
}
// namespace RTC
#endif
worker/include/handles/UdpSocket.hpp
浏览文件 @
abdc9ff0
...
...
@@ -39,6 +39,8 @@ public:
int
GetLocalFamily
()
const
;
const
std
::
string
&
GetLocalIP
()
const
;
uint16_t
GetLocalPort
()
const
;
size_t
GetRecvBytes
()
const
;
size_t
GetSentBytes
()
const
;
private
:
bool
SetLocalAddress
();
...
...
@@ -60,6 +62,8 @@ private:
uv_udp_t
*
uvHandle
{
nullptr
};
// Others.
bool
isClosing
{
false
};
size_t
recvBytes
{
0
};
size_t
sentBytes
{
0
};
protected
:
struct
sockaddr_storage
localAddr
...
...
@@ -101,4 +105,14 @@ inline uint16_t UdpSocket::GetLocalPort() const
return
this
->
localPort
;
}
inline
size_t
UdpSocket
::
GetRecvBytes
()
const
{
return
this
->
recvBytes
;
}
inline
size_t
UdpSocket
::
GetSentBytes
()
const
{
return
this
->
sentBytes
;
}
#endif
worker/src/RTC/TcpConnection.cpp
浏览文件 @
abdc9ff0
...
...
@@ -63,9 +63,12 @@ namespace RTC
{
const
uint8_t
*
packet
=
this
->
buffer
+
this
->
frameStart
+
2
;
//
N
otify the listener.
//
Update received bytes and n
otify the listener.
if
(
packetLen
!=
0
)
{
this
->
recvBytes
+=
packetLen
;
this
->
listener
->
OnPacketRecv
(
this
,
packet
,
packetLen
);
}
// If there is no more space available in the buffer and that is because
// the latest parsed frame filled it, then empty the full buffer.
...
...
@@ -140,6 +143,9 @@ namespace RTC
{
MS_TRACE
();
// Update sent bytes.
this
->
sentBytes
+=
len
;
// Write according to Framing RFC 4571.
uint8_t
frameLen
[
2
];
...
...
worker/src/RTC/TransportTuple.cpp
浏览文件 @
abdc9ff0
...
...
@@ -21,6 +21,8 @@ namespace RTC
static
const
Json
::
StaticString
JsonStringProtocol
{
"protocol"
};
static
const
Json
::
StaticString
JsonStringUdp
{
"udp"
};
static
const
Json
::
StaticString
JsonStringTcp
{
"tcp"
};
static
const
Json
::
StaticString
JsonStringRecvBytes
{
"recvBytes"
};
static
const
Json
::
StaticString
JsonStringSentBytes
{
"sentBytes"
};
Json
::
Value
json
(
Json
::
objectValue
);
int
ipFamily
;
...
...
@@ -38,6 +40,8 @@ namespace RTC
Utils
::
IP
::
GetAddressInfo
(
this
->
GetRemoteAddress
(),
&
ipFamily
,
ip
,
&
port
);
json
[
JsonStringRemoteIp
]
=
ip
;
json
[
JsonStringRemotePort
]
=
Json
::
UInt
{
port
};
json
[
JsonStringRecvBytes
]
=
Json
::
UInt64
{
GetRecvBytes
()
};
json
[
JsonStringSentBytes
]
=
Json
::
UInt64
{
GetSentBytes
()
};
return
json
;
}
...
...
worker/src/handles/UdpSocket.cpp
浏览文件 @
abdc9ff0
...
...
@@ -204,12 +204,18 @@ void UdpSocket::Send(const uint8_t* data, size_t len, const struct sockaddr* add
// Entire datagram was sent. Done.
if
(
sent
==
static_cast
<
int
>
(
len
))
{
// Update sent bytes.
this
->
sentBytes
+=
sent
;
return
;
}
if
(
sent
>=
0
)
{
MS_WARN_DEV
(
"datagram truncated (just %d of %zu bytes were sent)"
,
sent
,
len
);
// Update sent bytes.
this
->
sentBytes
+=
sent
;
return
;
}
// Error,
...
...
@@ -243,6 +249,11 @@ void UdpSocket::Send(const uint8_t* data, size_t len, const struct sockaddr* add
// Delete the UvSendData struct (which includes the uv_req_t and the store char[]).
std
::
free
(
sendData
);
}
else
{
// Update sent bytes.
this
->
sentBytes
+=
len
;
}
}
void
UdpSocket
::
Send
(
const
uint8_t
*
data
,
size_t
len
,
const
std
::
string
&
ip
,
uint16_t
port
)
...
...
@@ -346,6 +357,9 @@ inline void UdpSocket::OnUvRecv(
// Data received.
if
(
nread
>
0
)
{
// Update received bytes.
this
->
recvBytes
+=
nread
;
// Notify the subclass.
UserOnUdpDatagramRecv
(
reinterpret_cast
<
uint8_t
*>
(
buf
->
base
),
nread
,
addr
);
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论