mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
RTC: Fix TWCC enable bug
This commit is contained in:
parent
96dbd7bced
commit
98839d3d53
3 changed files with 32 additions and 2 deletions
|
@ -866,6 +866,7 @@ SrsRtcPublishStream::SrsRtcPublishStream(SrsRtcConnection* session, const SrsCon
|
||||||
pt_to_drop_ = 0;
|
pt_to_drop_ = 0;
|
||||||
|
|
||||||
nn_audio_frames = 0;
|
nn_audio_frames = 0;
|
||||||
|
twcc_enabled_ = false;
|
||||||
twcc_id_ = 0;
|
twcc_id_ = 0;
|
||||||
twcc_fb_count_ = 0;
|
twcc_fb_count_ = 0;
|
||||||
|
|
||||||
|
@ -930,7 +931,7 @@ srs_error_t SrsRtcPublishStream::initialize(SrsRequest* r, SrsRtcStreamDescripti
|
||||||
media_ssrc = desc->ssrc_;
|
media_ssrc = desc->ssrc_;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (twcc_id != -1) {
|
if (twcc_id > 0) {
|
||||||
twcc_id_ = twcc_id;
|
twcc_id_ = twcc_id;
|
||||||
extension_types_.register_by_uri(twcc_id_, kTWCCExt);
|
extension_types_.register_by_uri(twcc_id_, kTWCCExt);
|
||||||
rtcp_twcc_.set_media_ssrc(media_ssrc);
|
rtcp_twcc_.set_media_ssrc(media_ssrc);
|
||||||
|
@ -941,6 +942,11 @@ srs_error_t SrsRtcPublishStream::initialize(SrsRequest* r, SrsRtcStreamDescripti
|
||||||
pt_to_drop_ = (uint16_t)_srs_config->get_rtc_drop_for_pt(req->vhost);
|
pt_to_drop_ = (uint16_t)_srs_config->get_rtc_drop_for_pt(req->vhost);
|
||||||
twcc_enabled_ = _srs_config->get_rtc_twcc_enabled(req->vhost);
|
twcc_enabled_ = _srs_config->get_rtc_twcc_enabled(req->vhost);
|
||||||
|
|
||||||
|
// No TWCC when negotiate, disable it.
|
||||||
|
if (twcc_id <= 0) {
|
||||||
|
twcc_enabled_ = false;
|
||||||
|
}
|
||||||
|
|
||||||
srs_trace("RTC publisher nack=%d, nnc=%d, pt-drop=%u, twcc=%u/%d", nack_enabled_, nack_no_copy_, pt_to_drop_, twcc_enabled_, twcc_id);
|
srs_trace("RTC publisher nack=%d, nnc=%d, pt-drop=%u, twcc=%u/%d", nack_enabled_, nack_no_copy_, pt_to_drop_, twcc_enabled_, twcc_id);
|
||||||
|
|
||||||
// Setup tracks.
|
// Setup tracks.
|
||||||
|
@ -3116,6 +3122,7 @@ srs_error_t SrsRtcConnection::negotiate_play_capability(SrsRequest* req, SrsRtcS
|
||||||
//negotiate audio media
|
//negotiate audio media
|
||||||
if(NULL != req_stream_desc->audio_track_desc_) {
|
if(NULL != req_stream_desc->audio_track_desc_) {
|
||||||
SrsRtcTrackDescription* req_audio_track = req_stream_desc->audio_track_desc_;
|
SrsRtcTrackDescription* req_audio_track = req_stream_desc->audio_track_desc_;
|
||||||
|
int remote_twcc_id = req_audio_track->get_rtp_extension_id(kTWCCExt);
|
||||||
|
|
||||||
src_track_descs = source->get_track_desc("audio", "opus");
|
src_track_descs = source->get_track_desc("audio", "opus");
|
||||||
if (src_track_descs.size() > 0) {
|
if (src_track_descs.size() > 0) {
|
||||||
|
@ -3131,6 +3138,11 @@ srs_error_t SrsRtcConnection::negotiate_play_capability(SrsRequest* req, SrsRtcS
|
||||||
track->red_->pt_ = req_audio_track->red_->pt_;
|
track->red_->pt_ = req_audio_track->red_->pt_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
track->del_rtp_extension_desc(kTWCCExt);
|
||||||
|
if (remote_twcc_id > 0) {
|
||||||
|
track->add_rtp_extension_desc(remote_twcc_id, kTWCCExt);
|
||||||
|
}
|
||||||
|
|
||||||
track->mid_ = req_audio_track->mid_;
|
track->mid_ = req_audio_track->mid_;
|
||||||
sub_relations.insert(make_pair(track->ssrc_, track));
|
sub_relations.insert(make_pair(track->ssrc_, track));
|
||||||
track->set_direction("sendonly");
|
track->set_direction("sendonly");
|
||||||
|
@ -3143,6 +3155,8 @@ srs_error_t SrsRtcConnection::negotiate_play_capability(SrsRequest* req, SrsRtcS
|
||||||
src_track_descs = source->get_track_desc("video", "h264");
|
src_track_descs = source->get_track_desc("video", "h264");
|
||||||
for(int i = 0; i < (int)req_video_tracks.size(); ++i) {
|
for(int i = 0; i < (int)req_video_tracks.size(); ++i) {
|
||||||
SrsRtcTrackDescription* req_video = req_video_tracks.at(i);
|
SrsRtcTrackDescription* req_video = req_video_tracks.at(i);
|
||||||
|
int remote_twcc_id = req_video->get_rtp_extension_id(kTWCCExt);
|
||||||
|
|
||||||
for(int j = 0; j < (int)src_track_descs.size(); ++j) {
|
for(int j = 0; j < (int)src_track_descs.size(); ++j) {
|
||||||
SrsRtcTrackDescription* src_video = src_track_descs.at(j);
|
SrsRtcTrackDescription* src_video = src_track_descs.at(j);
|
||||||
if(req_video->id_ == src_video->id_) {
|
if(req_video->id_ == src_video->id_) {
|
||||||
|
@ -3158,6 +3172,11 @@ srs_error_t SrsRtcConnection::negotiate_play_capability(SrsRequest* req, SrsRtcS
|
||||||
track->red_->pt_ = req_video->red_->pt_;
|
track->red_->pt_ = req_video->red_->pt_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
track->del_rtp_extension_desc(kTWCCExt);
|
||||||
|
if (remote_twcc_id > 0) {
|
||||||
|
track->add_rtp_extension_desc(remote_twcc_id, kTWCCExt);
|
||||||
|
}
|
||||||
|
|
||||||
track->mid_ = req_video->mid_;
|
track->mid_ = req_video->mid_;
|
||||||
sub_relations.insert(make_pair(track->ssrc_, track));
|
sub_relations.insert(make_pair(track->ssrc_, track));
|
||||||
track->set_direction("sendonly");
|
track->set_direction("sendonly");
|
||||||
|
|
|
@ -1583,6 +1583,16 @@ void SrsRtcTrackDescription::add_rtp_extension_desc(int id, std::string uri)
|
||||||
extmaps_[id] = uri;
|
extmaps_[id] = uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SrsRtcTrackDescription::del_rtp_extension_desc(std::string uri)
|
||||||
|
{
|
||||||
|
for(std::map<int, std::string>::iterator it = extmaps_.begin(); it != extmaps_.end(); ++it) {
|
||||||
|
if(uri == it->second) {
|
||||||
|
extmaps_.erase(it++);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SrsRtcTrackDescription::set_direction(std::string direction)
|
void SrsRtcTrackDescription::set_direction(std::string direction)
|
||||||
{
|
{
|
||||||
direction_ = direction;
|
direction_ = direction;
|
||||||
|
@ -1630,7 +1640,7 @@ void SrsRtcTrackDescription::set_mid(std::string mid)
|
||||||
|
|
||||||
int SrsRtcTrackDescription::get_rtp_extension_id(std::string uri)
|
int SrsRtcTrackDescription::get_rtp_extension_id(std::string uri)
|
||||||
{
|
{
|
||||||
for(std::map<int, std::string>::iterator it = extmaps_.begin(); it != extmaps_.end(); ++it) {
|
for (std::map<int, std::string>::iterator it = extmaps_.begin(); it != extmaps_.end(); ++it) {
|
||||||
if(uri == it->second) {
|
if(uri == it->second) {
|
||||||
return it->first;
|
return it->first;
|
||||||
}
|
}
|
||||||
|
|
|
@ -439,6 +439,7 @@ public:
|
||||||
bool has_ssrc(uint32_t ssrc);
|
bool has_ssrc(uint32_t ssrc);
|
||||||
public:
|
public:
|
||||||
void add_rtp_extension_desc(int id, std::string uri);
|
void add_rtp_extension_desc(int id, std::string uri);
|
||||||
|
void del_rtp_extension_desc(std::string uri);
|
||||||
void set_direction(std::string direction);
|
void set_direction(std::string direction);
|
||||||
void set_codec_payload(SrsCodecPayload* payload);
|
void set_codec_payload(SrsCodecPayload* payload);
|
||||||
// auxiliary paylod include red, rtx, ulpfec.
|
// auxiliary paylod include red, rtx, ulpfec.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue