mirror of
https://github.com/koush/scrypted.git
synced 2026-03-04 10:23:18 +00:00
server: prevent invalid media converter from crashing all conversions
This commit is contained in:
@@ -208,20 +208,25 @@ export abstract class MediaManagerBase implements MediaManager {
|
||||
.map(([id]) => {
|
||||
const device = this.getDeviceById<MediaConverter & BufferConverter>(id);
|
||||
|
||||
return (device.converters || []).map(([fromMimeType, toMimeType], index) => {
|
||||
return {
|
||||
id: `${id}-${index}`,
|
||||
name: device.name,
|
||||
fromMimeType,
|
||||
toMimeType,
|
||||
convert(data, fromMimeType, toMimeType, options?) {
|
||||
// MediaConverter is injected the plugin's node runtime which may be compiled against an
|
||||
// older sdk that does not have MediaConverter. use the older convert method instead.
|
||||
// once BufferConverter is removed, this can be simplified to device.convertMedia.
|
||||
return (device.convertMedia || device.convert)(data, fromMimeType, toMimeType, options);
|
||||
},
|
||||
} as IdBufferConverter;
|
||||
});
|
||||
try {
|
||||
return (device.converters || []).map(([fromMimeType, toMimeType], index) => {
|
||||
return {
|
||||
id: `${id}-${index}`,
|
||||
name: device.name,
|
||||
fromMimeType,
|
||||
toMimeType,
|
||||
convert(data, fromMimeType, toMimeType, options?) {
|
||||
// MediaConverter is injected the plugin's node runtime which may be compiled against an
|
||||
// older sdk that does not have MediaConverter. use the older convert method instead.
|
||||
// once BufferConverter is removed, this can be simplified to device.convertMedia.
|
||||
return (device.convertMedia || device.convert)(data, fromMimeType, toMimeType, options);
|
||||
},
|
||||
} as IdBufferConverter;
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
return [];
|
||||
}
|
||||
});
|
||||
|
||||
const converters = [...mediaConverters.flat(), ...bufferConverters];
|
||||
|
||||
Reference in New Issue
Block a user