Media storage policy#

Camera2 offers to possibility to configure where media files should be stored:

  • internal: store media files in internal drone storage.

  • removable: store media files in removable storage.

  • automatic: let the drone choose where media files are stored.

Camera 1#

This feature is not available on Camera1.

Camera 2#

Media storage policy is configured with parameter Camera2Params.storagePolicy.

Sample code to monitor media storage policy:

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

// Monitors and prints media storage policy.
func monitorMediaStoragePolicy(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.storagePolicy] {
                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 storagePolicy = configParam.value
                    print("Current value is: \(storagePolicy)")
                }
            }
        }
    }
}

Example of output:

Current value is: automatic

Sample code to modify media storage policy:

/// Sets media storage policy.
func setMediaStoragePolicy(drone: Drone, storagePolicy: Camera2StoragePolicy) {
    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.storagePolicy] {
            // change parameter value,
            // and unset other parameters conflicting with this new value
            configParam.value = storagePolicy
            // 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 provided by the parameter field configParam.overallSupportedValues.