Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add packet stats and improve padding bitrate assignment #1774

Merged
merged 2 commits into from
Nov 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions erizo/src/erizo/MediaStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ void MediaStream::printStats() {
if (audio_enabled_) {
audio_ssrc = std::to_string(is_publisher_ ? getAudioSourceSSRC() : getAudioSinkSSRC());
transferMediaStats("audioBitrate", audio_ssrc, "bitrateCalculated");
transferMediaStats("audioPackets", audio_ssrc, "packetsCalculated");
transferMediaStats("audioPL", audio_ssrc, "packetsLost");
transferMediaStats("audioFL", audio_ssrc, "fractionLost");
transferMediaStats("audioJitter", audio_ssrc, "jitter");
Expand All @@ -407,6 +408,9 @@ void MediaStream::printStats() {
if (video_enabled_) {
video_ssrc = std::to_string(is_publisher_ ? getVideoSourceSSRC() : getVideoSinkSSRC());
transferMediaStats("videoBitrate", video_ssrc, "bitrateCalculated");
transferMediaStats("videoBitrateWithoutPadding", video_ssrc, "mediaBitrateCalculated");
transferMediaStats("videoPackets", video_ssrc, "packetsCalculated");
transferMediaStats("videoPacketsWithoutPadding", video_ssrc, "mediaPacketsCalculated");
transferMediaStats("videoPL", video_ssrc, "packetsLost");
transferMediaStats("videoFL", video_ssrc, "fractionLost");
transferMediaStats("videoJitter", video_ssrc, "jitter");
Expand Down Expand Up @@ -434,6 +438,7 @@ void MediaStream::printStats() {
transferMediaStats("selectedTL", "qualityLayers", "selectedTemporalLayer");
transferMediaStats("qualityLevel", "qualityLayers", "currentQualityLevel");
transferMediaStats("totalBitrate", "total", "bitrateCalculated");
transferMediaStats("totalPackets", "total", "packetsCalculated");
transferMediaStats("paddingBitrate", "total", "paddingBitrate");
transferMediaStats("rtxBitrate", "total", "rtxBitrate");
transferMediaStats("bwe", "total", "senderBitrateEstimation");
Expand Down
2 changes: 2 additions & 0 deletions erizo/src/erizo/MediaStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ class MediaStream: public MediaSink, public MediaSource, public FeedbackSink,
bool isAudioMuted() { return audio_muted_; }
bool isVideoMuted() { return video_muted_; }

bool canSendPadding() { return !isPublisher() && hasVideo() && !isVideoMuted(); }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


std::shared_ptr<SdpInfo> getRemoteSdpInfo() { return remote_sdp_; }

virtual bool isSlideShowModeEnabled() { return slide_show_mode_; }
Expand Down
6 changes: 3 additions & 3 deletions erizo/src/erizo/rtp/RtpPaddingManagerHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ void RtpPaddingManagerHandler::distributeTotalTargetPaddingBitrate(int64_t bitra
size_t num_streams = 0;
connection_->forEachMediaStream([&num_streams]
(std::shared_ptr<MediaStream> media_stream) {
if (!media_stream->isPublisher()) {
if (media_stream->canSendPadding()) {
num_streams++;
}
});
Expand All @@ -179,7 +179,7 @@ void RtpPaddingManagerHandler::distributeTotalTargetPaddingBitrate(int64_t bitra
int64_t bitrate_per_stream = bitrate / num_streams;
connection_->forEachMediaStreamAsync([bitrate_per_stream]
(std::shared_ptr<MediaStream> media_stream) {
if (media_stream->isPublisher()) {
if (!media_stream->canSendPadding()) {
return;
}
media_stream->setTargetPaddingBitrate(bitrate_per_stream);
Expand All @@ -190,7 +190,7 @@ int64_t RtpPaddingManagerHandler::getTotalTargetBitrate() {
int64_t target_bitrate = 0;
connection_->forEachMediaStream([&target_bitrate]
(std::shared_ptr<MediaStream> media_stream) {
if (media_stream->isPublisher()) {
if (!media_stream->canSendPadding()) {
return;
}
target_bitrate += media_stream->getTargetVideoBitrate();
Expand Down
9 changes: 9 additions & 0 deletions erizo/src/erizo/rtp/StatsHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ void StatsCalculator::update(MediaStream *stream, std::shared_ptr<Stats> stats)
if (!getStatsInfo().hasChild("total")) {
getStatsInfo()["total"].insertStat("bitrateCalculated", MovingIntervalRateStat{kRateStatIntervalSize,
kRateStatIntervals, 8.});
getStatsInfo()["total"].insertStat("packetsCalculated", MovingIntervalRateStat{kRateStatIntervalSize,
kRateStatIntervals, 1.});
}
}
}
Expand Down Expand Up @@ -52,11 +54,18 @@ void StatsCalculator::processRtpPacket(std::shared_ptr<DataPacket> packet) {
kRateStatIntervals, 8.});
getStatsInfo()[ssrc].insertStat("mediaBitrateCalculated", MovingIntervalRateStat{kRateStatIntervalSize,
kRateStatIntervals, 8.});
getStatsInfo()[ssrc].insertStat("packetsCalculated", MovingIntervalRateStat{kRateStatIntervalSize,
kRateStatIntervals, 1.});
getStatsInfo()[ssrc].insertStat("mediaPacketsCalculated", MovingIntervalRateStat{kRateStatIntervalSize,
kRateStatIntervals, 1.});
}
getStatsInfo()[ssrc]["bitrateCalculated"] += len;
getStatsInfo()[ssrc]["packetsCalculated"] += 1;
getStatsInfo()["total"]["bitrateCalculated"] += len;
getStatsInfo()["total"]["packetsCalculated"] += 1;
if (!packet->is_padding) {
getStatsInfo()[ssrc]["mediaBitrateCalculated"] += len;
getStatsInfo()[ssrc]["mediaPacketsCalculated"] += 1;
}
if (packet->type == VIDEO_PACKET) {
stream_->setVideoBitrate(getStatsInfo()[ssrc]["mediaBitrateCalculated"].value());
Expand Down