VideoSource
Video source
General class of video capture objects providing functionality to grab images from various sources. It implements basic interfaces like setup, start, stop of the video capture, and grabbing of frames. Internally utilizes ImageBuffer as storages.
Extends
Section titled “Extends”EventEmitterT
<CaptureEvents
>
Extended by
Section titled “Extended by”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new VideoSource():
VideoSource
Constructor
Returns
Section titled “Returns”VideoSource
Overrides
Section titled “Overrides”Properties
Section titled “Properties”aspectRatio?
Section titled “aspectRatio?”
protected
optional
aspectRatio:number
Aspect ratio
buffer
Section titled “buffer”buffer:
ImageBuffer
Context of original stream
captureTime
Section titled “captureTime”captureTime:
number
=0
Timestamp of the last captured frame
clipRect?
Section titled “clipRect?”
protected
optional
clipRect:ClipRect
Clipping rectangle
sizeMax?
Section titled “sizeMax?”
protected
optional
sizeMax:number
Maximum capture resolutions
transpose?
Section titled “transpose?”
protected
optional
transpose:boolean
Transpose frames
Methods
Section titled “Methods”addListener()
Section titled “addListener()”addListener<
E
>(event
,listener
):this
Adds the listener function to the end of the listeners array
Type Parameters
Section titled “Type Parameters”E
extends "resize"
Parameters
Section titled “Parameters”E
The name of the event
listener
Section titled “listener”CaptureEvents
[E
]
The callback function
Returns
Section titled “Returns”this
This EventEmitter
Inherited from
Section titled “Inherited from”capture()
Section titled “capture()”capture():
boolean
Grab the next video frame
VideoSource grabs the static image permanently stored in embedded ImageBuffer object.
Returns
Section titled “Returns”boolean
True if next frame was available and grabbed
dispose()
Section titled “dispose()”dispose():
void
Dispose video source object
Returns
Section titled “Returns”void
emit()
Section titled “emit()”emit<
E
>(event
, …args
):boolean
Synchronously calls each of the listeners registered for the event
Type Parameters
Section titled “Type Parameters”E
extends "resize"
Parameters
Section titled “Parameters”E
The name of the event
…Args
<CaptureEvents
[E
]>
Arguments passed to the listeners
Returns
Section titled “Returns”boolean
True if the event had listeners, False otherwise
Inherited from
Section titled “Inherited from”eventNames()
Section titled “eventNames()”eventNames(): (
string
|symbol
)[]
List of emitter’s events
Returns
Section titled “Returns”(string
| symbol
)[]
List of emitter’s events
Inherited from
Section titled “Inherited from”getMaxListeners()
Section titled “getMaxListeners()”getMaxListeners():
number
Maximum number of listeners per event
Returns
Section titled “Returns”number
Maximum number of listeners per event
Inherited from
Section titled “Inherited from”listenerCount()
Section titled “listenerCount()”listenerCount<
E
>(event
):number
The number of listeners listening to the event
Type Parameters
Section titled “Type Parameters”E
extends "resize"
Parameters
Section titled “Parameters”E
The name of the event
Returns
Section titled “Returns”number
Number of listeners
Inherited from
Section titled “Inherited from”listeners()
Section titled “listeners()”listeners<
E
>(event
):Function
[]
Copy of the array of listeners for the event
Type Parameters
Section titled “Type Parameters”E
extends "resize"
Parameters
Section titled “Parameters”E
The name of the event
Returns
Section titled “Returns”Function
[]
Copy of the listeners array
Inherited from
Section titled “Inherited from”off<
E
>(event
,listener
):this
Removes the listener from the listener array for the event
Type Parameters
Section titled “Type Parameters”E
extends "resize"
Parameters
Section titled “Parameters”E
The name of the event
listener
Section titled “listener”CaptureEvents
[E
]
The callback function
Returns
Section titled “Returns”this
This EventEmitter
Inherited from
Section titled “Inherited from”on<
E
>(event
,listener
):this
Adds the listener function to the event
Type Parameters
Section titled “Type Parameters”E
extends "resize"
Parameters
Section titled “Parameters”E
The name of the event
listener
Section titled “listener”CaptureEvents
[E
]
The callback function
Returns
Section titled “Returns”this
This EventEmitter
Inherited from
Section titled “Inherited from”once()
Section titled “once()”once<
E
>(event
,listener
):this
Adds a one-time listener function for the event
Type Parameters
Section titled “Type Parameters”E
extends "resize"
Parameters
Section titled “Parameters”E
The name of the event
listener
Section titled “listener”CaptureEvents
[E
]
The callback function
Returns
Section titled “Returns”this
This EventEmitter
Inherited from
Section titled “Inherited from”pause()
Section titled “pause()”pause():
void
Pause video capture
Returns
Section titled “Returns”void
prependListener()
Section titled “prependListener()”prependListener<
E
>(event
,listener
):this
Adds the listener function to the beginning of the listeners array
Type Parameters
Section titled “Type Parameters”E
extends "resize"
Parameters
Section titled “Parameters”E
The name of the event
listener
Section titled “listener”CaptureEvents
[E
]
The callback function
Returns
Section titled “Returns”this
This EventEmitter
Inherited from
Section titled “Inherited from”prependOnceListener()
Section titled “prependOnceListener()”prependOnceListener<
E
>(event
,listener
):this
Adds a one-time listener function to the beginning of the listeners array
Type Parameters
Section titled “Type Parameters”E
extends "resize"
Parameters
Section titled “Parameters”E
The name of the event
listener
Section titled “listener”CaptureEvents
[E
]
The callback function
Returns
Section titled “Returns”this
Inherited from
Section titled “Inherited from”EventEmitterT
.prependOnceListener
ratio()
Section titled “ratio()”ratio():
number
Aspect ratio of the video stream
Returns
Section titled “Returns”number
Aspect ratio of the video stream
rawListeners()
Section titled “rawListeners()”rawListeners<
E
>(event
):Function
[]
Copy of the array of listeners for the event including wrappers
Type Parameters
Section titled “Type Parameters”E
extends "resize"
Parameters
Section titled “Parameters”E
The name of the event
Returns
Section titled “Returns”Function
[]
Copy of the listeners array
Inherited from
Section titled “Inherited from”removeAllListeners()
Section titled “removeAllListeners()”removeAllListeners<
E
>(event?
):this
Removes all listeners, or those of the specified event
Type Parameters
Section titled “Type Parameters”E
extends "resize"
Parameters
Section titled “Parameters”event?
Section titled “event?”E
The name of the event
Returns
Section titled “Returns”this
This EventEmitter
Inherited from
Section titled “Inherited from”EventEmitterT
.removeAllListeners
removeListener()
Section titled “removeListener()”removeListener<
E
>(event
,listener
):this
Removes the specified listener from the listener array
Type Parameters
Section titled “Type Parameters”E
extends "resize"
Parameters
Section titled “Parameters”E
The name of the event
listener
Section titled “listener”CaptureEvents
[E
]
The callback function
Returns
Section titled “Returns”this
This EventEmitter
Inherited from
Section titled “Inherited from”reset()
Section titled “reset()”reset():
void
Reset video capture
After reset() capture may be started again only after setup().
Returns
Section titled “Returns”void
setMaxListeners()
Section titled “setMaxListeners()”setMaxListeners(
n
):this
Sets maximum number of listeners per event
Parameters
Section titled “Parameters”number
Maximum number of listeners
Returns
Section titled “Returns”this
This EventEmitter
Inherited from
Section titled “Inherited from”setup()
Section titled “setup()”setup(
params?
):Promise
<boolean
>
Setup video source
Sets up capture, overridden for particular video source.
Video source can be setup by simplified VideoParams
opening default front/rear camera with provided resolution.
Additional fine-grained MediaStreamConstraints can be passed
via opts
field providing the most flexible way to setup
video stream (for example, by requesting specific deviceId).
Stream constraints have higher priority than rest or params.
Another options are an external MediaStream allowing custom
video sources (e.g. remote stream) or a media file defined
by url or FileParams that allows to limit maximum
capture size in cases resolution is too big for a device.
Default implementation sets video resolution according to
size in VideoParams or 1920x1080 as the fallback.
It captures static image, canvas is filled by white color.
Parameters
Section titled “Parameters”params?
Section titled “params?”Parameters of video capture
Returns
Section titled “Returns”Promise
<boolean
>
Promise resolved to the status of setup when done
size()
Section titled “size()”size():
Size
Resolution of the video stream
Returns
Section titled “Returns”Resolution of the video stream
start()
Section titled “start()”start():
Promise
<void
>
Start video capture
Video capture can be started only after successful setup().
Returns
Section titled “Returns”Promise
<void
>
Promise resolved when capture is started
updateSize()
Section titled “updateSize()”
protected
updateSize(size
):void
Update callback on video resize
Parameters
Section titled “Parameters”New size of the video stream
Returns
Section titled “Returns”void