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 Camera.Config.STORAGE_POLICY
.
Sample code to monitor media storage policy:
/** Reference on MainCamera peripheral. */
private var cameraRef: Ref<MainCamera>? = null
/** Monitors and prints media storage policy. */
fun monitorMediaStoragePolicy(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.STORAGE_POLICY].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 {
println("Current value: $value")
}
}
}
}
}
Example of output:
Current value is: AUTOMATIC
Sample code to modify media storage policy:
/** Sets media storage policy. */
fun setMediaStoragePolicy(drone: Drone, policy: Camera.StoragePolicy) {
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.STORAGE_POLICY].let { configParam ->
// change parameter value,
// and unset other parameters conflicting with this new value
configParam.value = policy
// 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)
.