CameraMediaSource class
A media source that captures the video feed of a camera on the device and outputs it.
Signature:
export declare class CameraMediaSource extends O3hMediaSource
Extends: O3hMediaSource
Remarks
Use MediaSourceManager.createCameraSource() to create an instance of this class.
Methods
Method | Modifiers | Description |
---|---|---|
getCameraRunningStateUpdates() | Returns a subject the provides the running state of the camera for this media source. | |
requestResolutionScale(resolutionScale) | Requests to capture the camera feed at a new resolution scale. | |
setCameraType(cameraType) | Changes the position of the camera on the device that is captured by this media source. | |
setFallbackEnabled(enabled) | Enables or disables the a fallback image that is shown when the camera is not running. | |
setFallbackMicrophoneEnabled(enabled) | Enables or disables microphone audio visualization for the fallback display when the camera is not running. | |
startCamera() | Starts camera capture for this media source. | |
stopCamera() | Stops camera capture for this media source. |
CameraMediaSource.getCameraRunningStateUpdates() method
Returns a subject the provides the running state of the camera for this media source.
Signature:
getCameraRunningStateUpdates(): Subject<boolean>;
Returns:
Subject<boolean>
A subject that emits true when this media source is capturing the camera feed, and false when the camera is not being captured and a fallback is being displayed.
CameraMediaSource.requestResolutionScale() method
Requests to capture the camera feed at a new resolution scale.
Signature:
requestResolutionScale(resolutionScale: Enum<typeof CameraResolutionScale>): Promise<void>;
Parameters
Parameter | Type | Description |
---|---|---|
resolutionScale | Enum<typeof CameraResolutionScale> |
Returns:
Promise<void>
A promise that resolves when the switch to the new resolution is complete.
Remarks
The actual resolution used may be different from the requested one, depending on the resolution requested by other media sources that capture from the same camera position as only one resolution scale can be used by a particular camera at a time.
If this is called after calling MediaSourceManager.lockCameras(), do not await the returned promise without calling MediaSourceManager.unlockCameras() first, otherwise it will never resolve!
CameraMediaSource.setCameraType() method
Changes the position of the camera on the device that is captured by this media source.
Signature:
setCameraType(cameraType: Enum<typeof CameraType>): Promise<void>;
Parameters
Parameter | Type | Description |
---|---|---|
cameraType | Enum<typeof CameraType> |
Returns:
Promise<void>
A promise that resolves when the switch to the new camera is complete.
Remarks
If this is called after calling MediaSourceManager.lockCameras(), do not await the returned promise without calling MediaSourceManager.unlockCameras() first, otherwise it will never resolve!
CameraMediaSource.setFallbackEnabled() method
Enables or disables the a fallback image that is shown when the camera is not running.
Signature:
setFallbackEnabled(enabled: boolean): void;
Parameters
Parameter | Type | Description |
---|---|---|
enabled | boolean | True to enable the fallback, false to disable. |
Returns:
void
Remarks
The fallback used is a visualization of the microphone audio or static user avatar image, depending on whether the microphone is enabled for this source (see CameraMediaSourceConfig.fallbackMicrophoneEnabled and CameraMediaSource.setFallbackMicrophoneEnabled()) and whether the module has permission to use it.
This is enabled by default unless disabled in the CameraMediaSourceConfig or by calling this method.
If the fallback is disabled nothing is displayed when the camera is not running.
CameraMediaSource.setFallbackMicrophoneEnabled() method
Enables or disables microphone audio visualization for the fallback display when the camera is not running.
Signature:
setFallbackMicrophoneEnabled(enabled: boolean): void;
Parameters
Parameter | Type | Description |
---|---|---|
enabled | boolean |
Returns:
void
Remarks
This does not affect microphone audio capture by video recorders created using O3hMediaSource.createVideoRecorder() as microphone capture is configured separately for the recorder.
This is true by default unless disabled in the CameraMediaSourceConfig or by calling this method.
CameraMediaSource.startCamera() method
Starts camera capture for this media source.
Signature:
startCamera(): Promise<void>;
Returns:
Promise<void>
A promise that resolves when the camera is turned on and camera capture has started for this source.
Remarks
If this is called after calling MediaSourceManager.lockCameras(), do not await the returned promise without calling MediaSourceManager.unlockCameras() first, otherwise it will never resolve!
CameraMediaSource.stopCamera() method
Stops camera capture for this media source.
Signature:
stopCamera(): void;
Returns:
void
Remarks
Calling this will not affect other media source that are capturing from the same camera position. The camera will only be turned off when all active media sources have stopped capturing.
Updated 12 months ago