mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Merge SRS4, lots of features
This commit is contained in:
commit
3bb1b673c5
3479 changed files with 920400 additions and 110 deletions
|
@ -4919,7 +4919,7 @@ SrsConfDirective* SrsConfig::get_rtc_server_rtp_cache()
|
|||
|
||||
bool SrsConfig::get_rtc_server_rtp_cache_enabled()
|
||||
{
|
||||
static bool DEFAULT = false;
|
||||
static bool DEFAULT = true;
|
||||
|
||||
SrsConfDirective* conf = get_rtc_server_rtp_cache();
|
||||
if (!conf) {
|
||||
|
@ -4931,7 +4931,7 @@ bool SrsConfig::get_rtc_server_rtp_cache_enabled()
|
|||
return DEFAULT;
|
||||
}
|
||||
|
||||
return SRS_CONF_PERFER_FALSE(conf->arg0());
|
||||
return SRS_CONF_PERFER_TRUE(conf->arg0());
|
||||
}
|
||||
|
||||
uint64_t SrsConfig::get_rtc_server_rtp_cache_pkt_size()
|
||||
|
@ -4985,7 +4985,7 @@ SrsConfDirective* SrsConfig::get_rtc_server_rtp_msg_cache()
|
|||
|
||||
bool SrsConfig::get_rtc_server_rtp_msg_cache_enabled()
|
||||
{
|
||||
static bool DEFAULT = false;
|
||||
static bool DEFAULT = true;
|
||||
|
||||
SrsConfDirective* conf = get_rtc_server_rtp_msg_cache();
|
||||
if (!conf) {
|
||||
|
@ -4997,7 +4997,7 @@ bool SrsConfig::get_rtc_server_rtp_msg_cache_enabled()
|
|||
return DEFAULT;
|
||||
}
|
||||
|
||||
return SRS_CONF_PERFER_FALSE(conf->arg0());
|
||||
return SRS_CONF_PERFER_TRUE(conf->arg0());
|
||||
}
|
||||
|
||||
uint64_t SrsConfig::get_rtc_server_rtp_msg_cache_msg_size()
|
||||
|
@ -5251,7 +5251,7 @@ bool SrsConfig::get_rtc_nack_enabled(string vhost)
|
|||
|
||||
bool SrsConfig::get_rtc_nack_no_copy(string vhost)
|
||||
{
|
||||
static bool DEFAULT = false;
|
||||
static bool DEFAULT = true;
|
||||
|
||||
SrsConfDirective* conf = get_vhost(vhost);
|
||||
if (!conf) {
|
||||
|
@ -5268,7 +5268,7 @@ bool SrsConfig::get_rtc_nack_no_copy(string vhost)
|
|||
return DEFAULT;
|
||||
}
|
||||
|
||||
return SRS_CONF_PERFER_FALSE(conf->arg0());
|
||||
return SRS_CONF_PERFER_TRUE(conf->arg0());
|
||||
}
|
||||
|
||||
bool SrsConfig::get_rtc_twcc_enabled(string vhost)
|
||||
|
|
|
@ -130,10 +130,11 @@ srs_error_t SrsAudioDecoder::decode(SrsSample *pkt, char *buf, int &size)
|
|||
return srs_error_new(ERROR_RTC_RTP_MUXER, "Failed to calculate data size");
|
||||
}
|
||||
|
||||
for (int i = 0; i < frame_->nb_samples; i++) {
|
||||
if (size + pcm_size * codec_ctx_->channels <= max) {
|
||||
memcpy(buf + size,frame_->data[0] + pcm_size*codec_ctx_->channels * i, pcm_size * codec_ctx_->channels);
|
||||
size += pcm_size * codec_ctx_->channels;
|
||||
// @see https://github.com/ossrs/srs/pull/2011/files
|
||||
for (int i = 0; i < codec_ctx_->channels; i++) {
|
||||
if (size + pcm_size * frame_->nb_samples <= max) {
|
||||
memcpy(buf + size,frame_->data[i],pcm_size * frame_->nb_samples);
|
||||
size += pcm_size * frame_->nb_samples;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -866,6 +866,7 @@ SrsRtcPublishStream::SrsRtcPublishStream(SrsRtcConnection* session, const SrsCon
|
|||
pt_to_drop_ = 0;
|
||||
|
||||
nn_audio_frames = 0;
|
||||
twcc_enabled_ = false;
|
||||
twcc_id_ = 0;
|
||||
twcc_fb_count_ = 0;
|
||||
|
||||
|
@ -930,7 +931,7 @@ srs_error_t SrsRtcPublishStream::initialize(SrsRequest* r, SrsRtcStreamDescripti
|
|||
media_ssrc = desc->ssrc_;
|
||||
break;
|
||||
}
|
||||
if (twcc_id != -1) {
|
||||
if (twcc_id > 0) {
|
||||
twcc_id_ = twcc_id;
|
||||
extension_types_.register_by_uri(twcc_id_, kTWCCExt);
|
||||
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);
|
||||
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);
|
||||
|
||||
// Setup tracks.
|
||||
|
@ -3116,6 +3122,7 @@ srs_error_t SrsRtcConnection::negotiate_play_capability(SrsRequest* req, SrsRtcS
|
|||
//negotiate audio media
|
||||
if(NULL != 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");
|
||||
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->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_;
|
||||
sub_relations.insert(make_pair(track->ssrc_, track));
|
||||
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");
|
||||
for(int i = 0; i < (int)req_video_tracks.size(); ++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) {
|
||||
SrsRtcTrackDescription* src_video = src_track_descs.at(j);
|
||||
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->del_rtp_extension_desc(kTWCCExt);
|
||||
if (remote_twcc_id > 0) {
|
||||
track->add_rtp_extension_desc(remote_twcc_id, kTWCCExt);
|
||||
}
|
||||
|
||||
track->mid_ = req_video->mid_;
|
||||
sub_relations.insert(make_pair(track->ssrc_, track));
|
||||
track->set_direction("sendonly");
|
||||
|
|
|
@ -768,11 +768,11 @@ srs_error_t SrsRtcServer::notify(int type, srs_utime_t interval, srs_utime_t tic
|
|||
rnk_desc = buf;
|
||||
}
|
||||
|
||||
string drop_desc;
|
||||
string loss_desc;
|
||||
SrsSnmpUdpStat* s = srs_get_udp_snmp_stat();
|
||||
if (s->rcv_buf_errors_delta || s->snd_buf_errors_delta) {
|
||||
snprintf(buf, sizeof(buf), ", drop=(r:%d,s:%d)", s->rcv_buf_errors_delta, s->snd_buf_errors_delta);
|
||||
drop_desc = buf;
|
||||
snprintf(buf, sizeof(buf), ", loss=(r:%d,s:%d)", s->rcv_buf_errors_delta, s->snd_buf_errors_delta);
|
||||
loss_desc = buf;
|
||||
}
|
||||
|
||||
string fid_desc;
|
||||
|
@ -784,7 +784,7 @@ srs_error_t SrsRtcServer::notify(int type, srs_utime_t interval, srs_utime_t tic
|
|||
|
||||
srs_trace("RTC: Server conns=%u%s%s%s%s%s%s%s",
|
||||
nn_rtc_conns,
|
||||
rpkts_desc.c_str(), spkts_desc.c_str(), rtcp_desc.c_str(), snk_desc.c_str(), rnk_desc.c_str(), drop_desc.c_str(), fid_desc.c_str()
|
||||
rpkts_desc.c_str(), spkts_desc.c_str(), rtcp_desc.c_str(), snk_desc.c_str(), rnk_desc.c_str(), loss_desc.c_str(), fid_desc.c_str()
|
||||
);
|
||||
|
||||
return err;
|
||||
|
|
|
@ -1583,6 +1583,16 @@ void SrsRtcTrackDescription::add_rtp_extension_desc(int id, std::string 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)
|
||||
{
|
||||
direction_ = direction;
|
||||
|
@ -1630,7 +1640,7 @@ void SrsRtcTrackDescription::set_mid(std::string mid)
|
|||
|
||||
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) {
|
||||
return it->first;
|
||||
}
|
||||
|
|
|
@ -439,6 +439,7 @@ public:
|
|||
bool has_ssrc(uint32_t ssrc);
|
||||
public:
|
||||
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_codec_payload(SrsCodecPayload* payload);
|
||||
// auxiliary paylod include red, rtx, ulpfec.
|
||||
|
|
|
@ -24,6 +24,6 @@
|
|||
#ifndef SRS_CORE_VERSION4_HPP
|
||||
#define SRS_CORE_VERSION4_HPP
|
||||
|
||||
#define SRS_VERSION4_REVISION 76
|
||||
#define SRS_VERSION4_REVISION 81
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1143,8 +1143,8 @@ VOID TEST(KernelRTCTest, DTLSServerARQTest)
|
|||
|
||||
EXPECT_EQ(1, cio.nn_client_hello);
|
||||
EXPECT_EQ(1, sio.nn_server_hello);
|
||||
EXPECT_EQ(1, cio.nn_certificate);
|
||||
EXPECT_EQ(1, sio.nn_new_session);
|
||||
EXPECT_TRUE(1 <= cio.nn_certificate);
|
||||
EXPECT_TRUE(1 <= sio.nn_new_session);
|
||||
EXPECT_EQ(0, sio.nn_change_cipher);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue