@stream-io/video-react-native-sdk 1.44.0 → 1.45.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/CHANGELOG.md +25 -3
- package/dist/commonjs/hooks/push/useCallingExpWithCallingStateEffect.js +9 -5
- package/dist/commonjs/hooks/push/useCallingExpWithCallingStateEffect.js.map +1 -1
- package/dist/commonjs/hooks/useLoopbackRecording.js +10 -127
- package/dist/commonjs/hooks/useLoopbackRecording.js.map +1 -1
- package/dist/commonjs/utils/StreamVideoRN/index.js +2 -0
- package/dist/commonjs/utils/StreamVideoRN/index.js.map +1 -1
- package/dist/commonjs/utils/internal/callingx/callingx.js +2 -2
- package/dist/commonjs/utils/push/android.js +7 -167
- package/dist/commonjs/utils/push/android.js.map +1 -1
- package/dist/commonjs/utils/push/internal/android.js +186 -0
- package/dist/commonjs/utils/push/internal/android.js.map +1 -0
- package/dist/commonjs/utils/push/libs/firebaseMessaging/index.js +9 -1
- package/dist/commonjs/utils/push/libs/firebaseMessaging/index.js.map +1 -1
- package/dist/commonjs/utils/push/libs/firebaseMessaging/lib.js +1 -1
- package/dist/commonjs/utils/push/libs/firebaseMessaging/lib.js.map +1 -1
- package/dist/commonjs/utils/push/setupAndroidPushEvents.js +25 -0
- package/dist/commonjs/utils/push/setupAndroidPushEvents.js.map +1 -0
- package/dist/commonjs/utils/push/setupCallingExpEvents.js +6 -2
- package/dist/commonjs/utils/push/setupCallingExpEvents.js.map +1 -1
- package/dist/commonjs/utils/push/setupIosVoipPushEvents.js +6 -7
- package/dist/commonjs/utils/push/setupIosVoipPushEvents.js.map +1 -1
- package/dist/commonjs/utils/push/utils.js.map +1 -1
- package/dist/commonjs/version.js +1 -1
- package/dist/module/hooks/push/useCallingExpWithCallingStateEffect.js +9 -5
- package/dist/module/hooks/push/useCallingExpWithCallingStateEffect.js.map +1 -1
- package/dist/module/hooks/useLoopbackRecording.js +10 -127
- package/dist/module/hooks/useLoopbackRecording.js.map +1 -1
- package/dist/module/utils/StreamVideoRN/index.js +2 -0
- package/dist/module/utils/StreamVideoRN/index.js.map +1 -1
- package/dist/module/utils/internal/callingx/callingx.js +2 -2
- package/dist/module/utils/push/android.js +9 -169
- package/dist/module/utils/push/android.js.map +1 -1
- package/dist/module/utils/push/internal/android.js +182 -0
- package/dist/module/utils/push/internal/android.js.map +1 -0
- package/dist/module/utils/push/libs/firebaseMessaging/index.js +9 -1
- package/dist/module/utils/push/libs/firebaseMessaging/index.js.map +1 -1
- package/dist/module/utils/push/libs/firebaseMessaging/lib.js +1 -1
- package/dist/module/utils/push/libs/firebaseMessaging/lib.js.map +1 -1
- package/dist/module/utils/push/setupAndroidPushEvents.js +21 -0
- package/dist/module/utils/push/setupAndroidPushEvents.js.map +1 -0
- package/dist/module/utils/push/setupCallingExpEvents.js +6 -2
- package/dist/module/utils/push/setupCallingExpEvents.js.map +1 -1
- package/dist/module/utils/push/setupIosVoipPushEvents.js +6 -7
- package/dist/module/utils/push/setupIosVoipPushEvents.js.map +1 -1
- package/dist/module/utils/push/utils.js.map +1 -1
- package/dist/module/version.js +1 -1
- package/dist/typescript/hooks/push/useCallingExpWithCallingStateEffect.d.ts.map +1 -1
- package/dist/typescript/hooks/useLoopbackRecording.d.ts +12 -69
- package/dist/typescript/hooks/useLoopbackRecording.d.ts.map +1 -1
- package/dist/typescript/utils/StreamVideoRN/index.d.ts.map +1 -1
- package/dist/typescript/utils/push/android.d.ts +3 -4
- package/dist/typescript/utils/push/android.d.ts.map +1 -1
- package/dist/typescript/utils/push/internal/android.d.ts +8 -0
- package/dist/typescript/utils/push/internal/android.d.ts.map +1 -0
- package/dist/typescript/utils/push/libs/firebaseMessaging/index.d.ts +6 -4
- package/dist/typescript/utils/push/libs/firebaseMessaging/index.d.ts.map +1 -1
- package/dist/typescript/utils/push/libs/firebaseMessaging/lib.d.ts +2 -2
- package/dist/typescript/utils/push/libs/firebaseMessaging/lib.d.ts.map +1 -1
- package/dist/typescript/utils/push/setupAndroidPushEvents.d.ts +3 -0
- package/dist/typescript/utils/push/setupAndroidPushEvents.d.ts.map +1 -0
- package/dist/typescript/utils/push/setupCallingExpEvents.d.ts.map +1 -1
- package/dist/typescript/utils/push/setupIosVoipPushEvents.d.ts.map +1 -1
- package/dist/typescript/utils/push/utils.d.ts +2 -2
- package/dist/typescript/utils/push/utils.d.ts.map +1 -1
- package/dist/typescript/version.d.ts +1 -1
- package/ios/TracksRecorder/RecorderVideoSink.swift +92 -5
- package/package.json +4 -4
- package/src/hooks/push/useCallingExpWithCallingStateEffect.ts +12 -5
- package/src/hooks/useLoopbackRecording.ts +36 -248
- package/src/utils/StreamVideoRN/index.ts +2 -0
- package/src/utils/internal/callingx/callingx.ts +2 -2
- package/src/utils/push/android.ts +12 -237
- package/src/utils/push/internal/android.ts +252 -0
- package/src/utils/push/libs/firebaseMessaging/index.ts +16 -5
- package/src/utils/push/libs/firebaseMessaging/lib.ts +3 -3
- package/src/utils/push/setupAndroidPushEvents.ts +25 -0
- package/src/utils/push/setupCallingExpEvents.ts +6 -3
- package/src/utils/push/setupIosVoipPushEvents.ts +8 -7
- package/src/utils/push/utils.ts +2 -4
- package/src/version.ts +1 -1
|
@@ -21,7 +21,7 @@ export const useCallingExpWithCallingStateEffect = () => {
|
|
|
21
21
|
} = useCallStateHooks();
|
|
22
22
|
const activeCall = useCall();
|
|
23
23
|
const {
|
|
24
|
-
|
|
24
|
+
optimisticStatus,
|
|
25
25
|
microphone
|
|
26
26
|
} = useMicrophoneState();
|
|
27
27
|
const callMembers = useCallMembers();
|
|
@@ -31,7 +31,7 @@ export const useCallingExpWithCallingStateEffect = () => {
|
|
|
31
31
|
const callCustomDisplayName = activeCall?.state.custom?.display_name;
|
|
32
32
|
const currentUserId = activeCall?.currentUserId;
|
|
33
33
|
const isIncoming = activeCall?.ringing && !activeCall?.isCreatedByMe || false;
|
|
34
|
-
const callDisplayName = useMemo(() => callCustomDisplayName
|
|
34
|
+
const callDisplayName = useMemo(() => callCustomDisplayName || getCallDisplayName(callMembers, participants, currentUserId), [callMembers, participants, currentUserId, callCustomDisplayName]);
|
|
35
35
|
useEffect(() => {
|
|
36
36
|
const callingx = getCallingxLibIfAvailable();
|
|
37
37
|
if (!callingx?.isSetup || !activeCall) {
|
|
@@ -95,8 +95,12 @@ export const useCallingExpWithCallingStateEffect = () => {
|
|
|
95
95
|
logger.debug(`useCallingExpWithCallingStateEffect: No active call cid to set muted in calling exp: ${activeCallCid} isCallTracked: ${isCallTracked}`);
|
|
96
96
|
return;
|
|
97
97
|
}
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
if (optimisticStatus === undefined) {
|
|
99
|
+
logger.debug(`useCallingExpWithCallingStateEffect: mic status is not resolved yet, skipping mute sync for: ${activeCallCid}`);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
callingx.setMutedCall(activeCallCid, optimisticStatus === 'disabled');
|
|
103
|
+
}, [activeCallCid, optimisticStatus]);
|
|
100
104
|
|
|
101
105
|
// Sync mute state from CallKit → app (only for system-initiated mute actions)
|
|
102
106
|
useEffect(() => {
|
|
@@ -120,7 +124,7 @@ export const useCallingExpWithCallingStateEffect = () => {
|
|
|
120
124
|
logger.debug(`useCallingExpWithCallingStateEffect: No active call cid to set muted in calling exp: ${activeCallCid} isCallTracked: ${isCallTracked} callId: ${callId}`);
|
|
121
125
|
return;
|
|
122
126
|
}
|
|
123
|
-
const isCurrentlyMuted = microphone.state.
|
|
127
|
+
const isCurrentlyMuted = microphone.state.optimisticStatus === 'disabled';
|
|
124
128
|
if (isCurrentlyMuted === muted) {
|
|
125
129
|
logger.debug(`useCallingExpWithCallingStateEffect: Mic toggle is already in the desired state: ${muted} for call: ${activeCallCid}`);
|
|
126
130
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["CallingState","videoLoggerSystem","useCall","useCallStateHooks","useEffect","useMemo","Platform","AudioDeviceModule","filter","take","getCallDisplayName","getCallingxLibIfAvailable","logger","getLogger","useCallingExpWithCallingStateEffect","useMicrophoneState","useParticipants","useCallMembers","activeCall","
|
|
1
|
+
{"version":3,"names":["CallingState","videoLoggerSystem","useCall","useCallStateHooks","useEffect","useMemo","Platform","AudioDeviceModule","filter","take","getCallDisplayName","getCallingxLibIfAvailable","logger","getLogger","useCallingExpWithCallingStateEffect","useMicrophoneState","useParticipants","useCallMembers","activeCall","optimisticStatus","microphone","callMembers","participants","activeCallCid","cid","createdByUserId","state","createdBy","id","callCustomDisplayName","custom","display_name","currentUserId","isIncoming","ringing","isCreatedByMe","callDisplayName","callingx","isSetup","shouldMakeCallActive","call","isOngoingCallsEnabled","subscription","callingState$","pipe","callingState","JOINED","isCallTracked","subscribe","setCurrentCallActive","unsubscribe","debug","endCallWithReason","catch","error","updateDisplay","undefined","setMutedCall","addEventListener","event","callId","muted","isCurrentlyMuted","disable","enable","remove","activateSubscription","tracer","trace","deactivateSubscription","OS","timeouts","Set","traceRecordingState","trigger","status","isRecording","isEngineRunning","isMicrophoneMuted","warn","scheduleCheck","delayMs","timeout","setTimeout","delete","add","joinedSubscription","activationSubscription","forEach","clearTimeout","clear"],"sourceRoot":"../../../../src","sources":["hooks/push/useCallingExpWithCallingStateEffect.ts"],"mappings":";;AAAA,SAAeA,YAAY,EAAEC,iBAAiB,QAAQ,yBAAyB;AAC/E,SAASC,OAAO,EAAEC,iBAAiB,QAAQ,iCAAiC;AAC5E,SAASC,SAAS,EAAEC,OAAO,QAAQ,OAAO;AAC1C,SAASC,QAAQ,QAAQ,cAAc;AACvC,SAASC,iBAAiB,QAAQ,gCAAgC;AAClE,SAASC,MAAM,EAAEC,IAAI,QAAQ,gBAAgB;AAC7C,SAASC,kBAAkB,QAAQ,wCAAwC;AAC3E,SAASC,yBAAyB,QAAQ,gCAAgC;AAE1E,MAAMC,MAAM,GAAGX,iBAAiB,CAACY,SAAS,CAAC,UAAU,CAAC;;AAEtD;AACA;AACA;AACA,OAAO,MAAMC,mCAAmC,GAAGA,CAAA,KAAM;EACvD,M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useRef, useState } from 'react';
|
|
4
4
|
import { NativeModules } from 'react-native';
|
|
5
|
-
import {
|
|
6
|
-
import { CallingState, videoLoggerSystem } from '@stream-io/video-client';
|
|
5
|
+
import { CallingState, DEFAULT_LOOPBACK_RECORDING_DURATION_MS, LOOPBACK_STREAMS_WAIT_TIMEOUT_MS, clampLoopbackRecordingDuration, getLoopbackStreams, videoLoggerSystem, waitForLoopbackStreams, withLoopbackAudioEnabled } from '@stream-io/video-client';
|
|
7
6
|
import { useCall, useCallStateHooks } from '@stream-io/video-react-bindings';
|
|
8
7
|
|
|
9
8
|
/** @internal */
|
|
10
9
|
const {
|
|
11
10
|
StreamVideoReactNative
|
|
12
11
|
} = NativeModules;
|
|
13
|
-
|
|
14
|
-
// Upper bound on how long `startRecording` will wait for the SFU to
|
|
15
|
-
// echo loopback tracks back via the Subscriber. Tuned generously since
|
|
16
|
-
// this includes connection setup; consumers that want shorter feedback
|
|
17
|
-
// should call `stopRecording` to cancel the wait early.
|
|
18
|
-
const STREAMS_WAIT_TIMEOUT_MS = 10 * 1000;
|
|
19
|
-
const DEFAULT_RECORDING_DURATION = 10 * 1000;
|
|
20
|
-
const MIN_RECORDING_DURATION = 5 * 1000;
|
|
21
|
-
const MAX_RECORDING_DURATION = 2 * 60 * 1000;
|
|
22
|
-
/**
|
|
23
|
-
* Records the SFU loopback streams (audio + video) on the local participant
|
|
24
|
-
* to a local MP4 file. Designed for the `allowOwnTracksLoopback` pre-call test mode:
|
|
25
|
-
* the SFU echoes the caller's published tracks back through the Subscriber
|
|
26
|
-
* peer connection. The hook identifies the loopback streams on the local
|
|
27
|
-
* participant by reference inequality against
|
|
28
|
-
* `call.camera.state.mediaStream` / `call.microphone.state.mediaStream` —
|
|
29
|
-
* the canonical references to the local capture — and captures them.
|
|
30
|
-
*/
|
|
12
|
+
/** Records SFU loopback streams to a local MP4 file. */
|
|
31
13
|
export function useLoopbackRecording() {
|
|
32
14
|
const call = useCall();
|
|
33
15
|
const {
|
|
34
16
|
useCallCallingState,
|
|
35
17
|
useParticipantCount,
|
|
36
|
-
useLocalParticipant
|
|
37
|
-
useCameraState,
|
|
38
|
-
useMicrophoneState
|
|
18
|
+
useLocalParticipant
|
|
39
19
|
} = useCallStateHooks();
|
|
40
20
|
const callingState = useCallCallingState();
|
|
41
21
|
const participantCount = useParticipantCount();
|
|
42
22
|
const localParticipant = useLocalParticipant();
|
|
43
|
-
const {
|
|
44
|
-
mediaStream: cameraStream
|
|
45
|
-
} = useCameraState();
|
|
46
|
-
const {
|
|
47
|
-
mediaStream: microphoneStream
|
|
48
|
-
} = useMicrophoneState();
|
|
49
23
|
const [recordingState, setRecordingState] = useState('idle');
|
|
50
24
|
const recordingStateRef = useRef('idle');
|
|
51
25
|
const isMountedRef = useRef(true);
|
|
52
|
-
// Used to abort the awaiting-streams wait on stop / leave / unmount.
|
|
53
26
|
const awaitAbortRef = useRef(null);
|
|
54
|
-
const loopbackStreams = useMemo(() =>
|
|
27
|
+
const loopbackStreams = useMemo(() => getLoopbackStreams(call, localParticipant), [call, localParticipant]);
|
|
55
28
|
const updateState = useCallback(next => {
|
|
56
29
|
recordingStateRef.current = next;
|
|
57
30
|
if (isMountedRef.current) {
|
|
@@ -77,7 +50,7 @@ export function useLoopbackRecording() {
|
|
|
77
50
|
}, []);
|
|
78
51
|
const startRecording = useCallback(async ({
|
|
79
52
|
includeVideo = true,
|
|
80
|
-
maxDurationMs =
|
|
53
|
+
maxDurationMs = DEFAULT_LOOPBACK_RECORDING_DURATION_MS
|
|
81
54
|
} = {}) => {
|
|
82
55
|
if (!call) {
|
|
83
56
|
return null;
|
|
@@ -92,51 +65,30 @@ export function useLoopbackRecording() {
|
|
|
92
65
|
}
|
|
93
66
|
awaitAbortRef.current = new AbortController();
|
|
94
67
|
updateState('awaiting-streams');
|
|
95
|
-
let audioTrack;
|
|
96
68
|
try {
|
|
97
69
|
const streams = await waitForLoopbackStreams(call, {
|
|
98
70
|
includeVideo,
|
|
99
71
|
signal: awaitAbortRef.current.signal,
|
|
100
|
-
timeoutMs:
|
|
72
|
+
timeoutMs: LOOPBACK_STREAMS_WAIT_TIMEOUT_MS
|
|
101
73
|
});
|
|
102
74
|
if (streams === null) {
|
|
103
75
|
videoLoggerSystem.getLogger('useLoopbackRecording').warn('timed out waiting for loopback streams');
|
|
104
76
|
return null;
|
|
105
77
|
}
|
|
106
|
-
audioTrack = streams.audioTrack;
|
|
107
|
-
const videoTrackId = streams.videoTrack?.id;
|
|
108
|
-
|
|
109
|
-
// The loopback audio track lands disabled (the SDK default-mutes
|
|
110
|
-
// it to prevent echo). Enable it so the native recording
|
|
111
|
-
// pipeline receives PCM; `finally` returns it to muted.
|
|
112
|
-
if (audioTrack) {
|
|
113
|
-
audioTrack.enabled = true;
|
|
114
|
-
}
|
|
115
78
|
updateState('recording');
|
|
116
|
-
const clampedDuration = Math.min(MAX_RECORDING_DURATION, Math.max(MIN_RECORDING_DURATION, maxDurationMs));
|
|
117
|
-
|
|
118
|
-
// Pre-size the native encoder to the publisher's max video
|
|
119
|
-
// publish-option dimension. Without this, the encoder locks to
|
|
120
|
-
// whatever the SFU happens to echo *first* and stays there for the
|
|
121
|
-
// rest of the recording even after the network improves and
|
|
122
|
-
// higher layers arrive.
|
|
123
79
|
const publishMaxDim = call.getMaxVideoPublishDimension();
|
|
124
80
|
try {
|
|
125
|
-
|
|
126
|
-
videoTrackId,
|
|
127
|
-
maxDurationMs:
|
|
81
|
+
return await withLoopbackAudioEnabled(streams, () => StreamVideoReactNative.startTrackRecording({
|
|
82
|
+
videoTrackId: streams.videoTrack?.id,
|
|
83
|
+
maxDurationMs: clampLoopbackRecordingDuration(maxDurationMs),
|
|
128
84
|
targetWidth: publishMaxDim?.width,
|
|
129
85
|
targetHeight: publishMaxDim?.height
|
|
130
|
-
});
|
|
131
|
-
return uri;
|
|
86
|
+
}));
|
|
132
87
|
} catch (error) {
|
|
133
88
|
videoLoggerSystem.getLogger('useLoopbackRecording').error('failed to start recording', error);
|
|
134
89
|
throw new Error('failed to start recording');
|
|
135
90
|
}
|
|
136
91
|
} finally {
|
|
137
|
-
if (audioTrack) {
|
|
138
|
-
audioTrack.enabled = false;
|
|
139
|
-
}
|
|
140
92
|
awaitAbortRef.current = null;
|
|
141
93
|
updateState('idle');
|
|
142
94
|
}
|
|
@@ -158,21 +110,12 @@ export function useLoopbackRecording() {
|
|
|
158
110
|
throw new Error('failed to get recordings');
|
|
159
111
|
}
|
|
160
112
|
}, []);
|
|
161
|
-
|
|
162
|
-
// Auto-stop on call leave / end. Aborts an awaiting-streams wait or
|
|
163
|
-
// signals native finalisation depending on which phase we're in.
|
|
164
|
-
// Without this, leaving the call mid-recording would leave native
|
|
165
|
-
// encoders mid-write while the SFU subscriber tracks end under their
|
|
166
|
-
// feet — undefined final file state.
|
|
167
113
|
useEffect(() => {
|
|
168
114
|
if (callingState === CallingState.LEFT || callingState === CallingState.IDLE) {
|
|
169
115
|
videoLoggerSystem.getLogger('useLoopbackRecording').debug('auto-stopping recording on call leave / end');
|
|
170
116
|
stopRecording().catch(() => {});
|
|
171
117
|
}
|
|
172
118
|
}, [callingState, stopRecording]);
|
|
173
|
-
|
|
174
|
-
// Auto-stop if another participant joins. Loopback recording is a
|
|
175
|
-
// single-user pre-call test.
|
|
176
119
|
useEffect(() => {
|
|
177
120
|
if (recordingState !== 'idle' && participantCount > 1) {
|
|
178
121
|
stopRecording().catch(() => {});
|
|
@@ -197,64 +140,4 @@ export function useLoopbackRecording() {
|
|
|
197
140
|
loopbackAudioStream: loopbackStreams.loopbackAudioStream
|
|
198
141
|
};
|
|
199
142
|
}
|
|
200
|
-
function getLoopbackStreamsFor(participant, cameraStream, microphoneStream) {
|
|
201
|
-
return {
|
|
202
|
-
loopbackVideoStream: participant?.videoStream && participant.videoStream !== cameraStream ? participant.videoStream : undefined,
|
|
203
|
-
loopbackAudioStream: participant?.audioStream && participant.audioStream !== microphoneStream ? participant.audioStream : undefined
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* Subscribe to `localParticipant$` and resolve once the requested loopback
|
|
209
|
-
* streams are present on the participant. Aborts cleanly on `signal`
|
|
210
|
-
* (resolves `null`) and rejects on timeout.
|
|
211
|
-
*/
|
|
212
|
-
function waitForLoopbackStreams(call, opts) {
|
|
213
|
-
return new Promise((resolve, reject) => {
|
|
214
|
-
const initial = getLoopbackStreams(call.state.localParticipant, call.camera.state.mediaStream, call.microphone.state.mediaStream, opts.includeVideo);
|
|
215
|
-
if (initial) {
|
|
216
|
-
resolve(initial);
|
|
217
|
-
return;
|
|
218
|
-
}
|
|
219
|
-
const cleanup = () => {
|
|
220
|
-
subscription.unsubscribe();
|
|
221
|
-
if (timeoutId !== undefined) {
|
|
222
|
-
clearTimeout(timeoutId);
|
|
223
|
-
}
|
|
224
|
-
opts.signal.removeEventListener('abort', onAbort);
|
|
225
|
-
};
|
|
226
|
-
const onAbort = () => {
|
|
227
|
-
cleanup();
|
|
228
|
-
resolve(null);
|
|
229
|
-
};
|
|
230
|
-
opts.signal.addEventListener('abort', onAbort);
|
|
231
|
-
const timeoutId = setTimeout(() => {
|
|
232
|
-
cleanup();
|
|
233
|
-
reject(new Error('useLoopbackRecording: timed out waiting for loopback streams. ' + 'Ensure the call was joined with `allowOwnTracksLoopback: true` and ' + 'that the SFU is configured to echo self-sub tracks.'));
|
|
234
|
-
}, opts.timeoutMs);
|
|
235
|
-
const subscription = combineLatest([call.state.localParticipant$, call.camera.state.mediaStream$, call.microphone.state.mediaStream$]).subscribe(([participant, cameraStream, microphoneStream]) => {
|
|
236
|
-
const ready = getLoopbackStreams(participant, cameraStream, microphoneStream, opts.includeVideo);
|
|
237
|
-
if (ready) {
|
|
238
|
-
cleanup();
|
|
239
|
-
resolve(ready);
|
|
240
|
-
}
|
|
241
|
-
});
|
|
242
|
-
});
|
|
243
|
-
}
|
|
244
|
-
function getLoopbackStreams(participant, cameraStream, microphoneStream, includeVideo) {
|
|
245
|
-
if (!participant) return undefined;
|
|
246
|
-
const {
|
|
247
|
-
loopbackAudioStream,
|
|
248
|
-
loopbackVideoStream
|
|
249
|
-
} = getLoopbackStreamsFor(participant, cameraStream, microphoneStream);
|
|
250
|
-
const audioTrack = loopbackAudioStream?.getAudioTracks()[0];
|
|
251
|
-
const videoTrack = includeVideo ? loopbackVideoStream?.getVideoTracks()[0] : undefined;
|
|
252
|
-
if (!audioTrack || includeVideo && !videoTrack) {
|
|
253
|
-
return undefined;
|
|
254
|
-
}
|
|
255
|
-
return {
|
|
256
|
-
audioTrack,
|
|
257
|
-
videoTrack
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
143
|
//# sourceMappingURL=useLoopbackRecording.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useCallback","useEffect","useMemo","useRef","useState","NativeModules","
|
|
1
|
+
{"version":3,"names":["useCallback","useEffect","useMemo","useRef","useState","NativeModules","CallingState","DEFAULT_LOOPBACK_RECORDING_DURATION_MS","LOOPBACK_STREAMS_WAIT_TIMEOUT_MS","clampLoopbackRecordingDuration","getLoopbackStreams","videoLoggerSystem","waitForLoopbackStreams","withLoopbackAudioEnabled","useCall","useCallStateHooks","StreamVideoReactNative","useLoopbackRecording","call","useCallCallingState","useParticipantCount","useLocalParticipant","callingState","participantCount","localParticipant","recordingState","setRecordingState","recordingStateRef","isMountedRef","awaitAbortRef","loopbackStreams","updateState","next","current","stopRecording","getLogger","debug","abort","stopTrackRecording","error","Error","startRecording","includeVideo","maxDurationMs","warn","state","AbortController","streams","signal","timeoutMs","publishMaxDim","getMaxVideoPublishDimension","startTrackRecording","videoTrackId","videoTrack","id","targetWidth","width","targetHeight","height","clearRecordings","clearStreamRecordings","getRecordings","list","getStreamRecordings","LEFT","IDLE","catch","loopbackVideoStream","loopbackAudioStream"],"sourceRoot":"../../../src","sources":["hooks/useLoopbackRecording.ts"],"mappings":";;AAAA,SAASA,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ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L,YAAY,CAACK,OAAO,GAAG,KAAK;MAC5BtB,iBAAiB,CACdwB,SAAS,CAAC,sBAAsB,CAAC,CACjCC,KAAK,CAAC,oCAAoC,CAAC;MAC9CF,aAAa,CAAC,CAAC,CAACiC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;IACjC,CAAC;EACH,CAAC,EAAE,CAACjC,aAAa,CAAC,CAAC;EAEnB,OAAO;IACLO,cAAc;IACdP,aAAa;IACb0B,eAAe;IACfE,aAAa;IACbrC,cAAc;IACd2C,mBAAmB,EAAEtC,eAAe,CAACsC,mBAAmB;IACxDC,mBAAmB,EAAEvC,eAAe,CAACuC;EACvC,CAAC;AACH","ignoreList":[]}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import pushLogoutCallbacks from '../internal/pushLogoutCallback';
|
|
4
4
|
import { setupIosVoipPushEvents } from '../push/setupIosVoipPushEvents';
|
|
5
|
+
import { setupAndroidPushEvents } from '../push/setupAndroidPushEvents';
|
|
5
6
|
import { setupCallingExpEvents } from '../push/setupCallingExpEvents';
|
|
6
7
|
import { extractCallingExpOptions, getCallingxLib } from '../push/libs/callingx';
|
|
7
8
|
import { NativeModules, Platform } from 'react-native';
|
|
@@ -104,6 +105,7 @@ export class StreamVideoRN {
|
|
|
104
105
|
}
|
|
105
106
|
setupCallingExpEvents(pushConfig);
|
|
106
107
|
setupIosVoipPushEvents(pushConfig);
|
|
108
|
+
setupAndroidPushEvents(pushConfig);
|
|
107
109
|
}
|
|
108
110
|
static getConfig() {
|
|
109
111
|
return this.config;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["pushLogoutCallbacks","setupIosVoipPushEvents","setupCallingExpEvents","extractCallingExpOptions","getCallingxLib","NativeModules","Platform","videoLoggerSystem","deepMerge","target","source","result","key","undefined","Array","isArray","DEFAULT_STREAM_VIDEO_CONFIG","foregroundService","android","channel","id","name","notificationTexts","title","body","taskToRun","Promise","StreamVideoRN","config","updateConfig","setPushConfig","pushConfig","push","callingx","getLogger","info","JSON","stringify","options","setup","Error","getConfig","onPushLogout","callbacks","current","resolve","all","map","callback","then","clearPushLogoutCallbacks","playBusyTone","StreamVideoReactNative","stopBusyTone","androidHasAudioOutputHardware","OS","hasAudioOutputHardware","androidHasMicrophoneHardware","hasMicrophoneHardware","androidHasCameraHardware","hasCameraHardware"],"sourceRoot":"../../../../src","sources":["utils/StreamVideoRN/index.ts"],"mappings":";;AACA,OAAOA,mBAAmB,MAAM,gCAAgC;AAChE,SAASC,sBAAsB,QAAQ,gCAAgC;AACvE,SAASC,qBAAqB,QAAQ,+BAA+B;AACrE,SACEC,wBAAwB,EACxBC,cAAc,QACT,uBAAuB;AAC9B,SAASC,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AACtD,SAASC,iBAAiB,QAAQ,yBAAyB;;AAE3D;;AAKA;AACA,SAASC,SAASA,CAChBC,MAAS,EACTC,MAAsB,EACnB;EACH,MAAMC,MAAM,GAAG;IAAE,GAAGF;EAAO,CAAC;EAE5B,KAAK,MAAMG,GAAG,IAAIF,MAAM,EAAE;IACxB,IAAIA,MAAM,CAACE,GAAG,CAAC,KAAKC,SAAS,EAAE;MAC7B,IACE,OAAOH,MAAM,CAACE,GAAG,CAAC,KAAK,QAAQ,IAC/BF,MAAM,CAACE,GAAG,CAAC,KAAK,IAAI,IACpB,CAACE,KAAK,CAACC,OAAO,CAACL,MAAM,CAACE,GAAG,CAAC,CAAC,IAC3B,OAAOH,MAAM,CAACG,GAAG,CAAC,KAAK,QAAQ,IAC/BH,MAAM,CAACG,GAAG,CAAC,KAAK,IAAI,IACpB,CAACE,KAAK,CAACC,OAAO,CAACN,MAAM,CAACG,GAAG,CAAC,CAAC,EAC3B;QACAD,MAAM,CAACC,GAAG,CAAC,GAAGJ,SAAS,CACrBC,MAAM,CAACG,GAAG,CAAC,EACXF,MAAM,CAACE,GAAG,CACZ,CAAC;MACH,CAAC,MAAM;QACLD,MAAM,CAACC,GAAG,CAAC,GAA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AAC,CAAC,MAAM;MACN,MAAM,IAAIE,KAAK,CACb,iKACF,CAAC;IACH;IAEAtC,qBAAqB,CAAC6B,UAAU,CAAC;
|
|
1
|
+
{"version":3,"names":["pushLogoutCallbacks","setupIosVoipPushEvents","setupAndroidPushEvents","setupCallingExpEvents","extractCallingExpOptions","getCallingxLib","NativeModules","Platform","videoLoggerSystem","deepMerge","target","source","result","key","undefined","Array","isArray","DEFAULT_STREAM_VIDEO_CONFIG","foregroundService","android","channel","id","name","notificationTexts","title","body","taskToRun","Promise","StreamVideoRN","config","updateConfig","setPushConfig","pushConfig","push","callingx","getLogger","info","JSON","stringify","options","setup","Error","getConfig","onPushLogout","callbacks","current","resolve","all","map","callback","then","clearPushLogoutCallbacks","playBusyTone","StreamVideoReactNative","stopBusyTone","androidHasAudioOutputHardware","OS","hasAudioOutputHardware","androidHasMicrophoneHardware","hasMicrophoneHardware","androidHasCameraHardware","hasCameraHardware"],"sourceRoot":"../../../../src","sources":["utils/StreamVideoRN/index.ts"],"mappings":";;AACA,OAAOA,mBAAmB,MAAM,gCAAgC;AAChE,SAASC,sBAAsB,QAAQ,gCAAgC;AACvE,SAASC,sBAAsB,QAAQ,gCAAgC;AACvE,SAASC,qBAAqB,QAAQ,+BAA+B;AACrE,SACEC,wBAAwB,EACxBC,cAAc,QACT,uBAAuB;AAC9B,SAASC,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AACtD,SAASC,iBAAiB,QAAQ,yBAAyB;;AAE3D;;AAKA;AACA,SAASC,SAASA,CAChBC,MAAS,EACTC,MAAsB,EACnB;EACH,MAAMC,MAAM,GAAG;IAAE,GAAGF;EAAO,CAAC;EAE5B,KAAK,MAAMG,GAAG,IAAIF,MAAM,EAAE;IACxB,IAAIA,MAAM,CAACE,GAAG,CAAC,KAAKC,SAAS,EAAE;MAC7B,IACE,OAAOH,MAAM,CAACE,GAAG,CAAC,KAAK,QAAQ,IAC/BF,MAAM,CAACE,GAAG,CAAC,KAAK,IAAI,IACpB,C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AEA;AACF;AACA;EACE,aAAaE,YAAYA,CAAA,EAAG;IAC1B,OAAOhD,aAAa,CAAC+C,sBAAsB,CAACC,YAAY,CAAC,CAAC;EAC5D;;EAEA;AACF;AACA;AACA;EACE,aAAaC,6BAA6BA,CAAA,EAAqB;IAC7D,IAAIhD,QAAQ,CAACiD,EAAE,KAAK,SAAS,EAC3B,MAAM,IAAIf,KAAK,CACb,qEACF,CAAC;IACH,OAAOnC,aAAa,CAAC+C,sBAAsB,CAACI,sBAAsB,CAAC,CAAC;EACtE;;EAEA;AACF;AACA;AACA;EACE,aAAaC,4BAA4BA,CAAA,EAAqB;IAC5D,IAAInD,QAAQ,CAACiD,EAAE,KAAK,SAAS,EAC3B,MAAM,IAAIf,KAAK,CACb,oEACF,CAAC;IACH,OAAOnC,aAAa,CAAC+C,sBAAsB,CAACM,qBAAqB,CAAC,CAAC;EACrE;;EAEA;AACF;AACA;AACA;EACE,aAAaC,wBAAwBA,CAAA,EAAqB;IACxD,IAAIrD,QAAQ,CAACiD,EAAE,KAAK,SAAS,EAC3B,MAAM,IAAIf,KAAK,CACb,gEACF,CAAC;IACH,OAAOnC,aAAa,CAAC+C,sBAAsB,CAACQ,iBAAiB,CAAC,CAAC;EACjE;AACF","ignoreList":[]}
|
|
@@ -27,12 +27,12 @@ export function getCallDisplayName(callMembers, participants, currentUserId) {
|
|
|
27
27
|
|
|
28
28
|
// if no names are found, we use the name of the current user
|
|
29
29
|
if (names.length === 0) {
|
|
30
|
-
names = [participants.find(participant => participant.userId === currentUserId)?.name
|
|
30
|
+
names = [participants.find(participant => participant.userId === currentUserId)?.name || 'Call'];
|
|
31
31
|
}
|
|
32
32
|
return names.sort().join(', ');
|
|
33
33
|
}
|
|
34
34
|
function getCallDisplayNameFromCall(call) {
|
|
35
|
-
return call.state.custom?.display_name
|
|
35
|
+
return call.state.custom?.display_name || getCallDisplayName(call.state.members, call.state.participants, call.currentUserId);
|
|
36
36
|
}
|
|
37
37
|
export async function registerOutgoingCall(call) {
|
|
38
38
|
if (!CallingxModule || !CallingxModule.isSetup || call.isOwnTracksLoopbackAllowed) {
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { videoLoggerSystem } from '@stream-io/video-client';
|
|
4
|
+
import { Platform } from 'react-native';
|
|
5
5
|
import { getFirebaseMessagingLib } from './libs';
|
|
6
|
-
import { pushUnsubscriptionCallbacks } from './internal/constants';
|
|
7
|
-
import { canListenToWS, shouldCallBeClosed } from './internal/utils';
|
|
8
6
|
import { setPushLogoutCallback } from '../internal/pushLogoutCallback';
|
|
9
|
-
import { StreamVideoRN } from '../StreamVideoRN';
|
|
10
|
-
import { getCallingxLib } from './libs/callingx';
|
|
11
7
|
let lastFirebaseToken = {
|
|
12
8
|
token: '',
|
|
13
9
|
userId: ''
|
|
@@ -56,172 +52,16 @@ export async function initAndroidPushToken(client, pushConfig, setUnsubscribeLis
|
|
|
56
52
|
const token = await messaging().getToken();
|
|
57
53
|
await setDeviceToken(token);
|
|
58
54
|
}
|
|
59
|
-
|
|
55
|
+
let firebaseDataHandlerDeprecationLogged = false;
|
|
60
56
|
/**
|
|
61
|
-
*
|
|
62
|
-
*
|
|
57
|
+
* @deprecated Ring notifications are now handled by the SDK internally. This method is a no-op;
|
|
58
|
+
* you can safely remove `firebaseDataHandler(...)` wiring from your Firebase messaging handlers.
|
|
63
59
|
*/
|
|
64
|
-
|
|
65
60
|
export const firebaseDataHandler = async data => {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
call_display_name: '',
|
|
71
|
-
created_by_display_name: 'tommaso',
|
|
72
|
-
created_by_id: 'tommaso-03dcddb7-e9e2-42ec-b2f3-5043aac666ee',
|
|
73
|
-
receiver_id: 'martin-21824f17-319b-401b-a61b-fcab646f0d3f',
|
|
74
|
-
sender: 'stream.video',
|
|
75
|
-
type: 'call.live_started',
|
|
76
|
-
version: 'v2'
|
|
77
|
-
},
|
|
78
|
-
// other stuff
|
|
79
|
-
}
|
|
80
|
-
*/
|
|
81
|
-
if (Platform.OS !== 'android') return;
|
|
82
|
-
const logger = videoLoggerSystem.getLogger('firebaseDataHandler');
|
|
83
|
-
const pushConfig = StreamVideoRN.getConfig().push;
|
|
84
|
-
if (!pushConfig || !data || data.sender !== 'stream.video') {
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
if (data.type === 'call.ring') {
|
|
88
|
-
const call_cid = data.call_cid;
|
|
89
|
-
const callingx = getCallingxLib();
|
|
90
|
-
const client = await pushConfig.createStreamVideoClient();
|
|
91
|
-
if (!client) {
|
|
92
|
-
logger.debug(`video client not found, skipping the call.ring notification`);
|
|
93
|
-
await callingx.stopService();
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
const asForegroundService = canListenToWS();
|
|
97
|
-
if (asForegroundService) {
|
|
98
|
-
// Listen to call events from WS with headless task, bound to call service.
|
|
99
|
-
// By this moment the call service is already running, so we can acquire the background task.
|
|
100
|
-
const backgroundTaskOwner = `push:${call_cid}`;
|
|
101
|
-
await callingx.acquireBackgroundTask(backgroundTaskOwner).catch(e => {
|
|
102
|
-
logger.error(`Failed to acquire background task for callCid: ${call_cid} error: ${e}`);
|
|
103
|
-
});
|
|
104
|
-
const finishBackgroundTask = () => {
|
|
105
|
-
callingx.log(`Finishing background task for callCid: ${call_cid}`, 'debug');
|
|
106
|
-
callingx.releaseBackgroundTask(backgroundTaskOwner);
|
|
107
|
-
};
|
|
108
|
-
(async () => {
|
|
109
|
-
try {
|
|
110
|
-
const _client = await pushConfig.createStreamVideoClient();
|
|
111
|
-
if (!_client) {
|
|
112
|
-
logger.debug(`Closing fg service as there is no client to create from push config`);
|
|
113
|
-
finishBackgroundTask();
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
const callFromPush = await _client.onRingingCall(call_cid);
|
|
117
|
-
const {
|
|
118
|
-
mustEndCall,
|
|
119
|
-
endCallReason
|
|
120
|
-
} = shouldCallBeClosed(callFromPush, data);
|
|
121
|
-
if (mustEndCall) {
|
|
122
|
-
logger.debug(`Closing fg service callCid: ${call_cid} endCallReason: ${endCallReason}`);
|
|
123
|
-
callingx.log(`Ending call with callCid: ${call_cid} endCallReason: ${endCallReason}`, 'debug');
|
|
124
|
-
callingx.endCallWithReason(call_cid, endCallReason);
|
|
125
|
-
callFromPush.leave({
|
|
126
|
-
reject: false
|
|
127
|
-
}).catch(error => {
|
|
128
|
-
logger.error(`Failed to leave already-ended ringing call ${call_cid}: ${error}`);
|
|
129
|
-
});
|
|
130
|
-
finishBackgroundTask();
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
const unsubscribeFunctions = [];
|
|
134
|
-
// check if service needs to be closed if accept/decline event was done on another device
|
|
135
|
-
const unsubscribe = callFromPush.on('all', event => {
|
|
136
|
-
const _canListenToWS = canListenToWS();
|
|
137
|
-
if (!_canListenToWS) {
|
|
138
|
-
logger.debug(`Closing fg service from event callCid: ${call_cid} canListenToWS: ${_canListenToWS}`, {
|
|
139
|
-
event
|
|
140
|
-
});
|
|
141
|
-
unsubscribeFunctions.forEach(fn => fn());
|
|
142
|
-
finishBackgroundTask();
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
const {
|
|
146
|
-
mustEndCall: mustEndCallFromEvent,
|
|
147
|
-
endCallReason: endCallReasonFromEvent
|
|
148
|
-
} = shouldCallBeClosed(callFromPush, data);
|
|
149
|
-
if (mustEndCallFromEvent) {
|
|
150
|
-
logger.debug(`Closing fg service from event callCid: ${call_cid} canListenToWS: ${_canListenToWS} shouldCallBeClosed`, {
|
|
151
|
-
event
|
|
152
|
-
});
|
|
153
|
-
unsubscribeFunctions.forEach(fn => fn());
|
|
154
|
-
callingx.endCallWithReason(call_cid, endCallReasonFromEvent);
|
|
155
|
-
finishBackgroundTask();
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
// check if service needs to be closed if call was left
|
|
160
|
-
const stateSubscription = callFromPush.state.callingState$.subscribe(callingState => {
|
|
161
|
-
if (callingState === CallingState.IDLE || callingState === CallingState.LEFT) {
|
|
162
|
-
logger.debug(`Closing fg service from callingState callCid: ${call_cid} callingState: ${callingState}`);
|
|
163
|
-
unsubscribeFunctions.forEach(fn => fn());
|
|
164
|
-
callingx.log(`Ending call with callCid: ${call_cid} callingState: ${callingState}`, 'debug');
|
|
165
|
-
finishBackgroundTask();
|
|
166
|
-
}
|
|
167
|
-
});
|
|
168
|
-
const endCallSubscription = callingx.addEventListener('endCall', async ({
|
|
169
|
-
callId
|
|
170
|
-
}) => {
|
|
171
|
-
unsubscribeFunctions.forEach(fn => fn());
|
|
172
|
-
try {
|
|
173
|
-
await callFromPush.leave({
|
|
174
|
-
reject: callFromPush.state.callingState === CallingState.RINGING,
|
|
175
|
-
reason: 'decline'
|
|
176
|
-
});
|
|
177
|
-
} catch (error) {
|
|
178
|
-
logger.error(`Failed to leave call with callCid: ${call_cid} error: ${error}`);
|
|
179
|
-
} finally {
|
|
180
|
-
callingx.log(`Ending call with callCid: ${call_cid} callId: ${callId}`, 'debug');
|
|
181
|
-
finishBackgroundTask();
|
|
182
|
-
}
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
//stop background task when app comes to foreground
|
|
186
|
-
const appStateSubscription = AppState.addEventListener('change', nextAppState => {
|
|
187
|
-
const _canListenToWS = canListenToWS();
|
|
188
|
-
callingx.log(`AppState changed to: ${nextAppState} for callCid: ${call_cid} canListenToWS: ${_canListenToWS}`, 'debug');
|
|
189
|
-
if (!_canListenToWS) {
|
|
190
|
-
unsubscribeFunctions.forEach(fn => fn());
|
|
191
|
-
finishBackgroundTask();
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
194
|
-
});
|
|
195
|
-
unsubscribeFunctions.push(unsubscribe);
|
|
196
|
-
unsubscribeFunctions.push(() => stateSubscription.unsubscribe());
|
|
197
|
-
unsubscribeFunctions.push(() => endCallSubscription.remove());
|
|
198
|
-
unsubscribeFunctions.push(() => appStateSubscription.remove());
|
|
199
|
-
pushUnsubscriptionCallbacks.get(call_cid)?.forEach(cb => cb());
|
|
200
|
-
pushUnsubscriptionCallbacks.set(call_cid, unsubscribeFunctions);
|
|
201
|
-
} catch (error) {
|
|
202
|
-
callingx.log(`Failed to start background task with callCid: ${call_cid} error: ${error}`, 'error');
|
|
203
|
-
finishBackgroundTask();
|
|
204
|
-
}
|
|
205
|
-
})();
|
|
206
|
-
}
|
|
207
|
-
if (asForegroundService) {
|
|
208
|
-
// no need to check if call has be closed as that will be handled by the fg service
|
|
209
|
-
return;
|
|
210
|
-
}
|
|
211
|
-
const callFromPush = await client.onRingingCall(call_cid);
|
|
212
|
-
const {
|
|
213
|
-
mustEndCall,
|
|
214
|
-
endCallReason
|
|
215
|
-
} = shouldCallBeClosed(callFromPush, data);
|
|
216
|
-
if (mustEndCall) {
|
|
217
|
-
logger.debug(`Removing incoming call notification immediately with callCid: ${call_cid} as it should be closed`);
|
|
218
|
-
callingx.endCallWithReason(call_cid, endCallReason);
|
|
219
|
-
callFromPush.leave({
|
|
220
|
-
reject: false
|
|
221
|
-
}).catch(error => {
|
|
222
|
-
logger.error(`Failed to leave already-ended ringing call ${call_cid}: ${error}`);
|
|
223
|
-
});
|
|
224
|
-
}
|
|
61
|
+
void data;
|
|
62
|
+
if (!firebaseDataHandlerDeprecationLogged) {
|
|
63
|
+
firebaseDataHandlerDeprecationLogged = true;
|
|
64
|
+
console.warn('[@stream-io/video-react-native-sdk] `firebaseDataHandler` is deprecated. Ring notifications are now handled by the SDK internally — you can remove calls to it from your Firebase messaging handlers.');
|
|
225
65
|
}
|
|
226
66
|
};
|
|
227
67
|
//# sourceMappingURL=android.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["videoLoggerSystem","Platform","getFirebaseMessagingLib","setPushLogoutCallback","lastFirebaseToken","token","userId","initAndroidPushToken","client","pushConfig","setUnsubscribeListener","OS","android","pushProviderName","logger","getLogger","setDeviceToken","streamClient","_user","id","anonymous","debug","removeDevice","err","warn","push_provider_name","addDevice","messaging","unsubscribe","onTokenRefresh","refreshedToken","getToken","firebaseDataHandlerDeprecationLogged","firebaseDataHandler","data","console"],"sourceRoot":"../../../../src","sources":["utils/push/android.ts"],"mappings":";;AAAA,SAA4BA,iBAAiB,QAAQ,yBAAyB;AAC9E,SAASC,QAAQ,QAAQ,cAAc;AAEvC,SAASC,uBAAuB,QAAQ,QAAQ;AAChD,SAASC,qBAAqB,QAAQ,gCAAgC;AAItE,IAAIC,iBAAiB,GAAG;EAAEC,KAAK,EAAE,EAAE;EAAEC,MAAM,EAAE;AAAG,CAAC;;AAEjD;AACA,OAAO,eAAeC,oBAAoBA,CACxCC,MAAyB,EACzBC,UAAsB,EACtBC,sBAAyD,EACzD;EACA,IAAIT,QAAQ,CAACU,EAAE,KAAK,SAAS,IAAI,CAACF,UAAU,CAACG,OAAO,EAAEC,gBAAgB,EAAE;IACtE;EACF;EACA,MAAMC,MAAM,GAAGd,iBAAiB,CAACe,SAAS,CAAC,sBAAsB,CAAC;EAClE,MAAMC,cAAc,GAAG,MAAOX,KAAa,IAAK;IAC9C,MAAMC,MAAM,GAAGE,MAAM,CAACS,YAAY,CAACC,KAAK,EAAEC,EAAE,IAAI,EAAE;IAClD,IAAIX,MAAM,CAACS,YAAY,CAACG,SAAS,EAAE;MACjCN,MAAM,CAACO,KAAK,CAAC,mDAAmD,CAAC;MACjE;IACF;IACA,IACEjB,iBAAiB,CAACC,KAAK,KAAKA,KAAK,IACjCD,iBAAiB,CAACE,MAAM,KAAKA,MAAM,EACnC;MACAQ,MAAM,CAACO,KAAK,CACV,qDAAqDf,MAAM,eAAeD,KAAK,EACjF,CAAC;MACD;IACF;IACAD,iBAAiB,GAAG;MAAEC,KAAK;MAAEC;IAAO,CAAC;IACrCH,qBAAqB,CAAC,YAAY;MAChCC,iBAAiB,GAAG;QAAEC,KAAK,E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