mpd:
- manifest_edit.plugins.mpd.label_add:
    # This config file makes use of the "label_add" plugin to add a
    # "Label" and a "GroupLabel" elements to a manifest.
    #
    # "label_add" allows to specify the position where the label
    # will be added with reference to a specific Representation or
    # Adaptation Set, inside one or more Period if necessary. This reflects
    # the general structure of a DASH manifest, which is briefly recapped
    # here to better clarify how to configure the plugin.
    #
    # Tracks in mpd manifests are specified as list of Representations
    # inside a given Adaptation Set, inside a given Period. The general
    # scheme can roughly be illustrated as
    #
    # Manifest:
    #  |- Period id:
    #     id = "id"
    #     |- AdaptationSet :
    #        contentType = "audio"
    #        |- Representation
    #        |-   ...
    #        |- Representation
    #     |- AdaptationSet :
    #        contentType = "video"
    #        |- Representation
    #        |-   ...
    #        |- Representation
    #
    # In an mpd there could be multiple periods, each with multiple
    # adaptation sets, each with multiple representations, to form an
    # arbitrarily nested structure.
    #
    # The label_add plugin allows to add a label to any Adaptation Set or
    # Representation in any period.
    # This is done by selecting the desired element by means if its properties,
    # as illustrated by the following examples:
    #
    # 1) add a label to all adaptation sets in all periods.
    #
    #    periods:
    #      - '*' : '.*'
    #        adaptationSets:
    #          - '*' : '.*'
    #            plugin_config:
    #              label:
    #                id: 0
    #                lang: "en"
    #                data: "my label"
    #
    # 2) add a label to all adaptation sets having
    #    a "video" contentType, in all periods that have an 'id'
    #    property
    #
    #    periods:
    #      - id : '.*'
    #        adaptationSets:
    #          - contentType :  "video"
    #            plugin_config:
    #              label:
    #                id: 0
    #                lang: "en"
    #                data: "my label"
    #
    # 3) add a Label and a GroupLabel to all representations, in all
    #    adaptation sets having a "video" contentType, in all periods.
    #
    #    periods:
    #      - '*' : '.*'
    #        adaptationSets:
    #          - contentType :  "video"
    #            representations:
    #              - '*' : '.*'
    #                plugin_config:
    #                  label:
    #                    id: 0
    #                    lang: "en"
    #                    data: "my label"
    #                  groupLabel:
    #                    id: 0
    #                    lang: "en"
    #                    data: "my group label"
    #
    # Since labels can only be added to specific elements (i.e.
    # Label and GroupLabel can only be present in an Adaptation Set or
    # Representation, not in a Period), the plugin will check for "impossible"
    # configurations and will only perform manipulations leading to a
    # DASH-compliant manifest.
    #
    # In addition to providing a specific "static" string as label, a
    # template syntax is available to use a "dynamic" string that can include
    # values read at runtime from attributes of the Period, Adaptation Set or
    # Representation where the Label is being added. In other words, it is
    # possible to build the Label based on, i.e. a Representation's id,
    # resolution or codec using a syntax similar to "This track has resolution
    # {width}x{height}". The template values within curly braces "{width}" and
    # "{height}" will be replaced at runtime by the actual values present in
    # the manifest for that Representation, generating labels such as "This
    # track has resolution 1280×720".
    #
    # More details about the template syntax and in general about the plugin
    # are available in manifest edit documentation.
    periods:
      - id: ".*"
        adaptationSets:
        - contentType :  "audio"
          plugin_config:
            label:
              id : 1
              lang: "{ISO639Alpha3(lang)}"
              data: "{ISO639Name(lang)}"
        - contentType :  "video"
          plugin_config:
            groupLabel:
              id : 1
              lang: "{lang}"
              data: "my group label"
        - contentType :  "video"
          representations:
          # matches width < 720
          - width: '^([0-6]\d\d|[7][0-1]\d|\d{1,2})$'
            plugin_config:
              label:
                id : 1
                data: "label for Standard Definition track {id}"
          # matches width >= 720
          - width: '^([8-9]\d+|[7][2-9]\d|\d{4,})$'
            plugin_config:
              label:
                id : 1
                data: "label for High Definition track {id}"
        # select adaptation set by Role
        - role: "main"
          lang: "fr"
          plugin_config:
            label:
              data: "Français"
        - role: "alternate"
          lang: "fr"
          plugin_config:
            label:
              data: "Français (Audio description)"
        - role: "subtitle"
          lang: "fr"
          plugin_config:
            label:
              data: "Français (Sourds et malentendants)"