Skip to content

Commit

Permalink
Properly include relay endpoints and senders in relay bitrate/packet …
Browse files Browse the repository at this point in the history
…rate stats. (#1822)
  • Loading branch information
JonathanLennox authored Mar 1, 2022
1 parent 3ce3c1a commit ff8609a
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -380,15 +380,11 @@ private void generate0()

for (Relay relay : conference.getRelays())
{
TransceiverStats transceiverStats = relay.getTransceiver().getTransceiverStats();
PacketStreamStats.Snapshot incomingPacketStreamStats
= transceiverStats.getRtpReceiverStats().getPacketStreamStats();
relayBitrateIncomingBps += incomingPacketStreamStats.getBitrateBps();
relayPacketRateIncoming += incomingPacketStreamStats.getPacketRate();
relayBitrateIncomingBps += relay.getIncomingBitrateBps();
relayPacketRateIncoming += relay.getIncomingPacketRate();

PacketStreamStats.Snapshot outgoingStats = transceiverStats.getOutgoingPacketStreamStats();
relayBitrateOutgoingBps += outgoingStats.getBitrateBps();
relayPacketRateOutgoing += outgoingStats.getPacketRate();
relayBitrateOutgoingBps += relay.getOutgoingBitrateBps();
relayPacketRateOutgoing += relay.getOutgoingPacketRate();

/* TODO: report Relay RTT and loss, like we do for Endpoints? */
}
Expand Down
21 changes: 21 additions & 0 deletions jvb/src/main/kotlin/org/jitsi/videobridge/relay/Relay.kt
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.TimeUnit
import java.util.concurrent.atomic.AtomicLong
import java.util.function.Supplier
import kotlin.collections.sumOf

/**
* Models a relay (remote videobridge) in a [Conference].
Expand Down Expand Up @@ -763,6 +764,26 @@ class Relay @JvmOverloads constructor(
s?.expire()
}

val incomingBitrateBps: Double
get() = transceiver.getTransceiverStats().rtpReceiverStats.packetStreamStats.getBitrateBps() +
synchronized(endpointsLock) {
relayedEndpoints.values.sumOf { it.getIncomingStats().getBitrateBps() }
}

val incomingPacketRate: Long
get() = transceiver.getTransceiverStats().rtpReceiverStats.packetStreamStats.packetRate +
synchronized(endpointsLock) {
relayedEndpoints.values.sumOf { it.getIncomingStats().packetRate }
}

val outgoingBitrateBps: Double
get() = transceiver.getTransceiverStats().outgoingPacketStreamStats.getBitrateBps() +
senders.values.sumOf { it.getOutgoingStats().getBitrateBps() }

val outgoingPacketRate: Long
get() = transceiver.getTransceiverStats().outgoingPacketStreamStats.packetRate +
senders.values.sumOf { it.getOutgoingStats().packetRate }

/**
* Updates the conference statistics with value from this endpoint. Since
* the values are cumulative this should execute only once when the endpoint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ class RelayEndpointSender(
rtpSender.setFeature(feature, enabled)
}

fun getOutgoingStats() = rtpSender.getPacketStreamStats()

fun getNodeStats(): NodeStatsBlock {
return NodeStatsBlock("Remote Endpoint $id").apply {
addBlock(streamInformationStore.getNodeStats())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ class RelayedEndpoint(
rtpReceiver.setFeature(feature, enabled)
}

fun getIncomingStats() = rtpReceiver.getStats().packetStreamStats

fun getNodeStats(): NodeStatsBlock {
return NodeStatsBlock("Remote Endpoint $id").apply {
addBlock(streamInformationStore.getNodeStats())
Expand Down

0 comments on commit ff8609a

Please sign in to comment.