Skip to main content
Version: 12 Dec 2024

Media Recorder

APIs for MediaMuxer to facilitate muxing of elementary streams. More...

Classes

Name
structMLMediaMuxerSampleData
Data type that encapsulates sample data to be written in to MLMediaMuxer.
structMLMediaRecorderOnInfo
structMLMediaRecorderOnError
structMLMediaRecorderEventCallbacks

Types

Name
typedef struct MLMediaMuxerSampleDataMLMediaMuxerSampleData
Data type that encapsulates sample data to be written in to MLMediaMuxer.
typedef struct MLMediaRecorderOnInfoMLMediaRecorderOnInfo
typedef struct MLMediaRecorderOnErrorMLMediaRecorderOnError
typedef struct MLMediaRecorderEventCallbacksMLMediaRecorderEventCallbacks

Enums

Name
enumMLMediaMuxerOutputFormat
{
MLMediaMuxerOutputFormat_MPEG4 = 0,
MLMediaMuxerOutputFormat_WEBM = 1,
MLMediaMuxerOutputFormat_3GPP = 2,
MLMediaMuxerOutputFormat_HEIF = 3,
MLMediaMuxerOutputFormat_OGG = 4,
MLMediaMuxerOutputFormat_Ensure32Bits = 0x7FFFFFFF
}
Output formats for MediaMuxer.
enumMLMediaRecorderVideoSource
{
MLMediaRecorderVideoSource_Camera = 1,
MLMediaRecorderVideoSource_Ensure32Bits = 0x7FFFFFFF
}
enumMLMediaRecorderAudioSource
{
MLMediaRecorderAudioSource_Voice = 0,
MLMediaRecorderAudioSource_World = 1,
MLMediaRecorderAudioSource_Virtual = 2,
MLMediaRecorderAudioSource_Mixed = 3,
MLMediaRecorderAudioSource_Ensure32Bits = 0x7FFFFFFF
}
enumMLMediaRecorderEvent
{
MLMediaRecorderEvent_Error = 1,
MLMediaRecorderEvent_Info = 2,
MLMediaRecorderTrackEvent_Error = 100,
MLMediaRecorderTrackEvent_Info = 101,
MLMediaRecorderTrackEvent_Ensure32Bits = 0x7FFFFFFF
}
enumMLMediaRecorderInfo
{
MLMediaRecorderInfo_Unknown = 1,
MLMediaRecorderInfo_MaxDurationReached = 800,
MLMediaRecorderInfo_MaxFileSizeReached = 801,
MLMediaRecorderInfo_MaxFileSizeApproaching = 802,
MLMediaRecorderTrackInfo_CompletionStatus = 1000,
MLMediaRecorderTrackInfo_ProgressInTime = 1001,
MLMediaRecorderTrackInfo_Type = 1002,
MLMediaRecorderTrackInfo_DurationMs = 1003,
MLMediaRecorderTrackInfo_MaxChunkDurationMs = 1004,
MLMediaRecorderTrackInfo_EncodedFrames = 1005,
MLMediaRecorderTrackInfo_InterChunkTimeUs = 1006,
MLMediaRecorderTrackInfo_InitialDelayMs = 1007,
MLMediaRecorderTrackInfo_StartOffsetMs = 1008,
MLMediaRecorderTrackInfo_DataKBytes = 1009,
MLMediaRecorderTrackInfo_Ensure32Bits = 0x7FFFFFFF
}
enumMLMediaRecorderError
{
MLMediaRecorderError_Unknown = 1,
MLMediaRecorderError_ServerDied = 2,
MLMediaRecorderTrackError_General = 100,
MLMediaRecorderError_VideoNoSyncFrame = 200,
MLMediaRecorderTrackError_Ensure32Bits = 0x7FFFFFFF
}
Video recorder error types.
enumMLMediaRecorderOutputFormat
{
MLMediaRecorderOutputFormat_DEFAULT = 0,
MLMediaRecorderOutputFormat_THREE_GPP = 1,
MLMediaRecorderOutputFormat_MPEG_4 = 2,
MLMediaRecorderOutputFormat_AMR_NB = 3,
MLMediaRecorderOutputFormat_AMR_WB = 4,
MLMediaRecorderOutputFormat_AAC_ADIF = 5,
MLMediaRecorderOutputFormat_AAC_ADTS = 6,
MLMediaRecorderOutputFormat_RTP_AVP = 7,
MLMediaRecorderOutputFormat_MPEG2TS = 8,
MLMediaRecorderOutputFormat_WEBM = 9,
MLMediaRecorderOutputFormat_HEIF = 10,
MLMediaRecorderOutputFormat_OGG = 11,
MLMediaRecorderOutputFormat_Ensure32Bits = 0x7FFFFFFF
}
enumMLMediaRecorderVideoEncoder
{
MLMediaRecorderVideoEncoder_Default = 0,
MLMediaRecorderVideoEncoder_H263 = 1,
MLMediaRecorderVideoEncoder_H264 = 2,
MLMediaRecorderVideoEncoder_MPEG_4_SP = 3,
MLMediaRecorderVideoEncoder_VP8 = 4,
MLMediaRecorderVideoEncoder_HEVC = 5,
MLMediaRecorderVideoEncoder_Ensure32Bits = 0x7FFFFFFF
}
enumMLMediaRecorderAudioEncoder
{
MLMediaRecorderAudioEncoder_Default = 0,
MLMediaRecorderAudioEncoder_AMR_NB = 1,
MLMediaRecorderAudioEncoder_AMR_WB = 2,
MLMediaRecorderAudioEncoder_AAC = 3,
MLMediaRecorderAudioEncoder_HE_AAC = 4,
MLMediaRecorderAudioEncoder_AAC_ELD = 5,
MLMediaRecorderAudioEncoder_VORBIS = 6,
MLMediaRecorderAudioEncoder_OPUS = 7,
MLMediaRecorderAudioEncoder_Ensure32Bits = 0x7FFFFFFF
}

Functions

Name
voidMLMediaMuxerSampleDataInit(MLMediaMuxerSampleData * inout_sampledata)
Initializes MLMediaMuxerSampleData with default values.
MLResultMLMediaMuxerCreate(MLHandle * out_handle)
Create a MLMediaMuxer instance.
MLResultMLMediaMuxerRelease(MLHandle media_muxer)
Release the MLMediaMuxer instance.
MLResultMLMediaMuxerGetSupportedOutputFormats(MLHandle media_muxer, const MLMediaMuxerOutputFormat out_format_list[], size_t out_format_list_size)
Get a list of all the supported Media Muxer Output Formats on the Platform.
MLResultMLMediaMuxerGetSupportedMimes(MLHandle media_muxer, MLMediaMuxerOutputFormat format, const char const out_mime_list[], size_t * out_mime_list_size)
Get a list of all the supported mime-types for a given Media Muxer Output Format on the Platform.
MLResultMLMediaMuxerConfigure(MLHandle media_muxer, MLMediaMuxerOutputFormat format, const char * path)
Configure the MLMediaMuxer for a given Output format with output path.
MLResultMLMediaMuxerAddTrack(MLHandle media_muxer, MLHandle media_format, size_t * out_track_index)
Add a track with given format information.
MLResultMLMediaMuxerSetOrientationHint(MLHandle media_muxer, int32_t degrees)
Set the orientation hint for output video playback.
MLResultMLMediaMuxerSetLocation(MLHandle media_muxer, float latitude, float longitude)
Set and store the geodata (latitude and longitude) in the output file.
MLResultMLMediaMuxerStart(MLHandle media_muxer)
Start muxing.
MLResultMLMediaMuxerWriteSampleData(MLHandle media_muxer, const MLMediaMuxerSampleData * data)
Writes an encoded sample into the muxer.
MLResultMLMediaMuxerStop(MLHandle media_muxer)
Stop muxing.
voidMLMediaRecorderEventCallbacksInit(MLMediaRecorderEventCallbacks * inout_callbacks)
Initializes MediaRecorderEventCallbacks with default values.
MLResultMLMediaRecorderCreate(MLHandle * out_handle)
Create a new MediaRecorder object.
MLResultMLMediaRecorderDestroy(MLHandle media_recorder)
Destroy a MediaRecorder object.
MLResultMLMediaRecorderSetOutputFileForFD(MLHandle media_recorder, int32_t fd)
Pass in the file descriptor of the file to be written.
MLResultMLMediaRecorderSetOutputFileForPath(MLHandle media_recorder, const char * path)
Sets the path of the output file to be produced.
MLResultMLMediaRecorderSetEventCallbacks(MLHandle media_recorder, const MLMediaRecorderEventCallbacks callbacks, void data)
Sets the MediaRecorderListener object that will receive MediaRecorder notifications.
MLResultMLMediaRecorderSetVideoSource(MLHandle media_recorder, MLMediaRecorderVideoSource in_video_source)
Sets MediaRecorder default video source.
MLResultMLMediaRecorderSetAudioSource(MLHandle media_recorder, MLMediaRecorderAudioSource in_audio_source)
Set MediaRecorder audio source.
MLResultMLMediaRecorderSetOutputFormat(MLHandle media_recorder, MLMediaRecorderOutputFormat in_format)
Sets the format of the output file produced during recording.
MLResultMLMediaRecorderSetVideoEncoder(MLHandle media_recorder, MLMediaRecorderVideoEncoder in_video_encoder)
Sets the video encoder to be used for recording.
MLResultMLMediaRecorderSetAudioEncoder(MLHandle media_recorder, MLMediaRecorderAudioEncoder in_audio_encoder)
Sets the audio encoder to be used for recording.
MLResultMLMediaRecorderSetMaxDuration(MLHandle media_recorder, int32_t in_max_duration_msec)
Sets the maximum duration (in ms) of the recording session.
MLResultMLMediaRecorderSetMaxFileSize(MLHandle media_recorder, int64_t in_max_file_size)
Sets the maximum filesize (in bytes) of the recording session.
MLResultMLMediaRecorderSetGeoLocation(MLHandle media_recorder, int64_t in_latitude10000, int64_t in_longitude10000)
Sets the GEO location for recording.
MLResultMLMediaRecorderPrepare(MLHandle media_recorder, MLHandle format)
Prepares the recorder to begin capturing and encoding data for input mediaformat.
MLResultMLMediaRecorderStart(MLHandle media_recorder)
Begins capturing and encoding data to the specified file.
MLResultMLMediaRecorderGetInputSurface(MLHandle media_recorder, MLHandle * out_input_surface_handle)
Gets the input surface to record from when using SURFACE video source.
MLResultMLMediaRecorderGetMaxAmplitude(MLHandle media_recorder, int32_t * inout_max_amp)
Returns the maximum absolute amplitude that was sampled since the last call to this method.
MLResultMLMediaRecorderStop(MLHandle media_recorder)
Stops recording.
MLResultMLMediaRecorderReleaseInputSurface(MLHandle media_recorder, MLHandle input_surface_handle)
Release the surface that was returned by MLMediaRecorderGetInputSurface.
MLResultMLMediaRecorderReset(MLHandle media_recorder)
Restarts the MediaRecorder to its idle state.

Attributes

Name
uint32_ttrack_id
MLMediaRecorderInfoinfo
intextra
void *data
uint32_ttrack_id
MLMediaRecorderErrorerror
intextra
void *data
uint32_tversion
void()(MLHandle media_recorder, const MLMediaRecorderOnInfo info)on_info
MediaRecorder received a general info/warning message.
void()(MLHandle media_recorder, const MLMediaRecorderOnInfo track_info)on_track_info
MediaRecorder received a track-related info/warning message.
void()(MLHandle media_recorder, const MLMediaRecorderOnError error)on_error
MediaRecorder received a general error message.
void()(MLHandle media_recorder, const MLMediaRecorderOnError track_error)on_track_error
MediaRecorder received a track-related error message.

Detailed Description

APIs for MediaMuxer to facilitate muxing of elementary streams.

APIs for video and auido recording.

Stringify the error codes returned by these APIs, call MLMediaResultGetString.

Stringify the error codes returned by these APIs, call MLMediaResultGetString.

Warning

Shared Object:

  • media_muxer.magicleap*

Shared Object:

  • media_recorder.magicleap*

Enums Documentation

MLMediaMuxerOutputFormat

EnumeratorValueDescription
MLMediaMuxerOutputFormat_MPEG40MP4 format.
MLMediaMuxerOutputFormat_WEBM1VP8/VORBIS data in a WEBM container.
MLMediaMuxerOutputFormat_3GPP23gpp format.
MLMediaMuxerOutputFormat_HEIF3HEIC data in a HEIF container.
MLMediaMuxerOutputFormat_OGG4Opus data in a OGG container.
MLMediaMuxerOutputFormat_Ensure32Bits0x7FFFFFFFEnsure enum is represented as 32 bits.

Output formats for MediaMuxer.

This enumarates list of all the possibly supported output formats for the muxer across all the releases/Platform.

Use MLMediaMuxerGetSupportedOutputFormats to query for all supported Output formats on the Platform.

API Level:

  • 20

MLMediaRecorderVideoSource

EnumeratorValueDescription
MLMediaRecorderVideoSource_Camera1Camera video source.
MLMediaRecorderVideoSource_Ensure32Bits0x7FFFFFFFEnsure enum is represented as 32 bits.

Media recorder video source.


MLMediaRecorderAudioSource

EnumeratorValueDescription
MLMediaRecorderAudioSource_Voice0Recording voice.
MLMediaRecorderAudioSource_World1Recording ambient sounds.
MLMediaRecorderAudioSource_Virtual2Recording digital sounds.
MLMediaRecorderAudioSource_Mixed3Mixed reality mode: digital + ambient.
MLMediaRecorderAudioSource_Ensure32Bits0x7FFFFFFFEnsure enum is represented as 32 bits.

Media recorder audio source.


MLMediaRecorderEvent

EnumeratorValueDescription
MLMediaRecorderEvent_Error1Media recorder error.
MLMediaRecorderEvent_Info2Media recorder info.
MLMediaRecorderTrackEvent_Error100Media recorder track error.
MLMediaRecorderTrackEvent_Info101Media recorder track info.
MLMediaRecorderTrackEvent_Ensure32Bits0x7FFFFFFFEnsure enum is represented as 32 bits.

Media recorder events.


MLMediaRecorderInfo

EnumeratorValueDescription
MLMediaRecorderInfo_Unknown1
MLMediaRecorderInfo_MaxDurationReached800Max duration of the clip is reached.
MLMediaRecorderInfo_MaxFileSizeReached801Max file size is reached.
MLMediaRecorderInfo_MaxFileSizeApproaching802Max file size is approaching.
MLMediaRecorderTrackInfo_CompletionStatus1000Next output file has started.The info about completion status.
MLMediaRecorderTrackInfo_ProgressInTime1001The info about progress in time.
MLMediaRecorderTrackInfo_Type1002Track info.
MLMediaRecorderTrackInfo_DurationMs1003The info about track duration.
MLMediaRecorderTrackInfo_MaxChunkDurationMs1004The time to measure the max chunk duration.
MLMediaRecorderTrackInfo_EncodedFrames1005The info about encoded frames.
MLMediaRecorderTrackInfo_InterChunkTimeUs1006The time to measure how well the audio and video track data interleaved.
MLMediaRecorderTrackInfo_InitialDelayMs1007The time to measure system response.
MLMediaRecorderTrackInfo_StartOffsetMs1008The time used to compensate for initial A/V sync.
MLMediaRecorderTrackInfo_DataKBytes1009Total number of bytes of the media data.
MLMediaRecorderTrackInfo_Ensure32Bits0x7FFFFFFFEnsure enum is represented as 32 bits.

MLMediaRecorderError

EnumeratorValueDescription
MLMediaRecorderError_Unknown1
MLMediaRecorderError_ServerDied2
MLMediaRecorderTrackError_General100
MLMediaRecorderError_VideoNoSyncFrame200
MLMediaRecorderTrackError_Ensure32Bits0x7FFFFFFFEnsure enum is represented as 32 bits.

Video recorder error types.


MLMediaRecorderOutputFormat

EnumeratorValueDescription
MLMediaRecorderOutputFormat_DEFAULT0
MLMediaRecorderOutputFormat_THREE_GPP13gpp format.
MLMediaRecorderOutputFormat_MPEG_42MP4 format.
MLMediaRecorderOutputFormat_AMR_NB3AMR NB.
MLMediaRecorderOutputFormat_AMR_WB4AMR WB.
MLMediaRecorderOutputFormat_AAC_ADIF5AAC_ADIF.
MLMediaRecorderOutputFormat_AAC_ADTS6AAC_ADTS.
MLMediaRecorderOutputFormat_RTP_AVP7Stream over a socket, limited to a single stream.
MLMediaRecorderOutputFormat_MPEG2TS8H.264/AAC data encapsulated in MPEG2/TS.
MLMediaRecorderOutputFormat_WEBM9VP8/VORBIS data in a WEBM container.
MLMediaRecorderOutputFormat_HEIF10HEIC data in a HEIF container.
MLMediaRecorderOutputFormat_OGG11Opus data in a OGG container.
MLMediaRecorderOutputFormat_Ensure32Bits0x7FFFFFFFEnsure enum is represented as 32 bits.

MLMediaRecorderVideoEncoder

EnumeratorValueDescription
MLMediaRecorderVideoEncoder_Default0
MLMediaRecorderVideoEncoder_H2631H263. This format has support for software encoder.
MLMediaRecorderVideoEncoder_H2642H264. This format has support for hardware encoder.
MLMediaRecorderVideoEncoder_MPEG_4_SP3MPEG4 SP. This format has support for software encoder.
MLMediaRecorderVideoEncoder_VP84VP8. This format has support for software encoder.
MLMediaRecorderVideoEncoder_HEVC5HEVC. This format has support for hardware encoder.
MLMediaRecorderVideoEncoder_Ensure32Bits0x7FFFFFFFEnsure enum is represented as 32 bits.

MLMediaRecorderAudioEncoder

EnumeratorValueDescription
MLMediaRecorderAudioEncoder_Default0
MLMediaRecorderAudioEncoder_AMR_NB1AMR NB.
MLMediaRecorderAudioEncoder_AMR_WB2AMR WB.
MLMediaRecorderAudioEncoder_AAC3AAC.
MLMediaRecorderAudioEncoder_HE_AAC4HE AAC.
MLMediaRecorderAudioEncoder_AAC_ELD5AAC ELD.
MLMediaRecorderAudioEncoder_VORBIS6Vorbis.
MLMediaRecorderAudioEncoder_OPUS7Opus.
MLMediaRecorderAudioEncoder_Ensure32Bits0x7FFFFFFFEnsure enum is represented as 32 bits.

Types Documentation

MLMediaMuxerSampleData

typedef struct MLMediaMuxerSampleData MLMediaMuxerSampleData;

Data type that encapsulates sample data to be written in to MLMediaMuxer.

More Info

Deprecated

Deprecated since 1.4.0. Scheduled for removal.

API Level:

  • 20

MLMediaRecorderOnInfo

typedef struct MLMediaRecorderOnInfo MLMediaRecorderOnInfo;

More Info


MLMediaRecorderOnError

typedef struct MLMediaRecorderOnError MLMediaRecorderOnError;

More Info


MLMediaRecorderEventCallbacks

typedef struct MLMediaRecorderEventCallbacks MLMediaRecorderEventCallbacks;

More Info


Functions Documentation

MLMediaMuxerSampleDataInit

static inline void MLMediaMuxerSampleDataInit(
MLMediaMuxerSampleData * inout_sampledata
)

Initializes MLMediaMuxerSampleData with default values.

Parameters

MLMediaMuxerSampleData *inout_sampledataSampleData defined by MLMediaMuxerSampleData that needs to be initialized.
Deprecated

Deprecated since 1.4.0. Scheduled for removal.


MLMediaMuxerCreate

MLResult MLMediaMuxerCreate(
MLHandle * out_handle
)

Create a MLMediaMuxer instance.

Parameters

MLHandle *out_handleUpon successful return will point to handle to the created MLMediaMuxer. Or else, it will point to ML_INVALID_HANDLE.

Returns

MLResultMLResult_AllocFailedMLMediaMuxer object creation failed with resource allocation failure.
MLResultMLResult_InvalidParamOne of the parameters is invalid.
MLResultMLResult_OkMLMediaMuxer object was created successfully.
MLResultMLResult_UnspecifiedFailureThe operation failed with an unspecified error.

Required Permissions:

  • None
Deprecated

Deprecated since 1.4.0. Scheduled for removal.

API Level:

  • 20

MLMediaMuxerRelease

MLResult MLMediaMuxerRelease(
MLHandle media_muxer
)

Release the MLMediaMuxer instance.

Parameters

MLHandlemedia_muxerHandle to the MLMediaMuxer instance.

Returns

MLResultMLResult_InvalidParamOne of the parameters is invalid.
MLResultMLResult_OkMLMediaMuxer object was released successfully.
MLResultMLResult_UnspecifiedFailureThe operation failed with an unspecified error.

Required Permissions:

  • None
Deprecated

Deprecated since 1.4.0. Scheduled for removal.

API Level:

  • 20

MLMediaMuxerGetSupportedOutputFormats

MLResult MLMediaMuxerGetSupportedOutputFormats(
MLHandle media_muxer,
const MLMediaMuxerOutputFormat * out_format_list[],
size_t * out_format_list_size
)

Get a list of all the supported Media Muxer Output Formats on the Platform.

Parameters

MLHandlemedia_muxerHandle to the MLMediaMuxer instance.
const MLMediaMuxerOutputFormat *out_format_listPointer to MLMediaMuxerOutputFormat. This should not be NULL.
size_t *out_format_list_sizeThe size of the returned out_format_list. This should not be NULL.

Returns

MLResultMLResult_InvalidParamIf one of the parameters are invalid.
MLResultMLResult_OkSuccessfully retrieved all the supported Output Formats.
MLResultMLResult_UnspecifiedFailureThe operation failed with an unspecified error.

Required Permissions:

  • None

User doesn't own the memory/buffer returned from this API and MUST NOT be freeing or releasing the out_format_list.

Deprecated

Deprecated since 1.4.0. Scheduled for removal.

API Level:

  • 20

MLMediaMuxerGetSupportedMimes

MLResult MLMediaMuxerGetSupportedMimes(
MLHandle media_muxer,
MLMediaMuxerOutputFormat format,
const char *const * out_mime_list[],
size_t * out_mime_list_size
)

Get a list of all the supported mime-types for a given Media Muxer Output Format on the Platform.

Parameters

MLHandlemedia_muxerHandle to the MLMediaMuxer instance.
MLMediaMuxerOutputFormatformatThe Output format, to which we would like to know all the supported mime-types. The format should be one returned from MLMediaMuxerGetSupportedOutputFormats.
const char const out_mime_listPointer to array of mime-type (char array). This should not be NULL.
size_t *out_mime_list_sizeThe size of the returned out_mime_list. This should not be NULL.

Returns

MLResultMLResult_InvalidParamIf one of the parameters is invalid.
MLResultMLResult_OkSuccessfully retrieved all the supported Output Formats.
MLResultMLResult_UnspecifiedFailureThe operation failed with an unspecified error.

Required Permissions:

  • None

User doesn't own the memory/buffer returned from this API and MUST NOT be freeing or releasing the out_mime_list.

Deprecated

Deprecated since 1.4.0. Scheduled for removal.

API Level:

  • 20

MLMediaMuxerConfigure

MLResult MLMediaMuxerConfigure(
MLHandle media_muxer,
MLMediaMuxerOutputFormat format,
const char * path
)

Configure the MLMediaMuxer for a given Output format with output path.

Parameters

MLHandlemedia_muxerHandle to the MLMediaMuxer instance.
MLMediaMuxerOutputFormatformatThe format of the muxed output media file. The format should be one returned from MLMediaMuxerGetSupportedOutputFormats.
const char *pathThe linux-style path for the output media file. This value cannot be empty or NULL.

Returns

MLResultMLResult_AllocFailedFailed to configure the MLMediaMuxer object with resource allocation failure.
MLResultMLResult_InvalidParamOne of the parameters is invalid.
MLResultMLResult_OkMLMediaMuxer object was configured successfully.
MLResultMLResult_UnspecifiedFailureThe operation failed with an unspecified error.
MLResultMLMediaResult_UnsupportedIf the format is not supported.

Required Permissions:

  • None
Deprecated

Deprecated since 1.4.0. Scheduled for removal.

API Level:

  • 20

MLMediaMuxerAddTrack

MLResult MLMediaMuxerAddTrack(
MLHandle media_muxer,
MLHandle media_format,
size_t * out_track_index
)

Add a track with given format information.

Parameters

MLHandlemedia_muxerInteger handle type used to reference many things returned by the API, instead of returning pointers directly. Use MLHandleIsValid() to check if a handle is valid or not.
MLHandlemedia_formatInteger handle type used to reference many things returned by the API, instead of returning pointers directly. Use MLHandleIsValid() to check if a handle is valid or not.
size_t *out_track_index

This should be called before MLMediaMuxerStart() and after MLMediaMuxerConfigure.

The following media format keys are supported for Audio/Video and Metadata tracks.


| Audio Track | Video Track | Metadata Track |

| MLMediaFormat_Key_Mime | MLMediaFormat_Key_Mime | MLMediaFormat_Key_Mime | | MLMediaFormat_Key_Sample_Rate | MLMediaFormat_Key_Width | | | MLMediaFormat_Key_Channel_Count | MLMediaFormat_Key_Height | | | MLMediaFormat_Key_CSD0 | MLMediaFormat_Key_Bt_Rate | | | MLMediaFormat_Key_CSD1 | MLMediaFormat_Key_Frame_Rate | | | | MLMediaFormat_Key_Color_Range | | | | MLMediaFormat_Key_Color_Standard | | | | MLMediaFormat_Key_Color_Transfer | | | | MLMediaFormat_Key_HDR_Static_Info | | | | MLMediaFormat_Key_CSD0 | |

| | MLMediaFormat_Key_CSD1 | |

MLMediaMuxerGetSupportedMimes can be used to query for all the supported MLMediaFormat_Key_Mime for a given Output Format.

While MLMediaFormat_Key_Mime is must for all tracks, some of the keys aren't mandatory. For Audio track, MLMediaFormat_Key_SAMPLE_RATE and MLMediaFormat_Key_CHANNEL_COUNT is must. For Video track, MLMediaFormat_Key_WIDTH anb MLMediaFormat_Key_HEIGHT are must.

Requierment of providing csd (Codec Specific Data) through MediaFormat is optional for some audio/video mimes where as it is mandatory for some other ones (for example vorbis).

With mp4 container following audio/video and metadata mime types can be supported.


| Audio Mimes | Video Mimes | Metadata Mimes |

| audio/3gpp | video/3gpp | application/ | | audio/mp4a-latm | video/mp4v-es | image/vnd.android.heic | | audio/amr-wb | video/avc | |

| | video/hevc | |

With Webm container following audio/video mime types can be supported.


| Audio Mimes | Video Mimes |

| audio/vorbis | video/x-vnd.on2.vp8 |

| audio/opus | video/x-vnd.on2.vp9 |

With Ogg container, only supported mime is "audio/opus".

If a mime passed through the MLMediaFormat is not supported, it will return MLMediaResult_Unsupported.

API Level:\n 20

media_muxerHandle to the MLMediaMuxer instance.

media_formatMLHandle to the MLMediaFormat that contains the track's format.

out_track_indexUpon successful return, this will conatin the index of the track added.

MLResult_InvalidParamOne of the parameters is invalid.

MLResult_OkIf the operation completes successfully.

MLResult_UnspecifiedFailureThe operation failed with an unspecified error.

MLMediaGenericResult_InvalidOperationThe operation is invalid.

MLMediaResult_UnsupportedIf one of the keys in the format is not supported.

Required PermissionsNone

Deprecated

Deprecated since 1.4.0. Scheduled for removal.


MLMediaMuxerSetOrientationHint

MLResult MLMediaMuxerSetOrientationHint(
MLHandle media_muxer,
int32_t degrees
)

Set the orientation hint for output video playback.

Parameters

MLHandlemedia_muxerHandle to the MLMediaMuxer instance.
int32_tdegreesThe rotation degrees. It has to be either 0, 90, 180 or 270.

Returns

MLResultMLResult_InvalidParamOne of the parameters is invalid.
MLResultMLResult_OkIf the operation completes successfully.
MLResultMLResult_UnspecifiedFailureThe operation failed with an unspecified error.
MLResultMLMediaGenericResult_InvalidOperationThe operation is invalid.

Required Permissions:

  • None

This should be called before MLMediaMuxerStart() and after MLMediaMuxerConfigure.

Calling this method will not rotate the video frame when muxer is generating the file, but add a composition matrix containing the rotation angle in the output video if the output format is MLMediaMuxerOutputFormat_MPEG4 so that a video player can choose the proper orientation for playback.

Note that some video players may choose to ignore the composition matrix in a video during playback. By default, the rotation degree is 0.

Deprecated

Deprecated since 1.4.0. Scheduled for removal.

API Level:

  • 20

MLMediaMuxerSetLocation

MLResult MLMediaMuxerSetLocation(
MLHandle media_muxer,
float latitude,
float longitude
)

Set and store the geodata (latitude and longitude) in the output file.

Parameters

MLHandlemedia_muxerHandle to the MLMediaMuxer instance.
floatlatitudeThe latitude in degree. Its value must be in the range [-90, 90].
floatlongitudeThe longitude in degree. Its value must be in the range [-180, 180].

Returns

MLResultMLResult_InvalidParamOne of the parameters is invalid.
MLResultMLResult_OkIf the operation completes successfully.
MLResultMLResult_UnspecifiedFailureThe operation failed with an unspecified error.
MLResultMLMediaGenericResult_InvalidOperationThe operation is invalid.

Required Permissions:

  • None

This should be called before MLMediaMuxerStart() and after MLMediaMuxerConfigure.

The geodata is stored in udta box if the output format is MLMediaMuxerOutputFormat_MPEG4, and is ignored for other output formats. The geodata is stored according to ISO-6709 standard.

Deprecated

Deprecated since 1.4.0. Scheduled for removal.

API Level:

  • 20

MLMediaMuxerStart

MLResult MLMediaMuxerStart(
MLHandle media_muxer
)

Start muxing.

Parameters

MLHandlemedia_muxerHandle to the MLMediaMuxer instance.

Returns

MLResultMLResult_InvalidParamOne of the parameters is invalid.
MLResultMLResult_OkIf the operation completes successfully.
MLResultMLResult_UnspecifiedFailureThe operation failed with an unspecified error.
MLResultMLMediaGenericResult_InvalidOperationThe operation is invalid.

Required Permissions:

  • None

Make sure all the tracks have been added (MLMediaMuxerAddTrack) before calling this.

Deprecated

Deprecated since 1.4.0. Scheduled for removal.

API Level:

  • 20

MLMediaMuxerWriteSampleData

MLResult MLMediaMuxerWriteSampleData(
MLHandle media_muxer,
const MLMediaMuxerSampleData * data
)

Writes an encoded sample into the muxer.

Parameters

MLHandlemedia_muxerHandle to the MLMediaMuxer instance.
const MLMediaMuxerSampleData *dataThe sample data to be written encapsulated in MLMediaMuxerSampleData.

Returns

MLResultMLResult_InvalidParamOne of the parameters is invalid.
MLResultMLResult_OkIf the operation completes successfully.
MLResultMLResult_UnspecifiedFailureThe operation failed with an unspecified error.
MLResultMLMediaGenericResult_InvalidOperationThe operation is invalid.

Required Permissions:

  • None

The application needs to make sure that the samples are written into the right tracks. Also, it needs to make sure the samples for each track are written in chronological order (e.g. in the order they are provided by the encoder).

For MPEG4 media format, the duration of the last sample in a track can be set by passing an additional empty buffer) with MLMediaCodecBufferFlag_EOS flag and a suitable presentation timestamp set in time_us (of MLMediaMuxerSampleData structure) as the last sample of that track. This last sample's presentation timestamp shall be a sum of the presentation timestamp and the duration preferred for the original last sample. If no explicit END_OF_STREAM sample was passed, then the duration of the last sample would be the same as that of the sample before that.

The buffer can be reused once this method returns.

Deprecated

Deprecated since 1.4.0. Scheduled for removal.

API Level:

  • 20

MLMediaMuxerStop

MLResult MLMediaMuxerStop(
MLHandle media_muxer
)

Stop muxing.

Parameters

MLHandlemedia_muxerHandle to the MLMediaMuxer instance.

Returns

MLResultMLResult_InvalidParamOne of the parameters is invalid.
MLResultMLResult_OkIf the operation completes successfully.
MLResultMLResult_UnspecifiedFailureThe operation failed with an unspecified error.
MLResultMLMediaGenericResult_InvalidOperationThe operation is invalid.

Required Permissions:

  • None

Once the muxer stops, it can not be restarted.

Deprecated

Deprecated since 1.4.0. Scheduled for removal.

API Level:

  • 20

MLMediaRecorderEventCallbacksInit

static inline void MLMediaRecorderEventCallbacksInit(
MLMediaRecorderEventCallbacks * inout_callbacks
)

Initializes MediaRecorderEventCallbacks with default values.

Parameters

MLMediaRecorderEventCallbacks *inout_callbacksMedia Recorder Callback structure defined by MLMediaRecorderEventCallbacks that needs to be initialized.

MLMediaRecorderCreate

MLResult MLMediaRecorderCreate(
MLHandle * out_handle
)

Create a new MediaRecorder object.

Parameters

MLHandle *out_handleHandle to the new MediaRecorder object created. Only valid if result is MLResult_Ok.

Returns

MLResultMLResult_AllocFailedCould not allocate internal MediaRecorder.
MLResultMLResult_InvalidParamPassed out_handle was NULL.
MLResultMLResult_OkMediaRecorder was created successfully.

Required Permissions:

  • None
Deprecated

Deprecated since 1.4.0. Scheduled for removal.

API Level:

  • 20

MLMediaRecorderDestroy

MLResult MLMediaRecorderDestroy(
MLHandle media_recorder
)

Destroy a MediaRecorder object.

Parameters

MLHandlemedia_recorderHandle to the media recorder object to destroy.

Returns

MLResultMLResult_InvalidParamMedia recorder handle was not found.
MLResultMLResult_OkMediaRecorder was destroyed successfully.
MLResultMLResult_UnspecifiedFailureThe operation failed with an unspecified error.

Required Permissions:

  • None
Deprecated

Deprecated since 1.4.0. Scheduled for removal.

API Level:

  • 20

MLMediaRecorderSetOutputFileForFD

MLResult MLMediaRecorderSetOutputFileForFD(
MLHandle media_recorder,
int32_t fd
)

Pass in the file descriptor of the file to be written.

Parameters

MLHandlemedia_recorderHandle to the media recorder instance.
int32_tfdThe file descriptor for the file you want to write into.

Returns

MLResultMLResult_InvalidParamPassed fd does no refer to a valid,open file descriptor or 'media_recorder' was NULL.
MLResultMLResult_OkData source was correctly set to passed file descriptor.
MLResultMLResult_UnspecifiedFailureThe operation failed with an unspecified error.
MLResultMLMediaGenericResult_InvalidOperationMethod was called from the wrong state.

Required Permissions:

  • None

Call this after MLMediaRecorderSetOutputFormat() but before MLMediaRecorderprepare().

Deprecated

Deprecated since 1.4.0. Scheduled for removal.

API Level:

  • 20

MLMediaRecorderSetOutputFileForPath

MLResult MLMediaRecorderSetOutputFileForPath(
MLHandle media_recorder,
const char * path
)

Sets the path of the output file to be produced.

Parameters

MLHandlemedia_recorderHandle to the media recorder instance.
const char *pathThe linux-style path of the file. Must be a valid and existing path.

Returns

MLResultMLResult_InvalidParamMedia recorder handle was not found.
MLResultMLResult_OkData source was correctly set to passed file path.
MLResultMLResult_UnspecifiedFailureThe operation failed with an unspecified error.
MLResultMLMediaGenericResult_InvalidOperationMethod was called from the wrong state.

Required Permissions:

  • None

Call this after MLMediaRecorderSetOutputFormat() but before MLMediaRecorderprepare().

Deprecated

Deprecated since 1.4.0. Scheduled for removal.

API Level:

  • 20

MLMediaRecorderSetEventCallbacks

MLResult MLMediaRecorderSetEventCallbacks(
MLHandle media_recorder,
const MLMediaRecorderEventCallbacks * callbacks,
void * data
)

Sets the MediaRecorderListener object that will receive MediaRecorder notifications.

Parameters

MLHandlemedia_recorderHandle to the media recorder.
const MLMediaRecorderEventCallbacks *callbacksSet of event callbacks. Can be set to NULL to unset the callbacks altogether.
void *dataCustom data to be returned when any callback is fired.

Returns

MLResultMLResult_InvalidParamMedia recorder handle was not found.
MLResultMLResult_OkThe specified callbacks were successfully set/unset.
MLResultMLResult_UnspecifiedFailureThe operation failed with an unspecified error.
MLResultMLMediaGenericResult_InvalidOperationMethod was called from the wrong state.

Required Permissions:

  • None
Deprecated

Deprecated since 1.4.0. Scheduled for removal.

API Level:

  • 20

MLMediaRecorderSetVideoSource

MLResult MLMediaRecorderSetVideoSource(
MLHandle media_recorder,
MLMediaRecorderVideoSource in_video_source
)

Sets MediaRecorder default video source.

Parameters

MLHandlemedia_recorderHandle to the media recorder.
MLMediaRecorderVideoSourcein_video_sourceType of the MediaRecorderVideoSource.

Returns

MLResultMLResult_InvalidParamMedia recorder handle was not found or in_video_source is not MLMediaRecorderVideoSource_Camera.
MLResultMLResult_OkSet default video source successfully.
MLResultMLResult_UnspecifiedFailureThe operation failed with an unspecified error.
MLResultMLMediaGenericResult_InvalidOperationMethod was called from the wrong state.

Required Permissions:

  • None

Cannot be called twice (without calling MLMediaRecorderReset() in between) because it triggers internal initialization.

Current implementation supports only camera as video source from MediaRecorderVideoSource.

Deprecated

Deprecated since 1.4.0. Scheduled for removal.


MLMediaRecorderSetAudioSource

MLResult MLMediaRecorderSetAudioSource(
MLHandle media_recorder,
MLMediaRecorderAudioSource in_audio_source
)

Set MediaRecorder audio source.

Parameters

MLHandlemedia_recorderHandle to the media recorder.
MLMediaRecorderAudioSourcein_audio_sourceType of the MediaRecorderAudioSource.

Returns

MLResultMLResult_InvalidParamMedia recorder handle was not found.
MLResultMLResult_OkSet audio source successfully.
MLResultMLResult_UnspecifiedFailureThe operation failed with an unspecified error.
MLResultMLMediaGenericResult_InvalidOperationMethod was called from the wrong state.

Required Permissions:

  • android.permission.RECORD_AUDIO (protection level: dangerous)

Cannot be called twice (without calling MLMediaRecorderReset() in between) because it triggers internal initialization.

Deprecated

Deprecated since 1.4.0. Scheduled for removal.

API Level:

  • 20

MLMediaRecorderSetOutputFormat

MLResult MLMediaRecorderSetOutputFormat(
MLHandle media_recorder,
MLMediaRecorderOutputFormat in_format
)

Sets the format of the output file produced during recording.

Parameters

MLHandlemedia_recorderHandle to the media recorder.
MLMediaRecorderOutputFormatin_formatType of the MLMediaRecorderOutputFormat.

Returns

MLResultMLResult_InvalidParamMedia recorder handle was not found.
MLResultMLResult_OkSet output format successfully.
MLResultMLResult_UnspecifiedFailureThe operation failed with an unspecified error.
MLResultMLMediaGenericResult_InvalidOperationMethod was called from the wrong state.

Required Permissions:

  • None
Deprecated

Deprecated since 1.4.0. Scheduled for removal.

API Level:

  • 20

MLMediaRecorderSetVideoEncoder

MLResult MLMediaRecorderSetVideoEncoder(
MLHandle media_recorder,
MLMediaRecorderVideoEncoder in_video_encoder
)

Sets the video encoder to be used for recording.

Parameters

MLHandlemedia_recorderHandle to the media recorder.
MLMediaRecorderVideoEncoderin_video_encoderType of the VideoEncoder to use.

Returns

MLResultMLResult_InvalidParamMedia recorder handle was not found.
MLResultMLResult_OkSet video encoder successfully.
MLResultMLResult_UnspecifiedFailureThe operation failed with an unspecified error.
MLResultMLMediaResult_InvalidCodecParamrequested width height is not supported.
MLResultMLMediaGenericResult_InvalidOperationMethod was called from the wrong state.

Required Permissions:

  • None

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.

Deprecated

Deprecated since 1.4.0. Scheduled for removal.

API Level:

  • 20

MLMediaRecorderSetAudioEncoder

MLResult MLMediaRecorderSetAudioEncoder(
MLHandle media_recorder,
MLMediaRecorderAudioEncoder in_audio_encoder
)

Sets the audio encoder to be used for recording.

Parameters

MLHandlemedia_recorderHandle to the media recorder.
MLMediaRecorderAudioEncoderin_audio_encoderType of the MLMediaRecorderAudioEncoder to use.

Returns

MLResultMLResult_InvalidParamMedia recorder handle was not found.
MLResultMLResult_OkSet audio encoder successfully.
MLResultMLResult_UnspecifiedFailureThe operation failed with an unspecified error.
MLResultMLMediaGenericResult_InvalidOperationMethod was called from the wrong state.

Required Permissions:

  • None

If this method is not called, the output file will not contain an audio track. Call this after MLMediaRecorderSetOutputFormat() and before MLMediaRecorderPrepare().

Deprecated

Deprecated since 1.4.0. Scheduled for removal.

API Level:

  • 20

MLMediaRecorderSetMaxDuration

MLResult MLMediaRecorderSetMaxDuration(
MLHandle media_recorder,
int32_t in_max_duration_msec
)

Sets the maximum duration (in ms) of the recording session.

Parameters

MLHandlemedia_recorderHandle to the media recorder.
int32_tin_max_duration_msecThe maximum duration in ms (if zero or negative, disables the duration limit).

Returns

MLResultMLResult_InvalidParamMedia recorder handle was not found.
MLResultMLResult_OkMax duration was successfully set.
MLResultMLResult_UnspecifiedFailureThe operation failed with an unspecified error.
MLResultMLMediaGenericResult_InvalidOperationMethod was called from the wrong state.

Required Permissions:

  • None

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.

Deprecated

Deprecated since 1.4.0. Scheduled for removal.

API Level:

  • 20

MLMediaRecorderSetMaxFileSize

MLResult MLMediaRecorderSetMaxFileSize(
MLHandle media_recorder,
int64_t in_max_file_size
)

Sets the maximum filesize (in bytes) of the recording session.

Parameters

MLHandlemedia_recorderHandle to the media recorder.
int64_tin_max_file_sizeMaxFilesizeBytes The maximum filesize in bytes (if zero or negative, disables the limit).

Returns

MLResultMLResult_InvalidParamMedia recorder handle was not found.
MLResultMLResult_OkMax file size was successfully set.
MLResultMLResult_UnspecifiedFailureThe operation failed with an unspecified error.
MLResultMLMediaGenericResult_InvalidOperationMethod was called from the wrong state.

Required Permissions:

  • None

Call this after MLMediaRecorderSetOutputFormat() and before MLMediaRecorderPrepare(). After recording reaches the specified filesize, a notification will be sent via the callback with a MLMediaRecorderInfo code of MLMediaRecorderInfo_MaxFileSizeReached 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.

Deprecated

Deprecated since 1.4.0. Scheduled for removal.

API Level:

  • 20

MLMediaRecorderSetGeoLocation

MLResult MLMediaRecorderSetGeoLocation(
MLHandle media_recorder,
int64_t in_latitude10000,
int64_t in_longitude10000
)

Sets the GEO location for recording.

Parameters

MLHandlemedia_recorderHandle to the media recorder.
int64_tin_latitude10000The 10000 multiplies latitude of location.
int64_tin_longitude10000The 10000 multiplies longitude of location.

Returns

MLResultMLResult_InvalidParamMedia recorder handle was not found.
MLResultMLResult_OkGEO location was successfully set.
MLResultMLResult_UnspecifiedFailureThe operation failed with an unspecified error.
MLResultMLMediaGenericResult_InvalidOperationMethod was called from the wrong state.

Required Permissions:

  • None
Deprecated

Deprecated since 1.4.0. Scheduled for removal.

API Level:

  • 20

MLMediaRecorderPrepare

MLResult MLMediaRecorderPrepare(
MLHandle media_recorder,
MLHandle format
)

Prepares the recorder to begin capturing and encoding data for input mediaformat.

Parameters

MLHandlemedia_recorderHandle to the media recorder.
MLHandleformatMLHandle to the MediaFormat. MediaFormat object can be created with:

* MLMediaFormatCreateVideo if we want to record video only. * MLMediaFormatCreateAudio if we want to record audio only. * MLMediaFormatCreate if we want to record both video and audio.|

Returns

MLResultMLResult_InvalidParamMedia recorder handle was not found.
MLResultMLResult_OkRecorder was prepared successfully.
MLResultMLResult_UnspecifiedFailureThe operation failed with an unspecified error.
MLResultMLMediaGenericResult_InvalidOperationMethod was called from the wrong state.

Required Permissions:

  • None

This method must be called after setting up the desired audio and video sources, encoders, but before start.

Following parameters can be added to MediaFormat handle. Audio Specific parametes:

Deprecated

Deprecated since 1.4.0. Scheduled for removal.

API Level:

  • 20

MLMediaRecorderStart

MLResult MLMediaRecorderStart(
MLHandle media_recorder
)

Begins capturing and encoding data to the specified file.

Parameters

MLHandlemedia_recorderHandle to the media recorder.

Returns

MLResultMLResult_InvalidParamMedia recorder handle was not found.
MLResultMLResult_OkRecorder was started successfully.
MLResultMLResult_UnspecifiedFailureThe operation failed with an unspecified error.
MLResultMLMediaGenericResult_InvalidOperationMethod was called from the wrong state.

Required Permissions:

  • None

Call this after MLMediaRecorderPrepare(). The apps should not start another recording session during recording.

Deprecated

Deprecated since 1.4.0. Scheduled for removal.

API Level:

  • 20

MLMediaRecorderGetInputSurface

MLResult MLMediaRecorderGetInputSurface(
MLHandle media_recorder,
MLHandle * out_input_surface_handle
)

Gets the input surface to record from when using SURFACE video source.

Parameters

MLHandlemedia_recorderHandle to the Media Recorder instance.
MLHandle *out_input_surface_handleHandle to the created input native surface.

Returns

MLResultMLResult_InvalidParamMedia recorder handle was not found.
MLResultMLResult_OKinput surface was correctly returned.
MLResultMLResult_UnspecifiedFailureThe operation failed with an unspecified error.
MLResultMLMediaGenericResult_InvalidOperationMethod was called from the wrong state.

Required Permissions:

  • None

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

Deprecated

Deprecated since 1.4.0. Scheduled for removal.

API Level:

  • 20

MLMediaRecorderGetMaxAmplitude

MLResult MLMediaRecorderGetMaxAmplitude(
MLHandle media_recorder,
int32_t * inout_max_amp
)

Returns the maximum absolute amplitude that was sampled since the last call to this method.

Parameters

MLHandlemedia_recorderHandle to the MediaRecorder.
int32_t *inout_max_ampThe maximum absolute amplitude measured since the last call, or 0 when called for the first time.

Returns

MLResultMLResult_InvalidParamMmedia recorder handle was not found.
MLResultMLResult_OkMaximum amplitude was returned successfully.
MLResultMLResult_UnspecifiedFailureThe operation failed with an unspecified error.
MLResultMLMediaGenericResult_InvalidOperationMethod was called from the wrong state.

Required Permissions:

  • None

Call this only after the MLMediaRecorderSetAudioSource().

Deprecated

Deprecated since 1.4.0. Scheduled for removal.

API Level:

  • 20

MLMediaRecorderStop

MLResult MLMediaRecorderStop(
MLHandle media_recorder
)

Stops recording.

Parameters

MLHandlemedia_recorderHandle to the MediaRecorder.

Returns

MLResultMLResult_InvalidParamMedia recorder handle was not found.
MLResultMLResult_OkRecorder was stopped successfully.
MLResultMLResult_UnspecifiedFailureThe operation failed with an unspecified error.
MLResultMLMediaGenericResult_InvalidOperationMethod was called from the wrong state.

Required Permissions:

  • None

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

Deprecated

Deprecated since 1.4.0. Scheduled for removal.

API Level:

  • 20

MLMediaRecorderReleaseInputSurface

MLResult MLMediaRecorderReleaseInputSurface(
MLHandle media_recorder,
MLHandle input_surface_handle
)

Release the surface that was returned by MLMediaRecorderGetInputSurface.

Parameters

MLHandlemedia_recorderHandle to the MediaRecorder.
MLHandleinput_surface_handleHandle to the internal surface object.

Returns

MLResultMLResult_InvalidParamMedia recorder handle was not found.
MLResultMLResult_OkSurface object was successfully released.
MLResultMLResult_UnspecifiedFailureThe operation failed with an unspecified error.
MLResultMLMediaGenericResult_NoInitMLMediaCodec was not initialized.

Required Permissions:

  • None
Deprecated

Deprecated since 1.4.0. Scheduled for removal.

API Level:

  • 20

MLMediaRecorderReset

MLResult MLMediaRecorderReset(
MLHandle media_recorder
)

Restarts the MediaRecorder to its idle state.

Parameters

MLHandlemedia_recorderHandle to the media recorder.

Returns

MLResultMLResult_InvalidParamMedia recorder handle was not found.
MLResultMLResult_OkRecorder was resetted successfully.
MLResultMLResult_UnspecifiedFailureThe operation failed with an unspecified error.
MLResultMLMediaGenericResult_InvalidOperationMethod was called from the wrong state.

Required Permissions:

  • None

After calling this method, you will have to configure it again as if it had just been constructed.

Deprecated

Deprecated since 1.4.0. Scheduled for removal.

API Level:

  • 20

Attributes Documentation

track_id

uint32_t track_id;

Holds valid track id only for track specific info (returned via on_track_info callback.). Holds 0 for the generic info (returned via on_info callback). Refer to MLMediaRecorderInfo for the info.


info

MLMediaRecorderInfo info;

The info of MLMediaRecorderInfo.


extra

int extra;

The extra info.


data

void * data;

User data as passed to MLMediaRecorderSetEventCallbacks.


track_id

uint32_t track_id;

Holds valid track id only for track specific errors (returned via on_track_error callback). Holds 0 for the generic errors (returned via on_error callback). Refer to MLMediaRecorderError for the errors.


error

MLMediaRecorderError error;
TypeDescription
MLMediaRecorderErrorVideo recorder error types.

The error of MLMediaRecorderError.


extra

int extra;

The extra info.


data

void * data;

User data as passed to MLMediaRecorderSetEventCallbacks.


version

uint32_t version;

on_info

void(*)(MLHandle media_recorder, const MLMediaRecorderOnInfo *info) on_info;

MediaRecorder received a general info/warning message.

TypeDescription
void()(MLHandle media_recorder, const MLMediaRecorderOnInfo info))(MLHandle media_recorder, const MLMediaRecorderOnInfo *info)

Parameters

media_recorderHandle is a MediaRecorder instance on which callback was set.
pointerto MLMediaRecorderOnInfo.

on_track_info

void(*)(MLHandle media_recorder, const MLMediaRecorderOnInfo *track_info) on_track_info;

MediaRecorder received a track-related info/warning message.

TypeDescription
void()(MLHandle media_recorder, const MLMediaRecorderOnInfo track_info))(MLHandle media_recorder, const MLMediaRecorderOnInfo *track_info)

Parameters

media_recorderHandle is a MediaRecorder instance on which callback was set.
track_infopointer to MLMediaRecorderOnInfo.

on_error

void(*)(MLHandle media_recorder, const MLMediaRecorderOnError *error) on_error;

MediaRecorder received a general error message.

TypeDescription
void()(MLHandle media_recorder, const MLMediaRecorderOnError error))(MLHandle media_recorder, const MLMediaRecorderOnError *error)

Parameters

media_recorderHandle is a MediaRecorder instance on which callback was set.
pointerto MLMediaRecorderOnError.

on_track_error

void(*)(MLHandle media_recorder, const MLMediaRecorderOnError *track_error) on_track_error;

MediaRecorder received a track-related error message.

TypeDescription
void()(MLHandle media_recorder, const MLMediaRecorderOnError track_error))(MLHandle media_recorder, const MLMediaRecorderOnError *track_error)

Parameters

media_recorderHandle is a MediaRecorder instance on which callback was set.
pointerto MLMediaRecorderError.