1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

Refactor RTC publish queue

This commit is contained in:
winlin 2020-05-05 06:41:19 +08:00
parent 8c4b6d3166
commit 42ae71e96c

View file

@ -384,29 +384,31 @@ void SrsRtpAudioQueue::collect_frames(SrsRtpNackForReceiver* nack, vector<SrsRtp
{ {
// When done, next point to the next available packet. // When done, next point to the next available packet.
uint16_t next = queue_->begin; uint16_t next = queue_->begin;
for (; next != queue_->end; ++next) {
SrsRtpPacket2* pkt = queue_->at(next);
// If nack disabled, we ignore any empty packet. // If nack disabled, we ignore any empty packet.
if (!nack) { if (!nack) {
if (!pkt) { for (; next != queue_->end; ++next) {
continue; SrsRtpPacket2* pkt = queue_->at(next);
if (pkt) {
frames.push_back(pkt);
}
}
} else {
for (; next != queue_->end; ++next) {
SrsRtpPacket2* pkt = queue_->at(next);
// TODO: FIXME: Should not wait for NACK packets.
// Not found or in NACK, stop collecting frame.
if (!pkt || nack->find(next) != NULL) {
srs_trace("wait for nack seq=%u", next);
break;
} }
frames.push_back(pkt); frames.push_back(pkt);
continue;
} }
// TODO: FIXME: Should not wait for NACK packets.
// Not found or in NACK, stop collecting frame.
if (!pkt || nack->find(next) != NULL) {
srs_trace("wait for nack seq=%u", next);
break;
}
frames.push_back(pkt);
} }
// Reap packets from begin to next.
if (next != queue_->begin) { if (next != queue_->begin) {
// Reset the range of packets to NULL in buffer. // Reset the range of packets to NULL in buffer.
queue_->reset(queue_->begin, next); queue_->reset(queue_->begin, next);
@ -540,12 +542,11 @@ void SrsRtpVideoQueue::collect_frame(SrsRtpNackForReceiver* nack, SrsRtpPacket2*
// When done, next point to the next available packet. // When done, next point to the next available packet.
uint16_t next = queue_->begin; uint16_t next = queue_->begin;
for (; next != queue_->end; ++next) {
SrsRtpPacket2* pkt = queue_->at(next);
// TODO: FIXME: We should skip whole packet. // If nack disabled, we ignore any empty packet.
// If nack disabled, we ignore any empty packet. if (!nack) {
if (!nack) { for (; next != queue_->end; ++next) {
SrsRtpPacket2* pkt = queue_->at(next);
if (!pkt) { if (!pkt) {
continue; continue;
} }
@ -561,30 +562,33 @@ void SrsRtpVideoQueue::collect_frame(SrsRtpNackForReceiver* nack, SrsRtpPacket2*
next++; next++;
break; break;
} }
continue;
} }
} else {
for (; next != queue_->end; ++next) {
SrsRtpPacket2* pkt = queue_->at(next);
// TODO: FIXME: Should not wait for NACK packets. // TODO: FIXME: Should not wait for NACK packets.
// Not found or in NACK, stop collecting frame. // Not found or in NACK, stop collecting frame.
if (!pkt || nack->find(next) != NULL) { if (!pkt || nack->find(next) != NULL) {
srs_trace("wait for nack seq=%u", next); srs_trace("wait for nack seq=%u", next);
return; return;
} }
// Ignore when the first packet not the start. // Ignore when the first packet not the start.
if (frame.empty() && !pkt->video_is_first_packet) { if (frame.empty() && !pkt->video_is_first_packet) {
return; return;
} }
// OK, collect packet to frame. // OK, collect packet to frame.
frame.push_back(pkt); frame.push_back(pkt);
// Done, we got the last packet of frame. // Done, we got the last packet of frame.
// @remark Note that the STAP-A is marker false and it's the last packet. // @remark Note that the STAP-A is marker false and it's the last packet.
if (pkt->rtp_header.get_marker() || pkt->video_is_last_packet) { if (pkt->rtp_header.get_marker() || pkt->video_is_last_packet) {
found = true; found = true;
next++; next++;
break; break;
}
} }
} }