react-native-altibbi 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.
Files changed (150) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +190 -0
  3. package/android/build.gradle +104 -0
  4. package/android/gradle.properties +5 -0
  5. package/android/src/main/AndroidManifest.xml +3 -0
  6. package/android/src/main/AndroidManifestNew.xml +2 -0
  7. package/android/src/main/java/com/altibbi/AltibbiModule.kt +18 -0
  8. package/android/src/main/java/com/altibbi/AltibbiPackage.kt +18 -0
  9. package/android/src/main/java/com/altibbi/OTCustomAudioDevice.java +1146 -0
  10. package/android/src/main/java/com/altibbi/OTPublisherLayout.java +61 -0
  11. package/android/src/main/java/com/altibbi/OTPublisherViewManager.java +30 -0
  12. package/android/src/main/java/com/altibbi/OTRN.java +101 -0
  13. package/android/src/main/java/com/altibbi/OTScreenCapturer.java +120 -0
  14. package/android/src/main/java/com/altibbi/OTSessionManager.java +1281 -0
  15. package/android/src/main/java/com/altibbi/OTSubscriberLayout.java +68 -0
  16. package/android/src/main/java/com/altibbi/OTSubscriberViewManager.java +30 -0
  17. package/android/src/main/java/com/altibbi/Socket.kt +294 -0
  18. package/android/src/main/java/com/altibbi/SocketEventEmitter.kt +25 -0
  19. package/android/src/main/java/com/altibbi/utils/EventUtils.java +189 -0
  20. package/android/src/main/java/com/altibbi/utils/Utils.java +135 -0
  21. package/ios/Altibbi-Bridging-Header.h +6 -0
  22. package/ios/Altibbi.mm +10 -0
  23. package/ios/Altibbi.swift +4 -0
  24. package/ios/OTCustomAudioDriver.swift +696 -0
  25. package/ios/OTPublisher.m +16 -0
  26. package/ios/OTPublisherManager.swift +21 -0
  27. package/ios/OTPublisherView.swift +28 -0
  28. package/ios/OTRN.swift +27 -0
  29. package/ios/OTScreenCapture.h +27 -0
  30. package/ios/OTScreenCapture.m +171 -0
  31. package/ios/OTSessionManager.m +127 -0
  32. package/ios/OTSessionManager.swift +866 -0
  33. package/ios/OTSubscriber.m +15 -0
  34. package/ios/OTSubscriberManager.swift +21 -0
  35. package/ios/OTSubscriberView.swift +29 -0
  36. package/ios/OpenTokReactNative.h +13 -0
  37. package/ios/OpenTokReactNative.m +13 -0
  38. package/ios/SocketReactNative.m +38 -0
  39. package/ios/SocketReactNative.swift +276 -0
  40. package/ios/Utils/EventUtils.swift +143 -0
  41. package/ios/Utils/Utils.swift +126 -0
  42. package/lib/commonjs/connection.js +200 -0
  43. package/lib/commonjs/connection.js.map +1 -0
  44. package/lib/commonjs/data.js +12 -0
  45. package/lib/commonjs/data.js.map +1 -0
  46. package/lib/commonjs/index.js +275 -0
  47. package/lib/commonjs/index.js.map +1 -0
  48. package/lib/commonjs/scoket.js +245 -0
  49. package/lib/commonjs/scoket.js.map +1 -0
  50. package/lib/commonjs/service.js +21 -0
  51. package/lib/commonjs/service.js.map +1 -0
  52. package/lib/commonjs/types.js +2 -0
  53. package/lib/commonjs/types.js.map +1 -0
  54. package/lib/commonjs/video/OT.js +57 -0
  55. package/lib/commonjs/video/OT.js.map +1 -0
  56. package/lib/commonjs/video/OTError.js +17 -0
  57. package/lib/commonjs/video/OTError.js.map +1 -0
  58. package/lib/commonjs/video/OTPublisher.js +171 -0
  59. package/lib/commonjs/video/OTPublisher.js.map +1 -0
  60. package/lib/commonjs/video/OTSession.js +205 -0
  61. package/lib/commonjs/video/OTSession.js.map +1 -0
  62. package/lib/commonjs/video/OTSubscriber.js +185 -0
  63. package/lib/commonjs/video/OTSubscriber.js.map +1 -0
  64. package/lib/commonjs/video/contexts/OTContext.js +11 -0
  65. package/lib/commonjs/video/contexts/OTContext.js.map +1 -0
  66. package/lib/commonjs/video/helpers/OTHelper.js +92 -0
  67. package/lib/commonjs/video/helpers/OTHelper.js.map +1 -0
  68. package/lib/commonjs/video/helpers/OTPublisherHelper.js +117 -0
  69. package/lib/commonjs/video/helpers/OTPublisherHelper.js.map +1 -0
  70. package/lib/commonjs/video/helpers/OTSessionHelper.js +206 -0
  71. package/lib/commonjs/video/helpers/OTSessionHelper.js.map +1 -0
  72. package/lib/commonjs/video/helpers/OTSubscriberHelper.js +121 -0
  73. package/lib/commonjs/video/helpers/OTSubscriberHelper.js.map +1 -0
  74. package/lib/commonjs/video/index.js +42 -0
  75. package/lib/commonjs/video/index.js.map +1 -0
  76. package/lib/commonjs/video/views/OTPublisherView.js +26 -0
  77. package/lib/commonjs/video/views/OTPublisherView.js.map +1 -0
  78. package/lib/commonjs/video/views/OTSubscriberView.js +25 -0
  79. package/lib/commonjs/video/views/OTSubscriberView.js.map +1 -0
  80. package/lib/module/connection.js +180 -0
  81. package/lib/module/connection.js.map +1 -0
  82. package/lib/module/data.js +6 -0
  83. package/lib/module/data.js.map +1 -0
  84. package/lib/module/index.js +12 -0
  85. package/lib/module/index.js.map +1 -0
  86. package/lib/module/scoket.js +235 -0
  87. package/lib/module/scoket.js.map +1 -0
  88. package/lib/module/service.js +14 -0
  89. package/lib/module/service.js.map +1 -0
  90. package/lib/module/types.js +2 -0
  91. package/lib/module/types.js.map +1 -0
  92. package/lib/module/video/OT.js +49 -0
  93. package/lib/module/video/OT.js.map +1 -0
  94. package/lib/module/video/OTError.js +10 -0
  95. package/lib/module/video/OTError.js.map +1 -0
  96. package/lib/module/video/OTPublisher.js +162 -0
  97. package/lib/module/video/OTPublisher.js.map +1 -0
  98. package/lib/module/video/OTSession.js +195 -0
  99. package/lib/module/video/OTSession.js.map +1 -0
  100. package/lib/module/video/OTSubscriber.js +175 -0
  101. package/lib/module/video/OTSubscriber.js.map +1 -0
  102. package/lib/module/video/contexts/OTContext.js +4 -0
  103. package/lib/module/video/contexts/OTContext.js.map +1 -0
  104. package/lib/module/video/helpers/OTHelper.js +82 -0
  105. package/lib/module/video/helpers/OTHelper.js.map +1 -0
  106. package/lib/module/video/helpers/OTPublisherHelper.js +110 -0
  107. package/lib/module/video/helpers/OTPublisherHelper.js.map +1 -0
  108. package/lib/module/video/helpers/OTSessionHelper.js +195 -0
  109. package/lib/module/video/helpers/OTSessionHelper.js.map +1 -0
  110. package/lib/module/video/helpers/OTSubscriberHelper.js +112 -0
  111. package/lib/module/video/helpers/OTSubscriberHelper.js.map +1 -0
  112. package/lib/module/video/index.js +7 -0
  113. package/lib/module/video/index.js.map +1 -0
  114. package/lib/module/video/views/OTPublisherView.js +18 -0
  115. package/lib/module/video/views/OTPublisherView.js.map +1 -0
  116. package/lib/module/video/views/OTSubscriberView.js +17 -0
  117. package/lib/module/video/views/OTSubscriberView.js.map +1 -0
  118. package/lib/typescript/src/connection.d.ts +40 -0
  119. package/lib/typescript/src/connection.d.ts.map +1 -0
  120. package/lib/typescript/src/data.d.ts +7 -0
  121. package/lib/typescript/src/data.d.ts.map +1 -0
  122. package/lib/typescript/src/index.d.ts +12 -0
  123. package/lib/typescript/src/index.d.ts.map +1 -0
  124. package/lib/typescript/src/scoket.d.ts +100 -0
  125. package/lib/typescript/src/scoket.d.ts.map +1 -0
  126. package/lib/typescript/src/service.d.ts +9 -0
  127. package/lib/typescript/src/service.d.ts.map +1 -0
  128. package/lib/typescript/src/types.d.ts +22 -0
  129. package/lib/typescript/src/types.d.ts.map +1 -0
  130. package/package.json +178 -0
  131. package/react-native-altibbi.podspec +46 -0
  132. package/src/connection.ts +255 -0
  133. package/src/data.ts +21 -0
  134. package/src/index.tsx +80 -0
  135. package/src/scoket.ts +365 -0
  136. package/src/service.ts +20 -0
  137. package/src/types.ts +22 -0
  138. package/src/video/OT.js +65 -0
  139. package/src/video/OTError.js +14 -0
  140. package/src/video/OTPublisher.js +193 -0
  141. package/src/video/OTSession.js +168 -0
  142. package/src/video/OTSubscriber.js +148 -0
  143. package/src/video/contexts/OTContext.js +5 -0
  144. package/src/video/helpers/OTHelper.js +91 -0
  145. package/src/video/helpers/OTPublisherHelper.js +122 -0
  146. package/src/video/helpers/OTSessionHelper.js +233 -0
  147. package/src/video/helpers/OTSubscriberHelper.js +125 -0
  148. package/src/video/index.js +13 -0
  149. package/src/video/views/OTPublisherView.js +19 -0
  150. package/src/video/views/OTSubscriberView.js +18 -0
@@ -0,0 +1,61 @@
1
+ package com.altibbi;
2
+
3
+ import android.opengl.GLSurfaceView;
4
+ import android.widget.FrameLayout;
5
+
6
+ import com.facebook.react.uimanager.ThemedReactContext;
7
+ import com.opentok.android.BaseVideoRenderer;
8
+ import com.opentok.android.Publisher;
9
+
10
+ import java.util.concurrent.ConcurrentHashMap;
11
+
12
+
13
+
14
+ public class OTPublisherLayout extends FrameLayout{
15
+
16
+ public OTRN sharedState;
17
+
18
+ public OTPublisherLayout(ThemedReactContext reactContext) {
19
+
20
+ super(reactContext);
21
+ sharedState = OTRN.getSharedState();
22
+ }
23
+
24
+ public void createPublisherView(String publisherId) {
25
+
26
+ ConcurrentHashMap<String, Publisher> mPublishers = sharedState.getPublishers();
27
+ ConcurrentHashMap<String, String> androidOnTopMap = sharedState.getAndroidOnTopMap();
28
+ ConcurrentHashMap<String, String> androidZOrderMap = sharedState.getAndroidZOrderMap();
29
+ String pubOrSub = "";
30
+ String zOrder = "";
31
+ Publisher mPublisher = mPublishers.get(publisherId);
32
+ if (mPublisher != null) {
33
+ String sessionId = mPublisher.getSession().getSessionId();
34
+ if (sessionId != null) {
35
+ if (androidOnTopMap.get(sessionId) != null) {
36
+ pubOrSub = androidOnTopMap.get(sessionId);
37
+ }
38
+ if (androidZOrderMap.get(sessionId) != null) {
39
+ zOrder = androidZOrderMap.get(sessionId);
40
+ }
41
+ }
42
+ mPublisher.setStyle(BaseVideoRenderer.STYLE_VIDEO_SCALE,
43
+ BaseVideoRenderer.STYLE_VIDEO_FILL);
44
+ FrameLayout mPublisherViewContainer = new FrameLayout(getContext());
45
+ if (pubOrSub.equals("publisher") && mPublisher.getView() instanceof GLSurfaceView) {
46
+ if (zOrder.equals("mediaOverlay")) {
47
+ ((GLSurfaceView) mPublisher.getView()).setZOrderMediaOverlay(true);
48
+ } else {
49
+ ((GLSurfaceView) mPublisher.getView()).setZOrderOnTop(true);
50
+ }
51
+ }
52
+ ConcurrentHashMap<String, FrameLayout> mPublisherViewContainers = sharedState.getPublisherViewContainers();
53
+ mPublisherViewContainers.put(publisherId, mPublisherViewContainer);
54
+ addView(mPublisherViewContainer, 0);
55
+ mPublisherViewContainer.addView(mPublisher.getView());
56
+ requestLayout();
57
+ }
58
+
59
+ }
60
+
61
+ }
@@ -0,0 +1,30 @@
1
+ package com.altibbi;
2
+
3
+
4
+
5
+ import com.facebook.react.uimanager.ThemedReactContext;
6
+ import com.facebook.react.uimanager.ViewGroupManager;
7
+ import com.facebook.react.uimanager.annotations.ReactProp;
8
+
9
+
10
+ public class OTPublisherViewManager extends ViewGroupManager<OTPublisherLayout> {
11
+
12
+ @Override
13
+ public String getName() {
14
+
15
+ return this.getClass().getSimpleName();
16
+ }
17
+
18
+ @Override
19
+ protected OTPublisherLayout createViewInstance(ThemedReactContext reactContext) {
20
+
21
+ return new OTPublisherLayout(reactContext);
22
+ }
23
+
24
+ @ReactProp(name = "publisherId")
25
+ public void setPublisherId(OTPublisherLayout view, String publisherId) {
26
+
27
+ view.createPublisherView(publisherId);
28
+ }
29
+
30
+ }
@@ -0,0 +1,101 @@
1
+ package com.altibbi;
2
+
3
+ import android.widget.FrameLayout;
4
+
5
+ import com.facebook.react.bridge.Callback;
6
+ import com.opentok.android.Connection;
7
+ import com.opentok.android.Publisher;
8
+ import com.opentok.android.Session;
9
+ import com.opentok.android.Stream;
10
+ import com.opentok.android.Subscriber;
11
+
12
+ import java.util.concurrent.ConcurrentHashMap;
13
+
14
+
15
+ public class OTRN {
16
+
17
+ public static OTRN sharedState;
18
+
19
+ private ConcurrentHashMap<String, Stream> subscriberStreams = new ConcurrentHashMap<>();
20
+ private ConcurrentHashMap<String, Subscriber> subscribers = new ConcurrentHashMap<>();
21
+ private ConcurrentHashMap<String, Publisher> publishers = new ConcurrentHashMap<>();
22
+ private ConcurrentHashMap<String, Session> sessions = new ConcurrentHashMap<>();
23
+ private ConcurrentHashMap<String, String> androidOnTopMap = new ConcurrentHashMap<>();
24
+ private ConcurrentHashMap<String, String> androidZOrderMap = new ConcurrentHashMap<>();
25
+ private ConcurrentHashMap<String, FrameLayout> subscriberViewContainers = new ConcurrentHashMap<>();
26
+ private ConcurrentHashMap<String, FrameLayout> publisherViewContainers = new ConcurrentHashMap<>();
27
+ private ConcurrentHashMap<String, Callback> publisherDestroyedCallbacks = new ConcurrentHashMap<>();
28
+ private ConcurrentHashMap<String, Callback> sessionConnectCallbacks = new ConcurrentHashMap<>();
29
+ private ConcurrentHashMap<String, Callback> sessionDisconnectCallbacks = new ConcurrentHashMap<>();
30
+ private ConcurrentHashMap<String, Connection> connections = new ConcurrentHashMap<>();
31
+
32
+ public static synchronized OTRN getSharedState() {
33
+
34
+ if (sharedState == null) {
35
+ sharedState = new OTRN();
36
+ }
37
+ return sharedState;
38
+ }
39
+
40
+ public ConcurrentHashMap<String, String> getAndroidOnTopMap() {
41
+
42
+ return this.androidOnTopMap;
43
+ }
44
+
45
+ public ConcurrentHashMap<String, String> getAndroidZOrderMap() {
46
+
47
+ return this.androidZOrderMap;
48
+ }
49
+
50
+ public ConcurrentHashMap<String, Stream> getSubscriberStreams() {
51
+
52
+ return this.subscriberStreams;
53
+ }
54
+
55
+ public ConcurrentHashMap<String, Subscriber> getSubscribers() {
56
+
57
+ return this.subscribers;
58
+ }
59
+
60
+ public ConcurrentHashMap<String, FrameLayout> getSubscriberViewContainers() {
61
+
62
+ return this.subscriberViewContainers;
63
+ }
64
+
65
+ public ConcurrentHashMap<String, Publisher> getPublishers() {
66
+
67
+ return this.publishers;
68
+ }
69
+
70
+ public ConcurrentHashMap<String, FrameLayout> getPublisherViewContainers() {
71
+
72
+ return this.publisherViewContainers;
73
+ }
74
+
75
+ public ConcurrentHashMap<String, Callback> getPublisherDestroyedCallbacks() {
76
+
77
+ return this.publisherDestroyedCallbacks;
78
+ }
79
+
80
+ public ConcurrentHashMap<String, Callback> getSessionConnectCallbacks() {
81
+
82
+ return this.sessionConnectCallbacks;
83
+ }
84
+
85
+ public ConcurrentHashMap<String, Callback> getSessionDisconnectCallbacks() {
86
+
87
+ return this.sessionDisconnectCallbacks;
88
+ }
89
+
90
+ public ConcurrentHashMap<String, Connection> getConnections() {
91
+
92
+ return this.connections;
93
+ }
94
+
95
+ public ConcurrentHashMap<String, Session> getSessions() {
96
+
97
+ return this.sessions;
98
+ }
99
+
100
+ private OTRN() {}
101
+ }
@@ -0,0 +1,120 @@
1
+ package com.altibbi;
2
+
3
+ import android.graphics.Bitmap;
4
+ import android.graphics.Canvas;
5
+ import android.os.Handler;
6
+ import android.view.View;
7
+
8
+ import com.opentok.android.BaseVideoCapturer;
9
+
10
+ public class OTScreenCapturer extends BaseVideoCapturer {
11
+
12
+ private boolean capturing = false;
13
+ private View contentView;
14
+
15
+ private int fps = 15;
16
+ private int width = 20;
17
+ private int height = 20;
18
+ private int[] frame;
19
+
20
+ private Bitmap bmp;
21
+ private Canvas canvas;
22
+
23
+ private Handler mHandler = new Handler();
24
+
25
+ private Runnable newFrame = new Runnable() {
26
+ @Override
27
+ public void run() {
28
+ if (capturing) {
29
+ int width = contentView.getWidth();
30
+ int height = contentView.getHeight();
31
+
32
+ if (frame == null ||
33
+ OTScreenCapturer.this.width != width ||
34
+ OTScreenCapturer.this.height != height) {
35
+
36
+ OTScreenCapturer.this.width = width;
37
+ OTScreenCapturer.this.height = height;
38
+
39
+ if (bmp != null) {
40
+ bmp.recycle();
41
+ bmp = null;
42
+ }
43
+ bmp = Bitmap.createBitmap(width,
44
+ height, Bitmap.Config.ARGB_8888);
45
+
46
+ canvas = new Canvas(bmp);
47
+ frame = new int[width * height];
48
+ }
49
+ canvas.save();
50
+ canvas.translate(-contentView.getScrollX(), - contentView.getScrollY());
51
+ contentView.draw(canvas);
52
+
53
+ bmp.getPixels(frame, 0, width, 0, 0, width, height);
54
+
55
+ provideIntArrayFrame(frame, ARGB, width, height, 0, false);
56
+
57
+ canvas.restore();
58
+
59
+ mHandler.postDelayed(newFrame, 1000 / fps);
60
+
61
+ }
62
+ }
63
+ };
64
+
65
+ public OTScreenCapturer(View view) {
66
+ this.contentView = view;
67
+ }
68
+
69
+ @Override
70
+ public void init() {
71
+
72
+ }
73
+
74
+ @Override
75
+ public int startCapture() {
76
+ capturing = true;
77
+
78
+ mHandler.postDelayed(newFrame, 1000 / fps);
79
+ return 0;
80
+ }
81
+
82
+ @Override
83
+ public int stopCapture() {
84
+ capturing = false;
85
+ mHandler.removeCallbacks(newFrame);
86
+ return 0;
87
+ }
88
+
89
+ @Override
90
+ public boolean isCaptureStarted() {
91
+ return capturing;
92
+ }
93
+
94
+ @Override
95
+ public CaptureSettings getCaptureSettings() {
96
+
97
+ CaptureSettings settings = new CaptureSettings();
98
+ settings.fps = fps;
99
+ settings.width = width;
100
+ settings.height = height;
101
+ settings.format = ARGB;
102
+ return settings;
103
+ }
104
+
105
+ @Override
106
+ public void destroy() {
107
+
108
+ }
109
+
110
+ @Override
111
+ public void onPause() {
112
+
113
+ }
114
+
115
+ @Override
116
+ public void onResume() {
117
+
118
+ }
119
+
120
+ }