mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Support simulate NACK for RTC publisher
This commit is contained in:
parent
4d33070c59
commit
d125116317
6 changed files with 31 additions and 5 deletions
|
@ -967,7 +967,7 @@ srs_error_t SrsGoApiRtcPlay::do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMe
|
|||
// TODO: add candidates in response json?
|
||||
|
||||
res->set("sdp", SrsJsonAny::str(local_sdp_str.c_str()));
|
||||
res->set("sessionid", SrsJsonAny::str(session->id().c_str()));
|
||||
res->set("sessionid", SrsJsonAny::str(session->username().c_str()));
|
||||
|
||||
srs_trace("RTC username=%s, offer=%dB, answer=%dB", session->username().c_str(),
|
||||
remote_sdp_str.length(), local_sdp_str.length());
|
||||
|
@ -1309,7 +1309,7 @@ srs_error_t SrsGoApiRtcPublish::do_serve_http(ISrsHttpResponseWriter* w, ISrsHtt
|
|||
// TODO: add candidates in response json?
|
||||
|
||||
res->set("sdp", SrsJsonAny::str(local_sdp_str.c_str()));
|
||||
res->set("sessionid", SrsJsonAny::str(session->id().c_str()));
|
||||
res->set("sessionid", SrsJsonAny::str(session->username().c_str()));
|
||||
|
||||
srs_trace("RTC username=%s, offer=%dB, answer=%dB", session->username().c_str(),
|
||||
remote_sdp_str.length(), local_sdp_str.length());
|
||||
|
|
|
@ -1553,6 +1553,7 @@ SrsRtcPublisher::SrsRtcPublisher(SrsRtcSession* session)
|
|||
audio_nack_ = new SrsRtpNackForReceiver(audio_queue_, 100 * 2 / 3);
|
||||
|
||||
source = NULL;
|
||||
nn_simulate_nack_drop = 0;
|
||||
}
|
||||
|
||||
SrsRtcPublisher::~SrsRtcPublisher()
|
||||
|
@ -1967,6 +1968,17 @@ srs_error_t SrsRtcPublisher::on_rtp(char* buf, int nb_buf)
|
|||
return srs_error_wrap(err, "decode rtp packet");
|
||||
}
|
||||
|
||||
// For NACK simulator, drop packet.
|
||||
if (nn_simulate_nack_drop) {
|
||||
SrsRtpHeader* h = &pkt->rtp_header;
|
||||
srs_warn("RTC NACK simulator #%d drop seq=%u, ssrc=%u/%s, ts=%u, %d bytes", nn_simulate_nack_drop,
|
||||
h->get_sequence(), h->get_ssrc(), (h->get_ssrc()==video_ssrc? "Video":"Audio"), h->get_timestamp(),
|
||||
(int)nb_buf);
|
||||
nn_simulate_nack_drop--;
|
||||
srs_freep(pkt);
|
||||
return err;
|
||||
}
|
||||
|
||||
uint32_t ssrc = pkt->rtp_header.get_ssrc();
|
||||
if (ssrc == audio_ssrc) {
|
||||
return on_audio(pkt);
|
||||
|
@ -2217,7 +2229,7 @@ srs_error_t SrsRtcPublisher::notify(int type, srs_utime_t interval, srs_utime_t
|
|||
|
||||
void SrsRtcPublisher::simulate_nack_drop(int nn)
|
||||
{
|
||||
// TODO: FIXME: Implements it.
|
||||
nn_simulate_nack_drop = nn;
|
||||
}
|
||||
|
||||
SrsRtcSession::SrsRtcSession(SrsRtcServer* s)
|
||||
|
@ -3359,16 +3371,17 @@ srs_error_t SrsRtcServer::create_session(
|
|||
return srs_error_new(ERROR_RTC_SOURCE_BUSY, "stream %s busy", req->get_stream_url().c_str());
|
||||
}
|
||||
|
||||
// TODO: FIXME: Seems not random, please check it.
|
||||
std::string local_pwd = gen_random_str(32);
|
||||
std::string local_ufrag = "";
|
||||
// TODO: FIXME: Rename for a better name, it's not an username.
|
||||
std::string username = "";
|
||||
while (true) {
|
||||
local_ufrag = gen_random_str(8);
|
||||
|
||||
username = local_ufrag + ":" + remote_sdp.get_ice_ufrag();
|
||||
if (!map_username_session.count(username))
|
||||
if (!map_username_session.count(username)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int cid = _srs_context->get_id();
|
||||
|
|
|
@ -278,6 +278,8 @@ private:
|
|||
private:
|
||||
SrsRequest* req;
|
||||
SrsSource* source;
|
||||
// Simulators.
|
||||
int nn_simulate_nack_drop;
|
||||
private:
|
||||
std::map<uint32_t, uint64_t> last_sender_report_sys_time;
|
||||
std::map<uint32_t, SrsNtp> last_sender_report_ntp;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue