@bits-innovate/react-native-vstarcam 1.0.48 → 1.0.50
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.
|
@@ -205,11 +205,6 @@ public class VStarCamModule extends ReactContextBaseJavaModule {
|
|
|
205
205
|
currentContext = new java.lang.ref.WeakReference<>(reactContext);
|
|
206
206
|
|
|
207
207
|
synchronized (initLock) {
|
|
208
|
-
if (isP2PInitialized) {
|
|
209
|
-
Log.d(TAG, "P2P already initialized, skipping...");
|
|
210
|
-
return;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
208
|
// Load the native libraries
|
|
214
209
|
try {
|
|
215
210
|
if (!isNativeLibraryLoaded) {
|
|
@@ -242,11 +237,6 @@ public class VStarCamModule extends ReactContextBaseJavaModule {
|
|
|
242
237
|
return;
|
|
243
238
|
}
|
|
244
239
|
|
|
245
|
-
if (VStarCamModule.isP2PInitialized) {
|
|
246
|
-
Log.d(TAG, "P2P system already initialized, skipping SDK init calls");
|
|
247
|
-
return;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
240
|
try {
|
|
251
241
|
// Create dynamic proxy for ClientStateListener
|
|
252
242
|
stateListenerProxy = Proxy.newProxyInstance(
|
|
@@ -268,8 +258,14 @@ public class VStarCamModule extends ReactContextBaseJavaModule {
|
|
|
268
258
|
Log.d(TAG, "ClientStateListener." + methodName + " called");
|
|
269
259
|
if (methodName.equals("stateListener")) {
|
|
270
260
|
// args: long clientPtr, int state
|
|
271
|
-
|
|
272
|
-
|
|
261
|
+
long clientPtr = 0;
|
|
262
|
+
int state = 0;
|
|
263
|
+
|
|
264
|
+
if (args != null && args.length >= 2) {
|
|
265
|
+
if (args[0] instanceof Number) clientPtr = ((Number) args[0]).longValue();
|
|
266
|
+
if (args[1] instanceof Number) state = ((Number) args[1]).intValue();
|
|
267
|
+
}
|
|
268
|
+
|
|
273
269
|
Log.d(TAG, "State callback: clientPtr=" + clientPtr + ", state=" + state);
|
|
274
270
|
|
|
275
271
|
// Post to main thread for React Native compatibility
|
|
@@ -303,9 +299,16 @@ public class VStarCamModule extends ReactContextBaseJavaModule {
|
|
|
303
299
|
Log.d(TAG, "ClientCommandListener." + methodName + " called");
|
|
304
300
|
if (methodName.equals("commandListener")) {
|
|
305
301
|
// args: long clientPtr, byte[] data, int length (from interface)
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
302
|
+
long clientPtr = 0;
|
|
303
|
+
byte[] data = null;
|
|
304
|
+
int length = 0;
|
|
305
|
+
|
|
306
|
+
if (args != null && args.length >= 3) {
|
|
307
|
+
if (args[0] instanceof Number) clientPtr = ((Number) args[0]).longValue();
|
|
308
|
+
if (args[1] instanceof byte[]) data = (byte[]) args[1];
|
|
309
|
+
if (args[2] instanceof Number) length = ((Number) args[2]).intValue();
|
|
310
|
+
}
|
|
311
|
+
|
|
309
312
|
Log.d(TAG, "Command callback: clientPtr=" + clientPtr + ", dataLen=" + (data != null ? data.length : 0));
|
|
310
313
|
|
|
311
314
|
// Post to main thread for React Native compatibility
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -213,6 +213,8 @@ export type VideoFrameListener = (
|
|
|
213
213
|
*/
|
|
214
214
|
class VStarCamClient {
|
|
215
215
|
private clientPtr: number = 0;
|
|
216
|
+
private currentUsername: string = "admin";
|
|
217
|
+
private currentPassword: string = "888888";
|
|
216
218
|
private eventEmitter: NativeEventEmitter;
|
|
217
219
|
private connectionListeners: Set<ConnectionEventListener> = new Set();
|
|
218
220
|
private commandListeners: Set<CommandEventListener> = new Set();
|
|
@@ -328,6 +330,8 @@ class VStarCamClient {
|
|
|
328
330
|
password: string = "888888"
|
|
329
331
|
): Promise<boolean> {
|
|
330
332
|
if (!this.clientPtr) return false;
|
|
333
|
+
this.currentUsername = username;
|
|
334
|
+
this.currentPassword = password;
|
|
331
335
|
return VStarCamModule.clientLogin(this.clientPtr, username, password);
|
|
332
336
|
}
|
|
333
337
|
|
|
@@ -458,28 +462,32 @@ class VStarCamClient {
|
|
|
458
462
|
/**
|
|
459
463
|
* PTZ Control - Move camera
|
|
460
464
|
*/
|
|
465
|
+
private getPtzBaseParams(): string {
|
|
466
|
+
return `loginuse=${encodeURIComponent(this.currentUsername)}&loginpas=${encodeURIComponent(this.currentPassword)}`;
|
|
467
|
+
}
|
|
468
|
+
|
|
461
469
|
async ptzUp(continuous: boolean = false): Promise<boolean> {
|
|
462
470
|
const cmd = continuous ? "command=0&onestep=0" : "command=0&onestep=1";
|
|
463
|
-
return this.sendCommand(`decoder_control.cgi?${cmd}&`);
|
|
471
|
+
return this.sendCommand(`decoder_control.cgi?${this.getPtzBaseParams()}&${cmd}&`);
|
|
464
472
|
}
|
|
465
473
|
|
|
466
474
|
async ptzDown(continuous: boolean = false): Promise<boolean> {
|
|
467
475
|
const cmd = continuous ? "command=2&onestep=0" : "command=2&onestep=1";
|
|
468
|
-
return this.sendCommand(`decoder_control.cgi?${cmd}&`);
|
|
476
|
+
return this.sendCommand(`decoder_control.cgi?${this.getPtzBaseParams()}&${cmd}&`);
|
|
469
477
|
}
|
|
470
478
|
|
|
471
479
|
async ptzLeft(continuous: boolean = false): Promise<boolean> {
|
|
472
480
|
const cmd = continuous ? "command=4&onestep=0" : "command=5&onestep=1";
|
|
473
|
-
return this.sendCommand(`decoder_control.cgi?${cmd}&`);
|
|
481
|
+
return this.sendCommand(`decoder_control.cgi?${this.getPtzBaseParams()}&${cmd}&`);
|
|
474
482
|
}
|
|
475
483
|
|
|
476
484
|
async ptzRight(continuous: boolean = false): Promise<boolean> {
|
|
477
485
|
const cmd = continuous ? "command=6&onestep=0" : "command=7&onestep=1";
|
|
478
|
-
return this.sendCommand(`decoder_control.cgi?${cmd}&`);
|
|
486
|
+
return this.sendCommand(`decoder_control.cgi?${this.getPtzBaseParams()}&${cmd}&`);
|
|
479
487
|
}
|
|
480
488
|
|
|
481
489
|
async ptzStop(): Promise<boolean> {
|
|
482
|
-
return this.sendCommand(
|
|
490
|
+
return this.sendCommand(`decoder_control.cgi?${this.getPtzBaseParams()}&command=1&onestep=0&`);
|
|
483
491
|
}
|
|
484
492
|
|
|
485
493
|
/**
|