@pexip/peer-connection-stats
Enumerations
Interfaces
- CacheStats
- CandidatePair
- Codec
- InboundAudio
- InboundVideo
- MediaSource
- Metrics
- OutboundAudio
- OutboundVideo
- RTCStats
- Remote
- StatsCollector
- StatsCollectorOptions
- StatsSignals
- Stream
- Track
- Transport
- VideoMetrics
Type Aliases
AnyStats
Ƭ AnyStats: CandidatePair
| Codec
| InboundAudio
| InboundVideo
| OutboundAudio
| OutboundVideo
| RTCStats
| Remote
| Stream
| Track
| Transport
AudioQualityStats
Ƭ AudioQualityStats: [number
, number
][]
CallPacketsStats
Ƭ CallPacketsStats: PacketsStats
CallQualityStats
Ƭ CallQualityStats: AudioQualityStats
| VideoQualityStats
InboundAudioMetrics
Ƭ InboundAudioMetrics: Metrics
InboundVideoMetrics
Ƭ InboundVideoMetrics: VideoMetrics
NormalizedRTCStats
Ƭ NormalizedRTCStats: InboundAudioMetrics
| InboundVideoMetrics
| OutboundAudioMetrics
| OutboundVideoMetrics
OutboundAudioMetrics
Ƭ OutboundAudioMetrics: Metrics
OutboundVideoMetrics
Ƭ OutboundVideoMetrics: VideoMetrics
& { averagePacketSendDelay?
: number
; totalPacketSendDelay?
: number
}
PacketsStats
Ƭ PacketsStats: [number
, number
][]
VideoQualityStats
Ƭ VideoQualityStats: number
[]
Variables
STATS_SIZE
• Const
STATS_SIZE: 60
Functions
addDeltaStats
▸ addDeltaStats(newStats
, cache
): readonly [{ bitrate?
: number
; bytesTransmitted?
: number
; codec?
: string
; jitter?
: number
; kind
: "audio"
| "video"
; packetsLost
: number
; packetsTransmitted
: number
; recentPercentageLost?
: number
; roundTripTime?
: number
; timestamp?
: number
; totalPercentageLost?
: number
; type
: "inbound-rtp"
| "outbound-rtp"
} | { bitrate?
: number
; bytesTransmitted?
: number
; codec?
: string
; framesPerSecond?
: number
; jitter?
: number
; kind
: "audio"
| "video"
; packetsLost
: number
; packetsTransmitted
: number
; recentPercentageLost?
: number
; resolution?
: string
; resolutionHeight?
: number
; resolutionWidth?
: number
; roundTripTime?
: number
; timestamp?
: number
; totalPercentageLost?
: number
; type
: "inbound-rtp"
| "outbound-rtp"
} | { averagePacketSendDelay?
: number
; bitrate?
: number
; bytesTransmitted?
: number
; codec?
: string
; framesPerSecond?
: number
; jitter?
: number
; kind
: "audio"
| "video"
; packetsLost
: number
; packetsTransmitted
: number
; recentPercentageLost?
: number
; resolution?
: string
; resolutionHeight?
: number
; resolutionWidth?
: number
; roundTripTime?
: number
; timestamp?
: number
; totalPacketSendDelay?
: number
; totalPercentageLost?
: number
; type
: "inbound-rtp"
| "outbound-rtp"
}, Quality
, CallQualityStats
]
Parameters
Name | Type |
---|---|
newStats | NormalizedRTCStats |
cache | CacheStats |
Returns
readonly [{ bitrate?
: number
; bytesTransmitted?
: number
; codec?
: string
; jitter?
: number
; kind
: "audio"
| "video"
; packetsLost
: number
; packetsTransmitted
: number
; recentPercentageLost?
: number
; roundTripTime?
: number
; timestamp?
: number
; totalPercentageLost?
: number
; type
: "inbound-rtp"
| "outbound-rtp"
} | { bitrate?
: number
; bytesTransmitted?
: number
; codec?
: string
; framesPerSecond?
: number
; jitter?
: number
; kind
: "audio"
| "video"
; packetsLost
: number
; packetsTransmitted
: number
; recentPercentageLost?
: number
; resolution?
: string
; resolutionHeight?
: number
; resolutionWidth?
: number
; roundTripTime?
: number
; timestamp?
: number
; totalPercentageLost?
: number
; type
: "inbound-rtp"
| "outbound-rtp"
} | { averagePacketSendDelay?
: number
; bitrate?
: number
; bytesTransmitted?
: number
; codec?
: string
; framesPerSecond?
: number
; jitter?
: number
; kind
: "audio"
| "video"
; packetsLost
: number
; packetsTransmitted
: number
; recentPercentageLost?
: number
; resolution?
: string
; resolutionHeight?
: number
; resolutionWidth?
: number
; roundTripTime?
: number
; timestamp?
: number
; totalPacketSendDelay?
: number
; totalPercentageLost?
: number
; type
: "inbound-rtp"
| "outbound-rtp"
}, Quality
, CallQualityStats
]
calculateQuality
▸ calculateQuality(stats
): Quality
Parameters
Name | Type |
---|---|
stats | number | [number , number ] |
Returns
createResolver
▸ createResolver(statsReport
): Object
The WebRTC stats are given to us as a flat structure (an array of objects that contain id-fields pointing to other objects in the same array).
This class takes such an array as input and can expand an entry so that references become nested objects.
https://www.w3.org/TR/webrtc-stats/#summary https://www.w3.org/TR/webrtc-stats/#rtctatstype-*
Parameters
Name | Type |
---|---|
statsReport | AnyStats [] |
Returns
Object
Name | Type |
---|---|
expand | (audioIn : InboundAudio ) => InboundAudio (audioOut : OutboundAudio ) => OutboundAudio (videoIn : InboundVideo ) => InboundVideo (videoOut : OutboundVideo ) => OutboundVideo |
createStatsCollector
▸ createStatsCollector(«destructured»
): StatsCollector
Creates stats collector
Parameters
Name | Type |
---|---|
«destructured» | StatsCollectorOptions |
Returns
{function to reset stats window, cleanup func}
createStatsSignals
▸ createStatsSignals(scope?
): StatsSignals
Create and return all required and optional (if specified with more
),
signals for infinity client to work
See
- Signal
- InfinitySignalsOptional
The following signals created by default
- 'onConnected',
- 'onAnswer',
- REQUIRED_STATS_SIGNAL_KEYS
Parameters
Name | Type | Default value | Description |
---|---|---|---|
scope | string | '' | any scope prefix for the generated signal name, |
Returns
getQuality
▸ getQuality(stats
): Object
Parameters
Name | Type |
---|---|
stats | CallQualityStats |
Returns
Object
Name | Type |
---|---|
goodOrOkQuality | number |
quality | Quality |
qualityOverTime | Quality [] |
inboundAudio
▸ inboundAudio(statsData
): Metrics
Normalize inbound audio stats
See
InboundAudio
Parameters
Name | Type | Description |
---|---|---|
statsData | InboundAudio | Raw inbound audio stats |
Returns
normalized stats for inbound audio from PeerConnection
inboundVideo
▸ inboundVideo(statsData
): VideoMetrics
Normalize inbound video stats
See
InboundVideo
Parameters
Name | Type | Description |
---|---|---|
statsData | InboundVideo | Raw inbound video stats |
Returns
normalized stats for inbound video from PeerConnection
outboundAudio
▸ outboundAudio(statsData
): Metrics
Normalize outbound audio stats
See
OutboundAudio
Parameters
Name | Type | Description |
---|---|---|
statsData | OutboundAudio | Raw outbound audio stats |
Returns
normalized stats for outbound audio from PeerConnection
outboundVideo
▸ outboundVideo(statsData
): OutboundVideoMetrics
Normalize outbound video stats
See
OutboundVideo
Parameters
Name | Type | Description |
---|---|---|
statsData | OutboundVideo | Raw outbound video stats |
Returns
normalized stats for outbound video from PeerConnection
statsFrom
▸ statsFrom(statsReports
): undefined
| Metrics
Normalize stats into inbound and outbound video and audio stats
Parameters
Name | Type | Description |
---|---|---|
statsReports | AnyStats [] | reports to for mapping |
Returns
undefined
| Metrics
normalized stats for inbound, outbound audio and video
statsFromRTCPeer
▸ statsFromRTCPeer(rtcPeer
): Promise
<NormalizedRTCStats
>
Gets raw stats from peerConnection and normalized them
https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_Statistics_API
A RTCPeerConnection has getStats()
- getStats() returns promise which resolve to a RTCStatsReport
- RTCStatsReport behaves like an array of RTCStats objects, or more specific RTCRtpStreamStats objects
https://developer.mozilla.org/en-US/docs/Web/API/RTCStatsReport https://developer.mozilla.org/en-US/docs/Web/API/RTCStats https://developer.mozilla.org/en-US/docs/Web/API/RTCRtpStreamStats
Parameters
Name | Type |
---|---|
rtcPeer | Object |
rtcPeer.getStats | (selector? : null | MediaStreamTrack ) => Promise <RTCStatsReport > |
Returns
Promise
<NormalizedRTCStats
>