Metadata#
Camera2 offers to possibility to define some character strings that are stored in media files metadata (photo captures, video records).
Camera 1#
This feature is not available on Camera1.
Camera 2#
Media metadata are defined using sub-component Camera2Components.mediaMetadata
.
Available metadata:
Camera2MediaMetadata.copyright
copyright
stored in XMP metadata with identifier
XMP-dc:Rights
defined using sub-component
Camera2Components.mediaMetadata
Camera2MediaMetadata.customId
application custom identifier
stored in XMP metadata with identifier
XMP-drone-parrot:CustomId
Sample code to monitor media metadata:
/** Reference on MainCamera peripheral. */
private var cameraRef: Ref<MainCamera>? = null
/** `MainCamera` peripheral. This is used to know when peripheral appears. */
private var mainCamera: Camera? = null
/** Monitors and prints media metadata. */
fun monitorMediaMetadata(drone: Drone) {
cameraRef = drone.getPeripheral(MainCamera::class.java) { camera ->
// called on main thread when the camera peripheral changes
camera?.run {
// register sub-component listeners, only when camera peripheral appears
if (mainCamera == null) {
// get notified every time copyright metadata sub-component changes
camera.component<Camera.MediaMetadata.Copyright> { copyright ->
copyright?.run {
println("Copyright content: $content")
println("Copyright applying: $applying")
}
}
// get notified every time customId metadata sub-component changes
camera.component<Camera.MediaMetadata.CustomId> { customId ->
customId?.run {
println("CustomId content: $content")
println("CustomId applying: $applying")
}
}
}
}
mainCamera = camera
}
}
Example of output:
Copyright content: Parrot SA 2021
Copyright applying: false
CustomId content: Sample
CustomId applying: false
Sample code to modify copyright metadata:
/** Sets copyright metadata. */
fun setMetadataCopyright(drone: Drone, copyright: String) {
drone.getPeripheral(MainCamera::class.java)?.run {
// get Copyright component
component<Camera.MediaMetadata.Copyright>()?.apply {
setContent(copyright)
} ?: run {
println("Copyright media metadata not available")
}
}
}
Sample code to modify custom ID metadata:
/** Sets custom ID metadata. */
fun setMetadataCustomId(drone: Drone, customId: String) {
drone.getPeripheral(MainCamera::class.java)?.run {
// get CustomId component
component<Camera.MediaMetadata.CustomId>()?.apply {
setContent(customId)
} ?: run {
println("CustomId media metadata not available")
}
}
}