@stream-io/video-client 0.0.2-alpha.2 → 0.0.2-alpha.20

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.
@@ -14,6 +14,7 @@ import {
14
14
  CallRecording,
15
15
  CallResponse,
16
16
  MemberResponse,
17
+ OwnCapability,
17
18
  PermissionRequestEvent,
18
19
  } from '../gen/coordinator';
19
20
  import { TrackType } from '../gen/video/sfu/models/models';
@@ -91,6 +92,13 @@ export class CallState {
91
92
  */
92
93
  private membersSubject = new BehaviorSubject<MemberResponse[]>([]);
93
94
 
95
+ /**
96
+ * The list of capabilities of the current user.
97
+ *
98
+ * @private
99
+ */
100
+ private ownCapabilitiesSubject = new BehaviorSubject<OwnCapability[]>([]);
101
+
94
102
  /**
95
103
  * The calling state.
96
104
  *
@@ -249,6 +257,11 @@ export class CallState {
249
257
  */
250
258
  members$: Observable<MemberResponse[]>;
251
259
 
260
+ /**
261
+ * The list of capabilities of the current user.
262
+ */
263
+ ownCapabilities$: Observable<OwnCapability[]>;
264
+
252
265
  /**
253
266
  * The calling state.
254
267
  */
@@ -307,6 +320,7 @@ export class CallState {
307
320
  this.callRecordingList$ = this.callRecordingListSubject.asObservable();
308
321
  this.metadata$ = this.metadataSubject.asObservable();
309
322
  this.members$ = this.membersSubject.asObservable();
323
+ this.ownCapabilities$ = this.ownCapabilitiesSubject.asObservable();
310
324
  this.callingState$ = this.callingStateSubject.asObservable();
311
325
  }
312
326
 
@@ -555,6 +569,23 @@ export class CallState {
555
569
  this.setCurrentValue(this.membersSubject, members);
556
570
  };
557
571
 
572
+ /**
573
+ * The capabilities of the current user for the current call.
574
+ */
575
+ get ownCapabilities() {
576
+ return this.getCurrentValue(this.ownCapabilities$);
577
+ }
578
+
579
+ /**
580
+ * Sets the own capabilities.
581
+ *
582
+ * @internal
583
+ * @param capabilities the capabilities to set.
584
+ */
585
+ setOwnCapabilities = (capabilities: Patch<OwnCapability[]>) => {
586
+ return this.setCurrentValue(this.ownCapabilitiesSubject, capabilities);
587
+ };
588
+
558
589
  /**
559
590
  * Will try to find the participant with the given sessionId in the current call.
560
591
  *
@@ -137,6 +137,16 @@ export class StreamVideoWriteableStateStore {
137
137
  return this.setCalls((calls) => calls.filter((c) => c !== call));
138
138
  };
139
139
 
140
+ /**
141
+ * Finds a {@link Call} object in the list of {@link Call} objects created/tracked by this client.
142
+ *
143
+ * @param type the type of call to find.
144
+ * @param id the id of the call to find.
145
+ */
146
+ findCall = (type: string, id: string) => {
147
+ return this.calls.find((c) => c.type === type && c.id === id);
148
+ };
149
+
140
150
  /**
141
151
  * A list of objects describing incoming calls.
142
152
  * @deprecated derive from calls$ instead.
package/src/types.ts CHANGED
@@ -6,6 +6,7 @@ import type {
6
6
  CallResponse,
7
7
  JoinCallRequest,
8
8
  MemberResponse,
9
+ OwnCapability,
9
10
  ReactionResponse,
10
11
  } from './gen/coordinator';
11
12
  import type { StreamClient } from './coordinator/connection/client';
@@ -184,6 +185,13 @@ export type CallConstructor = {
184
185
  */
185
186
  members?: MemberResponse[];
186
187
 
188
+ /**
189
+ * An optional list of {@link OwnCapability} coming from the backed.
190
+ * If provided, the call will be initialized with the data from this object.
191
+ * This is useful when initializing a new "pending call" from an event.
192
+ */
193
+ ownCapabilities?: OwnCapability[];
194
+
187
195
  /**
188
196
  * Flags the call as a ringing call.
189
197
  * @default false