Audio recording mode#

Camera2 offers to possibility to record audio while recording a video.

A configuration parameter is provided to enable or disable audio recording and to select which audio source to use: drone, controller or both.

Camera 1#

This feature is not available on Camera1.

Camera 2#

Audio recording mode is configured with parameter Camera.Config.AUDIO_RECORDING_MODE.

Sample code to monitor audio recording mode:

/** Reference on MainCamera peripheral. */
private var cameraRef: Ref<MainCamera>? = null

/** Monitors and prints audio recording mode. */
fun monitorAudioRecordingMode(drone: Drone) {
    cameraRef = drone.getPeripheral(MainCamera::class.java) { camera ->
        // called on main thread when the camera peripheral changes
        camera?.run {
            // get configuration parameter
            config[Camera.Config.AUDIO_RECORDING_MODE].run {
                if (supportedValues(onlyCurrent = true).isEmpty()) {
                    // parameter value is not relevant
                    // if there is not supported values in current configuration
                    println("No supported value in current configuration")
                } else {
                    // print parameter value
                    println("Current value: $value")
                }
            }
        }
    }
}

Example of output:

Current value: DRONE

Sample code to modify audio recording mode:

/** Sets audio recording mode. */
fun setAudioRecordingMode(drone: Drone, mode: Camera.AudioRecordingMode) {
    drone.getPeripheral(MainCamera::class.java)?.run {
        // create configuration editor, starting from current configuration
        val editor = config.edit(fromScratch = false)
        // get configuration parameter
        editor[Camera.Config.AUDIO_RECORDING_MODE].let { configParam ->
            // change parameter value,
            // and unset other parameters conflicting with this new value
            configParam.value = mode
            // complete configuration, by setting missing parameters values
            editor.autoComplete()
            // send new configuration to drone
            editor.commit()
        }
    }
}

Trying to change the parameter value to an unsupported value has no effect. Values supported by the camera are retrieved by calling configParam.supportedValues(onlyCurrent = false).