@@ -46,6 +46,13 @@ class PacketLossTracker {
4646
4747 protected ArrayList<Integer > sampleIndexArray = new ArrayList<Integer > ();
4848
49+ // use these vars for notification at the bottom
50+ private boolean notificationShown = false ;
51+ protected String lostPackagesMsg = " Lost packets detected, open packet loss widget for more info" ;
52+ protected String noLostPackagesMsg = " Data streaming is running as usual" ;
53+ protected int windowSizeNotificationMs = 5000 ;
54+ protected double thresholdNotification = 1.0 ;
55+
4956 PacketLossTracker (int _sampleIndexChannel , int _timestampChannel , int _minSampleIndex , int _maxSampleIndex ) {
5057 this (_sampleIndexChannel, _timestampChannel, _minSampleIndex, _maxSampleIndex, new RealTimeProvider ());
5158 }
@@ -153,6 +160,7 @@ class PacketLossTracker {
153160 }
154161
155162 packetRecords. push(currentRecord);
163+ checkCurrentStreamStatus();
156164 }
157165
158166 private void incrementLastSampleIndexLocation () {
@@ -165,6 +173,22 @@ class PacketLossTracker {
165173 protected void reset () {
166174 lastSample = null ;
167175 }
176+
177+ protected void checkCurrentStreamStatus () {
178+ PacketRecord lastMillisPacketRecord = getCumulativePacketRecordForLast(windowSizeNotificationMs);
179+ if (lastMillisPacketRecord. getLostPercent() > thresholdNotification) {
180+ if (! notificationShown) {
181+ notificationShown = true ;
182+ outputWarn(lostPackagesMsg);
183+ }
184+ }
185+ else {
186+ if (notificationShown) {
187+ notificationShown = false ;
188+ outputInfo(noLostPackagesMsg);
189+ }
190+ }
191+ }
168192}
169193
170194// sample index range 1-255, odd numbers only (skips evens)
0 commit comments