omikit-plugin 1.0.0 → 2.0.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.
Files changed (47) hide show
  1. package/README.md +296 -66
  2. package/android/build.gradle +1 -1
  3. package/android/src/main/java/com/omikitplugin/FLLocalCameraModule.kt +37 -0
  4. package/android/src/main/java/com/omikitplugin/FLLocalCameraView.kt +23 -0
  5. package/android/src/main/java/com/omikitplugin/FLRemoteCameraModule.kt +37 -0
  6. package/android/src/main/java/com/omikitplugin/FLRemoteCameraView.kt +23 -0
  7. package/android/src/main/java/com/omikitplugin/OmikitPluginModule.kt +249 -85
  8. package/android/src/main/java/com/omikitplugin/OmikitPluginPackage.kt +21 -2
  9. package/android/src/main/java/com/omikitplugin/constants/constant.kt +23 -12
  10. package/ios/CallProcess/CallManager.swift +109 -71
  11. package/ios/Constant/Constant.swift +15 -10
  12. package/ios/OmikitPlugin.m +34 -2
  13. package/ios/OmikitPlugin.swift +69 -32
  14. package/ios/VideoCall/FLLocalCameraView.m +17 -0
  15. package/ios/VideoCall/FLLocalCameraView.swift +41 -80
  16. package/ios/VideoCall/FLRemoteCameraView.m +18 -0
  17. package/ios/VideoCall/FLRemoteCameraView.swift +39 -1
  18. package/lib/commonjs/index.js +32 -64
  19. package/lib/commonjs/index.js.map +1 -1
  20. package/lib/commonjs/omi_local_camera.js +15 -0
  21. package/lib/commonjs/omi_local_camera.js.map +1 -0
  22. package/lib/commonjs/omi_remote_camera.js +15 -0
  23. package/lib/commonjs/omi_remote_camera.js.map +1 -0
  24. package/lib/commonjs/omikit.js +98 -0
  25. package/lib/commonjs/omikit.js.map +1 -0
  26. package/lib/module/index.js +3 -51
  27. package/lib/module/index.js.map +1 -1
  28. package/lib/module/omi_local_camera.js +7 -0
  29. package/lib/module/omi_local_camera.js.map +1 -0
  30. package/lib/module/omi_remote_camera.js +7 -0
  31. package/lib/module/omi_remote_camera.js.map +1 -0
  32. package/lib/module/omikit.js +73 -0
  33. package/lib/module/omikit.js.map +1 -0
  34. package/lib/typescript/index.d.ts +3 -19
  35. package/lib/typescript/index.d.ts.map +1 -1
  36. package/lib/typescript/omi_local_camera.d.ts +5 -0
  37. package/lib/typescript/omi_local_camera.d.ts.map +1 -0
  38. package/lib/typescript/omi_remote_camera.d.ts +5 -0
  39. package/lib/typescript/omi_remote_camera.d.ts.map +1 -0
  40. package/lib/typescript/omikit.d.ts +26 -0
  41. package/lib/typescript/omikit.d.ts.map +1 -0
  42. package/omikit-plugin.podspec +1 -1
  43. package/package.json +1 -1
  44. package/src/index.tsx +3 -71
  45. package/src/omi_local_camera.tsx +11 -0
  46. package/src/omi_remote_camera.tsx +11 -0
  47. package/src/omikit.tsx +98 -0
package/README.md CHANGED
@@ -11,20 +11,20 @@ The most important part of the framework is :
11
11
 
12
12
  ## Status
13
13
 
14
- Currently active maintained
14
+ Currently active maintainance and improve performance
15
15
 
16
16
  ## Running
17
17
 
18
18
  Install via npm:
19
19
 
20
20
  ```sh
21
- npm install omikit-plugin
21
+ npm install omikit-plugin@latest
22
22
  ```
23
23
 
24
24
  Install via yarn:
25
25
 
26
26
  ```sh
27
- yarn add omikit-plugin
27
+ yarn add omikit-plugin --latest
28
28
  ```
29
29
 
30
30
  ### Configuration
@@ -32,67 +32,154 @@ yarn add omikit-plugin
32
32
  #### Android:
33
33
 
34
34
  - Add this setting in `build.gradle`:
35
-
36
35
  ```
37
- jcenter() // Warning: this repository is going to shut down soon
36
+ jcenter()
38
37
  maven {
39
- url("https://vihat.jfrog.io/artifactory/vihat-local-repo")
38
+ url("https://vihatgroup.jfrog.io/artifactory/omi-voice/")
40
39
  credentials {
41
- username = "anonymous"
40
+ username = "downloader"
41
+ password = "Omi@2022"
42
42
  }
43
43
  }
44
44
  ```
45
-
46
45
  ```
47
- classpath 'com.google.gms:google-services:4.3.13' //in dependencies
46
+ //in dependencies
47
+ classpath 'com.google.gms:google-services:4.3.13'
48
+ ```
49
+ ```
50
+ //under buildscript
51
+ allprojects {
52
+ repositories {
53
+ maven {
54
+ // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
55
+ url("$rootDir/../node_modules/react-native/android")
56
+ }
57
+ maven {
58
+ // Android JSC is installed from npm
59
+ url("$rootDir/../node_modules/jsc-android/dist")
60
+ }
61
+ mavenCentral {
62
+ // We don't want to fetch react-native from Maven Central as there are
63
+ // older versions over there.
64
+ content {
65
+ excludeGroup "com.facebook.react"
66
+ }
67
+ }
68
+ google()
69
+ maven { url 'https://www.jitpack.io' }
70
+ maven {
71
+ url("https://vihatgroup.jfrog.io/artifactory/omi-voice/")
72
+ credentials {
73
+ username = "downloader"
74
+ password = "Omi@2022"
75
+ }
76
+ }
77
+ }
78
+ }
48
79
  ```
49
80
 
50
- - Add this setting In `app/build.gradle`:
81
+ You can refer <a href="https://github.com/VIHATTeam/OMICALL-React-Native-SDK/blob/main/example/android/build.gradle">android/build.gradle</a> to know more informations.
51
82
 
83
+ - Add this setting In `app/build.gradle`:
52
84
  ```
53
85
  apply plugin: 'com.android.application'
54
86
  apply plugin: 'kotlin-android'
55
87
  apply plugin: 'com.google.gms.google-services'
56
88
  ```
57
89
 
58
- Push Notification:
90
+ You can refer <a href="https://github.com/VIHATTeam/OMICALL-React-Native-SDK/blob/main/example/android/app/build.gradle">android/app/build.gradle</a> to know more informations.
59
91
 
60
- - Add `google-service.json` in `android/app` (For more information, you can refer <a href="https://rnfirebase.io/">Firebase core</a>)
92
+ - Update AndroidManifest.xml:
93
+ ```
94
+ //need request this permission
95
+ <uses-permission android:name="android.permission.INTERNET" />
96
+ //add this lines inside <activity>
97
+ <intent-filter>
98
+ <action android:name="com.omicall.sdk.CallingActivity"/>
99
+ <category android:name="android.intent.category.DEFAULT" />
100
+ </intent-filter>
101
+ //add this lines outside <activity>
102
+ <service
103
+ android:name="vn.vihat.omicall.omisdk.service.FMService"
104
+ android:exported="false">
105
+ <intent-filter>
106
+ <action android:name="com.google.firebase.MESSAGING_EVENT" />
107
+ </intent-filter>
108
+ </service>
109
+ ```
61
110
 
62
- - For more setting information, please refer <a href="https://api.omicall.com/web-sdk/mobile-sdk/android-sdk/cau-hinh-push-notification">Omicall Config Push for Android</a>
111
+ You can refer <a href="https://github.com/VIHATTeam/OMICALL-React-Native-SDK/blob/main/example/android/app/src/main/AndroidManifest.xml">AndroidManifest</a> to know more informations.
63
112
 
64
- #### iOS: Set up environment and library:
113
+ - We registered permissions into my plugin:
114
+ ```
115
+ <uses-permission android:name="android.permission.BROADCAST_CLOSE_SYSTEM_DIALOGS"
116
+ tools:ignore="ProtectedPermissions" />
117
+ <uses-permission android:name="android.permission.INTERNET" />
118
+ <uses-permission android:name="android.permission.USE_SIP" />
119
+ <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
120
+ <uses-permission android:name="android.permission.WAKE_LOCK" />
121
+ <uses-permission android:name="android.permission.CAMERA" />
122
+ <uses-permission android:name="android.permission.RECORD_AUDIO" />
123
+ <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
124
+ <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
125
+ <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
126
+ <uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" />
127
+ <uses-permission android:name="android.permission.WAKE_LOCK"/>
128
+ <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
129
+ <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
130
+ <uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
131
+ ```
65
132
 
66
- - AppDelete.h
133
+ - Setup push notification: We only support Firebase for push notification.
134
+ - Add `google-service.json` in `android/app` (For more information, you can refer <a href="https://rnfirebase.io/app/usage">Core/App</a>)
135
+ - Add Fire Messaging to receive `fcm_token` (You can refer <a href="https://pub.dev/packages/firebase_messaging">Cloud Messaging</a> to setup notification for Flutter)
67
136
 
68
- ```
69
- #import <OmiKit/OmiKit-umbrella.h>
70
- #import <UserNotifications/UserNotifications.h>
137
+ - For more setting information, please refer <a href="https://rnfirebase.io/messaging/usage">Config Push for Android</a>
138
+
139
+ #### iOS:
140
+ ----
71
141
 
72
- @interface AppDelegate : UIResponder <UIApplicationDelegate, RCTBridgeDelegate>
142
+ We support both Object-C and Swift. But we only support documents for Object-C. We will write for Swift language later. Thank you.
73
143
 
74
- @property (nonatomic, strong) UIWindow *window;
75
- @property (nonatomic, strong) PushKitManager *pushkitManager;
76
- @property (nonatomic, strong) CallKitProviderDelegate * provider;
77
- @property (nonatomic, strong) PKPushRegistry * voipRegistry;
144
+ ---
78
145
 
79
- @end
146
+ - Add variables in Appdelegate.h:
80
147
 
81
148
  ```
149
+ #import <UIKit/UIKit.h>
150
+ #import <UserNotifications/UserNotifications.h>
151
+ #import <OmiKit/OmiKit-umbrella.h>
152
+ #import <OmiKit/Constants.h>
153
+ #import <UserNotifications/UserNotifications.h>
82
154
 
83
- - AppDelete.m
155
+ PushKitManager *pushkitManager;
156
+ CallKitProviderDelegate * provider;
157
+ PKPushRegistry * voipRegistry;
158
+ ```
159
+
160
+ - Edit AppDelegate.m:
84
161
 
85
162
  ```
86
163
  #import <OmiKit/OmiKit.h>
164
+ #import <omicall_flutter_plugin/omicall_flutter_plugin-Swift.h>
87
165
 
88
166
  [OmiClient setEnviroment:KEY_OMI_APP_ENVIROMENT_SANDBOX];
89
- self.provider = [[CallKitProviderDelegate alloc] initWithCallManager: [OMISIPLib sharedInstance].callManager];
90
- self.voipRegistry = [[PKPushRegistry alloc] initWithQueue:dispatch_get_main_queue()];
91
- self.pushkitManager = [[PushKitManager alloc] initWithVoipRegistry: self.voipRegistry];
92
- //Add into `didFinishLaunchingWithOptions` function
167
+ provider = [[CallKitProviderDelegate alloc] initWithCallManager: [OMISIPLib sharedInstance].callManager];
168
+ voipRegistry = [[PKPushRegistry alloc] initWithQueue:dispatch_get_main_queue()];
169
+ pushkitManager = [[PushKitManager alloc] initWithVoipRegistry:voipRegistry];
170
+ ```
171
+
172
+ - Add this lines into `Info.plist`:
173
+
174
+ ```
175
+ <key>NSMicrophoneUsageDescription</key>
176
+ <string>Need microphone access for make Call</string>
177
+ //If you implement video call
178
+ <key>NSCameraUsageDescription</key>
179
+ <string>Need camera access for video call functions</string>
93
180
  ```
94
181
 
95
- - Save token for `OmiClient`, if you don't use `Messaging` for iOS:
182
+ - Save token for `OmiClient`: You use `Cloud Messaging` into your project so you don't need add this lines.
96
183
 
97
184
  ```
98
185
  - (void)application:(UIApplication*)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)devToken
@@ -104,62 +191,205 @@ self.pushkitManager = [[PushKitManager alloc] initWithVoipRegistry: self.voipReg
104
191
  {
105
192
  [token appendFormat:@"%02.2hhX", data[i]];
106
193
  }
107
-
194
+
108
195
  // print the token in the console.
109
196
  NSLog(@"Push Notification Token: %@", [token copy]);
110
197
  [OmiClient setUserPushNotificationToken:[token copy]];
111
198
  }
112
199
 
113
200
  ```
201
+ *** Only use under lines when add `Cloud Messaging` plugin ***
202
+ - Setup push notification: We only support Firebase for push notification.
203
+ - Add `google-service.json` in `android/app` (For more information, you can refer <a href="https://rnfirebase.io/app/usage">Core/App</a>)
204
+ - Add Firebase Messaging to receive `fcm_token` (You can refer <a href="https://pub.dev/packages/firebase_messaging">Cloud Messaging</a> to setup notification for React Native)
114
205
 
115
- Push Notification:
116
- Omicall need two certificates: VOIP Push Certificate & User Push Notification Certificate
117
-
118
- - For more information, please refer <a href="https://api.omicall.com/web-sdk/mobile-sdk/ios-sdk/cau-hinh-push-notification">Omicall Push Notification for iOS</a>
206
+ - For more setting information, please refer <a href="https://api.omicall.com/web-sdk/mobile-sdk/ios-sdk/cau-hinh-push-notification">Config Push for iOS</a>
119
207
 
120
208
  ## Implement
121
209
 
122
- - Set up Firebase Messaging: <a href="https://rnfirebase.io/messaging/usage">messaging</a> plugin.
210
+ - Set up <a href="https://rnfirebase.io/messaging/usage">Cloud Messaging</a> plugin:
123
211
 
124
212
  ```
125
213
  //if you use only on Android. you only implement for Android.
126
214
  //because we use APNS to push notification on iOS so you don't need add Firebase for iOS.
127
215
  //But you can use firebase-messaging to get APNS token for iOS.
128
216
  ```
129
-
130
- - Call actions:
131
-
132
- * `initCall` : register and init OmiCall. You need send Object value with `userName`, `password` and `realm`.
133
- * `updateToken` : update token for sdk. You need send `fcmToken` for Android and send `apnsToken` for iOS.
134
- * `startCall` : start Call.
135
- * `endCall` : end Call.
136
- * `toggleMute` : toggle the microphone status.
137
- * `toggleSpeaker` : toggle the voice status. You need send Object value with `useSpeaker`.
138
- * `sendDTMF` : send DTMF for call server. You need send Object value with `character` value.
139
-
140
- * Event listener:
141
-
217
+ - Important function.
218
+ - Start Serivce: OmiKit need start services and register some events.
219
+ ```
220
+ //Call in the root widget
221
+ import { startServices } from 'omikit-plugin';
222
+
223
+ startServices();
224
+ ```
225
+ - Create OmiKit With ApiKey: OmiKit need apikey, username, user id to init enviroment. ViHAT Group will provide api key for you. Please contact for my sale:
226
+ ```
227
+ import { initCallWithApiKey } from 'omikit-plugin';
228
+
229
+ const loginInfo = {
230
+ usrUuid: usrUuid,
231
+ fullName: fullName,
232
+ apiKey: apiKey,
233
+ isVideo: isVideo,
234
+ };
235
+ console.log(loginInfo);
236
+ const result = await initCallWithApiKey(loginInfo);
237
+ //result is true then user login successfully.
238
+ ```
239
+ - Create OmiKit: OmiKit need userName, password, realm, host to init enviroment. ViHAT Group will provide informations for you. Please contact for my sale:
240
+ ```
241
+ import { initCall } from 'omikit-plugin';
242
+
243
+ const loginInfo = {
244
+ userName: userName, //string
245
+ password: password, //string
246
+ realm: realm, //string
247
+ isVideo: isVideo, //boolean: true/false
248
+ host: host, //string
249
+ };
250
+ const result = await initCall(loginInfo);
251
+ //result is true then user login successfully.
252
+ ```
253
+ - Config push notification for Android:
254
+ ```
255
+ import { configPushNotification } from 'omikit-plugin';
256
+
257
+ configPushNotification({
258
+ prefix: 'Cuộc gọi tới từ: ',
259
+ declineTitle: 'Từ chối',
260
+ acceptTitle: 'Chấp nhận',
261
+ acceptBackgroundColor: '#FF3700B3',
262
+ declineBackgroundColor: '#FF000000',
263
+ incomingBackgroundColor: '#FFFFFFFF',
264
+ incomingAcceptButtonImage: 'join_call',
265
+ incomingDeclineButtonImage: 'hangup',
266
+ backImage: 'ic_back',
267
+ userImage: 'calling_face',
268
+ });
269
+ //incomingAcceptButtonImage, incomingDeclineButtonImage, backImage, userImage: Add these into `android/app/src/main/res/drawble`
270
+ ```
271
+ - Get call when user open app from killed status(only iOS):
272
+ ```
273
+ import { getInitialCall } from 'omikit-plugin';
274
+
275
+ const callingInfo = await getInitialCall();
276
+ if (callingInfo !== false) {
277
+ navigation.navigate('DialCall' as never, callingInfo as never);
278
+ }
279
+ //callingInfo != false then user have a calling.
280
+ ```
281
+ - Upload token: OmiKit need FCM for Android and APNS to push notification on user devices. We use more packages: <a href="https://rnfirebase.io/messaging/usage">Cloud Messaging</a> and <a href="https://www.npmjs.com/package/react-native-device-info?activeTab=readme">react-native-device-info</a>
282
+ ```
283
+ import { updateToken } from 'omikit-plugin';
284
+
285
+ const fcmToken = await fcm;
286
+ const apnsToken = await apns;
287
+ const deviceId = DeviceInfo.getDeviceId();
288
+ const appId = DeviceInfo.getBundleId();
289
+ updateToken({
290
+ apnsToken: apnsToken,
291
+ fcmToken: fcmToken,
292
+ deviceId: deviceId,
293
+ appId: appId,
294
+ });
295
+ ```
296
+ - Other functions:
297
+ - Call with phone number (mobile phone or internal number):
298
+ ```
299
+ import {startCall} from 'omikit-plugin';
300
+
301
+ const result = await startCall({
302
+ phoneNumber: phone, //phone number
303
+ isVideo: false //allow video call: true/false
304
+ });
305
+ ```
306
+ - Accept a call:
307
+ ```
308
+ import {joinCall} from 'omikit-plugin';
309
+
310
+ await joinCall();
311
+ ```
312
+ - End a call: We will push a event `endCall` for you.
313
+ ```
314
+ import {endCall} from 'omikit-plugin';
315
+
316
+ await endCall();
317
+ ```
318
+ - Toggle the audio: On/off audio a call
319
+ ```
320
+ import {toggleMute} from 'omikit-plugin';
321
+
322
+ toggleMute();
323
+ ```
324
+ - Toggle the speaker: On/off the phone speaker
325
+ ```
326
+ import {toggleSpeaker} from 'omikit-plugin';
327
+
328
+ toggleSpeaker();
329
+ ```
330
+ - Send character: We only support `1 to 9` and `* #`.
331
+ ```
332
+ import {sendDTMF} from 'omikit-plugin';
333
+
334
+ sendDTMF({
335
+ character: text,
336
+ });
337
+ ```
338
+
339
+ - Video Call functions: Support only video call, You need enable video in `init functions` and `start call` to implements under functions.
340
+ - Switch front/back camera: We use the front camera for first time.
341
+ ```
342
+ import {switchOmiCamera} from 'omikit-plugin';
343
+ switchOmiCamera();
344
+ ```
345
+ - Toggle a video in video call: On/off video in video call
346
+ ```
347
+ import {toggleOmiVideo} from 'omikit-plugin';
348
+ toggleOmiVideo();
349
+ ```
350
+ - Local Camera Widget: Your camera view in a call
351
+ ```
352
+ import { OmiLocalCameraView } from 'omikit-plugin';
353
+ <OmiLocalCameraView style={styles.localCamera} />
354
+ ```
355
+ - Remote Camera Widget: Remote camera view in a call
356
+ ```
357
+ import { OmiRemoteCameraView } from 'omikit-plugin';
358
+ <OmiRemoteCameraView style={styles.remoteCamera} />
359
+ ```
360
+ - More function: Refresh local camera
361
+ ```
362
+ import {refreshLocalCamera} from 'omikit-plugin';
363
+ refreshLocalCamera();
364
+ ```
365
+ - More function: Refresh remote camera
366
+ ```
367
+ import {refreshRemoteCamera} from 'omikit-plugin';
368
+ refreshRemoteCamera();
369
+ ```
370
+
371
+
372
+ - Event listener:
142
373
  ```
143
374
  useEffect(() => {
144
- omiEmitter.addListener('incomingReceived', incomingReceived);
145
- omiEmitter.addListener('onCallEstablished', onCallEstablished);
146
- omiEmitter.addListener('onCallEnd', onCallEnd);
147
- omiEmitter.addListener('onMuted', onMuted);
148
- omiEmitter.addListener('onRinging', onRinging);
375
+ omiEmitter.addListener(OmiCallEvent.incomingReceived, incomingReceived);
376
+ omiEmitter.addListener(OmiCallEvent.onCallEstablished, onCallEstablished);
377
+ omiEmitter.addListener(OmiCallEvent.onCallEnd, onCallEnd);
378
+ omiEmitter.addListener(OmiCallEvent.onMuted, onMuted);
379
+ omiEmitter.addListener(OmiCallEvent.onSpeaker, onSpeaker);
149
380
  return () => {
150
- omiEmitter.removeAllListeners('incomingReceived');
381
+ omiEmitter.removeAllListeners(OmiCallEvent.incomingReceived);
151
382
  omiEmitter.removeAllListeners('onCallEstablished');
152
- omiEmitter.removeAllListeners('onCallEnd');
153
- omiEmitter.removeAllListeners('onMuted');
154
- omiEmitter.removeAllListeners('onRinging');
383
+ omiEmitter.removeAllListeners(OmiCallEvent.onCallEnd);
384
+ omiEmitter.removeAllListeners(OmiCallEvent.onMuted);
385
+ omiEmitter.removeAllListeners(OmiCallEvent.onSpeaker);
155
386
  };
156
387
  }, []);
157
-
158
388
  ```
159
-
160
- * Event List: `We support 5 events`
161
- * `onCallEnd`: Trigger when end the call.
162
- * `onCallEstablished`: Trigger when we created the call.
163
- * `onRinging`: Trigger when the phone is ringing.
164
- * `onHold`: Trigger when user hold the call. From parameters, you can reviceved correct status from server through `isHold`
165
- * `onMuted`: Trigger when user muted the call. From parameters, you can reviceved correct status from server through `isMuted`
389
+ - Action Name value:
390
+ - `OmiCallEvent.incomingReceived`: Have a incoming call. On Android this event work only foreground
391
+ - `OmiCallEvent.onCallEstablished`: Connected a call.
392
+ - `OmiCallEvent.onCallEnd`: End a call.
393
+ - `OmiCallEvent.onMuted`: Audio changed.
394
+ - `OmiCallEvent.onSpeaker`: Audio changed.
395
+ - Data value: We return `callerNumber`, `isVideo: true/false` information
@@ -96,7 +96,7 @@ dependencies {
96
96
  implementation "com.facebook.react:react-native:+" // From node_modules
97
97
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
98
98
 
99
- api 'vn.vihat.omicall:omi-sdk:1.0.10'
99
+ api 'vn.vihat.omicall:omi-sdk:1.0.51'
100
100
 
101
101
  implementation 'androidx.core:core-ktx:1.7.0'
102
102
  implementation 'androidx.fragment:fragment-ktx:1.4.0'
@@ -0,0 +1,37 @@
1
+ package com.omikitplugin
2
+
3
+ import android.view.Surface
4
+ import android.view.TextureView
5
+ import com.facebook.react.bridge.Promise
6
+ import com.facebook.react.bridge.ReactApplicationContext
7
+ import com.facebook.react.bridge.ReactContextBaseJavaModule
8
+ import com.facebook.react.bridge.ReactMethod
9
+ import vn.vihat.omicall.omisdk.OmiClient
10
+ import vn.vihat.omicall.omisdk.videoutils.ScaleManager
11
+ import vn.vihat.omicall.omisdk.videoutils.Size
12
+
13
+ class FLLocalCameraModule(reactContext: ReactApplicationContext, localViewManager: FLLocalCameraView) :
14
+ ReactContextBaseJavaModule(reactContext) {
15
+
16
+ var cameraView: TextureView
17
+
18
+ override fun getName(): String {
19
+ return "FLLocalCameraView"
20
+ }
21
+
22
+ init {
23
+ cameraView = localViewManager.localView
24
+ }
25
+
26
+ @ReactMethod
27
+ fun refresh(promise: Promise) {
28
+ cameraView.surfaceTexture?.let {
29
+ OmiClient.instance.setupLocalVideoFeed(Surface(it))
30
+ ScaleManager.adjustAspectRatio(cameraView,
31
+ Size(cameraView.width, cameraView.height),
32
+ Size(1280,720)
33
+ )
34
+ promise.resolve(true)
35
+ }
36
+ }
37
+ }
@@ -0,0 +1,23 @@
1
+ package com.omikitplugin
2
+
3
+ import android.view.TextureView
4
+ import com.facebook.react.bridge.ReactApplicationContext
5
+ import com.facebook.react.uimanager.SimpleViewManager
6
+ import com.facebook.react.uimanager.ThemedReactContext
7
+
8
+ class FLLocalCameraView(private val context: ReactApplicationContext) :
9
+ SimpleViewManager<TextureView>() {
10
+ val localView : TextureView = TextureView(context)
11
+
12
+ override fun getName(): String {
13
+ return "FLLocalCameraView"
14
+ }
15
+
16
+ override fun createViewInstance(p0: ThemedReactContext): TextureView {
17
+ return localView
18
+ }
19
+
20
+ fun localViewInstance(): TextureView {
21
+ return localView
22
+ }
23
+ }
@@ -0,0 +1,37 @@
1
+ package com.omikitplugin
2
+
3
+ import android.view.Surface
4
+ import android.view.TextureView
5
+ import com.facebook.react.bridge.Promise
6
+ import com.facebook.react.bridge.ReactApplicationContext
7
+ import com.facebook.react.bridge.ReactContextBaseJavaModule
8
+ import com.facebook.react.bridge.ReactMethod
9
+ import vn.vihat.omicall.omisdk.OmiClient
10
+ import vn.vihat.omicall.omisdk.videoutils.ScaleManager
11
+ import vn.vihat.omicall.omisdk.videoutils.Size
12
+
13
+ class FLRemoteCameraModule(reactContext: ReactApplicationContext, remoteViewManager: FLRemoteCameraView) :
14
+ ReactContextBaseJavaModule(reactContext) {
15
+
16
+ var cameraView: TextureView
17
+
18
+ override fun getName(): String {
19
+ return "FLRemoteCameraView"
20
+ }
21
+
22
+ init {
23
+ cameraView = remoteViewManager.remoteView
24
+ }
25
+
26
+ @ReactMethod
27
+ fun refresh(promise: Promise) {
28
+ cameraView.surfaceTexture?.let {
29
+ OmiClient.instance.setupIncomingVideoFeed(Surface(it))
30
+ ScaleManager.adjustAspectRatio(cameraView,
31
+ Size(cameraView.width, cameraView.height),
32
+ Size(1280,720)
33
+ )
34
+ promise.resolve(true)
35
+ }
36
+ }
37
+ }
@@ -0,0 +1,23 @@
1
+ package com.omikitplugin
2
+
3
+ import android.view.TextureView
4
+ import com.facebook.react.bridge.ReactApplicationContext
5
+ import com.facebook.react.uimanager.SimpleViewManager
6
+ import com.facebook.react.uimanager.ThemedReactContext
7
+
8
+ class FLRemoteCameraView(private val context: ReactApplicationContext) :
9
+ SimpleViewManager<TextureView>() {
10
+ val remoteView : TextureView = TextureView(context)
11
+
12
+ override fun getName(): String {
13
+ return "FLRemoteCameraView"
14
+ }
15
+
16
+ override fun createViewInstance(p0: ThemedReactContext): TextureView {
17
+ return remoteView
18
+ }
19
+
20
+ fun localViewInstance(): TextureView {
21
+ return remoteView
22
+ }
23
+ }