diff --git a/CHANGELOG.md b/CHANGELOG.md index 56519ef06..a62fc57a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ The changelog for SRS. ## SRS 4.0 Changelog +* v4.0, 2021-07-08, For [#2403](https://github.com/ossrs/srs/issues/2403), fix padding packets for RTMP2RTC. 4.0.140 * v4.0, 2021-07-04, For [#2424](https://github.com/ossrs/srs/issues/2424), use srandom/random to generate. 4.0.139 * v4.0, 2021-07-01, Merge [#2452](https://github.com/ossrs/srs/pull/2452), fix FFmpeg bug by updating channel_layout. 4.0.138 * v4.0, 2021-06-30, Merge [#2440](https://github.com/ossrs/srs/pull/2440), fix [#2390](https://github.com/ossrs/srs/issues/2390), SRT bug for zerolatency. 4.0.137 diff --git a/trunk/src/app/srs_app_rtc_source.cpp b/trunk/src/app/srs_app_rtc_source.cpp index 9470d5594..d0e719217 100644 --- a/trunk/src/app/srs_app_rtc_source.cpp +++ b/trunk/src/app/srs_app_rtc_source.cpp @@ -1517,8 +1517,7 @@ srs_error_t SrsRtmpFromRtcBridger::packet_video_rtmp(const uint16_t start, const { srs_error_t err = srs_success; - //type_codec1 + avc_type + composition time + nalu size + nalu - int nb_payload = 1 + 1 + 3; + int nb_payload = 0; uint16_t cnt = end - start + 1; for (uint16_t i = 0; i < cnt; ++i) { @@ -1527,7 +1526,7 @@ srs_error_t SrsRtmpFromRtcBridger::packet_video_rtmp(const uint16_t start, const SrsRtpPacket* pkt = cache_video_pkts_[index].pkt; // calculate nalu len SrsRtpFUAPayload2* fua_payload = dynamic_cast(pkt->payload()); - if (fua_payload) { + if (fua_payload && fua_payload->size > 0) { if (fua_payload->start) { nb_payload += 1 + 4; } @@ -1539,18 +1538,28 @@ srs_error_t SrsRtmpFromRtcBridger::packet_video_rtmp(const uint16_t start, const if (stap_payload) { for (int j = 0; j < (int)stap_payload->nalus.size(); ++j) { SrsSample* sample = stap_payload->nalus.at(j); - nb_payload += 4 + sample->size; + if (sample->size > 0) { + nb_payload += 4 + sample->size; + } } continue; } SrsRtpRawPayload* raw_payload = dynamic_cast(pkt->payload()); - if (raw_payload) { + if (raw_payload && raw_payload->nn_payload > 0) { nb_payload += 4 + raw_payload->nn_payload; continue; } } + if (0 == nb_payload) { + srs_warn("empty nalu"); + return err; + } + + //type_codec1 + avc_type + composition time + nalu size + nalu + nb_payload += 1 + 1 + 3; + SrsCommonMessage rtmp; SrsRtpPacket* header = cache_video_pkts_[cache_index(start)].pkt; rtmp.header.initialize_video(nb_payload, header->header.get_timestamp() / 90, 1); @@ -1578,7 +1587,7 @@ srs_error_t SrsRtmpFromRtcBridger::packet_video_rtmp(const uint16_t start, const cache_video_pkts_[index].sn = 0; SrsRtpFUAPayload2* fua_payload = dynamic_cast(pkt->payload()); - if (fua_payload) { + if (fua_payload && fua_payload->size > 0) { if (fua_payload->start) { nalu_len = fua_payload->size + 1; //skip 4 bytes to write nalu_len future @@ -1603,15 +1612,17 @@ srs_error_t SrsRtmpFromRtcBridger::packet_video_rtmp(const uint16_t start, const if (stap_payload) { for (int j = 0; j < (int)stap_payload->nalus.size(); ++j) { SrsSample* sample = stap_payload->nalus.at(j); - payload.write_4bytes(sample->size); - payload.write_bytes(sample->bytes, sample->size); + if (sample->size > 0) { + payload.write_4bytes(sample->size); + payload.write_bytes(sample->bytes, sample->size); + } } srs_freep(pkt); continue; } SrsRtpRawPayload* raw_payload = dynamic_cast(pkt->payload()); - if (raw_payload) { + if (raw_payload && raw_payload->nn_payload > 0) { payload.write_4bytes(raw_payload->nn_payload); payload.write_bytes(raw_payload->payload, raw_payload->nn_payload); srs_freep(pkt); diff --git a/trunk/src/core/srs_core_version4.hpp b/trunk/src/core/srs_core_version4.hpp index 54605d270..932132f0a 100644 --- a/trunk/src/core/srs_core_version4.hpp +++ b/trunk/src/core/srs_core_version4.hpp @@ -9,6 +9,6 @@ #define VERSION_MAJOR 4 #define VERSION_MINOR 0 -#define VERSION_REVISION 139 +#define VERSION_REVISION 140 #endif