@bits-innovate/react-native-vstarcam 1.0.20 → 1.0.22

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.
@@ -48,6 +48,16 @@ public class VStarCamModule extends ReactContextBaseJavaModule {
48
48
  private static final String TAG = "VStarCamModule";
49
49
  private static final String MODULE_NAME = "VStarCam";
50
50
 
51
+ // Set to true for verbose logging during development
52
+ private static final boolean DEBUG_LOGGING = false;
53
+
54
+ // Helper for conditional debug logging
55
+ private static void logDebug(String message) {
56
+ if (DEBUG_LOGGING) {
57
+ Log.d(TAG, message);
58
+ }
59
+ }
60
+
51
61
  // P2P Server parameters by DID prefix (from Flutter SDK)
52
62
  private static final Map<String, String> SERVICE_PARAM_MAP = new HashMap<String, String>() {{
53
63
  put("VSTC", "EBGBEMBMKGJMGAJPEIGIFKEGHBMCHMNFGKEGBFCBBMJELILDCJADCIOLHHLLJBKEAMMBLCDGONMDBJCJJPNFJP");
@@ -835,7 +845,7 @@ public class VStarCamModule extends ReactContextBaseJavaModule {
835
845
  @ReactMethod
836
846
  public void getSdkVersion(Promise promise) {
837
847
  WritableMap result = Arguments.createMap();
838
- result.putString("version", "1.0.20");
848
+ result.putString("version", "1.0.22");
839
849
  result.putBoolean("nativeLoaded", isNativeLibraryLoaded);
840
850
  result.putString("nativeLib", "OKSMARTPPCS");
841
851
  result.putBoolean("p2pInitialized", isP2PInitialized);
@@ -20,6 +20,15 @@ public class VStarCamVideoView extends FrameLayout
20
20
  implements TextureView.SurfaceTextureListener {
21
21
 
22
22
  private static final String TAG = "VStarCamVideoView";
23
+
24
+ // Set to true for verbose logging during development
25
+ private static final boolean DEBUG_LOGGING = false;
26
+
27
+ private static void logDebug(String message) {
28
+ if (DEBUG_LOGGING) {
29
+ Log.d(TAG, message);
30
+ }
31
+ }
23
32
 
24
33
  private TextureView textureView;
25
34
  private TextView statusView;
@@ -154,6 +163,10 @@ public class VStarCamVideoView extends FrameLayout
154
163
 
155
164
  /**
156
165
  * Start video streaming.
166
+ * Uses AppPlayerApi methods discovered via reflection:
167
+ * - createPlayer(long, Surface, int, int, int) -> long
168
+ * - setPlayerSource(long, int, String, String[], long, long[]) -> boolean
169
+ * - start(long) -> boolean
157
170
  */
158
171
  public void startStream() {
159
172
  if (sdkClientPtr == 0) {
@@ -182,58 +195,37 @@ public class VStarCamVideoView extends FrameLayout
182
195
 
183
196
  try {
184
197
  // 1. Create player instance if needed
198
+ // API: createPlayer(long identifier, Surface surface, int width, int height, int flags)
185
199
  if (playerPtr == 0) {
186
- Method createMethod = appPlayerClass.getMethod("create");
187
- Object result = createMethod.invoke(null);
200
+ int width = getWidth() > 0 ? getWidth() : 640;
201
+ int height = getHeight() > 0 ? getHeight() : 480;
202
+
203
+ Method createPlayerMethod = appPlayerClass.getMethod(
204
+ "createPlayer", long.class, Surface.class, int.class, int.class, int.class);
205
+ Object result = createPlayerMethod.invoke(null, 0L, surface, width, height, 0);
188
206
  playerPtr = (Long) result;
189
- Log.d(TAG, "Player created: " + playerPtr);
207
+ Log.d(TAG, "Player created: " + playerPtr + " (size: " + width + "x" + height + ")");
190
208
  }
191
209
 
192
210
  // 2. Set the video source (P2P client)
211
+ // API: setPlayerSource(long player, int sourceType, String path, String[] extraPaths, long clientPtr, long[] extraPtrs)
193
212
  try {
194
213
  Method setSourceMethod = appPlayerClass.getMethod(
195
- "setSource", long.class, long.class);
196
- setSourceMethod.invoke(null, playerPtr, sdkClientPtr);
197
- Log.d(TAG, "Source set to client: " + sdkClientPtr);
198
- } catch (NoSuchMethodException e) {
199
- Log.w(TAG, "setSource method not found, trying alternative...");
200
- // Try alternative method signatures if the main one doesn't exist
201
- }
202
-
203
- // 3. Set the render surface
204
- try {
205
- Method setSurfaceMethod = appPlayerClass.getMethod(
206
- "setSurface", long.class, Surface.class);
207
- setSurfaceMethod.invoke(null, playerPtr, surface);
208
- Log.d(TAG, "Surface set");
214
+ "setPlayerSource", long.class, int.class, String.class,
215
+ String[].class, long.class, long[].class);
216
+ // sourceType: probably 0 or 1 for P2P, path can be empty
217
+ boolean sourceSet = (Boolean) setSourceMethod.invoke(null,
218
+ playerPtr, 1, "", new String[0], sdkClientPtr, new long[0]);
219
+ Log.d(TAG, "Source set: " + sourceSet + " (client: " + sdkClientPtr + ")");
209
220
  } catch (NoSuchMethodException e) {
210
- Log.w(TAG, "setSurface method not found, trying alternative...");
211
- // Try with Object parameter
212
- try {
213
- Method setSurfaceMethod = appPlayerClass.getMethod(
214
- "setSurface", long.class, Object.class);
215
- setSurfaceMethod.invoke(null, playerPtr, surface);
216
- Log.d(TAG, "Surface set (via Object)");
217
- } catch (NoSuchMethodException e2) {
218
- Log.e(TAG, "No setSurface method found");
219
- }
221
+ Log.w(TAG, "setPlayerSource not found, continuing without explicit source");
220
222
  }
221
223
 
222
- // 4. Start playback
223
- try {
224
- Method startMethod = appPlayerClass.getMethod("start", long.class);
225
- startMethod.invoke(null, playerPtr);
226
- Log.d(TAG, "Playback started");
227
- } catch (NoSuchMethodException e) {
228
- // Try play() instead of start()
229
- try {
230
- Method playMethod = appPlayerClass.getMethod("play", long.class);
231
- playMethod.invoke(null, playerPtr);
232
- Log.d(TAG, "Playback started (via play)");
233
- } catch (NoSuchMethodException e2) {
234
- Log.e(TAG, "No start/play method found");
235
- }
236
- }
224
+ // 3. Start playback
225
+ // API: start(long player) -> boolean
226
+ Method startMethod = appPlayerClass.getMethod("start", long.class);
227
+ boolean started = (Boolean) startMethod.invoke(null, playerPtr);
228
+ Log.d(TAG, "Playback started: " + started);
237
229
 
238
230
  isStreaming = true;
239
231
  statusView.setVisibility(GONE);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bits-innovate/react-native-vstarcam",
3
- "version": "1.0.20",
3
+ "version": "1.0.22",
4
4
  "description": "React Native bridge for VStarCam P2P SDK",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",