com.webos.service.mediarecorder

Note
This API has been available since API level 27.

API Summary

Provides an interface to record in a webOS device.

Overview of the API

NA 

Methods

close

ACG: mediarecorder.operation
  • Added: API level 27

Description

Closes the recorder and releases all resources.

Parameters

Name

Required

Type

Description

recorderIdRequiredNumber

Unique ID of the recorder.

Note: ID is obtained by using the open() API.

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

Indicates the status of operation. Possible values are:

  • true : Indicates that the operation was successful.
  • false : Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
errorCodeOptionalNumber

The error code for the failed operation.

errorTextOptionalString

The reason for the failure of the operation.

Error Codes Reference

Error Code

Error Text

Error Description

100, 110, 300, 310, 710, 800Depends on error code

Check details of the relevant error codes in the "API Error Codes Reference" table below.

Example

Example scenario

# luna-send -n 1 -f luna://com.webos.service.mediarecorder/close '{"recorderId": 1234}'

Response:

{
    "returnValue": true
}

open

ACG: mediarecorder.operation
  • Added: API level 27

Description

Opens a new recorder. 

Returns a unique ID to the client that is used for subsequent operations to control the recorder.

Parameters

Name

Required

Type

Description

videoOptionalString

Indicates the unique ID of the camera.

Note:

  • You must provide both "video" and "audio", or either "video" or "audio".
  • ID can be obtained using the com.webos.service.camera2/getCameraList() API.
audioOptionalBoolean

Enables audio recording.

Note: 

  • Audio only recording is supported.
  • Management of audio devices can be used through the audio service (com.webos.service.audio) below.
    • Use com.webos.service.audio/listSupportedDevices() to get the list of supported audio devices
    • Use com.webos.service.audio/setSoundOutput() to set the sound input device for recording.
    • Use com.webos.service.audio/getSoundInput() to get the currently active sound input device.

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

Indicates the status of operation. Possible values are:

  • true : Indicates that the operation was successful.
  • false : Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
recorderIdOptionalNumber

Unique identifier to control the recorder.

errorCodeOptionalNumber

The error code for the failed operation.

errorTextOptionalString

The reason for the failure of the operation.

Error Codes Reference

Error Code

Error Text

Error Description

100, 110, 200, 210, 700Depends on error code

Check details of the relevant error codes in the "API Error Codes Reference" table below.

Example

Example : Camera recording with audio

# luna-send -n 1 -f luna://com.webos.service.mediarecorder/open '{"video": "camera1","audio": true}'

Response:

{
    "returnValue": true,
    "recorderId": 1234
}

Example : Camera recording without audio

# luna-send -n 1 -f luna://com.webos.service.mediarecorder/open '{"video": "camera1"}'

Response:

{
    "returnValue": true,
    "recorderId": 1234
}

Example : Audio only recording

# luna-send -n 1 -f luna://com.webos.service.mediarecorder/open '{"audio": true}'

Response:

{
    "returnValue": true,
    "recorderId": 1234
}

pause

ACG: mediarecorder.operation
  • Added: API level 29

Description

Pauses recording.

Note: Call this API after start() but before stop() or resume().

Parameters

Name

Required

Type

Description

recorderIdRequiredNumber

Unique ID of the recorder.

Note: ID is obtained by using the open() API.

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

Indicates the status of the operation.

Possible values are:

  • true: Operation is successful.
  • false: Operation has failed. Check the 'errorCode' and 'errorText' fields.
errorCodeOptionalNumber

The error code for the failed operation.

errorTextOptionalString

The reason for the failure of the operation. See the methods 'Error Codes' section for details.

Error Codes Reference

Error Code

Error Text

Error Description

100, 110, 300, 310, 630, 800Depends on error code

Check details of the relevant error codes in the "API Error Codes Reference" table below.

Example

Example scenario

# luna-send -n 1 -f luna://com.webos.service.mediarecorder/pause '{"recorderId": 1234}'

Response:

{
    "returnValue": true
}

resume

ACG: mediarecorder.operation
  • Added: API level 29

Description

Resumes recording.

Note: Call this API after pause() but before stop().

Parameters

Name

Required

Type

Description

recorderIdRequiredNumber

Unique ID of the recorder.

Note: ID is obtained by using the open() API.

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

Indicates the status of the operation.

Possible values are:

  • true: Operation is successful.
  • false: Operation has failed. Check the 'errorCode' and 'errorText' fields.
errorCodeOptionalNumber

The error code for the failed operation.

errorTextOptionalString

The reason for the failure of the operation. See the methods 'Error Codes' section for details.

Error Codes Reference

Error Code

Error Text

Error Description

100, 110, 300, 310, 640, 800Depends on error code

Check details of the relevant error codes in the "API Error Codes Reference" table below.

Example

Example scenario

# luna-send -n 1 -f luna://com.webos.service.mediarecorder/resume '{"recorderId": 1234}'

Response:

{
    "returnValue": true
}

setAudioFormat

ACG: mediarecorder.operation
  • Added: API level 29

Description

Sets the audio format.

Note: Call this API after open() but before start().

Parameters

Name

Required

Type

Description

recorderIdRequiredNumber

Unique ID of the recorder.

Note: ID is obtained by using the open() API.

codecOptionalString

Set the audio encoder to use for recording.

Possible values are:

  • AAC

Note: Currently supports only AAC

bitRateOptionalNumber

Set the audio encoding bitrate (in bits/s).

Default : 0 (Automatically adjust bitrate)

sampleRateOptionalNumber

Set the audio sample rate.

Possible values are:

  • When using AAC encoder.

    • 7350
    • 8000
    • 11025
    • 12000
    • 16000
    • 22050
    • 24000
    • 32000
    • 44100 (default)
    • 48000
    • 64000
    • 88200
    • 96000
channelCountOptionalNumber

Set the number of audio channels

Possible values are:

  • When using AAC encoder.

    • 1
    • 2 (default - stereo)
    • 3
    • 4

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

Indicates the status of the operation.

Possible values are:

  • true: Operation is successful.
  • false: Operation has failed. Check the 'errorCode' and 'errorText' fields.
errorCodeOptionalNumber

The error code for the failed operation.

errorTextOptionalString

The reason for the failure of the operation. See the methods 'Error Codes' section for details.

Error Codes Reference

Error Code

Error Text

Error Description

100, 110, 300, 310, 540, 730, 800Depends on error code

Check details of the relevant error codes in the "API Error Codes Reference" table below.

Example

Example scenario

# luna-send -n 1 -f luna://com.webos.service.mediarecorder/setAudioFormat '{
   "recorderId": 1234,
   "codec":"AAC",
   "bitRate":192000,
   "sampleRate":48000,
   "channelCount":2
}'

Response:

{
    "returnValue": true
}

setOutputFile

ACG: mediarecorder.operation
  • Added: API level 27

Description

Sets the path to store the streaming data. 

The default file name is of the format "RecordDDMMYYYY-HHMMSS", where DDMMYYYY-HHMMSS is current date and time.

  • Call this after open() but before start().

Note: If not explicitly set by calling this method, the default path is /media/internal/.

Parameters

Name

Required

Type

Description

recorderIdRequiredNumber

Unique ID of the recorder.

Note: ID is obtained by using the open() API.

pathRequiredString

Absolute path to the directory where the recorded file must be saved.

Possible values are:

  • /media/internal/
  • /tmp/

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

Indicates the status of operation. Possible values are:

  • true : Indicates that the operation was successful.
  • false : Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
errorCodeOptionalNumber

The error code for the failed operation.

errorTextOptionalString

The reason for the failure of the operation.

Error Codes Reference

Error Code

Error Text

Error Description

100, 110, 300, 310, 400, 800, 900Depends on error code

Check details of the relevant error codes in the "API Error Codes Reference" table below.

Example

Example scenario

# luna-send -n 1 -f luna://com.webos.service.mediarecorder/setOutputFile '{"recorderId": 1234,"path":"/media/internal/"}'

Response:

{
    "returnValue": true
}

setOutputFormat

ACG: mediarecorder.operation
  • Added: API level 27

Description

Sets the specified format to store the streaming data.

Note: Call this API after open() but before start().

Parameters

Name

Required

Type

Description

recorderIdRequiredNumber

Unique ID of the recorder.

Note: ID is obtained by using the open() API.

formatRequiredString

Format in which data is stored.

Possible values are:

  • MP4 (Note: When recording video only or video with audio).
  • M4A (Note: When recording audio only).

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

Indicates the status of operation. Possible values are:

  • true : Indicates that the operation was successful.
  • false : Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
errorCodeOptionalNumber

The error code for the failed operation.

errorTextOptionalString

The reason for the failure of the operation.

Error Codes Reference

Error Code

Error Text

Error Description

100, 110, 300, 310, 500, 510, 800Depends on error code

Check details of the relevant error codes in the "API Error Codes Reference" table below.

Example

Example scenario

# luna-send -n 1 -f luna://com.webos.service.mediarecorder/setOutputFormat '{"recorderId": 1234,"format":"MP4"}'

Response:

{
    "returnValue": true
}

setVideoFormat

ACG: mediarecorder.operation
  • Added: API level 29

Description

Sets the video format.

Note: Call this API after open() but before start().

Parameters

Name

Required

Type

Description

recorderIdRequiredNumber

Unique ID of the recorder.

Note: ID is obtained by using the open() API.

codecOptionalString

Set the audio encoder to use for recording.

Possible values are:

  • H264

Note: Currently supports only H264

bitRateOptionalNumber

Set the video encoding bitrate(in bits/s).

Default value: 10000000

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

Indicates the status of the operation.

Possible values are:

  • true: Operation is successful.
  • false: Operation has failed. Check the 'errorCode' and 'errorText' fields.
errorCodeOptionalNumber

The error code for the failed operation.

errorTextOptionalString

The reason for the failure of the operation. See the methods 'Error Codes' section for details.

Error Codes Reference

Error Code

Error Text

Error Description

100, 110, 300, 310, 530, 550, 720, 800Depends on error code

Check details of the relevant error codes in the "API Error Codes Reference" table below.

Example

Example scenario

# luna-send -n 1 -f luna://com.webos.service.mediarecorder/setVideoFormat '{
   "recorderId": 1234,
   "codec":"H264",
   "bitRate":10000000
}'

Response:

{
    "returnValue": true
}

start

ACG: mediarecorder.operation
  • Added: API level 27

Description

Starts recording.

Parameters

Name

Required

Type

Description

recorderIdRequiredNumber

Unique ID of the recorder.

Note: ID is obtained by using the open() API.

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

Indicates the status of operation. Possible values are:

  • true : Indicates that the operation was successful.
  • false : Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
errorCodeOptionalNumber

The error code for the failed operation.

errorTextOptionalString

The reason for the failure of the operation.

Error Codes Reference

Error Code

Error Text

Error Description

100, 110, 300, 310, 600, 800Depends on error code

Check details of the relevant error codes in the "API Error Codes Reference" table below.

Example

Example scenario

# luna-send -n 1 -f luna://com.webos.service.mediarecorder/start '{"recorderId": 1234}'

Response:

{
    "returnValue": true
}

stop

ACG: mediarecorder.operation
  • Added: API level 27

Description

Stops recording and saves the output to file.

Parameters

Name

Required

Type

Description

recorderIdRequiredNumber

Unique ID of the recorder.

Note: ID is obtained by using the open() API.

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

Indicates the status of operation. Possible values are:

  • true : Indicates that the operation was successful.
  • false : Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
errorCodeOptionalNumber

The error code for the failed operation.

errorTextOptionalString

The reason for the failure of the operation.

pathOptionalString

Indicates the path and file names of the saved file.

Error Codes Reference

Error Code

Error Text

Error Description

100, 110, 300, 310, 610, 800Depends on error code

Check details of the relevant error codes in the "API Error Codes Reference" table below.

Example

Example scenario

# luna-send -n 1 -f luna://com.webos.service.mediarecorder/stop '{"recorderId": 1234}'

<Record video and audio or record video only>

Response:

{
    "returnValue": true,
    "path": "/media/internal/Record03122023-17171504.mp4"
}

<Record audio only>

Response:

{
    "returnValue": true,
    "path": "/media/internal/Audio03122023-17174953.m4a"
}

takeSnapshot

ACG: mediarecorder.operation
  • Added: API level 27

Description

Takes one video snapshot during recording and save the image to a file.

The default file name is of the format "CaptureDDMMYYYY-HHMMSS", where DDMMYYYY-HHMMSS is current date and time.

Parameters

Name

Required

Type

Description

recorderIdRequiredNumber

Unique ID of the recorder.

Note: ID is obtained by using the open() API.

pathRequiredString

Absolute path to the directory where the snapshot image must be saved.

Possible values are:

  • /media/internal/
  • /tmp/
formatRequiredString

Indicates the format of the snapshot image.

Possible values are:

  • JPEG

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

Indicates the status of operation. Possible values are:

  • true : Indicates that the operation was successful.
  • false : Indicates that the operation failed. Check the "errorCode" and "errorText" fields for details.
errorCodeOptionalNumber

The error code for the failed operation.

errorTextOptionalString

The reason for the failure of the operation.

pathOptionalString

Indicates the path and file names of the saved file.

Error Codes Reference

Error Code

Error Text

Error Description

100, 110, 300, 310, 400, 500, 510, 620, 800, 900Depends on error code

Check details of the relevant error codes in the "API Error Codes Reference" table below.

Example

Example scenario

# luna-send -n 1 -f luna://com.webos.service.mediarecorder/takeSnapshot '{"recorderId": 1234,"path":"/media/internal/","format":"JPEG"}'

Response:

{
    "returnValue": true,
    "path": "/media/internal/Capture03122023-17173792.jpeg"
}

API Error Codes Reference

Error Code

Error Text

Error Description

100JSON parsing error

There is an error during JSON parsing.

110JSON type error

Trying to access a JSON value with the incorrect data type.

200Source must be specified

Source not provided for recording action.

210Audio only recording is not supported

Audio recording alone is currently not supported, will be available in a future release.

300Recorder ID must be specified

Unique ID for the recorder not provided.

310Recorder ID is invalid

The provided recorder ID is not valid or does not exist.

400Path must be specified

Required path information is missing.

500Format must be specified

Required format information is missing.

510Unsupported format

The format is not supported.

520Failed to open camera

Attempt to open camera has failed.

530Video bitrate is out of range

The bitrate of the video is not within the acceptable range.

540Unsupported audio format

Unsupported audio format

550Unsupported video format

Unsupported video format

600Failed to start recording

Attempt to begin recording process has failed.

610Failed to stop recording

Unsuccessful in stopping an ongoing recording.

620Snapshot capture failed

Snapshot attempt was not successful.

630Failed to pause

Attempted to pause recording, but failed.

640Failed to resume

Attempted to resume recording, but failed.

700Failed to open recorder

Opening the recorder was unsuccessful or encountered an error.

710Failed to close recorder

Closing the recorder was unsuccessful or encountered an error.

720Video is not opened

Occurs when you try to set the video format when the video is not open.

730Audio is not opened

Occurs when you try to set the audio format when the audio is not open.

800Invalid state

The recorder is not in the appropriate state to perform the action.

900Cannot write at specified location

Cannot save or write data at the specified location.

Contents