Skip to content

Commit

Permalink
Fixes in stats (#490)
Browse files Browse the repository at this point in the history
  • Loading branch information
hiroshihorie authored Sep 23, 2024
1 parent e4f089c commit 7727ac6
Showing 1 changed file with 25 additions and 36 deletions.
61 changes: 25 additions & 36 deletions Sources/LiveKit/Types/Statistics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,14 @@ public class Statistics: NSObject, Identifiable {
public let id: String
public let type: StatisticsType
public let timestamp: Double
public let rawValues: [String: NSObject]

init?(id: String,
type: StatisticsType,
timestamp: Double,
rawValues: [String: NSObject])
timestamp: Double)
{
self.id = id
self.type = type
self.timestamp = timestamp
self.rawValues = rawValues
}
}

Expand All @@ -149,8 +146,7 @@ public class CodecStatistics: Statistics {

super.init(id: id,
type: .codec,
timestamp: timestamp,
rawValues: rawValues)
timestamp: timestamp)
}
}

Expand All @@ -168,8 +164,7 @@ public class MediaSourceStatistics: Statistics {

super.init(id: id,
type: .mediaSource,
timestamp: timestamp,
rawValues: rawValues)
timestamp: timestamp)
}
}

Expand All @@ -180,10 +175,10 @@ public class RtpStreamStatistics: Statistics {
public let transportId: String?
public let codecId: String?

override init?(id: String,
type: StatisticsType,
timestamp: Double,
rawValues: [String: NSObject])
init?(id: String,
type: StatisticsType,
timestamp: Double,
rawValues: [String: NSObject])
{
ssrc = rawValues.readOptional("ssrc")
kind = rawValues.readOptional("kind")
Expand All @@ -192,8 +187,7 @@ public class RtpStreamStatistics: Statistics {

super.init(id: id,
type: type,
timestamp: timestamp,
rawValues: rawValues)
timestamp: timestamp)
}
}

Expand All @@ -220,8 +214,7 @@ public class AudioPlayoutStatistics: Statistics {

super.init(id: id,
type: .mediaPlayout,
timestamp: timestamp,
rawValues: rawValues)
timestamp: timestamp)
}
}

Expand All @@ -240,8 +233,7 @@ public class PeerConnectionStatistics: Statistics {

super.init(id: id,
type: .peerConnection,
timestamp: timestamp,
rawValues: rawValues)
timestamp: timestamp)
}
}

Expand All @@ -262,7 +254,7 @@ public class DataChannelStatistics: Statistics {
rawValues: [String: NSObject])
{
label = rawValues.readOptional("label")
self.protocol = rawValues.readOptional("protocol")
`protocol` = rawValues.readOptional("protocol")
dataChannelIdentifier = rawValues.readOptional("dataChannelIdentifier")
state = DataChannelState(rawValue: rawValues.readNonOptional("state"))
messagesSent = rawValues.readOptional("messagesSent")
Expand All @@ -272,8 +264,7 @@ public class DataChannelStatistics: Statistics {

super.init(id: id,
type: .dataChannel,
timestamp: timestamp,
rawValues: rawValues)
timestamp: timestamp)
}
}

Expand Down Expand Up @@ -320,8 +311,7 @@ public class TransportStatistics: Statistics {

super.init(id: id,
type: .transport,
timestamp: timestamp,
rawValues: rawValues)
timestamp: timestamp)
}
}

Expand All @@ -342,15 +332,15 @@ public class IceCandidateStatistics: Statistics {
public let usernameFragment: String?
public let tcpType: IceTcpCandidateType?

override init?(id: String,
type: StatisticsType,
timestamp: Double,
rawValues: [String: NSObject])
init?(id: String,
type: StatisticsType,
timestamp: Double,
rawValues: [String: NSObject])
{
transportId = rawValues.readOptional("transportId")
address = rawValues.readOptional("address")
port = rawValues.readOptional("port")
self.protocol = rawValues.readOptional("protocol")
`protocol` = rawValues.readOptional("protocol")
candidateType = IceCandidateType(rawValue: rawValues.readNonOptional("candidateType"))
priority = rawValues.readOptional("priority")
url = rawValues.readOptional("url")
Expand All @@ -363,8 +353,7 @@ public class IceCandidateStatistics: Statistics {

super.init(id: id,
type: type,
timestamp: timestamp,
rawValues: rawValues)
timestamp: timestamp)
}
}

Expand Down Expand Up @@ -449,8 +438,7 @@ public class IceCandidatePairStatistics: Statistics {

super.init(id: id,
type: .candidatePair,
timestamp: timestamp,
rawValues: rawValues)
timestamp: timestamp)
}
}

Expand All @@ -473,8 +461,7 @@ public class CertificateStatistics: Statistics {

super.init(id: id,
type: .certificate,
timestamp: timestamp,
rawValues: rawValues)
timestamp: timestamp)
}
}

Expand Down Expand Up @@ -575,7 +562,8 @@ public class InboundRtpStreamStatistics: ReceivedRtpStreamStatistics {
public let retransmittedPacketsReceived: UInt64?
public let retransmittedBytesReceived: UInt64?

public let previous: InboundRtpStreamStatistics?
// Weak reference to previous stat so we can compare later.
public weak var previous: InboundRtpStreamStatistics?

init?(id: String,
timestamp: Double,
Expand Down Expand Up @@ -720,7 +708,8 @@ public class OutboundRtpStreamStatistics: SentRtpStreamStatistics {
public let active: Bool?
public let scalabilityMode: String?

public let previous: OutboundRtpStreamStatistics?
// Weak reference to previous stat so we can compare later.
public weak var previous: OutboundRtpStreamStatistics?

init?(id: String,
timestamp: Double,
Expand Down

0 comments on commit 7727ac6

Please sign in to comment.