WebRTC video frames count
This commit is contained in:
parent
6e2392f366
commit
9e9b5f15ee
|
|
@ -1687,7 +1687,7 @@ srs_error_t SrsRtcPublishStream::do_on_rtp_plaintext(SrsRtpPacket *&pkt, SrsBuff
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update RTP packet statistics.
|
// Update RTP packet statistics.
|
||||||
update_rtp_packet_stats(is_audio);
|
update_rtp_packet_stats(pkt, track, is_audio);
|
||||||
|
|
||||||
// Consume packet by track.
|
// Consume packet by track.
|
||||||
if ((err = track->on_rtp(source_, pkt)) != srs_success) {
|
if ((err = track->on_rtp(source_, pkt)) != srs_success) {
|
||||||
|
|
@ -1709,19 +1709,25 @@ srs_error_t SrsRtcPublishStream::do_on_rtp_plaintext(SrsRtpPacket *&pkt, SrsBuff
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SrsRtcPublishStream::update_rtp_packet_stats(bool is_audio)
|
void SrsRtcPublishStream::update_rtp_packet_stats(SrsRtpPacket *pkt, SrsRtcRecvTrack *track, bool is_audio)
|
||||||
{
|
{
|
||||||
srs_error_t err = srs_success;
|
srs_error_t err = srs_success;
|
||||||
|
|
||||||
// Count RTP packets for statistics.
|
// Count audio packets and video frames for statistics.
|
||||||
|
bool is_primary_ssrc = track && pkt->header_.get_ssrc() == track->get_ssrc();
|
||||||
|
if (!is_primary_ssrc) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (is_audio) {
|
if (is_audio) {
|
||||||
++nn_audio_frames_;
|
++nn_audio_frames_;
|
||||||
} else {
|
} else if (pkt->header_.get_marker()) {
|
||||||
++nn_video_frames_;
|
++nn_video_frames_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the stat for video frames, counting RTP packets as frames.
|
// Update the stat for video frames. Note that for WebRTC, a video frame may be
|
||||||
if (nn_video_frames_ > 288) {
|
// fragmented into multiple RTP packets, so we count frames by RTP marker bit.
|
||||||
|
if (nn_video_frames_ > 30) {
|
||||||
if ((err = stat_->on_video_frames(req_, nn_video_frames_)) != srs_success) {
|
if ((err = stat_->on_video_frames(req_, nn_video_frames_)) != srs_success) {
|
||||||
srs_warn("RTC: stat video frames err %s", srs_error_desc(err).c_str());
|
srs_warn("RTC: stat video frames err %s", srs_error_desc(err).c_str());
|
||||||
srs_freep(err);
|
srs_freep(err);
|
||||||
|
|
@ -1730,7 +1736,7 @@ void SrsRtcPublishStream::update_rtp_packet_stats(bool is_audio)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the stat for audio frames periodically.
|
// Update the stat for audio frames periodically.
|
||||||
if (nn_audio_frames_ > 288) {
|
if (nn_audio_frames_ > 50) {
|
||||||
if ((err = stat_->on_audio_frames(req_, nn_audio_frames_)) != srs_success) {
|
if ((err = stat_->on_audio_frames(req_, nn_audio_frames_)) != srs_success) {
|
||||||
srs_warn("RTC: stat audio frames err %s", srs_error_desc(err).c_str());
|
srs_warn("RTC: stat audio frames err %s", srs_error_desc(err).c_str());
|
||||||
srs_freep(err);
|
srs_freep(err);
|
||||||
|
|
|
||||||
|
|
@ -622,7 +622,7 @@ public:
|
||||||
// clang-format off
|
// clang-format off
|
||||||
SRS_DECLARE_PRIVATE: // clang-format on
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t do_on_rtp_plaintext(SrsRtpPacket *&pkt, SrsBuffer *buf);
|
srs_error_t do_on_rtp_plaintext(SrsRtpPacket *&pkt, SrsBuffer *buf);
|
||||||
void update_rtp_packet_stats(bool is_audio);
|
void update_rtp_packet_stats(SrsRtpPacket *pkt, SrsRtcRecvTrack *track, bool is_audio);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
srs_error_t check_send_nacks();
|
srs_error_t check_send_nacks();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user