@apocaliss92/scrypted-reolink-native 0.3.0 → 0.3.1

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.
package/dist/plugin.zip CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apocaliss92/scrypted-reolink-native",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Use any reolink camera with Scrypted, even older/unsupported models without HTTP protocol support",
5
5
  "author": "@apocaliss92",
6
6
  "license": "Apache",
package/src/camera.ts CHANGED
@@ -235,6 +235,14 @@ export class ReolinkCamera extends BaseBaichuanClass implements VideoCamera, Cam
235
235
  defaultValue: 'default',
236
236
  choices: ['default', 'autotrack', 'telephoto'] as NativeVideoStreamVariant[],
237
237
  },
238
+ preferredStreams: {
239
+ type: 'string',
240
+ title: 'Preferred Stream Order',
241
+ description: 'Order preference for video streams. Default: RTSP -> RTMP -> Native',
242
+ defaultValue: 'Default',
243
+ choices: ['Default', 'Native', 'RTSP', 'RTMP'],
244
+ subgroup: 'Streaming',
245
+ },
238
246
  // capabilities: {
239
247
  // json: true,
240
248
  // hide: true,
@@ -2406,11 +2414,33 @@ export class ReolinkCamera extends BaseBaichuanClass implements VideoCamera, Cam
2406
2414
  compositeOnly: this.isMultiFocal,
2407
2415
  })}`);
2408
2416
 
2409
- // const urls = client.getRtspUrl(rtspChannel);
2410
-
2411
- // let supportedStreams: ReolinkSupportedStream[] = [];
2412
- const supportedStreams = [...nativeStreams, ...rtspStreams, ...rtmpStreams];
2413
- // logger.log({ supportedStreams, variantType, lensParam, rtspChannel, onNvr: this.isOnNvr, nativeStreams: nativeStreams.map(s => ({ id: s.id, nativeVariant: s.nativeVariant, lens: s.lens })), rtspStreams: rtspStreams.map(s => ({ id: s.id, lens: s.lens })), rtmpStreams: rtmpStreams.map(s => ({ id: s.id, lens: s.lens })) });
2417
+ // Update preferredStreams choices based on supported stream types
2418
+ const availableChoices = ['Default'];
2419
+ if (nativeStreams.length > 0) availableChoices.push('Native');
2420
+ if (rtspStreams.length > 0) availableChoices.push('RTSP');
2421
+ if (rtmpStreams.length > 0) availableChoices.push('RTMP');
2422
+
2423
+ this.storageSettings.settings.preferredStreams.choices = availableChoices;
2424
+
2425
+ // Order streams based on preferredStreams setting
2426
+ const preferredOrder = this.storageSettings.values.preferredStreams || 'Default';
2427
+ let supportedStreams: any[] = [];
2428
+
2429
+ if (preferredOrder === 'Default') {
2430
+ // Default: Native -> RTSP -> RTMP
2431
+ supportedStreams = [...nativeStreams, ...rtspStreams, ...rtmpStreams];
2432
+ // // Default: RTSP -> RTMP -> Native
2433
+ // supportedStreams = [...rtspStreams, ...rtmpStreams, ...nativeStreams];
2434
+ } else if (preferredOrder === 'Native') {
2435
+ supportedStreams = [...nativeStreams, ...rtspStreams, ...rtmpStreams];
2436
+ } else if (preferredOrder === 'RTSP') {
2437
+ supportedStreams = [...rtspStreams, ...rtmpStreams, ...nativeStreams];
2438
+ } else if (preferredOrder === 'RTMP') {
2439
+ supportedStreams = [...rtmpStreams, ...rtspStreams, ...nativeStreams];
2440
+ } else {
2441
+ // Fallback to default
2442
+ supportedStreams = [...rtspStreams, ...rtmpStreams, ...nativeStreams];
2443
+ }
2414
2444
 
2415
2445
  for (const supportedStream of supportedStreams) {
2416
2446
  const { id, metadata, url, name, container, lens, channel, profile, nativeVariant } = supportedStream;
@@ -2500,8 +2530,11 @@ export class ReolinkCamera extends BaseBaichuanClass implements VideoCamera, Cam
2500
2530
  return await this.createMediaObject(ret, ScryptedMimeTypes.MediaStreamUrl);
2501
2531
  }
2502
2532
 
2533
+ // Ensure streamManager is initialized before use
2503
2534
  if (!this.streamManager) {
2504
- throw new Error('StreamManager not initialized');
2535
+ const logger = this.getBaichuanLogger();
2536
+ logger.warn('StreamManager not initialized, initializing now...');
2537
+ this.initStreamManager(logger);
2505
2538
  }
2506
2539
 
2507
2540
  const streamKey = selected.id;