Skip to content

Commit 2e7259e

Browse files
authored
fix: remove required wid constructor params, fix readme (#2)
1 parent f0c75ba commit 2e7259e

File tree

2 files changed

+51
-50
lines changed

2 files changed

+51
-50
lines changed

README.md

Lines changed: 45 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ webRtcIssueDetector.watchNewPeerConnections();
3939
```
4040

4141
### Configure
42+
43+
By default, WebRTCIssueDetector can be created with minimum of mandatory constructor parameters. But it's possible to override most of them.
44+
4245
```typescript
4346
import WebRTCIssueDetector, {
4447
QualityLimitationsIssueDetector,
@@ -49,17 +52,14 @@ import WebRTCIssueDetector, {
4952
NetworkMediaSyncIssueDetector,
5053
AvailableOutgoingBitrateIssueDetector,
5154
VideoCodecMismatchDetector,
52-
CompositeRTCStatsParser,
53-
WebRTCIssueEmitter,
54-
NetworkScoresCalculator,
55-
PeriodicWebRTCStatsReporter,
56-
RTCStatsParser,
5755
} from 'webrtc-issue-detector';
5856

59-
new WebRTCIssueDetector({
60-
issueEmitter: new WebRTCIssueEmitter(),
61-
networkScoresCalculator: new NetworkScoresCalculator(),
62-
detectors: [
57+
const widWithDefaultConstructorArgs = new WebRTCIssueDetector();
58+
59+
// or you can fully customize WebRTCIssueDetector with constructor arguments
60+
61+
const widWithCustomConstructorArgs = new WebRTCIssueDetector({
62+
detectors: [ // you are free to change the detectors list according to your needs
6363
new QualityLimitationsIssueDetector(),
6464
new FramesDroppedIssueDetector(),
6565
new FramesEncodedSentIssueDetector(),
@@ -69,15 +69,16 @@ new WebRTCIssueDetector({
6969
new AvailableOutgoingBitrateIssueDetector(),
7070
new VideoCodecMismatchDetector(),
7171
],
72-
statsReporter: new PeriodicWebRTCStatsReporter({
73-
compositeStatsParser,
74-
getStatsInterval: 5000,
75-
}),
76-
onIssues: params.onIssues,
77-
onNetworkScoresUpdated: params.onNetworkScoresUpdated,
78-
ignoreSSRCList: params.ignoreSSRCList,
79-
compositeStatsParser,
80-
logger,
72+
getStatsInterval: 10_000, // set custom stats parsing interval
73+
onIssues: (payload: IssueDetectorResult) => {
74+
// your custom callback for detected issues handling
75+
},
76+
onNetworkScoresUpdated: (payload: NetworkScores) => {
77+
// your custom callback for networks score updates handling
78+
},
79+
ignoreSSRCList: [
80+
// in case you need to skip some ssrc from parsing, add its numbers to the array
81+
],
8182
});
8283
```
8384

@@ -86,105 +87,105 @@ new WebRTCIssueDetector({
8687
### AvailableOutgoingBitrateIssueDetector
8788
Detects issues with outgoing network connection.
8889
```js
89-
{
90+
const issue = {
9091
type: 'network',
9192
reason: 'outbound-network-throughput',
92-
debug: '...'
93+
debug: '...',
9394
}
9495
```
9596

9697
### FramesDroppedIssueDetector
9798
Detects issues with decoder.
9899
```js
99-
{
100+
const issue = {
100101
type: 'cpu',
101102
reason: 'decoder-cpu-throttling',
102-
debug: '...'
103+
debug: '...',
103104
}
104105
```
105106

106107
### FramesEncodedSentIssueDetector
107108
Detects issues with outbound network throughput.
108109
```js
109-
{
110+
const issue = {
110111
type: 'network',
111112
reason: 'outbound-network-throughput',
112-
debug: '...'
113+
debug: '...',
113114
}
114115
```
115116

116117
### InboundNetworkIssueDetector
117118
Detects issues with inbound network connection.
118119
```js
119-
{
120+
const issue = {
120121
type: 'network',
121122
reason: 'inbound-network-quality' | 'inbound-network-media-latency' | 'network-media-sync-failure',
122-
iceCandidate: 'ice-candidate-id'
123-
debug: '...'
123+
iceCandidate: 'ice-candidate-id',
124+
debug: '...',
124125
}
125126
```
126127

127128
Also can detect server side issues if there is high RTT and jitter is ok.
128129
```js
129-
{
130+
const issue = {
130131
type: 'server',
131132
reason: 'server-issue',
132-
iceCandidate: 'ice-candidate-id'
133-
debug: '...'
133+
iceCandidate: 'ice-candidate-id',
134+
debug: '...',
134135
}
135136
```
136137

137138
### NetworkMediaSyncIssueDetector
138139
Detects issues with audio syncronization.
139140
```js
140-
{
141+
const issue = {
141142
type: 'network',
142143
reason: 'network-media-sync-failure',
143-
ssrc: '...'
144-
debug: '...'
144+
ssrc: '...',
145+
debug: '...',
145146
}
146147
```
147148

148149
### OutboundNetworkIssueDetector
149150
Detects issues with outbound network connection.
150151
```js
151-
{
152+
const issue = {
152153
type: 'network',
153154
reason: 'outbound-network-quality' | 'outbound-network-media-latency',
154-
iceCandidate: 'ice-candidate-id'
155-
debug: '...'
155+
iceCandidate: 'ice-candidate-id',
156+
debug: '...',
156157
}
157158
```
158159

159160
### QualityLimitationsIssueDetector
160161
Detects issues with encoder and outbound network. Based on native qualitiLimitationReason.
161162
```js
162-
{
163+
const issue = {
163164
type: 'cpu',
164165
reason: 'encoder-cpu-throttling',
165-
ssrc: '...'
166-
debug: '...'
166+
ssrc: '...',
167+
debug: '...',
167168
}
168169
```
169170

170171
```js
171-
{
172+
const issue = {
172173
type: 'network',
173174
reason: 'outbound-network-throughput',
174-
ssrc: '...'
175-
debug: '...'
175+
ssrc: '...',
176+
debug: '...',
176177
}
177178
```
178179

179180
### VideoCodecMismatchDetector
180181
Detects issues with decoding stream.
181182
```js
182-
{
183+
const issue = {
183184
type: 'stream',
184185
reason: 'codec-mismatch',
185186
ssrc: '...',
186187
trackIdentifier: '...',
187-
debug: '...'
188+
debug: '...',
188189
}
189190
```
190191

src/types.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ export interface StatsParser {
4646
}
4747

4848
export type WebRTCIssueDetectorConstructorParams = {
49-
issueEmitter: WebRTCIssueEmitter;
50-
networkScoresCalculator: INetworkScoresCalculator,
51-
detectors: IssueDetector[],
52-
compositeStatsParser: CompositeStatsParser,
53-
statsReporter: PeriodicWebRTCStatsReporter,
54-
logger: Logger,
49+
issueEmitter?: WebRTCIssueEmitter;
50+
networkScoresCalculator?: INetworkScoresCalculator,
51+
detectors?: IssueDetector[],
52+
compositeStatsParser?: CompositeStatsParser,
53+
statsReporter?: PeriodicWebRTCStatsReporter,
54+
logger?: Logger,
5555
onIssues?: (payload: IssueDetectorResult) => void,
5656
onNetworkScoresUpdated?: (payload: NetworkScores) => void,
5757
ignoreSSRCList?: number[],

0 commit comments

Comments
 (0)