Skip to content

Commit

Permalink
add send jitter metric
Browse files Browse the repository at this point in the history
  • Loading branch information
vpalmisano committed Nov 27, 2024
1 parent 4bf9218 commit 6218612
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
4 changes: 2 additions & 2 deletions scripts/get-user-media.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ if (navigator.getUserMedia) {
if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
const nativeGetUserMedia = navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices)
navigator.mediaDevices.getUserMedia = async function (constraints, ...args) {
log(`getUserMedia:`, constraints)
log(`getUserMedia:`, JSON.stringify(constraints, null, 2))
try {
overrideGetUserMedia(constraints)
} catch (err) {
Expand Down Expand Up @@ -192,7 +192,7 @@ if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
if (navigator.mediaDevices && navigator.mediaDevices.getDisplayMedia) {
const nativeGetDisplayMedia = navigator.mediaDevices.getDisplayMedia.bind(navigator.mediaDevices)
navigator.mediaDevices.getDisplayMedia = async function (constraints, ...args) {
log(`getDisplayMedia:`, constraints)
log(`getDisplayMedia:`, JSON.stringify(constraints, null, 2))
let stopFakeScreenshare = null
if (window.PARAMS?.fakeScreenshare) {
stopFakeScreenshare = await webrtcperf.setupFakeScreenshare(window.PARAMS?.fakeScreenshare)
Expand Down
4 changes: 4 additions & 0 deletions scripts/peer-connection-stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ async function getPeerConnectionStats(id, pc, now, raw = false, verbose = false)
s.packetsLost = remoteInboundRtpStreamStats.packetsLost
s.totalRoundTripTime = remoteInboundRtpStreamStats.totalRoundTripTime
s.roundTripTimeMeasurements = remoteInboundRtpStreamStats.roundTripTimeMeasurements
s.jitter = remoteInboundRtpStreamStats.jitter
}
const {
kind,
Expand All @@ -146,6 +147,7 @@ async function getPeerConnectionStats(id, pc, now, raw = false, verbose = false)
nackCount,
totalRoundTripTime,
roundTripTimeMeasurements,
jitter,
totalEncodeTime,
totalPacketSendDelay,
} = s
Expand All @@ -165,6 +167,7 @@ async function getPeerConnectionStats(id, pc, now, raw = false, verbose = false)
pliCountReceived: pliCount,
totalRoundTripTime,
roundTripTimeMeasurements,
jitter,
totalEncodeTime,
totalPacketSendDelay,
qualityLimitationResolutionChanges,
Expand Down Expand Up @@ -201,6 +204,7 @@ async function getPeerConnectionStats(id, pc, now, raw = false, verbose = false)
'pliCountReceived',
'totalRoundTripTime',
'roundTripTimeMeasurements',
'jitter',
'totalEncodeTime',
'totalPacketSendDelay',
].forEach(prop => maxOptional(values.outboundRtp, outboundRtp, prop))
Expand Down
4 changes: 2 additions & 2 deletions scripts/screenshare.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ webrtcperf.setupFakeScreenshare = ({
wrapper.setAttribute('id', 'webrtcperf-fake-screenshare')
wrapper.setAttribute(
'style',
`position: fixed; top: 0; left: 0; width: ${width}px; height: ${height}px; z-index: -1; background-color: black; isolation: isolate; transform-style: flat;`,
`all: unset; position: fixed; top: 0; left: 0; width: ${width}px; height: ${height}px; z-index: -1; background-color: black; isolation: isolate; transform-style: flat;`,
)
document.body.appendChild(wrapper)
window.GET_DISPLAY_MEDIA_CROP = '#webrtcperf-fake-screenshare'
Expand All @@ -60,7 +60,7 @@ webrtcperf.setupFakeScreenshare = ({
img.setAttribute('src', `https://picsum.photos/seed/${i + 1}/${width}/${height}`)
img.setAttribute(
'style',
`position: absolute; width: ${width}px; height: ${height}px; transform: translateX(100%); opacity: 0;`,
`all: unset; position: absolute; width: ${width}px; height: ${height}px; transform: translateX(100%); opacity: 0;`,
)
wrapper.appendChild(img)
slidesElements.push(img)
Expand Down
7 changes: 7 additions & 0 deletions src/rtcstats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ export enum RtcStatsMetricNames {
audioSentNackCountRecv = 'audioSentNackCountRecv',
/** The sent audio round trip time. */
audioSentRoundTripTime = 'audioSentRoundTripTime',
/** The sent audio jitter. */
audioSentJitter = 'audioSentJitter',
/** The audio RTC transport round trip time. */
audioSentTransportRoundTripTime = 'audioSentTransportRoundTripTime',
/** The sent audio encoding max bitrate. */
Expand Down Expand Up @@ -161,6 +163,8 @@ export enum RtcStatsMetricNames {
videoSentRoundTripTime = 'videoSentRoundTripTime',
/** The transport send video round trip time. */
videoSentTransportRoundTripTime = 'videoSentTransportRoundTripTime',
/** The video sent jitter. */
videoSentJitter = 'videoSentJitter',
/** The sent video RTX packets. */
videoSentRetransmittedPackets = 'videoSentRetransmittedPackets',

Expand Down Expand Up @@ -208,6 +212,8 @@ export enum RtcStatsMetricNames {
screenSentRoundTripTime = 'screenSentRoundTripTime',
/** The transport sent screen round trip time. */
screenSentTransportRoundTripTime = 'screenSentTransportRoundTripTime',
/** The screen sent jitter. */
screenSentJitter = 'screenSentJitter',
/** The screen audio RTX packets. */
screenSentRetransmittedPackets = 'screenSentRetransmittedPackets',

Expand Down Expand Up @@ -439,6 +445,7 @@ export function updateRtcStats(
setStats(stats, (prefix + 'SentNackCountRecv') as RtcStatsMetricNames, key, outboundRtp.nackCount)
//setStats(stats, prefix + 'SentPacketsLostCount', key, outboundRtp.packetsLost)
setStats(stats, (prefix + 'SentRoundTripTime') as RtcStatsMetricNames, key, outboundRtp.roundTripTime)
setStats(stats, (prefix + 'SentJitter') as RtcStatsMetricNames, key, outboundRtp.jitter)
setStats(
stats,
(prefix + 'SentTransportRoundTripTime') as RtcStatsMetricNames,
Expand Down

0 comments on commit 6218612

Please sign in to comment.