TelnyxCallReportCollector
public class TelnyxCallReportCollector
Collects WebRTC statistics during a call and posts them to voice-sdk-proxy at the end of the call for quality analysis and debugging.
Stats Collection Strategy (based on Twilio/Jitsi best practices):
- Collects stats at regular intervals (default 5 seconds)
- Stores cumulative values (packets, bytes) from WebRTC API
- Calculates averages for variable metrics (audio level, jitter, RTT)
- Uses in-memory buffer with size limits for long calls
- Posts aggregated stats to voice-sdk-proxy on call end
-
Undocumented
Declaration
Swift
public init(config: CallReportConfig = CallReportConfig(), logCollectorConfig: LogCollectorConfig = LogCollectorConfig())
-
Start collecting stats from the peer connection
Declaration
Swift
public func start(peerConnection: RTCPeerConnection)Parameters
peerConnectionThe RTCPeerConnection to monitor
-
Stop collecting stats and prepare for final report
Declaration
Swift
public func stop() -
Post the final collected stats to voice-sdk-proxy
Declaration
Swift
public func postReport(summary: CallReportSummary, callReportId: String, host: String, voiceSdkId: String? = nil)Parameters
summaryCall summary information
callReportIdCall report ID from REGED message
hostWebSocket host URL (will be converted to HTTP)
voiceSdkIdOptional voice SDK ID
-
Add a structured log entry to the call report.
Declaration
Swift
public func addLogEntry(level: String, message: String, context: [String : Any]? = nil)Parameters
levelLog level (e.g. “info”, “warn”, “error”)
messageHuman-readable event description
contextOptional dictionary with structured event data
-
Get the current stats buffer (for debugging)
Declaration
Swift
public func getStatsBuffer() -> [CallReportInterval]Return Value
Array of collected intervals
-
Get the collected logs (for debugging)
Declaration
Swift
public func getLogs() -> [LogEntry]Return Value
Array of log entries
-
Clean up resources (call after postReport)
Declaration
Swift
public func cleanup()