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

fix: unrecognized fmtp parameter caused crash #3162

Conversation

underthere
Copy link

Please describe the summary for this PR.

relative issue: #3093

@underthere underthere changed the title fix: unrecognized fmtp parameter caused crash #3093 fix: unrecognized fmtp parameter caused crash Sep 1, 2022
@@ -59,6 +59,9 @@ srs_error_t srs_parse_h264_fmtp(const std::string& fmtp, H264SpecificParam& h264
std::vector<std::string> vec = split_str(fmtp, ";");
for (size_t i = 0; i < vec.size(); ++i) {
std::vector<std::string> kv = split_str(vec[i], "=");
if( kv.size() >= 2 && kv[0] == "sprop-parameter-sets") { // ignore sprop-parameter-sets
Copy link
Member

Choose a reason for hiding this comment

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

Why >=2? Should be:

if (!kv.empty() && kv[0] == "sprop-parameter-sets") { // Ignore sprop-parameter-sets

??

@@ -3171,6 +3175,11 @@ srs_error_t SrsRtcConnection::generate_publish_local_sdp(SrsRequest* req, SrsSdp
}
}

if (local_sdp.media_descs_.empty()){
srs_trace("empty media desc!");
Copy link
Member

@winlinvip winlinvip Sep 1, 2022

Choose a reason for hiding this comment

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

Please remove this line, because all information is in err, no need to logging here. The error message should be merged to err.

@@ -3131,9 +3131,14 @@ srs_error_t SrsRtcConnection::generate_publish_local_sdp(SrsRequest* req, SrsSdp
for (int i = 0; i < (int)stream_desc->video_track_descs_.size(); ++i) {
SrsRtcTrackDescription* video_track = stream_desc->video_track_descs_.at(i);

SrsVideoPayload* payload = (SrsVideoPayload*)video_track->media_;
if (payload == NULL){
Copy link
Member

Choose a reason for hiding this comment

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

Should be replaced by:

if (!video_track->media_) break;

?

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for your review!
Is there any coding style guide? Someone likes me may need it.

@@ -59,6 +59,9 @@ srs_error_t srs_parse_h264_fmtp(const std::string& fmtp, H264SpecificParam& h264
std::vector<std::string> vec = split_str(fmtp, ";");
for (size_t i = 0; i < vec.size(); ++i) {
std::vector<std::string> kv = split_str(vec[i], "=");
if( !kv.empty() && kv[0] == "sprop-parameter-sets") { // ignore sprop-parameter-sets
Copy link
Member

@winlinvip winlinvip Sep 9, 2022

Choose a reason for hiding this comment

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

A better approach is to ignore the ones that are not recognized and only focus on checking if the required parameters meet the requirements.

However, I am still very grateful for the submitted PR. 👍

TRANS_BY_GPT3

@winlinvip
Copy link
Member

winlinvip commented Sep 9, 2022

FMTP parsing improvement, refer to 1c0236a

Improvement for unmatched media, refer to 8ac8ae1

Thank you again for submitting the PR.

TRANS_BY_GPT3

@winlinvip winlinvip closed this Sep 9, 2022
@underthere underthere deleted the bugfix/parse-rtc-sdp-fmtp-unrecognized-parameter-caused-crash branch September 9, 2022 11:26
@winlinvip winlinvip added the TransByAI Translated by AI/GPT. label Jul 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
TransByAI Translated by AI/GPT.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants