@fishjam-cloud/react-native-client 0.1.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/.eslintignore +7 -0
- package/.eslintrc +6 -0
- package/.prettierrc +9 -0
- package/.watchmanconfig +1 -0
- package/android/.editorconfig +9 -0
- package/android/build.gradle +89 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/org/membraneframework/reactnative/AudioDeviceKind.kt +34 -0
- package/android/src/main/java/org/membraneframework/reactnative/AudioSwitchManager.kt +61 -0
- package/android/src/main/java/org/membraneframework/reactnative/EmitableEvents.kt +14 -0
- package/android/src/main/java/org/membraneframework/reactnative/Errors.kt +31 -0
- package/android/src/main/java/org/membraneframework/reactnative/RNFishjamClient.kt +866 -0
- package/android/src/main/java/org/membraneframework/reactnative/RNFishjamClientModule.kt +294 -0
- package/android/src/main/java/org/membraneframework/reactnative/Utils.kt +11 -0
- package/android/src/main/java/org/membraneframework/reactnative/VideoPreviewView.kt +40 -0
- package/android/src/main/java/org/membraneframework/reactnative/VideoPreviewViewModule.kt +17 -0
- package/android/src/main/java/org/membraneframework/reactnative/VideoRendererView.kt +58 -0
- package/android/src/main/java/org/membraneframework/reactnative/VideoRendererViewModule.kt +25 -0
- package/android/src/main/java/org/membraneframework/reactnative/VideoView.kt +77 -0
- package/app.plugin.js +1 -0
- package/babel.config.js +2 -0
- package/build/RNFishjamClientModule.d.ts +47 -0
- package/build/RNFishjamClientModule.d.ts.map +1 -0
- package/build/RNFishjamClientModule.js +4 -0
- package/build/RNFishjamClientModule.js.map +1 -0
- package/build/common/client.d.ts +19 -0
- package/build/common/client.d.ts.map +1 -0
- package/build/common/client.js +8 -0
- package/build/common/client.js.map +1 -0
- package/build/common/eventEmitter.d.ts +16 -0
- package/build/common/eventEmitter.d.ts.map +1 -0
- package/build/common/eventEmitter.js +17 -0
- package/build/common/eventEmitter.js.map +1 -0
- package/build/common/metadata.d.ts +7 -0
- package/build/common/metadata.d.ts.map +1 -0
- package/build/common/metadata.js +9 -0
- package/build/common/metadata.js.map +1 -0
- package/build/common/webRTC.d.ts +19 -0
- package/build/common/webRTC.d.ts.map +1 -0
- package/build/common/webRTC.js +22 -0
- package/build/common/webRTC.js.map +1 -0
- package/build/components/VideoPreviewView.d.ts +21 -0
- package/build/components/VideoPreviewView.d.ts.map +1 -0
- package/build/components/VideoPreviewView.js +7 -0
- package/build/components/VideoPreviewView.js.map +1 -0
- package/build/components/VideoRendererView.d.ts +19 -0
- package/build/components/VideoRendererView.d.ts.map +1 -0
- package/build/components/VideoRendererView.js +7 -0
- package/build/components/VideoRendererView.js.map +1 -0
- package/build/hooks/useAudioSettings.d.ts +23 -0
- package/build/hooks/useAudioSettings.d.ts.map +1 -0
- package/build/hooks/useAudioSettings.js +72 -0
- package/build/hooks/useAudioSettings.js.map +1 -0
- package/build/hooks/useBandwidthEstimation.d.ts +12 -0
- package/build/hooks/useBandwidthEstimation.d.ts.map +1 -0
- package/build/hooks/useBandwidthEstimation.js +16 -0
- package/build/hooks/useBandwidthEstimation.js.map +1 -0
- package/build/hooks/useCamera.d.ts +80 -0
- package/build/hooks/useCamera.d.ts.map +1 -0
- package/build/hooks/useCamera.js +140 -0
- package/build/hooks/useCamera.js.map +1 -0
- package/build/hooks/useMicrophone.d.ts +8 -0
- package/build/hooks/useMicrophone.d.ts.map +1 -0
- package/build/hooks/useMicrophone.js +27 -0
- package/build/hooks/useMicrophone.js.map +1 -0
- package/build/hooks/useParticipants.d.ts +62 -0
- package/build/hooks/useParticipants.d.ts.map +1 -0
- package/build/hooks/useParticipants.js +32 -0
- package/build/hooks/useParticipants.js.map +1 -0
- package/build/hooks/useReconnection.d.ts +5 -0
- package/build/hooks/useReconnection.d.ts.map +1 -0
- package/build/hooks/useReconnection.js +23 -0
- package/build/hooks/useReconnection.js.map +1 -0
- package/build/hooks/useScreencast.d.ts +38 -0
- package/build/hooks/useScreencast.d.ts.map +1 -0
- package/build/hooks/useScreencast.js +81 -0
- package/build/hooks/useScreencast.js.map +1 -0
- package/build/index.d.ts +24 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +14 -0
- package/build/index.js.map +1 -0
- package/build/protos/fishjam/peer_notifications.d.ts +63 -0
- package/build/protos/fishjam/peer_notifications.d.ts.map +1 -0
- package/build/protos/fishjam/peer_notifications.js +235 -0
- package/build/protos/fishjam/peer_notifications.js.map +1 -0
- package/build/stats/types.d.ts +55 -0
- package/build/stats/types.d.ts.map +1 -0
- package/build/stats/types.js +2 -0
- package/build/stats/types.js.map +1 -0
- package/build/stats/useRTCStatistics.d.ts +8 -0
- package/build/stats/useRTCStatistics.d.ts.map +1 -0
- package/build/stats/useRTCStatistics.js +78 -0
- package/build/stats/useRTCStatistics.js.map +1 -0
- package/build/types.d.ts +43 -0
- package/build/types.d.ts.map +1 -0
- package/build/types.js +2 -0
- package/build/types.js.map +1 -0
- package/expo-module.config.json +17 -0
- package/ios/Events.swift +13 -0
- package/ios/RNFishjamClient.podspec +30 -0
- package/ios/RNFishjamClient.swift +836 -0
- package/ios/RNFishjamClientModule.swift +220 -0
- package/ios/Utils.swift +43 -0
- package/ios/VideoPreviewView.swift +64 -0
- package/ios/VideoPreviewViewModule.swift +21 -0
- package/ios/VideoRendererView.swift +84 -0
- package/ios/VideoRendererViewModule.swift +17 -0
- package/ios/swift-format-config.json +56 -0
- package/package.json +89 -0
- package/plugin/broadcastExtensionFiles/Info.plist +27 -0
- package/plugin/broadcastExtensionFiles/MembraneBroadcastSampleHandler.swift +50 -0
- package/plugin/broadcastExtensionFiles/MembraneScreenBroadcastExtension.entitlements +10 -0
- package/plugin/src/withMembrane.ts +310 -0
- package/plugin/tsconfig.json +9 -0
- package/scripts/lint.sh +18 -0
- package/scripts/lint_check.sh +14 -0
- package/src/RNFishjamClientModule.ts +73 -0
- package/src/__tests__/index.test.tsx +199 -0
- package/src/common/client.ts +33 -0
- package/src/common/eventEmitter.ts +21 -0
- package/src/common/metadata.ts +12 -0
- package/src/common/webRTC.ts +31 -0
- package/src/components/VideoPreviewView.tsx +33 -0
- package/src/components/VideoRendererView.tsx +31 -0
- package/src/hooks/useAudioSettings.ts +115 -0
- package/src/hooks/useBandwidthEstimation.ts +24 -0
- package/src/hooks/useCamera.ts +270 -0
- package/src/hooks/useMicrophone.ts +38 -0
- package/src/hooks/useParticipants.ts +118 -0
- package/src/hooks/useReconnection.ts +41 -0
- package/src/hooks/useScreencast.ts +146 -0
- package/src/index.tsx +63 -0
- package/src/protos/fishjam/peer_notifications.ts +299 -0
- package/src/stats/types.ts +56 -0
- package/src/stats/useRTCStatistics.ts +97 -0
- package/src/types.ts +49 -0
- package/tsconfig.json +9 -0
- package/typedoc.json +5 -0
package/.eslintignore
ADDED
package/.eslintrc
ADDED
package/.prettierrc
ADDED
package/.watchmanconfig
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
[*.{kt,kts}]
|
|
2
|
+
ktlint_code_style = ktlint_official
|
|
3
|
+
ktlint_standard_no-wildcard-imports = disabled
|
|
4
|
+
ktlint_standard_filename = disabled
|
|
5
|
+
ktlint_standard_function-naming = disabled
|
|
6
|
+
ktlint_standard_property-naming = disabled
|
|
7
|
+
ij_kotlin_allow_trailing_comma = false
|
|
8
|
+
ij_kotlin_allow_trailing_comma_on_call_site = false
|
|
9
|
+
ktlint_standard_function-literal = disabled
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
apply plugin: 'com.android.library'
|
|
2
|
+
apply plugin: 'kotlin-android'
|
|
3
|
+
apply plugin: 'maven-publish'
|
|
4
|
+
|
|
5
|
+
group = 'org.membraneframework.reactnative'
|
|
6
|
+
version = '0.1.0'
|
|
7
|
+
|
|
8
|
+
buildscript {
|
|
9
|
+
def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
|
|
10
|
+
if (expoModulesCorePlugin.exists()) {
|
|
11
|
+
apply from: expoModulesCorePlugin
|
|
12
|
+
applyKotlinExpoModulesCorePlugin()
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Simple helper that allows the root project to override versions declared by this library.
|
|
16
|
+
ext.safeExtGet = { prop, fallback ->
|
|
17
|
+
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Ensures backward compatibility
|
|
21
|
+
ext.getKotlinVersion = {
|
|
22
|
+
if (ext.has("kotlinVersion")) {
|
|
23
|
+
ext.kotlinVersion()
|
|
24
|
+
} else {
|
|
25
|
+
ext.safeExtGet("kotlinVersion", "1.6.10")
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
repositories {
|
|
30
|
+
mavenLocal()
|
|
31
|
+
mavenCentral()
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
dependencies {
|
|
35
|
+
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${getKotlinVersion()}")
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
afterEvaluate {
|
|
40
|
+
publishing {
|
|
41
|
+
publications {
|
|
42
|
+
release(MavenPublication) {
|
|
43
|
+
from components.release
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
repositories {
|
|
47
|
+
maven {
|
|
48
|
+
url = mavenLocal().url
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
android {
|
|
55
|
+
namespace = "org.membraneframework.reactnative"
|
|
56
|
+
compileSdk(31)
|
|
57
|
+
|
|
58
|
+
defaultConfig {
|
|
59
|
+
minSdkVersion safeExtGet("minSdkVersion", 21)
|
|
60
|
+
targetSdkVersion safeExtGet("targetSdkVersion", 31)
|
|
61
|
+
versionCode 1
|
|
62
|
+
versionName "0.1.0"
|
|
63
|
+
}
|
|
64
|
+
lintOptions {
|
|
65
|
+
abortOnError false
|
|
66
|
+
}
|
|
67
|
+
publishing {
|
|
68
|
+
singleVariant("release") {
|
|
69
|
+
withSourcesJar()
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
repositories {
|
|
75
|
+
mavenCentral()
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
dependencies {
|
|
79
|
+
implementation project(':expo-modules-core')
|
|
80
|
+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${getKotlinVersion()}"
|
|
81
|
+
if (findProject(':fishjam-cloud-android-client')) {
|
|
82
|
+
implementation project(':fishjam-cloud-android-client')
|
|
83
|
+
} else {
|
|
84
|
+
// todo when released, changed repo name etc then update
|
|
85
|
+
implementation 'com.github.fishjam-cloud:mobile-client-sdk:0.1.0'
|
|
86
|
+
}
|
|
87
|
+
api 'com.github.davidliu:audioswitch:8edf84ee46cdbc84c2b7725aa8f8d66363e19876'
|
|
88
|
+
implementation 'androidx.appcompat:appcompat:1.6.1'
|
|
89
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
package org.membraneframework.reactnative
|
|
2
|
+
|
|
3
|
+
import com.twilio.audioswitch.AudioDevice
|
|
4
|
+
|
|
5
|
+
enum class AudioDeviceKind(
|
|
6
|
+
val typeName: String,
|
|
7
|
+
val audioDeviceClass: Class<out AudioDevice>
|
|
8
|
+
) {
|
|
9
|
+
BLUETOOTH("bluetooth", AudioDevice.BluetoothHeadset::class.java),
|
|
10
|
+
WIRED_HEADSET("headset", AudioDevice.WiredHeadset::class.java),
|
|
11
|
+
SPEAKER("speaker", AudioDevice.Speakerphone::class.java),
|
|
12
|
+
EARPIECE("earpiece", AudioDevice.Earpiece::class.java)
|
|
13
|
+
;
|
|
14
|
+
|
|
15
|
+
companion object {
|
|
16
|
+
fun fromAudioDevice(audioDevice: AudioDevice): AudioDeviceKind? {
|
|
17
|
+
for (kind in values()) {
|
|
18
|
+
if (kind.audioDeviceClass == audioDevice.javaClass) {
|
|
19
|
+
return kind
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return null
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
fun fromTypeName(typeName: String): AudioDeviceKind? {
|
|
26
|
+
for (kind in values()) {
|
|
27
|
+
if (kind.typeName == typeName) {
|
|
28
|
+
return kind
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return null
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
package org.membraneframework.reactnative
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import android.os.Handler
|
|
5
|
+
import android.os.Looper
|
|
6
|
+
import com.twilio.audioswitch.AudioDevice
|
|
7
|
+
import com.twilio.audioswitch.AudioDeviceChangeListener
|
|
8
|
+
import com.twilio.audioswitch.AudioSwitch
|
|
9
|
+
|
|
10
|
+
class AudioSwitchManager(
|
|
11
|
+
private val context: Context
|
|
12
|
+
) {
|
|
13
|
+
private var preferredDeviceList =
|
|
14
|
+
listOf(
|
|
15
|
+
AudioDevice.BluetoothHeadset::class.java,
|
|
16
|
+
AudioDevice.WiredHeadset::class.java,
|
|
17
|
+
AudioDevice.Speakerphone::class.java,
|
|
18
|
+
AudioDevice.Earpiece::class.java
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
// AudioSwitch is not threadsafe, so all calls should be done on the main thread.
|
|
22
|
+
private val handler: Handler = Handler(Looper.getMainLooper())
|
|
23
|
+
|
|
24
|
+
private var audioSwitch: AudioSwitch =
|
|
25
|
+
AudioSwitch(context, loggingEnabled = true, preferredDeviceList = preferredDeviceList)
|
|
26
|
+
|
|
27
|
+
fun start(listener: AudioDeviceChangeListener) {
|
|
28
|
+
handler.removeCallbacksAndMessages(null)
|
|
29
|
+
handler.postAtFrontOfQueue {
|
|
30
|
+
audioSwitch.start(listener)
|
|
31
|
+
audioSwitch.activate()
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
fun stop() {
|
|
36
|
+
handler.removeCallbacksAndMessages(null)
|
|
37
|
+
handler.postAtFrontOfQueue {
|
|
38
|
+
audioSwitch.stop()
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
fun selectedAudioDevice(): AudioDevice? = audioSwitch.selectedAudioDevice
|
|
43
|
+
|
|
44
|
+
fun availableAudioDevices(): List<AudioDevice> = audioSwitch.availableAudioDevices
|
|
45
|
+
|
|
46
|
+
fun selectAudioOutput(audioDeviceClass: Class<out AudioDevice?>) {
|
|
47
|
+
handler.post {
|
|
48
|
+
availableAudioDevices()
|
|
49
|
+
.find { it.javaClass == audioDeviceClass }
|
|
50
|
+
?.let {
|
|
51
|
+
audioSwitch.selectDevice(it)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
fun selectAudioOutput(kind: AudioDeviceKind?) {
|
|
57
|
+
if (kind != null) {
|
|
58
|
+
selectAudioOutput(kind.audioDeviceClass)
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
package org.membraneframework.reactnative
|
|
2
|
+
|
|
3
|
+
object EmitableEvents {
|
|
4
|
+
const val IsCameraOn = "IsCameraOn"
|
|
5
|
+
const val IsMicrophoneOn = "IsMicrophoneOn"
|
|
6
|
+
const val IsScreencastOn = "IsScreencastOn"
|
|
7
|
+
const val SimulcastConfigUpdate = "SimulcastConfigUpdate"
|
|
8
|
+
const val PeersUpdate = "PeersUpdate"
|
|
9
|
+
const val AudioDeviceUpdate = "AudioDeviceUpdate"
|
|
10
|
+
const val BandwidthEstimation = "BandwidthEstimation"
|
|
11
|
+
const val ReconnectionRetriesLimitReached = "ReconnectionRetriesLimitReached"
|
|
12
|
+
const val ReconnectionStarted = "ReconnectionStarted"
|
|
13
|
+
const val Reconnected = "Reconnected"
|
|
14
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
package org.membraneframework.reactnative
|
|
2
|
+
|
|
3
|
+
import com.fishjamcloud.client.models.AuthError
|
|
4
|
+
import expo.modules.kotlin.exception.CodedException
|
|
5
|
+
|
|
6
|
+
class JoinError(
|
|
7
|
+
metadata: Any
|
|
8
|
+
) : CodedException(message = "Join error: $metadata")
|
|
9
|
+
|
|
10
|
+
class ConnectionError(
|
|
11
|
+
reason: AuthError
|
|
12
|
+
) : CodedException(message = "Connection error: ${reason.error}")
|
|
13
|
+
|
|
14
|
+
class MissingScreencastPermission : CodedException(message = "No permission to start screencast, call handleScreencastPermission first.")
|
|
15
|
+
|
|
16
|
+
class ClientNotConnectedError : CodedException(message = "Client not connected to server yet. Make sure to call connect() first!")
|
|
17
|
+
|
|
18
|
+
class NoLocalVideoTrackError : CodedException(message = "No local video track. Make sure to call connect() first!")
|
|
19
|
+
|
|
20
|
+
class NoLocalAudioTrackError : CodedException(message = "No local audio track. Make sure to call connect() first!")
|
|
21
|
+
|
|
22
|
+
class NoScreencastTrackError : CodedException(message = "No local screencast track. Make sure to toggle screencast on first!")
|
|
23
|
+
|
|
24
|
+
class SocketClosedError(
|
|
25
|
+
code: Int,
|
|
26
|
+
reason: String
|
|
27
|
+
) : CodedException(message = "Socket was closed with code = $code and reason = $reason")
|
|
28
|
+
|
|
29
|
+
class SocketError(
|
|
30
|
+
message: String
|
|
31
|
+
) : CodedException(message = "Socket error: $message")
|