@whereby.com/core 1.31.5 → 1.31.7
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/index.cjs +46 -35
- package/dist/index.d.cts +718 -0
- package/dist/index.d.mts +718 -0
- package/dist/index.d.ts +718 -0
- package/dist/index.mjs +46 -35
- package/dist/legacy-esm.js +46 -35
- package/dist/redux/index.cjs +46 -35
- package/dist/redux/index.d.cts +436 -1
- package/dist/redux/index.d.mts +436 -1
- package/dist/redux/index.d.ts +436 -1
- package/dist/redux/index.js +46 -35
- package/dist/redux/index.mjs +46 -35
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1312,7 +1312,7 @@ const createReactor = (selectors, callback) => {
|
|
|
1312
1312
|
});
|
|
1313
1313
|
};
|
|
1314
1314
|
|
|
1315
|
-
const coreVersion = "1.31.
|
|
1315
|
+
const coreVersion = "1.31.7";
|
|
1316
1316
|
|
|
1317
1317
|
function decodeRoomName(roomName) {
|
|
1318
1318
|
if (!roomName) {
|
|
@@ -1909,6 +1909,17 @@ const localMediaSlice = createSlice({
|
|
|
1909
1909
|
});
|
|
1910
1910
|
},
|
|
1911
1911
|
});
|
|
1912
|
+
const snapshotTracks = (stream) => ({
|
|
1913
|
+
audio: stream.getAudioTracks()[0] || null,
|
|
1914
|
+
video: stream.getVideoTracks()[0] || null,
|
|
1915
|
+
});
|
|
1916
|
+
const findChangedTracks = (stream, before) => {
|
|
1917
|
+
const after = snapshotTracks(stream);
|
|
1918
|
+
return ["audio", "video"].flatMap((kind) => {
|
|
1919
|
+
const track = after[kind];
|
|
1920
|
+
return track && track !== before[kind] ? [{ track, oldTrack: before[kind] }] : [];
|
|
1921
|
+
});
|
|
1922
|
+
};
|
|
1912
1923
|
const { deviceBusy, setCurrentCameraDeviceId, setCurrentMicrophoneDeviceId, setCurrentSpeakerDeviceId, toggleCameraEnabled, toggleMicrophoneEnabled, toggleHdModeEnabled, toggleLowDataModeEnabled, toggleWidescreenModeEnabled, setLocalMediaOptions, setLocalMediaStream, localMediaStopped, localStreamMetadataUpdated, } = localMediaSlice.actions;
|
|
1913
1924
|
const doToggleCamera = createAppAsyncThunk("localMedia/doToggleCamera", (_1, _a) => __awaiter(void 0, [_1, _a], void 0, function* (_, { getState, rejectWithValue }) {
|
|
1914
1925
|
const state = getState();
|
|
@@ -1916,8 +1927,9 @@ const doToggleCamera = createAppAsyncThunk("localMedia/doToggleCamera", (_1, _a)
|
|
|
1916
1927
|
if (!stream) {
|
|
1917
1928
|
return;
|
|
1918
1929
|
}
|
|
1919
|
-
|
|
1930
|
+
const track = stream.getVideoTracks()[0];
|
|
1920
1931
|
const enabled = selectIsCameraEnabled(state);
|
|
1932
|
+
const before = snapshotTracks(stream);
|
|
1921
1933
|
try {
|
|
1922
1934
|
if (enabled) {
|
|
1923
1935
|
if (track) {
|
|
@@ -1927,7 +1939,6 @@ const doToggleCamera = createAppAsyncThunk("localMedia/doToggleCamera", (_1, _a)
|
|
|
1927
1939
|
const constraintsOptions = selectLocalMediaConstraintsOptions(state);
|
|
1928
1940
|
const cameraDeviceId = selectCurrentCameraDeviceId(state);
|
|
1929
1941
|
yield getStream(Object.assign(Object.assign({}, constraintsOptions), { audioId: false, videoId: cameraDeviceId, type: "exact" }), { replaceStream: stream });
|
|
1930
|
-
track = stream.getVideoTracks()[0];
|
|
1931
1942
|
}
|
|
1932
1943
|
}
|
|
1933
1944
|
else {
|
|
@@ -1938,7 +1949,7 @@ const doToggleCamera = createAppAsyncThunk("localMedia/doToggleCamera", (_1, _a)
|
|
|
1938
1949
|
track.stop();
|
|
1939
1950
|
stream.removeTrack(track);
|
|
1940
1951
|
}
|
|
1941
|
-
|
|
1952
|
+
return { changedTracks: findChangedTracks(stream, before) };
|
|
1942
1953
|
}
|
|
1943
1954
|
catch (error) {
|
|
1944
1955
|
return rejectWithValue(error);
|
|
@@ -1968,13 +1979,17 @@ const doSetDevice = createAppAsyncThunk("localMedia/reactSetDevice", (_a, _b) =>
|
|
|
1968
1979
|
const audioId = audio ? selectCurrentMicrophoneDeviceId(state) : false;
|
|
1969
1980
|
const videoId = video ? selectCurrentCameraDeviceId(state) : false;
|
|
1970
1981
|
const constraintsOptions = selectLocalMediaConstraintsOptions(state);
|
|
1982
|
+
const before = snapshotTracks(stream);
|
|
1971
1983
|
const { replacedTracks } = yield getStream(Object.assign(Object.assign({}, constraintsOptions), { audioId,
|
|
1972
1984
|
videoId, type: "exact" }), { replaceStream: stream });
|
|
1973
1985
|
const isAudioEnabled = selectIsMicrophoneEnabled(state);
|
|
1974
1986
|
stream.getAudioTracks().forEach((track) => (track.enabled = isAudioEnabled));
|
|
1975
1987
|
const isVideoEnabled = selectIsCameraEnabled(state);
|
|
1976
1988
|
stream.getVideoTracks().forEach((track) => (track.enabled = isVideoEnabled));
|
|
1977
|
-
return {
|
|
1989
|
+
return {
|
|
1990
|
+
replacedTracks,
|
|
1991
|
+
changedTracks: findChangedTracks(stream, before),
|
|
1992
|
+
};
|
|
1978
1993
|
}
|
|
1979
1994
|
catch (error) {
|
|
1980
1995
|
return rejectWithValue(error);
|
|
@@ -2048,6 +2063,7 @@ const doSwitchLocalStream = createAppAsyncThunk("localMedia/doSwitchLocalStream"
|
|
|
2048
2063
|
beforeEffectTracks.video = undefined;
|
|
2049
2064
|
}
|
|
2050
2065
|
const hasLiveTrackFromDevice = (deviceId) => (audioId ? replaceStream.getAudioTracks() : replaceStream.getVideoTracks()).some((track) => track.readyState === "live" && track.getSettings().deviceId === deviceId);
|
|
2066
|
+
const before = snapshotTracks(replaceStream);
|
|
2051
2067
|
try {
|
|
2052
2068
|
const { replacedTracks } = yield getStream(Object.assign(Object.assign({}, constraintsOptions), { audioId: audioId === undefined ? false : audioId, videoId: videoId === undefined ? false : videoId, type: "exact" }), { replaceStream });
|
|
2053
2069
|
const deviceId = audioId || videoId;
|
|
@@ -2056,7 +2072,11 @@ const doSwitchLocalStream = createAppAsyncThunk("localMedia/doSwitchLocalStream"
|
|
|
2056
2072
|
deviceId,
|
|
2057
2073
|
}));
|
|
2058
2074
|
}
|
|
2059
|
-
return {
|
|
2075
|
+
return {
|
|
2076
|
+
replacedTracks,
|
|
2077
|
+
beforeEffectTracks,
|
|
2078
|
+
changedTracks: findChangedTracks(replaceStream, before),
|
|
2079
|
+
};
|
|
2060
2080
|
}
|
|
2061
2081
|
catch (error) {
|
|
2062
2082
|
console.error(error);
|
|
@@ -2125,6 +2145,7 @@ const doLocalStreamEffect = createAppAsyncThunk("localMedia/doLocalStreamEffect"
|
|
|
2125
2145
|
if (!stream) {
|
|
2126
2146
|
throw new Error("No local media stream");
|
|
2127
2147
|
}
|
|
2148
|
+
const before = snapshotTracks(stream);
|
|
2128
2149
|
if (effectStream) {
|
|
2129
2150
|
if (!beforeTrack) {
|
|
2130
2151
|
beforeEffectTracks = {
|
|
@@ -2145,7 +2166,12 @@ const doLocalStreamEffect = createAppAsyncThunk("localMedia/doLocalStreamEffect"
|
|
|
2145
2166
|
};
|
|
2146
2167
|
beforeTrack.stop();
|
|
2147
2168
|
}
|
|
2148
|
-
return {
|
|
2169
|
+
return {
|
|
2170
|
+
effectStream,
|
|
2171
|
+
beforeEffectTracks,
|
|
2172
|
+
replacedTracks,
|
|
2173
|
+
changedTracks: findChangedTracks(stream, before),
|
|
2174
|
+
};
|
|
2149
2175
|
}
|
|
2150
2176
|
catch (error) {
|
|
2151
2177
|
console.error("Error applying local stream effect", error);
|
|
@@ -4065,19 +4091,21 @@ const selectRtcIsCreatingDispatcher = (state) => state.rtcConnection.isCreatingD
|
|
|
4065
4091
|
const selectRtcStatus = (state) => state.rtcConnection.status;
|
|
4066
4092
|
const selectIsAcceptingStreams = (state) => state.rtcConnection.isAcceptingStreams;
|
|
4067
4093
|
const selectIsAudioOnlyModeEnabled = (state) => state.rtcConnection.isAudioOnlyModeEnabled;
|
|
4094
|
+
const handOverChangedTracks = ({ payload }, { getState }) => {
|
|
4095
|
+
const { rtcManager } = selectRtcConnectionRaw(getState());
|
|
4096
|
+
payload === null || payload === void 0 ? void 0 : payload.changedTracks.forEach(({ track, oldTrack }) => {
|
|
4097
|
+
rtcManager === null || rtcManager === void 0 ? void 0 : rtcManager.replaceTrack(oldTrack, track);
|
|
4098
|
+
});
|
|
4099
|
+
};
|
|
4100
|
+
startAppListening({ actionCreator: doSetDevice.fulfilled, effect: handOverChangedTracks });
|
|
4101
|
+
startAppListening({ actionCreator: doSwitchLocalStream.fulfilled, effect: handOverChangedTracks });
|
|
4102
|
+
startAppListening({ actionCreator: doLocalStreamEffect.fulfilled, effect: handOverChangedTracks });
|
|
4068
4103
|
startAppListening({
|
|
4069
|
-
actionCreator:
|
|
4070
|
-
effect: (
|
|
4071
|
-
|
|
4104
|
+
actionCreator: doToggleCamera.fulfilled,
|
|
4105
|
+
effect: (action, { getState }) => {
|
|
4106
|
+
handOverChangedTracks(action, { getState });
|
|
4072
4107
|
const { rtcManager } = selectRtcConnectionRaw(getState());
|
|
4073
|
-
|
|
4074
|
-
const replace = (kind, oldTrack) => {
|
|
4075
|
-
const track = stream === null || stream === void 0 ? void 0 : stream.getTracks().find((t) => t.kind === kind);
|
|
4076
|
-
return track && (rtcManager === null || rtcManager === void 0 ? void 0 : rtcManager.replaceTrack(oldTrack, track));
|
|
4077
|
-
};
|
|
4078
|
-
replacedTracks === null || replacedTracks === void 0 ? void 0 : replacedTracks.forEach((t) => {
|
|
4079
|
-
replace(t.kind, t);
|
|
4080
|
-
});
|
|
4108
|
+
rtcManager === null || rtcManager === void 0 ? void 0 : rtcManager.stopOrResumeVideo({ enable: selectIsCameraEnabled(getState()) });
|
|
4081
4109
|
},
|
|
4082
4110
|
});
|
|
4083
4111
|
startAppListening({
|
|
@@ -4111,23 +4139,6 @@ startAppListening({
|
|
|
4111
4139
|
rtcManager === null || rtcManager === void 0 ? void 0 : rtcManager.removeScreenshareStream(stream);
|
|
4112
4140
|
},
|
|
4113
4141
|
});
|
|
4114
|
-
startAppListening({
|
|
4115
|
-
matcher: isAnyOf(doSwitchLocalStream.fulfilled, doLocalStreamEffect.fulfilled),
|
|
4116
|
-
effect: ({ payload }, { getState }) => {
|
|
4117
|
-
var _a;
|
|
4118
|
-
const stream = selectLocalMediaStream(getState());
|
|
4119
|
-
const { rtcManager } = selectRtcConnectionRaw(getState());
|
|
4120
|
-
if (stream && rtcManager) {
|
|
4121
|
-
const replace = (kind, oldTrack) => {
|
|
4122
|
-
const track = stream.getTracks().find((t) => t.kind === kind);
|
|
4123
|
-
return track && rtcManager.replaceTrack(oldTrack, track);
|
|
4124
|
-
};
|
|
4125
|
-
(_a = payload === null || payload === void 0 ? void 0 : payload.replacedTracks) === null || _a === void 0 ? void 0 : _a.forEach((t) => {
|
|
4126
|
-
replace(t.kind, t);
|
|
4127
|
-
});
|
|
4128
|
-
}
|
|
4129
|
-
},
|
|
4130
|
-
});
|
|
4131
4142
|
startAppListening({
|
|
4132
4143
|
actionCreator: audioOnlyModeToggled,
|
|
4133
4144
|
effect: (_, { getState }) => {
|
package/dist/legacy-esm.js
CHANGED
|
@@ -1312,7 +1312,7 @@ const createReactor = (selectors, callback) => {
|
|
|
1312
1312
|
});
|
|
1313
1313
|
};
|
|
1314
1314
|
|
|
1315
|
-
const coreVersion = "1.31.
|
|
1315
|
+
const coreVersion = "1.31.7";
|
|
1316
1316
|
|
|
1317
1317
|
function decodeRoomName(roomName) {
|
|
1318
1318
|
if (!roomName) {
|
|
@@ -1909,6 +1909,17 @@ const localMediaSlice = createSlice({
|
|
|
1909
1909
|
});
|
|
1910
1910
|
},
|
|
1911
1911
|
});
|
|
1912
|
+
const snapshotTracks = (stream) => ({
|
|
1913
|
+
audio: stream.getAudioTracks()[0] || null,
|
|
1914
|
+
video: stream.getVideoTracks()[0] || null,
|
|
1915
|
+
});
|
|
1916
|
+
const findChangedTracks = (stream, before) => {
|
|
1917
|
+
const after = snapshotTracks(stream);
|
|
1918
|
+
return ["audio", "video"].flatMap((kind) => {
|
|
1919
|
+
const track = after[kind];
|
|
1920
|
+
return track && track !== before[kind] ? [{ track, oldTrack: before[kind] }] : [];
|
|
1921
|
+
});
|
|
1922
|
+
};
|
|
1912
1923
|
const { deviceBusy, setCurrentCameraDeviceId, setCurrentMicrophoneDeviceId, setCurrentSpeakerDeviceId, toggleCameraEnabled, toggleMicrophoneEnabled, toggleHdModeEnabled, toggleLowDataModeEnabled, toggleWidescreenModeEnabled, setLocalMediaOptions, setLocalMediaStream, localMediaStopped, localStreamMetadataUpdated, } = localMediaSlice.actions;
|
|
1913
1924
|
const doToggleCamera = createAppAsyncThunk("localMedia/doToggleCamera", (_1, _a) => __awaiter(void 0, [_1, _a], void 0, function* (_, { getState, rejectWithValue }) {
|
|
1914
1925
|
const state = getState();
|
|
@@ -1916,8 +1927,9 @@ const doToggleCamera = createAppAsyncThunk("localMedia/doToggleCamera", (_1, _a)
|
|
|
1916
1927
|
if (!stream) {
|
|
1917
1928
|
return;
|
|
1918
1929
|
}
|
|
1919
|
-
|
|
1930
|
+
const track = stream.getVideoTracks()[0];
|
|
1920
1931
|
const enabled = selectIsCameraEnabled(state);
|
|
1932
|
+
const before = snapshotTracks(stream);
|
|
1921
1933
|
try {
|
|
1922
1934
|
if (enabled) {
|
|
1923
1935
|
if (track) {
|
|
@@ -1927,7 +1939,6 @@ const doToggleCamera = createAppAsyncThunk("localMedia/doToggleCamera", (_1, _a)
|
|
|
1927
1939
|
const constraintsOptions = selectLocalMediaConstraintsOptions(state);
|
|
1928
1940
|
const cameraDeviceId = selectCurrentCameraDeviceId(state);
|
|
1929
1941
|
yield getStream(Object.assign(Object.assign({}, constraintsOptions), { audioId: false, videoId: cameraDeviceId, type: "exact" }), { replaceStream: stream });
|
|
1930
|
-
track = stream.getVideoTracks()[0];
|
|
1931
1942
|
}
|
|
1932
1943
|
}
|
|
1933
1944
|
else {
|
|
@@ -1938,7 +1949,7 @@ const doToggleCamera = createAppAsyncThunk("localMedia/doToggleCamera", (_1, _a)
|
|
|
1938
1949
|
track.stop();
|
|
1939
1950
|
stream.removeTrack(track);
|
|
1940
1951
|
}
|
|
1941
|
-
|
|
1952
|
+
return { changedTracks: findChangedTracks(stream, before) };
|
|
1942
1953
|
}
|
|
1943
1954
|
catch (error) {
|
|
1944
1955
|
return rejectWithValue(error);
|
|
@@ -1968,13 +1979,17 @@ const doSetDevice = createAppAsyncThunk("localMedia/reactSetDevice", (_a, _b) =>
|
|
|
1968
1979
|
const audioId = audio ? selectCurrentMicrophoneDeviceId(state) : false;
|
|
1969
1980
|
const videoId = video ? selectCurrentCameraDeviceId(state) : false;
|
|
1970
1981
|
const constraintsOptions = selectLocalMediaConstraintsOptions(state);
|
|
1982
|
+
const before = snapshotTracks(stream);
|
|
1971
1983
|
const { replacedTracks } = yield getStream(Object.assign(Object.assign({}, constraintsOptions), { audioId,
|
|
1972
1984
|
videoId, type: "exact" }), { replaceStream: stream });
|
|
1973
1985
|
const isAudioEnabled = selectIsMicrophoneEnabled(state);
|
|
1974
1986
|
stream.getAudioTracks().forEach((track) => (track.enabled = isAudioEnabled));
|
|
1975
1987
|
const isVideoEnabled = selectIsCameraEnabled(state);
|
|
1976
1988
|
stream.getVideoTracks().forEach((track) => (track.enabled = isVideoEnabled));
|
|
1977
|
-
return {
|
|
1989
|
+
return {
|
|
1990
|
+
replacedTracks,
|
|
1991
|
+
changedTracks: findChangedTracks(stream, before),
|
|
1992
|
+
};
|
|
1978
1993
|
}
|
|
1979
1994
|
catch (error) {
|
|
1980
1995
|
return rejectWithValue(error);
|
|
@@ -2048,6 +2063,7 @@ const doSwitchLocalStream = createAppAsyncThunk("localMedia/doSwitchLocalStream"
|
|
|
2048
2063
|
beforeEffectTracks.video = undefined;
|
|
2049
2064
|
}
|
|
2050
2065
|
const hasLiveTrackFromDevice = (deviceId) => (audioId ? replaceStream.getAudioTracks() : replaceStream.getVideoTracks()).some((track) => track.readyState === "live" && track.getSettings().deviceId === deviceId);
|
|
2066
|
+
const before = snapshotTracks(replaceStream);
|
|
2051
2067
|
try {
|
|
2052
2068
|
const { replacedTracks } = yield getStream(Object.assign(Object.assign({}, constraintsOptions), { audioId: audioId === undefined ? false : audioId, videoId: videoId === undefined ? false : videoId, type: "exact" }), { replaceStream });
|
|
2053
2069
|
const deviceId = audioId || videoId;
|
|
@@ -2056,7 +2072,11 @@ const doSwitchLocalStream = createAppAsyncThunk("localMedia/doSwitchLocalStream"
|
|
|
2056
2072
|
deviceId,
|
|
2057
2073
|
}));
|
|
2058
2074
|
}
|
|
2059
|
-
return {
|
|
2075
|
+
return {
|
|
2076
|
+
replacedTracks,
|
|
2077
|
+
beforeEffectTracks,
|
|
2078
|
+
changedTracks: findChangedTracks(replaceStream, before),
|
|
2079
|
+
};
|
|
2060
2080
|
}
|
|
2061
2081
|
catch (error) {
|
|
2062
2082
|
console.error(error);
|
|
@@ -2125,6 +2145,7 @@ const doLocalStreamEffect = createAppAsyncThunk("localMedia/doLocalStreamEffect"
|
|
|
2125
2145
|
if (!stream) {
|
|
2126
2146
|
throw new Error("No local media stream");
|
|
2127
2147
|
}
|
|
2148
|
+
const before = snapshotTracks(stream);
|
|
2128
2149
|
if (effectStream) {
|
|
2129
2150
|
if (!beforeTrack) {
|
|
2130
2151
|
beforeEffectTracks = {
|
|
@@ -2145,7 +2166,12 @@ const doLocalStreamEffect = createAppAsyncThunk("localMedia/doLocalStreamEffect"
|
|
|
2145
2166
|
};
|
|
2146
2167
|
beforeTrack.stop();
|
|
2147
2168
|
}
|
|
2148
|
-
return {
|
|
2169
|
+
return {
|
|
2170
|
+
effectStream,
|
|
2171
|
+
beforeEffectTracks,
|
|
2172
|
+
replacedTracks,
|
|
2173
|
+
changedTracks: findChangedTracks(stream, before),
|
|
2174
|
+
};
|
|
2149
2175
|
}
|
|
2150
2176
|
catch (error) {
|
|
2151
2177
|
console.error("Error applying local stream effect", error);
|
|
@@ -4065,19 +4091,21 @@ const selectRtcIsCreatingDispatcher = (state) => state.rtcConnection.isCreatingD
|
|
|
4065
4091
|
const selectRtcStatus = (state) => state.rtcConnection.status;
|
|
4066
4092
|
const selectIsAcceptingStreams = (state) => state.rtcConnection.isAcceptingStreams;
|
|
4067
4093
|
const selectIsAudioOnlyModeEnabled = (state) => state.rtcConnection.isAudioOnlyModeEnabled;
|
|
4094
|
+
const handOverChangedTracks = ({ payload }, { getState }) => {
|
|
4095
|
+
const { rtcManager } = selectRtcConnectionRaw(getState());
|
|
4096
|
+
payload === null || payload === void 0 ? void 0 : payload.changedTracks.forEach(({ track, oldTrack }) => {
|
|
4097
|
+
rtcManager === null || rtcManager === void 0 ? void 0 : rtcManager.replaceTrack(oldTrack, track);
|
|
4098
|
+
});
|
|
4099
|
+
};
|
|
4100
|
+
startAppListening({ actionCreator: doSetDevice.fulfilled, effect: handOverChangedTracks });
|
|
4101
|
+
startAppListening({ actionCreator: doSwitchLocalStream.fulfilled, effect: handOverChangedTracks });
|
|
4102
|
+
startAppListening({ actionCreator: doLocalStreamEffect.fulfilled, effect: handOverChangedTracks });
|
|
4068
4103
|
startAppListening({
|
|
4069
|
-
actionCreator:
|
|
4070
|
-
effect: (
|
|
4071
|
-
|
|
4104
|
+
actionCreator: doToggleCamera.fulfilled,
|
|
4105
|
+
effect: (action, { getState }) => {
|
|
4106
|
+
handOverChangedTracks(action, { getState });
|
|
4072
4107
|
const { rtcManager } = selectRtcConnectionRaw(getState());
|
|
4073
|
-
|
|
4074
|
-
const replace = (kind, oldTrack) => {
|
|
4075
|
-
const track = stream === null || stream === void 0 ? void 0 : stream.getTracks().find((t) => t.kind === kind);
|
|
4076
|
-
return track && (rtcManager === null || rtcManager === void 0 ? void 0 : rtcManager.replaceTrack(oldTrack, track));
|
|
4077
|
-
};
|
|
4078
|
-
replacedTracks === null || replacedTracks === void 0 ? void 0 : replacedTracks.forEach((t) => {
|
|
4079
|
-
replace(t.kind, t);
|
|
4080
|
-
});
|
|
4108
|
+
rtcManager === null || rtcManager === void 0 ? void 0 : rtcManager.stopOrResumeVideo({ enable: selectIsCameraEnabled(getState()) });
|
|
4081
4109
|
},
|
|
4082
4110
|
});
|
|
4083
4111
|
startAppListening({
|
|
@@ -4111,23 +4139,6 @@ startAppListening({
|
|
|
4111
4139
|
rtcManager === null || rtcManager === void 0 ? void 0 : rtcManager.removeScreenshareStream(stream);
|
|
4112
4140
|
},
|
|
4113
4141
|
});
|
|
4114
|
-
startAppListening({
|
|
4115
|
-
matcher: isAnyOf(doSwitchLocalStream.fulfilled, doLocalStreamEffect.fulfilled),
|
|
4116
|
-
effect: ({ payload }, { getState }) => {
|
|
4117
|
-
var _a;
|
|
4118
|
-
const stream = selectLocalMediaStream(getState());
|
|
4119
|
-
const { rtcManager } = selectRtcConnectionRaw(getState());
|
|
4120
|
-
if (stream && rtcManager) {
|
|
4121
|
-
const replace = (kind, oldTrack) => {
|
|
4122
|
-
const track = stream.getTracks().find((t) => t.kind === kind);
|
|
4123
|
-
return track && rtcManager.replaceTrack(oldTrack, track);
|
|
4124
|
-
};
|
|
4125
|
-
(_a = payload === null || payload === void 0 ? void 0 : payload.replacedTracks) === null || _a === void 0 ? void 0 : _a.forEach((t) => {
|
|
4126
|
-
replace(t.kind, t);
|
|
4127
|
-
});
|
|
4128
|
-
}
|
|
4129
|
-
},
|
|
4130
|
-
});
|
|
4131
4142
|
startAppListening({
|
|
4132
4143
|
actionCreator: audioOnlyModeToggled,
|
|
4133
4144
|
effect: (_, { getState }) => {
|
package/dist/redux/index.cjs
CHANGED
|
@@ -76,7 +76,7 @@ const createReactor = (selectors, callback) => {
|
|
|
76
76
|
});
|
|
77
77
|
};
|
|
78
78
|
|
|
79
|
-
const coreVersion = "1.31.
|
|
79
|
+
const coreVersion = "1.31.7";
|
|
80
80
|
|
|
81
81
|
function decodeRoomName(roomName) {
|
|
82
82
|
if (!roomName) {
|
|
@@ -692,6 +692,17 @@ const localMediaSlice = toolkit.createSlice({
|
|
|
692
692
|
});
|
|
693
693
|
},
|
|
694
694
|
});
|
|
695
|
+
const snapshotTracks = (stream) => ({
|
|
696
|
+
audio: stream.getAudioTracks()[0] || null,
|
|
697
|
+
video: stream.getVideoTracks()[0] || null,
|
|
698
|
+
});
|
|
699
|
+
const findChangedTracks = (stream, before) => {
|
|
700
|
+
const after = snapshotTracks(stream);
|
|
701
|
+
return ["audio", "video"].flatMap((kind) => {
|
|
702
|
+
const track = after[kind];
|
|
703
|
+
return track && track !== before[kind] ? [{ track, oldTrack: before[kind] }] : [];
|
|
704
|
+
});
|
|
705
|
+
};
|
|
695
706
|
const { deviceBusy, setCurrentCameraDeviceId, setCurrentMicrophoneDeviceId, setCurrentSpeakerDeviceId, toggleCameraEnabled, toggleMicrophoneEnabled, toggleHdModeEnabled, toggleLowDataModeEnabled, toggleWidescreenModeEnabled, setLocalMediaOptions, setLocalMediaStream, localMediaStopped, localStreamMetadataUpdated, } = localMediaSlice.actions;
|
|
696
707
|
const doToggleCamera = createAppAsyncThunk("localMedia/doToggleCamera", (_1, _a) => __awaiter(void 0, [_1, _a], void 0, function* (_, { getState, rejectWithValue }) {
|
|
697
708
|
const state = getState();
|
|
@@ -699,8 +710,9 @@ const doToggleCamera = createAppAsyncThunk("localMedia/doToggleCamera", (_1, _a)
|
|
|
699
710
|
if (!stream) {
|
|
700
711
|
return;
|
|
701
712
|
}
|
|
702
|
-
|
|
713
|
+
const track = stream.getVideoTracks()[0];
|
|
703
714
|
const enabled = selectIsCameraEnabled(state);
|
|
715
|
+
const before = snapshotTracks(stream);
|
|
704
716
|
try {
|
|
705
717
|
if (enabled) {
|
|
706
718
|
if (track) {
|
|
@@ -710,7 +722,6 @@ const doToggleCamera = createAppAsyncThunk("localMedia/doToggleCamera", (_1, _a)
|
|
|
710
722
|
const constraintsOptions = selectLocalMediaConstraintsOptions(state);
|
|
711
723
|
const cameraDeviceId = selectCurrentCameraDeviceId(state);
|
|
712
724
|
yield media.getStream(Object.assign(Object.assign({}, constraintsOptions), { audioId: false, videoId: cameraDeviceId, type: "exact" }), { replaceStream: stream });
|
|
713
|
-
track = stream.getVideoTracks()[0];
|
|
714
725
|
}
|
|
715
726
|
}
|
|
716
727
|
else {
|
|
@@ -721,7 +732,7 @@ const doToggleCamera = createAppAsyncThunk("localMedia/doToggleCamera", (_1, _a)
|
|
|
721
732
|
track.stop();
|
|
722
733
|
stream.removeTrack(track);
|
|
723
734
|
}
|
|
724
|
-
|
|
735
|
+
return { changedTracks: findChangedTracks(stream, before) };
|
|
725
736
|
}
|
|
726
737
|
catch (error) {
|
|
727
738
|
return rejectWithValue(error);
|
|
@@ -761,13 +772,17 @@ const doSetDevice = createAppAsyncThunk("localMedia/reactSetDevice", (_a, _b) =>
|
|
|
761
772
|
const audioId = audio ? selectCurrentMicrophoneDeviceId(state) : false;
|
|
762
773
|
const videoId = video ? selectCurrentCameraDeviceId(state) : false;
|
|
763
774
|
const constraintsOptions = selectLocalMediaConstraintsOptions(state);
|
|
775
|
+
const before = snapshotTracks(stream);
|
|
764
776
|
const { replacedTracks } = yield media.getStream(Object.assign(Object.assign({}, constraintsOptions), { audioId,
|
|
765
777
|
videoId, type: "exact" }), { replaceStream: stream });
|
|
766
778
|
const isAudioEnabled = selectIsMicrophoneEnabled(state);
|
|
767
779
|
stream.getAudioTracks().forEach((track) => (track.enabled = isAudioEnabled));
|
|
768
780
|
const isVideoEnabled = selectIsCameraEnabled(state);
|
|
769
781
|
stream.getVideoTracks().forEach((track) => (track.enabled = isVideoEnabled));
|
|
770
|
-
return {
|
|
782
|
+
return {
|
|
783
|
+
replacedTracks,
|
|
784
|
+
changedTracks: findChangedTracks(stream, before),
|
|
785
|
+
};
|
|
771
786
|
}
|
|
772
787
|
catch (error) {
|
|
773
788
|
return rejectWithValue(error);
|
|
@@ -841,6 +856,7 @@ const doSwitchLocalStream = createAppAsyncThunk("localMedia/doSwitchLocalStream"
|
|
|
841
856
|
beforeEffectTracks.video = undefined;
|
|
842
857
|
}
|
|
843
858
|
const hasLiveTrackFromDevice = (deviceId) => (audioId ? replaceStream.getAudioTracks() : replaceStream.getVideoTracks()).some((track) => track.readyState === "live" && track.getSettings().deviceId === deviceId);
|
|
859
|
+
const before = snapshotTracks(replaceStream);
|
|
844
860
|
try {
|
|
845
861
|
const { replacedTracks } = yield media.getStream(Object.assign(Object.assign({}, constraintsOptions), { audioId: audioId === undefined ? false : audioId, videoId: videoId === undefined ? false : videoId, type: "exact" }), { replaceStream });
|
|
846
862
|
const deviceId = audioId || videoId;
|
|
@@ -849,7 +865,11 @@ const doSwitchLocalStream = createAppAsyncThunk("localMedia/doSwitchLocalStream"
|
|
|
849
865
|
deviceId,
|
|
850
866
|
}));
|
|
851
867
|
}
|
|
852
|
-
return {
|
|
868
|
+
return {
|
|
869
|
+
replacedTracks,
|
|
870
|
+
beforeEffectTracks,
|
|
871
|
+
changedTracks: findChangedTracks(replaceStream, before),
|
|
872
|
+
};
|
|
853
873
|
}
|
|
854
874
|
catch (error) {
|
|
855
875
|
console.error(error);
|
|
@@ -918,6 +938,7 @@ const doLocalStreamEffect = createAppAsyncThunk("localMedia/doLocalStreamEffect"
|
|
|
918
938
|
if (!stream) {
|
|
919
939
|
throw new Error("No local media stream");
|
|
920
940
|
}
|
|
941
|
+
const before = snapshotTracks(stream);
|
|
921
942
|
if (effectStream) {
|
|
922
943
|
if (!beforeTrack) {
|
|
923
944
|
beforeEffectTracks = {
|
|
@@ -938,7 +959,12 @@ const doLocalStreamEffect = createAppAsyncThunk("localMedia/doLocalStreamEffect"
|
|
|
938
959
|
};
|
|
939
960
|
beforeTrack.stop();
|
|
940
961
|
}
|
|
941
|
-
return {
|
|
962
|
+
return {
|
|
963
|
+
effectStream,
|
|
964
|
+
beforeEffectTracks,
|
|
965
|
+
replacedTracks,
|
|
966
|
+
changedTracks: findChangedTracks(stream, before),
|
|
967
|
+
};
|
|
942
968
|
}
|
|
943
969
|
catch (error) {
|
|
944
970
|
console.error("Error applying local stream effect", error);
|
|
@@ -2871,19 +2897,21 @@ const selectRtcIsCreatingDispatcher = (state) => state.rtcConnection.isCreatingD
|
|
|
2871
2897
|
const selectRtcStatus = (state) => state.rtcConnection.status;
|
|
2872
2898
|
const selectIsAcceptingStreams = (state) => state.rtcConnection.isAcceptingStreams;
|
|
2873
2899
|
const selectIsAudioOnlyModeEnabled = (state) => state.rtcConnection.isAudioOnlyModeEnabled;
|
|
2900
|
+
const handOverChangedTracks = ({ payload }, { getState }) => {
|
|
2901
|
+
const { rtcManager } = selectRtcConnectionRaw(getState());
|
|
2902
|
+
payload === null || payload === void 0 ? void 0 : payload.changedTracks.forEach(({ track, oldTrack }) => {
|
|
2903
|
+
rtcManager === null || rtcManager === void 0 ? void 0 : rtcManager.replaceTrack(oldTrack, track);
|
|
2904
|
+
});
|
|
2905
|
+
};
|
|
2906
|
+
startAppListening({ actionCreator: doSetDevice.fulfilled, effect: handOverChangedTracks });
|
|
2907
|
+
startAppListening({ actionCreator: doSwitchLocalStream.fulfilled, effect: handOverChangedTracks });
|
|
2908
|
+
startAppListening({ actionCreator: doLocalStreamEffect.fulfilled, effect: handOverChangedTracks });
|
|
2874
2909
|
startAppListening({
|
|
2875
|
-
actionCreator:
|
|
2876
|
-
effect: (
|
|
2877
|
-
|
|
2910
|
+
actionCreator: doToggleCamera.fulfilled,
|
|
2911
|
+
effect: (action, { getState }) => {
|
|
2912
|
+
handOverChangedTracks(action, { getState });
|
|
2878
2913
|
const { rtcManager } = selectRtcConnectionRaw(getState());
|
|
2879
|
-
|
|
2880
|
-
const replace = (kind, oldTrack) => {
|
|
2881
|
-
const track = stream === null || stream === void 0 ? void 0 : stream.getTracks().find((t) => t.kind === kind);
|
|
2882
|
-
return track && (rtcManager === null || rtcManager === void 0 ? void 0 : rtcManager.replaceTrack(oldTrack, track));
|
|
2883
|
-
};
|
|
2884
|
-
replacedTracks === null || replacedTracks === void 0 ? void 0 : replacedTracks.forEach((t) => {
|
|
2885
|
-
replace(t.kind, t);
|
|
2886
|
-
});
|
|
2914
|
+
rtcManager === null || rtcManager === void 0 ? void 0 : rtcManager.stopOrResumeVideo({ enable: selectIsCameraEnabled(getState()) });
|
|
2887
2915
|
},
|
|
2888
2916
|
});
|
|
2889
2917
|
startAppListening({
|
|
@@ -2917,23 +2945,6 @@ startAppListening({
|
|
|
2917
2945
|
rtcManager === null || rtcManager === void 0 ? void 0 : rtcManager.removeScreenshareStream(stream);
|
|
2918
2946
|
},
|
|
2919
2947
|
});
|
|
2920
|
-
startAppListening({
|
|
2921
|
-
matcher: toolkit.isAnyOf(doSwitchLocalStream.fulfilled, doLocalStreamEffect.fulfilled),
|
|
2922
|
-
effect: ({ payload }, { getState }) => {
|
|
2923
|
-
var _a;
|
|
2924
|
-
const stream = selectLocalMediaStream(getState());
|
|
2925
|
-
const { rtcManager } = selectRtcConnectionRaw(getState());
|
|
2926
|
-
if (stream && rtcManager) {
|
|
2927
|
-
const replace = (kind, oldTrack) => {
|
|
2928
|
-
const track = stream.getTracks().find((t) => t.kind === kind);
|
|
2929
|
-
return track && rtcManager.replaceTrack(oldTrack, track);
|
|
2930
|
-
};
|
|
2931
|
-
(_a = payload === null || payload === void 0 ? void 0 : payload.replacedTracks) === null || _a === void 0 ? void 0 : _a.forEach((t) => {
|
|
2932
|
-
replace(t.kind, t);
|
|
2933
|
-
});
|
|
2934
|
-
}
|
|
2935
|
-
},
|
|
2936
|
-
});
|
|
2937
2948
|
startAppListening({
|
|
2938
2949
|
actionCreator: audioOnlyModeToggled,
|
|
2939
2950
|
effect: (_, { getState }) => {
|