@fishjam-cloud/react-native-client 0.2.4 → 0.3.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 +7 -6
- package/android/build.gradle +3 -3
- package/android/src/main/java/io/fishjam/reactnative/EmitableEvents.kt +25 -12
- package/android/src/main/java/io/fishjam/reactnative/RNFishjamClient.kt +50 -33
- package/android/src/main/java/io/fishjam/reactnative/RNFishjamClientModule.kt +7 -16
- package/android/src/main/java/io/fishjam/reactnative/VideoPreviewView.kt +13 -3
- package/build/RNFishjamClientModule.d.ts +10 -8
- 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/useFishjamEvent.d.ts +1 -0
- package/build/hooks/useFishjamEvent.d.ts.map +1 -1
- package/build/hooks/useFishjamEvent.js +1 -0
- package/build/hooks/useFishjamEvent.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/index.d.ts +5 -5
- package/build/index.d.ts.map +1 -1
- package/build/index.js +3 -3
- package/build/index.js.map +1 -1
- package/debug/package.json +4 -0
- package/ios/Events.swift +29 -13
- package/ios/RNFishjamClient.podspec +1 -1
- package/ios/RNFishjamClient.swift +58 -55
- package/ios/RNFishjamClientModule.swift +7 -15
- package/ios/VideoPreviewView.swift +27 -9
- package/package.json +4 -3
- 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/{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
|
@@ -12,17 +12,18 @@ Check out the [installation](https://fishjam-cloud.github.io/documentation/guide
|
|
|
12
12
|
|
|
13
13
|
Check out our [documentation](https://fishjam-cloud.github.io/documentation/) 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.3.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
|
}
|
|
@@ -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
|
}
|
|
@@ -63,6 +63,13 @@ class RNFishjamClient(
|
|
|
63
63
|
|
|
64
64
|
var appContext: AppContext? = null
|
|
65
65
|
|
|
66
|
+
var peerStatus = PeerStatus.idle
|
|
67
|
+
private set(value) {
|
|
68
|
+
field = value
|
|
69
|
+
val event = EmitableEvents.PeerStatusChanged
|
|
70
|
+
emitEvent(event, mapOf(event.name to value))
|
|
71
|
+
}
|
|
72
|
+
|
|
66
73
|
interface OnTrackUpdateListener {
|
|
67
74
|
fun onTracksUpdate()
|
|
68
75
|
}
|
|
@@ -73,9 +80,14 @@ class RNFishjamClient(
|
|
|
73
80
|
suspend fun onLocalTrackSwitched()
|
|
74
81
|
}
|
|
75
82
|
|
|
83
|
+
interface OnLocalCameraTrackChangedListener {
|
|
84
|
+
fun onLocalCameraTrackChanged()
|
|
85
|
+
}
|
|
86
|
+
|
|
76
87
|
companion object {
|
|
77
88
|
var onTracksUpdateListeners: MutableList<OnTrackUpdateListener> = mutableListOf()
|
|
78
89
|
val onLocalTrackSwitchListener: MutableList<OnLocalTrackSwitchListener> = mutableListOf()
|
|
90
|
+
var localCameraTrackListeners: MutableList<OnLocalCameraTrackChangedListener> = mutableListOf()
|
|
79
91
|
lateinit var fishjamClient: FishjamClient
|
|
80
92
|
|
|
81
93
|
fun getAllPeers(): List<Peer> {
|
|
@@ -228,23 +240,25 @@ class RNFishjamClient(
|
|
|
228
240
|
CoroutineScope(Dispatchers.Main).launch {
|
|
229
241
|
connectPromise?.reject(ConnectionError(reason))
|
|
230
242
|
connectPromise = null
|
|
243
|
+
peerStatus = PeerStatus.error
|
|
231
244
|
}
|
|
232
245
|
}
|
|
233
246
|
|
|
234
247
|
fun joinRoom(
|
|
235
248
|
url: String,
|
|
236
|
-
|
|
237
|
-
|
|
249
|
+
peerToken: String,
|
|
250
|
+
peerMetadata: Map<String, Any>,
|
|
238
251
|
config: ConnectConfig,
|
|
239
252
|
promise: Promise
|
|
240
253
|
) {
|
|
254
|
+
peerStatus = PeerStatus.connecting
|
|
241
255
|
connectPromise = promise
|
|
242
|
-
localUserMetadata =
|
|
256
|
+
localUserMetadata = peerMetadata
|
|
243
257
|
fishjamClient.connect(
|
|
244
258
|
com.fishjamcloud.client.ConnectConfig(
|
|
245
259
|
url,
|
|
246
|
-
|
|
247
|
-
|
|
260
|
+
peerToken,
|
|
261
|
+
peerMetadata,
|
|
248
262
|
ReconnectConfig(
|
|
249
263
|
config.reconnectConfig.maxAttempts,
|
|
250
264
|
config.reconnectConfig.initialDelayMs,
|
|
@@ -263,7 +277,9 @@ class RNFishjamClient(
|
|
|
263
277
|
isScreenShareOn = false
|
|
264
278
|
isConnected = false
|
|
265
279
|
isCameraInitialized = false
|
|
266
|
-
fishjamClient.leave
|
|
280
|
+
fishjamClient.leave {
|
|
281
|
+
emitEndpoints()
|
|
282
|
+
}
|
|
267
283
|
}
|
|
268
284
|
|
|
269
285
|
suspend fun startCamera(config: CameraConfig) {
|
|
@@ -293,9 +309,9 @@ class RNFishjamClient(
|
|
|
293
309
|
) {
|
|
294
310
|
cameraTrack.setEnabled(isEnabled)
|
|
295
311
|
isCameraOn = isEnabled
|
|
296
|
-
val
|
|
297
|
-
|
|
298
|
-
|
|
312
|
+
val event = EmitableEvents.IsCameraOn
|
|
313
|
+
emitEvent(event, mapOf(event.name to isEnabled))
|
|
314
|
+
localCameraTrackListeners.forEach { it.onLocalCameraTrackChanged() }
|
|
299
315
|
}
|
|
300
316
|
|
|
301
317
|
fun toggleCamera(): Boolean {
|
|
@@ -332,9 +348,8 @@ class RNFishjamClient(
|
|
|
332
348
|
) {
|
|
333
349
|
microphoneTrack.setEnabled(isEnabled)
|
|
334
350
|
isMicrophoneOn = isEnabled
|
|
335
|
-
val
|
|
336
|
-
|
|
337
|
-
emitEvent(eventName, isMicrophoneOnMap)
|
|
351
|
+
val event = EmitableEvents.IsMicrophoneOn
|
|
352
|
+
emitEvent(event, mapOf(event.name to isEnabled))
|
|
338
353
|
}
|
|
339
354
|
|
|
340
355
|
suspend fun toggleMicrophone(): Boolean {
|
|
@@ -705,8 +720,8 @@ class RNFishjamClient(
|
|
|
705
720
|
|
|
706
721
|
private fun setScreenShareTrackState(isEnabled: Boolean) {
|
|
707
722
|
isScreenShareOn = isEnabled
|
|
708
|
-
val
|
|
709
|
-
emitEvent(
|
|
723
|
+
val event = EmitableEvents.IsScreenShareOn
|
|
724
|
+
emitEvent(event, mapOf(event.name to isEnabled))
|
|
710
725
|
}
|
|
711
726
|
|
|
712
727
|
private fun stopScreenShare() {
|
|
@@ -725,21 +740,19 @@ class RNFishjamClient(
|
|
|
725
740
|
}
|
|
726
741
|
|
|
727
742
|
private fun emitEvent(
|
|
728
|
-
|
|
729
|
-
data: Map<String, Any?>
|
|
743
|
+
event: EmitableEvents,
|
|
744
|
+
data: Map<String, Any?> = mapOf()
|
|
730
745
|
) {
|
|
731
|
-
sendEvent(
|
|
746
|
+
sendEvent(event.name, data)
|
|
732
747
|
}
|
|
733
748
|
|
|
734
749
|
private fun emitWarning(warning: String) {
|
|
735
|
-
|
|
736
|
-
emitEvent(eventName, mapOf("message" to warning))
|
|
750
|
+
emitEvent(EmitableEvents.Warning, mapOf("message" to warning))
|
|
737
751
|
}
|
|
738
752
|
|
|
739
753
|
private fun emitEndpoints() {
|
|
740
|
-
val
|
|
741
|
-
|
|
742
|
-
emitEvent(eventName, map)
|
|
754
|
+
val event = EmitableEvents.PeersUpdate
|
|
755
|
+
emitEvent(event, mapOf(event.name to getPeers()))
|
|
743
756
|
}
|
|
744
757
|
|
|
745
758
|
private fun audioDeviceAsRNMap(audioDevice: AudioDevice): Map<String, String?> =
|
|
@@ -752,10 +765,11 @@ class RNFishjamClient(
|
|
|
752
765
|
audioDevices: List<AudioDevice>,
|
|
753
766
|
selectedDevice: AudioDevice?
|
|
754
767
|
) {
|
|
755
|
-
val
|
|
756
|
-
|
|
768
|
+
val event = EmitableEvents.AudioDeviceUpdate
|
|
769
|
+
emitEvent(
|
|
770
|
+
event,
|
|
757
771
|
mapOf(
|
|
758
|
-
|
|
772
|
+
event.name to
|
|
759
773
|
mapOf(
|
|
760
774
|
"selectedDevice" to (
|
|
761
775
|
if (selectedDevice != null) {
|
|
@@ -774,8 +788,7 @@ class RNFishjamClient(
|
|
|
774
788
|
}
|
|
775
789
|
)
|
|
776
790
|
)
|
|
777
|
-
|
|
778
|
-
emitEvent(eventName, map)
|
|
791
|
+
)
|
|
779
792
|
}
|
|
780
793
|
|
|
781
794
|
private fun getSimulcastConfigAsRNMap(simulcastConfig: SimulcastConfig): Map<String, Any> =
|
|
@@ -796,6 +809,7 @@ class RNFishjamClient(
|
|
|
796
809
|
connectPromise?.resolve(null)
|
|
797
810
|
connectPromise = null
|
|
798
811
|
emitEndpoints()
|
|
812
|
+
peerStatus = PeerStatus.connected
|
|
799
813
|
}
|
|
800
814
|
}
|
|
801
815
|
|
|
@@ -846,11 +860,13 @@ class RNFishjamClient(
|
|
|
846
860
|
override fun onPeerUpdated(peer: Peer) {}
|
|
847
861
|
|
|
848
862
|
override fun onBandwidthEstimationChanged(estimation: Long) {
|
|
849
|
-
val
|
|
850
|
-
emitEvent(
|
|
863
|
+
val event = EmitableEvents.BandwidthEstimation
|
|
864
|
+
emitEvent(event, mapOf(event.name to estimation.toFloat()))
|
|
851
865
|
}
|
|
852
866
|
|
|
853
|
-
override fun onDisconnected() {
|
|
867
|
+
override fun onDisconnected() {
|
|
868
|
+
peerStatus = PeerStatus.idle
|
|
869
|
+
}
|
|
854
870
|
|
|
855
871
|
override fun onSocketClose(
|
|
856
872
|
code: Int,
|
|
@@ -859,6 +875,7 @@ class RNFishjamClient(
|
|
|
859
875
|
CoroutineScope(Dispatchers.Main).launch {
|
|
860
876
|
connectPromise?.reject(SocketClosedError(code, reason))
|
|
861
877
|
connectPromise = null
|
|
878
|
+
peerStatus = PeerStatus.error
|
|
862
879
|
}
|
|
863
880
|
}
|
|
864
881
|
|
|
@@ -870,14 +887,14 @@ class RNFishjamClient(
|
|
|
870
887
|
}
|
|
871
888
|
|
|
872
889
|
override fun onReconnected() {
|
|
873
|
-
emitEvent(EmitableEvents.Reconnected
|
|
890
|
+
emitEvent(EmitableEvents.Reconnected)
|
|
874
891
|
}
|
|
875
892
|
|
|
876
893
|
override fun onReconnectionStarted() {
|
|
877
|
-
emitEvent(EmitableEvents.ReconnectionStarted
|
|
894
|
+
emitEvent(EmitableEvents.ReconnectionStarted)
|
|
878
895
|
}
|
|
879
896
|
|
|
880
897
|
override fun onReconnectionRetriesLimitReached() {
|
|
881
|
-
emitEvent(EmitableEvents.ReconnectionRetriesLimitReached
|
|
898
|
+
emitEvent(EmitableEvents.ReconnectionRetriesLimitReached)
|
|
882
899
|
}
|
|
883
900
|
}
|
|
@@ -106,20 +106,7 @@ class RNFishjamClientModule : Module() {
|
|
|
106
106
|
ModuleDefinition {
|
|
107
107
|
Name("RNFishjamClient")
|
|
108
108
|
|
|
109
|
-
Events(
|
|
110
|
-
"IsCameraOn",
|
|
111
|
-
"IsMicrophoneOn",
|
|
112
|
-
"IsScreenShareOn",
|
|
113
|
-
"SimulcastConfigUpdate",
|
|
114
|
-
"PeersUpdate",
|
|
115
|
-
"AudioDeviceUpdate",
|
|
116
|
-
"SendMediaEvent",
|
|
117
|
-
"BandwidthEstimation",
|
|
118
|
-
"ReconnectionRetriesLimitReached",
|
|
119
|
-
"ReconnectionStarted",
|
|
120
|
-
"Reconnected",
|
|
121
|
-
"Warning"
|
|
122
|
-
)
|
|
109
|
+
Events(EmitableEvents.allEvents)
|
|
123
110
|
|
|
124
111
|
val rnFishjamClient =
|
|
125
112
|
RNFishjamClient { name: String, data: Map<String, Any?> ->
|
|
@@ -146,9 +133,9 @@ class RNFishjamClientModule : Module() {
|
|
|
146
133
|
|
|
147
134
|
AsyncFunction(
|
|
148
135
|
"joinRoom"
|
|
149
|
-
) { url: String,
|
|
136
|
+
) { url: String, peerToken: String, peerMetadata: Map<String, Any>, config: ConnectConfig, promise: Promise ->
|
|
150
137
|
CoroutineScope(Dispatchers.Main).launch {
|
|
151
|
-
rnFishjamClient.joinRoom(url,
|
|
138
|
+
rnFishjamClient.joinRoom(url, peerToken, peerMetadata, config, promise)
|
|
152
139
|
}
|
|
153
140
|
}
|
|
154
141
|
|
|
@@ -367,5 +354,9 @@ class RNFishjamClientModule : Module() {
|
|
|
367
354
|
|
|
368
355
|
appContext.reactContext!!.stopService(serviceIntent)
|
|
369
356
|
}
|
|
357
|
+
|
|
358
|
+
Property("peerStatus") {
|
|
359
|
+
return@Property rnFishjamClient.peerStatus
|
|
360
|
+
}
|
|
370
361
|
}
|
|
371
362
|
}
|
|
@@ -8,16 +8,20 @@ import expo.modules.kotlin.AppContext
|
|
|
8
8
|
class VideoPreviewView(
|
|
9
9
|
context: Context,
|
|
10
10
|
appContext: AppContext
|
|
11
|
-
) : VideoView(context, appContext)
|
|
11
|
+
) : VideoView(context, appContext),
|
|
12
|
+
RNFishjamClient.OnLocalCameraTrackChangedListener {
|
|
12
13
|
private var localVideoTrack: LocalVideoTrack? = null
|
|
13
14
|
|
|
14
|
-
private fun
|
|
15
|
+
private fun trySetLocalCameraTrack() {
|
|
15
16
|
localVideoTrack =
|
|
16
17
|
RNFishjamClient.fishjamClient.getLocalEndpoint().tracks.values.firstOrNull { track ->
|
|
17
18
|
track is LocalVideoTrack
|
|
18
19
|
} as? LocalVideoTrack?
|
|
19
|
-
|
|
20
20
|
videoView.let { localVideoTrack?.addRenderer(it) }
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
private fun initialize() {
|
|
24
|
+
trySetLocalCameraTrack()
|
|
21
25
|
super.setupTrack()
|
|
22
26
|
}
|
|
23
27
|
|
|
@@ -27,14 +31,20 @@ class VideoPreviewView(
|
|
|
27
31
|
}
|
|
28
32
|
|
|
29
33
|
override fun onDetachedFromWindow() {
|
|
34
|
+
RNFishjamClient.localCameraTrackListeners.remove(this)
|
|
30
35
|
super.onDetachedFromWindow()
|
|
31
36
|
dispose()
|
|
32
37
|
}
|
|
33
38
|
|
|
34
39
|
override fun onAttachedToWindow() {
|
|
40
|
+
RNFishjamClient.localCameraTrackListeners.add(this)
|
|
35
41
|
super.onAttachedToWindow()
|
|
36
42
|
initialize()
|
|
37
43
|
}
|
|
38
44
|
|
|
39
45
|
override fun getVideoTrack(): VideoTrack? = localVideoTrack
|
|
46
|
+
|
|
47
|
+
override fun onLocalCameraTrackChanged() {
|
|
48
|
+
if (localVideoTrack == null) trySetLocalCameraTrack()
|
|
49
|
+
}
|
|
40
50
|
}
|
|
@@ -1,29 +1,31 @@
|
|
|
1
1
|
import { EventEmitter } from 'expo-modules-core';
|
|
2
2
|
import { NativeModule } from 'react-native';
|
|
3
|
-
import type { RTCStats } from './stats/types';
|
|
3
|
+
import type { RTCStats } from './debug/stats/types';
|
|
4
4
|
import type { ForegroundServiceOptions, SimulcastConfig } from './types';
|
|
5
5
|
import type { CameraConfigInternal, Camera } from './hooks/useCamera';
|
|
6
|
-
import type {
|
|
6
|
+
import type { Peer } from './hooks/usePeers';
|
|
7
7
|
import type { ScreenShareOptionsInternal } from './hooks/useScreenShare';
|
|
8
8
|
import type { ConnectionConfig } from './common/client';
|
|
9
|
+
import { PeerStatus } from './hooks/usePeerStatus';
|
|
9
10
|
type Metadata = {
|
|
10
11
|
[key: string]: any;
|
|
11
12
|
};
|
|
12
13
|
type RNFishjamClient = {
|
|
13
|
-
|
|
14
|
+
isMicrophoneOn: boolean;
|
|
15
|
+
isCameraOn: boolean;
|
|
16
|
+
isScreenShareOn: boolean;
|
|
17
|
+
cameras: ReadonlyArray<Camera>;
|
|
18
|
+
peerStatus: PeerStatus;
|
|
19
|
+
joinRoom: (url: string, peerToken: string, peerMetadata: Metadata, config: ConnectionConfig) => Promise<void>;
|
|
14
20
|
leaveRoom: () => Promise<void>;
|
|
15
21
|
startCamera: (config: CameraConfigInternal) => Promise<void>;
|
|
16
|
-
isMicrophoneOn: boolean;
|
|
17
22
|
toggleMicrophone: () => Promise<boolean>;
|
|
18
|
-
isCameraOn: boolean;
|
|
19
23
|
toggleCamera: () => Promise<boolean>;
|
|
20
24
|
flipCamera: () => Promise<void>;
|
|
21
25
|
switchCamera: (cameraId: string) => Promise<void>;
|
|
22
|
-
cameras: ReadonlyArray<Camera>;
|
|
23
26
|
handleScreenSharePermission: () => Promise<'granted' | 'denied'>;
|
|
24
27
|
toggleScreenShare: (screenShareOptions: Partial<ScreenShareOptionsInternal>) => Promise<void>;
|
|
25
|
-
|
|
26
|
-
getPeers: <PeerMetadataType extends Metadata>() => Promise<Participant<PeerMetadataType>[]>;
|
|
28
|
+
getPeers: <PeerMetadataType extends Metadata>() => Promise<Peer<PeerMetadataType>[]>;
|
|
27
29
|
updatePeerMetadata: <MetadataType extends Metadata>(metadata: MetadataType) => Promise<void>;
|
|
28
30
|
updateVideoTrackMetadata: <MetadataType extends Metadata>(metadata: MetadataType) => Promise<void>;
|
|
29
31
|
updateAudioTrackMetadata: <MetadataType extends Metadata>(metadata: MetadataType) => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RNFishjamClientModule.d.ts","sourceRoot":"","sources":["../src/RNFishjamClientModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAuB,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"RNFishjamClientModule.d.ts","sourceRoot":"","sources":["../src/RNFishjamClientModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAuB,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,wBAAwB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AACzE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAA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