@fishjam-cloud/react-native-client 0.2.3 → 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 +14 -401
- 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/Errors.kt +3 -2
- package/android/src/main/java/io/fishjam/reactnative/RNFishjamClient.kt +122 -105
- package/android/src/main/java/io/fishjam/reactnative/RNFishjamClientModule.kt +24 -33
- package/android/src/main/java/io/fishjam/reactnative/VideoPreviewView.kt +13 -3
- package/build/RNFishjamClientModule.d.ts +17 -15
- package/build/RNFishjamClientModule.d.ts.map +1 -1
- package/build/RNFishjamClientModule.js.map +1 -1
- package/build/common/client.d.ts +4 -4
- package/build/common/client.d.ts.map +1 -1
- package/build/common/client.js +5 -5
- 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/useCamera.d.ts +17 -0
- package/build/hooks/useCamera.d.ts.map +1 -1
- package/build/hooks/useCamera.js +1 -1
- package/build/hooks/useCamera.js.map +1 -1
- package/build/hooks/useFishjamEvent.d.ts +2 -1
- package/build/hooks/useFishjamEvent.d.ts.map +1 -1
- package/build/hooks/useFishjamEvent.js +2 -1
- 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/hooks/useScreenShare.d.ts +57 -0
- package/build/hooks/useScreenShare.d.ts.map +1 -0
- package/build/hooks/useScreenShare.js +85 -0
- package/build/hooks/useScreenShare.js.map +1 -0
- package/build/index.d.ts +8 -7
- package/build/index.d.ts.map +1 -1
- package/build/index.js +4 -4
- 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 +110 -107
- package/ios/RNFishjamClientModule.swift +22 -29
- package/ios/VideoPreviewView.swift +27 -9
- package/package.json +14 -11
- package/plugin/broadcastExtensionFiles/FishjamBroadcastSampleHandler.swift +1 -1
- package/plugin/build/withFishjamIos.js +3 -3
- 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/hooks/useScreencast.d.ts +0 -57
- package/build/hooks/useScreencast.d.ts.map +0 -1
- package/build/hooks/useScreencast.js +0 -85
- package/build/hooks/useScreencast.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
|
@@ -1,416 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
`@fishjam-cloud/react-native-client` is a React Native wrapper for
|
|
4
|
-
[android-client](https://github.com/fishjam-dev/android-client-sdk) and
|
|
5
|
-
[ios-client](https://github.com/fishjam-dev/ios-client-sdk). It allows you to
|
|
6
|
-
quickly and easily create a mobile client app in React Native for a
|
|
7
|
-
[Fishjam](https://github.com/fishjam-dev/fishjam) server.
|
|
1
|
+
<img src="../../.github/images/fishjam-card.png" width="100%">
|
|
8
2
|
|
|
9
|
-
#
|
|
3
|
+
# Fishjam Cloud React Native client
|
|
10
4
|
|
|
11
|
-
|
|
12
|
-
[here](https://fishjam-cloud.github.io/mobile-client-sdk/modules/_fishjam_cloud_react_native_client.html)
|
|
5
|
+
`@fishjam-cloud/react-native-client` is an easiest way to add video streaming to your React Native app.
|
|
13
6
|
|
|
14
7
|
# Installation
|
|
15
8
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
```
|
|
19
|
-
yarn add @fishjam-cloud/react-native-client
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
or
|
|
23
|
-
|
|
24
|
-
```
|
|
25
|
-
npm install @fishjam-cloud/react-native-client
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
### Expo plugin
|
|
29
|
-
|
|
30
|
-
If you're using development builds with `eas build` or bare workflow you can try
|
|
31
|
-
using expo plugin to do the configuration below for you. Simply run:
|
|
32
|
-
|
|
33
|
-
```
|
|
34
|
-
expo install @fishjam-cloud/react-native-client
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
Add plugin to your `app.json` if it's not already added:
|
|
38
|
-
|
|
39
|
-
```json
|
|
40
|
-
{
|
|
41
|
-
"expo": {
|
|
42
|
-
"name": "example",
|
|
43
|
-
...
|
|
44
|
-
"plugins": [
|
|
45
|
-
"@fishjam-cloud/react-native-client"
|
|
46
|
-
]
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
If you want to use screensharing feature, enable the following flags:
|
|
52
|
-
|
|
53
|
-
```json
|
|
54
|
-
{
|
|
55
|
-
"expo": {
|
|
56
|
-
"name": "example",
|
|
57
|
-
...
|
|
58
|
-
"plugins": [
|
|
59
|
-
[
|
|
60
|
-
"@fishjam-cloud/react-native-client",
|
|
61
|
-
{
|
|
62
|
-
"android": {
|
|
63
|
-
"enableForegroundService": true
|
|
64
|
-
},
|
|
65
|
-
"ios": {
|
|
66
|
-
"enableScreensharing": true
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
]
|
|
70
|
-
]
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
On bare workflow run `expo prebuild` to configure the app, then run
|
|
76
|
-
`pod install`. On development build `eas build` should take care of it.
|
|
77
|
-
|
|
78
|
-
### Android
|
|
79
|
-
|
|
80
|
-
1. Add camera and microphone permissions to your `AndroidManifest.xml` or you app.json permissions.
|
|
81
|
-
2. Rebuild the app. That's it!
|
|
82
|
-
|
|
83
|
-
### iOS
|
|
84
|
-
|
|
85
|
-
> [!NOTE]
|
|
86
|
-
> If you're using our plugin with `enableScreensharing` set to `true`. Not further steps are required.
|
|
87
|
-
|
|
88
|
-
On iOS installation is a bit more complicated, because you need to setup a
|
|
89
|
-
screen broadcast app extension for screensharing.
|
|
90
|
-
|
|
91
|
-
1. Add camera and microphone permissions to your main `Info.plist`.
|
|
92
|
-
```xml
|
|
93
|
-
<key>NSCameraUsageDescription</key>
|
|
94
|
-
<string>Allow $(PRODUCT_NAME) to use the camera</string>
|
|
95
|
-
<key>NSMicrophoneUsageDescription</key>
|
|
96
|
-
<string>Allow $(PRODUCT_NAME) to use the microphone</string>
|
|
97
|
-
```
|
|
98
|
-
2. We recommend adding `audio` background mode in `Info.plist` so that the app
|
|
99
|
-
doesn't disconnect when it's in background:
|
|
100
|
-
|
|
101
|
-
```xml
|
|
102
|
-
<key>UIBackgroundModes</key>
|
|
103
|
-
<array>
|
|
104
|
-
<string>audio</string>
|
|
105
|
-
</array>
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
2. Open your `<your-project>.xcworkspace` in Xcode
|
|
109
|
-
3. Create new Broadcast Upload Extension. Select File → New → Target... →
|
|
110
|
-
Broadcast Upload Extension → Next. Choose the name for the new target, select
|
|
111
|
-
Swift language and deselect "Include UI Extension".
|
|
112
|
-
|
|
113
|
-

|
|
114
|
-
|
|
115
|
-
Press Finish. In the next alert xcode will ask you if you want to activate
|
|
116
|
-
the new scheme - press Cancel.
|
|
117
|
-
|
|
118
|
-
4. Configure app group. Go to "Signing & Capabilities" tab, click "+ Capability"
|
|
119
|
-
button in upper left corner and select "App Groups".
|
|
120
|
-
|
|
121
|
-

|
|
122
|
-
|
|
123
|
-
Then in the "App Groups" add a new group or select existing. Usually group
|
|
124
|
-
name has format `group.<your-bundle-identifier>`. Verify that both app and
|
|
125
|
-
extension targets have app group and dev team set correctly.
|
|
126
|
-
|
|
127
|
-
5. A new folder with app extension should appear on the left with contents like
|
|
128
|
-
this:
|
|
129
|
-
|
|
130
|
-

|
|
131
|
-
|
|
132
|
-
Replace `SampleHandler.swift` with `MembraneBroadcastSampleHandler.swift` and
|
|
133
|
-
this code:
|
|
134
|
-
|
|
135
|
-
```swift
|
|
136
|
-
import Foundation
|
|
137
|
-
import MembraneRTC
|
|
138
|
-
import os.log
|
|
139
|
-
import ReplayKit
|
|
140
|
-
import WebRTC
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
/// App Group used by the extension to exchange buffers with the target application
|
|
144
|
-
let appGroup = "{{GROUP_IDENTIFIER}}"
|
|
145
|
-
|
|
146
|
-
let logger = OSLog(subsystem: "{{BUNDLE_IDENTIFIER}}.MembraneBroadcastSampleHandler", category: "Broadcaster")
|
|
147
|
-
|
|
148
|
-
/// An example `SampleHandler` utilizing `BroadcastSampleSource` from `MembraneRTC` sending broadcast samples and necessary notification enabling device's screencast.
|
|
149
|
-
class MembraneBroadcastSampleHandler: RPBroadcastSampleHandler {
|
|
150
|
-
let broadcastSource = BroadcastSampleSource(appGroup: appGroup)
|
|
151
|
-
var started: Bool = false
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
override func broadcastStarted(withSetupInfo _: [String: NSObject]?) {
|
|
155
|
-
started = broadcastSource.connect()
|
|
156
|
-
|
|
157
|
-
guard started else {
|
|
158
|
-
os_log("failed to connect with ipc server", log: logger, type: .debug)
|
|
159
|
-
|
|
160
|
-
super.finishBroadcastWithError(NSError(domain: "", code: 0, userInfo: nil))
|
|
161
|
-
|
|
162
|
-
return
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
broadcastSource.started()
|
|
166
|
-
}
|
|
9
|
+
Check out the [installation](https://fishjam-cloud.github.io/documentation/guide/react-native/installation) section of our docs for the detailed installation instructions.
|
|
167
10
|
|
|
168
|
-
|
|
169
|
-
broadcastSource.paused()
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
override func broadcastResumed() {
|
|
173
|
-
broadcastSource.resumed()
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
override func broadcastFinished() {
|
|
177
|
-
broadcastSource.finished()
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
override func processSampleBuffer(_ sampleBuffer: CMSampleBuffer, with sampleBufferType: RPSampleBufferType) {
|
|
181
|
-
guard started else {
|
|
182
|
-
return
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
broadcastSource.processFrame(sampleBuffer: sampleBuffer, ofType: sampleBufferType)
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
Replace `{{GROUP_IDENTIFIER}}` and `{{BUNDLE_IDENTIFIER}}` with your group
|
|
191
|
-
identifier and bundle identifier respectively.
|
|
192
|
-
|
|
193
|
-
6. In project's Podfile add the following code:
|
|
194
|
-
```rb
|
|
195
|
-
target 'MembraneScreenBroadcastExtension' do
|
|
196
|
-
pod 'MembraneRTC/Broadcast'
|
|
197
|
-
end
|
|
198
|
-
```
|
|
199
|
-
> This new dependency should be added outside of your application target.
|
|
200
|
-
> Example
|
|
201
|
-
>
|
|
202
|
-
> ```rb
|
|
203
|
-
> target 'ReactNativeMembraneExample' do
|
|
204
|
-
> ...
|
|
205
|
-
> end
|
|
206
|
-
>
|
|
207
|
-
> target 'MembraneScreenBroadcastExtension' do
|
|
208
|
-
> pod 'MembraneRTC/Broadcast'
|
|
209
|
-
> end
|
|
210
|
-
> ```
|
|
211
|
-
7. Run `pod install` in your `ios/` directory
|
|
212
|
-
8. Add the following constants in your Info.plist:
|
|
213
|
-
```xml
|
|
214
|
-
<key>AppGroupName</key>
|
|
215
|
-
<string>{{GROUP_IDENTIFIER}}</string>
|
|
216
|
-
<key>ScreencastExtensionBundleId</key>
|
|
217
|
-
<string>{{BUNDLE_IDENTIFIER}}.MembraneBroadcastSampleHandler</string>
|
|
218
|
-
```
|
|
219
|
-
Replace `{{GROUP_IDENTIFIER}}` and `{{BUNDLE_IDENTIFIER}}` with your group
|
|
220
|
-
identifier and bundle identifier respectively.
|
|
221
|
-
9. Rebuild the app and enjoy!
|
|
222
|
-
|
|
223
|
-
# Example
|
|
224
|
-
|
|
225
|
-
We strongly recommend checking out our example app that implements a basic video
|
|
226
|
-
room client. To run the app:
|
|
227
|
-
|
|
228
|
-
1. Go to Membrane's server demo repo: https://fishjam.io/app/login Follow
|
|
229
|
-
instructions there to setup and run demo server.
|
|
230
|
-
2. Clone the repo
|
|
231
|
-
3. ```
|
|
232
|
-
yarn
|
|
233
|
-
yarn build
|
|
234
|
-
cd `examples/fishjam-chat`
|
|
235
|
-
npx expo prebuild --clean
|
|
236
|
-
```
|
|
237
|
-
4. Copy `.env.template` and create `.env` with proper secrets.
|
|
238
|
-
5. `yarn run android` or `yarn run ios` or run project from Android Studio /
|
|
239
|
-
Xcode just like every RN project. Note that simulators won't work, you have
|
|
240
|
-
to test on real device for camera and screensharing to run.
|
|
241
|
-
|
|
242
|
-
# Usage
|
|
243
|
-
|
|
244
|
-
> [!CAUTION]
|
|
245
|
-
> This part of documentation is out of date. It will be updated soon.
|
|
246
|
-
|
|
247
|
-
Connect to the server and join the room using the `connect` function. Use user
|
|
248
|
-
metadata to pass things like usernames etc. to the server.
|
|
249
|
-
|
|
250
|
-
```ts
|
|
251
|
-
const startServerConnection = () => {
|
|
252
|
-
try {
|
|
253
|
-
await connect('http://server_address:5002', 'peer_token', {
|
|
254
|
-
displayName: 'Annie',
|
|
255
|
-
});
|
|
256
|
-
} catch (e) {
|
|
257
|
-
console.log('error!');
|
|
258
|
-
}
|
|
259
|
-
};
|
|
260
|
-
```
|
|
261
|
-
|
|
262
|
-
Remember to gracefully disconnect from the server using the `leaveRoom()`
|
|
263
|
-
function:
|
|
264
|
-
|
|
265
|
-
```ts
|
|
266
|
-
const stopServerConnection = () => {
|
|
267
|
-
await leaveRoom();
|
|
268
|
-
};
|
|
269
|
-
```
|
|
270
|
-
|
|
271
|
-
Start the device's camera and microphone using `useCamera()` and
|
|
272
|
-
`useMicrophone()` hooks. Use `videoTrackMetadata` and `audioTrackMetadata`
|
|
273
|
-
options to send metadata about the tracks (for example whether it's a camera or
|
|
274
|
-
screencast track).
|
|
275
|
-
|
|
276
|
-
```ts
|
|
277
|
-
const { startCamera } = useCamera();
|
|
278
|
-
const { startMicrophone } = useMicrophone();
|
|
279
|
-
|
|
280
|
-
await startCamera({
|
|
281
|
-
quality: VideoQuality.HD_169,
|
|
282
|
-
videoTrackMetadata: { active: true, type: 'camera' },
|
|
283
|
-
});
|
|
284
|
-
await startMicrophone({ audioTrackMetadata: { active: true, type: 'audio' } });
|
|
285
|
-
```
|
|
286
|
-
|
|
287
|
-
For more options and functions to control the camera and microphone see the API
|
|
288
|
-
documentation.
|
|
289
|
-
|
|
290
|
-
If you have the connection set up, then use `useParticipants()` hook to track
|
|
291
|
-
the other participants in the room. One of the participants will be a local
|
|
292
|
-
participant (the one who's using the device). When participants is added or
|
|
293
|
-
removed because an user joins or leaves the room, the participants will be
|
|
294
|
-
updated automatically. Simply call the hook like this:
|
|
295
|
-
|
|
296
|
-
```ts
|
|
297
|
-
const participants = useParticipants();
|
|
298
|
-
```
|
|
299
|
-
|
|
300
|
-
When you have the participants all that's left is to render their video tracks.
|
|
301
|
-
Use `<VideoRendererView />` component like this:
|
|
302
|
-
|
|
303
|
-
```ts
|
|
304
|
-
{
|
|
305
|
-
endpoint.videoTracks.map((track) => (
|
|
306
|
-
<VideoRendererView trackId={track.id} />
|
|
307
|
-
));
|
|
308
|
-
}
|
|
309
|
-
```
|
|
310
|
-
|
|
311
|
-
You can style the views to lay out them however you'd like, basic animations
|
|
312
|
-
should work too.
|
|
313
|
-
|
|
314
|
-
There are also some simple hooks for toggling camera, microphone and
|
|
315
|
-
screensharing. Use them like this:
|
|
316
|
-
|
|
317
|
-
```ts
|
|
318
|
-
const { isCameraOn, toggleCamera } = useCameraState();
|
|
319
|
-
const { isMicrophoneOn, toggleMicrophone } = useMicrophoneState();
|
|
320
|
-
```
|
|
321
|
-
|
|
322
|
-
For screencasting use `useScreencast()` hook. The local endpoint will have a new
|
|
323
|
-
video track which you can render just like an ordinary video track with
|
|
324
|
-
<VideoRendererView />:
|
|
325
|
-
|
|
326
|
-
```ts
|
|
327
|
-
const { isScreencastOn, toggleScreencast } = useScreencast();
|
|
328
|
-
...
|
|
329
|
-
toggleScreencast({screencastMetadata: { displayName: "Annie's desktop" }});
|
|
330
|
-
```
|
|
331
|
-
|
|
332
|
-
Use track metadata to differentiate between video and screencast tracks.
|
|
333
|
-
|
|
334
|
-
### Android foreground service
|
|
335
|
-
|
|
336
|
-
> [!NOTE]
|
|
337
|
-
> If you're using our plugin with `enableForegroundService` set to `true`. Not further steps are required.
|
|
338
|
-
|
|
339
|
-
In order for the call to continue running when app is in background, you need to
|
|
340
|
-
set up and start a foreground service. You can use a 3rd party library for this,
|
|
341
|
-
for example [notifee](https://notifee.app/).
|
|
342
|
-
|
|
343
|
-
In `AndroidManifest.xml` specify necessary permissions:
|
|
344
|
-
|
|
345
|
-
```xml
|
|
346
|
-
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PROJECTION" />
|
|
347
|
-
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_CAMERA" />
|
|
348
|
-
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE" />
|
|
349
|
-
```
|
|
350
|
-
|
|
351
|
-
And add foreground service:
|
|
352
|
-
|
|
353
|
-
```xml
|
|
354
|
-
<application
|
|
355
|
-
...
|
|
356
|
-
>
|
|
357
|
-
...
|
|
358
|
-
<service
|
|
359
|
-
android:name="app.notifee.core.ForegroundService"
|
|
360
|
-
android:foregroundServiceType="mediaProjection|camera|microphone" />
|
|
361
|
-
</application>
|
|
362
|
-
```
|
|
363
|
-
|
|
364
|
-
Then to start the foreground service:
|
|
365
|
-
|
|
366
|
-
```ts
|
|
367
|
-
import notifee, { AndroidImportance } from '@notifee/react-native';
|
|
368
|
-
|
|
369
|
-
const startForegroundService = async () => {
|
|
370
|
-
if (Platform.OS === 'android') {
|
|
371
|
-
const channelId = await notifee.createChannel({
|
|
372
|
-
id: 'video_call',
|
|
373
|
-
name: 'Video call',
|
|
374
|
-
lights: false,
|
|
375
|
-
vibration: false,
|
|
376
|
-
importance: AndroidImportance.DEFAULT,
|
|
377
|
-
});
|
|
11
|
+
# Documentation
|
|
378
12
|
|
|
379
|
-
|
|
380
|
-
title: 'Your video call is ongoing',
|
|
381
|
-
body: 'Tap to return to the call.',
|
|
382
|
-
android: {
|
|
383
|
-
channelId,
|
|
384
|
-
asForegroundService: true,
|
|
385
|
-
ongoing: true,
|
|
386
|
-
pressAction: {
|
|
387
|
-
id: 'default',
|
|
388
|
-
},
|
|
389
|
-
},
|
|
390
|
-
});
|
|
391
|
-
}
|
|
392
|
-
};
|
|
393
|
-
```
|
|
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.
|
|
394
14
|
|
|
395
|
-
|
|
15
|
+
There is also [API documentation](https://fishjam-cloud.github.io/mobile-client-sdk/modules/_fishjam_cloud_react_native_client.html) available.
|
|
396
16
|
|
|
397
|
-
|
|
398
|
-
notifee.stopForegroundService();
|
|
399
|
-
```
|
|
17
|
+
# Examples
|
|
400
18
|
|
|
401
|
-
|
|
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).
|
|
402
20
|
|
|
403
|
-
|
|
404
|
-
notifee.registerForegroundService((notification) => {
|
|
405
|
-
return new Promise(() => {});
|
|
406
|
-
});
|
|
407
|
-
```
|
|
21
|
+
## License
|
|
408
22
|
|
|
409
|
-
|
|
23
|
+
Licensed under the [Apache License, Version 2.0](LICENSE)
|
|
410
24
|
|
|
411
|
-
|
|
412
|
-
[Software Mansion](https://swmansion.com/?utm_source=git&utm_medium=readme&utm_campaign=react-client)
|
|
25
|
+
## Fishjam Cloud is created by Software Mansion
|
|
413
26
|
|
|
414
|
-
[
|
|
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).
|
|
415
28
|
|
|
416
|
-
|
|
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
|
}
|