@fishjam-cloud/react-native-client 0.2.1 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/android/build.gradle +1 -1
  2. package/android/src/main/AndroidManifest.xml +2 -0
  3. package/android/src/main/java/io/fishjam/reactnative/AudioDeviceKind.kt +34 -0
  4. package/android/src/main/java/io/fishjam/reactnative/AudioSwitchManager.kt +61 -0
  5. package/android/src/main/java/io/fishjam/reactnative/EmitableEvents.kt +15 -0
  6. package/android/src/main/java/io/fishjam/reactnative/Errors.kt +31 -0
  7. package/android/src/main/java/io/fishjam/reactnative/FishjamForegroundService.kt +90 -0
  8. package/android/src/main/java/io/fishjam/reactnative/RNFishjamClient.kt +883 -0
  9. package/android/src/main/java/io/fishjam/reactnative/RNFishjamClientModule.kt +371 -0
  10. package/android/src/main/java/io/fishjam/reactnative/Utils.kt +11 -0
  11. package/android/src/main/java/io/fishjam/reactnative/VideoPreviewView.kt +40 -0
  12. package/android/src/main/java/io/fishjam/reactnative/VideoPreviewViewModule.kt +17 -0
  13. package/android/src/main/java/io/fishjam/reactnative/VideoRendererView.kt +58 -0
  14. package/android/src/main/java/io/fishjam/reactnative/VideoRendererViewModule.kt +25 -0
  15. package/android/src/main/java/io/fishjam/reactnative/VideoView.kt +77 -0
  16. package/build/RNFishjamClientModule.d.ts +2 -0
  17. package/build/RNFishjamClientModule.d.ts.map +1 -1
  18. package/build/RNFishjamClientModule.js +2 -1
  19. package/build/RNFishjamClientModule.js.map +1 -1
  20. package/build/common/client.d.ts +4 -1
  21. package/build/common/client.d.ts.map +1 -1
  22. package/build/common/client.js +4 -1
  23. package/build/common/client.js.map +1 -1
  24. package/build/common/metadata.d.ts +1 -0
  25. package/build/common/metadata.d.ts.map +1 -1
  26. package/build/common/metadata.js +1 -0
  27. package/build/common/metadata.js.map +1 -1
  28. package/build/common/webRTC.d.ts +2 -0
  29. package/build/common/webRTC.d.ts.map +1 -1
  30. package/build/common/webRTC.js +2 -0
  31. package/build/common/webRTC.js.map +1 -1
  32. package/build/components/VideoPreviewView.d.ts +6 -3
  33. package/build/components/VideoPreviewView.d.ts.map +1 -1
  34. package/build/components/VideoPreviewView.js +5 -0
  35. package/build/components/VideoPreviewView.js.map +1 -1
  36. package/build/components/VideoRendererView.d.ts +5 -3
  37. package/build/components/VideoRendererView.d.ts.map +1 -1
  38. package/build/components/VideoRendererView.js +4 -0
  39. package/build/components/VideoRendererView.js.map +1 -1
  40. package/build/hooks/useAudioSettings.d.ts +15 -0
  41. package/build/hooks/useAudioSettings.d.ts.map +1 -1
  42. package/build/hooks/useAudioSettings.js +15 -13
  43. package/build/hooks/useAudioSettings.js.map +1 -1
  44. package/build/hooks/useBandwidthEstimation.d.ts +2 -0
  45. package/build/hooks/useBandwidthEstimation.d.ts.map +1 -1
  46. package/build/hooks/useBandwidthEstimation.js +2 -0
  47. package/build/hooks/useBandwidthEstimation.js.map +1 -1
  48. package/build/hooks/useCamera.d.ts +45 -1
  49. package/build/hooks/useCamera.d.ts.map +1 -1
  50. package/build/hooks/useCamera.js +45 -37
  51. package/build/hooks/useCamera.js.map +1 -1
  52. package/build/hooks/useFishjamEvent.d.ts +1 -0
  53. package/build/hooks/useFishjamEvent.d.ts.map +1 -1
  54. package/build/hooks/useFishjamEvent.js +3 -4
  55. package/build/hooks/useFishjamEvent.js.map +1 -1
  56. package/build/hooks/useMicrophone.d.ts +4 -0
  57. package/build/hooks/useMicrophone.d.ts.map +1 -1
  58. package/build/hooks/useMicrophone.js +8 -4
  59. package/build/hooks/useMicrophone.js.map +1 -1
  60. package/build/hooks/useParticipants.d.ts +2 -0
  61. package/build/hooks/useParticipants.d.ts.map +1 -1
  62. package/build/hooks/useParticipants.js +2 -0
  63. package/build/hooks/useParticipants.js.map +1 -1
  64. package/build/hooks/useReconnection.d.ts +6 -0
  65. package/build/hooks/useReconnection.d.ts.map +1 -1
  66. package/build/hooks/useReconnection.js +6 -0
  67. package/build/hooks/useReconnection.js.map +1 -1
  68. package/build/hooks/useScreencast.d.ts +22 -3
  69. package/build/hooks/useScreencast.d.ts.map +1 -1
  70. package/build/hooks/useScreencast.js +30 -22
  71. package/build/hooks/useScreencast.js.map +1 -1
  72. package/build/index.d.ts +1 -1
  73. package/build/index.d.ts.map +1 -1
  74. package/build/index.js +2 -0
  75. package/build/index.js.map +1 -1
  76. package/build/stats/useRTCStatistics.d.ts +1 -0
  77. package/build/stats/useRTCStatistics.d.ts.map +1 -1
  78. package/build/stats/useRTCStatistics.js +1 -0
  79. package/build/stats/useRTCStatistics.js.map +1 -1
  80. package/build/types.d.ts +6 -0
  81. package/build/types.d.ts.map +1 -1
  82. package/build/types.js.map +1 -1
  83. package/build/utils/errorListener.d.ts +2 -0
  84. package/build/utils/errorListener.d.ts.map +1 -0
  85. package/build/utils/errorListener.js +16 -0
  86. package/build/utils/errorListener.js.map +1 -0
  87. package/build/utils/foregroundService.d.ts +2 -0
  88. package/build/utils/foregroundService.d.ts.map +1 -1
  89. package/build/utils/foregroundService.js +2 -0
  90. package/build/utils/foregroundService.js.map +1 -1
  91. package/ios/Events.swift +1 -0
  92. package/ios/RNFishjamClient.podspec +1 -1
  93. package/ios/RNFishjamClient.swift +14 -0
  94. package/package.json +7 -6
  95. package/plugin/broadcastExtensionFiles/FishjamBroadcastSampleHandler.swift +50 -0
  96. package/plugin/broadcastExtensionFiles/FishjamScreenBroadcastExtension.entitlements +10 -0
  97. package/plugin/broadcastExtensionFiles/Info.plist +27 -0
  98. package/plugin/build/types.d.ts +9 -0
  99. package/plugin/build/types.js +2 -0
  100. package/plugin/build/withFishjam.d.ts +4 -0
  101. package/plugin/build/withFishjam.js +13 -0
  102. package/plugin/build/withFishjamAndroid.d.ts +3 -0
  103. package/plugin/build/withFishjamAndroid.js +32 -0
  104. package/plugin/build/withFishjamIos.d.ts +9 -0
  105. package/plugin/build/withFishjamIos.js +222 -0
@@ -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 = '2.1'
5
+ def packageVersion = '0.2.3'
6
6
 
7
7
  group = 'io.fishjam.reactnative'
8
8
  version = "${packageVersion}"
@@ -0,0 +1,2 @@
1
+ <manifest>
2
+ </manifest>
@@ -0,0 +1,34 @@
1
+ package io.fishjam.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 io.fishjam.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,15 @@
1
+ package io.fishjam.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
+ const val Warning = "Warning"
15
+ }
@@ -0,0 +1,31 @@
1
+ package io.fishjam.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")
@@ -0,0 +1,90 @@
1
+ package io.fishjam.reactnative
2
+
3
+ import android.app.Notification
4
+ import android.app.NotificationChannel
5
+ import android.app.NotificationManager
6
+ import android.app.PendingIntent
7
+ import android.app.Service
8
+ import android.content.Intent
9
+ import android.os.Build
10
+ import android.os.IBinder
11
+ import androidx.core.app.NotificationCompat
12
+
13
+ class FishjamForegroundService : Service() {
14
+ companion object {
15
+ private const val FOREGROUND_SERVICE_ID = 1668
16
+ }
17
+
18
+ override fun onBind(p0: Intent?): IBinder? = null
19
+
20
+ override fun onStartCommand(
21
+ intent: Intent?,
22
+ flags: Int,
23
+ startId: Int
24
+ ): Int {
25
+ val channelId = intent!!.getStringExtra("channelId")!!
26
+ val channelName = intent.getStringExtra("channelName")!!
27
+ val notificationTitle = intent.getStringExtra("notificationTitle")!!
28
+ val notificationContent = intent.getStringExtra("notificationContent")!!
29
+ val foregroundServiceTypesArray = intent.getIntArrayExtra("foregroundServiceTypes")!!
30
+ // Create "bitwise or" of foregroundServiceTypesArray
31
+ val foregroundServiceType = foregroundServiceTypesArray.reduce { acc, value -> acc or value }
32
+
33
+ val pendingIntent =
34
+ PendingIntent.getActivity(
35
+ this,
36
+ 0,
37
+ intent,
38
+ PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_MUTABLE
39
+ )
40
+
41
+ val notification: Notification =
42
+ NotificationCompat
43
+ .Builder(this, channelId)
44
+ .setContentTitle(notificationTitle)
45
+ .setContentText(notificationContent)
46
+ .setContentIntent(pendingIntent)
47
+ .build()
48
+
49
+ createNotificationChannel(channelId, channelName)
50
+ startForegroundWithNotification(notification, foregroundServiceType)
51
+
52
+ return START_NOT_STICKY
53
+ }
54
+
55
+ private fun startForegroundWithNotification(
56
+ notification: Notification,
57
+ foregroundServiceType: Int
58
+ ) {
59
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
60
+ startForeground(
61
+ FOREGROUND_SERVICE_ID,
62
+ notification,
63
+ foregroundServiceType
64
+ )
65
+ } else {
66
+ startForeground(
67
+ FOREGROUND_SERVICE_ID,
68
+ notification
69
+ )
70
+ }
71
+ }
72
+
73
+ private fun createNotificationChannel(
74
+ channelId: String,
75
+ channelName: String
76
+ ) {
77
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
78
+ return
79
+ }
80
+
81
+ val serviceChannel =
82
+ NotificationChannel(
83
+ channelId,
84
+ channelName,
85
+ NotificationManager.IMPORTANCE_DEFAULT
86
+ )
87
+ val notificationManager = getSystemService(NOTIFICATION_SERVICE) as? NotificationManager
88
+ notificationManager?.createNotificationChannel(serviceChannel)
89
+ }
90
+ }