Skip to content

Commit d85eb3a

Browse files
committed
fix: refactor detector
1 parent eca85ec commit d85eb3a

File tree

6 files changed

+14
-96
lines changed

6 files changed

+14
-96
lines changed

README.md

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ By default, WebRTCIssueDetector can be created with minimum of mandatory constru
5151
```typescript
5252
import WebRTCIssueDetector, {
5353
QualityLimitationsIssueDetector,
54-
FramesDroppedIssueDetector,
5554
FramesEncodedSentIssueDetector,
5655
InboundNetworkIssueDetector,
5756
OutboundNetworkIssueDetector,
5857
NetworkMediaSyncIssueDetector,
5958
AvailableOutgoingBitrateIssueDetector,
6059
UnknownVideoDecoderImplementationDetector,
6160
FrozenVideoTrackDetector,
61+
VideoDecoderIssueDetector,
6262
} from 'webrtc-issue-detector';
6363

6464
const widWithDefaultConstructorArgs = new WebRTCIssueDetector();
@@ -68,14 +68,14 @@ const widWithDefaultConstructorArgs = new WebRTCIssueDetector();
6868
const widWithCustomConstructorArgs = new WebRTCIssueDetector({
6969
detectors: [ // you are free to change the detectors list according to your needs
7070
new QualityLimitationsIssueDetector(),
71-
new FramesDroppedIssueDetector(),
7271
new FramesEncodedSentIssueDetector(),
7372
new InboundNetworkIssueDetector(),
7473
new OutboundNetworkIssueDetector(),
7574
new NetworkMediaSyncIssueDetector(),
7675
new AvailableOutgoingBitrateIssueDetector(),
7776
new UnknownVideoDecoderImplementationDetector(),
7877
new FrozenVideoTrackDetector(),
78+
new VideoDecoderIssueDetector(),
7979
],
8080
getStatsInterval: 10_000, // set custom stats parsing interval
8181
onIssues: (payload: IssueDetectorResult) => {
@@ -106,19 +106,12 @@ const exampleIssue = {
106106
}
107107
```
108108

109-
### FramesDroppedIssueDetector
109+
### VideoDecoderIssueDetector
110110
Detects issues with decoder.
111111
```js
112112
const exampleIssue = {
113113
type: 'cpu',
114114
reason: 'decoder-cpu-throttling',
115-
statsSample: {
116-
deltaFramesDropped: 100,
117-
deltaFramesReceived: 1000,
118-
deltaFramesDecoded: 900,
119-
framesDroppedPct: 10,
120-
},
121-
ssrc: 1234,
122115
}
123116
```
124117

src/WebRTCIssueDetector.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import PeriodicWebRTCStatsReporter from './parser/PeriodicWebRTCStatsReporter';
1616
import DefaultNetworkScoresCalculator from './NetworkScoresCalculator';
1717
import {
1818
AvailableOutgoingBitrateIssueDetector,
19-
FramesDroppedIssueDetector,
2019
FramesEncodedSentIssueDetector,
2120
InboundNetworkIssueDetector,
2221
NetworkMediaSyncIssueDetector,
@@ -60,7 +59,6 @@ class WebRTCIssueDetector {
6059

6160
this.detectors = params.detectors ?? [
6261
new QualityLimitationsIssueDetector(),
63-
new FramesDroppedIssueDetector(),
6462
new FramesEncodedSentIssueDetector(),
6563
new InboundNetworkIssueDetector(),
6664
new OutboundNetworkIssueDetector(),

src/detectors/FramesDroppedIssueDetector.ts

Lines changed: 0 additions & 80 deletions
This file was deleted.

src/detectors/FrozenVideoTrackDetector.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class FrozenVideoTrackDetector extends BaseIssueDetector {
6969
return;
7070
}
7171

72-
// We skip it when ratio is too low because it should be handled by FramesDroppedIssueDetector
72+
// We skip it when ratio is too low because it should be handled by VideoDecoderIssueDetector
7373
if (ratioFramesDropped >= this.#framesDroppedThreshold) {
7474
return;
7575
}

src/detectors/VideoDecoderIssueDetector.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,24 @@ class VideoDecoderIssueDetector extends BaseIssueDetector {
9595
volatility,
9696
});
9797

98-
return volatility > this.#volatilityThreshold && isDecodeTimePerFrameIncrease;
98+
if (volatility > this.#volatilityThreshold && isDecodeTimePerFrameIncrease) {
99+
return { ssrc: incomeVideoStream.ssrc, allDecodeTimePerFrame, volatility, };
100+
} else {
101+
return undefined;
102+
}
99103
})
100-
.filter((throttled) => throttled);
104+
.filter((throttledVideoStream) => Boolean(throttledVideoStream));
101105

102106

103107
const affectedStreamsPercent = throtthedStreams.length / (data.video.inbound.length / 100);
104108
if (affectedStreamsPercent > this.#affectedStreamsPercentThreshold) {
105109
issues.push({
106110
type: IssueType.CPU,
107111
reason: IssueReason.DecoderCPUThrottling,
112+
statsSample: {
113+
affectedStreamsPercent,
114+
throtthedStreams: throtthedStreams,
115+
}
108116
});
109117
}
110118

src/detectors/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
export { default as BaseIssueDetector } from './BaseIssueDetector';
22
export { default as AvailableOutgoingBitrateIssueDetector } from './AvailableOutgoingBitrateIssueDetector';
3-
export { default as FramesDroppedIssueDetector } from './FramesDroppedIssueDetector';
43
export { default as FramesEncodedSentIssueDetector } from './FramesEncodedSentIssueDetector';
54
export { default as InboundNetworkIssueDetector } from './InboundNetworkIssueDetector';
65
export { default as NetworkMediaSyncIssueDetector } from './NetworkMediaSyncIssueDetector';

0 commit comments

Comments
 (0)