Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
b515d37e
提交
b515d37e
authored
2月 15, 2017
作者:
José Luis Millán
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rtcp: calculate RTCP interval internally
上级
0b0ade4c
隐藏空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
144 行增加
和
66 行删除
+144
-66
Peer.h
worker/include/RTC/Peer.h
+9
-3
Packet.h
worker/include/RTC/RTCP/Packet.h
+4
-0
Room.h
worker/include/RTC/Room.h
+0
-1
RtpReceiver.h
worker/include/RTC/RtpReceiver.h
+5
-1
RtpSender.h
worker/include/RTC/RtpSender.h
+14
-10
Peer.cpp
worker/src/RTC/Peer.cpp
+73
-28
Room.cpp
worker/src/RTC/Room.cpp
+0
-14
RtpReceiver.cpp
worker/src/RTC/RtpReceiver.cpp
+14
-9
RtpSender.cpp
worker/src/RTC/RtpSender.cpp
+25
-0
没有找到文件。
worker/include/RTC/Peer.h
浏览文件 @
b515d37e
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
#include "RTC/RTCP/Sdes.h"
#include "RTC/RTCP/Sdes.h"
#include "Channel/Request.h"
#include "Channel/Request.h"
#include "Channel/Notifier.h"
#include "Channel/Notifier.h"
#include "handles/Timer.h"
#include <string>
#include <string>
#include <unordered_map>
#include <unordered_map>
#include <vector>
#include <vector>
...
@@ -23,7 +24,8 @@ namespace RTC
...
@@ -23,7 +24,8 @@ namespace RTC
class
Peer
:
class
Peer
:
public
RTC
::
Transport
::
Listener
,
public
RTC
::
Transport
::
Listener
,
public
RTC
::
RtpReceiver
::
Listener
,
public
RTC
::
RtpReceiver
::
Listener
,
public
RTC
::
RtpSender
::
Listener
public
RTC
::
RtpSender
::
Listener
,
public
Timer
::
Listener
{
{
public
:
public
:
class
Listener
class
Listener
...
@@ -40,7 +42,6 @@ namespace RTC
...
@@ -40,7 +42,6 @@ namespace RTC
virtual
void
onPeerRtcpFeedback
(
RTC
::
Peer
*
peer
,
RTC
::
RtpSender
*
rtpSender
,
RTC
::
RTCP
::
FeedbackRtpPacket
*
packet
)
=
0
;
virtual
void
onPeerRtcpFeedback
(
RTC
::
Peer
*
peer
,
RTC
::
RtpSender
*
rtpSender
,
RTC
::
RTCP
::
FeedbackRtpPacket
*
packet
)
=
0
;
virtual
void
onPeerRtcpSenderReport
(
RTC
::
Peer
*
peer
,
RTC
::
RtpReceiver
*
rtpReceiver
,
RTC
::
RTCP
::
SenderReport
*
report
)
=
0
;
virtual
void
onPeerRtcpSenderReport
(
RTC
::
Peer
*
peer
,
RTC
::
RtpReceiver
*
rtpReceiver
,
RTC
::
RTCP
::
SenderReport
*
report
)
=
0
;
virtual
void
onPeerRtcpSdesChunk
(
RTC
::
Peer
*
peer
,
RTC
::
RtpReceiver
*
rtpReceiver
,
RTC
::
RTCP
::
SdesChunk
*
chunk
)
=
0
;
virtual
void
onPeerRtcpSdesChunk
(
RTC
::
Peer
*
peer
,
RTC
::
RtpReceiver
*
rtpReceiver
,
RTC
::
RTCP
::
SdesChunk
*
chunk
)
=
0
;
virtual
void
onPeerRtcpCompleted
(
RTC
::
Peer
*
peer
)
=
0
;
};
};
private
:
private
:
...
@@ -64,7 +65,7 @@ namespace RTC
...
@@ -64,7 +65,7 @@ namespace RTC
*/
*/
void
AddRtpSender
(
RTC
::
RtpSender
*
rtpSender
,
std
::
string
&
peerName
,
RTC
::
RtpParameters
*
rtpParameters
);
void
AddRtpSender
(
RTC
::
RtpSender
*
rtpSender
,
std
::
string
&
peerName
,
RTC
::
RtpParameters
*
rtpParameters
);
RTC
::
RtpSender
*
GetRtpSender
(
uint32_t
ssrc
);
RTC
::
RtpSender
*
GetRtpSender
(
uint32_t
ssrc
);
void
SendRtcp
();
void
SendRtcp
(
uint64_t
now
);
private
:
private
:
RTC
::
Transport
*
GetTransportFromRequest
(
Channel
::
Request
*
request
,
uint32_t
*
transportId
=
nullptr
);
RTC
::
Transport
*
GetTransportFromRequest
(
Channel
::
Request
*
request
,
uint32_t
*
transportId
=
nullptr
);
...
@@ -87,6 +88,10 @@ namespace RTC
...
@@ -87,6 +88,10 @@ namespace RTC
public
:
public
:
virtual
void
onRtpSenderClosed
(
RTC
::
RtpSender
*
rtpSender
)
override
;
virtual
void
onRtpSenderClosed
(
RTC
::
RtpSender
*
rtpSender
)
override
;
/* Pure virtual methods inherited from Timer::Listener. */
public
:
virtual
void
onTimer
(
Timer
*
timer
)
override
;
public
:
public
:
// Passed by argument.
// Passed by argument.
uint32_t
peerId
;
uint32_t
peerId
;
...
@@ -97,6 +102,7 @@ namespace RTC
...
@@ -97,6 +102,7 @@ namespace RTC
Listener
*
listener
=
nullptr
;
Listener
*
listener
=
nullptr
;
Channel
::
Notifier
*
notifier
=
nullptr
;
Channel
::
Notifier
*
notifier
=
nullptr
;
// Others.
// Others.
Timer
*
timer
=
nullptr
;
bool
hasCapabilities
=
false
;
bool
hasCapabilities
=
false
;
RTC
::
RtpCapabilities
capabilities
;
RTC
::
RtpCapabilities
capabilities
;
std
::
unordered_map
<
uint32_t
,
RTC
::
Transport
*>
transports
;
std
::
unordered_map
<
uint32_t
,
RTC
::
Transport
*>
transports
;
...
...
worker/include/RTC/RTCP/Packet.h
浏览文件 @
b515d37e
...
@@ -9,6 +9,10 @@
...
@@ -9,6 +9,10 @@
namespace
RTC
{
namespace
RTCP
namespace
RTC
{
namespace
RTCP
{
{
// Maximum interval for regular RTCP mode.
constexpr
uint16_t
MAX_VIDEO_INTERVAL_MS
=
1000
;
constexpr
uint16_t
MAX_AUDIO_INTERVAL_MS
=
5000
;
enum
class
Type
:
uint8_t
enum
class
Type
:
uint8_t
{
{
FIR
=
192
,
FIR
=
192
,
...
...
worker/include/RTC/Room.h
浏览文件 @
b515d37e
...
@@ -63,7 +63,6 @@ namespace RTC
...
@@ -63,7 +63,6 @@ namespace RTC
virtual
void
onPeerRtcpFeedback
(
RTC
::
Peer
*
peer
,
RTC
::
RtpSender
*
rtpSender
,
RTC
::
RTCP
::
FeedbackRtpPacket
*
packet
)
override
;
virtual
void
onPeerRtcpFeedback
(
RTC
::
Peer
*
peer
,
RTC
::
RtpSender
*
rtpSender
,
RTC
::
RTCP
::
FeedbackRtpPacket
*
packet
)
override
;
virtual
void
onPeerRtcpSenderReport
(
RTC
::
Peer
*
peer
,
RTC
::
RtpReceiver
*
rtpReceiver
,
RTC
::
RTCP
::
SenderReport
*
report
)
override
;
virtual
void
onPeerRtcpSenderReport
(
RTC
::
Peer
*
peer
,
RTC
::
RtpReceiver
*
rtpReceiver
,
RTC
::
RTCP
::
SenderReport
*
report
)
override
;
virtual
void
onPeerRtcpSdesChunk
(
RTC
::
Peer
*
peer
,
RTC
::
RtpReceiver
*
rtpReceiver
,
RTC
::
RTCP
::
SdesChunk
*
chunk
)
override
;
virtual
void
onPeerRtcpSdesChunk
(
RTC
::
Peer
*
peer
,
RTC
::
RtpReceiver
*
rtpReceiver
,
RTC
::
RTCP
::
SdesChunk
*
chunk
)
override
;
virtual
void
onPeerRtcpCompleted
(
RTC
::
Peer
*
peer
)
override
;
public
:
public
:
// Passed by argument.
// Passed by argument.
...
...
worker/include/RTC/RtpReceiver.h
浏览文件 @
b515d37e
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
#include "RTC/RtpStreamRecv.h"
#include "RTC/RtpStreamRecv.h"
#include "RTC/RTCP/ReceiverReport.h"
#include "RTC/RTCP/ReceiverReport.h"
#include "RTC/RTCP/Feedback.h"
#include "RTC/RTCP/Feedback.h"
#include "RTC/RTCP/CompoundPacket.h"
#include "Channel/Request.h"
#include "Channel/Request.h"
#include "Channel/Notifier.h"
#include "Channel/Notifier.h"
#include <string>
#include <string>
...
@@ -49,7 +50,7 @@ namespace RTC
...
@@ -49,7 +50,7 @@ namespace RTC
RTC
::
RtpParameters
*
GetParameters
();
RTC
::
RtpParameters
*
GetParameters
();
void
ReceiveRtpPacket
(
RTC
::
RtpPacket
*
packet
);
void
ReceiveRtpPacket
(
RTC
::
RtpPacket
*
packet
);
void
ReceiveRtcpSenderReport
(
RTC
::
RTCP
::
SenderReport
*
report
);
void
ReceiveRtcpSenderReport
(
RTC
::
RTCP
::
SenderReport
*
report
);
RTC
::
RTCP
::
ReceiverReport
*
GetRtcpReceiverReport
(
);
void
GetRtcp
(
RTC
::
RTCP
::
CompoundPacket
*
packet
,
uint64_t
now
);
void
ReceiveRtcpFeedback
(
RTC
::
RTCP
::
FeedbackPsPacket
*
packet
);
void
ReceiveRtcpFeedback
(
RTC
::
RTCP
::
FeedbackPsPacket
*
packet
);
void
ReceiveRtcpFeedback
(
RTC
::
RTCP
::
FeedbackRtpPacket
*
packet
);
void
ReceiveRtcpFeedback
(
RTC
::
RTCP
::
FeedbackRtpPacket
*
packet
);
...
@@ -73,6 +74,9 @@ namespace RTC
...
@@ -73,6 +74,9 @@ namespace RTC
// Others.
// Others.
bool
rtpRawEventEnabled
=
false
;
bool
rtpRawEventEnabled
=
false
;
bool
rtpObjectEventEnabled
=
false
;
bool
rtpObjectEventEnabled
=
false
;
// Timestamp when last RTCP was sent.
uint64_t
lastRtcpSentTime
=
0
;
uint16_t
maxRtcpInterval
;
};
};
/* Inline methods. */
/* Inline methods. */
...
...
worker/include/RTC/RtpSender.h
浏览文件 @
b515d37e
...
@@ -6,9 +6,11 @@
...
@@ -6,9 +6,11 @@
#include "RTC/RtpStreamSend.h"
#include "RTC/RtpStreamSend.h"
#include "RTC/RtpDictionaries.h"
#include "RTC/RtpDictionaries.h"
#include "RTC/RtpPacket.h"
#include "RTC/RtpPacket.h"
#include "RTC/RtpDataCounter.h"
#include "RTC/RTCP/SenderReport.h"
#include "RTC/RTCP/SenderReport.h"
#include "RTC/RTCP/Sdes.h"
#include "RTC/RTCP/Sdes.h"
#include "RTC/RTCP/FeedbackRtpNack.h"
#include "RTC/RTCP/FeedbackRtpNack.h"
#include "RTC/RTCP/CompoundPacket.h"
#include "Channel/Request.h"
#include "Channel/Request.h"
#include "Channel/Notifier.h"
#include "Channel/Notifier.h"
#include <unordered_set>
#include <unordered_set>
...
@@ -48,10 +50,10 @@ namespace RTC
...
@@ -48,10 +50,10 @@ namespace RTC
RTC
::
RtpParameters
*
GetParameters
();
RTC
::
RtpParameters
*
GetParameters
();
void
SendRtpPacket
(
RTC
::
RtpPacket
*
packet
);
void
SendRtpPacket
(
RTC
::
RtpPacket
*
packet
);
void
ReceiveRtcpSenderReport
(
RTC
::
RTCP
::
SenderReport
*
report
);
void
ReceiveRtcpSenderReport
(
RTC
::
RTCP
::
SenderReport
*
report
);
RTC
::
RTCP
::
SenderReport
*
GetRtcpSenderReport
();
void
ReceiveRtcpSdesChunk
(
RTC
::
RTCP
::
SdesChunk
*
chunk
);
void
ReceiveRtcpSdesChunk
(
RTC
::
RTCP
::
SdesChunk
*
chunk
);
RTC
::
RTCP
::
SdesChunk
*
GetRtcpSdesChunk
(
);
void
GetRtcp
(
RTC
::
RTCP
::
CompoundPacket
*
packet
,
uint64_t
now
);
void
ReceiveNack
(
RTC
::
RTCP
::
FeedbackRtpNackPacket
*
nackPacket
);
void
ReceiveNack
(
RTC
::
RTCP
::
FeedbackRtpNackPacket
*
nackPacket
);
uint32_t
GetTransmissionRate
(
uint64_t
now
);
private
:
private
:
void
RetransmitRtpPacket
(
RTC
::
RtpPacket
*
packet
);
void
RetransmitRtpPacket
(
RTC
::
RtpPacket
*
packet
);
...
@@ -77,6 +79,14 @@ namespace RTC
...
@@ -77,6 +79,14 @@ namespace RTC
// Sender Report holding the RTP stats.
// Sender Report holding the RTP stats.
std
::
unique_ptr
<
RTC
::
RTCP
::
SenderReport
>
senderReport
;
std
::
unique_ptr
<
RTC
::
RTCP
::
SenderReport
>
senderReport
;
std
::
unique_ptr
<
RTC
::
RTCP
::
SdesChunk
>
sdesChunk
;
std
::
unique_ptr
<
RTC
::
RTCP
::
SdesChunk
>
sdesChunk
;
// RTP counters.
RTC
::
RtpDataCounter
transmitted
;
// Timestamp when last RTCP was sent.
uint64_t
lastRtcpSentTime
=
0
;
uint16_t
maxRtcpInterval
;
// TODO: keep track of retransmitted data too.
//RTC::RtpDataCounter retransmitted;
};
};
/* Inline methods. */
/* Inline methods. */
...
@@ -113,12 +123,6 @@ namespace RTC
...
@@ -113,12 +123,6 @@ namespace RTC
this
->
senderReport
->
Serialize
();
this
->
senderReport
->
Serialize
();
};
};
inline
RTC
::
RTCP
::
SenderReport
*
RtpSender
::
GetRtcpSenderReport
()
{
return
this
->
senderReport
.
release
();
};
inline
inline
void
RtpSender
::
ReceiveRtcpSdesChunk
(
RTC
::
RTCP
::
SdesChunk
*
chunk
)
void
RtpSender
::
ReceiveRtcpSdesChunk
(
RTC
::
RTCP
::
SdesChunk
*
chunk
)
{
{
...
@@ -127,9 +131,9 @@ namespace RTC
...
@@ -127,9 +131,9 @@ namespace RTC
};
};
inline
inline
RTC
::
RTCP
::
SdesChunk
*
RtpSender
::
GetRtcpSdesChunk
(
)
uint32_t
RtpSender
::
GetTransmissionRate
(
uint64_t
now
)
{
{
return
this
->
sdesChunk
.
release
(
);
return
this
->
transmitted
.
GetRate
(
now
);
};
};
}
}
...
...
worker/src/RTC/Peer.cpp
浏览文件 @
b515d37e
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
#include "RTC/RTCP/FeedbackRtpNack.h"
#include "RTC/RTCP/FeedbackRtpNack.h"
#include "MediaSoupError.h"
#include "MediaSoupError.h"
#include "Logger.h"
#include "Logger.h"
#include "DepLibUV.h"
namespace
RTC
namespace
RTC
{
{
...
@@ -23,11 +24,19 @@ namespace RTC
...
@@ -23,11 +24,19 @@ namespace RTC
notifier
(
notifier
)
notifier
(
notifier
)
{
{
MS_TRACE
();
MS_TRACE
();
this
->
timer
=
new
Timer
(
this
);
// Start the RTCP timer.
this
->
timer
->
Start
(
uint64_t
(
RTC
::
RTCP
::
MAX_VIDEO_INTERVAL_MS
/
2
));
}
}
Peer
::~
Peer
()
Peer
::~
Peer
()
{
{
MS_TRACE
();
MS_TRACE
();
// Close the RTCP timer.
this
->
timer
->
Close
();
}
}
void
Peer
::
Close
()
void
Peer
::
Close
()
...
@@ -510,7 +519,7 @@ namespace RTC
...
@@ -510,7 +519,7 @@ namespace RTC
return
nullptr
;
return
nullptr
;
}
}
void
Peer
::
SendRtcp
()
void
Peer
::
SendRtcp
(
uint64_t
now
)
{
{
MS_TRACE
();
MS_TRACE
();
...
@@ -521,7 +530,7 @@ namespace RTC
...
@@ -521,7 +530,7 @@ namespace RTC
for
(
auto
it
=
this
->
transports
.
begin
();
it
!=
this
->
transports
.
end
();
++
it
)
for
(
auto
it
=
this
->
transports
.
begin
();
it
!=
this
->
transports
.
end
();
++
it
)
{
{
RTC
::
RTCP
::
CompoundPacket
packet
;
std
::
unique_ptr
<
RTC
::
RTCP
::
CompoundPacket
>
packet
(
new
RTC
::
RTCP
::
CompoundPacket
())
;
RTC
::
Transport
*
transport
=
it
->
second
;
RTC
::
Transport
*
transport
=
it
->
second
;
for
(
auto
it
=
this
->
rtpSenders
.
begin
();
it
!=
this
->
rtpSenders
.
end
();
++
it
)
for
(
auto
it
=
this
->
rtpSenders
.
begin
();
it
!=
this
->
rtpSenders
.
end
();
++
it
)
...
@@ -531,24 +540,26 @@ namespace RTC
...
@@ -531,24 +540,26 @@ namespace RTC
if
(
rtpSender
->
GetTransport
()
!=
transport
)
if
(
rtpSender
->
GetTransport
()
!=
transport
)
continue
;
continue
;
RTC
::
RTCP
::
SenderReport
*
report
=
rtpSender
->
GetRtcpSenderReport
(
);
rtpSender
->
GetRtcp
(
packet
.
get
(),
now
);
if
(
report
)
// Send one RTCP compound packet per sender report.
if
(
packet
->
GetSenderReportCount
())
{
{
packet
.
AddSenderReport
(
report
);
// Ensure that the RTCP packet fits into the RTCP buffer.
if
(
packet
->
GetSize
()
>
MS_RTCP_BUFFER_SIZE
)
{
MS_WARN_TAG
(
rtcp
,
"cannot send RTCP packet, size too big (%zu bytes)"
,
packet
->
GetSize
());
return
;
}
RTC
::
RTCP
::
SdesChunk
*
chunk
=
rtpSender
->
GetRtcpSdesChunk
();
packet
->
Serialize
(
Peer
::
rtcpBuffer
);
if
(
chunk
)
transport
->
SendRtcpCompoundPacket
(
packet
.
get
());
packet
.
AddSdesChunk
(
chunk
);
break
;
// reset the Compound packet.
packet
.
reset
(
new
RTC
::
RTCP
::
CompoundPacket
());
}
}
}
}
// TMP: only send RR if SR is also being sent.
// if (packet.GetSenderReportCount() == 0)
// return;
for
(
auto
it
=
this
->
rtpReceivers
.
begin
();
it
!=
this
->
rtpReceivers
.
end
();
++
it
)
for
(
auto
it
=
this
->
rtpReceivers
.
begin
();
it
!=
this
->
rtpReceivers
.
end
();
++
it
)
{
{
RTC
::
RtpReceiver
*
rtpReceiver
=
it
->
second
;
RTC
::
RtpReceiver
*
rtpReceiver
=
it
->
second
;
...
@@ -556,21 +567,22 @@ namespace RTC
...
@@ -556,21 +567,22 @@ namespace RTC
if
(
rtpReceiver
->
GetTransport
()
!=
transport
)
if
(
rtpReceiver
->
GetTransport
()
!=
transport
)
continue
;
continue
;
RTC
::
RTCP
::
ReceiverReport
*
report
=
rtpReceiver
->
GetRtcpReceiverReport
();
rtpReceiver
->
GetRtcp
(
packet
.
get
(),
now
);
if
(
report
)
packet
.
AddReceiverReport
(
report
);
}
}
//
Ensure that the RTCP packet fits into the RTCP buffer
.
//
Send one RTCP compound with all receiver reports
.
if
(
packet
.
GetSize
()
>
MS_RTCP_BUFFER_SIZE
)
if
(
packet
->
GetReceiverReportCount
()
)
{
{
MS_WARN_TAG
(
rtcp
,
"cannot send RTCP packet, size too big (%zu bytes)"
,
packet
.
GetSize
());
// Ensure that the RTCP packet fits into the RTCP buffer.
return
;
if
(
packet
->
GetSize
()
>
MS_RTCP_BUFFER_SIZE
)
}
{
MS_WARN_TAG
(
rtcp
,
"cannot send RTCP packet, size too big (%zu bytes)"
,
packet
->
GetSize
());
return
;
}
packet
.
Serialize
(
Peer
::
rtcpBuffer
);
packet
->
Serialize
(
Peer
::
rtcpBuffer
);
transport
->
SendRtcpCompoundPacket
(
&
packet
);
transport
->
SendRtcpCompoundPacket
(
packet
.
get
());
}
}
}
}
}
...
@@ -904,10 +916,6 @@ namespace RTC
...
@@ -904,10 +916,6 @@ namespace RTC
packet
=
packet
->
GetNext
();
packet
=
packet
->
GetNext
();
}
}
// TMP: Notify the listener about an incoming RTCP processing termination.
// Used for now as a trigger to relay the processed RTCP data accordingly.
this
->
listener
->
onPeerRtcpCompleted
(
this
);
}
}
void
Peer
::
onRtpReceiverClosed
(
RTC
::
RtpReceiver
*
rtpReceiver
)
void
Peer
::
onRtpReceiverClosed
(
RTC
::
RtpReceiver
*
rtpReceiver
)
...
@@ -939,4 +947,41 @@ namespace RTC
...
@@ -939,4 +947,41 @@ namespace RTC
// Notify the listener (Room) so it can remove this RtpSender from its map.
// Notify the listener (Room) so it can remove this RtpSender from its map.
this
->
listener
->
onPeerRtpSenderClosed
(
this
,
rtpSender
);
this
->
listener
->
onPeerRtpSenderClosed
(
this
,
rtpSender
);
}
}
void
Peer
::
onTimer
(
Timer
*
timer
)
{
uint64_t
interval
=
RTC
::
RTCP
::
MAX_VIDEO_INTERVAL_MS
;
uint32_t
now
=
DepLibUV
::
GetTime
();
// Transmission rate in kbps.
uint32_t
rate
=
0
;
this
->
SendRtcp
(
now
);
// Recalculate next RTCP interval.
if
(
this
->
rtpSenders
.
size
())
{
// Get the RTP sending rate.
for
(
auto
&
kv
:
this
->
rtpSenders
)
{
RTC
::
RtpSender
*
rtpSender
=
kv
.
second
;
rate
+=
rtpSender
->
GetTransmissionRate
(
now
)
/
1000
;
}
// Calculate bandwidth: 360 / transmission bandwidth in kbit/s
if
(
rate
)
interval
=
360000
/
rate
;
if
(
interval
>
RTC
::
RTCP
::
MAX_VIDEO_INTERVAL_MS
)
interval
=
RTC
::
RTCP
::
MAX_VIDEO_INTERVAL_MS
;
}
/* The interval between RTCP packets is varied randomly over the range
* [0.5,1.5] times the calculated interval to avoid unintended synchronization
* of all participants.
*/
interval
*=
static_cast
<
float
>
(
Utils
::
Crypto
::
GetRandomUInt
(
5
,
15
))
/
10
;
this
->
timer
->
Start
(
interval
);
}
}
}
worker/src/RTC/Room.cpp
浏览文件 @
b515d37e
...
@@ -685,18 +685,4 @@ namespace RTC
...
@@ -685,18 +685,4 @@ namespace RTC
rtpSender
->
ReceiveRtcpSdesChunk
(
chunk
);
rtpSender
->
ReceiveRtcpSdesChunk
(
chunk
);
}
}
}
}
void
Room
::
onPeerRtcpCompleted
(
RTC
::
Peer
*
peer
)
{
MS_TRACE
();
// Tell all the peers but the one in the argument to generate and send their RTCP.
for
(
auto
it
=
this
->
peers
.
begin
();
it
!=
this
->
peers
.
end
();
++
it
)
{
RTC
::
Peer
*
current_peer
=
it
->
second
;
if
(
current_peer
!=
peer
)
current_peer
->
SendRtcp
();
}
}
}
}
worker/src/RTC/RtpReceiver.cpp
浏览文件 @
b515d37e
...
@@ -22,6 +22,11 @@ namespace RTC
...
@@ -22,6 +22,11 @@ namespace RTC
notifier
(
notifier
)
notifier
(
notifier
)
{
{
MS_TRACE
();
MS_TRACE
();
if
(
this
->
kind
==
RTC
::
Media
::
Kind
::
AUDIO
)
this
->
maxRtcpInterval
=
RTC
::
RTCP
::
MAX_AUDIO_INTERVAL_MS
;
else
this
->
maxRtcpInterval
=
RTC
::
RTCP
::
MAX_VIDEO_INTERVAL_MS
;
}
}
RtpReceiver
::~
RtpReceiver
()
RtpReceiver
::~
RtpReceiver
()
...
@@ -284,20 +289,20 @@ namespace RTC
...
@@ -284,20 +289,20 @@ namespace RTC
// SSRC values in received RTP packets to match the chosen random values.
// SSRC values in received RTP packets to match the chosen random values.
}
}
RTC
::
RTCP
::
ReceiverReport
*
RtpReceiver
::
GetRtcpReceiverReport
(
)
void
RtpReceiver
::
GetRtcp
(
RTC
::
RTCP
::
CompoundPacket
*
packet
,
uint64_t
now
)
{
{
if
(
this
->
rtpStream
)
if
(
this
->
rtpStream
)
{
{
RTC
::
RTCP
::
ReceiverReport
*
report
=
this
->
rtpStream
->
GetRtcpReceiverReport
();
if
(
static_cast
<
float
>
((
now
-
this
->
lastRtcpSentTime
)
*
1.15
)
>=
this
->
maxRtcpInterval
)
{
RTC
::
RTCP
::
ReceiverReport
*
report
=
this
->
rtpStream
->
GetRtcpReceiverReport
();
// TODO: This assumes a single stream for now.
// TODO: This assumes a single stream for now.
report
->
SetSsrc
(
this
->
rtpParameters
->
encodings
[
0
].
ssrc
);
report
->
SetSsrc
(
this
->
rtpParameters
->
encodings
[
0
].
ssrc
);
packet
->
AddReceiverReport
(
report
);
return
report
;
this
->
lastRtcpSentTime
=
now
;
}
}
else
{
return
nullptr
;
}
}
}
}
...
...
worker/src/RTC/RtpSender.cpp
浏览文件 @
b515d37e
...
@@ -23,6 +23,11 @@ namespace RTC
...
@@ -23,6 +23,11 @@ namespace RTC
notifier
(
notifier
)
notifier
(
notifier
)
{
{
MS_TRACE
();
MS_TRACE
();
if
(
this
->
kind
==
RTC
::
Media
::
Kind
::
AUDIO
)
this
->
maxRtcpInterval
=
RTC
::
RTCP
::
MAX_AUDIO_INTERVAL_MS
;
else
this
->
maxRtcpInterval
=
RTC
::
RTCP
::
MAX_VIDEO_INTERVAL_MS
;
}
}
RtpSender
::~
RtpSender
()
RtpSender
::~
RtpSender
()
...
@@ -260,8 +265,28 @@ namespace RTC
...
@@ -260,8 +265,28 @@ namespace RTC
// Send the packet.
// Send the packet.
this
->
transport
->
SendRtpPacket
(
packet
);
this
->
transport
->
SendRtpPacket
(
packet
);
// Save RTP data
transmitted
.
Update
(
packet
);
}
}
void
RtpSender
::
GetRtcp
(
RTC
::
RTCP
::
CompoundPacket
*
packet
,
uint64_t
now
)
{
// TODO: Until we generate Sender Report.
if
(
this
->
senderReport
)
{
if
(
static_cast
<
float
>
((
now
-
this
->
lastRtcpSentTime
)
*
1.15
)
>=
this
->
maxRtcpInterval
)
{
packet
->
AddSenderReport
(
this
->
senderReport
.
release
());
if
(
this
->
sdesChunk
)
packet
->
AddSdesChunk
(
this
->
sdesChunk
.
release
());
this
->
lastRtcpSentTime
=
now
;
}
}
};
void
RtpSender
::
ReceiveNack
(
RTC
::
RTCP
::
FeedbackRtpNackPacket
*
nackPacket
)
void
RtpSender
::
ReceiveNack
(
RTC
::
RTCP
::
FeedbackRtpNackPacket
*
nackPacket
)
{
{
MS_TRACE
();
MS_TRACE
();
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论