Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(media-score-update): added sample score stats objects #405

Merged
merged 3 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/angular-ui-kit/components/dyte-network-indicator.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ A component that indicates poor network connection.
It listens to the mediaScoreUpdate event of the passed participant to get the score.

```tsx
(participant as DyteParticipant).addListener('mediaScoreUpdate', ({ kind, isScreenshare, score }) => {
(participant as DyteParticipant).addListener('mediaScoreUpdate', ({ kind, isScreenshare, score, scoreStats }) => {
console.log(`Score for ${isScreenshare ? 'screen share': ''} ${kind} was:: ${score}`);
});
```
Expand Down
2 changes: 1 addition & 1 deletion docs/react-ui-kit/components/dyte-network-indicator.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ A component that indicates poor network connection.
It listens to the mediaScoreUpdate event of the passed participant to get the score.

```tsx
(participant as DyteParticipant).addListener('mediaScoreUpdate', ({ kind, isScreenshare, score }) => {
(participant as DyteParticipant).addListener('mediaScoreUpdate', ({ kind, isScreenshare, score, scoreStats }) => {
console.log(`Score for ${isScreenshare ? 'screen share': ''} ${kind} was:: ${score}`);
});
```
Expand Down
20 changes: 2 additions & 18 deletions docs/react-web-core/local-user/events.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -97,26 +97,10 @@ meeting.self.on('deviceUpdate', ({ device }) => {

## Network quality score

Subscribe to the `mediaScoreUpdate` event to monitor network
import SelfMediaScoreUpdate from '@site/docs/web-core/local-user/self-media-score-update.mdx'

```ts
meeting.self.on('mediaScoreUpdate', ({ kind, isScreenshare, score }) => {
if (kind === 'video') {
console.log(
`Your ${isScreenshare ? 'screenshare' : 'video'} quality score is `,
score
);
}

if (kind === 'audio') {
console.log('Your audio quality score is ', score);
}
<SelfMediaScoreUpdate />

if (score < 5) {
console.log('Your media quality is poor');
}
});
```

## Permission Updates

Expand Down
32 changes: 5 additions & 27 deletions docs/react-web-core/participants/events.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -111,34 +111,12 @@ const screensharingParticipant = useDyteSelector((m) =>

## Network quality score

Subscribe to the `mediaScoreUpdate` event to monitor network
import ParticipantMediaScoreUpdate from '@site/docs/web-core/participants/participant-media-score-update.mdx'

<ParticipantMediaScoreUpdate />



```ts
meeting.participants.joined.on(
'mediaScoreUpdate',
({ participantId, kind, isScreenshare, score }) => {
if (kind === 'video') {
console.log(
`Participant ${participantId}'s ${
isScreenshare ? 'screenshare' : 'video'
} quality score is `,
score
);
}

if (kind === 'audio') {
console.log(
`Participant ${participantId}'s audio quality score is `,
score
);
}

if (score < 5) {
console.log(`Participant ${participantId}'s media quality is poor`);
}
}
);
```

## Events for specific participant

Expand Down
2 changes: 1 addition & 1 deletion docs/ui-kit/components/dyte-network-indicator.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ A component that indicates poor network connection.
It listens to the mediaScoreUpdate event of the passed participant to get the score.

```tsx
participant.addListener('mediaScoreUpdate', ({ kind, isScreenshare, score }) => {
participant.addListener('mediaScoreUpdate', ({ kind, isScreenshare, score, scoreStats }) => {
console.log(`Score for ${isScreenshare ? 'screen share': ''} ${kind} was:: ${score}`);
});
```
Expand Down
21 changes: 2 additions & 19 deletions docs/web-core/local-user/events.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -139,26 +139,9 @@ meeting.self.on('deviceUpdate', ({ device }) => {

## Network quality score

Subscribe to the `mediaScoreUpdate` event to monitor network
import SelfMediaScoreUpdate from '@site/docs/web-core/local-user/self-media-score-update.mdx'

```ts
meeting.self.on('mediaScoreUpdate', ({ kind, isScreenshare, score }) => {
if (kind === 'video') {
console.log(
`Your ${isScreenshare ? 'screenshare' : 'video'} quality score is `,
score
);
}

if (kind === 'audio') {
console.log('Your audio quality score is ', score);
}

if (score < 5) {
console.log('Your media quality is poor');
}
});
```
<SelfMediaScoreUpdate />

<head>
<title>Web Core Events</title>
Expand Down
61 changes: 61 additions & 0 deletions docs/web-core/local-user/self-media-score-update.mdx
swapnilmadavi marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
Subscribe to the `mediaScoreUpdate` event to monitor network

```ts
meeting.self.on('mediaScoreUpdate', ({ kind, isScreenshare, score, scoreStats }) => {
if (kind === 'video') {
console.log(
`Your ${isScreenshare ? 'screenshare' : 'video'} quality score is `,
score
);
}

if (kind === 'audio') {
console.log('Your audio quality score is ', score);
}

if (score < 5) {
console.log('Your media quality is poor');
}
});
```

The `scoreStats` object contains the statistics that contributed to the calculated media score.

The `mediaScoreUpdate` event will be emitted with an object similar to the following example as its first parameter, every few seconds, if media is being shared.

```
// Audio Producer
{
"kind": "audio",
"isScreenshare": false,
"score": 10,
"participantId": "c8aa91f6-0316-4025-8240-80d130e5acca", // meeting.self.id
"scoreStats": {
"score": 10,
"bitrate": 22452, // bytes per second
"packetsLostPercentage": 0,
"jitter": 0, // seconds
"isScreenShare": false
}
}

// Video Producer
{
"kind": "video",
"isScreenshare": false,
"score": 10,
"participantId": "c8aa91f6-0316-4025-8240-80d130e5acca", // meeting.self.id
"scoreStats": {
"score": 10,
"frameWidth": 640,
"frameHeight": 480,
"framesPerSecond": 24,
"jitter": 0, // seconds
"isScreenShare": false,
"packetsLostPercentage": 0,
"bitrate": 576195, // bytes per second
"cpuLimitations": false,
"bandwidthLimitations": false
}
}
```
29 changes: 2 additions & 27 deletions docs/web-core/participants/events.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -151,34 +151,9 @@ meeting.participants.joined.on('screenShareUpdate', (participant) => {

## Network quality score

Subscribe to the `mediaScoreUpdate` event to monitor network
import ParticipantMediaScoreUpdate from '@site/docs/web-core/participants/participant-media-score-update.mdx'

```ts
meeting.participants.joined.on(
'mediaScoreUpdate',
({ participantId, kind, isScreenshare, score }) => {
if (kind === 'video') {
console.log(
`Participant ${participantId}'s ${
isScreenshare ? 'screenshare' : 'video'
} quality score is `,
score
);
}

if (kind === 'audio') {
console.log(
`Participant ${participantId}'s audio quality score is `,
score
);
}

if (score < 5) {
console.log(`Participant ${participantId}'s media quality is poor`);
}
}
);
```
<ParticipantMediaScoreUpdate />

## Events for specific participant

Expand Down
67 changes: 67 additions & 0 deletions docs/web-core/participants/participant-media-score-update.mdx
swapnilmadavi marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
Subscribe to the `mediaScoreUpdate` event to monitor network

```ts
meeting.participants.joined.on(
'mediaScoreUpdate',
({ participantId, kind, isScreenshare, score, scoreStats }) => {
if (kind === 'video') {
console.log(
`Participant ${participantId}'s ${
isScreenshare ? 'screenshare' : 'video'
} quality score is `,
score
);
}

if (kind === 'audio') {
console.log(
`Participant ${participantId}'s audio quality score is `,
score
);
}

if (score < 5) {
console.log(`Participant ${participantId}'s media quality is poor`);
}
}
);
```

The `scoreStats` object contains the statistics that contributed to the calculated media score.

The `mediaScoreUpdate` event will be emitted with an object similar to the following example as its first parameter, every few seconds, if any participant's media is being shared.

```
// Audio Consumer
{
"kind": "audio",
"isScreenshare": false,
"score": 10,
"participantId": "f9b947d2-c9ca-4ea9-839b-c10304b0fffc",
"scoreStats": {
"score": 10,
"packetsLostPercentage": 0,
"jitter": 0.004, // seconds
"isScreenShare": false,
"bitrate": 1595 // bytes per second
}
}

// Video Consumer
{
"kind": "video",
"isScreenshare": false,
"score": 10,
"participantId": "f9b947d2-c9ca-4ea9-839b-c10304b0fffc",
"scoreStats": {
"score": 10,
"frameWidth": 640,
"frameHeight": 480,
"framesPerSecond": 24,
"packetsLostPercentage": 0,
"jitter": 0.002, // seconds
"isScreenShare": false,
"bitrate": 340460 // bytes per second
}
}
```
Loading