SRT: Fix bug for multiple NALUs, when configure OBS in zerolatency. (#2440)

* solve srt push bugs

* solve h264 mutiple nalus in srt when obs is configured in zerolatency

* optimize error code

* optimize error code

* optimize error code

* add commemnt:we only skip pps/sps frame and send left nalus in srt

* add commemnt:we only skip pps/sps frame and send left nalus in srt

Co-authored-by: shiwei <shiwei05@kuaishou.com>
pull/2452/head
Alex.CR 4 years ago committed by GitHub
parent 0391e71682
commit 346cc96d7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -466,14 +466,14 @@ srs_error_t rtmp_client::on_ts_video(std::shared_ptr<SrsBuffer> avs_ptr, uint64_
return srs_error_wrap(err, "demux annexb"); return srs_error_wrap(err, "demux annexb");
} }
//srs_trace_data(frame, frame_size, "video annexb demux:");
// 5bits, 7.3.1 NAL unit syntax, // 5bits, 7.3.1 NAL unit syntax,
// ISO_IEC_14496-10-AVC-2003.pdf, page 44. // ISO_IEC_14496-10-AVC-2003.pdf, page 44.
// 7: SPS, 8: PPS, 5: I Frame, 1: P Frame // 7: SPS, 8: PPS, 5: I Frame, 1: P Frame
SrsAvcNaluType nal_unit_type = (SrsAvcNaluType)(frame[0] & 0x1f); SrsAvcNaluType nal_unit_type = (SrsAvcNaluType)(frame[0] & 0x1f);
// ignore the nalu type sps(7), pps(8), aud(9) // ignore the nalu type aud(9), pad(12)
if (nal_unit_type == SrsAvcNaluTypeAccessUnitDelimiter) { if ((nal_unit_type == SrsAvcNaluTypeAccessUnitDelimiter)
|| (nal_unit_type == SrsAvcNaluTypeFilterData)) {
continue; continue;
} }
@ -523,12 +523,14 @@ srs_error_t rtmp_client::on_ts_video(std::shared_ptr<SrsBuffer> avs_ptr, uint64_
} }
// ibp frame. // ibp frame.
// TODO: FIXME: we should group all frames to a rtmp/flv message from one ts message. // for Issue: https://github.com/ossrs/srs/issues/2390
srs_info("mpegts: demux avc ibp frame size=%d, dts=%d", frame_size, dts); // we only skip pps/sps frame and send left nalus.
if ((err = write_h264_ipb_frame(frame, frame_size, dts, pts)) != srs_success) { srs_info("mpegts: demux avc ibp frame size=%d, dts=%d", avs_ptr->left() + frame_size, dts);
if ((err = write_h264_ipb_frame(avs_ptr->head() - frame_size, avs_ptr->left() + frame_size, dts, pts)) != srs_success) {
return srs_error_wrap(err, "write frame"); return srs_error_wrap(err, "write frame");
} }
_last_live_ts = now_ms(); _last_live_ts = now_ms();
break;
} }
return err; return err;

Loading…
Cancel
Save