@@ -13,6 +13,18 @@ import {
1313 Logger ,
1414} from './types' ;
1515import PeriodicWebRTCStatsReporter from './parser/PeriodicWebRTCStatsReporter' ;
16+ import DefaultNetworkScoresCalculator from './NetworkScoresCalculator' ;
17+ import {
18+ AvailableOutgoingBitrateIssueDetector ,
19+ FramesDroppedIssueDetector ,
20+ FramesEncodedSentIssueDetector ,
21+ InboundNetworkIssueDetector ,
22+ NetworkMediaSyncIssueDetector ,
23+ OutboundNetworkIssueDetector ,
24+ QualityLimitationsIssueDetector , VideoCodecMismatchDetector ,
25+ } from './detectors' ;
26+ import { CompositeRTCStatsParser , RTCStatsParser } from './parser' ;
27+ import createLogger from './utils/logger' ;
1628
1729class WebRTCIssueDetector {
1830 readonly eventEmitter : WebRTCIssueEmitter ;
@@ -30,7 +42,8 @@ class WebRTCIssueDetector {
3042 private readonly logger : Logger ;
3143
3244 constructor ( params : WebRTCIssueDetectorConstructorParams ) {
33- this . eventEmitter = params . issueEmitter ;
45+ this . logger = params . logger ?? createLogger ( ) ;
46+ this . eventEmitter = params . issueEmitter ?? new WebRTCIssueEmitter ( ) ;
3447
3548 if ( params . onIssues ) {
3649 this . eventEmitter . on ( EventType . Issue , params . onIssues ) ;
@@ -40,11 +53,25 @@ class WebRTCIssueDetector {
4053 this . eventEmitter . on ( EventType . NetworkScoresUpdated , params . onNetworkScoresUpdated ) ;
4154 }
4255
43- this . networkScoresCalculator = params . networkScoresCalculator ;
44- this . detectors = params . detectors ;
45- this . compositeStatsParser = params . compositeStatsParser ;
46- this . statsReporter = params . statsReporter ;
47- this . logger = params . logger ;
56+ this . detectors = params . detectors ?? [
57+ new QualityLimitationsIssueDetector ( ) ,
58+ new FramesDroppedIssueDetector ( ) ,
59+ new FramesEncodedSentIssueDetector ( ) ,
60+ new InboundNetworkIssueDetector ( ) ,
61+ new OutboundNetworkIssueDetector ( ) ,
62+ new NetworkMediaSyncIssueDetector ( ) ,
63+ new AvailableOutgoingBitrateIssueDetector ( ) ,
64+ new VideoCodecMismatchDetector ( ) ,
65+ ] ;
66+
67+ this . networkScoresCalculator = params . networkScoresCalculator ?? new DefaultNetworkScoresCalculator ( ) ;
68+ this . compositeStatsParser = params . compositeStatsParser ?? new CompositeRTCStatsParser ( {
69+ statsParser : new RTCStatsParser ( { logger : this . logger } ) ,
70+ } ) ;
71+ this . statsReporter = params . statsReporter ?? new PeriodicWebRTCStatsReporter ( {
72+ compositeStatsParser : this . compositeStatsParser ,
73+ getStatsInterval : params . getStatsInterval ?? 5000 ,
74+ } ) ;
4875
4976 ( window as unknown as WIDWindow ) . wid = this ;
5077 this . wrapRTCPeerConnection ( ) ;
0 commit comments