@bits-innovate/react-native-vstarcam 1.0.49 → 1.0.51

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.
@@ -236,6 +236,11 @@ public class VStarCamModule extends ReactContextBaseJavaModule {
236
236
  Log.e(TAG, "Cannot initialize P2P: native library or JNIApi not available");
237
237
  return;
238
238
  }
239
+
240
+ if (VStarCamModule.isP2PInitialized) {
241
+ Log.d(TAG, "P2P system already initialized. Skipping JNIApi.init() to prevent C++ SDK crashes during hot reload.");
242
+ return;
243
+ }
239
244
 
240
245
  try {
241
246
  // Create dynamic proxy for ClientStateListener
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bits-innovate/react-native-vstarcam",
3
- "version": "1.0.49",
3
+ "version": "1.0.51",
4
4
  "description": "React Native bridge for VStarCam P2P SDK",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
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("decoder_control.cgi?command=1&onestep=0&");
490
+ return this.sendCommand(`decoder_control.cgi?${this.getPtzBaseParams()}&command=1&onestep=0&`);
483
491
  }
484
492
 
485
493
  /**