Skip to main content
Version: 12 Dec 2024

NativeBindings

See ml_media_recorder.h for additional comments.

Inherits from:
MagicLeapNativeBindings

Public Methods

MLResult.Code MLMediaRecorderCreate

Create a new

public MLResult.Code MLMediaRecorderCreate(
out ulong outHandle
)

Parameters

TypeNameDescription
out ulongoutHandle

MLResult.Code MLMediaRecorderDestroy

Destroy a MediaRecorder object.

public MLResult.Code MLMediaRecorderDestroy(
ulong handle
)

Parameters

TypeNameDescription
ulonghandle

MLResult.Code MLMediaRecorderGetInputSurface

Gets the input surface to record from when using SURFACE video source. May only be called after MLMediaRecorderPrepare. Frames rendered to the producer before MLMediaRecorderStart() is called will be discarded. When using an input surface, there are no accessible input buffers, as buffers are automatically passed from the other modules to this surface. The returned input surface can also be passed as a destination surface to - a video/mixed reality video capture session when calling MLCameraPrepareCapture(). Captured raw video frames will be consumed directly as input to an encoder without copying. Caller of this API should release the surface using #MLMediaRecorderReleaseInputSurface() on the Surface handle after usage.

public MLResult.Code MLMediaRecorderGetInputSurface(
ulong handle,
out ulong outInputSurfaceHandle
)

Parameters

TypeNameDescription
ulonghandle
out ulongoutInputSurfaceHandle

MLResult.Code MLMediaRecorderGetMaxAmplitude

Returns the maximum absolute amplitude that was sampled since the last call to this method. Call this only after the MLMediaRecorderSetAudioSource().

public MLResult.Code MLMediaRecorderGetMaxAmplitude(
ulong handle,
out int MaxAmp
)

Parameters

TypeNameDescription
ulonghandle
out intMaxAmp

MLResult.Code MLMediaRecorderPrepare

Prepares the recorder to begin capturing and encoding data for input mediaformat. This method must be called after setting up the desired audio and video sources, encoders, but before start().

public MLResult.Code MLMediaRecorderPrepare(
ulong handle,
ulong formatHandle
)

Parameters

TypeNameDescription
ulonghandle
ulongformatHandle

MLResult.Code MLMediaRecorderReleaseInputSurface

Release the Surface that was returned by #MLMediaRecorderGetInputSurface.

public MLResult.Code MLMediaRecorderReleaseInputSurface(
ulong handle,
ulong inputSurfaceHandle
)

Parameters

TypeNameDescription
ulonghandle
ulonginputSurfaceHandle

MLResult.Code MLMediaRecorderReset

Restarts the MediaRecorder to its idle state. After calling this method, you will have to configure it again as if it had just been constructed.

public MLResult.Code MLMediaRecorderReset(
ulong handle
)

Parameters

TypeNameDescription
ulonghandle

MLResult.Code MLMediaRecorderSetAudioEncoder

Sets the audio encoder to be used for recording. If this method is not called, the output file will not contain an audio track. Call this after MLMediaRecorderSetOutputFormat() and before MLMediaRecorderPrepare().

public MLResult.Code MLMediaRecorderSetAudioEncoder(
ulong handle,
AudioEncoder inAudioEncoder
)

Parameters

TypeNameDescription
ulonghandle
AudioEncoderinAudioEncoderAvailable audio encoder formats

MLResult.Code MLMediaRecorderSetAudioSource

Set MediaRecorder audio source. cannot be called twice (without calling MLMediaRecorderReset() in between) because it triggers internal initialization.

public MLResult.Code MLMediaRecorderSetAudioSource(
ulong handle,
AudioSource inAudioSource
)

Parameters

TypeNameDescription
ulonghandle
AudioSourceinAudioSourceAudio source to put in the recorded media.

MLResult.Code MLMediaRecorderSetEventCallbacks

Sets the MediaRecorderListener object that will receive MediaRecorder notifications.

public MLResult.Code MLMediaRecorderSetEventCallbacks(
ulong handle,
ref MLMediaRecorderEventCallbacks callbacks,
IntPtr data
)

Parameters

TypeNameDescription
ulonghandle
ref MLMediaRecorderEventCallbackscallbacksComment Needed!
IntPtrdata

MLResult.Code MLMediaRecorderSetGeoLocation

Sets the GEO location for recording.

public MLResult.Code MLMediaRecorderSetGeoLocation(
ulong handle,
long inLatitude10000,
long inLongitude10000
)

Parameters

TypeNameDescription
ulonghandle
longinLatitude10000
longinLongitude10000

MLResult.Code MLMediaRecorderSetMaxDuration

Sets the maximum duration (in ms) of the recording session. Call this after MLMediaRecorderSetOutputFormat() and before MLMediaRecorderPrepare(). After recording reaches the specified duration, a notification will be sent via the callback with a MLMediaRecorderInfo code of MLMediaRecorderInfo_MaxDurationReached and recording will be stopped. Stopping happens asynchronously, there is no guarantee that the recorder will have stopped by the time the listener is notified.

public MLResult.Code MLMediaRecorderSetMaxDuration(
ulong handle,
int inMaxDurationMsec
)

Parameters

TypeNameDescription
ulonghandle
intinMaxDurationMsec

MLResult.Code MLMediaRecorderSetMaxFileSize

Sets the maximum file size (in bytes) of the recording session.

public MLResult.Code MLMediaRecorderSetMaxFileSize(
ulong handle,
long inMaxFileSize
)

Parameters

TypeNameDescription
ulonghandle
longinMaxFileSize

MLResult.Code MLMediaRecorderSetOutputFileForFD

Pass in the file descriptor of the file to be written. Call this after MLMediaRecorderSetOutputFormat() but before MLMediaRecorderprepare().

public MLResult.Code MLMediaRecorderSetOutputFileForFD(
ulong handle,
int Fd
)

Parameters

TypeNameDescription
ulonghandle
intFd

MLResult.Code MLMediaRecorderSetOutputFileForPath

Sets the path of the output file to be produced. Call this after MLMediaRecorderSetOutputFormat() but before MLMediaRecorder prepare().

public MLResult.Code MLMediaRecorderSetOutputFileForPath(
ulong handle,
string path
)

Parameters

TypeNameDescription
ulonghandle
stringpath

MLResult.Code MLMediaRecorderSetOutputFormat

Sets the format of the output file produced during recording.

public MLResult.Code MLMediaRecorderSetOutputFormat(
ulong handle,
OutputFormat inFormat
)

Parameters

TypeNameDescription
ulonghandle
OutputFormatinFormatPossible output formats

MLResult.Code MLMediaRecorderSetVideoEncoder

Sets the video encoder to be used for recording. If this method is not called, the output file will not contain an video track. Call this after MLMediaRecorderSetOutputFormat() and before MLMediaRecorderPrepare(). The video source is always set to camera by default.

public MLResult.Code MLMediaRecorderSetVideoEncoder(
ulong handle,
VideoEncoder inVideoEncoder
)

Parameters

TypeNameDescription
ulonghandle
VideoEncoderinVideoEncoderAvailable video encoder formats

MLResult.Code MLMediaRecorderSetVideoSource

Sets MediaRecorder default video source. cannot be called twice (without calling MLMediaRecorderReset() in between) because it triggers internal initialization. Current implementation supports only camera as video source from

public MLResult.Code MLMediaRecorderSetVideoSource(
ulong handle,
VideoSource inVideoSource
)

Parameters

TypeNameDescription
ulonghandle
VideoSourceinVideoSourceVideo source to put in the recorded media.

MLResult.Code MLMediaRecorderStart

Begins capturing and encoding data to the specified file. Call this after MLMediaRecorderPrepare(). The apps should not start another recording session during recording.

public MLResult.Code MLMediaRecorderStart(
ulong handle
)

Parameters

TypeNameDescription
ulonghandle

MLResult.Code MLMediaRecorderStop

Stops recording. Call this after MLMediaRecorderStart(). Once recording is stopped, you will have to configure it again as if it has just been constructed.

public MLResult.Code MLMediaRecorderStop(
ulong handle
)

Parameters

TypeNameDescription
ulonghandle

delegate void OnErrorDelegate

Callback whenever MediaRecorder received a general error message.

public delegate void OnErrorDelegate(
ulong handle,
ref MLMediaRecorderOnError error
)

Parameters

TypeNameDescription
ulonghandle
ref MLMediaRecorderOnErrorerrorWhen the error or info type is track specific, it has the following layout: The left-most 16-bit is meant for error or info type and the right-most 4-bit is meant for track id.

delegate void OnInfoDelegate

Callback whenever MediaRecorder received a general info/warning message.

public delegate void OnInfoDelegate(
ulong handle,
ref MLMediaRecorderOnInfo info
)

Parameters

TypeNameDescription
ulonghandle
ref MLMediaRecorderOnInfoinfoWhen the error or info type is track specific, it has the following layout: The left-most 16-bit is meant for error or info type and the right-most 4-bit is meant for track id.

delegate void OnTrackErrorDelegate

Callback whenever MediaRecorder received a track-related error message.

public delegate void OnTrackErrorDelegate(
ulong handle,
ref MLMediaRecorderOnError trackError
)

Parameters

TypeNameDescription
ulonghandle
ref MLMediaRecorderOnErrortrackErrorWhen the error or info type is track specific, it has the following layout: The left-most 16-bit is meant for error or info type and the right-most 4-bit is meant for track id.

delegate void OnTrackInfoDelegate

Callback whenever MediaRecorder received a track-related info/warning message.

public delegate void OnTrackInfoDelegate(
ulong handle,
ref MLMediaRecorderOnInfo trackInfo
)

Parameters

TypeNameDescription
ulonghandle
ref MLMediaRecorderOnInfotrackInfoWhen the error or info type is track specific, it has the following layout: The left-most 16-bit is meant for error or info type and the right-most 4-bit is meant for track id.