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

Send SPS/PPS before IDR

This commit is contained in:
winlin 2020-04-12 01:13:31 +08:00
parent 79d46fa2e1
commit 5e66a0d342

View file

@ -641,15 +641,6 @@ srs_error_t SrsRtcSenderThread::send_messages(
*pnn_rtp_pkts += 1; *pnn_rtp_pkts += 1;
} }
} else { } else {
for (int i = 0; i < msg->nn_samples(); i++) {
SrsSample* sample = msg->samples() + i;
// We always ignore bframe here, if config to discard bframe,
// the bframe flag will not be set.
if (sample->bframe) {
continue;
}
// Well, for each IDR, we append a SPS/PPS before it, which is packaged in STAP-A. // Well, for each IDR, we append a SPS/PPS before it, which is packaged in STAP-A.
if (msg->has_idr()) { if (msg->has_idr()) {
SrsRtpPacket2* packet = NULL; SrsRtpPacket2* packet = NULL;
@ -667,6 +658,15 @@ srs_error_t SrsRtcSenderThread::send_messages(
} }
vector<SrsRtpPacket2*> packets; vector<SrsRtpPacket2*> packets;
for (int i = 0; i < msg->nn_samples(); i++) {
SrsSample* sample = msg->samples() + i;
// We always ignore bframe here, if config to discard bframe,
// the bframe flag will not be set.
if (sample->bframe) {
continue;
}
if (sample->size <= kRtpMaxPayloadSize) { if (sample->size <= kRtpMaxPayloadSize) {
SrsRtpPacket2* packet = NULL; SrsRtpPacket2* packet = NULL;
if ((err = packet_single_nalu(msg, sample, &packet)) != srs_success) { if ((err = packet_single_nalu(msg, sample, &packet)) != srs_success) {
@ -678,8 +678,9 @@ srs_error_t SrsRtcSenderThread::send_messages(
return srs_error_wrap(err, "packet fu-a"); return srs_error_wrap(err, "packet fu-a");
} }
} }
}
if (i == msg->nn_samples() - 1) { if (!packets.empty()) {
packets.back()->rtp_header.set_marker(true); packets.back()->rtp_header.set_marker(true);
} }
@ -694,7 +695,6 @@ srs_error_t SrsRtcSenderThread::send_messages(
*pnn_rtp_pkts += (int)packets.size(); *pnn_rtp_pkts += (int)packets.size();
} }
} }
}
return err; return err;
} }