@vkontakte/calls-sdk 2.8.12-beta.14 → 2.8.12-beta.15
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.
- package/CallsSDK.d.ts +16 -13
- package/abstract/BaseSignaling.d.ts +4 -0
- package/calls-sdk.cjs.js +7 -13
- package/calls-sdk.esm.js +1320 -1162
- package/classes/conversation/Conversation.d.ts +11 -4
- package/classes/transport/PerfStatReporter.d.ts +2 -0
- package/classes/transport/ServerTransport.d.ts +1 -5
- package/classes/transport/SimulcastSender.d.ts +31 -0
- package/default/Signaling.d.ts +1 -0
- package/package.json +1 -1
- package/static/ParticipantConnectionStatusUtils.d.ts +1 -0
- package/static/Sdp.d.ts +3 -0
- package/static/SignalingCapabilities.d.ts +1 -1
- package/static/SimulcastInfo.d.ts +5 -3
- package/static/Utils.d.ts +0 -1
- package/types/Capabilities.d.ts +1 -0
- package/types/FastHangup.d.ts +66 -0
- package/types/Participant.d.ts +1 -0
- package/types/PerfStatReporter.d.ts +0 -4
- package/types/SignalingCommand.d.ts +2 -0
- package/utils/SerializeLatest.d.ts +5 -0
|
@@ -5,7 +5,6 @@ import BaseLogger from '../../abstract/BaseLogger';
|
|
|
5
5
|
import { AddParticipantParams } from '../../abstract/BaseSignaling';
|
|
6
6
|
import ConversationFeature from '../../enums/ConversationFeature';
|
|
7
7
|
import ConversationOption from '../../enums/ConversationOption';
|
|
8
|
-
import type ClientHangupReason from '../../enums/ClientHangupReason';
|
|
9
8
|
import MediaOption from '../../enums/MediaOption';
|
|
10
9
|
import UpdateDisplayLayoutErrorReason from '../../enums/UpdateDisplayLayoutErrorReason';
|
|
11
10
|
import UserRole from '../../enums/UserRole';
|
|
@@ -16,6 +15,7 @@ import { IAsrStartParams, IAsrStopParams } from '../../types/Asr';
|
|
|
16
15
|
import { AudienceModeHandsResponse } from '../../types/AudienceMode';
|
|
17
16
|
import { ConversationData, ConversationOnJoinParams, ConversationOnStartParams } from '../../types/Conversation';
|
|
18
17
|
import { ExternalId, ExternalParticipant, ExternalParticipantId, ExternalParticipantListChunk } from '../../types/ExternalId';
|
|
18
|
+
import type { FastHangupHandler, HangupParams } from '../../types/FastHangup';
|
|
19
19
|
import MediaModifiers from '../../types/MediaModifiers';
|
|
20
20
|
import MediaSettings, { IVideoDimentions } from '../../types/MediaSettings';
|
|
21
21
|
import { IAddMovieParams, IUpdateMovieData } from '../../types/MovieShare';
|
|
@@ -57,6 +57,7 @@ export default class Conversation extends EventEmitter {
|
|
|
57
57
|
private _serverSettings;
|
|
58
58
|
private _serverTimeOffset;
|
|
59
59
|
private _delayedHangup;
|
|
60
|
+
private _onFastHangup?;
|
|
60
61
|
private _hangupEmitted;
|
|
61
62
|
private _hangupPromise;
|
|
62
63
|
private _abortController;
|
|
@@ -78,7 +79,7 @@ export default class Conversation extends EventEmitter {
|
|
|
78
79
|
private readonly _statFirstMediaReceived;
|
|
79
80
|
constructor(api: BaseApi, externalLogger: BaseLogger | null);
|
|
80
81
|
static current(): Conversation | null;
|
|
81
|
-
static hangupAfterInit(): void;
|
|
82
|
+
static hangupAfterInit(onFastHangup?: FastHangupHandler): void;
|
|
82
83
|
static id(): string | null;
|
|
83
84
|
get id(): string;
|
|
84
85
|
get externalId(): ExternalParticipantId | undefined;
|
|
@@ -90,6 +91,7 @@ export default class Conversation extends EventEmitter {
|
|
|
90
91
|
static getSyncedTime(): number;
|
|
91
92
|
get debugSessionId(): string | null;
|
|
92
93
|
getCachedRawOkIdByExternalId(externalId: ExternalId): OkUserId | null;
|
|
94
|
+
private _buildInternalParams;
|
|
93
95
|
onStart({ opponentIds, opponentType, mediaOptions, payload, joiningAllowed, requireAuthToJoin, onlyAdminCanShareMovie, externalIds, onFastStart, conversationId, }: ConversationOnStartParams): Promise<ConversationData>;
|
|
94
96
|
onJoin(joinArgs: ConversationOnJoinParams): Promise<ConversationData>;
|
|
95
97
|
private _onJoinPart2;
|
|
@@ -105,8 +107,8 @@ export default class Conversation extends EventEmitter {
|
|
|
105
107
|
private _getMainRoomParticipants;
|
|
106
108
|
private _decodeExternalConversationParams;
|
|
107
109
|
accept(mediaOptions: MediaOption[]): Promise<ConversationData>;
|
|
108
|
-
decline(
|
|
109
|
-
hangup(
|
|
110
|
+
decline(params?: HangupParams): Promise<void>;
|
|
111
|
+
hangup(params?: HangupParams): Promise<void>;
|
|
110
112
|
addParticipant(participantIds: ExternalId[], params?: AddParticipantParams): Promise<void>;
|
|
111
113
|
addParticipantLegacy(participantIds: CompositeUserId[], params?: AddParticipantParams): Promise<void>;
|
|
112
114
|
removeParticipant(participantId: CompositeUserId, ban?: boolean): Promise<void>;
|
|
@@ -119,6 +121,7 @@ export default class Conversation extends EventEmitter {
|
|
|
119
121
|
private _emitHangupOnce;
|
|
120
122
|
private _sendHangupApi;
|
|
121
123
|
private _close;
|
|
124
|
+
private _sendHangup;
|
|
122
125
|
destroy(): void;
|
|
123
126
|
private _destroy;
|
|
124
127
|
private _getConversationParams;
|
|
@@ -223,6 +226,8 @@ export default class Conversation extends EventEmitter {
|
|
|
223
226
|
setAnimojiFill(fill: RGBTuple | string): void;
|
|
224
227
|
setVideoStream(stream: MediaStream, isScreen?: boolean): Promise<void>;
|
|
225
228
|
setAudioStream(stream: MediaStream): Promise<void>;
|
|
229
|
+
private readonly _toggleLocalVideo;
|
|
230
|
+
private readonly _toggleLocalAudio;
|
|
226
231
|
toggleLocalVideo(enabled: boolean): Promise<void>;
|
|
227
232
|
toggleLocalAudio(enabled: boolean): Promise<void>;
|
|
228
233
|
/**
|
|
@@ -419,6 +424,8 @@ export default class Conversation extends EventEmitter {
|
|
|
419
424
|
private _toggleJoinAvailability;
|
|
420
425
|
private _updateDisplayLayoutFromCache;
|
|
421
426
|
private _setParticipantsStatus;
|
|
427
|
+
private _setParticipantsStalled;
|
|
428
|
+
private _updateParticipantsStatus;
|
|
422
429
|
private _onJoinLinkChanged;
|
|
423
430
|
private _onRoomsUpdated;
|
|
424
431
|
private _onRoomUpdated;
|
|
@@ -9,6 +9,7 @@ export default class PerfStatReporter extends EventEmitter {
|
|
|
9
9
|
private _previousNetworkStatReportTimestamp;
|
|
10
10
|
private _previousCallStatReportTimestamp;
|
|
11
11
|
private _previousCallStatReport;
|
|
12
|
+
private _previousRemoteInboundRtps;
|
|
12
13
|
private _screenShareStats;
|
|
13
14
|
private _signaling;
|
|
14
15
|
private readonly _directTopology;
|
|
@@ -21,6 +22,7 @@ export default class PerfStatReporter extends EventEmitter {
|
|
|
21
22
|
private reportPerfStats;
|
|
22
23
|
private reportNetworkStats;
|
|
23
24
|
private _reportCallStats;
|
|
25
|
+
private _calculatePacketLoss;
|
|
24
26
|
private _handleScreenSharingStat;
|
|
25
27
|
private _handleTransportStateChanged;
|
|
26
28
|
}
|
|
@@ -42,12 +42,11 @@ export default class ServerTransport extends BaseTransport {
|
|
|
42
42
|
private _rtpReceiversByStreamId;
|
|
43
43
|
private _producerSessionId;
|
|
44
44
|
private _newAudioShareTrack;
|
|
45
|
-
private _simulcastInfo;
|
|
46
|
-
private _isSimulcastNegotiated;
|
|
47
45
|
private readonly _debug;
|
|
48
46
|
private readonly _logger;
|
|
49
47
|
private readonly _statAggregator;
|
|
50
48
|
private readonly _codecStatsAggregator;
|
|
49
|
+
private readonly _simulcast;
|
|
51
50
|
constructor(signaling: BaseSignaling, mediaSource: MediaSource, serverSettings: ServerSettings, debug?: DebugLogger, logger?: StatsLogger | null, statAggregator?: StatAggregator | null, codecStatsAggregator?: CodecStatsAggregator | null, onFirstMediaSent?: (() => void) | null);
|
|
52
51
|
updateStatisticsInterval(): void;
|
|
53
52
|
open(observer?: boolean): void;
|
|
@@ -86,8 +85,6 @@ export default class ServerTransport extends BaseTransport {
|
|
|
86
85
|
private _detectStaleTracks;
|
|
87
86
|
private _allocateConsumer;
|
|
88
87
|
private _processOffer;
|
|
89
|
-
private _findFirstSimTransceiver;
|
|
90
|
-
private _setupSimulcastTransceiver;
|
|
91
88
|
private _acceptProducer;
|
|
92
89
|
private _replaceScreenShareTrack;
|
|
93
90
|
private _handleTracks;
|
|
@@ -102,7 +99,6 @@ export default class ServerTransport extends BaseTransport {
|
|
|
102
99
|
private _onReplacedTrack;
|
|
103
100
|
private _onSourcesChanged;
|
|
104
101
|
getStreamWaitingTimeMs(streamId: string, targetRtpTimestamp: number): number;
|
|
105
|
-
private _changeSimulcastInfo;
|
|
106
102
|
private _monitorRtpShare;
|
|
107
103
|
private _startMonitorRtpShareInterval;
|
|
108
104
|
private _stopMonitorRtpShareInterval;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import BaseSignaling from '../../abstract/BaseSignaling';
|
|
2
|
+
import { type DebugLogger } from '../../static/Debug';
|
|
3
|
+
import type VideoSettings from '../../types/VideoSettings';
|
|
4
|
+
import { MediaSource } from '../MediaSource';
|
|
5
|
+
import StatsLogger from '../StatsLogger';
|
|
6
|
+
export default class SimulcastSender {
|
|
7
|
+
private _pc;
|
|
8
|
+
private _transceiver;
|
|
9
|
+
private _currentSimulcastInfo;
|
|
10
|
+
private readonly _signaling;
|
|
11
|
+
private readonly _mediaSource;
|
|
12
|
+
private readonly _getCameraSettings;
|
|
13
|
+
private readonly _debug;
|
|
14
|
+
private readonly _logger;
|
|
15
|
+
constructor(signaling: BaseSignaling, mediaSource: MediaSource, getCameraSettings: () => VideoSettings | null, debug?: DebugLogger, logger?: StatsLogger | null);
|
|
16
|
+
configureFromRemoteOffer(pc: RTCPeerConnection): Promise<void>;
|
|
17
|
+
finalizeAnswer(sdp: string): string;
|
|
18
|
+
sync({ force }?: {
|
|
19
|
+
force?: boolean;
|
|
20
|
+
}): Promise<void>;
|
|
21
|
+
replaceTrack(track: MediaStreamTrack): boolean;
|
|
22
|
+
reset(): void;
|
|
23
|
+
private _findTransceiver;
|
|
24
|
+
private _findMediaSection;
|
|
25
|
+
private _getConfig;
|
|
26
|
+
private _getTrackConfig;
|
|
27
|
+
private _applyConfig;
|
|
28
|
+
private _applyCurrentMediaState;
|
|
29
|
+
private _syncReplacedTrack;
|
|
30
|
+
private _changeSimulcast;
|
|
31
|
+
}
|
package/default/Signaling.d.ts
CHANGED
|
@@ -64,6 +64,7 @@ export default class Signaling extends BaseSignaling {
|
|
|
64
64
|
setProducerNotificationDataChannel(dataChannel: RTCDataChannel): void;
|
|
65
65
|
setProducerCommandDataChannel(dataChannel: RTCDataChannel): void;
|
|
66
66
|
useCommandDataChannel(status: boolean): void;
|
|
67
|
+
resetProducerConnection(cause?: Error): void;
|
|
67
68
|
/**
|
|
68
69
|
* Open a connection with a signaling server
|
|
69
70
|
*/
|
package/package.json
CHANGED
|
@@ -11,6 +11,7 @@ declare namespace ParticipantConnectionStatusUtils {
|
|
|
11
11
|
function computeEffective(status: ParticipantConnectionStatus): ParticipantStatus;
|
|
12
12
|
function setSessionState(status: ParticipantConnectionStatus, sessionState?: ParticipantSessionState, sessionStateConnectedBySpeaker?: boolean): StatusTransition;
|
|
13
13
|
function setTransport(status: ParticipantConnectionStatus, transport: ParticipantStatus): StatusTransition;
|
|
14
|
+
function setStalled(status: ParticipantConnectionStatus, stalled: boolean): StatusTransition;
|
|
14
15
|
function setSessionStateApplicable(status: ParticipantConnectionStatus, applicable: boolean): StatusTransition;
|
|
15
16
|
}
|
|
16
17
|
export default ParticipantConnectionStatusUtils;
|
package/static/Sdp.d.ts
ADDED
|
@@ -6,8 +6,10 @@ export declare const SIMULCAST_DEFAULT: {
|
|
|
6
6
|
BITRATE: number;
|
|
7
7
|
};
|
|
8
8
|
export declare const SIMULCAST_SCALABILITY_MODE = "L1T2";
|
|
9
|
-
export declare const MAP_RID_TO_SCALE_RESOLUTION_DOWN_BY: Record<string, number>;
|
|
10
9
|
export declare function isEqualSimulcastInfo(si1: ISimulcastInfo | null, si2: ISimulcastInfo | null): boolean;
|
|
11
10
|
export declare function findBitrateAsc(maxDimension: number, bitrates: VideoBitrateSettings[]): number;
|
|
12
|
-
export declare function calculateSimulcastInfo(width?: number, height?: number, bitrates?: VideoBitrateSettings[]):
|
|
13
|
-
|
|
11
|
+
export declare function calculateSimulcastInfo(width?: number, height?: number, bitrates?: VideoBitrateSettings[], fps?: number): {
|
|
12
|
+
streams: import("../types/SimulcastInfo").SimulcastStreamInfo[];
|
|
13
|
+
};
|
|
14
|
+
export declare function findScaleResolutionDownBy(rid: string | undefined, simulcastInfo: ISimulcastInfo): number;
|
|
15
|
+
export declare function applySimulcastInfoToEncodings(encodings: RTCRtpEncodingParameters[], simulcastInfo: ISimulcastInfo, maxDimension?: number, maxBitrate?: number): void;
|
package/static/Utils.d.ts
CHANGED
|
@@ -77,6 +77,5 @@ declare namespace Utils {
|
|
|
77
77
|
function objectReduce<R, T extends object>(obj: T, callback: (acc: R, value: T[keyof T], key: keyof T) => R, initialValue: R): R;
|
|
78
78
|
const setImmediate: (fn: VoidFunction) => VoidFunction;
|
|
79
79
|
function isObject(obj: unknown): obj is object;
|
|
80
|
-
function patchSimulcastAnswerSdp(sdp: string, trans: RTCRtpTransceiver, width: number, height: number): string;
|
|
81
80
|
}
|
|
82
81
|
export default Utils;
|
package/types/Capabilities.d.ts
CHANGED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type ClientHangupReason from '../enums/ClientHangupReason';
|
|
2
|
+
import type HangupType from '../enums/HangupType';
|
|
3
|
+
/**
|
|
4
|
+
* Параметры запроса завершения звонка через внешнего партнёра (fast hangup).
|
|
5
|
+
*
|
|
6
|
+
* SDK генерирует объект и передаёт его в {@link FastHangupHandler}.
|
|
7
|
+
* Хост и backend партнёра пробрасывают `internalParams` как есть, без парсинга.
|
|
8
|
+
*/
|
|
9
|
+
export interface FastHangupParams {
|
|
10
|
+
/**
|
|
11
|
+
* ID звонка
|
|
12
|
+
*/
|
|
13
|
+
conversationId: string;
|
|
14
|
+
/**
|
|
15
|
+
* Причина завершения звонка
|
|
16
|
+
*/
|
|
17
|
+
reason: HangupType;
|
|
18
|
+
/**
|
|
19
|
+
* Внутренние параметры звонка (JSON-строка). Генерируется SDK.
|
|
20
|
+
*/
|
|
21
|
+
internalParams?: string | null;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Ответ внешнего партнёра на завершение звонка.
|
|
25
|
+
*/
|
|
26
|
+
export interface FastHangupResponse {
|
|
27
|
+
/**
|
|
28
|
+
* true — участие в звонке завершено
|
|
29
|
+
*/
|
|
30
|
+
success: boolean;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Параметры публичных методов {@link hangup} / {@link declineCall}.
|
|
34
|
+
*
|
|
35
|
+
* `reason` и `conversationId` идут в signaling hangup.
|
|
36
|
+
* `onFastHangup` заменяет Calls API `vchat.hangupConversation`, если обработчик передан
|
|
37
|
+
* (явный hangup/decline или delayed hangup во время init).
|
|
38
|
+
* Если обработчик не передан, API hangup не вызывается — кроме закрытия вкладки (`pagehide`),
|
|
39
|
+
* где SDK всегда шлёт beacon, и delayed hangup без handler.
|
|
40
|
+
*/
|
|
41
|
+
export interface HangupParams {
|
|
42
|
+
/**
|
|
43
|
+
* ID звонка. Если опущен — завершается текущий активный звонок.
|
|
44
|
+
*/
|
|
45
|
+
conversationId?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Причина завершения для проброса в сигналинг. См. {@link ClientHangupReason}.
|
|
48
|
+
*/
|
|
49
|
+
reason?: ClientHangupReason;
|
|
50
|
+
/**
|
|
51
|
+
* Обработчик fast hangup — завершение звонка через внешнего партнёра.
|
|
52
|
+
*/
|
|
53
|
+
onFastHangup?: FastHangupHandler;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Функция-обработчик fast hangup.
|
|
57
|
+
*
|
|
58
|
+
* Если передана в {@link HangupParams.onFastHangup} при `hangup` / `declineCall`,
|
|
59
|
+
* SDK вызывает её вместо API `vchat.hangupConversation`.
|
|
60
|
+
*
|
|
61
|
+
* На `pagehide` не используется — SDK всегда отправляет `sendBeacon`.
|
|
62
|
+
*
|
|
63
|
+
* @param params Параметры запроса
|
|
64
|
+
* @param signal AbortSignal текущего звонка, если он ещё жив на момент вызова
|
|
65
|
+
*/
|
|
66
|
+
export type FastHangupHandler = (params: FastHangupParams, signal?: AbortSignal) => Promise<FastHangupResponse>;
|
package/types/Participant.d.ts
CHANGED
|
@@ -49,6 +49,7 @@ export interface ParticipantSessionState {
|
|
|
49
49
|
}
|
|
50
50
|
export interface ParticipantConnectionStatus {
|
|
51
51
|
transport: ParticipantStatus;
|
|
52
|
+
stalled: boolean;
|
|
52
53
|
sessionState?: ParticipantSessionState;
|
|
53
54
|
sessionStateApplicable: boolean;
|
|
54
55
|
sessionStateConnectedBySpeaker: boolean;
|
|
@@ -24,10 +24,6 @@ export interface CallStatReport {
|
|
|
24
24
|
audio_concealment_events: number;
|
|
25
25
|
inbound_video_count: number;
|
|
26
26
|
inbound_audio_count: number;
|
|
27
|
-
packets_lost_video: number;
|
|
28
|
-
packets_sent_video: number;
|
|
29
|
-
packets_lost_audio: number;
|
|
30
|
-
packets_sent_audio: number;
|
|
31
27
|
freeze_count: number;
|
|
32
28
|
total_freezes_duration: number;
|
|
33
29
|
rtt: number;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import SignalingCommandType from '../enums/SignalingCommandType';
|
|
2
2
|
import { SignalingResponse, SignalingSuccessResponse } from './SignalingMessage';
|
|
3
|
+
export type SignalingCommandRoute = 'websocket' | 'producer';
|
|
3
4
|
interface SignalingCommand<T extends SignalingResponse = SignalingSuccessResponse> {
|
|
4
5
|
sequence: number;
|
|
5
6
|
name: SignalingCommandType;
|
|
7
|
+
route: SignalingCommandRoute;
|
|
6
8
|
statMarkName: string;
|
|
7
9
|
params: object;
|
|
8
10
|
responseTimer: number;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Последовательно выполняет операции, оставляя в очереди только последнее запрошенное значение.
|
|
3
|
+
* Возвращает ошибку, только если не удалось применить итоговое состояние.
|
|
4
|
+
*/
|
|
5
|
+
export declare function serializeLatest<T>(run: (value: T) => Promise<void> | undefined): (value: T) => Promise<void>;
|