@telnyx/webrtc 2.27.0-beta.3 → 2.27.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -22,6 +22,7 @@ export default abstract class BaseSession {
22
22
  invalidMethodErrorCode: number;
23
23
  authenticationRequiredErrorCode: number;
24
24
  callReportId: string | null;
25
+ callReportVoiceSdkId: string | null;
25
26
  dc: string | null;
26
27
  region: string | null;
27
28
  connection: Connection;
@@ -33,6 +34,8 @@ export default abstract class BaseSession {
33
34
  protected _reconnectAttempts: number;
34
35
  private _tokenExpiryTimeout;
35
36
  private static readonly TOKEN_EXPIRY_WARNING_SECONDS;
37
+ private static readonly CALL_REPORT_UPLOAD_DRAIN_TIMEOUT_MS;
38
+ private _pendingCallReportUploads;
36
39
  private _executeQueue;
37
40
  private _pong;
38
41
  private registerAgent;
@@ -43,6 +46,8 @@ export default abstract class BaseSession {
43
46
  get reconnectDelay(): number;
44
47
  execute(msg: BaseMessage): Promise<any>;
45
48
  executeRaw(text: string): void;
49
+ trackCallReportUpload(upload: Promise<void>): void;
50
+ private _drainCallReportUploads;
46
51
  validateOptions(): boolean;
47
52
  broadcast(_params: BroadcastParams): void;
48
53
  disconnect(): Promise<void>;
@@ -68,7 +73,16 @@ export default abstract class BaseSession {
68
73
  }): Promise<void>;
69
74
  private _login;
70
75
  protected _onSocketOpen(): Promise<void>;
71
- onNetworkClose(): void;
76
+ private _flushIntermediateCallReports;
77
+ private _getSocketCloseCodeName;
78
+ private _getSocketCloseError;
79
+ private _createSocketCloseFlushReason;
80
+ onNetworkClose(event?: {
81
+ code?: number;
82
+ reason?: string;
83
+ wasClean?: boolean;
84
+ error?: unknown;
85
+ }): void;
72
86
  protected _onSocketMessage(_response: any): void;
73
87
  protected _removeSubscription(protocol: string, channel?: string): void;
74
88
  protected _addSubscription(protocol: string, handler: Function, channel: string): void;
@@ -36,6 +36,7 @@ export interface IVertoOptions {
36
36
  maxReconnectAttempts?: number;
37
37
  enableCallReports?: boolean;
38
38
  callReportInterval?: number;
39
+ callReportFlushInterval?: number;
39
40
  debugLogLevel?: 'debug' | 'info' | 'warn' | 'error';
40
41
  debugLogMaxEntries?: number;
41
42
  skipLastVoiceSdkId?: boolean;
@@ -1,4 +1,5 @@
1
1
  import BrowserSession from '../BrowserSession';
2
+ import { type ICallReportFlushReason } from './CallReportCollector';
2
3
  import Call from './Call';
3
4
  import Peer from './Peer';
4
5
  import { Direction, State } from './constants';
@@ -56,6 +57,7 @@ export default abstract class BaseCall implements IWebRTCCall {
56
57
  get remoteStream(): MediaStream;
57
58
  get memberChannel(): string;
58
59
  get isAudioMuted(): boolean;
60
+ shouldForceRelayCandidateForRecovery(): boolean;
59
61
  invite(): Promise<void>;
60
62
  answer(params?: AnswerParams): Promise<void>;
61
63
  playRingtone(): void;
@@ -83,6 +85,7 @@ export default abstract class BaseCall implements IWebRTCCall {
83
85
  setBandwidthEncodingsMaxBps(max: number, _kind: string): Promise<void>;
84
86
  setAudioBandwidthEncodingsMaxBps(max: number): void;
85
87
  setVideoBandwidthEncodingsMaxBps(max: number): void;
88
+ private _isTerminatingOrTerminated;
86
89
  getStats(callback: Function, constraints: any): void;
87
90
  setState(state: State): void;
88
91
  handleMessage(msg: any): void;
@@ -122,6 +125,8 @@ export default abstract class BaseCall implements IWebRTCCall {
122
125
  private _hasUsablePeerConnection;
123
126
  private _init;
124
127
  protected _finalize(): void;
128
+ private _getCallReportVoiceSdkId;
129
+ flushIntermediateCallReport(flushReason?: ICallReportFlushReason): void;
125
130
  private _flushIntermediateReport;
126
131
  private _postCallReport;
127
132
  private _startStats;
@@ -55,6 +55,7 @@ export interface ITransportStats {
55
55
  export interface ICallReportOptions {
56
56
  enabled: boolean;
57
57
  interval: number;
58
+ intermediateReportInterval?: number;
58
59
  }
59
60
  export interface ILogCollectorOptions {
60
61
  enabled: boolean;
@@ -112,11 +113,22 @@ export interface ICallSummary {
112
113
  startTimestamp?: string;
113
114
  endTimestamp?: string;
114
115
  }
116
+ export interface ICallReportFlushReason {
117
+ type: 'buffer-limit' | 'manual' | 'socket-close' | 'socket-error';
118
+ socketClose?: {
119
+ code?: number;
120
+ codeName?: string;
121
+ reason?: string;
122
+ wasClean?: boolean;
123
+ error?: string;
124
+ };
125
+ }
115
126
  export interface ICallReportPayload {
116
127
  summary: ICallSummary;
117
128
  stats: IStatsInterval[];
118
129
  logs?: ILogEntry[];
119
130
  segment?: number;
131
+ flushReason?: ICallReportFlushReason;
120
132
  }
121
133
  export declare class CallReportCollector {
122
134
  private options;
@@ -139,6 +151,7 @@ export declare class CallReportCollector {
139
151
  private readonly MAX_BUFFER_SIZE;
140
152
  private static readonly STATS_FLUSH_THRESHOLD;
141
153
  private static readonly LOGS_FLUSH_THRESHOLD;
154
+ private static readonly DEFAULT_INTERMEDIATE_REPORT_INTERVAL_MS;
142
155
  onFlushNeeded: (() => void) | null;
143
156
  onWarning: ((warning: ITelnyxWarning) => void) | null;
144
157
  private static readonly CONSECUTIVE_BREACHES_REQUIRED;
@@ -158,23 +171,29 @@ export declare class CallReportCollector {
158
171
  private _hasConfirmedLocalAudio;
159
172
  private _confirmedLocalAudioSilenceMs;
160
173
  private _segmentIndex;
174
+ private _lastIntermediateFlushTime;
161
175
  private _flushing;
162
176
  private _stopped;
163
- private static readonly RETRY_DELAY_MS;
177
+ private static readonly RETRY_DELAYS_MS;
178
+ private static readonly KEEPALIVE_BODY_LIMIT_BYTES;
164
179
  constructor(options: ICallReportOptions, logCollectorOptions?: ILogCollectorOptions);
165
180
  start(peerConnection: RTCPeerConnection): void;
166
181
  stop(): Promise<void>;
167
- flush(summary: ICallSummary): ICallReportPayload | null;
182
+ flush(summary: ICallSummary, flushReason?: ICallReportFlushReason): ICallReportPayload | null;
168
183
  postReport(summary: ICallSummary, callReportId: string, host: string, voiceSdkId?: string): Promise<void>;
169
184
  sendPayload(payload: ICallReportPayload, callReportId: string, host: string, voiceSdkId?: string): Promise<void>;
170
185
  private _sendPayload;
171
186
  getStatsBuffer(): IStatsInterval[];
187
+ shouldForceRelayCandidateForRecovery(): boolean;
172
188
  getLogs(): ILogEntry[];
189
+ private _positiveDelta;
173
190
  cleanup(): void;
174
191
  private _scheduleNextCollection;
175
192
  private _collectionIntervalFor;
176
193
  private _positiveInterval;
177
194
  private _collectStats;
195
+ private _getIntermediateReportInterval;
196
+ private _requestIntermediateFlushIfNeeded;
178
197
  private _checkQualityWarnings;
179
198
  private _trackLowLocalAudio;
180
199
  private _resetLowLocalAudioWarning;
@@ -1,3 +1,4 @@
1
+ import type { ICallReportFlushReason } from './CallReportCollector';
1
2
  import { State } from './constants';
2
3
  export interface IMediaSettings {
3
4
  useSdpASBandwidthKbps?: boolean;
@@ -109,6 +110,7 @@ export interface IWebRTCCall {
109
110
  invite: () => void;
110
111
  answer: (params: AnswerParams) => void;
111
112
  hangup: (params?: IHangupParams, execute?: boolean) => Promise<void>;
113
+ flushIntermediateCallReport?: (reason?: ICallReportFlushReason) => void;
112
114
  hold: () => void;
113
115
  unhold: () => void;
114
116
  toggleHold: () => void;
@@ -128,6 +130,7 @@ export interface IWebRTCCall {
128
130
  setAudioBandwidthEncodingsMaxBps: (max: number) => void;
129
131
  setVideoBandwidthEncodingsMaxBps: (max: number) => void;
130
132
  getStats: (callback: Function, constraints: any) => void;
133
+ shouldForceRelayCandidateForRecovery?: () => boolean;
131
134
  setState: (state: State) => void;
132
135
  handleMessage: (msg: any) => void;
133
136
  _addChannel: (laChannel: any) => void;
@@ -38,6 +38,7 @@ export interface IClientOptions {
38
38
  maxReconnectAttempts?: number;
39
39
  enableCallReports?: boolean;
40
40
  callReportInterval?: number;
41
+ callReportFlushInterval?: number;
41
42
  mediaPermissionsRecovery?: {
42
43
  enabled: boolean;
43
44
  timeout: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telnyx/webrtc",
3
- "version": "2.27.0-beta.3",
3
+ "version": "2.27.0-beta.5",
4
4
  "description": "Telnyx WebRTC Client",
5
5
  "keywords": [
6
6
  "telnyx",