Skip to content

core: Add a clear distinction between Single and Groups of metadata-keys

Victor Toso requested to merge victortoso/grilo:media-related-keys into master

Related: #145

As this moment there is a mix of what you can do with Grilo API.

  1. Set a metadata-key, like a single value:
grl_meda_set_artist(media, "Queen");
{
  "artist": "Queen"
}
  1. Add a metadata-key, like an array of values:
grl_media_add_artist(media, "Freddie Mercury");
grl_media_add_artist(media, "Roger Taylor");
{
  "artist": ["Freddie Mercury", "Roger Taylor"]
}
  1. You can use a GrlRelatedKey to group metadata-key, as together they make sense
relkeys = grl_related_keys_new_with_keys (GRL_METADATA_KEY_ARTIST, "Freddie Mercury",                                                                                                                                                                                                                                                                  
                                          GRL_METADATA_KEY_MB_ARTIST_ID, "022589ac-7177-460d-a178-9976cf70e29f",
                                          NULL);
grl_data_add_related_keys (GRL_DATA (media), relkeys);
{
  "grl-related-keys":
  [
    {
      "artist": "Freddie Mercury",
      "mb-artist-id": "022589ac-7177-460d-a178-9976cf70e29f"
    }
  ]
}
  1. You can both ways: the same metadata-key set single and together with related keys in a GrlRelatedKey.
grl_meda_set_artist(media, "Queen");
relkeys = grl_related_keys_new_with_keys (GRL_METADATA_KEY_ARTIST, "Freddie Mercury",                                                                                                                                                                                                                                                                  
                                          GRL_METADATA_KEY_MB_ARTIST_ID, "022589ac-7177-460d-a178-9976cf70e29f",
                                          NULL);
grl_data_add_related_keys (GRL_DATA (media), relkeys);
{
  "artist": "Queen",
  "grl-related-keys":
  [
    {
      "artist": "Freddie Mercury",
      "mb-artist-id": "022589ac-7177-460d-a178-9976cf70e29f"
    }
  ]
}

This MR tries to clarify the difference between single and groups of metadata-keys in GrlData.

The main objective is that the API user should refer to grl_related_keys API to interact with group of metadata-keys and only use grl_data_add/set or grl_media_add/set for single metadata-keys.

This is a initial proposal.

We might need:

  • To deprecate a few APIs too, like grl_data_length (see this TODO)
  • Add some more APIs
  • Need some more testing and likely some fixing outside Grilo too...
Edited by Victor Toso

Merge request reports