Media Recorder
APIs for video and auido recording. More...
Classes
Name | |
---|---|
struct | MLMediaRecorderOnInfo |
struct | MLMediaRecorderOnError |
struct | MLMediaRecorderEventCallbacks |
Types
Name | |
---|---|
typedef struct MLMediaRecorderOnInfo | MLMediaRecorderOnInfo |
typedef struct MLMediaRecorderOnError | MLMediaRecorderOnError |
typedef struct MLMediaRecorderEventCallbacks | MLMediaRecorderEventCallbacks |
Enums
Functions
Name | |
---|---|
void | MLMediaRecorderEventCallbacksInit(MLMediaRecorderEventCallbacks * inout_callbacks) Initializes MediaRecorderEventCallbacks with default values. |
MLResult | MLMediaRecorderCreate(MLHandle * out_handle) Create a new MediaRecorder object. |
MLResult | MLMediaRecorderDestroy(MLHandle media_recorder) Destroy a MediaRecorder object. |
MLResult | MLMediaRecorderSetOutputFileForFD(MLHandle media_recorder, int32_t fd) Pass in the file descriptor of the file to be written. |
MLResult | MLMediaRecorderSetOutputFileForPath(MLHandle media_recorder, const char * path) Sets the path of the output file to be produced. |
MLResult | MLMediaRecorderSetEventCallbacks(MLHandle media_recorder, const MLMediaRecorderEventCallbacks callbacks, void data) Sets the MediaRecorderListener object that will receive MediaRecorder notifications. |
MLResult | MLMediaRecorderSetVideoSource(MLHandle media_recorder, MLMediaRecorderVideoSource in_video_source) Sets MediaRecorder default video source. |
MLResult | MLMediaRecorderSetAudioSource(MLHandle media_recorder, MLMediaRecorderAudioSource in_audio_source) Set MediaRecorder audio source. |
MLResult | MLMediaRecorderSetOutputFormat(MLHandle media_recorder, MLMediaRecorderOutputFormat in_format) Sets the format of the output file produced during recording. |
MLResult | MLMediaRecorderSetVideoEncoder(MLHandle media_recorder, MLMediaRecorderVideoEncoder in_video_encoder) Sets the video encoder to be used for recording. |
MLResult | MLMediaRecorderSetAudioEncoder(MLHandle media_recorder, MLMediaRecorderAudioEncoder in_audio_encoder) Sets the audio encoder to be used for recording. |
MLResult | MLMediaRecorderSetMaxDuration(MLHandle media_recorder, int32_t in_max_duration_msec) Sets the maximum duration (in ms) of the recording session. |
MLResult | MLMediaRecorderSetMaxFileSize(MLHandle media_recorder, int64_t in_max_file_size) Sets the maximum filesize (in bytes) of the recording session. |
MLResult | MLMediaRecorderSetGeoLocation(MLHandle media_recorder, int64_t in_latitude10000, int64_t in_longitude10000) Sets the GEO location for recording. |
MLResult | MLMediaRecorderPrepare(MLHandle media_recorder, MLHandle format) Prepares the recorder to begin capturing and encoding data for input mediaformat. |
MLResult | MLMediaRecorderStart(MLHandle media_recorder) Begins capturing and encoding data to the specified file. |
MLResult | MLMediaRecorderGetInputSurface(MLHandle media_recorder, MLHandle * out_input_surface_handle) Gets the input surface to record from when using SURFACE video source. |
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. |
MLResult | MLMediaRecorderStop(MLHandle media_recorder) Stops recording. |
MLResult | MLMediaRecorderReleaseInputSurface(MLHandle media_recorder, MLHandle input_surface_handle) Release the surface that was returned by MLMediaRecorderGetInputSurface. |
MLResult | MLMediaRecorderReset(MLHandle media_recorder) Restarts the MediaRecorder to its idle state. |
Attributes
Name | |
---|---|
uint32_t | track_id |
MLMediaRecorderInfo | info |
int | extra |
void * | data |
uint32_t | track_id |
MLMediaRecorderError | error |
int | extra |
void * | data |
uint32_t | version |
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 video and auido recording.
Shared Object:
- media_recorder.magicleap*
Enums Documentation
MLMediaRecorderVideoSource
Enumerator | Value | Description |
---|---|---|
MLMediaRecorderVideoSource_Camera | 1 | Camera video source. |
MLMediaRecorderVideoSource_Ensure32Bits | 0x7FFFFFFF | Ensure enum is represented as 32 bits. |
Media recorder video source.
MLMediaRecorderAudioSource
Enumerator | Value | Description |
---|---|---|
MLMediaRecorderAudioSource_Voice | 0 | Recording voice. |
MLMediaRecorderAudioSource_World | 1 | Recording ambient sounds. |
MLMediaRecorderAudioSource_Virtual | 2 | Recording digital sounds. |
MLMediaRecorderAudioSource_Mixed | 3 | Mixed reality mode: digital + ambient. |
MLMediaRecorderAudioSource_Ensure32Bits | 0x7FFFFFFF | Ensure enum is represented as 32 bits. |
Media recorder audio source.
MLMediaRecorderEvent
Enumerator | Value | Description |
---|---|---|
MLMediaRecorderEvent_Error | 1 | Media recorder error. |
MLMediaRecorderEvent_Info | 2 | Media recorder info. |
MLMediaRecorderTrackEvent_Error | 100 | Media recorder track error. |
MLMediaRecorderTrackEvent_Info | 101 | Media recorder track info. |
MLMediaRecorderTrackEvent_Ensure32Bits | 0x7FFFFFFF | Ensure enum is represented as 32 bits. |
Media recorder events.
MLMediaRecorderInfo
Enumerator | Value | Description |
---|---|---|
MLMediaRecorderInfo_Unknown | 1 | |
MLMediaRecorderInfo_MaxDurationReached | 800 | Max duration of the clip is reached. |
MLMediaRecorderInfo_MaxFileSizeReached | 801 | Max file size is reached. |
MLMediaRecorderInfo_MaxFileSizeApproaching | 802 | Max file size is approaching. |
MLMediaRecorderTrackInfo_CompletionStatus | 1000 | Next output file has started.The info about completion status. |
MLMediaRecorderTrackInfo_ProgressInTime | 1001 | The info about progress in time. |
MLMediaRecorderTrackInfo_Type | 1002 | Track info. |
MLMediaRecorderTrackInfo_DurationMs | 1003 | The info about track duration. |
MLMediaRecorderTrackInfo_MaxChunkDurationMs | 1004 | The time to measure the max chunk duration. |
MLMediaRecorderTrackInfo_EncodedFrames | 1005 | The info about encoded frames. |
MLMediaRecorderTrackInfo_InterChunkTimeUs | 1006 | The time to measure how well the audio and video track data interleaved. |
MLMediaRecorderTrackInfo_InitialDelayMs | 1007 | The time to measure system response. |
MLMediaRecorderTrackInfo_StartOffsetMs | 1008 | The time used to compensate for initial A/V sync. |
MLMediaRecorderTrackInfo_DataKBytes | 1009 | Total number of bytes of the media data. |
MLMediaRecorderTrackInfo_Ensure32Bits | 0x7FFFFFFF | Ensure enum is represented as 32 bits. |
MLMediaRecorderError
Enumerator | Value | Description |
---|---|---|
MLMediaRecorderError_Unknown | 1 | |
MLMediaRecorderError_ServerDied | 2 | |
MLMediaRecorderTrackError_General | 100 | |
MLMediaRecorderError_VideoNoSyncFrame | 200 | |
MLMediaRecorderTrackError_Ensure32Bits | 0x7FFFFFFF | Ensure enum is represented as 32 bits. |
Video recorder error types.
MLMediaRecorderOutputFormat
Enumerator | Value | Description |
---|---|---|
MLMediaRecorderOutputFormat_DEFAULT | 0 | |
MLMediaRecorderOutputFormat_THREE_GPP | 1 | 3gpp format. |
MLMediaRecorderOutputFormat_MPEG_4 | 2 | MP4 format. |
MLMediaRecorderOutputFormat_AMR_NB | 3 | AMR NB. |
MLMediaRecorderOutputFormat_AMR_WB | 4 | AMR WB. |
MLMediaRecorderOutputFormat_AAC_ADIF | 5 | AAC_ADIF. |
MLMediaRecorderOutputFormat_AAC_ADTS | 6 | AAC_ADTS. |
MLMediaRecorderOutputFormat_RTP_AVP | 7 | Stream over a socket, limited to a single stream. |
MLMediaRecorderOutputFormat_MPEG2TS | 8 | H.264/AAC data encapsulated in MPEG2/TS. |
MLMediaRecorderOutputFormat_WEBM | 9 | VP8/VORBIS data in a WEBM container. |
MLMediaRecorderOutputFormat_HEIF | 10 | HEIC data in a HEIF container. |
MLMediaRecorderOutputFormat_OGG | 11 | Opus data in a OGG container. |
MLMediaRecorderOutputFormat_Ensure32Bits | 0x7FFFFFFF | Ensure enum is represented as 32 bits. |
MLMediaRecorderVideoEncoder
Enumerator | Value | Description |
---|---|---|
MLMediaRecorderVideoEncoder_Default | 0 | |
MLMediaRecorderVideoEncoder_H263 | 1 | H263. This format has support for software encoder. |
MLMediaRecorderVideoEncoder_H264 | 2 | H264. This format has support for hardware encoder. |
MLMediaRecorderVideoEncoder_MPEG_4_SP | 3 | MPEG4 SP. This format has support for software encoder. |
MLMediaRecorderVideoEncoder_VP8 | 4 | VP8. This format has support for software encoder. |
MLMediaRecorderVideoEncoder_HEVC | 5 | HEVC. This format has support for hardware encoder. |
MLMediaRecorderVideoEncoder_Ensure32Bits | 0x7FFFFFFF | Ensure enum is represented as 32 bits. |
MLMediaRecorderAudioEncoder
Enumerator | Value | Description |
---|---|---|
MLMediaRecorderAudioEncoder_Default | 0 | |
MLMediaRecorderAudioEncoder_AMR_NB | 1 | AMR NB. |
MLMediaRecorderAudioEncoder_AMR_WB | 2 | AMR WB. |
MLMediaRecorderAudioEncoder_AAC | 3 | AAC. |
MLMediaRecorderAudioEncoder_HE_AAC | 4 | HE AAC. |
MLMediaRecorderAudioEncoder_AAC_ELD | 5 | AAC ELD. |
MLMediaRecorderAudioEncoder_VORBIS | 6 | Vorbis. |
MLMediaRecorderAudioEncoder_OPUS | 7 | Opus. |
MLMediaRecorderAudioEncoder_Ensure32Bits | 0x7FFFFFFF | Ensure enum is represented as 32 bits. |
Types Documentation
MLMediaRecorderOnInfo
typedef struct MLMediaRecorderOnInfo MLMediaRecorderOnInfo;
MLMediaRecorderOnError
typedef struct MLMediaRecorderOnError MLMediaRecorderOnError;
MLMediaRecorderEventCallbacks
typedef struct MLMediaRecorderEventCallbacks MLMediaRecorderEventCallbacks;
Functions Documentation
MLMediaRecorderEventCallbacksInit
static inline void MLMediaRecorderEventCallbacksInit(
MLMediaRecorderEventCallbacks * inout_callbacks
)
Initializes MediaRecorderEventCallbacks with default values.
Parameters
MLMediaRecorderEventCallbacks * | inout_callbacks | Media 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_handle | Handle to the new MediaRecorder object created. Only valid if result is MLResult_Ok. |
Returns
MLResult | MLResult_AllocFailed | Could not allocate internal MediaRecorder. |
MLResult | MLResult_InvalidParam | Passed out_handle was NULL. |
MLResult | MLResult_Ok | MediaRecorder was created successfully. |
Required Permissions:
- None
API Level:
- 20
MLMediaRecorderDestroy
MLResult MLMediaRecorderDestroy(
MLHandle media_recorder
)
Destroy a MediaRecorder object.
Parameters
MLHandle | media_recorder | Handle to the media recorder object to destroy. |
Returns
MLResult | MLResult_InvalidParam | Media recorder handle was not found. |
MLResult | MLResult_Ok | MediaRecorder was destroyed successfully. |
MLResult | MLResult_UnspecifiedFailure | The operation failed with an unspecified error. |
Required Permissions:
- None
API Level:
- 20
MLMediaRecorderSetOutputFileForFD
MLResult MLMediaRecorderSetOutputFileForFD(
MLHandle media_recorder,
int32_t fd
)
Pass in the file descriptor of the file to be written.
Parameters
MLHandle | media_recorder | Handle to the media recorder instance. |
int32_t | fd | The file descriptor for the file you want to write into. |
Returns
MLResult | MLResult_InvalidParam | Passed fd does no refer to a valid,open file descriptor or 'media_recorder' was NULL. |
MLResult | MLResult_Ok | Data source was correctly set to passed file descriptor. |
MLResult | MLResult_UnspecifiedFailure | The operation failed with an unspecified error. |
MLResult | MLMediaGenericResult_InvalidOperation | Method was called from the wrong state. |
Required Permissions:
- None
Call this after MLMediaRecorderSetOutputFormat() but before MLMediaRecorderprepare().
API Level:
- 20
MLMediaRecorderSetOutputFileForPath
MLResult MLMediaRecorderSetOutputFileForPath(
MLHandle media_recorder,
const char * path
)
Sets the path of the output file to be produced.
Parameters
MLHandle | media_recorder | Handle to the media recorder instance. |
const char * | path | The linux-style path of the file. Must be a valid and existing path. |
Returns
MLResult | MLResult_InvalidParam | Media recorder handle was not found. |
MLResult | MLResult_Ok | Data source was correctly set to passed file path. |
MLResult | MLResult_UnspecifiedFailure | The operation failed with an unspecified error. |
MLResult | MLMediaGenericResult_InvalidOperation | Method was called from the wrong state. |
Required Permissions:
- None
Call this after MLMediaRecorderSetOutputFormat() but before MLMediaRecorderprepare().
API Level:
- 20
MLMediaRecorderSetEventCallbacks
MLResult MLMediaRecorderSetEventCallbacks(
MLHandle media_recorder,
const MLMediaRecorderEventCallbacks * callbacks,
void * data
)
Sets the MediaRecorderListener object that will receive MediaRecorder notifications.
Parameters
MLHandle | media_recorder | Handle to the media recorder. |
const MLMediaRecorderEventCallbacks * | callbacks | Set of event callbacks. Can be set to NULL to unset the callbacks altogether. |
void * | data | Custom data to be returned when any callback is fired. |
Returns
MLResult | MLResult_InvalidParam | Media recorder handle was not found. |
MLResult | MLResult_Ok | The specified callbacks were successfully set/unset. |
MLResult | MLResult_UnspecifiedFailure | The operation failed with an unspecified error. |
MLResult | MLMediaGenericResult_InvalidOperation | Method was called from the wrong state. |
Required Permissions:
- None
API Level:
- 20
MLMediaRecorderSetVideoSource
MLResult MLMediaRecorderSetVideoSource(
MLHandle media_recorder,
MLMediaRecorderVideoSource in_video_source
)
Sets MediaRecorder default video source.
Parameters
MLHandle | media_recorder | Handle to the media recorder. |
MLMediaRecorderVideoSource | in_video_source | Type of the MediaRecorderVideoSource. |
Returns
MLResult | MLResult_InvalidParam | Media recorder handle was not found or in_video_source is not MLMediaRecorderVideoSource_Camera. |
MLResult | MLResult_Ok | Set default video source successfully. |
MLResult | MLResult_UnspecifiedFailure | The operation failed with an unspecified error. |
MLResult | MLMediaGenericResult_InvalidOperation | Method 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.
MLMediaRecorderSetAudioSource
MLResult MLMediaRecorderSetAudioSource(
MLHandle media_recorder,
MLMediaRecorderAudioSource in_audio_source
)
Set MediaRecorder audio source.
Parameters
MLHandle | media_recorder | Handle to the media recorder. |
MLMediaRecorderAudioSource | in_audio_source | Type of the MediaRecorderAudioSource. |
Returns
MLResult | MLResult_InvalidParam | Media recorder handle was not found. |
MLResult | MLResult_Ok | Set audio source successfully. |
MLResult | MLResult_UnspecifiedFailure | The operation failed with an unspecified error. |
MLResult | MLMediaGenericResult_InvalidOperation | Method 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.
API Level:
- 20
MLMediaRecorderSetOutputFormat
MLResult MLMediaRecorderSetOutputFormat(
MLHandle media_recorder,
MLMediaRecorderOutputFormat in_format
)
Sets the format of the output file produced during recording.
Parameters
MLHandle | media_recorder | Handle to the media recorder. |
MLMediaRecorderOutputFormat | in_format | Type of the MLMediaRecorderOutputFormat. |
Returns
MLResult | MLResult_InvalidParam | Media recorder handle was not found. |
MLResult | MLResult_Ok | Set output format successfully. |
MLResult | MLResult_UnspecifiedFailure | The operation failed with an unspecified error. |
MLResult | MLMediaGenericResult_InvalidOperation | Method was called from the wrong state. |
Required Permissions:
- None
API Level:
- 20
MLMediaRecorderSetVideoEncoder
MLResult MLMediaRecorderSetVideoEncoder(
MLHandle media_recorder,
MLMediaRecorderVideoEncoder in_video_encoder
)
Sets the video encoder to be used for recording.
Parameters
MLHandle | media_recorder | Handle to the media recorder. |
MLMediaRecorderVideoEncoder | in_video_encoder | Type of the VideoEncoder to use. |
Returns
MLResult | MLResult_InvalidParam | Media recorder handle was not found. |
MLResult | MLResult_Ok | Set video encoder successfully. |
MLResult | MLResult_UnspecifiedFailure | The operation failed with an unspecified error. |
MLResult | MLMediaResult_InvalidCodecParam | requested width height is not supported. |
MLResult | MLMediaGenericResult_InvalidOperation | Method 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.
API Level:
- 20
MLMediaRecorderSetAudioEncoder
MLResult MLMediaRecorderSetAudioEncoder(
MLHandle media_recorder,
MLMediaRecorderAudioEncoder in_audio_encoder
)
Sets the audio encoder to be used for recording.
Parameters
MLHandle | media_recorder | Handle to the media recorder. |
MLMediaRecorderAudioEncoder | in_audio_encoder | Type of the MLMediaRecorderAudioEncoder to use. |
Returns
MLResult | MLResult_InvalidParam | Media recorder handle was not found. |
MLResult | MLResult_Ok | Set audio encoder successfully. |
MLResult | MLResult_UnspecifiedFailure | The operation failed with an unspecified error. |
MLResult | MLMediaGenericResult_InvalidOperation | Method 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().
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
MLHandle | media_recorder | Handle to the media recorder. |
int32_t | in_max_duration_msec | The maximum duration in ms (if zero or negative, disables the duration limit). |
Returns
MLResult | MLResult_InvalidParam | Media recorder handle was not found. |
MLResult | MLResult_Ok | Max duration was successfully set. |
MLResult | MLResult_UnspecifiedFailure | The operation failed with an unspecified error. |
MLResult | MLMediaGenericResult_InvalidOperation | Method 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.
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
MLHandle | media_recorder | Handle to the media recorder. |
int64_t | in_max_file_size | MaxFilesizeBytes The maximum filesize in bytes (if zero or negative, disables the limit). |
Returns
MLResult | MLResult_InvalidParam | Media recorder handle was not found. |
MLResult | MLResult_Ok | Max file size was successfully set. |
MLResult | MLResult_UnspecifiedFailure | The operation failed with an unspecified error. |
MLResult | MLMediaGenericResult_InvalidOperation | Method 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.
API Level:
- 20
MLMediaRecorderSetGeoLocation
MLResult MLMediaRecorderSetGeoLocation(
MLHandle media_recorder,
int64_t in_latitude10000,
int64_t in_longitude10000
)
Sets the GEO location for recording.
Parameters
MLHandle | media_recorder | Handle to the media recorder. |
int64_t | in_latitude10000 | The 10000 multiplies latitude of location. |
int64_t | in_longitude10000 | The 10000 multiplies longitude of location. |
Returns
MLResult | MLResult_InvalidParam | Media recorder handle was not found. |
MLResult | MLResult_Ok | GEO location was successfully set. |
MLResult | MLResult_UnspecifiedFailure | The operation failed with an unspecified error. |
MLResult | MLMediaGenericResult_InvalidOperation | Method was called from the wrong state. |
Required Permissions:
- None
API Level:
- 20
MLMediaRecorderPrepare
MLResult MLMediaRecorderPrepare(
MLHandle media_recorder,
MLHandle format
)
Prepares the recorder to begin capturing and encoding data for input mediaformat.
Parameters
MLHandle | media_recorder | Handle to the media recorder. |
MLHandle | format | MLHandle 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
MLResult | MLResult_InvalidParam | Media recorder handle was not found. |
MLResult | MLResult_Ok | Recorder was prepared successfully. |
MLResult | MLResult_UnspecifiedFailure | The operation failed with an unspecified error. |
MLResult | MLMediaGenericResult_InvalidOperation | Method 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:
MLMediaFormat_Key_Bit_Rate for audio "bitrate".
MLMediaFormat_Key_Channel_Count for audio "channel-count".
MLMediaFormat_Key_Sample_Rate for audio "sample-rate". Video Specific parametes:
MLMediaFormat_Key_Width for video frame "width".
MLMediaFormat_Key_Height for video frame "height".
MLMediaFormat_Key_Frame_Rate for video "frame-rate".
MLMediaFormat_Key_Parameter_Video_Bitrate for "video-bitrate".
MLMediaFormat_Key_I_Frame_Interval for "i-frame-interval".
API Level:
- 20
MLMediaRecorderStart
MLResult MLMediaRecorderStart(
MLHandle media_recorder
)
Begins capturing and encoding data to the specified file.
Parameters
MLHandle | media_recorder | Handle to the media recorder. |
Returns
MLResult | MLResult_InvalidParam | Media recorder handle was not found. |
MLResult | MLResult_Ok | Recorder was started successfully. |
MLResult | MLResult_UnspecifiedFailure | The operation failed with an unspecified error. |
MLResult | MLMediaGenericResult_InvalidOperation | Method was called from the wrong state. |
Required Permissions:
- None
Call this after MLMediaRecorderPrepare(). The apps should not start another recording session during recording.
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
MLHandle | media_recorder | Handle to the Media Recorder instance. |
MLHandle * | out_input_surface_handle | Handle to the created input native surface. |
Returns
MLResult | MLResult_InvalidParam | Media recorder handle was not found. |
MLResult | MLResult_OK | input surface was correctly returned. |
MLResult | MLResult_UnspecifiedFailure | The operation failed with an unspecified error. |
MLResult | MLMediaGenericResult_InvalidOperation | Method 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
- 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.
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
MLHandle | media_recorder | Handle to the MediaRecorder. |
int32_t * | inout_max_amp | The maximum absolute amplitude measured since the last call, or 0 when called for the first time. |
Returns
MLResult | MLResult_InvalidParam | Mmedia recorder handle was not found. |
MLResult | MLResult_Ok | Maximum amplitude was returned successfully. |
MLResult | MLResult_UnspecifiedFailure | The operation failed with an unspecified error. |
MLResult | MLMediaGenericResult_InvalidOperation | Method was called from the wrong state. |
Required Permissions:
- None
Call this only after the MLMediaRecorderSetAudioSource().
API Level:
- 20
MLMediaRecorderStop
MLResult MLMediaRecorderStop(
MLHandle media_recorder
)
Stops recording.
Parameters
MLHandle | media_recorder | Handle to the MediaRecorder. |
Returns
MLResult | MLResult_InvalidParam | Media recorder handle was not found. |
MLResult | MLResult_Ok | Recorder was stopped successfully. |
MLResult | MLResult_UnspecifiedFailure | The operation failed with an unspecified error. |
MLResult | MLMediaGenericResult_InvalidOperation | Method 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.
API Level:
- 20
MLMediaRecorderReleaseInputSurface
MLResult MLMediaRecorderReleaseInputSurface(
MLHandle media_recorder,
MLHandle input_surface_handle
)
Release the surface that was returned by MLMediaRecorderGetInputSurface.
Parameters
MLHandle | media_recorder | Handle to the MediaRecorder. |
MLHandle | input_surface_handle | Handle to the internal surface object. |
Returns
MLResult | MLResult_InvalidParam | Media recorder handle was not found. |
MLResult | MLResult_Ok | Surface object was successfully released. |
MLResult | MLResult_UnspecifiedFailure | The operation failed with an unspecified error. |
MLResult | MLMediaGenericResult_NoInit | MLMediaCodec was not initialized. |
Required Permissions:
- None
API Level:
- 20
MLMediaRecorderReset
MLResult MLMediaRecorderReset(
MLHandle media_recorder
)
Restarts the MediaRecorder to its idle state.
Parameters
MLHandle | media_recorder | Handle to the media recorder. |
Returns
MLResult | MLResult_InvalidParam | Media recorder handle was not found. |
MLResult | MLResult_Ok | Recorder was resetted successfully. |
MLResult | MLResult_UnspecifiedFailure | The operation failed with an unspecified error. |
MLResult | MLMediaGenericResult_InvalidOperation | Method 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.
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;
Type | Description |
---|---|
MLMediaRecorderError | Video 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.
Type | Description |
---|---|
void()(MLHandle media_recorder, const MLMediaRecorderOnInfo info) | )(MLHandle media_recorder, const MLMediaRecorderOnInfo *info) |
Parameters
media_recorder | Handle is a MediaRecorder instance on which callback was set. | |
pointer | to MLMediaRecorderOnInfo. |
on_track_info
void(*)(MLHandle media_recorder, const MLMediaRecorderOnInfo *track_info) on_track_info;
MediaRecorder received a track-related info/warning message.
Type | Description |
---|---|
void()(MLHandle media_recorder, const MLMediaRecorderOnInfo track_info) | )(MLHandle media_recorder, const MLMediaRecorderOnInfo *track_info) |
Parameters
media_recorder | Handle is a MediaRecorder instance on which callback was set. | |
track_info | pointer to MLMediaRecorderOnInfo. |
on_error
void(*)(MLHandle media_recorder, const MLMediaRecorderOnError *error) on_error;
MediaRecorder received a general error message.
Type | Description |
---|---|
void()(MLHandle media_recorder, const MLMediaRecorderOnError error) | )(MLHandle media_recorder, const MLMediaRecorderOnError *error) |
Parameters
media_recorder | Handle is a MediaRecorder instance on which callback was set. | |
pointer | to MLMediaRecorderOnError. |
on_track_error
void(*)(MLHandle media_recorder, const MLMediaRecorderOnError *track_error) on_track_error;
MediaRecorder received a track-related error message.
Type | Description |
---|---|
void()(MLHandle media_recorder, const MLMediaRecorderOnError track_error) | )(MLHandle media_recorder, const MLMediaRecorderOnError *track_error) |
Parameters
media_recorder | Handle is a MediaRecorder instance on which callback was set. | |
pointer | to MLMediaRecorderError. |