mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
RTC: Always keep and use original sequence.
This commit is contained in:
parent
6662568c11
commit
75fbcba71d
6 changed files with 7 additions and 76 deletions
|
@ -491,10 +491,6 @@ vhost rtc.vhost.srs.com {
|
|||
# The strick check when process stun.
|
||||
# default: off
|
||||
stun_strict_check on;
|
||||
# Whether keep original sequence number.
|
||||
# If off, we will regenerate the sequence number for RTP packet.
|
||||
# default: off
|
||||
keep_sequence off;
|
||||
# The role of dtls when peer is actpass: passive or active
|
||||
# default: passive
|
||||
dtls_role passive;
|
||||
|
|
|
@ -3935,7 +3935,7 @@ srs_error_t SrsConfig::check_normal_config()
|
|||
for (int j = 0; j < (int)conf->directives.size(); j++) {
|
||||
string m = conf->at(j)->name;
|
||||
if (m != "enabled" && m != "bframe" && m != "aac" && m != "stun_timeout" && m != "stun_strict_check"
|
||||
&& m != "keep_sequence" && m != "dtls_role" && m != "dtls_version") {
|
||||
&& m != "dtls_role" && m != "dtls_version") {
|
||||
return srs_error_new(ERROR_SYSTEM_CONFIG_INVALID, "illegal vhost.rtc.%s of %s", m.c_str(), vhost->arg0().c_str());
|
||||
}
|
||||
}
|
||||
|
@ -5020,24 +5020,6 @@ bool SrsConfig::get_rtc_stun_strict_check(string vhost)
|
|||
return SRS_CONF_PERFER_FALSE(conf->arg0());
|
||||
}
|
||||
|
||||
bool SrsConfig::get_rtc_keep_sequence(string vhost)
|
||||
{
|
||||
static bool DEFAULT = false;
|
||||
|
||||
SrsConfDirective* conf = get_rtc(vhost);
|
||||
|
||||
if (!conf) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
conf = conf->get("keep_sequence");
|
||||
if (!conf || conf->arg0().empty()) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
return SRS_CONF_PERFER_FALSE(conf->arg0());
|
||||
}
|
||||
|
||||
std::string SrsConfig::get_rtc_dtls_role(string vhost)
|
||||
{
|
||||
static std::string DEFAULT = "passive";
|
||||
|
|
|
@ -544,7 +544,6 @@ public:
|
|||
bool get_rtc_aac_discard(std::string vhost);
|
||||
srs_utime_t get_rtc_stun_timeout(std::string vhost);
|
||||
bool get_rtc_stun_strict_check(std::string vhost);
|
||||
bool get_rtc_keep_sequence(std::string vhost);
|
||||
std::string get_rtc_dtls_role(std::string vhost);
|
||||
std::string get_rtc_dtls_version(std::string vhost);
|
||||
bool get_rtc_nack_enabled(std::string vhost);
|
||||
|
|
|
@ -136,16 +136,9 @@ srs_error_t SrsGoApiRtcPlay::do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMe
|
|||
string eip = r->query_get("eip");
|
||||
// For client to specifies whether encrypt by SRTP.
|
||||
string encrypt = r->query_get("encrypt");
|
||||
// If keep_sequence is off, for client to specifies the startup sequence.
|
||||
string sequence_startup = r->query_get("sequence_startup");
|
||||
// If keep_sequence is on, for client to specifies the delta value for sequence.
|
||||
string sequence_delta = r->query_get("sequence_delta");
|
||||
// Whether keep sequence, overwrite the config for debugging each session.
|
||||
string sequence_keep = r->query_get("sequence_keep");
|
||||
|
||||
srs_trace("RTC play %s, api=%s, clientip=%s, app=%s, stream=%s, offer=%dB, eip=%s, encrypt=%s, sequence(startup=%s,delta=%s,keep=%s)",
|
||||
streamurl.c_str(), api.c_str(), clientip.c_str(), app.c_str(), stream_name.c_str(), remote_sdp_str.length(), eip.c_str(), encrypt.c_str(),
|
||||
sequence_startup.c_str(), sequence_delta.c_str(), sequence_keep.c_str());
|
||||
srs_trace("RTC play %s, api=%s, clientip=%s, app=%s, stream=%s, offer=%dB, eip=%s, encrypt=%s",
|
||||
streamurl.c_str(), api.c_str(), clientip.c_str(), app.c_str(), stream_name.c_str(), remote_sdp_str.length(), eip.c_str(), encrypt.c_str());
|
||||
|
||||
// TODO: FIXME: It seems remote_sdp doesn't represents the full SDP information.
|
||||
SrsSdp remote_sdp;
|
||||
|
@ -200,11 +193,6 @@ srs_error_t SrsGoApiRtcPlay::do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMe
|
|||
session->set_encrypt(encrypt != "false");
|
||||
}
|
||||
|
||||
// Set the optional parameters from client.
|
||||
session->sequence_startup = sequence_startup;
|
||||
session->sequence_delta = sequence_delta;
|
||||
session->sequence_keep = sequence_keep;
|
||||
|
||||
ostringstream os;
|
||||
if ((err = local_sdp.encode(os)) != srs_success) {
|
||||
return srs_error_wrap(err, "encode sdp");
|
||||
|
|
|
@ -273,9 +273,6 @@ SrsRtcPlayer::SrsRtcPlayer(SrsRtcSession* s, string parent_cid)
|
|||
|
||||
session_ = s;
|
||||
|
||||
audio_sequence = 0;
|
||||
video_sequence = 0;
|
||||
sequence_delta = 0;
|
||||
mw_msgs = 0;
|
||||
realtime = true;
|
||||
|
||||
|
@ -285,7 +282,6 @@ SrsRtcPlayer::SrsRtcPlayer(SrsRtcSession* s, string parent_cid)
|
|||
|
||||
nn_simulate_nack_drop = 0;
|
||||
nack_enabled_ = false;
|
||||
keep_sequence_ = false;
|
||||
|
||||
_srs_config->subscribe(this);
|
||||
}
|
||||
|
@ -311,18 +307,8 @@ srs_error_t SrsRtcPlayer::initialize(const uint32_t& vssrc, const uint32_t& assr
|
|||
|
||||
// TODO: FIXME: Support reload.
|
||||
nack_enabled_ = _srs_config->get_rtc_nack_enabled(session_->req->vhost);
|
||||
keep_sequence_ = _srs_config->get_rtc_keep_sequence(session_->req->vhost);
|
||||
if (!session_->sequence_startup.empty()) {
|
||||
audio_sequence = video_sequence = uint16_t(::atoi(session_->sequence_startup.c_str()));
|
||||
}
|
||||
if (!session_->sequence_delta.empty()) {
|
||||
sequence_delta = uint16_t(::atoi(session_->sequence_delta.c_str()));
|
||||
}
|
||||
if (!session_->sequence_keep.empty()) {
|
||||
keep_sequence_ = (session_->sequence_keep == "true");
|
||||
}
|
||||
srs_trace("RTC player video(ssrc=%d, pt=%d), audio(ssrc=%d, pt=%d), nack=%d, keep-seq=%d, sequence(audio=%u,video=%u,delta=%u)",
|
||||
video_ssrc, video_payload_type, audio_ssrc, audio_payload_type, nack_enabled_, keep_sequence_, audio_sequence, video_sequence, sequence_delta);
|
||||
srs_trace("RTC player video(ssrc=%d, pt=%d), audio(ssrc=%d, pt=%d), nack=%d",
|
||||
video_ssrc, video_payload_type, audio_ssrc, audio_payload_type, nack_enabled_);
|
||||
|
||||
if (_srs_rtc_hijacker) {
|
||||
if ((err = _srs_rtc_hijacker->on_start_play(session_, this, session_->req)) != srs_success) {
|
||||
|
@ -495,36 +481,21 @@ srs_error_t SrsRtcPlayer::send_packets(SrsRtcSource* source, const vector<SrsRtp
|
|||
// Update stats.
|
||||
info.nn_bytes += pkt->nb_bytes();
|
||||
|
||||
uint16_t oseq = pkt->header.get_sequence();
|
||||
if (pkt->is_audio()) {
|
||||
info.nn_audios++;
|
||||
|
||||
if (!keep_sequence_) {
|
||||
// TODO: FIXME: Should keep the order by original sequence.
|
||||
pkt->header.set_sequence(sequence_delta + audio_sequence++);
|
||||
} else {
|
||||
pkt->header.set_sequence(sequence_delta + oseq);
|
||||
}
|
||||
pkt->header.set_ssrc(audio_ssrc);
|
||||
pkt->header.set_payload_type(audio_payload_type);
|
||||
|
||||
// TODO: FIXME: Padding audio to the max payload in RTP packets.
|
||||
} else {
|
||||
info.nn_videos++;
|
||||
|
||||
if (!keep_sequence_) {
|
||||
// TODO: FIXME: Should keep the order by original sequence.
|
||||
pkt->header.set_sequence(sequence_delta + video_sequence++);
|
||||
} else {
|
||||
pkt->header.set_sequence(sequence_delta + oseq);
|
||||
}
|
||||
pkt->header.set_ssrc(video_ssrc);
|
||||
pkt->header.set_payload_type(video_payload_type);
|
||||
}
|
||||
|
||||
// Detail log, should disable it in release version.
|
||||
srs_info("RTC: Update PT=%u, SSRC=%#x, OSEQ=%u, SEQ=%u, Time=%u, %u bytes", pkt->header.get_payload_type(), pkt->header.get_ssrc(),
|
||||
oseq, pkt->header.get_sequence(), pkt->header.get_timestamp(), pkt->nb_bytes());
|
||||
srs_info("RTC: Update PT=%u, SSRC=%#x, Time=%u, %u bytes", pkt->header.get_payload_type(), pkt->header.get_ssrc(),
|
||||
pkt->header.get_timestamp(), pkt->nb_bytes());
|
||||
}
|
||||
|
||||
// By default, we send packets by sendmmsg.
|
||||
|
|
|
@ -191,18 +191,15 @@ protected:
|
|||
private:
|
||||
// TODO: FIXME: How to handle timestamp overflow?
|
||||
// Information for audio.
|
||||
uint16_t audio_sequence;
|
||||
uint32_t audio_ssrc;
|
||||
uint16_t audio_payload_type;
|
||||
// Information for video.
|
||||
uint16_t video_sequence;
|
||||
uint16_t video_payload_type;
|
||||
uint32_t video_ssrc;
|
||||
// NACK ARQ ring buffer.
|
||||
SrsRtpRingBuffer* audio_queue_;
|
||||
SrsRtpRingBuffer* video_queue_;
|
||||
// Simulators.
|
||||
uint16_t sequence_delta;
|
||||
int nn_simulate_nack_drop;
|
||||
private:
|
||||
// For merged-write messages.
|
||||
|
@ -210,8 +207,6 @@ private:
|
|||
bool realtime;
|
||||
// Whether enabled nack.
|
||||
bool nack_enabled_;
|
||||
// Whether keep original sequence number.
|
||||
bool keep_sequence_;
|
||||
public:
|
||||
SrsRtcPlayer(SrsRtcSession* s, std::string parent_cid);
|
||||
virtual ~SrsRtcPlayer();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue