@vkontakte/calls-sdk 2.8.11-beta.0 → 2.8.11-dev.3d9bb708.0

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.
@@ -0,0 +1,18 @@
1
+ import Conversation from './Conversation';
2
+ export interface HoldableConversation extends Conversation {
3
+ id: string;
4
+ hold(hold: boolean): Promise<void>;
5
+ }
6
+ export declare class CallRegistry {
7
+ private _conversations;
8
+ private _activeId;
9
+ add(conversation: HoldableConversation): void;
10
+ remove(id: string | null): void;
11
+ get(id: string): HoldableConversation | undefined;
12
+ getActive(): HoldableConversation | null;
13
+ getActiveId(): string | null;
14
+ has(id: string): boolean;
15
+ getAll(): HoldableConversation[];
16
+ setActive(id: string): Promise<void>;
17
+ clear(): void;
18
+ }
@@ -16,7 +16,7 @@ import { ConversationData, ConversationOnStartParams } from '../types/Conversati
16
16
  import { ExternalId, ExternalParticipant, ExternalParticipantId, ExternalParticipantListChunk, ExternalUserId } from '../types/ExternalId';
17
17
  import type { FastJoinHandler } from '../types/FastJoin';
18
18
  import MediaModifiers from '../types/MediaModifiers';
19
- import { IVideoDimentions } from '../types/MediaSettings';
19
+ import MediaSettings, { IVideoDimentions } from '../types/MediaSettings';
20
20
  import { IAddMovieParams, IUpdateMovieData } from '../types/MovieShare';
21
21
  import MuteStates from '../types/MuteStates';
22
22
  import { CompositeUserId, IGetParticipantsParameters, ParticipantId, ParticipantStateData } from '../types/Participant';
@@ -27,6 +27,7 @@ import { ParticipantStreamDescription } from '../types/ParticipantStreamDescript
27
27
  import { ScreenCaptureSettings } from '../types/ScreenCaptureSettings';
28
28
  import SignalingMessage from '../types/SignalingMessage';
29
29
  import { WaitingHallResponse } from '../types/WaitingHall';
30
+ import { CallRegistry } from './CallRegistry';
30
31
  import EventEmitter from './EventEmitter';
31
32
  export default class Conversation extends EventEmitter {
32
33
  private readonly _api;
@@ -49,10 +50,8 @@ export default class Conversation extends EventEmitter {
49
50
  private _lastSignalledActiveSpeakerId;
50
51
  private _isRealTimeAsrRequested;
51
52
  private _serverSettings;
52
- private static _current;
53
- private static _activationMutex;
54
- private static _delayedHangup;
55
- private static _abortController;
53
+ private _delayedHangup;
54
+ private _abortController;
56
55
  private readonly _onUnload;
57
56
  private readonly _audioOutput;
58
57
  private _lastStalled;
@@ -69,6 +68,10 @@ export default class Conversation extends EventEmitter {
69
68
  static current(): Conversation | null;
70
69
  static hangupAfterInit(): void;
71
70
  static id(): string | null;
71
+ get id(): string;
72
+ get externalId(): ExternalParticipantId | undefined;
73
+ get mediaSettings(): MediaSettings | undefined;
74
+ get isCallHeld(): boolean;
72
75
  onStart({ opponentIds, opponentType, mediaOptions, payload, joiningAllowed, requireAuthToJoin, onlyAdminCanShareMovie, externalIds, onFastStart, conversationId, }: ConversationOnStartParams): Promise<ConversationData>;
73
76
  onJoin(joinArgs: {
74
77
  conversationId?: string;
@@ -402,6 +405,10 @@ export default class Conversation extends EventEmitter {
402
405
  private _getParticipants;
403
406
  private _getParticipant;
404
407
  }
408
+ declare const _callRegistry: CallRegistry;
409
+ export { _callRegistry };
410
+ declare function _resetPendingInstance(): void;
411
+ export { _resetPendingInstance };
405
412
  export declare class UpdateDisplayLayoutError extends Error {
406
413
  readonly participantErrors: {
407
414
  externalId: ExternalParticipantId;
@@ -45,6 +45,7 @@ export declare class MediaSource extends EventEmitter {
45
45
  /** Трек аудио эффектов. Не изменяется на протяжении всего времени */
46
46
  private _audioEffectsTrack;
47
47
  private _mediaSettings;
48
+ private _lastMediaSettings;
48
49
  private _videoStatusOnScreenCapturingEnabled;
49
50
  private _effect;
50
51
  private _audioEffectParams;
@@ -63,7 +64,7 @@ export declare class MediaSource extends EventEmitter {
63
64
  getSendAudioTrack(): MediaStreamTrack | null;
64
65
  get isAnimojiRequested(): boolean;
65
66
  addTrackToPeerConnection(pc: RTCPeerConnection, observer: boolean, noDataChannel: boolean): void;
66
- getMediaSettings(): MediaSettings;
67
+ get mediaSettings(): MediaSettings;
67
68
  changeDevice(kind: MediaDeviceKind): Promise<void>;
68
69
  /**
69
70
  * Установка кастомного стрима для видео, например внешний шаринг экрана
@@ -91,6 +92,8 @@ export declare class MediaSource extends EventEmitter {
91
92
  private _setEffect;
92
93
  private _stopEffect;
93
94
  destroy(): void;
95
+ stopLocalMedia(): void;
96
+ resumeLocalMedia(): Promise<void>;
94
97
  toggleScreenCapturing(settings: ScreenCaptureSettings): Promise<void>;
95
98
  disableScreenCapturing(): Promise<void>;
96
99
  private videoTrackMuteHandler;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vkontakte/calls-sdk",
3
- "version": "2.8.11-beta.0",
3
+ "version": "2.8.11-dev.3d9bb708.0",
4
4
  "author": "vk.com",
5
5
  "description": "Library for video calls based on the vk.com platform",
6
6
  "homepage": "https://vk.com",
@@ -47,8 +47,9 @@ declare namespace External {
47
47
  *
48
48
  * @param stream
49
49
  * @param mediaSettings
50
+ * @param conversationId ID звонка
50
51
  */
51
- function onLocalStream(stream: MediaStream | null, mediaSettings: MediaSettings): void;
52
+ function onLocalStream(stream: MediaStream | null, mediaSettings: MediaSettings, conversationId?: string): void;
52
53
  /**
53
54
  * Локальный стрим с экрана добавлен/удалён
54
55
  *
@@ -80,16 +81,18 @@ declare namespace External {
80
81
  * Изменился статус локального соединения
81
82
  *
82
83
  * @param status
84
+ * @param conversationId ID звонка
83
85
  */
84
- function onLocalStatus(status: ParticipantStatus): void;
86
+ function onLocalStatus(status: ParticipantStatus, conversationId?: string): void;
85
87
  /**
86
88
  * Получен стрим собеседника.
87
89
  * Если сервер закончил стримить собеседника, вместо стрима будет передан null
88
90
  *
89
91
  * @param userId
90
92
  * @param stream
93
+ * @param conversationId ID звонка
91
94
  */
92
- function onRemoteStream(userId: ExternalParticipantId, stream: MediaStream | null): void;
95
+ function onRemoteStream(userId: ExternalParticipantId, stream: MediaStream | null, conversationId?: string): void;
93
96
  /**
94
97
  * Получен стрим лайв от собеседника.
95
98
  * Если сервер закончил стримить собеседника, вместо стрима будет передан null
@@ -126,8 +129,9 @@ declare namespace External {
126
129
  *
127
130
  * @param userId
128
131
  * @param stream
132
+ * @param conversationId ID звонка
129
133
  */
130
- function onRemoteScreenStream(userId: ExternalParticipantId, stream: MediaStream | null): void;
134
+ function onRemoteScreenStream(userId: ExternalParticipantId, stream: MediaStream | null, conversationId?: string): void;
131
135
  /**
132
136
  * Получен стрим вимоджи собеседника.
133
137
  * Если сервер закончил стримить собеседника, вместо стрима будет передан null
@@ -152,8 +156,9 @@ declare namespace External {
152
156
  * @param muteStates Состояние устройств при входе в звонок
153
157
  * @param participants Список участников звонка
154
158
  * @param rooms Список сессионных залов в звонке
159
+ * @param conversationId ID звонка
155
160
  */
156
- function onConversation(userId: ExternalParticipantId, mediaModifiers: MediaModifiers, muteStates: MuteStates, participants: ExternalParticipant[], rooms?: Rooms): void;
161
+ function onConversation(userId: ExternalParticipantId, mediaModifiers: MediaModifiers, muteStates: MuteStates, participants: ExternalParticipant[], rooms?: Rooms, conversationId?: string): void;
157
162
  /**
158
163
  * Постраничные данные про участников при начале звонка
159
164
  * @param chunk
@@ -219,15 +224,17 @@ declare namespace External {
219
224
  *
220
225
  * @param userId
221
226
  * @param markers
227
+ * @param conversationId ID звонка
222
228
  */
223
- function onParticipantAdded(userId: ExternalId, markers: ExternalParticipantListMarkers | null): void;
229
+ function onParticipantAdded(userId: ExternalId, markers: ExternalParticipantListMarkers | null, conversationId?: string): void;
224
230
  /**
225
231
  * Участник подключился
226
232
  *
227
233
  * @param userId
228
234
  * @param markers
235
+ * @param conversationId ID звонка
229
236
  */
230
- function onParticipantJoined(userId: ExternalId, markers: ExternalParticipantListMarkers | null): void;
237
+ function onParticipantJoined(userId: ExternalId, markers: ExternalParticipantListMarkers | null, conversationId?: string): void;
231
238
  function onLocalParticipantState(participantState: ParticipantStateMapped, global?: boolean): void;
232
239
  /**
233
240
  * Изменились данные состояний собеседника
@@ -250,8 +257,9 @@ declare namespace External {
250
257
  * @param userIds
251
258
  * @param status
252
259
  * @param data
260
+ * @param conversationId ID звонка
253
261
  */
254
- function onRemoteStatus(userIds: ExternalParticipantId[], status: ParticipantStatus, data?: any): void;
262
+ function onRemoteStatus(userIds: ExternalParticipantId[], status: ParticipantStatus, data?: any, conversationId?: string): void;
255
263
  /**
256
264
  * Разрешения на доступы были запрошены в браузере
257
265
  */
@@ -268,23 +276,26 @@ declare namespace External {
268
276
  *
269
277
  * @param userId
270
278
  * @param markers
279
+ * @param conversationId ID звонка
271
280
  */
272
- function onRemoteRemoved(userId: ExternalParticipantId, markers: ExternalParticipantListMarkers | null): void;
281
+ function onRemoteRemoved(userId: ExternalParticipantId, markers: ExternalParticipantListMarkers | null, conversationId?: string): void;
273
282
  /**
274
283
  * Изменилось состояние звонка
275
284
  *
276
285
  * @param isCallActive Активен ли сейчас звонок
277
286
  * @param canAddParticipants Можно ли добавлять собеседников
278
287
  * @param conversation Информация о звонке
288
+ * @param conversationId ID звонка
279
289
  */
280
- function onCallState(isCallActive: boolean, canAddParticipants: boolean, conversation: ConversationData): void;
290
+ function onCallState(isCallActive: boolean, canAddParticipants: boolean, conversation: ConversationData, conversationId?: string): void;
281
291
  /**
282
292
  * Изменилось состояние камеры или микрофона
283
293
  *
284
294
  * @param mediaOption Тип устройства
285
295
  * @param enabled Включено или выключено
296
+ * @param conversationId ID звонка
286
297
  */
287
- function onDeviceSwitched(mediaOption: MediaOption, enabled: boolean): void;
298
+ function onDeviceSwitched(mediaOption: MediaOption, enabled: boolean, conversationId?: string): void;
288
299
  /**
289
300
  * Изменились состояния устройств пользователя или разрешения включать камеру/микрофон
290
301
  *
@@ -339,21 +350,34 @@ declare namespace External {
339
350
  function onOptionsChanged(options: ConversationOption[]): void;
340
351
  /**
341
352
  * Входящий звонок был принят мной
353
+ *
354
+ * @param conversationId ID звонка
355
+ */
356
+ function onCallAccepted(conversationId?: string): void;
357
+ /**
358
+ * Входящий звонок получен во время активного звонка
359
+ *
360
+ * @param conversationId ID звонка
361
+ * @param externalId
362
+ * @param mediaSettings
342
363
  */
343
- function onCallAccepted(): void;
364
+ function onIncomingCall(conversationId: string, externalId: ExternalParticipantId | undefined, mediaSettings: MediaSettings | undefined): void;
344
365
  /**
345
366
  * Исходящий звонок был принят кем-то
367
+ *
346
368
  * @param userId
347
369
  * @param capabilities
370
+ * @param conversationId ID звонка
348
371
  */
349
- function onAcceptedCall(userId: ExternalId, capabilities: ParticipantCapabilities): void;
372
+ function onAcceptedCall(userId: ExternalId, capabilities: ParticipantCapabilities, conversationId?: string): void;
350
373
  function onRateNeeded(): void;
351
374
  /**
352
375
  * Изменился говорящий в звонке
353
376
  *
354
377
  * @param userId
378
+ * @param conversationId ID звонка
355
379
  */
356
- function onSpeakerChanged(userId: ExternalParticipantId): void;
380
+ function onSpeakerChanged(userId: ExternalParticipantId, conversationId?: string): void;
357
381
  /**
358
382
  * Громкость собеседников
359
383
  *
@@ -490,7 +490,7 @@ export type ParamsObject = {
490
490
  /**
491
491
  * Получен локальный стрим с камеры/микрофона
492
492
  */
493
- onLocalStream?: (stream: MediaStream | null, mediaSettings: MediaSettings) => void;
493
+ onLocalStream?: (stream: MediaStream | null, mediaSettings: MediaSettings, conversationId?: string) => void;
494
494
  /**
495
495
  * Локальный стрим изменился
496
496
  */
@@ -510,12 +510,12 @@ export type ParamsObject = {
510
510
  /**
511
511
  * Изменился статус локального соединения
512
512
  */
513
- onLocalStatus?: (status: ParticipantStatus) => void;
513
+ onLocalStatus?: (status: ParticipantStatus, conversationId?: string) => void;
514
514
  /**
515
515
  * Получен стрим собеседника.
516
516
  * Если сервер закончил стримить собеседника, вместо стрима будет передан null
517
517
  */
518
- onRemoteStream?: (userId: ExternalParticipantId, stream: MediaStream | null) => void;
518
+ onRemoteStream?: (userId: ExternalParticipantId, stream: MediaStream | null, conversationId?: string) => void;
519
519
  /**
520
520
  * Cтрим собеседника приостановлен/возобновлен.
521
521
  */
@@ -524,7 +524,7 @@ export type ParamsObject = {
524
524
  * Получен стрим с экрана собеседника.
525
525
  * Если сервер закончил стримить экран собеседника, вместо стрима будет передан null
526
526
  */
527
- onRemoteScreenStream?: (userId: ExternalParticipantId, stream: MediaStream | null) => void;
527
+ onRemoteScreenStream?: (userId: ExternalParticipantId, stream: MediaStream | null, conversationId?: string) => void;
528
528
  /**
529
529
  * Получен стрим вимоджи собеседника.
530
530
  * Если сервер закончил стримить вимоджи собеседника, вместо стрима будет передан null
@@ -551,7 +551,7 @@ export type ParamsObject = {
551
551
  /**
552
552
  * Начат звонок
553
553
  */
554
- onConversation?: (userId: ExternalParticipantId, mediaModifiers: MediaModifiers, muteStates: MuteStates, participants: ExternalParticipant[], rooms?: Rooms) => void;
554
+ onConversation?: (userId: ExternalParticipantId, mediaModifiers: MediaModifiers, muteStates: MuteStates, participants: ExternalParticipant[], rooms?: Rooms, conversationId?: string) => void;
555
555
  /**
556
556
  * Начальный список участников для постраничного звонка
557
557
  */
@@ -583,11 +583,11 @@ export type ParamsObject = {
583
583
  /**
584
584
  * Добавили участника
585
585
  */
586
- onParticipantAdded?: (userId: ExternalParticipantId, markers: ExternalParticipantListMarkers | null) => void;
586
+ onParticipantAdded?: (userId: ExternalParticipantId, markers: ExternalParticipantListMarkers | null, conversationId?: string) => void;
587
587
  /**
588
588
  * Участник присоединился к звонку
589
589
  */
590
- onParticipantJoined?: (userId: ExternalParticipantId, markers: ExternalParticipantListMarkers) => void;
590
+ onParticipantJoined?: (userId: ExternalParticipantId, markers: ExternalParticipantListMarkers, conversationId?: string) => void;
591
591
  /**
592
592
  * Получены данные по изменению локальных состояний со стороны админа
593
593
  * Например, принудительно опущена рука
@@ -607,7 +607,7 @@ export type ParamsObject = {
607
607
  /**
608
608
  * Изменился статус соединения собеседников
609
609
  */
610
- onRemoteStatus?: (userIds: ExternalParticipantId[], status: ParticipantStatus, data: any) => void;
610
+ onRemoteStatus?: (userIds: ExternalParticipantId[], status: ParticipantStatus, data: any, conversationId?: string) => void;
611
611
  /**
612
612
  * Разрешения на доступы были запрошены в браузере
613
613
  */
@@ -619,15 +619,15 @@ export type ParamsObject = {
619
619
  /**
620
620
  * Пользователь отключился от звонка
621
621
  */
622
- onRemoteRemoved?: (userId: ExternalParticipantId, markers: ExternalParticipantListMarkers | null) => void;
622
+ onRemoteRemoved?: (userId: ExternalParticipantId, markers: ExternalParticipantListMarkers | null, conversationId?: string) => void;
623
623
  /**
624
624
  * Изменилось состояние звонка
625
625
  */
626
- onCallState?: (isCallActive: boolean, canAddParticipants: boolean, conversation: ConversationData) => void;
626
+ onCallState?: (isCallActive: boolean, canAddParticipants: boolean, conversation: ConversationData, conversationId?: string) => void;
627
627
  /**
628
628
  * Изменилось состояние камеры или микрофона
629
629
  */
630
- onDeviceSwitched?: (mediaOption: MediaOption, enabled: boolean) => void;
630
+ onDeviceSwitched?: (mediaOption: MediaOption, enabled: boolean, conversationId?: string) => void;
631
631
  /**
632
632
  * Изменились состояния устройств пользователя или разрешения включать камеру/микрофон
633
633
  */
@@ -656,7 +656,7 @@ export type ParamsObject = {
656
656
  /**
657
657
  * Изменился говорящий в звонке
658
658
  */
659
- onSpeakerChanged?: (userId: ExternalParticipantId) => void;
659
+ onSpeakerChanged?: (userId: ExternalParticipantId, conversationId?: string) => void;
660
660
  /**
661
661
  * Громкость собеседников
662
662
  */
@@ -676,12 +676,12 @@ export type ParamsObject = {
676
676
  /**
677
677
  * Входящий звонок был принят мной
678
678
  */
679
- onCallAccepted?: () => void;
679
+ onCallAccepted?: (conversationId?: string) => void;
680
680
  /**
681
681
  * Исходящий звонок был принят кем-то
682
682
  * @param userId
683
683
  */
684
- onAcceptedCall?: (userId: ExternalParticipantId, capabilities: ParticipantCapabilities) => void;
684
+ onAcceptedCall?: (userId: ExternalParticipantId, capabilities: ParticipantCapabilities, conversationId?: string) => void;
685
685
  /**
686
686
  * Список устройств изменился
687
687
  */
@@ -859,6 +859,14 @@ export type ParamsObject = {
859
859
  * @param demoted участник разжалован
860
860
  */
861
861
  onPromoted?: (demoted: boolean) => void;
862
+ /**
863
+ * Входящий звонок получен во время активного звонка
864
+ *
865
+ * @param conversationId ID звонка
866
+ * @param externalId Внешний ID вызывающего
867
+ * @param mediaSettings Настройки медиа
868
+ */
869
+ onIncomingCall?: (conversationId: string, externalId: ExternalParticipantId | undefined, mediaSettings: MediaSettings | undefined) => void;
862
870
  /**
863
871
  * Собеседник подключился к сигналлингу
864
872
  */