mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
tenfold: implement nack ringbuffer notify_nack_list_full and notify_drop_seq
This commit is contained in:
parent
c875639eb6
commit
a3c7be2c75
2 changed files with 15 additions and 1 deletions
|
@ -1457,6 +1457,7 @@ void SrsRtcPublisher::check_send_nacks(SrsRtpNackForReceiver* nack, uint32_t ssr
|
||||||
// @see: https://tools.ietf.org/html/rfc4585#section-6.1
|
// @see: https://tools.ietf.org/html/rfc4585#section-6.1
|
||||||
vector<uint16_t> nack_seqs;
|
vector<uint16_t> nack_seqs;
|
||||||
nack->get_nack_seqs(nack_seqs);
|
nack->get_nack_seqs(nack_seqs);
|
||||||
|
|
||||||
vector<uint16_t>::iterator iter = nack_seqs.begin();
|
vector<uint16_t>::iterator iter = nack_seqs.begin();
|
||||||
while (iter != nack_seqs.end()) {
|
while (iter != nack_seqs.end()) {
|
||||||
char buf[kRtpPacketSize];
|
char buf[kRtpPacketSize];
|
||||||
|
|
|
@ -130,10 +130,19 @@ SrsRtpPacket2* SrsRtpRingBuffer::at(uint16_t seq) {
|
||||||
|
|
||||||
void SrsRtpRingBuffer::notify_nack_list_full()
|
void SrsRtpRingBuffer::notify_nack_list_full()
|
||||||
{
|
{
|
||||||
|
while(begin <= end) {
|
||||||
|
remove(begin);
|
||||||
|
++begin;
|
||||||
|
}
|
||||||
|
|
||||||
|
begin = end = 0;
|
||||||
|
initialized_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SrsRtpRingBuffer::notify_drop_seq(uint16_t seq)
|
void SrsRtpRingBuffer::notify_drop_seq(uint16_t seq)
|
||||||
{
|
{
|
||||||
|
remove(seq);
|
||||||
|
advance_to(seq+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsNackOption::SrsNackOption()
|
SrsNackOption::SrsNackOption()
|
||||||
|
@ -142,7 +151,7 @@ SrsNackOption::SrsNackOption()
|
||||||
max_alive_time = 2 * SRS_UTIME_SECONDS;
|
max_alive_time = 2 * SRS_UTIME_SECONDS;
|
||||||
first_nack_interval = 10 * SRS_UTIME_MILLISECONDS;
|
first_nack_interval = 10 * SRS_UTIME_MILLISECONDS;
|
||||||
nack_interval = 400 * SRS_UTIME_MILLISECONDS;
|
nack_interval = 400 * SRS_UTIME_MILLISECONDS;
|
||||||
//TODO: FIXME:
|
//TODO: FIXME: audio and video using diff nack strategy
|
||||||
// audio_max_retries = 2
|
// audio_max_retries = 2
|
||||||
// video_max_retries = 4
|
// video_max_retries = 4
|
||||||
// nack_interval = 100ms
|
// nack_interval = 100ms
|
||||||
|
@ -201,11 +210,13 @@ void SrsRtpNackForReceiver::check_queue_size()
|
||||||
{
|
{
|
||||||
if (queue_.size() >= max_queue_size_) {
|
if (queue_.size() >= max_queue_size_) {
|
||||||
rtp_->notify_nack_list_full();
|
rtp_->notify_nack_list_full();
|
||||||
|
queue_.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SrsRtpNackForReceiver::get_nack_seqs(vector<uint16_t>& seqs)
|
void SrsRtpNackForReceiver::get_nack_seqs(vector<uint16_t>& seqs)
|
||||||
{
|
{
|
||||||
|
//TODO: use get_system_time to udpate
|
||||||
srs_utime_t now = srs_update_system_time();
|
srs_utime_t now = srs_update_system_time();
|
||||||
srs_utime_t interval = now - pre_check_time_;
|
srs_utime_t interval = now - pre_check_time_;
|
||||||
if (interval < opts_.nack_interval / 2) {
|
if (interval < opts_.nack_interval / 2) {
|
||||||
|
@ -219,7 +230,9 @@ void SrsRtpNackForReceiver::get_nack_seqs(vector<uint16_t>& seqs)
|
||||||
SrsRtpNackInfo& nack_info = iter->second;
|
SrsRtpNackInfo& nack_info = iter->second;
|
||||||
|
|
||||||
int alive_time = now - nack_info.generate_time_;
|
int alive_time = now - nack_info.generate_time_;
|
||||||
|
// TODO: delete max_alive_time
|
||||||
if (alive_time > opts_.max_alive_time || nack_info.req_nack_count_ > opts_.max_count) {
|
if (alive_time > opts_.max_alive_time || nack_info.req_nack_count_ > opts_.max_count) {
|
||||||
|
// TODO: advace_to
|
||||||
rtp_->notify_drop_seq(seq);
|
rtp_->notify_drop_seq(seq);
|
||||||
queue_.erase(iter++);
|
queue_.erase(iter++);
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue