media-stream-player
Version:
Player built on top of media-stream-library
41 lines (40 loc) • 1.51 kB
TypeScript
import { XmlMessage, pipelines, utils } from 'media-stream-library';
/**
* Metadata handlers
*
* For video streams that also include ONVIF metadata,
* once can specify a parser + synced callback to be run
* whenever metadata occurs on the stream.
*
* The `parser` provided produces a scheduled message, that
* will be returned later through the `cb` synched callback,
* whenever the message is synchronized with the presentation.
*/
export interface MetadataXMLMessage extends XmlMessage {
readonly xmlDocument: XMLDocument;
}
export interface ScheduledMessage {
readonly ntpTimestamp: number | undefined;
readonly data: unknown;
}
export type MetadataParser = (msg: MetadataXMLMessage) => ScheduledMessage;
export type MetadataCallback = (msg: ScheduledMessage) => void;
export interface MetadataHandler {
/**
* A parser that will receive an XML message and should return
* a new message with at least an ntpTimestamp.
*/
readonly parser: MetadataParser;
/**
* A synchronized callback that will be called whenever the message
* produced by the parser is in sync with the video.
*/
readonly cb: MetadataCallback;
}
/**
* Attach ONVIF metadata handlers to a pipeline
*
* @param pipeline The (HTML5 video) pipeline to modify
* @param handlers The handlers to deal with XML data
*/
export declare const attachMetadataHandler: (pipeline: pipelines.Html5VideoPipeline, { parser, cb }: MetadataHandler) => utils.Scheduler<ScheduledMessage>;