@fishjam-cloud/react-client 0.7.1 → 0.8.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.
- package/dist/DeviceManager.d.ts +25 -15
- package/dist/DeviceManager.d.ts.map +1 -1
- package/dist/DeviceManager.js +125 -79
- package/dist/devices/MiddlewareManager.d.ts +9 -0
- package/dist/devices/MiddlewareManager.d.ts.map +1 -0
- package/dist/devices/MiddlewareManager.js +26 -0
- package/dist/fishjamProvider.d.ts +5 -2
- package/dist/fishjamProvider.d.ts.map +1 -1
- package/dist/fishjamProvider.js +12 -4
- package/dist/hooks/deviceManagers/useDeviceManager.d.ts.map +1 -1
- package/dist/hooks/deviceManagers/useDeviceManager.js +2 -2
- package/dist/hooks/devices/useCamera.d.ts +7 -0
- package/dist/hooks/devices/useCamera.d.ts.map +1 -0
- package/dist/hooks/devices/useCamera.js +35 -0
- package/dist/hooks/devices/useInitializeDevices.d.ts +8 -0
- package/dist/hooks/devices/useInitializeDevices.d.ts.map +1 -0
- package/dist/hooks/devices/useInitializeDevices.js +41 -0
- package/dist/hooks/devices/useMicrophone.d.ts +7 -0
- package/dist/hooks/devices/useMicrophone.d.ts.map +1 -0
- package/dist/hooks/devices/useMicrophone.js +37 -0
- package/dist/hooks/public.d.ts +3 -1
- package/dist/hooks/public.d.ts.map +1 -1
- package/dist/hooks/public.js +3 -1
- package/dist/hooks/useFishjamContext.d.ts +4 -3
- package/dist/hooks/useFishjamContext.d.ts.map +1 -1
- package/dist/hooks/useScreenShare.d.ts +10 -1
- package/dist/hooks/useScreenShare.d.ts.map +1 -1
- package/dist/hooks/useScreenShare.js +34 -33
- package/dist/hooks/useTrackManager.d.ts +4 -2
- package/dist/hooks/useTrackManager.d.ts.map +1 -1
- package/dist/hooks/useTrackManager.js +55 -71
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/mediaInitializer.d.ts.map +1 -1
- package/dist/mediaInitializer.js +30 -1
- package/dist/types/internal.d.ts +20 -31
- package/dist/types/internal.d.ts.map +1 -1
- package/dist/types/public.d.ts +16 -5
- package/dist/types/public.d.ts.map +1 -1
- package/dist/utils/bandwidth.d.ts +3 -0
- package/dist/utils/bandwidth.d.ts.map +1 -0
- package/dist/utils/bandwidth.js +4 -0
- package/dist/utils/localStorage.d.ts +3 -4
- package/dist/utils/localStorage.d.ts.map +1 -1
- package/dist/utils/localStorage.js +18 -4
- package/dist/utils/track.d.ts +8 -2
- package/dist/utils/track.d.ts.map +1 -1
- package/dist/utils/track.js +23 -0
- package/package.json +5 -5
- package/dist/hooks/deviceManagers/useAudioDeviceManager.d.ts +0 -6
- package/dist/hooks/deviceManagers/useAudioDeviceManager.d.ts.map +0 -1
- package/dist/hooks/deviceManagers/useAudioDeviceManager.js +0 -11
- package/dist/hooks/deviceManagers/useVideoDeviceManager.d.ts +0 -6
- package/dist/hooks/deviceManagers/useVideoDeviceManager.d.ts.map +0 -1
- package/dist/hooks/deviceManagers/useVideoDeviceManager.js +0 -11
- package/dist/hooks/useDevices.d.ts +0 -19
- package/dist/hooks/useDevices.d.ts.map +0 -1
- package/dist/hooks/useDevices.js +0 -98
- package/dist/hooks/useProcessedPreviewStream.d.ts +0 -3
- package/dist/hooks/useProcessedPreviewStream.d.ts.map +0 -1
- package/dist/hooks/useProcessedPreviewStream.js +0 -17
- package/dist/utils/media.d.ts +0 -13
- package/dist/utils/media.d.ts.map +0 -1
- package/dist/utils/media.js +0 -64
package/dist/types/internal.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { DeviceType } from "../DeviceManager";
|
|
2
|
+
import type { StartStreamingProps, Track, TrackMiddleware, TracksMiddleware } from "./public";
|
|
3
3
|
export type TrackId = string;
|
|
4
4
|
export type PeerId = string;
|
|
5
5
|
export type PeerState = {
|
|
@@ -24,7 +24,6 @@ export type DeviceManagerStatus = "uninitialized" | "initializing" | "initialize
|
|
|
24
24
|
export interface DeviceManagerState {
|
|
25
25
|
deviceState: DeviceState;
|
|
26
26
|
status: DeviceManagerStatus;
|
|
27
|
-
tracks: MediaStreamTrack[];
|
|
28
27
|
}
|
|
29
28
|
export type Media = {
|
|
30
29
|
stream: MediaStream | null;
|
|
@@ -38,18 +37,7 @@ export type DeviceState = {
|
|
|
38
37
|
devices: MediaDeviceInfo[] | null;
|
|
39
38
|
devicesStatus: DevicesStatus;
|
|
40
39
|
error: DeviceError | null;
|
|
41
|
-
|
|
42
|
-
export type MediaState = {
|
|
43
|
-
video: DeviceState;
|
|
44
|
-
audio: DeviceState;
|
|
45
|
-
};
|
|
46
|
-
export type DeviceManagerInitConfig = {
|
|
47
|
-
videoTrackConstraints?: boolean | MediaTrackConstraints;
|
|
48
|
-
audioTrackConstraints?: boolean | MediaTrackConstraints;
|
|
49
|
-
};
|
|
50
|
-
export type DeviceManagerStartConfig = {
|
|
51
|
-
audioDeviceId?: string | boolean;
|
|
52
|
-
videoDeviceId?: string | boolean;
|
|
40
|
+
currentMiddleware: TrackMiddleware | null;
|
|
53
41
|
};
|
|
54
42
|
export type DeviceError = {
|
|
55
43
|
name: "OverconstrainedError";
|
|
@@ -66,16 +54,17 @@ export type CurrentDevices = {
|
|
|
66
54
|
};
|
|
67
55
|
export interface MediaManager {
|
|
68
56
|
start: (deviceId?: string) => Promise<void>;
|
|
69
|
-
stop: () =>
|
|
57
|
+
stop: () => void;
|
|
70
58
|
disable: () => void;
|
|
71
59
|
enable: () => void;
|
|
72
|
-
|
|
60
|
+
setTrackMiddleware: (middleware: TrackMiddleware | null) => void;
|
|
61
|
+
getMiddleware: () => TrackMiddleware | null;
|
|
73
62
|
getMedia: () => {
|
|
74
63
|
stream: MediaStream | null;
|
|
75
64
|
track: MediaStreamTrack | null;
|
|
76
65
|
enabled: boolean;
|
|
77
66
|
} | null;
|
|
78
|
-
getDeviceType: () =>
|
|
67
|
+
getDeviceType: () => DeviceType;
|
|
79
68
|
}
|
|
80
69
|
export type ScreenShareState = ({
|
|
81
70
|
stream: MediaStream;
|
|
@@ -91,34 +80,34 @@ export type ScreenShareState = ({
|
|
|
91
80
|
};
|
|
92
81
|
export interface TrackManager {
|
|
93
82
|
initialize: (deviceId?: string) => Promise<void>;
|
|
94
|
-
stop: () =>
|
|
95
|
-
startStreaming: (
|
|
83
|
+
stop: () => void;
|
|
84
|
+
startStreaming: (startStreamingProps?: StartStreamingProps) => Promise<string>;
|
|
96
85
|
stopStreaming: () => Promise<void>;
|
|
97
86
|
pauseStreaming: () => Promise<void>;
|
|
98
87
|
resumeStreaming: () => Promise<void>;
|
|
99
88
|
paused: boolean;
|
|
100
89
|
disableTrack: () => void;
|
|
101
90
|
enableTrack: () => void;
|
|
102
|
-
setTrackMiddleware: (middleware: TrackMiddleware) => Promise<void>;
|
|
103
|
-
currentTrackMiddleware: TrackMiddleware;
|
|
91
|
+
setTrackMiddleware: (middleware: TrackMiddleware | null) => Promise<void>;
|
|
104
92
|
refreshStreamedTrack: () => Promise<void>;
|
|
105
93
|
currentTrack: Track | null;
|
|
106
94
|
/**
|
|
107
|
-
*
|
|
108
|
-
* Either initiates or terminates the device or enables or disables the stream.
|
|
109
|
-
*
|
|
110
|
-
* @param {ToggleMode} [mode] - The toggle mode, either "hard" or "soft". Defaults to "hard".
|
|
111
|
-
*
|
|
112
|
-
* - **Hard Mode** - Turns the physical device on and off.
|
|
113
|
-
* - If started: disables the media stream, pauses streaming, and stops the device.
|
|
114
|
-
* - If stopped: starts the device and begins (or resumes) streaming.
|
|
95
|
+
* Either enables or disables the stream.
|
|
115
96
|
*
|
|
116
97
|
* - **Soft Mode** - Enables and disables the media stream. Starts the device if needed.
|
|
117
98
|
* - If enabled: disables the media stream and pauses streaming, but does not stop the device.
|
|
118
99
|
* - If disabled: enables the media stream and starts (or resumes) streaming.
|
|
119
100
|
* - If stopped: starts the device, enables the media stream, and starts (or resumes) streaming.
|
|
120
101
|
*/
|
|
121
|
-
|
|
102
|
+
toggleMute: () => Promise<void>;
|
|
103
|
+
/**
|
|
104
|
+
* Either initiates or terminates the device.
|
|
105
|
+
*
|
|
106
|
+
* - **Hard Mode** - Turns the physical device on and off.
|
|
107
|
+
* - If started: disables the media stream, pauses streaming, and stops the device.
|
|
108
|
+
* - If stopped: starts the device and begins (or resumes) streaming.
|
|
109
|
+
*/
|
|
110
|
+
toggleDevice: () => Promise<void>;
|
|
122
111
|
}
|
|
123
112
|
export type DistinguishedTracks = {
|
|
124
113
|
cameraTrack?: Track;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../src/types/internal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../src/types/internal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,mBAAmB,EAAE,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE9F,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC;AAC7B,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC;AAE5B,MAAM,MAAM,SAAS,GAAG;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE;QACR,IAAI,CAAC,EAAE,YAAY,CAAC;QACpB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACjC,CAAC;IACF,MAAM,EAAE,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;CAChC,CAAC;AAGF,MAAM,MAAM,YAAY,GAAG;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,QAAQ,GAAG,YAAY,GAAG,kBAAkB,GAAG,kBAAkB,CAAC;IACxE,MAAM,EAAE,OAAO,CAAC;IAEhB,WAA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AC;IACrC,MAAM,EAAE,OAAO,CAAC;IAChB,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,kBAAkB,EAAE,CAAC,UAAU,EAAE,eAAe,GAAG,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1E,oBAAoB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1C,YAAY,EAAE,KAAK,GAAG,IAAI,CAAC;IAE3B;;;;;;;OAOG;IACH,UAAU,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAChC;;;;;;OAMG;IACH,YAAY,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACnC;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,WAAW,CAAC,EAAE,KAAK,CAAC;IACpB,eAAe,CAAC,EAAE,KAAK,CAAC;IACxB,qBAAqB,CAAC,EAAE,KAAK,CAAC;IAC9B,qBAAqB,CAAC,EAAE,KAAK,CAAC;CAC/B,CAAC"}
|
package/dist/types/public.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Encoding, SimulcastConfig, ConnectConfig as TSClientConnectConfig, VadStatus } from "@fishjam-cloud/ts-client";
|
|
2
|
-
import type { DeviceManagerStatus, DistinguishedTracks, PeerMetadata, PeerState, TrackId, TrackManager, TrackMetadata } from "./internal";
|
|
2
|
+
import type { DeviceError, DeviceManagerStatus, DistinguishedTracks, PeerMetadata, PeerState, TrackId, TrackManager, TrackMetadata } from "./internal";
|
|
3
3
|
export type Track = {
|
|
4
4
|
stream: MediaStream | null;
|
|
5
5
|
encoding: Encoding | null;
|
|
@@ -9,8 +9,8 @@ export type Track = {
|
|
|
9
9
|
vadStatus: VadStatus;
|
|
10
10
|
track: MediaStreamTrack | null;
|
|
11
11
|
};
|
|
12
|
-
export type TrackMiddleware = ((track: MediaStreamTrack
|
|
13
|
-
track: MediaStreamTrack
|
|
12
|
+
export type TrackMiddleware = ((track: MediaStreamTrack) => {
|
|
13
|
+
track: MediaStreamTrack;
|
|
14
14
|
onClear?: () => void;
|
|
15
15
|
}) | null;
|
|
16
16
|
export type TracksMiddleware = (videoTrack: MediaStreamTrack, audioTrack: MediaStreamTrack | null) => {
|
|
@@ -27,7 +27,6 @@ export type TracksMiddleware = (videoTrack: MediaStreamTrack, audioTrack: MediaS
|
|
|
27
27
|
* error - There was an error in the connection process.
|
|
28
28
|
*/
|
|
29
29
|
export type PeerStatus = "connecting" | "connected" | "error" | "idle";
|
|
30
|
-
export type ToggleMode = "soft" | "hard";
|
|
31
30
|
export type Device = {
|
|
32
31
|
isStreaming: boolean;
|
|
33
32
|
status: DeviceManagerStatus;
|
|
@@ -36,6 +35,10 @@ export type Device = {
|
|
|
36
35
|
stream: MediaStream | null;
|
|
37
36
|
devices: MediaDeviceInfo[];
|
|
38
37
|
activeDevice: MediaDeviceInfo | null;
|
|
38
|
+
currentMiddleware: TrackMiddleware;
|
|
39
|
+
deviceError: DeviceError | null;
|
|
40
|
+
isMuted: boolean;
|
|
41
|
+
isDeviceEnabled: boolean;
|
|
39
42
|
} & Omit<TrackManager, "currentTrack">;
|
|
40
43
|
export type AudioDevice = Device & {
|
|
41
44
|
isAudioPlaying: boolean;
|
|
@@ -45,7 +48,7 @@ export type ConnectConfig = Omit<TSClientConnectConfig<PeerMetadata>, "peerMetad
|
|
|
45
48
|
peerMetadata?: PeerMetadata;
|
|
46
49
|
};
|
|
47
50
|
export type PersistLastDeviceHandlers = {
|
|
48
|
-
getLastDevice: (
|
|
51
|
+
getLastDevice: () => MediaDeviceInfo | null;
|
|
49
52
|
saveLastDevice: (info: MediaDeviceInfo) => void;
|
|
50
53
|
};
|
|
51
54
|
export type ScreenshareApi = {
|
|
@@ -62,4 +65,12 @@ export type ScreenshareApi = {
|
|
|
62
65
|
setTracksMiddleware: (middleware: TracksMiddleware | null) => Promise<void>;
|
|
63
66
|
currentTracksMiddleware: TracksMiddleware | null;
|
|
64
67
|
};
|
|
68
|
+
export type SimulcastBandwidthLimits = Record<Encoding, number>;
|
|
69
|
+
export type StartStreamingProps = {
|
|
70
|
+
simulcast?: Encoding[] | false;
|
|
71
|
+
};
|
|
72
|
+
export type BandwidthLimits = {
|
|
73
|
+
singleStream: number;
|
|
74
|
+
simulcast: SimulcastBandwidthLimits;
|
|
75
|
+
};
|
|
65
76
|
//# sourceMappingURL=public.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/types/public.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,eAAe,EACf,aAAa,IAAI,qBAAqB,EACtC,SAAS,EACV,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EACV,mBAAmB,EACnB,mBAAmB,EACnB,YAAY,EACZ,SAAS,EACT,OAAO,EACP,YAAY,EACZ,aAAa,EACd,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,KAAK,GAAG;IAClB,MAAM,EAAE,WAAW,GAAG,IAAI,CAAC;IAC3B,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,eAAe,EAAE,eAAe,GAAG,IAAI,CAAC;IACxC,SAAS,EAAE,SAAS,CAAC;IACrB,KAAK,EAAE,gBAAgB,GAAG,IAAI,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/types/public.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,eAAe,EACf,aAAa,IAAI,qBAAqB,EACtC,SAAS,EACV,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EACV,WAAW,EACX,mBAAmB,EACnB,mBAAmB,EACnB,YAAY,EACZ,SAAS,EACT,OAAO,EACP,YAAY,EACZ,aAAa,EACd,MA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QAAQ,EAAE,MAAM,CAAC,CAAC;AAEhE,MAAM,MAAM,mBAAmB,GAAG;IAAE,SAAS,CAAC,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAA;CAAE,CAAC;AAErE,MAAM,MAAM,eAAe,GAAG;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,wBAAwB,CAAA;CAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bandwidth.d.ts","sourceRoot":"","sources":["../../src/utils/bandwidth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEvD,eAAO,MAAM,gCAAgC,YAAa,OAAO,CAAC,eAAe,CAAC,KAAG,eAGnF,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export declare
|
|
4
|
-
export declare const saveString: (key: string, value: string) => void;
|
|
1
|
+
import type { PersistLastDeviceHandlers } from "../types/public";
|
|
2
|
+
import type { DeviceType } from "../DeviceManager";
|
|
3
|
+
export declare function createStorageConfig(deviceType: DeviceType, storage?: boolean | PersistLastDeviceHandlers): PersistLastDeviceHandlers | null;
|
|
5
4
|
//# sourceMappingURL=localStorage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localStorage.d.ts","sourceRoot":"","sources":["../../src/utils/localStorage.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"localStorage.d.ts","sourceRoot":"","sources":["../../src/utils/localStorage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,UAAU,EACtB,OAAO,CAAC,EAAE,OAAO,GAAG,yBAAyB,GAC5C,yBAAyB,GAAG,IAAI,CAIlC"}
|
|
@@ -1,21 +1,35 @@
|
|
|
1
|
-
export
|
|
1
|
+
export function createStorageConfig(deviceType, storage) {
|
|
2
|
+
if (storage === false)
|
|
3
|
+
return null;
|
|
4
|
+
if (storage === true || storage === undefined)
|
|
5
|
+
return getLocalStorageConfig(deviceType);
|
|
6
|
+
return storage;
|
|
7
|
+
}
|
|
8
|
+
const getLocalStorageConfig = (deviceType) => {
|
|
9
|
+
const key = `last-selected-${deviceType}-device`;
|
|
10
|
+
return {
|
|
11
|
+
getLastDevice: () => loadObject(key, null),
|
|
12
|
+
saveLastDevice: (info) => saveObject(key, info),
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
const loadObject = (key, defaultValue) => {
|
|
2
16
|
const stringValue = loadString(key, "");
|
|
3
17
|
if (stringValue === "") {
|
|
4
18
|
return defaultValue;
|
|
5
19
|
}
|
|
6
20
|
return JSON.parse(stringValue);
|
|
7
21
|
};
|
|
8
|
-
|
|
22
|
+
const loadString = (key, defaultValue = "") => {
|
|
9
23
|
const value = localStorage.getItem(key);
|
|
10
24
|
if (value === null || value === undefined) {
|
|
11
25
|
return defaultValue;
|
|
12
26
|
}
|
|
13
27
|
return value;
|
|
14
28
|
};
|
|
15
|
-
|
|
29
|
+
const saveObject = (key, value) => {
|
|
16
30
|
const stringValue = JSON.stringify(value);
|
|
17
31
|
saveString(key, stringValue);
|
|
18
32
|
};
|
|
19
|
-
|
|
33
|
+
const saveString = (key, value) => {
|
|
20
34
|
localStorage.setItem(key, value);
|
|
21
35
|
};
|
package/dist/utils/track.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import type { FishjamClient } from "@fishjam-cloud/ts-client";
|
|
1
|
+
import type { Encoding, FishjamClient } from "@fishjam-cloud/ts-client";
|
|
2
2
|
import type { PeerMetadata, TrackMetadata } from "../types/internal";
|
|
3
|
-
import type { Track } from "../types/public";
|
|
3
|
+
import type { BandwidthLimits, Track } from "../types/public";
|
|
4
4
|
export declare const getRemoteOrLocalTrack: (tsClient: FishjamClient<PeerMetadata, TrackMetadata>, remoteOrLocalTrackId: string | null) => Track | null;
|
|
5
|
+
export declare function setupOnEndedCallback(track: MediaStreamTrack, getCurrentTrackId: () => string | undefined, callback: () => Promise<void>): void;
|
|
6
|
+
export declare const getConfigAndBandwidthFromProps: (encodings: Encoding[] | false | undefined, bandwidthLimits: BandwidthLimits) => readonly [number, undefined] | readonly [Map<Encoding, number>, {
|
|
7
|
+
enabled: boolean;
|
|
8
|
+
activeEncodings: Encoding[];
|
|
9
|
+
disabledEncodings: Encoding[];
|
|
10
|
+
}];
|
|
5
11
|
//# sourceMappingURL=track.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"track.d.ts","sourceRoot":"","sources":["../../src/utils/track.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAgB,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"track.d.ts","sourceRoot":"","sources":["../../src/utils/track.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAgB,MAAM,0BAA0B,CAAC;AACtF,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAoC9D,eAAO,MAAM,qBAAqB,aACtB,aAAa,CAAC,YAAY,EAAE,aAAa,CAAC,wBAC9B,MAAM,GAAG,IAAI,iBAKpC,CAAC;AAEF,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,gBAAgB,EACvB,iBAAiB,EAAE,MAAM,MAAM,GAAG,SAAS,EAC3C,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,QAQ9B;AAOD,eAAO,MAAM,8BAA8B,cAC9B,QAAQ,EAAE,GAAG,KAAK,GAAG,SAAS,mBACxB,eAAe;;;;EAWjC,CAAC"}
|
package/dist/utils/track.js
CHANGED
|
@@ -33,3 +33,26 @@ export const getRemoteOrLocalTrack = (tsClient, remoteOrLocalTrackId) => {
|
|
|
33
33
|
return null;
|
|
34
34
|
return getTrackFromContext(context);
|
|
35
35
|
};
|
|
36
|
+
export function setupOnEndedCallback(track, getCurrentTrackId, callback) {
|
|
37
|
+
track.addEventListener("ended", async (event) => {
|
|
38
|
+
const trackId = event.target.id;
|
|
39
|
+
if (trackId === getCurrentTrackId()) {
|
|
40
|
+
await callback();
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
const getDisabledEncodings = (activeEncodings = []) => {
|
|
45
|
+
const allEncodings = ["l", "m", "h"];
|
|
46
|
+
return allEncodings.filter((encoding) => !activeEncodings.includes(encoding));
|
|
47
|
+
};
|
|
48
|
+
export const getConfigAndBandwidthFromProps = (encodings, bandwidthLimits) => {
|
|
49
|
+
if (!encodings)
|
|
50
|
+
return [bandwidthLimits.singleStream, undefined];
|
|
51
|
+
const config = {
|
|
52
|
+
enabled: true,
|
|
53
|
+
activeEncodings: encodings,
|
|
54
|
+
disabledEncodings: getDisabledEncodings(encodings),
|
|
55
|
+
};
|
|
56
|
+
const bandwidth = new Map(Object.entries(bandwidthLimits.simulcast));
|
|
57
|
+
return [bandwidth, config];
|
|
58
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fishjam-cloud/react-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "React client library for Fishjam Cloud",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Fishjam Cloud Team",
|
|
@@ -41,16 +41,16 @@
|
|
|
41
41
|
"@playwright/test": "^1.47.2",
|
|
42
42
|
"@types/events": "^3.0.3",
|
|
43
43
|
"@types/lodash.isequal": "^4.5.8",
|
|
44
|
-
"@types/node": "^22.7.
|
|
45
|
-
"@types/react": "^18.3.
|
|
44
|
+
"@types/node": "^22.7.5",
|
|
45
|
+
"@types/react": "^18.3.11",
|
|
46
46
|
"react": "^18.2.0",
|
|
47
47
|
"typed-emitter": "^2.1.0",
|
|
48
|
-
"typedoc": "^0.26.
|
|
48
|
+
"typedoc": "^0.26.8",
|
|
49
49
|
"typedoc-plugin-mdn-links": "^3.3.2",
|
|
50
50
|
"typescript": "^5.6.2"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@fishjam-cloud/ts-client": "0.
|
|
53
|
+
"@fishjam-cloud/ts-client": "0.8.0",
|
|
54
54
|
"events": "3.3.0",
|
|
55
55
|
"lodash.isequal": "4.5.0"
|
|
56
56
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useAudioDeviceManager.d.ts","sourceRoot":"","sources":["../../../src/hooks/deviceManagers/useAudioDeviceManager.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,eAAO,MAAM,qBAAqB,yDAKjC,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { useFishjamContext } from "../useFishjamContext";
|
|
2
|
-
import { useDeviceManager } from "./useDeviceManager";
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* @category Devices
|
|
6
|
-
*/
|
|
7
|
-
export const useAudioDeviceManager = () => {
|
|
8
|
-
const { audioDeviceManagerRef } = useFishjamContext();
|
|
9
|
-
const audioDeviceState = useDeviceManager(audioDeviceManagerRef.current);
|
|
10
|
-
return audioDeviceState;
|
|
11
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useVideoDeviceManager.d.ts","sourceRoot":"","sources":["../../../src/hooks/deviceManagers/useVideoDeviceManager.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,eAAO,MAAM,qBAAqB,yDAIjC,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { useFishjamContext } from "../useFishjamContext";
|
|
2
|
-
import { useDeviceManager } from "./useDeviceManager";
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* @category Devices
|
|
6
|
-
*/
|
|
7
|
-
export const useVideoDeviceManager = () => {
|
|
8
|
-
const { videoDeviceManagerRef } = useFishjamContext();
|
|
9
|
-
const videoDeviceState = useDeviceManager(videoDeviceManagerRef.current);
|
|
10
|
-
return videoDeviceState;
|
|
11
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { AudioDevice, Device } from "../types/public";
|
|
2
|
-
/**
|
|
3
|
-
*
|
|
4
|
-
* @category Devices
|
|
5
|
-
*/
|
|
6
|
-
export declare function useCamera(): Device;
|
|
7
|
-
/**
|
|
8
|
-
*
|
|
9
|
-
* @category Devices
|
|
10
|
-
*/
|
|
11
|
-
export declare function useMicrophone(): AudioDevice;
|
|
12
|
-
/**
|
|
13
|
-
*
|
|
14
|
-
* @category Devices
|
|
15
|
-
*/
|
|
16
|
-
export declare const useInitializeDevices: () => {
|
|
17
|
-
initializeDevices: () => Promise<void>;
|
|
18
|
-
};
|
|
19
|
-
//# sourceMappingURL=useDevices.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useDevices.d.ts","sourceRoot":"","sources":["../../src/hooks/useDevices.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAE3D;;;GAGG;AACH,wBAAgB,SAAS,IAAI,MAAM,CAuBlC;AAED;;;GAGG;AACH,wBAAgB,aAAa,IAAI,WAAW,CA2B3C;AAED;;;GAGG;AACH,eAAO,MAAM,oBAAoB;;CAqDhC,CAAC"}
|
package/dist/hooks/useDevices.js
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { useFishjamContext } from "./useFishjamContext";
|
|
2
|
-
import { useVideoDeviceManager } from "./deviceManagers/useVideoDeviceManager";
|
|
3
|
-
import { useAudioDeviceManager } from "./deviceManagers/useAudioDeviceManager";
|
|
4
|
-
import { useCallback } from "react";
|
|
5
|
-
import { getAvailableMedia, getCorrectedResult } from "../mediaInitializer";
|
|
6
|
-
import { useProcessedPreviewStream } from "./useProcessedPreviewStream";
|
|
7
|
-
import { prepareConstraints } from "../constraints";
|
|
8
|
-
/**
|
|
9
|
-
*
|
|
10
|
-
* @category Devices
|
|
11
|
-
*/
|
|
12
|
-
export function useCamera() {
|
|
13
|
-
const { videoTrackManager } = useFishjamContext();
|
|
14
|
-
const { deviceState, status } = useVideoDeviceManager();
|
|
15
|
-
const { currentTrack, ...trackManager } = videoTrackManager;
|
|
16
|
-
const processedPreviewStream = useProcessedPreviewStream(videoTrackManager, deviceState.media?.track);
|
|
17
|
-
const stream = currentTrack?.stream ?? processedPreviewStream ?? deviceState.media?.stream ?? null;
|
|
18
|
-
const isStreaming = Boolean(currentTrack?.stream);
|
|
19
|
-
const track = stream?.getAudioTracks()[0] ?? null;
|
|
20
|
-
const trackId = currentTrack?.trackId ?? null;
|
|
21
|
-
const devices = deviceState.devices ?? [];
|
|
22
|
-
const activeDevice = deviceState.media?.deviceInfo ?? null;
|
|
23
|
-
return {
|
|
24
|
-
...trackManager,
|
|
25
|
-
status,
|
|
26
|
-
stream,
|
|
27
|
-
devices,
|
|
28
|
-
activeDevice,
|
|
29
|
-
isStreaming,
|
|
30
|
-
track,
|
|
31
|
-
trackId,
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
*
|
|
36
|
-
* @category Devices
|
|
37
|
-
*/
|
|
38
|
-
export function useMicrophone() {
|
|
39
|
-
const { audioTrackManager } = useFishjamContext();
|
|
40
|
-
const { deviceState, status } = useAudioDeviceManager();
|
|
41
|
-
const { currentTrack, ...trackManager } = audioTrackManager;
|
|
42
|
-
const processedPreviewStream = useProcessedPreviewStream(audioTrackManager, deviceState.media?.track);
|
|
43
|
-
const stream = currentTrack?.stream ?? processedPreviewStream ?? deviceState.media?.stream ?? null;
|
|
44
|
-
const isStreaming = Boolean(currentTrack?.stream);
|
|
45
|
-
const track = stream?.getAudioTracks()[0] ?? null;
|
|
46
|
-
const trackId = currentTrack?.trackId ?? null;
|
|
47
|
-
const devices = deviceState.devices ?? [];
|
|
48
|
-
const activeDevice = deviceState.media?.deviceInfo ?? null;
|
|
49
|
-
const isAudioPlaying = currentTrack?.vadStatus === "speech";
|
|
50
|
-
return {
|
|
51
|
-
...trackManager,
|
|
52
|
-
status,
|
|
53
|
-
stream,
|
|
54
|
-
isStreaming,
|
|
55
|
-
track,
|
|
56
|
-
trackId,
|
|
57
|
-
devices,
|
|
58
|
-
activeDevice,
|
|
59
|
-
isAudioPlaying,
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
*
|
|
64
|
-
* @category Devices
|
|
65
|
-
*/
|
|
66
|
-
export const useInitializeDevices = () => {
|
|
67
|
-
const { videoDeviceManagerRef, audioDeviceManagerRef, hasDevicesBeenInitializedRef } = useFishjamContext();
|
|
68
|
-
const initializeDevices = useCallback(async () => {
|
|
69
|
-
if (hasDevicesBeenInitializedRef.current)
|
|
70
|
-
return;
|
|
71
|
-
hasDevicesBeenInitializedRef.current = true;
|
|
72
|
-
const videoManager = videoDeviceManagerRef.current;
|
|
73
|
-
const audioManager = audioDeviceManagerRef.current;
|
|
74
|
-
const constraints = {
|
|
75
|
-
video: videoManager.getConstraints(),
|
|
76
|
-
audio: audioManager.getConstraints(),
|
|
77
|
-
};
|
|
78
|
-
const previousDevices = {
|
|
79
|
-
video: videoManager.getLastDevice(),
|
|
80
|
-
audio: audioManager.getLastDevice(),
|
|
81
|
-
};
|
|
82
|
-
// Attempt to start the last selected device to avoid an unnecessary restart.
|
|
83
|
-
// Without this, the first device will start, and `getCorrectedResult` will attempt to fix it.
|
|
84
|
-
let [stream, deviceErrors] = await getAvailableMedia({
|
|
85
|
-
video: prepareConstraints(previousDevices.video?.deviceId, constraints.video),
|
|
86
|
-
audio: prepareConstraints(previousDevices.audio?.deviceId, constraints.audio),
|
|
87
|
-
});
|
|
88
|
-
const devices = await navigator.mediaDevices.enumerateDevices();
|
|
89
|
-
const videoDevices = devices.filter(({ kind }) => kind === "videoinput");
|
|
90
|
-
const audioDevices = devices.filter(({ kind }) => kind === "audioinput");
|
|
91
|
-
if (stream) {
|
|
92
|
-
[stream, deviceErrors] = await getCorrectedResult(stream, deviceErrors, devices, constraints, previousDevices);
|
|
93
|
-
}
|
|
94
|
-
videoManager.initialize(stream, stream?.getVideoTracks()?.[0] ?? null, videoDevices, !!constraints.video, deviceErrors.video);
|
|
95
|
-
audioManager.initialize(stream, stream?.getAudioTracks()?.[0] ?? null, audioDevices, !!constraints.audio, deviceErrors.audio);
|
|
96
|
-
}, [videoDeviceManagerRef, audioDeviceManagerRef, hasDevicesBeenInitializedRef]);
|
|
97
|
-
return { initializeDevices };
|
|
98
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useProcessedPreviewStream.d.ts","sourceRoot":"","sources":["../../src/hooks/useProcessedPreviewStream.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,wBAAgB,yBAAyB,CACvC,YAAY,EAAE,YAAY,EAC1B,WAAW,EAAE,gBAAgB,GAAG,IAAI,GAAG,SAAS,sBAiBjD"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from "react";
|
|
2
|
-
export function useProcessedPreviewStream(trackManager, deviceTrack) {
|
|
3
|
-
const [previewStream, setPreviewStream] = useState(null);
|
|
4
|
-
const { currentTrack, currentTrackMiddleware } = trackManager;
|
|
5
|
-
useEffect(() => {
|
|
6
|
-
if (currentTrack || !deviceTrack)
|
|
7
|
-
return;
|
|
8
|
-
const result = currentTrackMiddleware?.(deviceTrack);
|
|
9
|
-
if (result?.track)
|
|
10
|
-
setPreviewStream(new MediaStream([result.track]));
|
|
11
|
-
return () => {
|
|
12
|
-
result?.onClear?.();
|
|
13
|
-
setPreviewStream(null);
|
|
14
|
-
};
|
|
15
|
-
}, [currentTrack, deviceTrack, currentTrackMiddleware]);
|
|
16
|
-
return previewStream;
|
|
17
|
-
}
|
package/dist/utils/media.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { CurrentDevices, DeviceError, DeviceState } from "../types/internal";
|
|
2
|
-
import type { PersistLastDeviceHandlers } from "../types/public";
|
|
3
|
-
export declare const removeSpecifiedDeviceFromConstraints: (trackConstraints?: boolean | MediaTrackConstraints) => boolean | MediaTrackConstraints | undefined;
|
|
4
|
-
export declare const REQUESTING = "Requesting";
|
|
5
|
-
export declare const NOT_REQUESTED = "Not requested";
|
|
6
|
-
export declare const getDeviceInfo: (trackDeviceId: string | null, devices: MediaDeviceInfo[]) => MediaDeviceInfo | null;
|
|
7
|
-
export declare const getCurrentDevicesSettings: (requestedDevices: MediaStream, mediaDeviceInfos: MediaDeviceInfo[]) => CurrentDevices;
|
|
8
|
-
export declare const isDeviceDifferentFromLastSession: (lastDevice: MediaDeviceInfo | null, currentDevice: MediaDeviceInfo | null) => boolean | null;
|
|
9
|
-
export declare const isAnyDeviceDifferentFromLastSession: (lastVideoDevice: MediaDeviceInfo | null, lastAudioDevice: MediaDeviceInfo | null, currentDevices: CurrentDevices | null) => boolean;
|
|
10
|
-
export declare const stopTracks: (requestedDevices: MediaStream) => void;
|
|
11
|
-
export declare const prepareDeviceState: (stream: MediaStream | null, track: MediaStreamTrack | null, devices: MediaDeviceInfo[], error: DeviceError | null, shouldAsk: boolean) => DeviceState;
|
|
12
|
-
export declare const getLocalStorageConfig: (deviceType: "audio" | "video") => PersistLastDeviceHandlers;
|
|
13
|
-
//# sourceMappingURL=media.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../../src/utils/media.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAiB,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGjG,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAEjE,eAAO,MAAM,oCAAoC,sBAC5B,OAAO,GAAG,qBAAqB,KACjD,OAAO,GAAG,qBAAqB,GAAG,SAKpC,CAAC;AAEF,eAAO,MAAM,UAAU,eAAe,CAAC;AACvC,eAAO,MAAM,aAAa,kBAAkB,CAAC;AAE7C,eAAO,MAAM,aAAa,kBAAmB,MAAM,GAAG,IAAI,WAAW,eAAe,EAAE,KAAG,eAAe,GAAG,IACpB,CAAC;AAExF,eAAO,MAAM,yBAAyB,qBAClB,WAAW,oBACX,eAAe,EAAE,KAClC,cAcF,CAAC;AAEF,eAAO,MAAM,gCAAgC,eAC/B,eAAe,GAAG,IAAI,iBACnB,eAAe,GAAG,IAAI,mBAC2E,CAAC;AAEnH,eAAO,MAAM,mCAAmC,oBAC7B,eAAe,GAAG,IAAI,mBACtB,eAAe,GAAG,IAAI,kBACvB,cAAc,GAAG,IAAI,KACpC,OAMA,CAAC;AAEJ,eAAO,MAAM,UAAU,qBAAsB,WAAW,SAIvD,CAAC;AAQF,eAAO,MAAM,kBAAkB,WACrB,WAAW,GAAG,IAAI,SACnB,gBAAgB,GAAG,IAAI,WACrB,eAAe,EAAE,SACnB,WAAW,GAAG,IAAI,aACd,OAAO,KACjB,WAgBF,CAAC;AAEF,eAAO,MAAM,qBAAqB,eAAgB,OAAO,GAAG,OAAO,KAAG,yBAMrE,CAAC"}
|
package/dist/utils/media.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { loadObject, saveObject } from "./localStorage";
|
|
2
|
-
export const removeSpecifiedDeviceFromConstraints = (trackConstraints) => {
|
|
3
|
-
if (typeof trackConstraints === "object") {
|
|
4
|
-
return { ...trackConstraints, deviceId: undefined };
|
|
5
|
-
}
|
|
6
|
-
return trackConstraints;
|
|
7
|
-
};
|
|
8
|
-
export const REQUESTING = "Requesting";
|
|
9
|
-
export const NOT_REQUESTED = "Not requested";
|
|
10
|
-
export const getDeviceInfo = (trackDeviceId, devices) => (trackDeviceId && devices.find(({ deviceId }) => trackDeviceId === deviceId)) || null;
|
|
11
|
-
export const getCurrentDevicesSettings = (requestedDevices, mediaDeviceInfos) => {
|
|
12
|
-
const currentDevices = { videoinput: null, audioinput: null };
|
|
13
|
-
for (const track of requestedDevices.getTracks()) {
|
|
14
|
-
const settings = track.getSettings();
|
|
15
|
-
if (settings.deviceId) {
|
|
16
|
-
const currentDevice = mediaDeviceInfos.find((device) => device.deviceId == settings.deviceId);
|
|
17
|
-
const kind = currentDevice?.kind ?? null;
|
|
18
|
-
if ((currentDevice && kind === "videoinput") || kind === "audioinput") {
|
|
19
|
-
currentDevices[kind] = currentDevice ?? null;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return currentDevices;
|
|
24
|
-
};
|
|
25
|
-
export const isDeviceDifferentFromLastSession = (lastDevice, currentDevice) => lastDevice && (currentDevice?.deviceId !== lastDevice.deviceId || currentDevice?.label !== lastDevice?.label);
|
|
26
|
-
export const isAnyDeviceDifferentFromLastSession = (lastVideoDevice, lastAudioDevice, currentDevices) => !!((currentDevices?.videoinput &&
|
|
27
|
-
isDeviceDifferentFromLastSession(lastVideoDevice, currentDevices?.videoinput || null)) ||
|
|
28
|
-
(currentDevices?.audioinput &&
|
|
29
|
-
isDeviceDifferentFromLastSession(lastAudioDevice, currentDevices?.audioinput || null)));
|
|
30
|
-
export const stopTracks = (requestedDevices) => {
|
|
31
|
-
for (const track of requestedDevices.getTracks()) {
|
|
32
|
-
track.stop();
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
const prepareStatus = (requested, track) => {
|
|
36
|
-
if (!requested)
|
|
37
|
-
return ["Not requested", null];
|
|
38
|
-
if (track)
|
|
39
|
-
return ["OK", null];
|
|
40
|
-
return ["Error", null];
|
|
41
|
-
};
|
|
42
|
-
export const prepareDeviceState = (stream, track, devices, error, shouldAsk) => {
|
|
43
|
-
const deviceInfo = getDeviceInfo(track?.getSettings()?.deviceId || null, devices);
|
|
44
|
-
const [devicesStatus, newError] = prepareStatus(shouldAsk, track);
|
|
45
|
-
return {
|
|
46
|
-
devices,
|
|
47
|
-
devicesStatus,
|
|
48
|
-
media: {
|
|
49
|
-
stream: track ? stream : null,
|
|
50
|
-
track: track,
|
|
51
|
-
deviceInfo,
|
|
52
|
-
enabled: !!track,
|
|
53
|
-
},
|
|
54
|
-
mediaStatus: devicesStatus,
|
|
55
|
-
error: newError ?? error,
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
export const getLocalStorageConfig = (deviceType) => {
|
|
59
|
-
const key = `last-selected-${deviceType}-device`;
|
|
60
|
-
return {
|
|
61
|
-
getLastDevice: () => loadObject(key, null),
|
|
62
|
-
saveLastDevice: (info) => saveObject(key, info),
|
|
63
|
-
};
|
|
64
|
-
};
|