@fishjam-cloud/react-native-client 0.1.1 → 0.2.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.
Files changed (110) hide show
  1. package/README.md +403 -0
  2. package/android/build.gradle +6 -6
  3. package/app.plugin.js +1 -1
  4. package/build/RNFishjamClientModule.d.ts +7 -5
  5. package/build/RNFishjamClientModule.d.ts.map +1 -1
  6. package/build/RNFishjamClientModule.js.map +1 -1
  7. package/build/common/client.d.ts +8 -1
  8. package/build/common/client.d.ts.map +1 -1
  9. package/build/common/client.js +9 -2
  10. package/build/common/client.js.map +1 -1
  11. package/build/components/VideoPreviewView.d.ts +3 -3
  12. package/build/components/VideoPreviewView.d.ts.map +1 -1
  13. package/build/components/VideoPreviewView.js +1 -1
  14. package/build/components/VideoPreviewView.js.map +1 -1
  15. package/build/hooks/useAudioSettings.d.ts.map +1 -1
  16. package/build/hooks/useAudioSettings.js +4 -5
  17. package/build/hooks/useAudioSettings.js.map +1 -1
  18. package/build/hooks/useBandwidthEstimation.d.ts +0 -3
  19. package/build/hooks/useBandwidthEstimation.d.ts.map +1 -1
  20. package/build/hooks/useBandwidthEstimation.js +3 -6
  21. package/build/hooks/useBandwidthEstimation.js.map +1 -1
  22. package/build/hooks/useCamera.d.ts +12 -21
  23. package/build/hooks/useCamera.d.ts.map +1 -1
  24. package/build/hooks/useCamera.js +52 -52
  25. package/build/hooks/useCamera.js.map +1 -1
  26. package/build/{common/eventEmitter.d.ts → hooks/useFishjamEvent.d.ts} +2 -3
  27. package/build/hooks/useFishjamEvent.d.ts.map +1 -0
  28. package/build/{common/eventEmitter.js → hooks/useFishjamEvent.js} +11 -2
  29. package/build/hooks/useFishjamEvent.js.map +1 -0
  30. package/build/hooks/useMicrophone.d.ts.map +1 -1
  31. package/build/hooks/useMicrophone.js +3 -7
  32. package/build/hooks/useMicrophone.js.map +1 -1
  33. package/build/hooks/useParticipants.d.ts +0 -3
  34. package/build/hooks/useParticipants.d.ts.map +1 -1
  35. package/build/hooks/useParticipants.js +6 -6
  36. package/build/hooks/useParticipants.js.map +1 -1
  37. package/build/hooks/useReconnection.d.ts.map +1 -1
  38. package/build/hooks/useReconnection.js +8 -18
  39. package/build/hooks/useReconnection.js.map +1 -1
  40. package/build/hooks/useScreencast.d.ts.map +1 -1
  41. package/build/hooks/useScreencast.js +3 -7
  42. package/build/hooks/useScreencast.js.map +1 -1
  43. package/build/index.d.ts +4 -3
  44. package/build/index.d.ts.map +1 -1
  45. package/build/index.js +3 -1
  46. package/build/index.js.map +1 -1
  47. package/build/types.d.ts +25 -0
  48. package/build/types.d.ts.map +1 -1
  49. package/build/types.js +10 -1
  50. package/build/types.js.map +1 -1
  51. package/build/utils/foregroundService.d.ts +30 -0
  52. package/build/utils/foregroundService.d.ts.map +1 -0
  53. package/build/utils/foregroundService.js +41 -0
  54. package/build/utils/foregroundService.js.map +1 -0
  55. package/ios/RNFishjamClient.swift +34 -29
  56. package/ios/RNFishjamClientModule.swift +11 -7
  57. package/package.json +19 -17
  58. package/.eslintignore +0 -7
  59. package/.eslintrc +0 -6
  60. package/.prettierrc +0 -9
  61. package/.watchmanconfig +0 -1
  62. package/android/.editorconfig +0 -9
  63. package/android/src/main/AndroidManifest.xml +0 -2
  64. package/android/src/main/java/org/membraneframework/reactnative/AudioDeviceKind.kt +0 -34
  65. package/android/src/main/java/org/membraneframework/reactnative/AudioSwitchManager.kt +0 -61
  66. package/android/src/main/java/org/membraneframework/reactnative/EmitableEvents.kt +0 -14
  67. package/android/src/main/java/org/membraneframework/reactnative/Errors.kt +0 -31
  68. package/android/src/main/java/org/membraneframework/reactnative/RNFishjamClient.kt +0 -866
  69. package/android/src/main/java/org/membraneframework/reactnative/RNFishjamClientModule.kt +0 -294
  70. package/android/src/main/java/org/membraneframework/reactnative/Utils.kt +0 -11
  71. package/android/src/main/java/org/membraneframework/reactnative/VideoPreviewView.kt +0 -40
  72. package/android/src/main/java/org/membraneframework/reactnative/VideoPreviewViewModule.kt +0 -17
  73. package/android/src/main/java/org/membraneframework/reactnative/VideoRendererView.kt +0 -58
  74. package/android/src/main/java/org/membraneframework/reactnative/VideoRendererViewModule.kt +0 -25
  75. package/android/src/main/java/org/membraneframework/reactnative/VideoView.kt +0 -77
  76. package/babel.config.js +0 -2
  77. package/build/common/eventEmitter.d.ts.map +0 -1
  78. package/build/common/eventEmitter.js.map +0 -1
  79. package/expo-module.config.json +0 -17
  80. package/ios/RNFishjamClient.podspec +0 -30
  81. package/ios/swift-format-config.json +0 -56
  82. package/plugin/broadcastExtensionFiles/Info.plist +0 -27
  83. package/plugin/broadcastExtensionFiles/MembraneBroadcastSampleHandler.swift +0 -50
  84. package/plugin/broadcastExtensionFiles/MembraneScreenBroadcastExtension.entitlements +0 -10
  85. package/plugin/src/withMembrane.ts +0 -310
  86. package/plugin/tsconfig.json +0 -9
  87. package/scripts/lint.sh +0 -18
  88. package/scripts/lint_check.sh +0 -14
  89. package/src/RNFishjamClientModule.ts +0 -73
  90. package/src/__tests__/index.test.tsx +0 -199
  91. package/src/common/client.ts +0 -33
  92. package/src/common/eventEmitter.ts +0 -21
  93. package/src/common/metadata.ts +0 -12
  94. package/src/common/webRTC.ts +0 -31
  95. package/src/components/VideoPreviewView.tsx +0 -33
  96. package/src/components/VideoRendererView.tsx +0 -31
  97. package/src/hooks/useAudioSettings.ts +0 -115
  98. package/src/hooks/useBandwidthEstimation.ts +0 -24
  99. package/src/hooks/useCamera.ts +0 -270
  100. package/src/hooks/useMicrophone.ts +0 -38
  101. package/src/hooks/useParticipants.ts +0 -118
  102. package/src/hooks/useReconnection.ts +0 -41
  103. package/src/hooks/useScreencast.ts +0 -146
  104. package/src/index.tsx +0 -63
  105. package/src/protos/fishjam/peer_notifications.ts +0 -299
  106. package/src/stats/types.ts +0 -56
  107. package/src/stats/useRTCStatistics.ts +0 -97
  108. package/src/types.ts +0 -49
  109. package/tsconfig.json +0 -9
  110. package/typedoc.json +0 -5
@@ -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
- }
package/src/types.ts DELETED
@@ -1,49 +0,0 @@
1
- // global
2
- export type VideoLayout = 'FILL' | 'FIT';
3
-
4
- export type TrackEncoding = 'l' | 'm' | 'h';
5
-
6
- /**
7
- * A type describing simulcast configuration.
8
- *
9
- * At the moment, simulcast track is initialized in three versions - low, medium and high.
10
- * High resolution is the original track resolution, while medium and low resolutions are
11
- * the original track resolution scaled down by 2 and 4 respectively.
12
- */
13
- export type SimulcastConfig = {
14
- /**
15
- * whether to simulcast track or not. By default simulcast is disabled.
16
- */
17
- enabled: boolean;
18
- /**
19
- * list of active encodings. Encoding can be one of `"h"` (original encoding), `"m"` (scaled down x2), `"l"` (scaled down x4).
20
- */
21
- activeEncodings: TrackEncoding[];
22
- };
23
-
24
- /**
25
- * Type describing maximal bandwidth that can be used, in kbps. 0 is interpreted as unlimited bandwidth.
26
- */
27
- export type BandwidthLimit = number;
28
-
29
- /**
30
- * Type describing bandwidth limit for simulcast track. It is a mapping `encoding -> BandwidthLimit`. If encoding isn't present in this mapping,
31
- * it will be assumed that this particular encoding shouldn't have any bandwidth limit.
32
- */
33
- export type SimulcastBandwidthLimit = Record<TrackEncoding, BandwidthLimit>;
34
-
35
- /**
36
- * A type describing bandwidth limitation of a track, including simulcast and non-simulcast tracks. Can be `BandwidthLimit` or `SimulcastBandwidthLimit`.
37
- */
38
- export type TrackBandwidthLimit = BandwidthLimit | SimulcastBandwidthLimit;
39
-
40
- export type TrackMetadata = {
41
- active: boolean;
42
- type: 'audio' | 'camera' | 'screensharing';
43
- };
44
-
45
- export type GenericMetadata = Record<string, unknown>;
46
-
47
- // branded types are useful for restricting where given value can be passed
48
- declare const brand: unique symbol;
49
- export type Brand<T, TBrand extends string> = T & { [brand]: TBrand };
package/tsconfig.json DELETED
@@ -1,9 +0,0 @@
1
- // @generated by expo-module-scripts
2
- {
3
- "extends": "expo-module-scripts/tsconfig.base",
4
- "compilerOptions": {
5
- "outDir": "./build"
6
- },
7
- "include": ["./src"],
8
- "exclude": ["**/__mocks__/*", "**/__tests__/*"]
9
- }
package/typedoc.json DELETED
@@ -1,5 +0,0 @@
1
- {
2
- "$schema": "https://typedoc.org/schema.json",
3
- "includeVersion": true,
4
- "entryPoints": ["src/index.tsx"]
5
- }