@@ -5,19 +5,21 @@ Diagnostic tool for WebRTC JS applications that analyzes WebRTC getStats() resul
55
66## Key features
77
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.
99- ** CPU issues** - indicates possible issues with encoding and decoding media streams.
1010- ** Server issues** - indicates possible server side issues.
1111- ** Fully customizable** - allows to create your own detectors or WebRTC getStats() parsers.
1212
1313
1414## Installation
15+
1516` yarn add webrtc-issue-detector `
1617
1718
1819## Usage
1920
2021### Getting started
22+
2123``` typescript
2224import WebRTCIssueDetector from ' webrtc-issue-detector' ;
2325
@@ -26,7 +28,7 @@ const webRtcIssueDetector = new WebRTCIssueDetector({
2628 onIssues : (issues ) => issues .map ((issue ) => {
2729 console .log (' Issues type:' , issue .type ); // eg. "network"
2830 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"
3032 }),
3133 onNetworkScoresUpdated : (scores ) => {
3234 console .log (' Inbound network score' , scores .inbound ); // eg. 3.7
@@ -36,6 +38,9 @@ const webRtcIssueDetector = new WebRTCIssueDetector({
3638
3739// start collecting getStats() and detecting issues
3840webRtcIssueDetector .watchNewPeerConnections ();
41+
42+ // stop collecting WebRTC stats and issues detection
43+ webRtcIssueDetector .stopWatchingNewPeerConnections ();
3944```
4045
4146### Configure
@@ -51,7 +56,7 @@ import WebRTCIssueDetector, {
5156 OutboundNetworkIssueDetector ,
5257 NetworkMediaSyncIssueDetector ,
5358 AvailableOutgoingBitrateIssueDetector ,
54- VideoCodecMismatchDetector ,
59+ UnknownVideoDecoderImplementationDetector ,
5560} from ' webrtc-issue-detector' ;
5661
5762const widWithDefaultConstructorArgs = new WebRTCIssueDetector ();
@@ -67,7 +72,7 @@ const widWithCustomConstructorArgs = new WebRTCIssueDetector({
6772 new OutboundNetworkIssueDetector (),
6873 new NetworkMediaSyncIssueDetector (),
6974 new AvailableOutgoingBitrateIssueDetector (),
70- new VideoCodecMismatchDetector (),
75+ new UnknownVideoDecoderImplementationDetector (),
7176 ],
7277 getStatsInterval: 10_000 , // set custom stats parsing interval
7378 onIssues : (payload : IssueDetectorResult ) => {
@@ -87,105 +92,143 @@ const widWithCustomConstructorArgs = new WebRTCIssueDetector({
8792### AvailableOutgoingBitrateIssueDetector
8893Detects issues with outgoing network connection.
8994``` js
90- const issue = {
95+ const exampleIssue = {
9196 type: ' network' ,
9297 reason: ' outbound-network-throughput' ,
93- debug: ' ...' ,
98+ statsSample: {
99+ availableOutgoingBitrate: 1234 ,
100+ videoStreamsTotalBitrate: 1234 ,
101+ audioStreamsTotalTargetBitrate: 1234 ,
102+ },
94103}
95104```
96105
97106### FramesDroppedIssueDetector
98107Detects issues with decoder.
99108``` js
100- const issue = {
109+ const exampleIssue = {
101110 type: ' cpu' ,
102111 reason: ' decoder-cpu-throttling' ,
103- debug: ' ...' ,
112+ statsSample: {
113+ deltaFramesDropped: 100 ,
114+ deltaFramesReceived: 1000 ,
115+ deltaFramesDecoded: 900 ,
116+ framesDroppedPct: 10 ,
117+ },
118+ ssrc: 1234 ,
104119}
105120```
106121
107122### FramesEncodedSentIssueDetector
108123Detects issues with outbound network throughput.
109124``` js
110- const issue = {
125+ const exampleIssue = {
111126 type: ' network' ,
112127 reason: ' outbound-network-throughput' ,
113- debug: ' ...' ,
128+ statsSample: {
129+ deltaFramesSent: 900 ,
130+ deltaFramesEncoded: 1000 ,
131+ missedFramesPct: 10 ,
132+ },
133+ ssrc: 1234 ,
114134}
115135```
116136
117137### InboundNetworkIssueDetector
118138Detects issues with inbound network connection.
119139``` js
120- const issue = {
140+ const exampleIssue = {
121141 type: ' network' ,
122142 reason: ' inbound-network-quality' | ' inbound-network-media-latency' | ' network-media-sync-failure' ,
123143 iceCandidate: ' ice-candidate-id' ,
124- debug: ' ...' ,
144+ statsSample: {
145+ rtt: 1234 ,
146+ packetLossPct: 1234 ,
147+ avgJitter: 1234 ,
148+ avgJitterBufferDelay: 1234 ,
149+ },
125150}
126151```
127152
128153Also can detect server side issues if there is high RTT and jitter is ok.
129154``` js
130- const issue = {
155+ const exampleIssue = {
131156 type: ' server' ,
132157 reason: ' server-issue' ,
133158 iceCandidate: ' ice-candidate-id' ,
134- debug: ' ...' ,
159+ statsSample: {
160+ rtt: 1234 ,
161+ packetLossPct: 1234 ,
162+ avgJitter: 1234 ,
163+ avgJitterBufferDelay: 1234 ,
164+ },
135165}
136166```
137167
138168### NetworkMediaSyncIssueDetector
139169Detects issues with audio synchronization.
140170``` js
141- const issue = {
171+ const exampleIssue = {
142172 type: ' network' ,
143173 reason: ' network-media-sync-failure' ,
144- ssrc: ' ...' ,
145- debug: ' ...' ,
174+ ssrc: 1234 ,
175+ statsSample: {
176+ correctedSamplesPct: 15 ,
177+ },
146178}
147179```
148180
149181### OutboundNetworkIssueDetector
150182Detects issues with outbound network connection.
151183``` js
152- const issue = {
184+ const exampleIssue = {
153185 type: ' network' ,
154186 reason: ' outbound-network-quality' | ' outbound-network-media-latency' ,
155187 iceCandidate: ' ice-candidate-id' ,
156- debug: ' ...' ,
188+ statsSample: {
189+ rtt: 1234 ,
190+ avgJitter: 1234 ,
191+ packetLossPct: 1234 ,
192+ },
157193}
158194```
159195
160196### QualityLimitationsIssueDetector
161197Detects issues with encoder and outbound network. Based on native qualityLimitationReason.
162198``` js
163- const issue = {
199+ const exampleIssue = {
164200 type: ' cpu' ,
165201 reason: ' encoder-cpu-throttling' ,
166- ssrc: ' ...' ,
167- debug: ' ...' ,
202+ ssrc: 1234 ,
203+ statsSample: {
204+ qualityLimitationReason: ' cpu' ,
205+ },
168206}
169207```
170208
171209``` js
172- const issue = {
210+ const exampleIssue = {
173211 type: ' network' ,
174212 reason: ' outbound-network-throughput' ,
175- ssrc: ' ...' ,
176- debug: ' ...' ,
213+ ssrc: 1234 ,
214+ statsSample: {
215+ qualityLimitationReason: ' bandwidth' ,
216+ },
177217}
178218```
179219
180220### VideoCodecMismatchDetector
181221Detects issues with decoding stream.
182222``` js
183- const issue = {
223+ const exampleIssue = {
184224 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+ },
189232}
190233```
191234
0 commit comments