Skip to content

Commit

Permalink
WebRTC: Fix missing msid in play answer
Browse files Browse the repository at this point in the history
  • Loading branch information
parallelcc committed Dec 7, 2024
1 parent 7416134 commit 2281dac
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
14 changes: 8 additions & 6 deletions trunk/src/app/srs_app_rtc_conn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3274,31 +3274,32 @@ srs_error_t SrsRtcConnection::generate_play_local_sdp(SrsRequest* req, SrsSdp& l
std::string cname = srs_random_str(16);

if (audio_before_video) {
if ((err = generate_play_local_sdp_for_audio(local_sdp, stream_desc, cname)) != srs_success) {
if ((err = generate_play_local_sdp_for_audio(local_sdp, stream_desc, cname, stream_id)) != srs_success) {
return srs_error_wrap(err, "audio");
}
if ((err = generate_play_local_sdp_for_video(local_sdp, stream_desc, unified_plan, cname)) != srs_success) {
if ((err = generate_play_local_sdp_for_video(local_sdp, stream_desc, unified_plan, cname, stream_id)) != srs_success) {
return srs_error_wrap(err, "video");
}
} else {
if ((err = generate_play_local_sdp_for_video(local_sdp, stream_desc, unified_plan, cname)) != srs_success) {
if ((err = generate_play_local_sdp_for_video(local_sdp, stream_desc, unified_plan, cname, stream_id)) != srs_success) {
return srs_error_wrap(err, "video");
}
if ((err = generate_play_local_sdp_for_audio(local_sdp, stream_desc, cname)) != srs_success) {
if ((err = generate_play_local_sdp_for_audio(local_sdp, stream_desc, cname, stream_id)) != srs_success) {
return srs_error_wrap(err, "audio");
}
}

return err;
}

srs_error_t SrsRtcConnection::generate_play_local_sdp_for_audio(SrsSdp& local_sdp, SrsRtcSourceDescription* stream_desc, std::string cname)
srs_error_t SrsRtcConnection::generate_play_local_sdp_for_audio(SrsSdp& local_sdp, SrsRtcSourceDescription* stream_desc, std::string cname, std::string stream_id)
{
srs_error_t err = srs_success;

// generate audio media desc
if (stream_desc->audio_track_desc_) {
SrsRtcTrackDescription* audio_track = stream_desc->audio_track_desc_;
audio_track->msid_ = stream_id;

local_sdp.media_descs_.push_back(SrsMediaDesc("audio"));
SrsMediaDesc& local_media_desc = local_sdp.media_descs_.back();
Expand Down Expand Up @@ -3358,12 +3359,13 @@ srs_error_t SrsRtcConnection::generate_play_local_sdp_for_audio(SrsSdp& local_sd
return err;
}

srs_error_t SrsRtcConnection::generate_play_local_sdp_for_video(SrsSdp& local_sdp, SrsRtcSourceDescription* stream_desc, bool unified_plan, std::string cname)
srs_error_t SrsRtcConnection::generate_play_local_sdp_for_video(SrsSdp& local_sdp, SrsRtcSourceDescription* stream_desc, bool unified_plan, std::string cname, std::string stream_id)
{
srs_error_t err = srs_success;

for (int i = 0; i < (int)stream_desc->video_track_descs_.size(); ++i) {
SrsRtcTrackDescription* track = stream_desc->video_track_descs_[i];
track->msid_ = stream_id;

if (!unified_plan) {
// for plan b, we only add one m= for video track.
Expand Down
4 changes: 2 additions & 2 deletions trunk/src/app/srs_app_rtc_conn.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -554,8 +554,8 @@ class SrsRtcConnection : public ISrsResource, public ISrsDisposingHandler, publi
//TODO: Use StreamDescription to negotiate and remove first negotiate_play_capability function
srs_error_t negotiate_play_capability(SrsRtcUserConfig* ruc, std::map<uint32_t, SrsRtcTrackDescription*>& sub_relations);
srs_error_t generate_play_local_sdp(SrsRequest* req, SrsSdp& local_sdp, SrsRtcSourceDescription* stream_desc, bool unified_plan, bool audio_before_video);
srs_error_t generate_play_local_sdp_for_audio(SrsSdp& local_sdp, SrsRtcSourceDescription* stream_desc, std::string cname);
srs_error_t generate_play_local_sdp_for_video(SrsSdp& local_sdp, SrsRtcSourceDescription* stream_desc, bool unified_plan, std::string cname);
srs_error_t generate_play_local_sdp_for_audio(SrsSdp& local_sdp, SrsRtcSourceDescription* stream_desc, std::string cname, std::string stream_id);
srs_error_t generate_play_local_sdp_for_video(SrsSdp& local_sdp, SrsRtcSourceDescription* stream_desc, bool unified_plan, std::string cname, std::string stream_id);
srs_error_t create_player(SrsRequest* request, std::map<uint32_t, SrsRtcTrackDescription*> sub_relations);
srs_error_t create_publisher(SrsRequest* request, SrsRtcSourceDescription* stream_desc);
};
Expand Down

0 comments on commit 2281dac

Please sign in to comment.