@@ -97,13 +97,15 @@ SrsStatisticStream::SrsStatisticStream()
9797 kbps_ = new SrsKbps ();
9898
9999 nb_clients_ = 0 ;
100- frames_ = new SrsPps ();
100+ video_frames_ = new SrsPps ();
101+ audio_frames_ = new SrsPps ();
101102}
102103
103104SrsStatisticStream::~SrsStatisticStream ()
104105{
105106 srs_freep (kbps_);
106- srs_freep (frames_);
107+ srs_freep (video_frames_);
108+ srs_freep (audio_frames_);
107109}
108110
109111srs_error_t SrsStatisticStream::dumps (SrsJsonObject *obj)
@@ -118,7 +120,9 @@ srs_error_t SrsStatisticStream::dumps(SrsJsonObject *obj)
118120 obj->set (" url" , SrsJsonAny::str (url_.c_str ()));
119121 obj->set (" live_ms" , SrsJsonAny::integer (srsu2ms (srs_time_now_cached ())));
120122 obj->set (" clients" , SrsJsonAny::integer (nb_clients_));
121- obj->set (" frames" , SrsJsonAny::integer (frames_->sugar_ ));
123+ obj->set (" frames" , SrsJsonAny::integer (video_frames_->sugar_ + audio_frames_->sugar_ ));
124+ obj->set (" audio_frames" , SrsJsonAny::integer (audio_frames_->sugar_ ));
125+ obj->set (" video_frames" , SrsJsonAny::integer (video_frames_->sugar_ ));
122126 obj->set (" send_bytes" , SrsJsonAny::integer (kbps_->get_send_bytes ()));
123127 obj->set (" recv_bytes" , SrsJsonAny::integer (kbps_->get_recv_bytes ()));
124128
@@ -395,7 +399,19 @@ srs_error_t SrsStatistic::on_video_frames(ISrsRequest *req, int nb_frames)
395399 SrsStatisticVhost *vhost = create_vhost (req);
396400 SrsStatisticStream *stream = create_stream (vhost, req);
397401
398- stream->frames_ ->sugar_ += nb_frames;
402+ stream->video_frames_ ->sugar_ += nb_frames;
403+
404+ return err;
405+ }
406+
407+ srs_error_t SrsStatistic::on_audio_frames (ISrsRequest *req, int nb_frames)
408+ {
409+ srs_error_t err = srs_success;
410+
411+ SrsStatisticVhost *vhost = create_vhost (req);
412+ SrsStatisticStream *stream = create_stream (vhost, req);
413+
414+ stream->audio_frames_ ->sugar_ += nb_frames;
399415
400416 return err;
401417}
@@ -542,7 +558,8 @@ void SrsStatistic::kbps_sample()
542558 for (it = streams_.begin (); it != streams_.end (); it++) {
543559 SrsStatisticStream *stream = it->second ;
544560 stream->kbps_ ->sample ();
545- stream->frames_ ->update ();
561+ stream->video_frames_ ->update ();
562+ stream->audio_frames_ ->update ();
546563 }
547564 }
548565 if (true ) {
0 commit comments