UNPKG

camstreamerlib

Version:

Helper library for CamStreamer ACAP applications.

175 lines (174 loc) 7.21 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.secondaryAudioSettingsSchema = exports.globalAudioSettingsSchema = exports.globalAudioSettingsTypeSchema = exports.cameraOptionsSchema = exports.bitrateVapixParamsSchema = exports.bitrateModeSchema = exports.clipListSchema = exports.playlistQueueSchema = exports.trackerSaveLoadSchema = exports.trackerSaveSchema = exports.playlistSaveLoadSchema = exports.clipSaveLoadSchema = exports.clipSaveSchema = exports.streamSaveLoadSchema = exports.audioPushInfoSchema = exports.outputInfoSchema = exports.storageInfoListSchema = void 0; const zod_1 = require("zod"); const transformers_1 = require("../internal/transformers"); const common_1 = require("./common"); const channelTypeSchema = zod_1.z.union([zod_1.z.literal('audio'), zod_1.z.literal('video'), zod_1.z.literal('av')]); const playlistPlayTypeSchema = zod_1.z.union([ zod_1.z.literal('PLAY_ALL'), zod_1.z.literal('PLAY_ALL_LOOP'), zod_1.z.literal('PLAY_ALL_SHUFFLED'), zod_1.z.literal('PLAY_ALL_LOOP_SHUFFLED'), zod_1.z.literal('PLAY_ONE_RANDOM'), ]); exports.storageInfoListSchema = zod_1.z.array(zod_1.z.object({ storage: common_1.storageTypeSchema, writable: zod_1.z.boolean(), size: zod_1.z.number(), available: zod_1.z.number(), })); exports.outputInfoSchema = zod_1.z .object({ rtsp_url: zod_1.z.string(), ws: zod_1.z.string(), ws_initial_message: zod_1.z.string(), }) .transform(transformers_1.toCamelCase); exports.audioPushInfoSchema = zod_1.z .object({ ws: zod_1.z.string(), ws_initial_message: zod_1.z.string(), }) .transform(transformers_1.toCamelCase); const streamSaveSchema = zod_1.z.object({ niceName: zod_1.z.string(), ip: zod_1.z.string(), mdnsName: zod_1.z.string(), port: zod_1.z.number(), enabled: zod_1.z.boolean(), auth: zod_1.z.string(), query: zod_1.z.string(), channel: channelTypeSchema, keyboard: common_1.keyboardShortcutsSchema, sortIndexOverview: zod_1.z.number().optional(), viewNumber: zod_1.z.number(), }); exports.streamSaveLoadSchema = zod_1.z.record(zod_1.z.string(), streamSaveSchema.partial()); exports.clipSaveSchema = zod_1.z.object({ niceName: zod_1.z.string(), channel: channelTypeSchema, keyboard: common_1.keyboardShortcutsSchema, sortIndexOverview: zod_1.z.number(), }); exports.clipSaveLoadSchema = zod_1.z.record(zod_1.z.string(), exports.clipSaveSchema.partial()); const playlistStreamSaveSchema = zod_1.z .object({ stream_name: zod_1.z.string(), clip_name: zod_1.z.string(), tracker_name: zod_1.z.string(), storage: common_1.storageTypeSchema, }) .partial(); const playlistSaveSchema = zod_1.z.object({ channel: channelTypeSchema, isFavourite: zod_1.z.boolean(), keyboard: common_1.keyboardShortcutsSchema, niceName: zod_1.z.string(), sortIndexFavourite: zod_1.z.number().optional(), sortIndexOverview: zod_1.z.number().optional(), play_type: playlistPlayTypeSchema, default: zod_1.z.boolean().optional(), stream_list: zod_1.z.array(zod_1.z.object({ id: zod_1.z.string(), isTimeoutCustom: zod_1.z.boolean(), ptz_preset_pos_name: zod_1.z.string(), repeat: zod_1.z.number(), timeout: zod_1.z.number(), video: playlistStreamSaveSchema, audio: playlistStreamSaveSchema.optional(), })), }); exports.playlistSaveLoadSchema = zod_1.z.record(zod_1.z.string(), playlistSaveSchema.partial()); exports.trackerSaveSchema = zod_1.z.object({ id: zod_1.z.string(), name: zod_1.z.string(), previewId: zod_1.z.string(), duration: zod_1.z.number(), keyboard: common_1.keyboardShortcutsSchema, channel: channelTypeSchema, sortIndexOverview: zod_1.z.number(), width: zod_1.z.number(), height: zod_1.z.number(), fps: zod_1.z.number(), motion_history_frames: zod_1.z.number(), include_zone: zod_1.z.array(zod_1.z.array(zod_1.z.number()).length(2)), include_node_ids: zod_1.z.array(zod_1.z.string()), camera_list: zod_1.z.array(zod_1.z.object({ id: zod_1.z.string(), name: zod_1.z.string(), overview: zod_1.z.boolean(), zone: zod_1.z.array(zod_1.z.number()).length(4), playlist_name: zod_1.z.string(), ptz_preset_pos_no: zod_1.z.number(), })), viewNumber: zod_1.z.number(), camera_view_number: zod_1.z.number(), }); exports.trackerSaveLoadSchema = zod_1.z.record(zod_1.z.string(), exports.trackerSaveSchema.partial()); exports.playlistQueueSchema = zod_1.z .object({ playlist_queue_list: zod_1.z.array(zod_1.z.string()), }) .transform(transformers_1.toCamelCaseDeep); exports.clipListSchema = zod_1.z.object({ clip_list: zod_1.z.record(zod_1.z.string(), zod_1.z.object({ storage: common_1.storageTypeSchema, duration: zod_1.z.number(), stream_list: zod_1.z.array(zod_1.z.union([ zod_1.z.object({ type: zod_1.z.literal('video'), width: zod_1.z.number(), height: zod_1.z.number(), sample_rate: zod_1.z.number(), h264_profile: common_1.h264ProfileSchema, h264_level: zod_1.z.literal('4.1'), gop: zod_1.z.number(), fps: zod_1.z.number(), bitrate: zod_1.z.number(), }), zod_1.z.object({ type: zod_1.z.literal('audio'), sample_rate: zod_1.z.number(), channel_count: common_1.audioChannelCountSchema, }), ])), })), }); exports.bitrateModeSchema = zod_1.z.union([zod_1.z.literal('VBR'), zod_1.z.literal('MBR'), zod_1.z.literal('ABR')]); exports.bitrateVapixParamsSchema = zod_1.z.object({ bitrateMode: exports.bitrateModeSchema, maximumBitRate: zod_1.z.number(), retentionTime: zod_1.z.number(), bitRateLimit: zod_1.z.number(), }); exports.cameraOptionsSchema = exports.bitrateVapixParamsSchema .extend({ resolution: zod_1.z.string(), h264Profile: common_1.h264ProfileSchema, fps: zod_1.z.number(), compression: zod_1.z.number().min(0).max(100), govLength: zod_1.z.number(), bitrateVapixParams: zod_1.z.string().nullable(), audioSampleRate: zod_1.z.number(), audioChannelCount: common_1.audioChannelCountSchema, keyboard: zod_1.z.object({ fromSource: common_1.keyboardShortcutSchema, none: common_1.keyboardShortcutSchema, }), }) .partial(); exports.globalAudioSettingsTypeSchema = zod_1.z.union([zod_1.z.literal('fromSource'), zod_1.z.literal('source')]); exports.globalAudioSettingsSchema = zod_1.z.object({ type: exports.globalAudioSettingsTypeSchema, source: zod_1.z.string(), storage: zod_1.z.string().optional(), }); exports.secondaryAudioSettingsSchema = zod_1.z.object({ type: zod_1.z.union([zod_1.z.literal('CLIP'), zod_1.z.literal('STREAM'), zod_1.z.literal('NONE')]), streamName: zod_1.z.string().optional(), clipName: zod_1.z.string().optional(), storage: common_1.storageTypeSchema, secondaryAudioLevel: zod_1.z.number(), masterAudioLevel: zod_1.z.number(), });