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.

  • Camera2MediaMetadata.customId: application custom identifier, stored in XMP metadata with identifier XMP-drone-parrot:CustomId.

Sample code to monitor media metadata:

/// Keep reference on Camera2MediaMetadata component to get notified of changes.
private var mediaMetadataRef: Ref<Camera2MediaMetadata>?

/// Monitors and prints media metadata.
func monitorMediaMetadata(drone: Drone) {
    if let camera = drone.getPeripheral(Peripherals.mainCamera2) {
        // get mediaMetadata component reference and register listener
        mediaMetadataRef = camera.getComponent(Camera2Components.mediaMetadata) { mediaMetadata in
            if let copyright = mediaMetadata?.copyright {
                print("Copyright: \(copyright)")
            }
            if let customId = mediaMetadata?.customId {
                print("CustomId: \(customId)")
            }
        }
    }
}

Example of output:

Copyright: Parrot SA 2021
CustomId: Sample

Sample code to modify copyright metadata:

/// Sets copyright metadata.
func setMetadataCopyright(drone: Drone, copyright: String) {
    if let camera = drone.getPeripheral(Peripherals.mainCamera2) {
        // get mediaMetadata component
        if let mediaMetadata = camera.getComponent(Camera2Components.mediaMetadata) {
            mediaMetadata.copyright = copyright
        } else {
            // mediaMetadata component not available
            print("Media metadata not available")
        }
    }
}

Sample code to modify custom ID metadata:

/// Sets custom ID metadata.
func setMetadataCustomId(drone: Drone, customId: String) {
    if let camera = drone.getPeripheral(Peripherals.mainCamera2) {
        // get mediaMetadata component
        if let mediaMetadata = camera.getComponent(Camera2Components.mediaMetadata) {
            mediaMetadata.customId = customId
        } else {
            // mediaMetadata component not available
            print("Media metadata not available")
        }
    }
}