Skip to content

Commit

Permalink
fix: guard for null issues in stats + bump SDK version
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliver-Zimmerman committed Feb 9, 2025
1 parent 1e7e608 commit ccb96ed
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
35 changes: 24 additions & 11 deletions packages/telnyx_webrtc/lib/utils/stats/webrtc_stats_reporter.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'dart:async';
import 'dart:collection';
import 'dart:convert';
import 'dart:io';
import 'package:flutter_webrtc/flutter_webrtc.dart';
import 'package:logger/logger.dart';
import 'package:telnyx_webrtc/utils/stats/stats_parsing_helpers.dart';
Expand Down Expand Up @@ -131,20 +130,34 @@ class WebRTCStatsReporter {
);
}
..onSignalingState = (RTCSignalingState signalingState) async {
final localSdp = await peerConnection.getLocalDescription();
final remoteSdp = await peerConnection.getRemoteDescription();
RTCSessionDescription? localSdp;
RTCSessionDescription? remoteSdp;

try {
localSdp = await peerConnection.getLocalDescription();
remoteSdp = await peerConnection.getRemoteDescription();
} catch (e) {
_logger.e('Error retrieving descriptions for Signaling State Stats: $e');
}

// If both are null, just skip
if (localSdp == null && remoteSdp == null) {
return;
}

final description = {
'signalingState':
StatParsingHelpers().parseSignalingStateChange(signalingState),
'remoteDescription': {
'type': remoteSdp?.type,
'sdp': remoteSdp?.sdp,
},
'localDescription': {
'type': localSdp?.type,
'sdp': localSdp?.sdp,
},
if (remoteSdp != null)
'remoteDescription': {
'type': remoteSdp.type,
'sdp': remoteSdp.sdp,
},
if (localSdp != null)
'localDescription': {
'type': localSdp.type,
'sdp': localSdp.sdp,
},
};

_sendDebugReportData(
Expand Down
2 changes: 1 addition & 1 deletion packages/telnyx_webrtc/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ environment:
dependencies:
flutter:
sdk: flutter
flutter_webrtc: ^0.12.7
flutter_webrtc: ^0.12.8
logger: ^2.5.0
uuid: ^4.5.1
just_audio: ^0.9.43
Expand Down

0 comments on commit ccb96ed

Please sign in to comment.