Created
September 25, 2021 13:51
-
-
Save mstyura/dd5e38cf2ba48a031c276e467eabb67a to your computer and use it in GitHub Desktop.
WebRTC statistics type definition.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type RTCStatsType = | |
"codec" | | |
"inbound-rtp" | | |
"outbound-rtp" | | |
"remote-inbound-rtp" | | |
"remote-outbound-rtp" | | |
"media-source" | | |
"csrc" | | |
"peer-connection" | | |
"data-channel" | | |
"transceiver" | | |
"sender" | | |
"receiver" | | |
"transport" | | |
"sctp-transport" | | |
"candidate-pair" | | |
"local-candidate" | | |
"remote-candidate" | | |
"certificate" | | |
"ice-server"; | |
type RTCQualityLimitationReason = "none" | "cpu" | "bandwidth" | "other"; | |
type RTCCodecType = "encode" | "decode"; | |
type RTCIceRole = "unknown" | "controlling" | "controlled" | |
type RTCStatsIceCandidatePairState = "frozen" | "waiting" | "in-progress" | "failed" | "succeeded"; | |
interface RTCStats { | |
timestamp: DOMHighResTimeStamp; | |
type: RTCStatsType; | |
id: string; | |
}; | |
interface RTCMediaSourceStats extends RTCStats { | |
type: "media-source"; | |
kind: "audio" | "video"; | |
trackIdentifier: string; | |
relayedSource?: boolean; | |
}; | |
interface RTCAudioSourceStats extends RTCMediaSourceStats { | |
kind: "audio"; | |
audioLevel?: number; | |
totalAudioEnergy?: number; | |
totalSamplesDuration?: number; | |
echoReturnLoss?: number; | |
echoReturnLossEnhancement?: number; | |
}; | |
interface RTCVideoSourceStats extends RTCMediaSourceStats { | |
kind: "video"; | |
width?: number; | |
height?: number; | |
frames?: number; | |
framesPerSecond?: number; | |
bitDepth?: number; | |
}; | |
interface RTCMediaHandlerStats extends RTCStats { | |
kind: "audio" | "video"; | |
trackIdentifier?: string; | |
ended?: boolean; | |
}; | |
interface RTCVideoHandlerStats extends RTCMediaHandlerStats { | |
kind: "video"; | |
}; | |
interface RTCVideoSenderStats extends RTCVideoHandlerStats { | |
type: "sender"; | |
mediaSourceId?: string; | |
}; | |
interface RTCVideoReceiverStats extends RTCVideoHandlerStats { | |
type: "receiver"; | |
}; | |
interface RTCAudioHandlerStats extends RTCMediaHandlerStats { | |
kind: "audio"; | |
}; | |
interface RTCAudioSenderStats extends RTCAudioHandlerStats { | |
type: "sender"; | |
mediaSourceId?: string; | |
}; | |
interface RTCAudioReceiverStats extends RTCAudioHandlerStats { | |
type: "receiver"; | |
}; | |
interface RTCRtpStreamStats extends RTCStats { | |
kind: "audio" | "video"; | |
ssrc: number; | |
transportId?: string; | |
codecId?: string; | |
}; | |
interface RTCSentRtpStreamStats extends RTCRtpStreamStats { | |
packetsSent?: number; | |
bytesSent?: number; | |
}; | |
type RTCOutboundRtpStreamStats = RTCSentRtpStreamStats & { | |
type: "outbound-rtp"; | |
rtxSsrc?: number; | |
mediaSourceId?: string; | |
senderId?: string; | |
remoteId?: string; | |
rid?: string; | |
lastPacketSentTimestamp?: DOMHighResTimeStamp; | |
headerBytesSent?: number; | |
packetsDiscardedOnSend?: number; | |
bytesDiscardedOnSend?: number; | |
fecPacketsSent?: number; | |
retransmittedPacketsSent?: number; | |
retransmittedBytesSent?: number; | |
targetBitrate?: number; | |
totalEncodedBytesTarget?: number; | |
totalEncodeTime?: number; | |
totalPacketSendDelay?: number; | |
averageRtcpInterval?: number; | |
perDscpPacketsSent?: Record<string, number>; | |
nackCount?: number; | |
encoderImplementation?: string; | |
} & ({ | |
kind: "video"; | |
frameWidth?: number; | |
frameHeight?: number; | |
frameBitDepth?: number; | |
framesPerSecond?: number; | |
framesSent?: number; | |
hugeFramesSent?: number; | |
framesEncoded?: number; | |
keyFramesEncoded?: number; | |
framesDiscardedOnSend?: number; | |
qpSum?: number; | |
qualityLimitationReason?: RTCQualityLimitationReason; | |
qualityLimitationDurations?: Record<string, number>; | |
qualityLimitationResolutionChanges?: number; | |
firCount?: number; | |
pliCount?: number; | |
sliCount?: number; | |
} | { | |
kind: "audio"; | |
totalSamplesSent?: number; | |
samplesEncodedWithSilk?: number; | |
samplesEncodedWithCelt?: number; | |
voiceActivityFlag?: boolean; | |
}); | |
interface RTCRemoteOutboundRtpStreamStats extends RTCSentRtpStreamStats { | |
type: "remote-outbound-rtp"; | |
localId?: string; | |
remoteTimestamp?: DOMHighResTimeStamp; | |
reportsSent?: number; | |
roundTripTime?: number; | |
totalRoundTripTime?: number; | |
roundTripTimeMeasurements?: number; | |
}; | |
type RTCReceivedRtpStreamStats = RTCRtpStreamStats & { | |
packetsReceived?: number; | |
packetsLost?: number; | |
jitter?: number; | |
packetsDiscarded?: number; | |
packetsRepaired?: number; | |
burstPacketsLost?: number; | |
burstPacketsDiscarded?: number; | |
burstLossCount?: number; | |
burstDiscardCount?: number; | |
burstLossRate?: number; | |
burstDiscardRate?: number; | |
gapLossRate?: number; | |
gapDiscardRate?: number; | |
} & ({ | |
kind: "audio"; | |
} | { | |
kind: "video"; | |
framesDropped?: number; | |
partialFramesLost?: number; | |
fullFramesLost?: number; | |
}); | |
type RTCInboundRtpStreamStats = RTCReceivedRtpStreamStats & { | |
type: "inbound-rtp"; | |
receiverId: string; | |
remoteId?: string; | |
lastPacketReceivedTimestamp?: DOMHighResTimeStamp; | |
averageRtcpInterval?: number; | |
headerBytesReceived?: number; | |
fecPacketsReceived?: number; | |
fecPacketsDiscarded?: number; | |
bytesReceived?: number; | |
packetsFailedDecryption?: number; | |
packetsDuplicated?: number; | |
perDscpPacketsReceived?: Record<string, number>; | |
nackCount?: number; | |
totalProcessingDelay?: number; | |
estimatedPlayoutTimestamp?: DOMHighResTimeStamp; | |
jitterBufferDelay?: number; | |
jitterBufferEmittedCount?: number; | |
decoderImplementation?: string; | |
} & ({ | |
kind: "audio"; | |
voiceActivityFlag?: boolean; | |
totalSamplesReceived?: number; | |
totalSamplesDecoded?: number; | |
samplesDecodedWithSilk?: number; | |
samplesDecodedWithCelt?: number; | |
concealedSamples?: number; | |
silentConcealedSamples?: number; | |
concealmentEvents?: number; | |
insertedSamplesForDeceleration?: number; | |
removedSamplesForAcceleration?: number; | |
audioLevel?: number; | |
totalAudioEnergy?: number; | |
totalSamplesDuration?: number; | |
} | { | |
kind: "video"; | |
framesDecoded?: number; | |
keyFramesDecoded?: number; | |
frameWidth?: number; | |
frameHeight?: number; | |
frameBitDepth?: number; | |
framesPerSecond?: number; | |
qpSum?: number; | |
totalDecodeTime?: number; | |
totalInterFrameDelay?: number; | |
totalSquaredInterFrameDelay?: number; | |
firCount?: number; | |
pliCount?: number; | |
sliCount?: number; | |
framesReceived?: number; | |
}); | |
type RTCRemoteInboundRtpStreamStats = RTCReceivedRtpStreamStats & { | |
type: "remote-inbound-rtp"; | |
localId?: string; | |
roundTripTime?: number; | |
totalRoundTripTime?: number; | |
fractionLost?: number; | |
reportsReceived?: number; | |
roundTripTimeMeasurements?: number; | |
}; | |
type RTCCodecStats = RTCStats & { | |
type: "codec" | |
payloadType: number; | |
codecType?: RTCCodecType; | |
transportId: string; | |
mimeType: string; | |
clockRate?: number; | |
channels?: number; | |
sdpFmtpLine?: string; | |
}; | |
interface RTCRtpContributingSourceStats extends RTCStats { | |
type: "csrc" | |
contributorSsrc: number; | |
inboundRtpStreamId: string; | |
packetsContributedTo?: number; | |
audioLevel?: number; | |
}; | |
interface RTCPeerConnectionStats extends RTCStats { | |
type: "peer-connection" | |
dataChannelsOpened?: number; | |
dataChannelsClosed?: number; | |
dataChannelsRequested?: number; | |
dataChannelsAccepted?: number; | |
}; | |
interface RTCDataChannelStats extends RTCStats { | |
type: "data-channel"; | |
label?: string; | |
protocol?: string; | |
dataChannelIdentifier?: number; | |
state: RTCDataChannelState; | |
messagesSent?: number; | |
bytesSent?: number; | |
messagesReceived?: number; | |
bytesReceived?: number; | |
}; | |
interface RTCRtpTransceiverStats extends RTCStats { | |
type: "transceiver"; | |
senderId: string; | |
receiverId: string; | |
mid?: string; | |
}; | |
interface RTCTransportStats extends RTCStats { | |
type: "transport"; | |
packetsSent?: number; | |
packetsReceived?: number; | |
bytesSent?: number; | |
bytesReceived?: number; | |
rtcpTransportStatsId?: string; | |
iceRole?: RTCIceRole; | |
iceLocalUsernameFragment?: string; | |
dtlsState: RTCDtlsTransportState; | |
iceState?: RTCIceTransportState; | |
selectedCandidatePairId?: string; | |
localCertificateId?: string; | |
remoteCertificateId?: string; | |
tlsVersion?: string; | |
dtlsCipher?: string; | |
srtpCipher?: string; | |
tlsGroup?: string; | |
selectedCandidatePairChanges?: number; | |
}; | |
interface RTCSctpTransportStats extends RTCStats { | |
type: "sctp-transport"; | |
transportId?: string; | |
smoothedRoundTripTime?: number; | |
congestionWindow?: number; | |
receiverWindow?: number; | |
mtu?: number; | |
unackData?: number; | |
}; | |
interface RTCIceCandidatePairStats extends RTCStats { | |
type: "candidate-pair"; | |
transportId: string; | |
localCandidateId: string; | |
remoteCandidateId: string; | |
state: RTCStatsIceCandidatePairState; | |
nominated?: boolean; | |
packetsSent?: number; | |
packetsReceived?: number; | |
bytesSent?: number; | |
bytesReceived?: number; | |
lastPacketSentTimestamp?: DOMHighResTimeStamp; | |
lastPacketReceivedTimestamp?: DOMHighResTimeStamp; | |
firstRequestTimestamp?: DOMHighResTimeStamp; | |
lastRequestTimestamp?: DOMHighResTimeStamp; | |
lastResponseTimestamp?: DOMHighResTimeStamp; | |
totalRoundTripTime?: number; | |
currentRoundTripTime?: number; | |
availableOutgoingBitrate?: number; | |
availableIncomingBitrate?: number; | |
circuitBreakerTriggerCount?: number; | |
requestsReceived?: number; | |
requestsSent?: number; | |
responsesReceived?: number; | |
responsesSent?: number; | |
retransmissionsReceived?: number; | |
retransmissionsSent?: number; | |
consentRequestsSent?: number; | |
consentExpiredTimestamp?: DOMHighResTimeStamp; | |
packetsDiscardedOnSend?: number; | |
bytesDiscardedOnSend?: number; | |
requestBytesSent?: number; | |
consentRequestBytesSent?: number; | |
responseBytesSent?: number; | |
}; | |
type RTCIceCandidateStats = RTCStats & { | |
transportId: string; | |
address?: string; | |
port?: number; | |
protocol?: string; | |
candidateType: RTCIceCandidateType; | |
priority?: number; | |
} & ({ | |
type: "remote-candidate"; | |
} | { | |
type: "local-candidate"; | |
relayProtocol?: string; | |
url?: string; | |
}); | |
interface RTCCertificateStats extends RTCStats { | |
type: "certificate"; | |
fingerprint: string; | |
fingerprintAlgorithm: string; | |
base64Certificate: string; | |
issuerCertificateId?: string; | |
} | |
interface RTCIceServerStats extends RTCStats { | |
type: "ice-server"; | |
url: string; | |
port?: number; | |
relayProtocol?: string; | |
totalRequestsSent?: number; | |
totalResponsesReceived?: number; | |
totalRoundTripTime?: number; | |
} | |
export type RTCStatsReport = | |
RTCAudioSourceStats | |
| RTCVideoSourceStats | |
| RTCAudioReceiverStats | |
| RTCAudioSenderStats | |
| RTCVideoSenderStats | |
| RTCVideoReceiverStats | |
| RTCOutboundRtpStreamStats | |
| RTCRemoteOutboundRtpStreamStats | |
| RTCInboundRtpStreamStats | |
| RTCRemoteInboundRtpStreamStats | |
| RTCCodecStats | |
| RTCRtpContributingSourceStats | |
| RTCPeerConnectionStats | |
| RTCDataChannelStats | |
| RTCRtpTransceiverStats | |
| RTCTransportStats | |
| RTCSctpTransportStats | |
| RTCIceCandidatePairStats | |
| RTCIceCandidateStats | |
| RTCCertificateStats | |
| RTCIceServerStats; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment