@@ -67,6 +67,8 @@ func UnmarshalStatsJSON(b []byte) (Stats, error) {
67
67
return unmarshalICECandidateStats (b )
68
68
case StatsTypeCertificate :
69
69
return unmarshalCertificateStats (b )
70
+ case StatsTypeSCTPTransport :
71
+ return unmarshalSCTPTransportStats (b )
70
72
default :
71
73
return nil , fmt .Errorf ("type: %w" , ErrUnknownType )
72
74
}
@@ -132,6 +134,9 @@ const (
132
134
133
135
// StatsTypeCertificate is used by CertificateStats.
134
136
StatsTypeCertificate StatsType = "certificate"
137
+
138
+ // StatsTypeSCTPTransport is used by SCTPTransportStats
139
+ StatsTypeSCTPTransport StatsType = "sctp-transport"
135
140
)
136
141
137
142
// MediaKind indicates the kind of media (audio or video)
@@ -1980,3 +1985,53 @@ func unmarshalCertificateStats(b []byte) (CertificateStats, error) {
1980
1985
}
1981
1986
return certificateStats , nil
1982
1987
}
1988
+
1989
+ // SCTPTransportStats contains information about a certificate used by an SCTPTransport.
1990
+ type SCTPTransportStats struct {
1991
+ // Timestamp is the timestamp associated with this object.
1992
+ Timestamp StatsTimestamp `json:"timestamp"`
1993
+
1994
+ // Type is the object's StatsType
1995
+ Type StatsType `json:"type"`
1996
+
1997
+ // ID is a unique id that is associated with the component inspected to produce
1998
+ // this Stats object. Two Stats objects will have the same ID if they were produced
1999
+ // by inspecting the same underlying object.
2000
+ ID string `json:"id"`
2001
+
2002
+ // TransportID is the identifier of the object that was inspected to produce the
2003
+ // RTCTransportStats for the DTLSTransport and ICETransport supporting the SCTP transport.
2004
+ TransportID string `json:"transportId"`
2005
+
2006
+ // SmoothedRoundTripTime is the latest smoothed round-trip time value, corresponding to spinfo_srtt defined in [RFC6458]
2007
+ // but converted to seconds. If there has been no round-trip time measurements yet, this value is undefined.
2008
+ SmoothedRoundTripTime float64 `json:"smoothedRoundTripTime"`
2009
+
2010
+ // CongestionWindow is the latest congestion window, corresponding to spinfo_cwnd defined in [RFC6458].
2011
+ CongestionWindow uint32 `json:"congestionWindow"`
2012
+
2013
+ // ReceiverWindow is the latest receiver window, corresponding to sstat_rwnd defined in [RFC6458].
2014
+ ReceiverWindow uint32 `json:"receiverWindow"`
2015
+
2016
+ // MTU is the latest maximum transmission unit, corresponding to spinfo_mtu defined in [RFC6458].
2017
+ MTU uint32 `json:"mtu"`
2018
+
2019
+ // UNACKData is the number of unacknowledged DATA chunks, corresponding to sstat_unackdata defined in [RFC6458].
2020
+ UNACKData uint32 `json:"unackData"`
2021
+
2022
+ // BytesSent represents the total number of bytes sent on this SCTPTransport
2023
+ BytesSent uint64 `json:"bytesSent"`
2024
+
2025
+ // BytesReceived represents the total number of bytes received on this SCTPTransport
2026
+ BytesReceived uint64 `json:"bytesReceived"`
2027
+ }
2028
+
2029
+ func (s SCTPTransportStats ) statsMarker () {}
2030
+
2031
+ func unmarshalSCTPTransportStats (b []byte ) (SCTPTransportStats , error ) {
2032
+ var sctpTransportStats SCTPTransportStats
2033
+ if err := json .Unmarshal (b , & sctpTransportStats ); err != nil {
2034
+ return SCTPTransportStats {}, fmt .Errorf ("unmarshal sctp transport stats: %w" , err )
2035
+ }
2036
+ return sctpTransportStats , nil
2037
+ }
0 commit comments