@@ -5,19 +5,21 @@ Diagnostic tool for WebRTC JS applications that analyzes WebRTC getStats() resul
5
5
6
6
## Key features
7
7
8
- - ** Mean opinion score** - calculates [ MOS] ( https://en.wikipedia.org/wiki/Mean_opinion_score ) for inbound and outbound network connections that can indicate problems before it even appears.
8
+ - ** Mean opinion score** - calculates [ MOS] ( https://en.wikipedia.org/wiki/Mean_opinion_score ) for inbound and outbound network connections that can indicate a problem before it even appears.
9
9
- ** CPU issues** - indicates possible issues with encoding and decoding media streams.
10
10
- ** Server issues** - indicates possible server side issues.
11
11
- ** Fully customizable** - allows to create your own detectors or WebRTC getStats() parsers.
12
12
13
13
14
14
## Installation
15
+
15
16
` yarn add webrtc-issue-detector `
16
17
17
18
18
19
## Usage
19
20
20
21
### Getting started
22
+
21
23
``` typescript
22
24
import WebRTCIssueDetector from ' webrtc-issue-detector' ;
23
25
@@ -26,7 +28,7 @@ const webRtcIssueDetector = new WebRTCIssueDetector({
26
28
onIssues : (issues ) => issues .map ((issue ) => {
27
29
console .log (' Issues type:' , issue .type ); // eg. "network"
28
30
console .log (' Issues reason:' , issue .reason ); // eg. "outbound-network-throughput"
29
- console .log (' Issues reason:' , issue .debug ); // eg. "packetLoss : 12%, jitter : 230, rtt: 150"
31
+ console .log (' Issues reason:' , issue .statsSample ); // eg. "packetLossPct : 12%, avgJitter : 230, rtt: 150"
30
32
}),
31
33
onNetworkScoresUpdated : (scores ) => {
32
34
console .log (' Inbound network score' , scores .inbound ); // eg. 3.7
@@ -36,6 +38,9 @@ const webRtcIssueDetector = new WebRTCIssueDetector({
36
38
37
39
// start collecting getStats() and detecting issues
38
40
webRtcIssueDetector .watchNewPeerConnections ();
41
+
42
+ // stop collecting WebRTC stats and issues detection
43
+ webRtcIssueDetector .stopWatchingNewPeerConnections ();
39
44
```
40
45
41
46
### Configure
@@ -51,7 +56,7 @@ import WebRTCIssueDetector, {
51
56
OutboundNetworkIssueDetector ,
52
57
NetworkMediaSyncIssueDetector ,
53
58
AvailableOutgoingBitrateIssueDetector ,
54
- VideoCodecMismatchDetector ,
59
+ UnknownVideoDecoderImplementationDetector ,
55
60
} from ' webrtc-issue-detector' ;
56
61
57
62
const widWithDefaultConstructorArgs = new WebRTCIssueDetector ();
@@ -67,7 +72,7 @@ const widWithCustomConstructorArgs = new WebRTCIssueDetector({
67
72
new OutboundNetworkIssueDetector (),
68
73
new NetworkMediaSyncIssueDetector (),
69
74
new AvailableOutgoingBitrateIssueDetector (),
70
- new VideoCodecMismatchDetector (),
75
+ new UnknownVideoDecoderImplementationDetector (),
71
76
],
72
77
getStatsInterval: 10_000 , // set custom stats parsing interval
73
78
onIssues : (payload : IssueDetectorResult ) => {
@@ -87,105 +92,143 @@ const widWithCustomConstructorArgs = new WebRTCIssueDetector({
87
92
### AvailableOutgoingBitrateIssueDetector
88
93
Detects issues with outgoing network connection.
89
94
``` js
90
- const issue = {
95
+ const exampleIssue = {
91
96
type: ' network' ,
92
97
reason: ' outbound-network-throughput' ,
93
- debug: ' ...' ,
98
+ statsSample: {
99
+ availableOutgoingBitrate: 1234 ,
100
+ videoStreamsTotalBitrate: 1234 ,
101
+ audioStreamsTotalTargetBitrate: 1234 ,
102
+ },
94
103
}
95
104
```
96
105
97
106
### FramesDroppedIssueDetector
98
107
Detects issues with decoder.
99
108
``` js
100
- const issue = {
109
+ const exampleIssue = {
101
110
type: ' cpu' ,
102
111
reason: ' decoder-cpu-throttling' ,
103
- debug: ' ...' ,
112
+ statsSample: {
113
+ deltaFramesDropped: 100 ,
114
+ deltaFramesReceived: 1000 ,
115
+ deltaFramesDecoded: 900 ,
116
+ framesDroppedPct: 10 ,
117
+ },
118
+ ssrc: 1234 ,
104
119
}
105
120
```
106
121
107
122
### FramesEncodedSentIssueDetector
108
123
Detects issues with outbound network throughput.
109
124
``` js
110
- const issue = {
125
+ const exampleIssue = {
111
126
type: ' network' ,
112
127
reason: ' outbound-network-throughput' ,
113
- debug: ' ...' ,
128
+ statsSample: {
129
+ deltaFramesSent: 900 ,
130
+ deltaFramesEncoded: 1000 ,
131
+ missedFramesPct: 10 ,
132
+ },
133
+ ssrc: 1234 ,
114
134
}
115
135
```
116
136
117
137
### InboundNetworkIssueDetector
118
138
Detects issues with inbound network connection.
119
139
``` js
120
- const issue = {
140
+ const exampleIssue = {
121
141
type: ' network' ,
122
142
reason: ' inbound-network-quality' | ' inbound-network-media-latency' | ' network-media-sync-failure' ,
123
143
iceCandidate: ' ice-candidate-id' ,
124
- debug: ' ...' ,
144
+ statsSample: {
145
+ rtt: 1234 ,
146
+ packetLossPct: 1234 ,
147
+ avgJitter: 1234 ,
148
+ avgJitterBufferDelay: 1234 ,
149
+ },
125
150
}
126
151
```
127
152
128
153
Also can detect server side issues if there is high RTT and jitter is ok.
129
154
``` js
130
- const issue = {
155
+ const exampleIssue = {
131
156
type: ' server' ,
132
157
reason: ' server-issue' ,
133
158
iceCandidate: ' ice-candidate-id' ,
134
- debug: ' ...' ,
159
+ statsSample: {
160
+ rtt: 1234 ,
161
+ packetLossPct: 1234 ,
162
+ avgJitter: 1234 ,
163
+ avgJitterBufferDelay: 1234 ,
164
+ },
135
165
}
136
166
```
137
167
138
168
### NetworkMediaSyncIssueDetector
139
169
Detects issues with audio synchronization.
140
170
``` js
141
- const issue = {
171
+ const exampleIssue = {
142
172
type: ' network' ,
143
173
reason: ' network-media-sync-failure' ,
144
- ssrc: ' ...' ,
145
- debug: ' ...' ,
174
+ ssrc: 1234 ,
175
+ statsSample: {
176
+ correctedSamplesPct: 15 ,
177
+ },
146
178
}
147
179
```
148
180
149
181
### OutboundNetworkIssueDetector
150
182
Detects issues with outbound network connection.
151
183
``` js
152
- const issue = {
184
+ const exampleIssue = {
153
185
type: ' network' ,
154
186
reason: ' outbound-network-quality' | ' outbound-network-media-latency' ,
155
187
iceCandidate: ' ice-candidate-id' ,
156
- debug: ' ...' ,
188
+ statsSample: {
189
+ rtt: 1234 ,
190
+ avgJitter: 1234 ,
191
+ packetLossPct: 1234 ,
192
+ },
157
193
}
158
194
```
159
195
160
196
### QualityLimitationsIssueDetector
161
197
Detects issues with encoder and outbound network. Based on native qualityLimitationReason.
162
198
``` js
163
- const issue = {
199
+ const exampleIssue = {
164
200
type: ' cpu' ,
165
201
reason: ' encoder-cpu-throttling' ,
166
- ssrc: ' ...' ,
167
- debug: ' ...' ,
202
+ ssrc: 1234 ,
203
+ statsSample: {
204
+ qualityLimitationReason: ' cpu' ,
205
+ },
168
206
}
169
207
```
170
208
171
209
``` js
172
- const issue = {
210
+ const exampleIssue = {
173
211
type: ' network' ,
174
212
reason: ' outbound-network-throughput' ,
175
- ssrc: ' ...' ,
176
- debug: ' ...' ,
213
+ ssrc: 1234 ,
214
+ statsSample: {
215
+ qualityLimitationReason: ' bandwidth' ,
216
+ },
177
217
}
178
218
```
179
219
180
220
### VideoCodecMismatchDetector
181
221
Detects issues with decoding stream.
182
222
``` js
183
- const issue = {
223
+ const exampleIssue = {
184
224
type: ' stream' ,
185
- reason: ' codec-mismatch' ,
186
- ssrc: ' ...' ,
187
- trackIdentifier: ' ...' ,
188
- debug: ' ...' ,
225
+ reason: ' unknown-video-decoder' ,
226
+ ssrc: 1234 ,
227
+ trackIdentifier: ' some-track-id' ,
228
+ statsSample: {
229
+ mimeType: ' video/vp9' ,
230
+ decoderImplementation: ' unknown'
231
+ },
189
232
}
190
233
```
191
234
0 commit comments