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#

Sample code to monitor audio recording mode:

/// Keep reference on MainCamera2 peripheral to get notified of changes.
private var cameraRef: Ref<MainCamera2>?

/// Monitors and prints audio recording mode.
func monitorAudioRecordingMode(drone: Drone) {
    cameraRef = drone.getPeripheral(Peripherals.mainCamera2) { camera in
        // called on main thread when the camera peripheral changes
        if let camera = camera {
            // get configuration parameter
            if let configParam = camera.config[Camera2Params.audioRecordingMode] {
                if configParam.currentSupportedValues.isEmpty {
                    // parameter value is not relevant
                    // if there is not supported values in current configuration
                    print("No supported value in current configuration")
                } else {
                    // get parameter value
                    let mode = configParam.value
                    print("Current value is: \(mode)")

Example of output:

Current value is: mixDroneController

Sample code to modify audio recording mode:

/// Sets audio recording mode.
func setAudioRecordingMode(drone: Drone, mode: Camera2AudioRecordingMode) {
    if let camera = drone.getPeripheral(Peripherals.mainCamera2) {
        // create configuration editor, starting from current configuration
        let editor = camera.config.edit(fromScratch: false)
        // retrieve configuration parameter
        if let configParam = editor[Camera2Params.audioRecordingMode] {
            // change parameter value,
            // and unset other parameters conflicting with this new value
            configParam.value = mode
            // complete configuration, by setting missing parameters values
            // send new configuration to drone

Trying to change the parameter value to an unsupported value has no effect. Values supported by the camera are provided by the parameter field configParam.overallSupportedValues.