@fishjam-cloud/react-native-client 0.1.1 → 0.2.1
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/README.md +416 -0
- package/android/build.gradle +8 -6
- package/app.plugin.js +1 -1
- package/build/RNFishjamClientModule.d.ts +7 -5
- package/build/RNFishjamClientModule.d.ts.map +1 -1
- package/build/RNFishjamClientModule.js.map +1 -1
- package/build/common/client.d.ts +8 -1
- package/build/common/client.d.ts.map +1 -1
- package/build/common/client.js +9 -2
- package/build/common/client.js.map +1 -1
- package/build/components/VideoPreviewView.d.ts +3 -3
- package/build/components/VideoPreviewView.d.ts.map +1 -1
- package/build/components/VideoPreviewView.js +1 -1
- package/build/components/VideoPreviewView.js.map +1 -1
- package/build/hooks/useAudioSettings.d.ts.map +1 -1
- package/build/hooks/useAudioSettings.js +4 -5
- package/build/hooks/useAudioSettings.js.map +1 -1
- package/build/hooks/useBandwidthEstimation.d.ts +0 -3
- package/build/hooks/useBandwidthEstimation.d.ts.map +1 -1
- package/build/hooks/useBandwidthEstimation.js +3 -6
- package/build/hooks/useBandwidthEstimation.js.map +1 -1
- package/build/hooks/useCamera.d.ts +12 -21
- package/build/hooks/useCamera.d.ts.map +1 -1
- package/build/hooks/useCamera.js +52 -52
- package/build/hooks/useCamera.js.map +1 -1
- package/build/{common/eventEmitter.d.ts → hooks/useFishjamEvent.d.ts} +2 -3
- package/build/hooks/useFishjamEvent.d.ts.map +1 -0
- package/build/{common/eventEmitter.js → hooks/useFishjamEvent.js} +11 -2
- package/build/hooks/useFishjamEvent.js.map +1 -0
- package/build/hooks/useMicrophone.d.ts.map +1 -1
- package/build/hooks/useMicrophone.js +3 -7
- package/build/hooks/useMicrophone.js.map +1 -1
- package/build/hooks/useParticipants.d.ts +0 -3
- package/build/hooks/useParticipants.d.ts.map +1 -1
- package/build/hooks/useParticipants.js +6 -6
- package/build/hooks/useParticipants.js.map +1 -1
- package/build/hooks/useReconnection.d.ts.map +1 -1
- package/build/hooks/useReconnection.js +8 -18
- package/build/hooks/useReconnection.js.map +1 -1
- package/build/hooks/useScreencast.d.ts.map +1 -1
- package/build/hooks/useScreencast.js +3 -7
- package/build/hooks/useScreencast.js.map +1 -1
- package/build/index.d.ts +4 -3
- package/build/index.d.ts.map +1 -1
- package/build/index.js +3 -1
- package/build/index.js.map +1 -1
- package/build/types.d.ts +25 -0
- package/build/types.d.ts.map +1 -1
- package/build/types.js +10 -1
- package/build/types.js.map +1 -1
- package/build/utils/foregroundService.d.ts +30 -0
- package/build/utils/foregroundService.d.ts.map +1 -0
- package/build/utils/foregroundService.js +41 -0
- package/build/utils/foregroundService.js.map +1 -0
- package/expo-module.config.json +3 -3
- package/ios/RNFishjamClient.swift +34 -29
- package/ios/RNFishjamClientModule.swift +12 -8
- package/package.json +23 -18
- package/.eslintignore +0 -7
- package/.eslintrc +0 -6
- package/.prettierrc +0 -9
- package/.watchmanconfig +0 -1
- package/android/.editorconfig +0 -9
- package/android/src/main/AndroidManifest.xml +0 -2
- package/android/src/main/java/org/membraneframework/reactnative/AudioDeviceKind.kt +0 -34
- package/android/src/main/java/org/membraneframework/reactnative/AudioSwitchManager.kt +0 -61
- package/android/src/main/java/org/membraneframework/reactnative/EmitableEvents.kt +0 -14
- package/android/src/main/java/org/membraneframework/reactnative/Errors.kt +0 -31
- package/android/src/main/java/org/membraneframework/reactnative/RNFishjamClient.kt +0 -866
- package/android/src/main/java/org/membraneframework/reactnative/RNFishjamClientModule.kt +0 -294
- package/android/src/main/java/org/membraneframework/reactnative/Utils.kt +0 -11
- package/android/src/main/java/org/membraneframework/reactnative/VideoPreviewView.kt +0 -40
- package/android/src/main/java/org/membraneframework/reactnative/VideoPreviewViewModule.kt +0 -17
- package/android/src/main/java/org/membraneframework/reactnative/VideoRendererView.kt +0 -58
- package/android/src/main/java/org/membraneframework/reactnative/VideoRendererViewModule.kt +0 -25
- package/android/src/main/java/org/membraneframework/reactnative/VideoView.kt +0 -77
- package/babel.config.js +0 -2
- package/build/common/eventEmitter.d.ts.map +0 -1
- package/build/common/eventEmitter.js.map +0 -1
- package/ios/swift-format-config.json +0 -56
- package/plugin/broadcastExtensionFiles/Info.plist +0 -27
- package/plugin/broadcastExtensionFiles/MembraneBroadcastSampleHandler.swift +0 -50
- package/plugin/broadcastExtensionFiles/MembraneScreenBroadcastExtension.entitlements +0 -10
- package/plugin/src/withMembrane.ts +0 -310
- package/plugin/tsconfig.json +0 -9
- package/scripts/lint.sh +0 -18
- package/scripts/lint_check.sh +0 -14
- package/src/RNFishjamClientModule.ts +0 -73
- package/src/__tests__/index.test.tsx +0 -199
- package/src/common/client.ts +0 -33
- package/src/common/eventEmitter.ts +0 -21
- package/src/common/metadata.ts +0 -12
- package/src/common/webRTC.ts +0 -31
- package/src/components/VideoPreviewView.tsx +0 -33
- package/src/components/VideoRendererView.tsx +0 -31
- package/src/hooks/useAudioSettings.ts +0 -115
- package/src/hooks/useBandwidthEstimation.ts +0 -24
- package/src/hooks/useCamera.ts +0 -270
- package/src/hooks/useMicrophone.ts +0 -38
- package/src/hooks/useParticipants.ts +0 -118
- package/src/hooks/useReconnection.ts +0 -41
- package/src/hooks/useScreencast.ts +0 -146
- package/src/index.tsx +0 -63
- package/src/protos/fishjam/peer_notifications.ts +0 -299
- package/src/stats/types.ts +0 -56
- package/src/stats/useRTCStatistics.ts +0 -97
- package/src/types.ts +0 -49
- package/tsconfig.json +0 -9
- package/typedoc.json +0 -5
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react';
|
|
2
|
-
import { ReceivableEvents, eventEmitter } from '../common/eventEmitter';
|
|
3
|
-
|
|
4
|
-
export type ReconnectionStatus = 'idle' | 'reconnecting' | 'error';
|
|
5
|
-
|
|
6
|
-
export function useReconnection() {
|
|
7
|
-
const [reconnectionStatus, setReconnectionStatus] =
|
|
8
|
-
useState<ReconnectionStatus>('idle');
|
|
9
|
-
|
|
10
|
-
useEffect(() => {
|
|
11
|
-
const reconnectedEventListener = eventEmitter.addListener(
|
|
12
|
-
ReceivableEvents.Reconnected,
|
|
13
|
-
() => {
|
|
14
|
-
setReconnectionStatus('idle');
|
|
15
|
-
},
|
|
16
|
-
);
|
|
17
|
-
|
|
18
|
-
const reconnectionStartedEventListener = eventEmitter.addListener(
|
|
19
|
-
ReceivableEvents.ReconnectionStarted,
|
|
20
|
-
() => {
|
|
21
|
-
setReconnectionStatus('reconnecting');
|
|
22
|
-
},
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
const reconnectionRetriesLimitReachedEventListener =
|
|
26
|
-
eventEmitter.addListener(
|
|
27
|
-
ReceivableEvents.ReconnectionRetriesLimitReached,
|
|
28
|
-
() => {
|
|
29
|
-
setReconnectionStatus('error');
|
|
30
|
-
},
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
return () => {
|
|
34
|
-
reconnectedEventListener.remove();
|
|
35
|
-
reconnectionStartedEventListener.remove();
|
|
36
|
-
reconnectionRetriesLimitReachedEventListener.remove();
|
|
37
|
-
};
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
return { reconnectionStatus };
|
|
41
|
-
}
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import { useCallback, useEffect, useState } from 'react';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
BandwidthLimit,
|
|
5
|
-
SimulcastConfig,
|
|
6
|
-
TrackBandwidthLimit,
|
|
7
|
-
TrackEncoding,
|
|
8
|
-
TrackMetadata,
|
|
9
|
-
} from '../types';
|
|
10
|
-
import RNFishjamClientModule from '../RNFishjamClientModule';
|
|
11
|
-
import { ReceivableEvents, eventEmitter } from '../common/eventEmitter';
|
|
12
|
-
import { Platform } from 'react-native';
|
|
13
|
-
|
|
14
|
-
type IsScreencastOnEvent = { IsScreencastOn: boolean };
|
|
15
|
-
|
|
16
|
-
export type ScreencastQuality = 'VGA' | 'HD5' | 'HD15' | 'FHD15' | 'FHD30';
|
|
17
|
-
|
|
18
|
-
export type ScreencastOptions = {
|
|
19
|
-
/**
|
|
20
|
-
* Resolution + fps of screencast track, one of: `VGA`, `HD5`, `HD15`, `FHD15`, `FHD30`.
|
|
21
|
-
* Note that quality might be worse than specified due to device capabilities, internet
|
|
22
|
-
* connection etc.
|
|
23
|
-
* @default `HD15``
|
|
24
|
-
*/
|
|
25
|
-
quality: ScreencastQuality;
|
|
26
|
-
/**
|
|
27
|
-
* bandwidth limit of a screencast track. By default there is no bandwidth limit.
|
|
28
|
-
*/
|
|
29
|
-
maxBandwidth: TrackBandwidthLimit;
|
|
30
|
-
};
|
|
31
|
-
export type ScreencastOptionsInternal = {
|
|
32
|
-
screencastMetadata: TrackMetadata & { displayName?: string };
|
|
33
|
-
/**
|
|
34
|
-
* SimulcastConfig of a screencast track. By default simulcast is disabled.
|
|
35
|
-
*/
|
|
36
|
-
simulcastConfig: SimulcastConfig;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const defaultSimulcastConfig = () => ({
|
|
40
|
-
enabled: false,
|
|
41
|
-
activeEncodings: [],
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
let screencastSimulcastConfig: SimulcastConfig = defaultSimulcastConfig();
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* This hook can toggle screen sharing on/off and provides current screencast state.
|
|
48
|
-
* @returns An object with functions to manage screencast.
|
|
49
|
-
*/
|
|
50
|
-
export function useScreencast() {
|
|
51
|
-
const [isScreencastOn, setIsScreencastOn] = useState<boolean>(
|
|
52
|
-
RNFishjamClientModule.isScreencastOn,
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
const [simulcastConfig, setSimulcastConfig] = useState<SimulcastConfig>(
|
|
56
|
-
screencastSimulcastConfig,
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
useEffect(() => {
|
|
60
|
-
const eventListener = eventEmitter.addListener<IsScreencastOnEvent>(
|
|
61
|
-
ReceivableEvents.IsScreencastOn,
|
|
62
|
-
(event) => setIsScreencastOn(event.IsScreencastOn),
|
|
63
|
-
);
|
|
64
|
-
setIsScreencastOn(RNFishjamClientModule.isScreencastOn);
|
|
65
|
-
return () => eventListener.remove();
|
|
66
|
-
}, []);
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Toggles the screencast on/off
|
|
70
|
-
*/
|
|
71
|
-
const toggleScreencast = useCallback(
|
|
72
|
-
async (screencastOptions: Partial<ScreencastOptions> = {}) => {
|
|
73
|
-
const options = {
|
|
74
|
-
...screencastOptions,
|
|
75
|
-
screencastMetadata: {
|
|
76
|
-
displayName: 'presenting',
|
|
77
|
-
type: 'screensharing' as const,
|
|
78
|
-
active: !isScreencastOn,
|
|
79
|
-
},
|
|
80
|
-
};
|
|
81
|
-
await RNFishjamClientModule.toggleScreencast(options);
|
|
82
|
-
screencastSimulcastConfig = defaultSimulcastConfig(); //to do: sync with camera settings
|
|
83
|
-
setSimulcastConfig(screencastSimulcastConfig);
|
|
84
|
-
},
|
|
85
|
-
[isScreencastOn],
|
|
86
|
-
);
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Toggles simulcast encoding of a screencast track on/off
|
|
90
|
-
* @param encoding encoding to toggle
|
|
91
|
-
*/
|
|
92
|
-
const toggleScreencastTrackEncoding = useCallback(
|
|
93
|
-
async (encoding: TrackEncoding) => {
|
|
94
|
-
screencastSimulcastConfig =
|
|
95
|
-
await RNFishjamClientModule.toggleScreencastTrackEncoding(encoding);
|
|
96
|
-
setSimulcastConfig(screencastSimulcastConfig);
|
|
97
|
-
},
|
|
98
|
-
[],
|
|
99
|
-
);
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* updates maximum bandwidth for the given simulcast encoding of the screencast track
|
|
103
|
-
* @param encoding encoding to update
|
|
104
|
-
* @param bandwidth BandwidthLimit to set
|
|
105
|
-
*/
|
|
106
|
-
const setScreencastTrackEncodingBandwidth = useCallback(
|
|
107
|
-
async (encoding: TrackEncoding, bandwidth: BandwidthLimit) => {
|
|
108
|
-
await RNFishjamClientModule.setScreencastTrackEncodingBandwidth(
|
|
109
|
-
encoding,
|
|
110
|
-
bandwidth,
|
|
111
|
-
);
|
|
112
|
-
},
|
|
113
|
-
[],
|
|
114
|
-
);
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* updates maximum bandwidth for the screencast track. This value directly translates
|
|
118
|
-
* to quality of the stream and the amount of RTP packets being sent. In case simulcast
|
|
119
|
-
* is enabled bandwidth is split between all of the variant streams proportionally to
|
|
120
|
-
* their resolution
|
|
121
|
-
* @param bandwidth BandwidthLimit to set
|
|
122
|
-
*/
|
|
123
|
-
const setScreencastTrackBandwidth = useCallback(
|
|
124
|
-
async (bandwidth: BandwidthLimit) => {
|
|
125
|
-
await RNFishjamClientModule.setScreencastTrackBandwidth(bandwidth);
|
|
126
|
-
},
|
|
127
|
-
[],
|
|
128
|
-
);
|
|
129
|
-
|
|
130
|
-
const handleScreencastPermission = useCallback(async () => {
|
|
131
|
-
if (Platform.OS == 'android') {
|
|
132
|
-
return await RNFishjamClientModule.handleScreencastPermission();
|
|
133
|
-
}
|
|
134
|
-
return 'denied';
|
|
135
|
-
}, []);
|
|
136
|
-
|
|
137
|
-
return {
|
|
138
|
-
isScreencastOn,
|
|
139
|
-
toggleScreencast,
|
|
140
|
-
toggleScreencastTrackEncoding,
|
|
141
|
-
simulcastConfig,
|
|
142
|
-
setScreencastTrackEncodingBandwidth,
|
|
143
|
-
setScreencastTrackBandwidth,
|
|
144
|
-
handleScreencastPermission,
|
|
145
|
-
};
|
|
146
|
-
}
|
package/src/index.tsx
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
export type {
|
|
2
|
-
Participant,
|
|
3
|
-
Track,
|
|
4
|
-
TrackType,
|
|
5
|
-
VadStatus,
|
|
6
|
-
EncodingReason,
|
|
7
|
-
} from './hooks/useParticipants';
|
|
8
|
-
export { useParticipants } from './hooks/useParticipants';
|
|
9
|
-
|
|
10
|
-
export type {
|
|
11
|
-
AudioOutputDevice,
|
|
12
|
-
AudioOutputDeviceType,
|
|
13
|
-
AudioSessionMode,
|
|
14
|
-
} from './hooks/useAudioSettings';
|
|
15
|
-
export { useAudioSettings } from './hooks/useAudioSettings';
|
|
16
|
-
|
|
17
|
-
export type { BandwidthEstimationEvent } from './hooks/useBandwidthEstimation';
|
|
18
|
-
export { useBandwidthEstimation } from './hooks/useBandwidthEstimation';
|
|
19
|
-
|
|
20
|
-
export type {
|
|
21
|
-
CaptureDevice,
|
|
22
|
-
CameraConfig,
|
|
23
|
-
VideoQuality,
|
|
24
|
-
} from './hooks/useCamera';
|
|
25
|
-
export { useCamera } from './hooks/useCamera';
|
|
26
|
-
|
|
27
|
-
export { useMicrophone } from './hooks/useMicrophone';
|
|
28
|
-
|
|
29
|
-
export { useRTCStatistics } from './stats/useRTCStatistics';
|
|
30
|
-
|
|
31
|
-
export type {
|
|
32
|
-
ScreencastOptions,
|
|
33
|
-
ScreencastQuality,
|
|
34
|
-
} from './hooks/useScreencast';
|
|
35
|
-
export { useScreencast } from './hooks/useScreencast';
|
|
36
|
-
|
|
37
|
-
export type { ReconnectionStatus } from './hooks/useReconnection';
|
|
38
|
-
export { useReconnection } from './hooks/useReconnection';
|
|
39
|
-
|
|
40
|
-
export { updatePeerMetadata } from './common/metadata';
|
|
41
|
-
|
|
42
|
-
export type { LoggingSeverity } from './common/webRTC';
|
|
43
|
-
export {
|
|
44
|
-
changeWebRTCLoggingSeverity,
|
|
45
|
-
setTargetTrackEncoding,
|
|
46
|
-
} from './common/webRTC';
|
|
47
|
-
|
|
48
|
-
export { connect, leaveRoom } from './common/client';
|
|
49
|
-
|
|
50
|
-
export type { VideoPreviewViewProps } from './components/VideoPreviewView';
|
|
51
|
-
export { VideoPreviewView } from './components/VideoPreviewView';
|
|
52
|
-
|
|
53
|
-
export type { VideoRendererProps } from './components/VideoRendererView';
|
|
54
|
-
export { VideoRendererView } from './components/VideoRendererView';
|
|
55
|
-
|
|
56
|
-
export type {
|
|
57
|
-
TrackBandwidthLimit,
|
|
58
|
-
TrackEncoding,
|
|
59
|
-
SimulcastBandwidthLimit,
|
|
60
|
-
BandwidthLimit,
|
|
61
|
-
SimulcastConfig,
|
|
62
|
-
VideoLayout,
|
|
63
|
-
} from './types';
|
|
@@ -1,299 +0,0 @@
|
|
|
1
|
-
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
2
|
-
// versions:
|
|
3
|
-
// protoc-gen-ts_proto v1.178.0
|
|
4
|
-
// protoc v5.26.1
|
|
5
|
-
// source: protos/fishjam/peer_notifications.proto
|
|
6
|
-
|
|
7
|
-
/* eslint-disable */
|
|
8
|
-
import * as _m0 from "protobufjs/minimal";
|
|
9
|
-
|
|
10
|
-
export const protobufPackage = "fishjam";
|
|
11
|
-
|
|
12
|
-
/** Defines any type of message sent between FJ and a peer */
|
|
13
|
-
export interface PeerMessage {
|
|
14
|
-
authenticated?: PeerMessage_Authenticated | undefined;
|
|
15
|
-
authRequest?: PeerMessage_AuthRequest | undefined;
|
|
16
|
-
mediaEvent?: PeerMessage_MediaEvent | undefined;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/** Response sent by FJ, confirming successfull authentication */
|
|
20
|
-
export interface PeerMessage_Authenticated {
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/** Request sent by peer, to authenticate to FJ server */
|
|
24
|
-
export interface PeerMessage_AuthRequest {
|
|
25
|
-
token: string;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/** Any type of WebRTC messages passed betweend FJ and peer */
|
|
29
|
-
export interface PeerMessage_MediaEvent {
|
|
30
|
-
data: string;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function createBasePeerMessage(): PeerMessage {
|
|
34
|
-
return { authenticated: undefined, authRequest: undefined, mediaEvent: undefined };
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export const PeerMessage = {
|
|
38
|
-
encode(message: PeerMessage, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
|
39
|
-
if (message.authenticated !== undefined) {
|
|
40
|
-
PeerMessage_Authenticated.encode(message.authenticated, writer.uint32(10).fork()).ldelim();
|
|
41
|
-
}
|
|
42
|
-
if (message.authRequest !== undefined) {
|
|
43
|
-
PeerMessage_AuthRequest.encode(message.authRequest, writer.uint32(18).fork()).ldelim();
|
|
44
|
-
}
|
|
45
|
-
if (message.mediaEvent !== undefined) {
|
|
46
|
-
PeerMessage_MediaEvent.encode(message.mediaEvent, writer.uint32(26).fork()).ldelim();
|
|
47
|
-
}
|
|
48
|
-
return writer;
|
|
49
|
-
},
|
|
50
|
-
|
|
51
|
-
decode(input: _m0.Reader | Uint8Array, length?: number): PeerMessage {
|
|
52
|
-
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
|
|
53
|
-
let end = length === undefined ? reader.len : reader.pos + length;
|
|
54
|
-
const message = createBasePeerMessage();
|
|
55
|
-
while (reader.pos < end) {
|
|
56
|
-
const tag = reader.uint32();
|
|
57
|
-
switch (tag >>> 3) {
|
|
58
|
-
case 1:
|
|
59
|
-
if (tag !== 10) {
|
|
60
|
-
break;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
message.authenticated = PeerMessage_Authenticated.decode(reader, reader.uint32());
|
|
64
|
-
continue;
|
|
65
|
-
case 2:
|
|
66
|
-
if (tag !== 18) {
|
|
67
|
-
break;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
message.authRequest = PeerMessage_AuthRequest.decode(reader, reader.uint32());
|
|
71
|
-
continue;
|
|
72
|
-
case 3:
|
|
73
|
-
if (tag !== 26) {
|
|
74
|
-
break;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
message.mediaEvent = PeerMessage_MediaEvent.decode(reader, reader.uint32());
|
|
78
|
-
continue;
|
|
79
|
-
}
|
|
80
|
-
if ((tag & 7) === 4 || tag === 0) {
|
|
81
|
-
break;
|
|
82
|
-
}
|
|
83
|
-
reader.skipType(tag & 7);
|
|
84
|
-
}
|
|
85
|
-
return message;
|
|
86
|
-
},
|
|
87
|
-
|
|
88
|
-
fromJSON(object: any): PeerMessage {
|
|
89
|
-
return {
|
|
90
|
-
authenticated: isSet(object.authenticated) ? PeerMessage_Authenticated.fromJSON(object.authenticated) : undefined,
|
|
91
|
-
authRequest: isSet(object.authRequest) ? PeerMessage_AuthRequest.fromJSON(object.authRequest) : undefined,
|
|
92
|
-
mediaEvent: isSet(object.mediaEvent) ? PeerMessage_MediaEvent.fromJSON(object.mediaEvent) : undefined,
|
|
93
|
-
};
|
|
94
|
-
},
|
|
95
|
-
|
|
96
|
-
toJSON(message: PeerMessage): unknown {
|
|
97
|
-
const obj: any = {};
|
|
98
|
-
if (message.authenticated !== undefined) {
|
|
99
|
-
obj.authenticated = PeerMessage_Authenticated.toJSON(message.authenticated);
|
|
100
|
-
}
|
|
101
|
-
if (message.authRequest !== undefined) {
|
|
102
|
-
obj.authRequest = PeerMessage_AuthRequest.toJSON(message.authRequest);
|
|
103
|
-
}
|
|
104
|
-
if (message.mediaEvent !== undefined) {
|
|
105
|
-
obj.mediaEvent = PeerMessage_MediaEvent.toJSON(message.mediaEvent);
|
|
106
|
-
}
|
|
107
|
-
return obj;
|
|
108
|
-
},
|
|
109
|
-
|
|
110
|
-
create<I extends Exact<DeepPartial<PeerMessage>, I>>(base?: I): PeerMessage {
|
|
111
|
-
return PeerMessage.fromPartial(base ?? ({} as any));
|
|
112
|
-
},
|
|
113
|
-
fromPartial<I extends Exact<DeepPartial<PeerMessage>, I>>(object: I): PeerMessage {
|
|
114
|
-
const message = createBasePeerMessage();
|
|
115
|
-
message.authenticated = (object.authenticated !== undefined && object.authenticated !== null)
|
|
116
|
-
? PeerMessage_Authenticated.fromPartial(object.authenticated)
|
|
117
|
-
: undefined;
|
|
118
|
-
message.authRequest = (object.authRequest !== undefined && object.authRequest !== null)
|
|
119
|
-
? PeerMessage_AuthRequest.fromPartial(object.authRequest)
|
|
120
|
-
: undefined;
|
|
121
|
-
message.mediaEvent = (object.mediaEvent !== undefined && object.mediaEvent !== null)
|
|
122
|
-
? PeerMessage_MediaEvent.fromPartial(object.mediaEvent)
|
|
123
|
-
: undefined;
|
|
124
|
-
return message;
|
|
125
|
-
},
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
function createBasePeerMessage_Authenticated(): PeerMessage_Authenticated {
|
|
129
|
-
return {};
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
export const PeerMessage_Authenticated = {
|
|
133
|
-
encode(_: PeerMessage_Authenticated, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
|
134
|
-
return writer;
|
|
135
|
-
},
|
|
136
|
-
|
|
137
|
-
decode(input: _m0.Reader | Uint8Array, length?: number): PeerMessage_Authenticated {
|
|
138
|
-
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
|
|
139
|
-
let end = length === undefined ? reader.len : reader.pos + length;
|
|
140
|
-
const message = createBasePeerMessage_Authenticated();
|
|
141
|
-
while (reader.pos < end) {
|
|
142
|
-
const tag = reader.uint32();
|
|
143
|
-
switch (tag >>> 3) {
|
|
144
|
-
}
|
|
145
|
-
if ((tag & 7) === 4 || tag === 0) {
|
|
146
|
-
break;
|
|
147
|
-
}
|
|
148
|
-
reader.skipType(tag & 7);
|
|
149
|
-
}
|
|
150
|
-
return message;
|
|
151
|
-
},
|
|
152
|
-
|
|
153
|
-
fromJSON(_: any): PeerMessage_Authenticated {
|
|
154
|
-
return {};
|
|
155
|
-
},
|
|
156
|
-
|
|
157
|
-
toJSON(_: PeerMessage_Authenticated): unknown {
|
|
158
|
-
const obj: any = {};
|
|
159
|
-
return obj;
|
|
160
|
-
},
|
|
161
|
-
|
|
162
|
-
create<I extends Exact<DeepPartial<PeerMessage_Authenticated>, I>>(base?: I): PeerMessage_Authenticated {
|
|
163
|
-
return PeerMessage_Authenticated.fromPartial(base ?? ({} as any));
|
|
164
|
-
},
|
|
165
|
-
fromPartial<I extends Exact<DeepPartial<PeerMessage_Authenticated>, I>>(_: I): PeerMessage_Authenticated {
|
|
166
|
-
const message = createBasePeerMessage_Authenticated();
|
|
167
|
-
return message;
|
|
168
|
-
},
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
function createBasePeerMessage_AuthRequest(): PeerMessage_AuthRequest {
|
|
172
|
-
return { token: "" };
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
export const PeerMessage_AuthRequest = {
|
|
176
|
-
encode(message: PeerMessage_AuthRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
|
177
|
-
if (message.token !== "") {
|
|
178
|
-
writer.uint32(10).string(message.token);
|
|
179
|
-
}
|
|
180
|
-
return writer;
|
|
181
|
-
},
|
|
182
|
-
|
|
183
|
-
decode(input: _m0.Reader | Uint8Array, length?: number): PeerMessage_AuthRequest {
|
|
184
|
-
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
|
|
185
|
-
let end = length === undefined ? reader.len : reader.pos + length;
|
|
186
|
-
const message = createBasePeerMessage_AuthRequest();
|
|
187
|
-
while (reader.pos < end) {
|
|
188
|
-
const tag = reader.uint32();
|
|
189
|
-
switch (tag >>> 3) {
|
|
190
|
-
case 1:
|
|
191
|
-
if (tag !== 10) {
|
|
192
|
-
break;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
message.token = reader.string();
|
|
196
|
-
continue;
|
|
197
|
-
}
|
|
198
|
-
if ((tag & 7) === 4 || tag === 0) {
|
|
199
|
-
break;
|
|
200
|
-
}
|
|
201
|
-
reader.skipType(tag & 7);
|
|
202
|
-
}
|
|
203
|
-
return message;
|
|
204
|
-
},
|
|
205
|
-
|
|
206
|
-
fromJSON(object: any): PeerMessage_AuthRequest {
|
|
207
|
-
return { token: isSet(object.token) ? globalThis.String(object.token) : "" };
|
|
208
|
-
},
|
|
209
|
-
|
|
210
|
-
toJSON(message: PeerMessage_AuthRequest): unknown {
|
|
211
|
-
const obj: any = {};
|
|
212
|
-
if (message.token !== "") {
|
|
213
|
-
obj.token = message.token;
|
|
214
|
-
}
|
|
215
|
-
return obj;
|
|
216
|
-
},
|
|
217
|
-
|
|
218
|
-
create<I extends Exact<DeepPartial<PeerMessage_AuthRequest>, I>>(base?: I): PeerMessage_AuthRequest {
|
|
219
|
-
return PeerMessage_AuthRequest.fromPartial(base ?? ({} as any));
|
|
220
|
-
},
|
|
221
|
-
fromPartial<I extends Exact<DeepPartial<PeerMessage_AuthRequest>, I>>(object: I): PeerMessage_AuthRequest {
|
|
222
|
-
const message = createBasePeerMessage_AuthRequest();
|
|
223
|
-
message.token = object.token ?? "";
|
|
224
|
-
return message;
|
|
225
|
-
},
|
|
226
|
-
};
|
|
227
|
-
|
|
228
|
-
function createBasePeerMessage_MediaEvent(): PeerMessage_MediaEvent {
|
|
229
|
-
return { data: "" };
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
export const PeerMessage_MediaEvent = {
|
|
233
|
-
encode(message: PeerMessage_MediaEvent, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
|
234
|
-
if (message.data !== "") {
|
|
235
|
-
writer.uint32(10).string(message.data);
|
|
236
|
-
}
|
|
237
|
-
return writer;
|
|
238
|
-
},
|
|
239
|
-
|
|
240
|
-
decode(input: _m0.Reader | Uint8Array, length?: number): PeerMessage_MediaEvent {
|
|
241
|
-
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
|
|
242
|
-
let end = length === undefined ? reader.len : reader.pos + length;
|
|
243
|
-
const message = createBasePeerMessage_MediaEvent();
|
|
244
|
-
while (reader.pos < end) {
|
|
245
|
-
const tag = reader.uint32();
|
|
246
|
-
switch (tag >>> 3) {
|
|
247
|
-
case 1:
|
|
248
|
-
if (tag !== 10) {
|
|
249
|
-
break;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
message.data = reader.string();
|
|
253
|
-
continue;
|
|
254
|
-
}
|
|
255
|
-
if ((tag & 7) === 4 || tag === 0) {
|
|
256
|
-
break;
|
|
257
|
-
}
|
|
258
|
-
reader.skipType(tag & 7);
|
|
259
|
-
}
|
|
260
|
-
return message;
|
|
261
|
-
},
|
|
262
|
-
|
|
263
|
-
fromJSON(object: any): PeerMessage_MediaEvent {
|
|
264
|
-
return { data: isSet(object.data) ? globalThis.String(object.data) : "" };
|
|
265
|
-
},
|
|
266
|
-
|
|
267
|
-
toJSON(message: PeerMessage_MediaEvent): unknown {
|
|
268
|
-
const obj: any = {};
|
|
269
|
-
if (message.data !== "") {
|
|
270
|
-
obj.data = message.data;
|
|
271
|
-
}
|
|
272
|
-
return obj;
|
|
273
|
-
},
|
|
274
|
-
|
|
275
|
-
create<I extends Exact<DeepPartial<PeerMessage_MediaEvent>, I>>(base?: I): PeerMessage_MediaEvent {
|
|
276
|
-
return PeerMessage_MediaEvent.fromPartial(base ?? ({} as any));
|
|
277
|
-
},
|
|
278
|
-
fromPartial<I extends Exact<DeepPartial<PeerMessage_MediaEvent>, I>>(object: I): PeerMessage_MediaEvent {
|
|
279
|
-
const message = createBasePeerMessage_MediaEvent();
|
|
280
|
-
message.data = object.data ?? "";
|
|
281
|
-
return message;
|
|
282
|
-
},
|
|
283
|
-
};
|
|
284
|
-
|
|
285
|
-
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
|
|
286
|
-
|
|
287
|
-
export type DeepPartial<T> = T extends Builtin ? T
|
|
288
|
-
: T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
|
|
289
|
-
: T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
|
|
290
|
-
: T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
|
|
291
|
-
: Partial<T>;
|
|
292
|
-
|
|
293
|
-
type KeysOfUnion<T> = T extends T ? keyof T : never;
|
|
294
|
-
export type Exact<P, I extends P> = P extends Builtin ? P
|
|
295
|
-
: P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };
|
|
296
|
-
|
|
297
|
-
function isSet(value: any): boolean {
|
|
298
|
-
return value !== null && value !== undefined;
|
|
299
|
-
}
|
package/src/stats/types.ts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A record of the total time, in seconds,
|
|
3
|
-
* that this stream has spent in each quality limitation state.
|
|
4
|
-
* none: The resolution and/or framerate is not limited.
|
|
5
|
-
* bandwidth: The resolution and/or framerate is primarily limited due to
|
|
6
|
-
* congestion cues during bandwidth estimation.
|
|
7
|
-
* Typical, congestion control algorithms use inter-arrival time,
|
|
8
|
-
* round-trip time, packet or other congestion cues to perform bandwidth estimation.
|
|
9
|
-
* cpu: The resolution and/or framerate is primarily limited due to CPU load.
|
|
10
|
-
* other: The resolution and/or framerate is primarily limited
|
|
11
|
-
* for a reason other than the above.
|
|
12
|
-
*/
|
|
13
|
-
export type QualityLimitationDurations = {
|
|
14
|
-
bandwidth: number;
|
|
15
|
-
cpu: number;
|
|
16
|
-
none: number;
|
|
17
|
-
other: number;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export type RTCOutboundStats = {
|
|
21
|
-
'kind': string;
|
|
22
|
-
'rid': string;
|
|
23
|
-
'bytesSent': number;
|
|
24
|
-
'targetBitrate': number;
|
|
25
|
-
'packetsSent': number;
|
|
26
|
-
'framesEncoded': number;
|
|
27
|
-
'framesPerSecond': number;
|
|
28
|
-
'frameWidth': number;
|
|
29
|
-
'frameHeight': number;
|
|
30
|
-
'qualityLimitationDurations': QualityLimitationDurations;
|
|
31
|
-
'bytesSent/s': number;
|
|
32
|
-
'packetsSent/s': number;
|
|
33
|
-
'framesEncoded/s': number;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export type RTCInboundStats = {
|
|
37
|
-
'kind': number;
|
|
38
|
-
'jitter': number;
|
|
39
|
-
'packetsLost': number;
|
|
40
|
-
'packetsReceived': number;
|
|
41
|
-
'bytesReceived': number;
|
|
42
|
-
'framesReceived': number;
|
|
43
|
-
'frameWidth': number;
|
|
44
|
-
'frameHeight': number;
|
|
45
|
-
'framesPerSecond': number;
|
|
46
|
-
'framesDropped': number;
|
|
47
|
-
'packetsLost/s': number;
|
|
48
|
-
'packetsReceived/s': number;
|
|
49
|
-
'bytesReceived/s': number;
|
|
50
|
-
'framesReceived/s': number;
|
|
51
|
-
'framesDropped/s': number;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
export type RTCTrackStats = RTCOutboundStats | RTCInboundStats;
|
|
55
|
-
|
|
56
|
-
export type RTCStats = { [key: string]: RTCTrackStats };
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { takeRight } from 'lodash';
|
|
2
|
-
import { useCallback, useEffect, useState } from 'react';
|
|
3
|
-
|
|
4
|
-
import type { RTCInboundStats, RTCOutboundStats, RTCStats } from './types';
|
|
5
|
-
import RNFishjamClientModule from '../RNFishjamClientModule';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* This hook provides access to current rtc statistics data.
|
|
9
|
-
*/
|
|
10
|
-
export function useRTCStatistics(refreshInterval: number) {
|
|
11
|
-
const MAX_SIZE = 120;
|
|
12
|
-
const [statistics, setStatistics] = useState<RTCStats[]>([]);
|
|
13
|
-
|
|
14
|
-
// Calculates diff between pervious and current stats,
|
|
15
|
-
// providing end users with a per second metric.
|
|
16
|
-
const processIncomingStats = useCallback(
|
|
17
|
-
(statistics: ReadonlyArray<RTCStats>, stats: Readonly<RTCStats>) => {
|
|
18
|
-
Object.keys(stats).forEach((obj) => {
|
|
19
|
-
if (obj.includes('Inbound')) {
|
|
20
|
-
const rtcStats = stats[obj] as RTCInboundStats;
|
|
21
|
-
|
|
22
|
-
if (
|
|
23
|
-
statistics.length > 0 &&
|
|
24
|
-
Object.keys(statistics[statistics.length - 1]).includes(obj)
|
|
25
|
-
) {
|
|
26
|
-
const prevRtcStats = statistics[statistics.length - 1][
|
|
27
|
-
obj
|
|
28
|
-
] as RTCInboundStats;
|
|
29
|
-
|
|
30
|
-
rtcStats['packetsLost/s'] =
|
|
31
|
-
rtcStats['packetsLost'] - prevRtcStats['packetsLost'];
|
|
32
|
-
rtcStats['packetsReceived/s'] =
|
|
33
|
-
rtcStats['packetsReceived'] - prevRtcStats['packetsReceived'];
|
|
34
|
-
rtcStats['bytesReceived/s'] =
|
|
35
|
-
rtcStats['bytesReceived'] - prevRtcStats['bytesReceived'];
|
|
36
|
-
rtcStats['framesReceived/s'] =
|
|
37
|
-
rtcStats['framesReceived'] - prevRtcStats['framesReceived'];
|
|
38
|
-
rtcStats['framesDropped/s'] =
|
|
39
|
-
rtcStats['framesDropped'] - prevRtcStats['framesDropped'];
|
|
40
|
-
} else {
|
|
41
|
-
rtcStats['packetsLost/s'] = 0;
|
|
42
|
-
rtcStats['packetsReceived/s'] = 0;
|
|
43
|
-
rtcStats['bytesReceived/s'] = 0;
|
|
44
|
-
rtcStats['framesReceived/s'] = 0;
|
|
45
|
-
rtcStats['framesDropped/s'] = 0;
|
|
46
|
-
}
|
|
47
|
-
return stats;
|
|
48
|
-
}
|
|
49
|
-
// Outbound
|
|
50
|
-
const rtcStats = stats[obj] as RTCOutboundStats;
|
|
51
|
-
|
|
52
|
-
if (
|
|
53
|
-
statistics.length > 0 &&
|
|
54
|
-
Object.keys(statistics[statistics.length - 1]).includes(obj)
|
|
55
|
-
) {
|
|
56
|
-
const prevRtcStats = statistics[statistics.length - 1][
|
|
57
|
-
obj
|
|
58
|
-
] as RTCOutboundStats;
|
|
59
|
-
|
|
60
|
-
rtcStats['bytesSent/s'] =
|
|
61
|
-
rtcStats['bytesSent'] - prevRtcStats['bytesSent'];
|
|
62
|
-
rtcStats['packetsSent/s'] =
|
|
63
|
-
rtcStats['packetsSent'] - prevRtcStats['packetsSent'];
|
|
64
|
-
rtcStats['framesEncoded/s'] =
|
|
65
|
-
rtcStats['framesEncoded'] - prevRtcStats['framesEncoded'];
|
|
66
|
-
} else {
|
|
67
|
-
rtcStats['bytesSent/s'] = 0;
|
|
68
|
-
rtcStats['packetsSent/s'] = 0;
|
|
69
|
-
rtcStats['framesEncoded/s'] = 0;
|
|
70
|
-
}
|
|
71
|
-
return stats;
|
|
72
|
-
});
|
|
73
|
-
return stats;
|
|
74
|
-
},
|
|
75
|
-
[],
|
|
76
|
-
);
|
|
77
|
-
|
|
78
|
-
// Gets stats from the native libraries.
|
|
79
|
-
const getStatistics = useCallback(async () => {
|
|
80
|
-
const stats = await RNFishjamClientModule.getStatistics();
|
|
81
|
-
setStatistics((prev) => {
|
|
82
|
-
const newStats = [...prev, processIncomingStats(prev, stats)];
|
|
83
|
-
takeRight(newStats, MAX_SIZE);
|
|
84
|
-
return newStats;
|
|
85
|
-
});
|
|
86
|
-
}, [processIncomingStats]);
|
|
87
|
-
|
|
88
|
-
useEffect(() => {
|
|
89
|
-
const intervalId = setInterval(getStatistics, refreshInterval);
|
|
90
|
-
return () => {
|
|
91
|
-
clearInterval(intervalId);
|
|
92
|
-
setStatistics([]);
|
|
93
|
-
};
|
|
94
|
-
}, [getStatistics, refreshInterval]);
|
|
95
|
-
|
|
96
|
-
return { statistics };
|
|
97
|
-
}
|