UNPKG

tv-automation-quantel-gateway-client

Version:
346 lines 14.7 kB
import * as Q from './quantelTypes.js'; import { Agent as HTTPAgent } from 'http'; import { Agent as HTTPSAgent } from 'https'; import { EventEmitter } from 'events'; /** * Remote connection to a [Sofie Quantel Gateway](https://github.com/nrkno/sofie-quantel-gateway). * Create and initialize a new connection as follows: * * const quantelClient = new QuantelGateway() * await quantelCient.init( * 'quantel.gateway.url:port', 'quantel.isa.url', undefined, 'default', serverID) * * If the serverID is not known, before calling `init()` request the details of all servers: * * await quantelClient.connectToISA('quantel.isa.url') * const servers = await quantelClient.getServers('default') * * Then initialize the client as above. * * Once finished with the class, call `dispose()`. */ export declare class QuantelGateway extends EventEmitter { private _checkStatusInterval; private _callTimeout; private _gatewayUrl; private _initialized; private _ISAUrls; private _zoneId; private _serverId; private _monitorInterval; private _statusMessage; private _cachedServer; private _monitorPorts; private _connected; /** Create a Quantel Gateway client. */ constructor(config?: { timeout?: number; checkStatusInterval?: number; }); /** * Initialize a Quantel Gateway client, making the required connections. * * in the event that connection to one of them fails. * @param gatewayUrl Location of the associated Quantel Gateway. * @param ISAUrls Locations of the ISA managers (in order of importance). * Multiple entries means that there are a master and one or several slave ISA's. * In the event of failure of the master, the slaves will be tried in order by the Quantel gateway. * @param zoneId Zone identifier, or `undefined` for default. * @param serverId Identifier of the server to be controlled. */ init(gatewayUrl: string, ISAUrls: string | string[], zoneId: string | undefined, serverId: number | undefined): Promise<void>; get checkStatusInterval(): number; /** * Request that the Quantel Gateway connects to the given ISA manager. * @param ISAUrls Locations of the ISA managers (in order of importance). Multiple entries means that there are a master and one or several slave ISA's. * @returns Details of the connection created. */ connectToISA(ISAUrls: string | string[]): Promise<Q.ConnectionDetails>; reconnectToISA(): Promise<Q.ConnectionDetails>; /** * Sefely dispose of the resources used by this client, stopping monitors. */ dispose(): void; /** * Start the process of repeatedly monitoring the status of the attached * Quantel Gateway and onwards to an ISA manager. * @param callbackOnStatusChange Callback function called when * the connection status through to the ISA manager changes. */ monitorServerStatus(callbackOnStatusChange: (connected: boolean, errorMessage: string | null) => void): void; /** Is the client connected somehow? */ get connected(): boolean; /** * Description of the status of the connection. * @returns Current status, or `null` if all is good. */ get statusMessage(): string | null; /** Is this client initialized? */ get initialized(): boolean; /** Location of the Quantel Gateway this client targets. */ get gatewayUrl(): string; /** The Location(s) of the ISA Manager(s) the gateway can connect to. (comma-separated string) */ get ISAUrl(): string; get ISAUrls(): string[]; /** Get the zone identifier set for this client. */ get zoneId(): string; /** Get the server to be controlled by this client. */ get serverId(): number | undefined; /** Set the server to be controlled by this client. */ setServerId(serverId: number | undefined): Promise<void>; /** * List details of all zones the ISA Manager is connected to. * @returns Details of zones all connected zones. */ getZones(): Promise<Q.ZoneInfo[]>; /** * Get a list of all servers availabe within a zone. * @param zoneId Zone identifier. Omit for `default`. * @returns Details of all the servers within a zone. */ getServers(zoneId?: string): Promise<Q.ServerInfo[]>; /** Return the (possibly cached) server */ getServer(disableCache?: boolean): Promise<Q.ServerInfo | null>; /** * Retrieve details of an existing port. * @param portId Identifier for the port to query. * @returns Status of the port, including timings and current playing offset. */ getPort(portId: string): Promise<Q.PortStatus | null>; /** * Create (allocate) a new port (logical device) and connect it to a channel * (physical SDI connector). * @param portId Name of the port to create. * @param channelId Number of the physical channel to connect the port to. * "returns" */ createPort(portId: string, channelId: number): Promise<Q.PortInfo>; /** * Release (remove) an allocated port. This allows other applications to grab the * associated channels. * @param portId Identifier of port to remove. * @returns Reported status of the removal. */ releasePort(portId: string): Promise<Q.ReleaseStatus>; /** * Reset a port, removing all fragments and resetting the playhead of the port. * The port persists after reset, maintaining ownership of its associated channels. * @returns Status of the release. */ resetPort(portId: string): Promise<Q.ReleaseStatus>; /** * Get infomation about a clip. * @param clipId Identifier for the clip to query. * @returns Resolves with clip details or `null` if the clip is not found. */ getClip(clipId: number): Promise<Q.ClipData | null>; /** * Search for a clip using search query parameters, e.g. `{ Title: 'Trump loses hair' }` * @param searchQuery Details of the requested search. * @returns A list of zero or more search summaries, one for each matching clip. */ searchClip(searchQuery: ClipSearchQuery): Promise<Q.ClipDataSummary[]>; /** * Get all the fragments associated with a clip. A clip is a collection of * disk fragments. These fragments must be loaded onto a port to so that a clip * may be played. * @param clipId Identifier of the clip to retrieve the fragments for. * @returns Collection of server fragments that make the requested clip. */ getClipFragments(clipId: number): Promise<Q.ServerFragments>; /** * Time-bounded request for clip fragments. * @param clipId Identifier of the clip to retrieve the fragments for. * @param inPoint Offset defining the start boundary for clips to be queried. * @param outPoint Offset defining the end boundary for clips to be queried. * @returns Collection of fragments that are contained within or overlap the given * time boundary. */ getClipFragments(clipId: number, inPoint: number, outPoint: number): Promise<Q.ServerFragments>; /** * Load the given fragments onto a port. * @param portId Name of the port to load fragments onto. * @param fragments Fragments to load. * @param offset Specify an offset from that specified in the fragment to load the fragment. * @returns Status of the port load request. */ loadFragmentsOntoPort(portId: string, fragments: Q.ServerFragmentTypes[], offset?: number): Promise<Q.PortLoadStatus>; /** Query the port for which fragments are loaded. */ getFragmentsOnPort(portId: string, rangeStart?: number, rangeEnd?: number): Promise<Q.ServerFragments>; /** * Start playing on a port at its current offset. * @param portId Name of the port to press play on. * @throws If the play operation was successful. */ portPlay(portId: string): Promise<Q.TriggerResult>; /** * Stop (pause) playback on a port. If `stopAtFrame` is provided, the playback * will stop at the frame specified. Otherwise playback will be paused now. * @param portId Name of the port to pause. * @param stopAtFrame Optional frame-in-the-future at which to stop. * @throws If the pause operation was not successful. */ portStop(portId: string, stopAtFrame?: number): Promise<Q.TriggerResult>; /** Jump directly to a frame. This might cause flicker on the output, as the frames * haven't been preloaded. * @param portId Name of port to jump on. * @param jumpToFrame Offset of the jump-to point. * @throws If the jump was not successful. */ portHardJump(portId: string, jumpToFrame?: number): Promise<Q.JumpResult>; /** * Prepare a jump to a frame. This ensures that those frames are preloaded and ready * to play. * @param portId Name of the port to prepare a jump on. * @param jumpToFrame Offset to set a jump point to. * @throws If setting the jump was not successful. */ portPrepareJump(portId: string, jumpToFrame?: number): Promise<Q.JumpResult>; /** * After preparing a jump, trigger the jump. * @portId Name of the port to trigger a jump on. * @throws If the jump was not successful. */ portTriggerJump(portId: string): Promise<Q.TriggerResult>; /** * Clear all fragments from a port. * If rangeStart and rangeEnd is provided, will clear the fragments for that time range. * If not, the fragments up until (but not including) the playhead, will be cleared. * * _Dragons_: Including the current offset or end of data inside the range can lead to * unexpected behaviour. * @param portId Name of the port to clear fragments from. * @param rangeStart Start of range to clear fragments from. * @param rangeEnd End range to clear fragments to. * @returns Details of how much was wiped. * @throws If the fragments were not wiped. */ portClearFragments(portId: string, rangeStart?: number, rangeEnd?: number): Promise<Q.WipeResult>; /** * Set the ports that are monitored for changes. * @param monitorPorts Dictionary of ports monitored for status change. */ setMonitoredPorts(monitorPorts: MonitorPorts): void; /** * Request that the Quantel gateway kills itself. * If running in Docker configured to auto-restart, calling this method will * cause the gateway to automatically restart. */ kill(): Promise<void>; /** * Request a clone of a clip, either between zones or between servers in the same zone. * The target zone ID is that of the servers the request is sent to. * @param zoneID Source zone ID, for inter-zone copies only. Otherwise `undefined`. * @param clipID Identifier for the source clip. * @param poolID Target pool identifier. * @param priority Priority level, a value between 0 (low) and 15 (high). Default is 8 (standard). * @param history For inter-zone cloning, should provenance be carried along with copy? Default is `true`. * @returns Details of the copy, including a `copyID` clip identifier for the target copy. */ copyClip(zoneID: number | undefined, clipID: number, poolID: number, priority?: number, history?: boolean): Promise<Q.CloneResult>; /** * Requests details of an ongoing or completed copy operation. * Note that if the copy completed some time ago or an associated copy operation * did not exist, this will throw a _Not Found_ exception. * @param copyID Identifier of the target clip. * @returns Details of the progress of the copy. */ getCopyRemaining(copyID: number): Promise<Q.CopyProgress>; /** * Get the details of all ongoing copy operations. * @returns List of all ongoing copy operations. */ getAllCopyOperations(): Promise<Q.CopyProgress[]>; getHTTPAgents(): Readonly<{ http: HTTPAgent; https: HTTPSAgent; }>; private sendServer; private sendZone; private sendBase; private sendRaw; private sendRawWithTimeout; private urlQuery; /** * If the response is an error, instead throw the error instead of returning it */ private _ensureGoodResponse; private _isAnErrorResponse; private _isNotFoundAThing; private get _formattedISAUrl(); } export interface QuantelErrorResponse { status: number; message: string; stack: string; } export type Optional<T> = { [K in keyof T]?: T[K]; }; export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>; /** * Specify a search query with a list of all properties that must be matched. * Propeprties may include a wildcard `*` to match one or more characters and * other [MySQL boolean full-text searches](https://dev.mysql.com/doc/refman/8.0/en/fulltext-boolean.html). */ export interface ClipSearchQuery { /** Limit the maximum number of clips returned */ limit?: number; /** Unique identifier for the clip in this zone. */ ClipID?: number; /** Globally-unique identifier for the clip. */ ClipGUID?: string; /** Source clip that this clip is a clone of. */ CloneID?: number; /** Date and time that the clip was considered complete. */ Completed?: string; /** Date and time that the clip was created. */ Created?: string; /** Description of the clip. */ Description?: string; /** Number of frames in the clip. Will be a number-as-a-string when knwon. */ Frames?: string; /** Clip owner. */ Owner?: string; /** Disk pool storage location for the clip. */ PoolID?: number; /** Title of the clip. */ Title?: string; Category?: string; CloneZone?: number; Destination?: number; Expiry?: string; HasEditData?: number; Inpoint?: number; JobID?: number; Modified?: string; NumAudTracks?: number; Number?: number; NumVidTracks?: number; Outpoint?: number; PlayAspect?: string; PublishedBy?: string; Register?: string; Tape?: string; Template?: number; UnEdited?: number; PlayMode?: string; Division?: string; AudioFormats?: string; VideoFormats?: string; Protection?: string; VDCPID?: string; PublishCompleted?: string; [index: string]: string | number | undefined; } /** * Dictionatu of ports monitored for status changes. */ export interface MonitorPorts { /** Name of the ports being monitored. */ [portId: string]: { /** Phyiscal channels (SDI ports) controlled by the port. */ channels: number[]; }; } //# sourceMappingURL=quantelGateway.d.ts.map