@stream-io/video-client 0.5.7 → 0.5.9

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.
@@ -1,7 +1,7 @@
1
1
  import { Publisher, SfuEventKinds, SfuEventListener, Subscriber } from './rtc';
2
2
  import { TrackType } from './gen/video/sfu/models/models';
3
3
  import { CallState } from './store';
4
- import { AcceptCallResponse, BlockUserResponse, EndCallResponse, GetCallResponse, GetOrCreateCallRequest, GetOrCreateCallResponse, GoLiveRequest, GoLiveResponse, ListRecordingsResponse, MuteUsersResponse, PinRequest, PinResponse, QueryMembersRequest, QueryMembersResponse, RejectCallResponse, RequestPermissionRequest, RequestPermissionResponse, SendEventResponse, SendReactionRequest, SendReactionResponse, StartHLSBroadcastingResponse, StartRecordingResponse, StopHLSBroadcastingResponse, StopLiveResponse, StopRecordingResponse, UnblockUserResponse, UnpinRequest, UnpinResponse, UpdateCallMembersRequest, UpdateCallMembersResponse, UpdateCallRequest, UpdateCallResponse, UpdateUserPermissionsRequest, UpdateUserPermissionsResponse } from './gen/coordinator';
4
+ import { AcceptCallResponse, BlockUserResponse, EndCallResponse, GetCallResponse, GetOrCreateCallRequest, GetOrCreateCallResponse, GoLiveRequest, GoLiveResponse, ListRecordingsResponse, MuteUsersResponse, PinRequest, PinResponse, QueryMembersRequest, QueryMembersResponse, RejectCallResponse, RequestPermissionRequest, RequestPermissionResponse, SendEventResponse, SendReactionRequest, SendReactionResponse, StartHLSBroadcastingResponse, StartRecordingRequest, StartRecordingResponse, StopHLSBroadcastingResponse, StopLiveResponse, StopRecordingResponse, UnblockUserResponse, UnpinRequest, UnpinResponse, UpdateCallMembersRequest, UpdateCallMembersResponse, UpdateCallRequest, UpdateCallResponse, UpdateUserPermissionsRequest, UpdateUserPermissionsResponse } from './gen/coordinator';
5
5
  import { AudioTrackType, CallConstructor, CallLeaveOptions, DebounceType, JoinCallData, PublishOptions, SubscriptionChanges, TrackMuteType, VideoTrackType } from './types';
6
6
  import { VideoLayerSetting } from './gen/video/sfu/event/events';
7
7
  import { DynascaleManager } from './helpers/DynascaleManager';
@@ -315,7 +315,7 @@ export declare class Call {
315
315
  /**
316
316
  * Starts recording the call
317
317
  */
318
- startRecording: () => Promise<StartRecordingResponse>;
318
+ startRecording: (request?: StartRecordingRequest) => Promise<StartRecordingResponse>;
319
319
  /**
320
320
  * Stops recording the call
321
321
  */
@@ -1,6 +1,6 @@
1
1
  import { StreamVideoClient } from './StreamVideoClient';
2
2
  import { StreamClientOptions } from './coordinator/connection/types';
3
- import { CreateCallTypeRequest, CreateCallTypeResponse, GetCallTypeResponse, ListCallTypeResponse, UpdateCallTypeRequest, UpdateCallTypeResponse } from './gen/coordinator';
3
+ import { CheckExternalStorageResponse, CreateCallTypeRequest, CreateCallTypeResponse, CreateExternalStorageRequest, CreateExternalStorageResponse, DeleteExternalStorageResponse, GetCallTypeResponse, ListCallTypeResponse, ListExternalStorageResponse, UpdateCallTypeRequest, UpdateCallTypeResponse, UpdateExternalStorageRequest, UpdateExternalStorageResponse } from './gen/coordinator';
4
4
  /**
5
5
  * @deprecated Please use the `@stream-io/node-sdk` package instead.
6
6
  *
@@ -25,4 +25,9 @@ export declare class StreamVideoServerClient extends StreamVideoClient {
25
25
  createCallType: (data: CreateCallTypeRequest) => Promise<CreateCallTypeResponse>;
26
26
  deleteCallType: (name: string) => Promise<void>;
27
27
  updateCallType: (name: string, data: UpdateCallTypeRequest) => Promise<UpdateCallTypeResponse>;
28
+ listExternalStorage: () => Promise<ListExternalStorageResponse>;
29
+ createExternalStorage: (request: CreateExternalStorageRequest) => Promise<CreateExternalStorageResponse>;
30
+ deleteExternalStorage: (name: string) => Promise<DeleteExternalStorageResponse>;
31
+ updateExternalStorage: (name: string, request: UpdateExternalStorageRequest) => Promise<UpdateExternalStorageResponse>;
32
+ checkExternalStorage: (name: string) => Promise<CheckExternalStorageResponse>;
28
33
  }
@@ -15,6 +15,10 @@ export declare abstract class InputMediaDeviceManager<T extends InputMediaDevice
15
15
  * @internal
16
16
  */
17
17
  disablePromise?: Promise<void>;
18
+ /**
19
+ * if true, stops the media stream when call is left
20
+ */
21
+ stopOnLeave: boolean;
18
22
  logger: Logger;
19
23
  private subscriptions;
20
24
  private isTrackStoppedDueToTrackEnd;
@@ -32,9 +36,10 @@ export declare abstract class InputMediaDeviceManager<T extends InputMediaDevice
32
36
  */
33
37
  enable(): Promise<void>;
34
38
  /**
35
- * Stops the stream.
39
+ * Stops or pauses the stream based on state.disableMode
40
+ * @param {boolean} [forceStop=false] when true, stops the tracks regardless of the state.disableMode
36
41
  */
37
- disable(): Promise<void>;
42
+ disable(forceStop?: boolean): Promise<void>;
38
43
  /**
39
44
  * If status was previously enabled, it will re-enable the device.
40
45
  */
@@ -2516,6 +2516,12 @@ export interface GetOrCreateCallResponse {
2516
2516
  * @interface GoLiveRequest
2517
2517
  */
2518
2518
  export interface GoLiveRequest {
2519
+ /**
2520
+ *
2521
+ * @type {string}
2522
+ * @memberof GoLiveRequest
2523
+ */
2524
+ recording_storage_name?: string;
2519
2525
  /**
2520
2526
  *
2521
2527
  * @type {boolean}
@@ -3840,6 +3846,19 @@ export interface StartHLSBroadcastingResponse {
3840
3846
  */
3841
3847
  playlist_url: string;
3842
3848
  }
3849
+ /**
3850
+ *
3851
+ * @export
3852
+ * @interface StartRecordingRequest
3853
+ */
3854
+ export interface StartRecordingRequest {
3855
+ /**
3856
+ *
3857
+ * @type {string}
3858
+ * @memberof StartRecordingRequest
3859
+ */
3860
+ recording_external_storage?: string;
3861
+ }
3843
3862
  /**
3844
3863
  *
3845
3864
  * @export
@@ -4731,3 +4750,279 @@ export interface WSClientEvent {
4731
4750
  */
4732
4751
  connection_id?: string;
4733
4752
  }
4753
+ /**
4754
+ *
4755
+ * @export
4756
+ * @interface AzureRequest
4757
+ */
4758
+ export interface AzureRequest {
4759
+ /**
4760
+ *
4761
+ * @type {string}
4762
+ * @memberof AzureRequest
4763
+ */
4764
+ abs_account_name: string;
4765
+ /**
4766
+ *
4767
+ * @type {string}
4768
+ * @memberof AzureRequest
4769
+ */
4770
+ abs_client_id: string;
4771
+ /**
4772
+ *
4773
+ * @type {string}
4774
+ * @memberof AzureRequest
4775
+ */
4776
+ abs_client_secret: string;
4777
+ /**
4778
+ *
4779
+ * @type {string}
4780
+ * @memberof AzureRequest
4781
+ */
4782
+ abs_tenant_id: string;
4783
+ }
4784
+ /**
4785
+ *
4786
+ * @export
4787
+ * @interface CheckExternalStorageResponse
4788
+ */
4789
+ export interface CheckExternalStorageResponse {
4790
+ /**
4791
+ * Duration of the request in human-readable format
4792
+ * @type {string}
4793
+ * @memberof CheckExternalStorageResponse
4794
+ */
4795
+ duration: string;
4796
+ }
4797
+ /**
4798
+ *
4799
+ * @export
4800
+ * @interface CreateExternalStorageRequest
4801
+ */
4802
+ export interface CreateExternalStorageRequest {
4803
+ /**
4804
+ *
4805
+ * @type {S3Request}
4806
+ * @memberof CreateExternalStorageRequest
4807
+ */
4808
+ aws_s3?: S3Request;
4809
+ /**
4810
+ *
4811
+ * @type {AzureRequest}
4812
+ * @memberof CreateExternalStorageRequest
4813
+ */
4814
+ azure_blob?: AzureRequest;
4815
+ /**
4816
+ *
4817
+ * @type {string}
4818
+ * @memberof CreateExternalStorageRequest
4819
+ */
4820
+ bucket: string;
4821
+ /**
4822
+ *
4823
+ * @type {string}
4824
+ * @memberof CreateExternalStorageRequest
4825
+ */
4826
+ gcs_credentials?: string;
4827
+ /**
4828
+ *
4829
+ * @type {string}
4830
+ * @memberof CreateExternalStorageRequest
4831
+ */
4832
+ name: string;
4833
+ /**
4834
+ *
4835
+ * @type {string}
4836
+ * @memberof CreateExternalStorageRequest
4837
+ */
4838
+ path?: string;
4839
+ /**
4840
+ *
4841
+ * @type {string}
4842
+ * @memberof CreateExternalStorageRequest
4843
+ */
4844
+ storage_type: string;
4845
+ }
4846
+ /**
4847
+ *
4848
+ * @export
4849
+ * @interface CreateExternalStorageResponse
4850
+ */
4851
+ export interface CreateExternalStorageResponse {
4852
+ /**
4853
+ * Duration of the request in human-readable format
4854
+ * @type {string}
4855
+ * @memberof CreateExternalStorageResponse
4856
+ */
4857
+ duration: string;
4858
+ }
4859
+ /**
4860
+ *
4861
+ * @export
4862
+ * @interface DeleteExternalStorageResponse
4863
+ */
4864
+ export interface DeleteExternalStorageResponse {
4865
+ /**
4866
+ * Duration of the request in human-readable format
4867
+ * @type {string}
4868
+ * @memberof DeleteExternalStorageResponse
4869
+ */
4870
+ duration: string;
4871
+ }
4872
+ /**
4873
+ *
4874
+ * @export
4875
+ * @interface ExternalStorageResponse
4876
+ */
4877
+ export interface ExternalStorageResponse {
4878
+ /**
4879
+ *
4880
+ * @type {string}
4881
+ * @memberof ExternalStorageResponse
4882
+ */
4883
+ bucket: string;
4884
+ /**
4885
+ *
4886
+ * @type {string}
4887
+ * @memberof ExternalStorageResponse
4888
+ */
4889
+ name: string;
4890
+ /**
4891
+ *
4892
+ * @type {string}
4893
+ * @memberof ExternalStorageResponse
4894
+ */
4895
+ path: string;
4896
+ /**
4897
+ *
4898
+ * @type {string}
4899
+ * @memberof ExternalStorageResponse
4900
+ */
4901
+ type: string;
4902
+ }
4903
+ /**
4904
+ *
4905
+ * @export
4906
+ * @interface ListExternalStorageResponse
4907
+ */
4908
+ export interface ListExternalStorageResponse {
4909
+ /**
4910
+ * Duration of the request in human-readable format
4911
+ * @type {string}
4912
+ * @memberof ListExternalStorageResponse
4913
+ */
4914
+ duration: string;
4915
+ /**
4916
+ *
4917
+ * @type {{ [key: string]: ExternalStorageResponse; }}
4918
+ * @memberof ListExternalStorageResponse
4919
+ */
4920
+ external_storages: {
4921
+ [key: string]: ExternalStorageResponse;
4922
+ };
4923
+ }
4924
+ /**
4925
+ *
4926
+ * @export
4927
+ * @interface S3Request
4928
+ */
4929
+ export interface S3Request {
4930
+ /**
4931
+ *
4932
+ * @type {string}
4933
+ * @memberof S3Request
4934
+ */
4935
+ s3_api_key?: string;
4936
+ /**
4937
+ *
4938
+ * @type {string}
4939
+ * @memberof S3Request
4940
+ */
4941
+ s3_region: string;
4942
+ /**
4943
+ *
4944
+ * @type {string}
4945
+ * @memberof S3Request
4946
+ */
4947
+ s3_secret?: string;
4948
+ }
4949
+ /**
4950
+ *
4951
+ * @export
4952
+ * @interface UpdateExternalStorageResponse
4953
+ */
4954
+ export interface UpdateExternalStorageResponse {
4955
+ /**
4956
+ *
4957
+ * @type {string}
4958
+ * @memberof UpdateExternalStorageResponse
4959
+ */
4960
+ bucket: string;
4961
+ /**
4962
+ * Duration of the request in human-readable format
4963
+ * @type {string}
4964
+ * @memberof UpdateExternalStorageResponse
4965
+ */
4966
+ duration: string;
4967
+ /**
4968
+ *
4969
+ * @type {string}
4970
+ * @memberof UpdateExternalStorageResponse
4971
+ */
4972
+ name: string;
4973
+ /**
4974
+ *
4975
+ * @type {string}
4976
+ * @memberof UpdateExternalStorageResponse
4977
+ */
4978
+ path: string;
4979
+ /**
4980
+ *
4981
+ * @type {string}
4982
+ * @memberof UpdateExternalStorageResponse
4983
+ */
4984
+ type: string;
4985
+ }
4986
+ /**
4987
+ *
4988
+ * @export
4989
+ * @interface UpdateExternalStorageRequest
4990
+ */
4991
+ export interface UpdateExternalStorageRequest {
4992
+ /**
4993
+ *
4994
+ * @type {S3Request}
4995
+ * @memberof UpdateExternalStorageRequest
4996
+ */
4997
+ aws_s3?: S3Request;
4998
+ /**
4999
+ *
5000
+ * @type {AzureRequest}
5001
+ * @memberof UpdateExternalStorageRequest
5002
+ */
5003
+ azure_blob?: AzureRequest;
5004
+ /**
5005
+ *
5006
+ * @type {string}
5007
+ * @memberof UpdateExternalStorageRequest
5008
+ */
5009
+ bucket: string;
5010
+ /**
5011
+ *
5012
+ * @type {string}
5013
+ * @memberof UpdateExternalStorageRequest
5014
+ */
5015
+ gcs_credentials?: string;
5016
+ /**
5017
+ *
5018
+ * @type {string}
5019
+ * @memberof UpdateExternalStorageRequest
5020
+ */
5021
+ path?: string;
5022
+ /**
5023
+ *
5024
+ * @type {string}
5025
+ * @memberof UpdateExternalStorageRequest
5026
+ */
5027
+ storage_type: string;
5028
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stream-io/video-client",
3
- "version": "0.5.7",
3
+ "version": "0.5.9",
4
4
  "packageManager": "yarn@3.2.4",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.es.js",
package/src/Call.ts CHANGED
@@ -47,6 +47,7 @@ import {
47
47
  SendReactionResponse,
48
48
  SFUResponse,
49
49
  StartHLSBroadcastingResponse,
50
+ StartRecordingRequest,
50
51
  StartRecordingResponse,
51
52
  StopHLSBroadcastingResponse,
52
53
  StopLiveResponse,
@@ -511,6 +512,18 @@ export class Call {
511
512
  this.microphone.removeSubscriptions();
512
513
  this.screenShare.removeSubscriptions();
513
514
  this.speaker.removeSubscriptions();
515
+
516
+ const stopOnLeavePromises: Promise<void>[] = [];
517
+ if (this.camera.stopOnLeave) {
518
+ stopOnLeavePromises.push(this.camera.disable(true));
519
+ }
520
+ if (this.microphone.stopOnLeave) {
521
+ stopOnLeavePromises.push(this.microphone.disable(true));
522
+ }
523
+ if (this.screenShare.stopOnLeave) {
524
+ stopOnLeavePromises.push(this.screenShare.disable(true));
525
+ }
526
+ await Promise.all(stopOnLeavePromises);
514
527
  };
515
528
 
516
529
  /**
@@ -1535,11 +1548,11 @@ export class Call {
1535
1548
  /**
1536
1549
  * Starts recording the call
1537
1550
  */
1538
- startRecording = async () => {
1539
- return this.streamClient.post<StartRecordingResponse>(
1540
- `${this.streamClientBasePath}/start_recording`,
1541
- {},
1542
- );
1551
+ startRecording = async (request?: StartRecordingRequest) => {
1552
+ return this.streamClient.post<
1553
+ StartRecordingResponse,
1554
+ StartRecordingRequest
1555
+ >(`${this.streamClientBasePath}/start_recording`, request ? request : {});
1543
1556
  };
1544
1557
 
1545
1558
  /**
@@ -1,12 +1,19 @@
1
1
  import { StreamVideoClient } from './StreamVideoClient';
2
2
  import { StreamClientOptions } from './coordinator/connection/types';
3
3
  import {
4
+ CheckExternalStorageResponse,
4
5
  CreateCallTypeRequest,
5
6
  CreateCallTypeResponse,
7
+ CreateExternalStorageRequest,
8
+ CreateExternalStorageResponse,
9
+ DeleteExternalStorageResponse,
6
10
  GetCallTypeResponse,
7
11
  ListCallTypeResponse,
12
+ ListExternalStorageResponse,
8
13
  UpdateCallTypeRequest,
9
14
  UpdateCallTypeResponse,
15
+ UpdateExternalStorageRequest,
16
+ UpdateExternalStorageResponse,
10
17
  } from './gen/coordinator';
11
18
 
12
19
  /**
@@ -61,4 +68,39 @@ export class StreamVideoServerClient extends StreamVideoClient {
61
68
  data,
62
69
  );
63
70
  };
71
+
72
+ listExternalStorage = () => {
73
+ return this.streamClient.get<ListExternalStorageResponse>(
74
+ '/external_storage',
75
+ );
76
+ };
77
+
78
+ createExternalStorage = (request: CreateExternalStorageRequest) => {
79
+ return this.streamClient.post<
80
+ CreateExternalStorageResponse,
81
+ CreateExternalStorageRequest
82
+ >('/external_storage', request);
83
+ };
84
+
85
+ deleteExternalStorage = (name: string) => {
86
+ return this.streamClient.delete<DeleteExternalStorageResponse>(
87
+ `/external_storage/${name}`,
88
+ );
89
+ };
90
+
91
+ updateExternalStorage = (
92
+ name: string,
93
+ request: UpdateExternalStorageRequest,
94
+ ) => {
95
+ return this.streamClient.put<
96
+ UpdateExternalStorageResponse,
97
+ UpdateExternalStorageRequest
98
+ >(`/external_storage/${name}`, request);
99
+ };
100
+
101
+ checkExternalStorage = (name: string) => {
102
+ return this.streamClient.get<CheckExternalStorageResponse>(
103
+ `/external_storage/${name}/check`,
104
+ );
105
+ };
64
106
  }
@@ -20,6 +20,10 @@ export abstract class InputMediaDeviceManager<
20
20
  * @internal
21
21
  */
22
22
  disablePromise?: Promise<void>;
23
+ /**
24
+ * if true, stops the media stream when call is left
25
+ */
26
+ stopOnLeave = true;
23
27
  logger: Logger;
24
28
  private subscriptions: Subscription[] = [];
25
29
  private isTrackStoppedDueToTrackEnd = false;
@@ -67,12 +71,13 @@ export abstract class InputMediaDeviceManager<
67
71
  }
68
72
 
69
73
  /**
70
- * Stops the stream.
74
+ * Stops or pauses the stream based on state.disableMode
75
+ * @param {boolean} [forceStop=false] when true, stops the tracks regardless of the state.disableMode
71
76
  */
72
- async disable() {
77
+ async disable(forceStop: boolean = false) {
73
78
  this.state.prevStatus = this.state.status;
74
- if (this.state.status === 'disabled') return;
75
- const stopTracks = this.state.disableMode === 'stop-tracks';
79
+ if (!forceStop && this.state.status === 'disabled') return;
80
+ const stopTracks = forceStop || this.state.disableMode === 'stop-tracks';
76
81
  this.disablePromise = this.muteStream(stopTracks);
77
82
  try {
78
83
  await this.disablePromise;
@@ -123,6 +123,19 @@ describe('InputMediaDeviceManager.test', () => {
123
123
  expect(manager.stopPublishStream).toHaveBeenCalledWith(true);
124
124
  });
125
125
 
126
+ it('disable device with forceStop', async () => {
127
+ manager['call'].state.setCallingState(CallingState.JOINED);
128
+ await manager.enable();
129
+
130
+ expect(manager.state.mediaStream).toBeDefined();
131
+
132
+ await manager.disable(true);
133
+
134
+ expect(manager.stopPublishStream).toHaveBeenCalledWith(true);
135
+ expect(manager.state.mediaStream).toBeUndefined();
136
+ expect(manager.state.status).toBe('disabled');
137
+ });
138
+
126
139
  it('toggle device', async () => {
127
140
  vi.spyOn(manager, 'disable');
128
141
  vi.spyOn(manager, 'enable');
@@ -113,6 +113,20 @@ describe('MicrophoneManager', () => {
113
113
  expect(manager.state.mediaStream!.getAudioTracks()[0].enabled).toBe(false);
114
114
  });
115
115
 
116
+ it('disable mic with forceStop should remove the stream', async () => {
117
+ await manager.enable();
118
+
119
+ expect(manager.state.mediaStream!.getAudioTracks()[0].enabled).toBe(true);
120
+
121
+ await manager.disable();
122
+
123
+ expect(manager.state.mediaStream!.getAudioTracks()[0].enabled).toBe(false);
124
+
125
+ await manager.disable(true);
126
+
127
+ expect(manager.state.mediaStream).toBeUndefined();
128
+ });
129
+
116
130
  it(`should start sound detection if mic is disabled`, async () => {
117
131
  await manager.enable();
118
132
  // @ts-expect-error
@@ -50,7 +50,7 @@ export const watchCallRejected = (call: Call) => {
50
50
  const { members, callingState } = call.state;
51
51
  if (callingState !== CallingState.RINGING) {
52
52
  call.logger(
53
- 'warn',
53
+ 'info',
54
54
  'Call is not in ringing mode (it is either accepted or rejected already). Ignoring call.rejected event.',
55
55
  event,
56
56
  );