Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calculate the correct payload_size which pure padding data, in the process of rtc2rtmp, make Chrome happy #2461

Merged
merged 3 commits into from
Jul 8, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions trunk/src/app/srs_app_rtc_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1527,7 +1527,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<SrsRtpFUAPayload2*>(pkt->payload());
if (fua_payload) {
if (fua_payload && fua_payload->size > 0) {
if (fua_payload->start) {
nb_payload += 1 + 4;
}
Expand All @@ -1539,18 +1539,25 @@ 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<SrsRtpRawPayload*>(pkt->payload());
if (raw_payload) {
if (raw_payload && raw_payload->nn_payload > 0) {
nb_payload += 4 + raw_payload->nn_payload;
continue;
}
}

if (5 == nb_payload) {
Copy link
Member

@winlinvip winlinvip Jul 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it 5? The magic number needs to have a comment.

TRANS_BY_GPT3

Copy link
Member Author

@duiniuluantanqin duiniuluantanqin Jul 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aad19c1
I made some adjustments, and now this 5 can be more clear.

TRANS_BY_GPT3

srs_warn("empty nalu");
return err;
}

SrsCommonMessage rtmp;
SrsRtpPacket* header = cache_video_pkts_[cache_index(start)].pkt;
rtmp.header.initialize_video(nb_payload, header->header.get_timestamp() / 90, 1);
Expand Down