mirror of
https://github.com/koush/scrypted.git
synced 2026-02-10 01:02:18 +00:00
server: fix plugin fork mixin event bug
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import ffmpegInstaller from '@ffmpeg-installer/ffmpeg';
|
||||
import { BufferConverter, DeviceManager, FFmpegInput, MediaManager, MediaObject, MediaObjectOptions, MediaStreamUrl, ScryptedInterface, ScryptedInterfaceProperty, ScryptedMimeTypes, ScryptedNativeId, SystemDeviceState, SystemManager } from "@scrypted/types";
|
||||
import axios from 'axios';
|
||||
import ffmpegInstaller from '@ffmpeg-installer/ffmpeg';
|
||||
import fs from 'fs';
|
||||
import https from 'https';
|
||||
import mimeType from 'mime';
|
||||
@@ -65,7 +65,19 @@ export abstract class MediaManagerBase implements MediaManager {
|
||||
fromMimeType: ScryptedMimeTypes.SchemePrefix + 'file',
|
||||
toMimeType: ScryptedMimeTypes.MediaObject,
|
||||
convert: async (data, fromMimeType, toMimeType) => {
|
||||
const filename = data.toString().substring('file:'.length);
|
||||
const url = data.toString();
|
||||
const filename = url.substring('file:'.length);
|
||||
|
||||
if (toMimeType === ScryptedMimeTypes.FFmpegInput) {
|
||||
const ffmpegInput: FFmpegInput = {
|
||||
url,
|
||||
inputArguments: [
|
||||
'-i', filename,
|
||||
]
|
||||
};
|
||||
return this.createFFmpegMediaObject(ffmpegInput);
|
||||
}
|
||||
|
||||
const ab = await fs.promises.readFile(filename);
|
||||
const mt = mimeType.getType(data.toString());
|
||||
const mo = this.createMediaObject(ab, mt);
|
||||
|
||||
@@ -90,7 +90,7 @@ export class PluginAPIProxy extends PluginAPIManagedListeners implements PluginA
|
||||
return this.api.onDeviceEvent(nativeId, eventInterface, eventData);
|
||||
}
|
||||
onMixinEvent(id: string, nativeId: ScryptedNativeId, eventInterface: any, eventData?: any): Promise<void> {
|
||||
return this.api.onMixinEvent(nativeId, eventInterface, eventData);
|
||||
return this.api.onMixinEvent(id, nativeId, eventInterface, eventData);
|
||||
}
|
||||
onDeviceRemoved(nativeId: string): Promise<void> {
|
||||
return this.api.onDeviceRemoved(nativeId);
|
||||
|
||||
@@ -394,13 +394,14 @@ export function startPluginRemote(pluginId: string, peerSend: (message: RpcMessa
|
||||
|
||||
try {
|
||||
peer.evalLocal(script, zipOptions?.filename || '/plugin/main.nodejs.js', params);
|
||||
pluginConsole?.log('plugin successfully loaded');
|
||||
|
||||
if (zipOptions?.fork) {
|
||||
pluginConsole?.log('plugin forked');
|
||||
const fork = exports.fork;
|
||||
return fork();
|
||||
}
|
||||
|
||||
pluginConsole?.log('plugin loaded');
|
||||
let pluginInstance = exports.default;
|
||||
// support exporting a plugin class, plugin main function,
|
||||
// or a plugin instance
|
||||
|
||||
Reference in New Issue
Block a user