mirror of
https://github.com/ossrs/srs.git
synced 2025-02-15 04:42:04 +00:00
RTC: Refine stat code
This commit is contained in:
parent
0f62587303
commit
133e07e670
3 changed files with 20 additions and 12 deletions
|
@ -483,8 +483,10 @@ void SrsRtcPlayStream::nack_fetch(vector<SrsRtpPacket2*>& pkts, uint32_t ssrc, u
|
||||||
if (true) {
|
if (true) {
|
||||||
std::map<uint32_t, SrsRtcAudioSendTrack*>::iterator it;
|
std::map<uint32_t, SrsRtcAudioSendTrack*>::iterator it;
|
||||||
for (it = audio_tracks_.begin(); it != audio_tracks_.end(); ++it) {
|
for (it = audio_tracks_.begin(); it != audio_tracks_.end(); ++it) {
|
||||||
if (it->second->has_ssrc(ssrc)) {
|
SrsRtcAudioSendTrack* track = it->second;
|
||||||
SrsRtpPacket2* pkt = it->second->fetch_rtp_packet(seq);
|
|
||||||
|
if (track->has_ssrc(ssrc)) {
|
||||||
|
SrsRtpPacket2* pkt = track->fetch_rtp_packet(seq);
|
||||||
if (pkt != NULL) {
|
if (pkt != NULL) {
|
||||||
pkts.push_back(pkt);
|
pkts.push_back(pkt);
|
||||||
}
|
}
|
||||||
|
@ -496,8 +498,10 @@ void SrsRtcPlayStream::nack_fetch(vector<SrsRtpPacket2*>& pkts, uint32_t ssrc, u
|
||||||
if (true) {
|
if (true) {
|
||||||
std::map<uint32_t, SrsRtcVideoSendTrack*>::iterator it;
|
std::map<uint32_t, SrsRtcVideoSendTrack*>::iterator it;
|
||||||
for (it = video_tracks_.begin(); it != video_tracks_.end(); ++it) {
|
for (it = video_tracks_.begin(); it != video_tracks_.end(); ++it) {
|
||||||
if (it->second->has_ssrc(ssrc)) {
|
SrsRtcVideoSendTrack* track = it->second;
|
||||||
SrsRtpPacket2* pkt = it->second->fetch_rtp_packet(seq);
|
|
||||||
|
if (track->has_ssrc(ssrc)) {
|
||||||
|
SrsRtpPacket2* pkt = track->fetch_rtp_packet(seq);
|
||||||
if (pkt != NULL) {
|
if (pkt != NULL) {
|
||||||
pkts.push_back(pkt);
|
pkts.push_back(pkt);
|
||||||
}
|
}
|
||||||
|
@ -1951,7 +1955,7 @@ void SrsRtcConnection::update_sendonly_socket(SrsUdpMuxSocket* skt)
|
||||||
sendonly_skt = addr_cache;
|
sendonly_skt = addr_cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SrsRtcConnection::check_send_nacks(SrsRtpNackForReceiver* nack, uint32_t ssrc)
|
void SrsRtcConnection::check_send_nacks(SrsRtpNackForReceiver* nack, uint32_t ssrc, uint32_t& sent_nacks)
|
||||||
{
|
{
|
||||||
// If DTLS is not OK, drop all messages.
|
// If DTLS is not OK, drop all messages.
|
||||||
if (!transport_) {
|
if (!transport_) {
|
||||||
|
@ -1996,6 +2000,7 @@ void SrsRtcConnection::check_send_nacks(SrsRtpNackForReceiver* nack, uint32_t ss
|
||||||
}
|
}
|
||||||
|
|
||||||
++iter;
|
++iter;
|
||||||
|
++sent_nacks;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -253,7 +253,6 @@ public:
|
||||||
srs_error_t initialize(SrsRequest* req, SrsRtcStreamDescription* stream_desc);
|
srs_error_t initialize(SrsRequest* req, SrsRtcStreamDescription* stream_desc);
|
||||||
srs_error_t start();
|
srs_error_t start();
|
||||||
private:
|
private:
|
||||||
void check_send_nacks(SrsRtpNackForReceiver* nack, uint32_t ssrc);
|
|
||||||
srs_error_t send_rtcp_rr();
|
srs_error_t send_rtcp_rr();
|
||||||
srs_error_t send_rtcp_xr_rrtr();
|
srs_error_t send_rtcp_xr_rrtr();
|
||||||
public:
|
public:
|
||||||
|
@ -390,7 +389,7 @@ public:
|
||||||
void update_sendonly_socket(SrsUdpMuxSocket* skt);
|
void update_sendonly_socket(SrsUdpMuxSocket* skt);
|
||||||
public:
|
public:
|
||||||
// send rtcp
|
// send rtcp
|
||||||
void check_send_nacks(SrsRtpNackForReceiver* nack, uint32_t ssrc);
|
void check_send_nacks(SrsRtpNackForReceiver* nack, uint32_t ssrc, uint32_t& sent_nacks);
|
||||||
srs_error_t send_rtcp_rr(uint32_t ssrc, SrsRtpRingBuffer* rtp_queue, const uint64_t& last_send_systime, const SrsNtp& last_send_ntp);
|
srs_error_t send_rtcp_rr(uint32_t ssrc, SrsRtpRingBuffer* rtp_queue, const uint64_t& last_send_systime, const SrsNtp& last_send_ntp);
|
||||||
srs_error_t send_rtcp_xr_rrtr(uint32_t ssrc);
|
srs_error_t send_rtcp_xr_rrtr(uint32_t ssrc);
|
||||||
srs_error_t send_rtcp_fb_pli(uint32_t ssrc);
|
srs_error_t send_rtcp_fb_pli(uint32_t ssrc);
|
||||||
|
|
|
@ -1597,8 +1597,10 @@ srs_error_t SrsRtcRecvTrack::on_nack(SrsRtpPacket2* pkt)
|
||||||
|
|
||||||
// insert into video_queue and audio_queue
|
// insert into video_queue and audio_queue
|
||||||
rtp_queue_->set(seq, pkt->copy());
|
rtp_queue_->set(seq, pkt->copy());
|
||||||
|
|
||||||
// send_nack
|
// send_nack
|
||||||
session_->check_send_nacks(nack_receiver_, ssrc);
|
uint32_t sent_nacks = 0;
|
||||||
|
session_->check_send_nacks(nack_receiver_, ssrc, sent_nacks);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -1621,6 +1623,9 @@ srs_error_t SrsRtcAudioRecvTrack::on_rtp(SrsRtcStream* source, SrsRtpPacket2* pk
|
||||||
{
|
{
|
||||||
srs_error_t err = srs_success;
|
srs_error_t err = srs_success;
|
||||||
|
|
||||||
|
// connection level statistic
|
||||||
|
session_->stat_->nn_in_audios++;
|
||||||
|
|
||||||
if (source) {
|
if (source) {
|
||||||
if ((err = source->on_rtp(pkt)) != srs_success) {
|
if ((err = source->on_rtp(pkt)) != srs_success) {
|
||||||
return srs_error_wrap(err, "source on rtp");
|
return srs_error_wrap(err, "source on rtp");
|
||||||
|
@ -1632,8 +1637,6 @@ srs_error_t SrsRtcAudioRecvTrack::on_rtp(SrsRtcStream* source, SrsRtpPacket2* pk
|
||||||
return srs_error_wrap(err, "on nack");
|
return srs_error_wrap(err, "on nack");
|
||||||
}
|
}
|
||||||
|
|
||||||
session_->stat_->nn_in_audios++;
|
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1651,6 +1654,9 @@ srs_error_t SrsRtcVideoRecvTrack::on_rtp(SrsRtcStream* source, SrsRtpPacket2* pk
|
||||||
{
|
{
|
||||||
srs_error_t err = srs_success;
|
srs_error_t err = srs_success;
|
||||||
|
|
||||||
|
// connection level statistic
|
||||||
|
session_->stat_->nn_in_videos++;
|
||||||
|
|
||||||
pkt->frame_type = SrsFrameTypeVideo;
|
pkt->frame_type = SrsFrameTypeVideo;
|
||||||
|
|
||||||
if (source) {
|
if (source) {
|
||||||
|
@ -1672,8 +1678,6 @@ srs_error_t SrsRtcVideoRecvTrack::on_rtp(SrsRtcStream* source, SrsRtpPacket2* pk
|
||||||
return srs_error_wrap(err, "on nack");
|
return srs_error_wrap(err, "on nack");
|
||||||
}
|
}
|
||||||
|
|
||||||
session_->stat_->nn_in_videos++;
|
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue