@fishjam-cloud/react-native-client 0.2.4 → 0.4.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/LICENSE +201 -0
- package/README.md +9 -8
- package/android/build.gradle +4 -4
- package/android/src/main/java/io/fishjam/reactnative/EmitableEvents.kt +25 -12
- package/android/src/main/java/io/fishjam/reactnative/Errors.kt +1 -2
- package/android/src/main/java/io/fishjam/reactnative/RNFishjamClient.kt +94 -52
- package/android/src/main/java/io/fishjam/reactnative/RNFishjamClientModule.kt +42 -90
- package/android/src/main/java/io/fishjam/reactnative/VideoPreviewView.kt +14 -3
- package/android/src/main/java/io/fishjam/reactnative/VideoPreviewViewModule.kt +5 -0
- package/android/src/main/java/io/fishjam/reactnative/VideoRendererView.kt +4 -3
- package/android/src/main/java/io/fishjam/reactnative/VideoRendererViewModule.kt +2 -0
- package/android/src/main/java/io/fishjam/reactnative/VideoView.kt +3 -2
- package/android/src/main/java/io/fishjam/reactnative/{FishjamForegroundService.kt → foregroundService/FishjamForegroundService.kt} +7 -2
- package/android/src/main/java/io/fishjam/reactnative/foregroundService/ForegroundServiceManager.kt +147 -0
- package/android/src/main/java/io/fishjam/reactnative/managers/LocalCameraTracksChangedListenersManager.kt +21 -0
- package/android/src/main/java/io/fishjam/reactnative/managers/LocalTracksSwitchListenersManager.kt +27 -0
- package/android/src/main/java/io/fishjam/reactnative/managers/TracksUpdateListenersManager.kt +21 -0
- package/android/src/main/java/io/fishjam/reactnative/utils/PermissionUtils.kt +45 -0
- package/build/RNFishjamClientModule.d.ts +16 -10
- package/build/RNFishjamClientModule.d.ts.map +1 -1
- package/build/RNFishjamClientModule.js.map +1 -1
- package/build/common/client.d.ts +3 -3
- package/build/common/client.d.ts.map +1 -1
- package/build/common/client.js +4 -4
- package/build/common/client.js.map +1 -1
- package/build/common/metadata.d.ts +3 -3
- package/build/common/metadata.d.ts.map +1 -1
- package/build/common/metadata.js +4 -4
- package/build/common/metadata.js.map +1 -1
- package/build/common/webRTC.d.ts +0 -8
- package/build/common/webRTC.d.ts.map +1 -1
- package/build/common/webRTC.js +0 -9
- package/build/common/webRTC.js.map +1 -1
- package/build/components/VideoRendererView.d.ts +1 -1
- package/build/components/VideoRendererView.js +1 -1
- package/build/components/VideoRendererView.js.map +1 -1
- package/build/debug/common/webRTC.d.ts +9 -0
- package/build/debug/common/webRTC.d.ts.map +1 -0
- package/build/debug/common/webRTC.js +11 -0
- package/build/debug/common/webRTC.js.map +1 -0
- package/build/debug/index.d.ts +4 -0
- package/build/debug/index.d.ts.map +1 -0
- package/build/debug/index.js +3 -0
- package/build/debug/index.js.map +1 -0
- package/build/debug/stats/types.d.ts.map +1 -0
- package/build/debug/stats/types.js.map +1 -0
- package/build/debug/stats/useRTCStatistics.d.ts.map +1 -0
- package/build/{stats → debug/stats}/useRTCStatistics.js +1 -1
- package/build/debug/stats/useRTCStatistics.js.map +1 -0
- package/build/hooks/useAppScreenShare.d.ts +11 -0
- package/build/hooks/useAppScreenShare.d.ts.map +1 -0
- package/build/hooks/useAppScreenShare.js +54 -0
- package/build/hooks/useAppScreenShare.js.map +1 -0
- package/build/hooks/useFishjamEvent.d.ts +2 -0
- package/build/hooks/useFishjamEvent.d.ts.map +1 -1
- package/build/hooks/useFishjamEvent.js +2 -0
- package/build/hooks/useFishjamEvent.js.map +1 -1
- package/build/hooks/useForegroundService.d.ts +44 -0
- package/build/hooks/useForegroundService.d.ts.map +1 -0
- package/build/hooks/useForegroundService.js +57 -0
- package/build/hooks/useForegroundService.js.map +1 -0
- package/build/hooks/useMicrophone.d.ts +1 -1
- package/build/hooks/useMicrophone.js +1 -1
- package/build/hooks/useMicrophone.js.map +1 -1
- package/build/hooks/usePeerStatus.d.ts +19 -0
- package/build/hooks/usePeerStatus.d.ts.map +1 -0
- package/build/hooks/usePeerStatus.js +18 -0
- package/build/hooks/usePeerStatus.js.map +1 -0
- package/build/hooks/{useParticipants.d.ts → usePeers.d.ts} +11 -11
- package/build/hooks/usePeers.d.ts.map +1 -0
- package/build/hooks/usePeers.js +34 -0
- package/build/hooks/usePeers.js.map +1 -0
- package/build/hooks/useScreenShare.d.ts +1 -0
- package/build/hooks/useScreenShare.d.ts.map +1 -1
- package/build/hooks/useScreenShare.js +20 -13
- package/build/hooks/useScreenShare.js.map +1 -1
- package/build/index.d.ts +8 -7
- package/build/index.d.ts.map +1 -1
- package/build/index.js +5 -5
- package/build/index.js.map +1 -1
- package/build/types.d.ts +0 -25
- package/build/types.d.ts.map +1 -1
- package/build/types.js +1 -10
- package/build/types.js.map +1 -1
- package/debug/package.json +4 -0
- package/ios/Events.swift +30 -13
- package/ios/RNFishjamClient.podspec +1 -1
- package/ios/RNFishjamClient.swift +196 -106
- package/ios/RNFishjamClientModule.swift +34 -34
- package/ios/VideoPreviewView.swift +26 -12
- package/ios/VideoRendererView.swift +5 -14
- package/package.json +7 -6
- package/plugin/build/withFishjamAndroid.js +1 -1
- package/plugin/build/withFishjamIos.js +2 -2
- package/build/hooks/useParticipants.d.ts.map +0 -1
- package/build/hooks/useParticipants.js +0 -34
- package/build/hooks/useParticipants.js.map +0 -1
- package/build/stats/types.d.ts.map +0 -1
- package/build/stats/types.js.map +0 -1
- package/build/stats/useRTCStatistics.d.ts.map +0 -1
- package/build/stats/useRTCStatistics.js.map +0 -1
- package/build/utils/foregroundService.d.ts +0 -32
- package/build/utils/foregroundService.d.ts.map +0 -1
- package/build/utils/foregroundService.js +0 -43
- package/build/utils/foregroundService.js.map +0 -1
- /package/build/{stats → debug/stats}/types.d.ts +0 -0
- /package/build/{stats → debug/stats}/types.js +0 -0
- /package/build/{stats → debug/stats}/useRTCStatistics.d.ts +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2023 Software Mansion
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -6,23 +6,24 @@
|
|
|
6
6
|
|
|
7
7
|
# Installation
|
|
8
8
|
|
|
9
|
-
Check out the [installation](https://fishjam
|
|
9
|
+
Check out the [installation](https://docs.fishjam.io/react-native/installation) section of our docs for the detailed installation instructions.
|
|
10
10
|
|
|
11
11
|
# Documentation
|
|
12
12
|
|
|
13
|
-
Check out our [documentation](https://fishjam
|
|
13
|
+
Check out our [documentation](https://docs.fishjam.io/) on how Fishjam Cloud work and how to integrate our service with your app.
|
|
14
14
|
|
|
15
|
-
There is also API documentation available.
|
|
15
|
+
There is also [API documentation](https://fishjam-cloud.github.io/mobile-client-sdk/modules/_fishjam_cloud_react_native_client.html) available.
|
|
16
16
|
|
|
17
17
|
# Examples
|
|
18
18
|
|
|
19
19
|
There is simple example app, that allows you to test our service. To run it locally, follow [instructions](https://github.com/fishjam-cloud/mobile-client-sdk/tree/main/examples/fishjam-chat#react-native-fishjam-cloud-example).
|
|
20
20
|
|
|
21
|
-
##
|
|
21
|
+
## License
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
[Software Mansion](https://swmansion.com/?utm_source=git&utm_medium=readme&utm_campaign=react-client)
|
|
23
|
+
Licensed under the [Apache License, Version 2.0](LICENSE)
|
|
25
24
|
|
|
26
|
-
|
|
25
|
+
## Fishjam Cloud is created by Software Mansion
|
|
27
26
|
|
|
28
|
-
|
|
27
|
+
Since 2012 [Software Mansion](https://swmansion.com) is a software agency with experience in building web and mobile apps. We are Core React Native Contributors and experts in dealing with all kinds of React Native issues. We can help you build your next dream product – [Hire us](https://swmansion.com/contact/projects?utm_source=fishjam&utm_medium=mobile-readme).
|
|
28
|
+
|
|
29
|
+
[](https://swmansion.com/contact/projects?utm_source=fishjam&utm_medium=mobile-readme)
|
package/android/build.gradle
CHANGED
|
@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
|
|
|
2
2
|
apply plugin: 'kotlin-android'
|
|
3
3
|
apply plugin: 'maven-publish'
|
|
4
4
|
|
|
5
|
-
def packageVersion = '0.
|
|
5
|
+
def packageVersion = '0.4.0'
|
|
6
6
|
|
|
7
7
|
group = 'io.fishjam.reactnative'
|
|
8
8
|
version = "${packageVersion}"
|
|
@@ -55,11 +55,11 @@ afterEvaluate {
|
|
|
55
55
|
|
|
56
56
|
android {
|
|
57
57
|
namespace = "io.fishjam.reactnative"
|
|
58
|
-
compileSdk(
|
|
58
|
+
compileSdk(34)
|
|
59
59
|
|
|
60
60
|
defaultConfig {
|
|
61
61
|
minSdkVersion safeExtGet("minSdkVersion", 21)
|
|
62
|
-
targetSdkVersion safeExtGet("targetSdkVersion",
|
|
62
|
+
targetSdkVersion safeExtGet("targetSdkVersion", 34)
|
|
63
63
|
versionCode 1
|
|
64
64
|
versionName "${packageVersion}"
|
|
65
65
|
}
|
|
@@ -86,6 +86,6 @@ dependencies {
|
|
|
86
86
|
// update version number when releasing
|
|
87
87
|
implementation "com.github.fishjam-cloud:mobile-client-sdk:${packageVersion}"
|
|
88
88
|
}
|
|
89
|
-
|
|
89
|
+
implementation 'com.twilio:audioswitch:1.2.0'
|
|
90
90
|
implementation 'androidx.appcompat:appcompat:1.6.1'
|
|
91
91
|
}
|
|
@@ -1,15 +1,28 @@
|
|
|
1
1
|
package io.fishjam.reactnative
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
3
|
+
@Suppress("ktlint:standard:enum-entry-name-case")
|
|
4
|
+
enum class PeerStatus {
|
|
5
|
+
connecting,
|
|
6
|
+
connected,
|
|
7
|
+
error,
|
|
8
|
+
idle
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
enum class EmitableEvents {
|
|
12
|
+
IsCameraOn,
|
|
13
|
+
IsMicrophoneOn,
|
|
14
|
+
IsScreenShareOn,
|
|
15
|
+
SimulcastConfigUpdate,
|
|
16
|
+
PeersUpdate,
|
|
17
|
+
AudioDeviceUpdate,
|
|
18
|
+
BandwidthEstimation,
|
|
19
|
+
ReconnectionRetriesLimitReached,
|
|
20
|
+
ReconnectionStarted,
|
|
21
|
+
Reconnected,
|
|
22
|
+
Warning,
|
|
23
|
+
PeerStatusChanged;
|
|
24
|
+
|
|
25
|
+
companion object {
|
|
26
|
+
val allEvents = EmitableEvents.entries.map { it.name }.toTypedArray()
|
|
27
|
+
}
|
|
15
28
|
}
|
|
@@ -11,8 +11,7 @@ class ConnectionError(
|
|
|
11
11
|
reason: AuthError
|
|
12
12
|
) : CodedException(message = "Connection error: ${reason.error}")
|
|
13
13
|
|
|
14
|
-
class MissingScreenSharePermission :
|
|
15
|
-
CodedException(message = "No permission to start screen share, call handleScreenSharePermission first.")
|
|
14
|
+
class MissingScreenSharePermission : CodedException(message = "No permission to start screen share.")
|
|
16
15
|
|
|
17
16
|
class ClientNotConnectedError : CodedException(message = "Client not connected to server yet. Make sure to call connect() first!")
|
|
18
17
|
|
|
@@ -27,6 +27,11 @@ import com.twilio.audioswitch.AudioDevice
|
|
|
27
27
|
import expo.modules.kotlin.AppContext
|
|
28
28
|
import expo.modules.kotlin.Promise
|
|
29
29
|
import expo.modules.kotlin.exception.CodedException
|
|
30
|
+
import io.fishjam.reactnative.foregroundService.ForegroundServiceManager
|
|
31
|
+
import io.fishjam.reactnative.managers.LocalCameraTracksChangedListenersManager
|
|
32
|
+
import io.fishjam.reactnative.managers.LocalTracksSwitchListenersManager
|
|
33
|
+
import io.fishjam.reactnative.managers.TracksUpdateListenersManager
|
|
34
|
+
import io.fishjam.reactnative.utils.PermissionUtils
|
|
30
35
|
import kotlinx.coroutines.CoroutineScope
|
|
31
36
|
import kotlinx.coroutines.Dispatchers
|
|
32
37
|
import kotlinx.coroutines.SupervisorJob
|
|
@@ -63,19 +68,22 @@ class RNFishjamClient(
|
|
|
63
68
|
|
|
64
69
|
var appContext: AppContext? = null
|
|
65
70
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
var peerStatus = PeerStatus.idle
|
|
72
|
+
private set(value) {
|
|
73
|
+
field = value
|
|
74
|
+
val event = EmitableEvents.PeerStatusChanged
|
|
75
|
+
emitEvent(event, mapOf(event.name to value))
|
|
76
|
+
}
|
|
72
77
|
|
|
73
|
-
|
|
74
|
-
}
|
|
78
|
+
private var foregroundServiceManager: ForegroundServiceManager? = null
|
|
75
79
|
|
|
76
80
|
companion object {
|
|
77
|
-
|
|
78
|
-
|
|
81
|
+
val trackUpdateListenersManager = TracksUpdateListenersManager()
|
|
82
|
+
|
|
83
|
+
val localTracksSwitchListenerManager = LocalTracksSwitchListenersManager()
|
|
84
|
+
|
|
85
|
+
val localCameraTracksChangedListenersManager = LocalCameraTracksChangedListenersManager()
|
|
86
|
+
|
|
79
87
|
lateinit var fishjamClient: FishjamClient
|
|
80
88
|
|
|
81
89
|
fun getAllPeers(): List<Peer> {
|
|
@@ -228,23 +236,25 @@ class RNFishjamClient(
|
|
|
228
236
|
CoroutineScope(Dispatchers.Main).launch {
|
|
229
237
|
connectPromise?.reject(ConnectionError(reason))
|
|
230
238
|
connectPromise = null
|
|
239
|
+
peerStatus = PeerStatus.error
|
|
231
240
|
}
|
|
232
241
|
}
|
|
233
242
|
|
|
234
243
|
fun joinRoom(
|
|
235
244
|
url: String,
|
|
236
|
-
|
|
237
|
-
|
|
245
|
+
peerToken: String,
|
|
246
|
+
peerMetadata: Map<String, Any>,
|
|
238
247
|
config: ConnectConfig,
|
|
239
248
|
promise: Promise
|
|
240
249
|
) {
|
|
250
|
+
peerStatus = PeerStatus.connecting
|
|
241
251
|
connectPromise = promise
|
|
242
|
-
localUserMetadata =
|
|
252
|
+
localUserMetadata = mapOf("server" to emptyMap(), "peer" to peerMetadata)
|
|
243
253
|
fishjamClient.connect(
|
|
244
254
|
com.fishjamcloud.client.ConnectConfig(
|
|
245
255
|
url,
|
|
246
|
-
|
|
247
|
-
|
|
256
|
+
peerToken,
|
|
257
|
+
localUserMetadata,
|
|
248
258
|
ReconnectConfig(
|
|
249
259
|
config.reconnectConfig.maxAttempts,
|
|
250
260
|
config.reconnectConfig.initialDelayMs,
|
|
@@ -263,7 +273,9 @@ class RNFishjamClient(
|
|
|
263
273
|
isScreenShareOn = false
|
|
264
274
|
isConnected = false
|
|
265
275
|
isCameraInitialized = false
|
|
266
|
-
fishjamClient.leave
|
|
276
|
+
fishjamClient.leave {
|
|
277
|
+
emitEndpoints()
|
|
278
|
+
}
|
|
267
279
|
}
|
|
268
280
|
|
|
269
281
|
suspend fun startCamera(config: CameraConfig) {
|
|
@@ -271,6 +283,11 @@ class RNFishjamClient(
|
|
|
271
283
|
emitWarning("Camera already started. You may only call startCamera once before leaveRoom is called.")
|
|
272
284
|
return
|
|
273
285
|
}
|
|
286
|
+
if (!PermissionUtils.requestCameraPermission(appContext)) {
|
|
287
|
+
emitWarning("Camera permission not granted.")
|
|
288
|
+
return
|
|
289
|
+
}
|
|
290
|
+
|
|
274
291
|
val cameraTrack = createCameraTrack(config)
|
|
275
292
|
setCameraTrackState(cameraTrack, config.cameraEnabled)
|
|
276
293
|
emitEndpoints()
|
|
@@ -293,9 +310,9 @@ class RNFishjamClient(
|
|
|
293
310
|
) {
|
|
294
311
|
cameraTrack.setEnabled(isEnabled)
|
|
295
312
|
isCameraOn = isEnabled
|
|
296
|
-
val
|
|
297
|
-
|
|
298
|
-
|
|
313
|
+
val event = EmitableEvents.IsCameraOn
|
|
314
|
+
emitEvent(event, mapOf(event.name to isEnabled))
|
|
315
|
+
localCameraTracksChangedListenersManager.notifyListeners()
|
|
299
316
|
}
|
|
300
317
|
|
|
301
318
|
fun toggleCamera(): Boolean {
|
|
@@ -306,21 +323,24 @@ class RNFishjamClient(
|
|
|
306
323
|
|
|
307
324
|
suspend fun flipCamera() {
|
|
308
325
|
ensureVideoTrack()
|
|
309
|
-
|
|
326
|
+
localTracksSwitchListenerManager.notifyWillSwitch()
|
|
310
327
|
getLocalVideoTrack()?.flipCamera()
|
|
311
|
-
|
|
328
|
+
localTracksSwitchListenerManager.notifySwitched()
|
|
312
329
|
}
|
|
313
330
|
|
|
314
331
|
suspend fun switchCamera(cameraId: String) {
|
|
315
332
|
ensureVideoTrack()
|
|
316
|
-
|
|
333
|
+
localTracksSwitchListenerManager.notifyWillSwitch()
|
|
317
334
|
getLocalVideoTrack()?.switchCamera(cameraId)
|
|
318
|
-
|
|
319
|
-
it.onLocalTrackSwitched()
|
|
320
|
-
}
|
|
335
|
+
localTracksSwitchListenerManager.notifySwitched()
|
|
321
336
|
}
|
|
322
337
|
|
|
323
338
|
private suspend fun startMicrophone() {
|
|
339
|
+
if (!PermissionUtils.requestMicrophonePermission(appContext)) {
|
|
340
|
+
emitWarning("Microphone permission not granted.")
|
|
341
|
+
return
|
|
342
|
+
}
|
|
343
|
+
|
|
324
344
|
val microphoneTrack = fishjamClient.createAudioTrack(emptyMap())
|
|
325
345
|
setMicrophoneTrackState(microphoneTrack, true)
|
|
326
346
|
emitEndpoints()
|
|
@@ -332,9 +352,8 @@ class RNFishjamClient(
|
|
|
332
352
|
) {
|
|
333
353
|
microphoneTrack.setEnabled(isEnabled)
|
|
334
354
|
isMicrophoneOn = isEnabled
|
|
335
|
-
val
|
|
336
|
-
|
|
337
|
-
emitEvent(eventName, isMicrophoneOnMap)
|
|
355
|
+
val event = EmitableEvents.IsMicrophoneOn
|
|
356
|
+
emitEvent(event, mapOf(event.name to isEnabled))
|
|
338
357
|
}
|
|
339
358
|
|
|
340
359
|
suspend fun toggleMicrophone(): Boolean {
|
|
@@ -361,6 +380,24 @@ class RNFishjamClient(
|
|
|
361
380
|
}
|
|
362
381
|
}
|
|
363
382
|
|
|
383
|
+
fun configureForegroundService(config: ForegroundServiceNotificationConfig) {
|
|
384
|
+
if (foregroundServiceManager == null) {
|
|
385
|
+
foregroundServiceManager = ForegroundServiceManager(appContext!!, config)
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
suspend fun startForegroundService(config: ForegroundServicePermissionsConfig) {
|
|
390
|
+
if (foregroundServiceManager == null) {
|
|
391
|
+
throw CodedException("Foreground service not configured.")
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
foregroundServiceManager?.startForegroundService(config)
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
fun stopForegroundService() {
|
|
398
|
+
foregroundServiceManager?.stopForegroundService()
|
|
399
|
+
}
|
|
400
|
+
|
|
364
401
|
suspend fun toggleScreenShare(screenShareOptions: ScreenShareOptions) {
|
|
365
402
|
this.screenShareMetadata = screenShareOptions.screenShareMetadata
|
|
366
403
|
this.screenShareQuality = screenShareOptions.quality
|
|
@@ -534,7 +571,8 @@ class RNFishjamClient(
|
|
|
534
571
|
fun toggleScreenShareTrackEncoding(encoding: String): Map<String, Any> {
|
|
535
572
|
ensureScreenShareTrack()
|
|
536
573
|
getLocalScreenShareTrack()?.let {
|
|
537
|
-
screenShareSimulcastConfig =
|
|
574
|
+
screenShareSimulcastConfig =
|
|
575
|
+
toggleTrackEncoding(encoding, it.id(), screenShareSimulcastConfig)
|
|
538
576
|
}
|
|
539
577
|
return getSimulcastConfigAsRNMap(screenShareSimulcastConfig)
|
|
540
578
|
}
|
|
@@ -705,8 +743,8 @@ class RNFishjamClient(
|
|
|
705
743
|
|
|
706
744
|
private fun setScreenShareTrackState(isEnabled: Boolean) {
|
|
707
745
|
isScreenShareOn = isEnabled
|
|
708
|
-
val
|
|
709
|
-
emitEvent(
|
|
746
|
+
val event = EmitableEvents.IsScreenShareOn
|
|
747
|
+
emitEvent(event, mapOf(event.name to isEnabled))
|
|
710
748
|
}
|
|
711
749
|
|
|
712
750
|
private fun stopScreenShare() {
|
|
@@ -725,21 +763,21 @@ class RNFishjamClient(
|
|
|
725
763
|
}
|
|
726
764
|
|
|
727
765
|
private fun emitEvent(
|
|
728
|
-
|
|
729
|
-
data: Map<String, Any?>
|
|
766
|
+
event: EmitableEvents,
|
|
767
|
+
data: Map<String, Any?> = mapOf()
|
|
730
768
|
) {
|
|
731
|
-
|
|
769
|
+
CoroutineScope(Dispatchers.Main).launch {
|
|
770
|
+
sendEvent(event.name, data)
|
|
771
|
+
}
|
|
732
772
|
}
|
|
733
773
|
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
emitEvent(eventName, mapOf("message" to warning))
|
|
774
|
+
fun emitWarning(warning: String) {
|
|
775
|
+
emitEvent(EmitableEvents.Warning, mapOf("message" to warning))
|
|
737
776
|
}
|
|
738
777
|
|
|
739
778
|
private fun emitEndpoints() {
|
|
740
|
-
val
|
|
741
|
-
|
|
742
|
-
emitEvent(eventName, map)
|
|
779
|
+
val event = EmitableEvents.PeersUpdate
|
|
780
|
+
emitEvent(event, mapOf(event.name to getPeers()))
|
|
743
781
|
}
|
|
744
782
|
|
|
745
783
|
private fun audioDeviceAsRNMap(audioDevice: AudioDevice): Map<String, String?> =
|
|
@@ -752,10 +790,11 @@ class RNFishjamClient(
|
|
|
752
790
|
audioDevices: List<AudioDevice>,
|
|
753
791
|
selectedDevice: AudioDevice?
|
|
754
792
|
) {
|
|
755
|
-
val
|
|
756
|
-
|
|
793
|
+
val event = EmitableEvents.AudioDeviceUpdate
|
|
794
|
+
emitEvent(
|
|
795
|
+
event,
|
|
757
796
|
mapOf(
|
|
758
|
-
|
|
797
|
+
event.name to
|
|
759
798
|
mapOf(
|
|
760
799
|
"selectedDevice" to (
|
|
761
800
|
if (selectedDevice != null) {
|
|
@@ -774,8 +813,7 @@ class RNFishjamClient(
|
|
|
774
813
|
}
|
|
775
814
|
)
|
|
776
815
|
)
|
|
777
|
-
|
|
778
|
-
emitEvent(eventName, map)
|
|
816
|
+
)
|
|
779
817
|
}
|
|
780
818
|
|
|
781
819
|
private fun getSimulcastConfigAsRNMap(simulcastConfig: SimulcastConfig): Map<String, Any> =
|
|
@@ -796,6 +834,7 @@ class RNFishjamClient(
|
|
|
796
834
|
connectPromise?.resolve(null)
|
|
797
835
|
connectPromise = null
|
|
798
836
|
emitEndpoints()
|
|
837
|
+
peerStatus = PeerStatus.connected
|
|
799
838
|
}
|
|
800
839
|
}
|
|
801
840
|
|
|
@@ -808,7 +847,7 @@ class RNFishjamClient(
|
|
|
808
847
|
|
|
809
848
|
private fun addOrUpdateTrack(track: Track) {
|
|
810
849
|
emitEndpoints()
|
|
811
|
-
|
|
850
|
+
trackUpdateListenersManager.notifyListeners()
|
|
812
851
|
}
|
|
813
852
|
|
|
814
853
|
override fun onTrackReady(track: Track) {
|
|
@@ -846,11 +885,13 @@ class RNFishjamClient(
|
|
|
846
885
|
override fun onPeerUpdated(peer: Peer) {}
|
|
847
886
|
|
|
848
887
|
override fun onBandwidthEstimationChanged(estimation: Long) {
|
|
849
|
-
val
|
|
850
|
-
emitEvent(
|
|
888
|
+
val event = EmitableEvents.BandwidthEstimation
|
|
889
|
+
emitEvent(event, mapOf(event.name to estimation.toFloat()))
|
|
851
890
|
}
|
|
852
891
|
|
|
853
|
-
override fun onDisconnected() {
|
|
892
|
+
override fun onDisconnected() {
|
|
893
|
+
peerStatus = PeerStatus.idle
|
|
894
|
+
}
|
|
854
895
|
|
|
855
896
|
override fun onSocketClose(
|
|
856
897
|
code: Int,
|
|
@@ -859,6 +900,7 @@ class RNFishjamClient(
|
|
|
859
900
|
CoroutineScope(Dispatchers.Main).launch {
|
|
860
901
|
connectPromise?.reject(SocketClosedError(code, reason))
|
|
861
902
|
connectPromise = null
|
|
903
|
+
peerStatus = PeerStatus.error
|
|
862
904
|
}
|
|
863
905
|
}
|
|
864
906
|
|
|
@@ -870,14 +912,14 @@ class RNFishjamClient(
|
|
|
870
912
|
}
|
|
871
913
|
|
|
872
914
|
override fun onReconnected() {
|
|
873
|
-
emitEvent(EmitableEvents.Reconnected
|
|
915
|
+
emitEvent(EmitableEvents.Reconnected)
|
|
874
916
|
}
|
|
875
917
|
|
|
876
918
|
override fun onReconnectionStarted() {
|
|
877
|
-
emitEvent(EmitableEvents.ReconnectionStarted
|
|
919
|
+
emitEvent(EmitableEvents.ReconnectionStarted)
|
|
878
920
|
}
|
|
879
921
|
|
|
880
922
|
override fun onReconnectionRetriesLimitReached() {
|
|
881
|
-
emitEvent(EmitableEvents.ReconnectionRetriesLimitReached
|
|
923
|
+
emitEvent(EmitableEvents.ReconnectionRetriesLimitReached)
|
|
882
924
|
}
|
|
883
925
|
}
|