diff --git a/trunk/src/app/srs_app_rtc_conn.cpp b/trunk/src/app/srs_app_rtc_conn.cpp index 0c0014235..09f28a035 100644 --- a/trunk/src/app/srs_app_rtc_conn.cpp +++ b/trunk/src/app/srs_app_rtc_conn.cpp @@ -460,9 +460,6 @@ srs_error_t SrsRtcPlayStream::initialize(SrsRequest* req, std::mapset_nack_no_copy(nack_no_copy_); } - // Update stat for session. - session_->stat_->nn_subscribers++; - return err; } @@ -745,8 +742,6 @@ srs_error_t SrsRtcPlayStream::on_rtcp_rr(SrsRtcpRR* rtcp) // TODO: FIXME: Implements it. - session_->stat_->nn_sr++; - return err; } @@ -756,8 +751,6 @@ srs_error_t SrsRtcPlayStream::on_rtcp_xr(SrsRtcpXr* rtcp) // TODO: FIXME: Implements it. - session_->stat_->nn_xr++; - return err; } @@ -807,8 +800,6 @@ srs_error_t SrsRtcPlayStream::on_rtcp_nack(SrsRtcpNack* rtcp) return srs_error_wrap(err, "track response nack. id:%s, ssrc=%u", target->get_track_id().c_str(), ssrc); } - session_->stat_->nn_nack++; - return err; } @@ -823,8 +814,6 @@ srs_error_t SrsRtcPlayStream::on_rtcp_ps_feedback(SrsRtcpPsfbCommon* rtcp) if (ssrc) { pli_worker_->request_keyframe(ssrc, cid_); } - - session_->stat_->nn_pli++; break; } case kSLI: { @@ -1074,9 +1063,6 @@ srs_error_t SrsRtcPublishStream::initialize(SrsRequest* r, SrsRtcStreamDescripti track->set_nack_no_copy(nack_no_copy_); } - // Update stat for session. - session_->stat_->nn_publishers++; - // Setup the publish stream in source to enable PLI as such. if ((err = _srs_rtc_sources->fetch_or_create(req, &source)) != srs_success) { return srs_error_wrap(err, "create source"); @@ -1193,8 +1179,6 @@ srs_error_t SrsRtcPublishStream::send_rtcp_rr() } } - session_->stat_->nn_rr++; - return err; } @@ -1216,8 +1200,6 @@ srs_error_t SrsRtcPublishStream::send_rtcp_xr_rrtr() } } - session_->stat_->nn_xr++; - return err; } @@ -1227,8 +1209,6 @@ srs_error_t SrsRtcPublishStream::on_twcc(uint16_t sn) { srs_utime_t now = srs_get_system_time(); err = rtcp_twcc_.recv_packet(sn, now); - session_->stat_->nn_in_twcc++; - return err; } @@ -1236,8 +1216,6 @@ srs_error_t SrsRtcPublishStream::on_rtp(char* data, int nb_data) { srs_error_t err = srs_success; - session_->stat_->nn_in_rtp++; - // For NACK simulator, drop packet. if (nn_simulate_nack_drop) { SrsBuffer b(data, nb_data); SrsRtpHeader h; h.ignore_padding(true); @@ -1586,8 +1564,6 @@ srs_error_t SrsRtcPublishStream::do_request_keyframe(uint32_t ssrc, SrsContextId srs_freep(err); } - session_->stat_->nn_pli++; - return err; } @@ -1655,51 +1631,6 @@ void SrsRtcPublishStream::update_send_report_time(uint32_t ssrc, const SrsNtp& n } } -SrsRtcConnectionStatistic::SrsRtcConnectionStatistic() -{ - dead = born = srs_get_system_time(); - nn_publishers = nn_subscribers = 0; - nn_rr = nn_xr = 0; - nn_sr = nn_nack = nn_pli = 0; - nn_in_twcc = nn_in_rtp = nn_in_audios = nn_in_videos = 0; - nn_out_twcc = nn_out_rtp = nn_out_audios = nn_out_videos = 0; -} - -SrsRtcConnectionStatistic::~SrsRtcConnectionStatistic() -{ -} - -string SrsRtcConnectionStatistic::summary() -{ - dead = srs_get_system_time(); - - stringstream ss; - - ss << "alive=" << srsu2msi(dead - born) << "ms"; - - if (nn_publishers) ss << ", npub=" << nn_publishers; - if (nn_subscribers) ss << ", nsub=" << nn_subscribers; - - if (nn_rr) ss << ", nrr=" << nn_rr; - if (nn_xr) ss << ", nxr=" << nn_xr; - - if (nn_sr) ss << ", nsr=" << nn_sr; - if (nn_nack) ss << ", nnack=" << nn_nack; - if (nn_pli) ss << ", npli=" << nn_pli; - - if (nn_in_twcc) ss << ", in_ntwcc=" << nn_in_twcc; - if (nn_in_rtp) ss << ", in_nrtp=" << nn_in_rtp; - if (nn_in_audios) ss << ", in_naudio=" << nn_in_audios; - if (nn_in_videos) ss << ", in_nvideo=" << nn_in_videos; - - if (nn_out_twcc) ss << ", out_ntwcc=" << nn_out_twcc; - if (nn_out_rtp) ss << ", out_nrtp=" << nn_out_rtp; - if (nn_out_audios) ss << ", out_naudio=" << nn_out_audios; - if (nn_out_videos) ss << ", out_nvideo=" << nn_out_videos; - - return ss.str(); -} - ISrsRtcConnectionHijacker::ISrsRtcConnectionHijacker() { } @@ -1751,7 +1682,6 @@ SrsRtcConnection::SrsRtcConnection(SrsRtcServer* s, const SrsContextId& cid) { req = NULL; cid_ = cid; - stat_ = new SrsRtcConnectionStatistic(); hijacker_ = NULL; sendonly_skt = NULL; @@ -1818,7 +1748,6 @@ SrsRtcConnection::~SrsRtcConnection() srs_freep(transport_); srs_freep(req); - srs_freep(stat_); srs_freep(pp_address_change); srs_freep(pli_epp); } @@ -2304,8 +2233,7 @@ srs_error_t SrsRtcConnection::on_dtls_alert(std::string type, std::string desc) SrsContextRestore(_srs_context->get_id()); switch_to_context(); - srs_trace("RTC: session destroy by DTLS alert, username=%s, summary: %s", - username_.c_str(), stat_->summary().c_str()); + srs_trace("RTC: session destroy by DTLS alert, username=%s", username_.c_str()); _srs_rtc_manager->remove(this); } diff --git a/trunk/src/app/srs_app_rtc_conn.hpp b/trunk/src/app/srs_app_rtc_conn.hpp index b57ef5b34..567c47c39 100644 --- a/trunk/src/app/srs_app_rtc_conn.hpp +++ b/trunk/src/app/srs_app_rtc_conn.hpp @@ -394,24 +394,6 @@ private: void update_send_report_time(uint32_t ssrc, const SrsNtp& ntp); }; -// The statistics for RTC connection. -class SrsRtcConnectionStatistic -{ -public: - int nn_publishers; int nn_subscribers; - int nn_rr; int nn_xr; int nn_sr; int nn_nack; int nn_pli; - uint64_t nn_in_twcc; uint64_t nn_in_rtp; uint64_t nn_in_audios; uint64_t nn_in_videos; - uint64_t nn_out_twcc; uint64_t nn_out_rtp; uint64_t nn_out_audios; uint64_t nn_out_videos; -private: - srs_utime_t born; - srs_utime_t dead; -public: - SrsRtcConnectionStatistic(); - virtual ~SrsRtcConnectionStatistic(); -public: - std::string summary(); -}; - // Callback for RTC connection. class ISrsRtcConnectionHijacker { @@ -449,7 +431,6 @@ private: SrsRtcConnectionNackTimer* timer_nack_; public: bool disposing_; - SrsRtcConnectionStatistic* stat_; ISrsRtcConnectionHijacker* hijacker_; private: SrsRtcServer* server_; diff --git a/trunk/src/app/srs_app_rtc_server.cpp b/trunk/src/app/srs_app_rtc_server.cpp index c71e94b8f..706b4a5e2 100644 --- a/trunk/src/app/srs_app_rtc_server.cpp +++ b/trunk/src/app/srs_app_rtc_server.cpp @@ -659,8 +659,7 @@ srs_error_t SrsRtcServer::on_timer(srs_utime_t interval) session->switch_to_context(); string username = session->username(); - srs_trace("RTC: session destroy by timeout, username=%s, summary: %s", username.c_str(), - session->stat_->summary().c_str()); + srs_trace("RTC: session destroy by timeout, username=%s", username.c_str()); // Use manager to free session and notify other objects. _srs_rtc_manager->remove(session); diff --git a/trunk/src/app/srs_app_rtc_source.cpp b/trunk/src/app/srs_app_rtc_source.cpp index 1948b4798..226a2105d 100644 --- a/trunk/src/app/srs_app_rtc_source.cpp +++ b/trunk/src/app/srs_app_rtc_source.cpp @@ -2192,29 +2192,10 @@ SrsRtcTrackDescription* SrsRtcStreamDescription::find_track_description_by_ssrc( return NULL; } -SrsRtcTrackStatistic::SrsRtcTrackStatistic() -{ - packets = 0; - last_packets = 0; - bytes = 0; - last_bytes = 0; - nacks = 0; - last_nacks = 0; - padding_packets = 0; - last_padding_packets = 0; - padding_bytes = 0; - last_padding_bytes = 0; - replay_packets = 0; - last_replay_packets = 0; - replay_bytes = 0; - last_replay_bytes = 0; -} - SrsRtcRecvTrack::SrsRtcRecvTrack(SrsRtcConnection* session, SrsRtcTrackDescription* track_desc, bool is_audio) { session_ = session; track_desc_ = track_desc->copy(); - statistic_ = new SrsRtcTrackStatistic(); nack_no_copy_ = false; if (is_audio) { @@ -2233,7 +2214,6 @@ SrsRtcRecvTrack::~SrsRtcRecvTrack() srs_freep(rtp_queue_); srs_freep(nack_receiver_); srs_freep(track_desc_); - srs_freep(statistic_); } bool SrsRtcRecvTrack::has_ssrc(uint32_t ssrc) @@ -2341,7 +2321,6 @@ srs_error_t SrsRtcRecvTrack::do_check_send_nacks(uint32_t& timeout_nacks) uint32_t sent_nacks = 0; session_->check_send_nacks(nack_receiver_, track_desc_->ssrc_, sent_nacks, timeout_nacks); - statistic_->nacks += sent_nacks; return err; } @@ -2370,13 +2349,6 @@ srs_error_t SrsRtcAudioRecvTrack::on_rtp(SrsRtcStream* source, SrsRtpPacket2* pk { srs_error_t err = srs_success; - // connection level statistic - session_->stat_->nn_in_audios++; - - // track level statistic - statistic_->packets++; - statistic_->bytes += pkt->nb_bytes(); - if ((err = source->on_rtp(pkt)) != srs_success) { return srs_error_wrap(err, "source on rtp"); } @@ -2433,13 +2405,6 @@ srs_error_t SrsRtcVideoRecvTrack::on_rtp(SrsRtcStream* source, SrsRtpPacket2* pk { srs_error_t err = srs_success; - // connection level statistic - session_->stat_->nn_in_videos++; - - // track level statistic - statistic_->packets++; - statistic_->bytes += pkt->nb_bytes(); - pkt->frame_type = SrsFrameTypeVideo; if ((err = source->on_rtp(pkt)) != srs_success) { @@ -2475,7 +2440,6 @@ SrsRtcSendTrack::SrsRtcSendTrack(SrsRtcConnection* session, SrsRtcTrackDescripti { session_ = session; track_desc_ = track_desc->copy(); - statistic_ = new SrsRtcTrackStatistic(); nack_no_copy_ = false; if (is_audio) { @@ -2491,7 +2455,6 @@ SrsRtcSendTrack::~SrsRtcSendTrack() { srs_freep(rtp_queue_); srs_freep(track_desc_); - srs_freep(statistic_); srs_freep(nack_epp); } @@ -2568,10 +2531,6 @@ srs_error_t SrsRtcSendTrack::on_recv_nack(const vector& lost_seqs) ++_srs_pps_rnack2->sugar; - SrsRtcTrackStatistic* statistic = statistic_; - - statistic->nacks++; - for(int i = 0; i < (int)lost_seqs.size(); ++i) { uint16_t seq = lost_seqs.at(i); SrsRtpPacket2* pkt = fetch_rtp_packet(seq); @@ -2624,14 +2583,6 @@ srs_error_t SrsRtcAudioSendTrack::on_rtp(SrsRtpPacket2* pkt) // TODO: FIXME: Should update PT for RTX. } - // Update stats. - session_->stat_->nn_out_audios++; - - // track level statistic - // TODO: FIXME: if send packets failed, statistic is no correct. - statistic_->packets++; - statistic_->bytes += pkt->nb_bytes(); - if ((err = session_->do_send_packet(pkt)) != srs_success) { return srs_error_wrap(err, "raw send"); } @@ -2662,8 +2613,6 @@ srs_error_t SrsRtcVideoSendTrack::on_rtp(SrsRtpPacket2* pkt) if (!track_desc_->is_active_) { return err; } - - SrsRtcTrackStatistic* statistic = statistic_; pkt->header.set_ssrc(track_desc_->ssrc_); @@ -2678,14 +2627,6 @@ srs_error_t SrsRtcVideoSendTrack::on_rtp(SrsRtpPacket2* pkt) // TODO: FIXME: Should update PT for RTX. } - // Update stats. - session_->stat_->nn_out_videos++; - - // track level statistic - // TODO: FIXME: if send packets failed, statistic is no correct. - statistic->packets++; - statistic->bytes += pkt->nb_bytes(); - if ((err = session_->do_send_packet(pkt)) != srs_success) { return srs_error_wrap(err, "raw send"); } diff --git a/trunk/src/app/srs_app_rtc_source.hpp b/trunk/src/app/srs_app_rtc_source.hpp index 19172304b..bf435996d 100644 --- a/trunk/src/app/srs_app_rtc_source.hpp +++ b/trunk/src/app/srs_app_rtc_source.hpp @@ -532,50 +532,10 @@ public: SrsRtcTrackDescription* find_track_description_by_ssrc(uint32_t ssrc); }; -class SrsRtcTrackStatistic -{ -public: - // packets received or sent. - uint32_t packets; - // packets received or sent at last statistic time. - uint32_t last_packets; - // bytes received or sent. - uint64_t bytes; - // bytes received or sent at last statistic time. - uint32_t last_bytes; - - // nacks received or sent. - uint32_t nacks; - // nacks received or sent at last statistic time. - uint32_t last_nacks; - - // padding packets received or sent. - uint32_t padding_packets; - // padding packets received or sent at last statistic time. - uint32_t last_padding_packets; - // padding bytes received or sent. - uint32_t padding_bytes; - // padding bytes received or sent at last statistic time. - uint32_t last_padding_bytes; - - // replay packets received or sent. - uint32_t replay_packets; - // replay packets received or sent at last statistic time. - uint32_t last_replay_packets; - // replay bytes received or sent. - uint64_t replay_bytes; - // replay bytes received or sent at last statistic time. - uint64_t last_replay_bytes; - -public: - SrsRtcTrackStatistic(); -}; - class SrsRtcRecvTrack { protected: SrsRtcTrackDescription* track_desc_; - SrsRtcTrackStatistic* statistic_; protected: SrsRtcConnection* session_; SrsRtpRingBuffer* rtp_queue_; @@ -642,7 +602,6 @@ class SrsRtcSendTrack protected: // send track description SrsRtcTrackDescription* track_desc_; - SrsRtcTrackStatistic* statistic_; protected: // The owner connection for this track. SrsRtcConnection* session_;