Skip to main content
Version: 20 Mar 2024

MLCameraVideoSource

Demonstrates using the MLCamera as an app defined video source.

Inherits from:
AppDefinedVideoSource,
AppDefinedSource,
Track

Public Methods

delegate void CaptureStatusChangedDelegate

public delegate void CaptureStatusChangedDelegate(
bool isDestroying
)

Parameters

TypeNameDescription
boolisDestroying

MLCameraVideoSource CreateLocal

Developer should've created the MLCamera object, queried the stream capabilities, selected one & populated a MLCamera.CaptureConfig object with it. Developers are NOT required to setup any native surface in the capture config. The CaptureConfig should contain at a minimum a StreamConfig with CaptureType Video in the first array position, and optionally a second StreamConfig with CaptureType Preview if the call app wishes to display camera preview. Developer should NOT have called MLCamera.PrepareCapture() or any other capture functions on the camera object.

public static MLCameraVideoSource CreateLocal(
MLCameraBase camera,
MLCamera.CaptureConfig captureConfig,
out MLResult result,
string trackId ="",
Renderer localRenderer =null,
bool nativeBuffers =true,
bool handlePause =true
)

Parameters

TypeNameDescription
MLCameraBasecameraThe MLCamera used to provide the video source for the Track.
MLCamera.CaptureConfigcaptureConfigThe CaptureConfig should be configured prior to calling. The StreamConfigs array must contain a StreamConfig with CaptureType Video at index 0 and optionally a second with CaptureType Preview to enable rendering the MLCamera.PreviewTexture
out MLResultresultThe MLResult generated by attempting to initialize this AppDefinedVideoSource.
stringtrackIdAn optional track ID
RendererlocalRendererOptional Unity Renderer component configured in the scene to display the MLCamera.PreviewTexture.
boolnativeBuffers
boolhandlePause

Returns:


MLCameraVideoSource

public MLCameraVideoSource(
string trackId
)

Parameters

TypeNameDescription
stringtrackId

Protected Methods

OnApplicationPause

Reacts to when the application is paused (after subscribing to MLDevice). Override for custom behavior.

protected virtual override void OnApplicationPause(
bool pause
)

Parameters

TypeNameDescription
boolpauseTrue if paused.

Reimplements: OnApplicationPause


OnSourceDestroy

Instance method that is called when the source is destroyed via MLWebRTC.MediaStream.Track.DestroyLocal() .

protected virtual override void OnSourceDestroy()

Reimplements: OnSourceDestroy


OnSourceSetEnabled

Instance method that is called when the source is enabled or disabled via MLWebRTC.MediaStream.Track.SetEnabled()

protected virtual override void OnSourceSetEnabled(
bool enabled
)

Parameters

TypeNameDescription
boolenabledTrue if enabled.

Reimplements: OnSourceSetEnabled


Public Attributes

IsCapturing


public bool IsCapturing => isCapturing;


Public Events

OnCaptureStatusChanged

public CaptureStatusChangedDelegate OnCaptureStatusChanged()