@bits-innovate/react-native-vstarcam 1.0.56 → 1.0.58
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.
|
@@ -184,10 +184,10 @@ public class VStarCamVideoView extends FrameLayout
|
|
|
184
184
|
streamingRequested = true;
|
|
185
185
|
|
|
186
186
|
if (sdkClientPtr == 0) {
|
|
187
|
-
// Try to get SDK pointer again in case it was set after setClientPtr
|
|
188
187
|
this.sdkClientPtr = VStarCamModule.getSdkClientPtr((int) clientPtr);
|
|
189
188
|
if (sdkClientPtr == 0) {
|
|
190
189
|
Log.e(TAG, "Cannot start: no SDK client pointer");
|
|
190
|
+
sendErrorEvent("Cannot start: sdkClientPtr=0, clientPtr=" + clientPtr);
|
|
191
191
|
statusView.setText("Not connected");
|
|
192
192
|
return;
|
|
193
193
|
}
|
|
@@ -195,6 +195,7 @@ public class VStarCamVideoView extends FrameLayout
|
|
|
195
195
|
|
|
196
196
|
if (surface == null) {
|
|
197
197
|
Log.d(TAG, "Surface not yet available — deferring stream start");
|
|
198
|
+
sendErrorEvent("Surface null — deferring (pendingStartStream=true)");
|
|
198
199
|
statusView.setText("Preparing...");
|
|
199
200
|
pendingStartStream = true;
|
|
200
201
|
return;
|
|
@@ -202,6 +203,7 @@ public class VStarCamVideoView extends FrameLayout
|
|
|
202
203
|
|
|
203
204
|
if (appPlayerClass == null) {
|
|
204
205
|
Log.e(TAG, "Cannot start: player class not found");
|
|
206
|
+
sendErrorEvent("appPlayerClass is null");
|
|
205
207
|
statusView.setText("Player unavailable");
|
|
206
208
|
return;
|
|
207
209
|
}
|
|
@@ -209,13 +211,11 @@ public class VStarCamVideoView extends FrameLayout
|
|
|
209
211
|
statusView.setText("Starting stream...");
|
|
210
212
|
|
|
211
213
|
// Start video stream on camera side via CGI
|
|
212
|
-
Log.d(TAG, "Requesting livestream start from camera...");
|
|
213
214
|
VStarCamModule.sendCgiInternal((int) clientPtr,
|
|
214
215
|
String.format("livestream.cgi?streamid=10&substream=%d", resolution), 5);
|
|
215
216
|
|
|
216
217
|
try {
|
|
217
218
|
// 1. Create player instance if needed
|
|
218
|
-
// API: createPlayer(long identifier, Surface surface, int width, int height, int flags)
|
|
219
219
|
if (playerPtr == 0) {
|
|
220
220
|
int width = getWidth() > 0 ? getWidth() : 640;
|
|
221
221
|
int height = getHeight() > 0 ? getHeight() : 480;
|
|
@@ -224,38 +224,62 @@ public class VStarCamVideoView extends FrameLayout
|
|
|
224
224
|
"createPlayer", long.class, Surface.class, int.class, int.class, int.class);
|
|
225
225
|
Object result = createPlayerMethod.invoke(null, 0L, surface, width, height, 0);
|
|
226
226
|
playerPtr = (Long) result;
|
|
227
|
-
|
|
227
|
+
sendErrorEvent("Player created: ptr=" + playerPtr + " size=" + width + "x" + height);
|
|
228
228
|
}
|
|
229
229
|
|
|
230
230
|
// 2. Set the video source (P2P client)
|
|
231
|
-
// API: setPlayerSource(long player, int sourceType, String path, String[] extraPaths, long clientPtr, long[] extraPtrs)
|
|
232
231
|
try {
|
|
233
232
|
Method setSourceMethod = appPlayerClass.getMethod(
|
|
234
233
|
"setPlayerSource", long.class, int.class, String.class,
|
|
235
234
|
String[].class, long.class, long[].class);
|
|
236
|
-
// sourceType: probably 0 or 1 for P2P, path can be empty
|
|
237
235
|
boolean sourceSet = (Boolean) setSourceMethod.invoke(null,
|
|
238
236
|
playerPtr, 1, "", new String[0], sdkClientPtr, new long[0]);
|
|
239
|
-
|
|
237
|
+
sendErrorEvent("Source set: " + sourceSet + " sdkClient=" + sdkClientPtr);
|
|
240
238
|
} catch (NoSuchMethodException e) {
|
|
241
|
-
|
|
239
|
+
sendErrorEvent("setPlayerSource not found: " + e.getMessage());
|
|
242
240
|
}
|
|
243
241
|
|
|
244
242
|
// 3. Start playback
|
|
245
|
-
// API: start(long player) -> boolean
|
|
246
243
|
Method startMethod = appPlayerClass.getMethod("start", long.class);
|
|
247
244
|
boolean started = (Boolean) startMethod.invoke(null, playerPtr);
|
|
248
|
-
|
|
245
|
+
sendErrorEvent("Playback result: started=" + started);
|
|
249
246
|
|
|
250
247
|
isStreaming = true;
|
|
248
|
+
playerInitialized = true;
|
|
251
249
|
statusView.setVisibility(GONE);
|
|
252
250
|
|
|
251
|
+
// Send success event to JS
|
|
252
|
+
try {
|
|
253
|
+
com.facebook.react.bridge.WritableMap event =
|
|
254
|
+
com.facebook.react.bridge.Arguments.createMap();
|
|
255
|
+
event.putBoolean("streaming", true);
|
|
256
|
+
event.putDouble("playerPtr", playerPtr);
|
|
257
|
+
event.putBoolean("started", started);
|
|
258
|
+
com.facebook.react.uimanager.events.RCTEventEmitter emitter =
|
|
259
|
+
((com.facebook.react.bridge.ReactContext) getContext())
|
|
260
|
+
.getJSModule(com.facebook.react.uimanager.events.RCTEventEmitter.class);
|
|
261
|
+
emitter.receiveEvent(getId(), "onStreamStarted", event);
|
|
262
|
+
} catch (Exception ignored) {}
|
|
263
|
+
|
|
253
264
|
} catch (Exception e) {
|
|
254
265
|
Log.e(TAG, "Failed to start stream", e);
|
|
266
|
+
sendErrorEvent("EXCEPTION: " + e.getClass().getSimpleName() + ": " + e.getMessage());
|
|
255
267
|
statusView.setText("Start failed: " + e.getMessage());
|
|
256
268
|
}
|
|
257
269
|
}
|
|
258
270
|
|
|
271
|
+
private void sendErrorEvent(String message) {
|
|
272
|
+
try {
|
|
273
|
+
com.facebook.react.bridge.WritableMap event =
|
|
274
|
+
com.facebook.react.bridge.Arguments.createMap();
|
|
275
|
+
event.putString("error", message);
|
|
276
|
+
com.facebook.react.uimanager.events.RCTEventEmitter emitter =
|
|
277
|
+
((com.facebook.react.bridge.ReactContext) getContext())
|
|
278
|
+
.getJSModule(com.facebook.react.uimanager.events.RCTEventEmitter.class);
|
|
279
|
+
emitter.receiveEvent(getId(), "onStreamError", event);
|
|
280
|
+
} catch (Exception ignored) {}
|
|
281
|
+
}
|
|
282
|
+
|
|
259
283
|
/**
|
|
260
284
|
* Stop video streaming.
|
|
261
285
|
*/
|
|
@@ -82,6 +82,25 @@ public class VStarCamVideoViewManager extends SimpleViewManager<VStarCamVideoVie
|
|
|
82
82
|
);
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
// Handle commands dispatched with NUMERIC IDs (from UIManager.Commands)
|
|
86
|
+
@Override
|
|
87
|
+
public void receiveCommand(@NonNull VStarCamVideoView view, int commandId, @Nullable ReadableArray args) {
|
|
88
|
+
switch (commandId) {
|
|
89
|
+
case COMMAND_START_STREAM:
|
|
90
|
+
view.startStream();
|
|
91
|
+
break;
|
|
92
|
+
case COMMAND_STOP_STREAM:
|
|
93
|
+
view.stopStream();
|
|
94
|
+
break;
|
|
95
|
+
case COMMAND_CAPTURE_SNAPSHOT:
|
|
96
|
+
if (args != null && args.size() > 0) {
|
|
97
|
+
view.captureSnapshot(args.getString(0));
|
|
98
|
+
}
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Handle commands dispatched with STRING IDs (legacy/fallback)
|
|
85
104
|
@Override
|
|
86
105
|
public void receiveCommand(@NonNull VStarCamVideoView view, String commandId, @Nullable ReadableArray args) {
|
|
87
106
|
switch (commandId) {
|