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

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.
@@ -835,7 +835,7 @@ public class VStarCamModule extends ReactContextBaseJavaModule {
835
835
  @ReactMethod
836
836
  public void getSdkVersion(Promise promise) {
837
837
  WritableMap result = Arguments.createMap();
838
- result.putString("version", "1.0.20");
838
+ result.putString("version", "1.0.21");
839
839
  result.putBoolean("nativeLoaded", isNativeLibraryLoaded);
840
840
  result.putString("nativeLib", "OKSMARTPPCS");
841
841
  result.putBoolean("p2pInitialized", isP2PInitialized);
@@ -154,6 +154,10 @@ public class VStarCamVideoView extends FrameLayout
154
154
 
155
155
  /**
156
156
  * Start video streaming.
157
+ * Uses AppPlayerApi methods discovered via reflection:
158
+ * - createPlayer(long, Surface, int, int, int) -> long
159
+ * - setPlayerSource(long, int, String, String[], long, long[]) -> boolean
160
+ * - start(long) -> boolean
157
161
  */
158
162
  public void startStream() {
159
163
  if (sdkClientPtr == 0) {
@@ -182,58 +186,37 @@ public class VStarCamVideoView extends FrameLayout
182
186
 
183
187
  try {
184
188
  // 1. Create player instance if needed
189
+ // API: createPlayer(long identifier, Surface surface, int width, int height, int flags)
185
190
  if (playerPtr == 0) {
186
- Method createMethod = appPlayerClass.getMethod("create");
187
- Object result = createMethod.invoke(null);
191
+ int width = getWidth() > 0 ? getWidth() : 640;
192
+ int height = getHeight() > 0 ? getHeight() : 480;
193
+
194
+ Method createPlayerMethod = appPlayerClass.getMethod(
195
+ "createPlayer", long.class, Surface.class, int.class, int.class, int.class);
196
+ Object result = createPlayerMethod.invoke(null, 0L, surface, width, height, 0);
188
197
  playerPtr = (Long) result;
189
- Log.d(TAG, "Player created: " + playerPtr);
198
+ Log.d(TAG, "Player created: " + playerPtr + " (size: " + width + "x" + height + ")");
190
199
  }
191
200
 
192
201
  // 2. Set the video source (P2P client)
202
+ // API: setPlayerSource(long player, int sourceType, String path, String[] extraPaths, long clientPtr, long[] extraPtrs)
193
203
  try {
194
204
  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);
205
+ "setPlayerSource", long.class, int.class, String.class,
206
+ String[].class, long.class, long[].class);
207
+ // sourceType: probably 0 or 1 for P2P, path can be empty
208
+ boolean sourceSet = (Boolean) setSourceMethod.invoke(null,
209
+ playerPtr, 1, "", new String[0], sdkClientPtr, new long[0]);
210
+ Log.d(TAG, "Source set: " + sourceSet + " (client: " + sdkClientPtr + ")");
198
211
  } 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
212
+ Log.w(TAG, "setPlayerSource not found, continuing without explicit source");
201
213
  }
202
214
 
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");
209
- } 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
- }
220
- }
221
-
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
- }
215
+ // 3. Start playback
216
+ // API: start(long player) -> boolean
217
+ Method startMethod = appPlayerClass.getMethod("start", long.class);
218
+ boolean started = (Boolean) startMethod.invoke(null, playerPtr);
219
+ Log.d(TAG, "Playback started: " + started);
237
220
 
238
221
  isStreaming = true;
239
222
  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.21",
4
4
  "description": "React Native bridge for VStarCam P2P SDK",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",