@stream-io/video-client 1.44.3 → 1.44.4
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/CHANGELOG.md +8 -0
- package/dist/index.browser.es.js +27 -31
- package/dist/index.browser.es.js.map +1 -1
- package/dist/index.cjs.js +27 -31
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +27 -31
- package/dist/index.es.js.map +1 -1
- package/dist/src/devices/BrowserPermission.d.ts +2 -0
- package/dist/src/devices/CameraManagerState.d.ts +2 -1
- package/dist/src/devices/MicrophoneManagerState.d.ts +2 -1
- package/dist/src/devices/devices.d.ts +2 -2
- package/package.json +2 -2
- package/src/devices/BrowserPermission.ts +5 -0
- package/src/devices/CameraManager.ts +6 -1
- package/src/devices/CameraManagerState.ts +3 -2
- package/src/devices/MicrophoneManager.ts +1 -2
- package/src/devices/MicrophoneManagerState.ts +3 -2
- package/src/devices/devices.ts +25 -31
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { Tracer } from '../stats';
|
|
1
2
|
interface BrowserPermissionConfig {
|
|
2
3
|
constraints: DisplayMediaStreamOptions;
|
|
3
4
|
queryName: PermissionName;
|
|
5
|
+
tracer: Tracer | undefined;
|
|
4
6
|
}
|
|
5
7
|
export type BrowserPermissionState = PermissionState | 'prompting';
|
|
6
8
|
export declare class BrowserPermission {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DeviceManagerState } from './DeviceManagerState';
|
|
2
|
+
import { Tracer } from '../stats';
|
|
2
3
|
export type CameraDirection = 'front' | 'back' | undefined;
|
|
3
4
|
export declare class CameraManagerState extends DeviceManagerState {
|
|
4
5
|
private directionSubject;
|
|
@@ -8,7 +9,7 @@ export declare class CameraManagerState extends DeviceManagerState {
|
|
|
8
9
|
* back - means the camera facing the environment
|
|
9
10
|
*/
|
|
10
11
|
direction$: import("rxjs").Observable<CameraDirection>;
|
|
11
|
-
constructor();
|
|
12
|
+
constructor(tracer: Tracer | undefined);
|
|
12
13
|
/**
|
|
13
14
|
* The preferred camera direction
|
|
14
15
|
* front - means the camera facing the user
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { TrackDisableMode } from './DeviceManagerState';
|
|
2
2
|
import { AudioDeviceManagerState } from './AudioDeviceManagerState';
|
|
3
|
+
import { Tracer } from '../stats';
|
|
3
4
|
export declare class MicrophoneManagerState extends AudioDeviceManagerState<MediaTrackConstraints> {
|
|
4
5
|
private speakingWhileMutedSubject;
|
|
5
6
|
/**
|
|
6
7
|
* An Observable that emits `true` if the user's microphone is muted, but they're speaking.
|
|
7
8
|
*/
|
|
8
9
|
speakingWhileMuted$: import("rxjs").Observable<boolean>;
|
|
9
|
-
constructor(disableMode: TrackDisableMode);
|
|
10
|
+
constructor(disableMode: TrackDisableMode, tracer: Tracer | undefined);
|
|
10
11
|
/**
|
|
11
12
|
* `true` if the user's microphone is muted but they're speaking.
|
|
12
13
|
*/
|
|
@@ -9,12 +9,12 @@ export declare const checkIfAudioOutputChangeSupported: () => boolean;
|
|
|
9
9
|
* Keeps track of the browser permission to use microphone. This permission also
|
|
10
10
|
* affects an ability to enumerate audio devices.
|
|
11
11
|
*/
|
|
12
|
-
export declare const getAudioBrowserPermission: (...args:
|
|
12
|
+
export declare const getAudioBrowserPermission: (...args: (Tracer | undefined)[]) => BrowserPermission;
|
|
13
13
|
/**
|
|
14
14
|
* Keeps track of the browser permission to use camera. This permission also
|
|
15
15
|
* affects an ability to enumerate video devices.
|
|
16
16
|
*/
|
|
17
|
-
export declare const getVideoBrowserPermission: (...args:
|
|
17
|
+
export declare const getVideoBrowserPermission: (...args: (Tracer | undefined)[]) => BrowserPermission;
|
|
18
18
|
/**
|
|
19
19
|
* Prompts the user for a permission to use audio devices (if not already granted
|
|
20
20
|
* and was not prompted before) and lists the available 'audioinput' devices,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stream-io/video-client",
|
|
3
|
-
"version": "1.44.
|
|
3
|
+
"version": "1.44.4",
|
|
4
4
|
"main": "dist/index.cjs.js",
|
|
5
5
|
"module": "dist/index.es.js",
|
|
6
6
|
"browser": "dist/index.browser.es.js",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"@openapitools/openapi-generator-cli": "^2.25.0",
|
|
47
47
|
"@rollup/plugin-replace": "^6.0.2",
|
|
48
48
|
"@rollup/plugin-typescript": "^12.1.4",
|
|
49
|
-
"@stream-io/audio-filters-web": "^0.7.
|
|
49
|
+
"@stream-io/audio-filters-web": "^0.7.3",
|
|
50
50
|
"@stream-io/node-sdk": "^0.7.28",
|
|
51
51
|
"@total-typescript/shoehorn": "^0.1.2",
|
|
52
52
|
"@types/sdp-transform": "^2.15.0",
|
|
@@ -3,10 +3,12 @@ import { isReactNative } from '../helpers/platforms';
|
|
|
3
3
|
import { disposeOfMediaStream } from './utils';
|
|
4
4
|
import { withoutConcurrency } from '../helpers/concurrency';
|
|
5
5
|
import { videoLoggerSystem } from '../logger';
|
|
6
|
+
import { Tracer } from '../stats';
|
|
6
7
|
|
|
7
8
|
interface BrowserPermissionConfig {
|
|
8
9
|
constraints: DisplayMediaStreamOptions;
|
|
9
10
|
queryName: PermissionName;
|
|
11
|
+
tracer: Tracer | undefined;
|
|
10
12
|
}
|
|
11
13
|
|
|
12
14
|
export type BrowserPermissionState = PermissionState | 'prompting';
|
|
@@ -162,6 +164,9 @@ export class BrowserPermission {
|
|
|
162
164
|
|
|
163
165
|
private setState(state: BrowserPermissionState) {
|
|
164
166
|
if (this.state !== state) {
|
|
167
|
+
const { tracer, queryName } = this.permission;
|
|
168
|
+
const traceKey = `navigator.mediaDevices.${queryName}.permission`;
|
|
169
|
+
tracer?.trace(traceKey, { previous: this.state, state });
|
|
165
170
|
this.state = state;
|
|
166
171
|
this.listeners.forEach((listener) => listener(state));
|
|
167
172
|
}
|
|
@@ -25,7 +25,12 @@ export class CameraManager extends DeviceManager<CameraManagerState> {
|
|
|
25
25
|
call: Call,
|
|
26
26
|
devicePersistence: Required<DevicePersistenceOptions>,
|
|
27
27
|
) {
|
|
28
|
-
super(
|
|
28
|
+
super(
|
|
29
|
+
call,
|
|
30
|
+
new CameraManagerState(call.tracer),
|
|
31
|
+
TrackType.VIDEO,
|
|
32
|
+
devicePersistence,
|
|
33
|
+
);
|
|
29
34
|
}
|
|
30
35
|
|
|
31
36
|
private isDirectionSupportedByDevice() {
|
|
@@ -3,6 +3,7 @@ import { DeviceManagerState } from './DeviceManagerState';
|
|
|
3
3
|
import { isReactNative } from '../helpers/platforms';
|
|
4
4
|
import { getVideoBrowserPermission } from './devices';
|
|
5
5
|
import { RxUtils } from '../store';
|
|
6
|
+
import { Tracer } from '../stats';
|
|
6
7
|
|
|
7
8
|
export type CameraDirection = 'front' | 'back' | undefined;
|
|
8
9
|
|
|
@@ -18,8 +19,8 @@ export class CameraManagerState extends DeviceManagerState {
|
|
|
18
19
|
.asObservable()
|
|
19
20
|
.pipe(distinctUntilChanged());
|
|
20
21
|
|
|
21
|
-
constructor() {
|
|
22
|
-
super('stop-tracks', getVideoBrowserPermission());
|
|
22
|
+
constructor(tracer: Tracer | undefined) {
|
|
23
|
+
super('stop-tracks', getVideoBrowserPermission(tracer));
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
/**
|
|
@@ -51,7 +51,7 @@ export class MicrophoneManager extends AudioDeviceManager<MicrophoneManagerState
|
|
|
51
51
|
) {
|
|
52
52
|
super(
|
|
53
53
|
call,
|
|
54
|
-
new MicrophoneManagerState(disableMode),
|
|
54
|
+
new MicrophoneManagerState(disableMode, call.tracer),
|
|
55
55
|
TrackType.AUDIO,
|
|
56
56
|
devicePersistence,
|
|
57
57
|
);
|
|
@@ -169,7 +169,6 @@ export class MicrophoneManager extends AudioDeviceManager<MicrophoneManagerState
|
|
|
169
169
|
deviceId,
|
|
170
170
|
label,
|
|
171
171
|
};
|
|
172
|
-
console.log(event);
|
|
173
172
|
this.call.tracer.trace('mic.capture_report', event);
|
|
174
173
|
this.call.streamClient.dispatchEvent(event);
|
|
175
174
|
},
|
|
@@ -4,6 +4,7 @@ import { TrackDisableMode } from './DeviceManagerState';
|
|
|
4
4
|
import { AudioDeviceManagerState } from './AudioDeviceManagerState';
|
|
5
5
|
import { getAudioBrowserPermission, resolveDeviceId } from './devices';
|
|
6
6
|
import { AudioBitrateProfile } from '../gen/video/sfu/models/models';
|
|
7
|
+
import { Tracer } from '../stats';
|
|
7
8
|
|
|
8
9
|
export class MicrophoneManagerState extends AudioDeviceManagerState<MediaTrackConstraints> {
|
|
9
10
|
private speakingWhileMutedSubject = new BehaviorSubject<boolean>(false);
|
|
@@ -15,10 +16,10 @@ export class MicrophoneManagerState extends AudioDeviceManagerState<MediaTrackCo
|
|
|
15
16
|
.asObservable()
|
|
16
17
|
.pipe(distinctUntilChanged());
|
|
17
18
|
|
|
18
|
-
constructor(disableMode: TrackDisableMode) {
|
|
19
|
+
constructor(disableMode: TrackDisableMode, tracer: Tracer | undefined) {
|
|
19
20
|
super(
|
|
20
21
|
disableMode,
|
|
21
|
-
getAudioBrowserPermission(),
|
|
22
|
+
getAudioBrowserPermission(tracer),
|
|
22
23
|
AudioBitrateProfile.VOICE_STANDARD_UNSPECIFIED,
|
|
23
24
|
);
|
|
24
25
|
}
|
package/src/devices/devices.ts
CHANGED
|
@@ -93,10 +93,11 @@ const videoDeviceConstraints = {
|
|
|
93
93
|
* affects an ability to enumerate audio devices.
|
|
94
94
|
*/
|
|
95
95
|
export const getAudioBrowserPermission = lazy(
|
|
96
|
-
() =>
|
|
96
|
+
(tracer: Tracer | undefined) =>
|
|
97
97
|
new BrowserPermission({
|
|
98
98
|
constraints: audioDeviceConstraints,
|
|
99
99
|
queryName: 'microphone' as PermissionName,
|
|
100
|
+
tracer,
|
|
100
101
|
}),
|
|
101
102
|
);
|
|
102
103
|
|
|
@@ -105,10 +106,11 @@ export const getAudioBrowserPermission = lazy(
|
|
|
105
106
|
* affects an ability to enumerate video devices.
|
|
106
107
|
*/
|
|
107
108
|
export const getVideoBrowserPermission = lazy(
|
|
108
|
-
() =>
|
|
109
|
+
(tracer: Tracer | undefined) =>
|
|
109
110
|
new BrowserPermission({
|
|
110
111
|
constraints: videoDeviceConstraints,
|
|
111
112
|
queryName: 'camera' as PermissionName,
|
|
113
|
+
tracer,
|
|
112
114
|
}),
|
|
113
115
|
);
|
|
114
116
|
|
|
@@ -132,11 +134,11 @@ const getDeviceChangeObserver = lazy((tracer: Tracer | undefined) => {
|
|
|
132
134
|
export const getAudioDevices = lazy((tracer?: Tracer) => {
|
|
133
135
|
return merge(
|
|
134
136
|
getDeviceChangeObserver(tracer),
|
|
135
|
-
getAudioBrowserPermission().asObservable(),
|
|
137
|
+
getAudioBrowserPermission(tracer).asObservable(),
|
|
136
138
|
).pipe(
|
|
137
139
|
startWith([]),
|
|
138
140
|
concatMap(() =>
|
|
139
|
-
getDevices(getAudioBrowserPermission(), 'audioinput', tracer),
|
|
141
|
+
getDevices(getAudioBrowserPermission(tracer), 'audioinput', tracer),
|
|
140
142
|
),
|
|
141
143
|
shareReplay(1),
|
|
142
144
|
);
|
|
@@ -151,11 +153,11 @@ export const getAudioDevices = lazy((tracer?: Tracer) => {
|
|
|
151
153
|
export const getVideoDevices = lazy((tracer?: Tracer) => {
|
|
152
154
|
return merge(
|
|
153
155
|
getDeviceChangeObserver(tracer),
|
|
154
|
-
getVideoBrowserPermission().asObservable(),
|
|
156
|
+
getVideoBrowserPermission(tracer).asObservable(),
|
|
155
157
|
).pipe(
|
|
156
158
|
startWith([]),
|
|
157
159
|
concatMap(() =>
|
|
158
|
-
getDevices(getVideoBrowserPermission(), 'videoinput', tracer),
|
|
160
|
+
getDevices(getVideoBrowserPermission(tracer), 'videoinput', tracer),
|
|
159
161
|
),
|
|
160
162
|
shareReplay(1),
|
|
161
163
|
);
|
|
@@ -170,11 +172,11 @@ export const getVideoDevices = lazy((tracer?: Tracer) => {
|
|
|
170
172
|
export const getAudioOutputDevices = lazy((tracer?: Tracer) => {
|
|
171
173
|
return merge(
|
|
172
174
|
getDeviceChangeObserver(tracer),
|
|
173
|
-
getAudioBrowserPermission().asObservable(),
|
|
175
|
+
getAudioBrowserPermission(tracer).asObservable(),
|
|
174
176
|
).pipe(
|
|
175
177
|
startWith([]),
|
|
176
178
|
concatMap(() =>
|
|
177
|
-
getDevices(getAudioBrowserPermission(), 'audiooutput', tracer),
|
|
179
|
+
getDevices(getAudioBrowserPermission(tracer), 'audiooutput', tracer),
|
|
178
180
|
),
|
|
179
181
|
shareReplay(1),
|
|
180
182
|
);
|
|
@@ -259,28 +261,24 @@ export const getAudioStream = async (
|
|
|
259
261
|
};
|
|
260
262
|
|
|
261
263
|
try {
|
|
262
|
-
await getAudioBrowserPermission().prompt({
|
|
264
|
+
await getAudioBrowserPermission(tracer).prompt({
|
|
263
265
|
throwOnNotAllowed: true,
|
|
264
266
|
forcePrompt: true,
|
|
265
267
|
});
|
|
266
268
|
return await getStream(constraints, tracer);
|
|
267
269
|
} catch (error) {
|
|
270
|
+
const logger = videoLoggerSystem.getLogger('devices');
|
|
268
271
|
if (isNotFoundOrOverconstrainedError(error) && trackConstraints?.deviceId) {
|
|
269
272
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
270
273
|
const { deviceId, ...relaxedConstraints } = trackConstraints;
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
{ error, constraints, relaxedConstraints },
|
|
276
|
-
);
|
|
274
|
+
logger.warn(
|
|
275
|
+
'Failed to get audio stream, will try again with relaxed constraints',
|
|
276
|
+
{ error, constraints, relaxedConstraints },
|
|
277
|
+
);
|
|
277
278
|
return getAudioStream(relaxedConstraints, tracer);
|
|
278
279
|
}
|
|
279
280
|
|
|
280
|
-
|
|
281
|
-
error,
|
|
282
|
-
constraints,
|
|
283
|
-
});
|
|
281
|
+
logger.error('Failed to get audio stream', { error, constraints });
|
|
284
282
|
throw error;
|
|
285
283
|
}
|
|
286
284
|
};
|
|
@@ -304,28 +302,24 @@ export const getVideoStream = async (
|
|
|
304
302
|
},
|
|
305
303
|
};
|
|
306
304
|
try {
|
|
307
|
-
await getVideoBrowserPermission().prompt({
|
|
305
|
+
await getVideoBrowserPermission(tracer).prompt({
|
|
308
306
|
throwOnNotAllowed: true,
|
|
309
307
|
forcePrompt: true,
|
|
310
308
|
});
|
|
311
309
|
return await getStream(constraints, tracer);
|
|
312
310
|
} catch (error) {
|
|
311
|
+
const logger = videoLoggerSystem.getLogger('devices');
|
|
313
312
|
if (isNotFoundOrOverconstrainedError(error) && trackConstraints?.deviceId) {
|
|
314
313
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
315
314
|
const { deviceId, ...relaxedConstraints } = trackConstraints;
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
);
|
|
322
|
-
return getVideoStream(relaxedConstraints);
|
|
315
|
+
logger.warn(
|
|
316
|
+
'Failed to get video stream, will try again with relaxed constraints',
|
|
317
|
+
{ error, constraints, relaxedConstraints },
|
|
318
|
+
);
|
|
319
|
+
return getVideoStream(relaxedConstraints, tracer);
|
|
323
320
|
}
|
|
324
321
|
|
|
325
|
-
|
|
326
|
-
error,
|
|
327
|
-
constraints,
|
|
328
|
-
});
|
|
322
|
+
logger.error('Failed to get video stream', { error, constraints });
|
|
329
323
|
throw error;
|
|
330
324
|
}
|
|
331
325
|
};
|