Docs/MediaManagement

From Apertis
Jump to: navigation, search

Contents

Media Management Features

Media Playability

Tracker will index medias using GstDiscoverer. If the media container is not known, indexing fails and the file won't appear at all in tracker's DB. If the container is known then the metadata are parsed and stored in tracker.

Additionally, we added a bosch:playable boolean property on nfo:Media class telling if everything else are supported by gstreamer to play that media. It is for example possible that gstreamer has the plugin to parse the container, but not the codec to decode the audio and/or video. Not all medias are parsed using gstreamer, so a missing bosch:playable property should be interpreted as if the media IS playable.

Example query to get all playable medias:

 select ?url where {
   ?o a nfo:Media;
     nie:url ?url.
   FILTER (NOT EXISTS {
     ?o bosch:playable false
   })
 }

When new gstreamer plugins are installed (e.g. codecs), package's post-install script should tell tracker to re-index affected media files. For example package adding support for wmv files should run this command:

 tracker-control --reindex-mime-type video/x-ms-asf

Indexing removable media

The Apertis Tracker package now indexes removable media by default and its automated tests to check configuration and successful indexing have been updated accordingly.

Media thumbnail generation

The Apertis Tracker package has been patched to automatically request from the thumbnailing service (Tumbler) thumbnails for indexed media. We have added the auto-thumbnailing test case to ensure this feature.

Indexing prioritization

The Apertis Tracker package has been patched to include a Priority DBus interface. That interface allows UI applications to inform tracker about the media type that needs to be extracted in priority. For example the Music application, when displayed to the user, can tell tracker to index audio files first.

Tracker also index files in 2 passes: First it queries only the file attributes (e.g. mime type, size, etc). When the first pass is done on all files, it will extract meta-data information (e.g. Author, title, etc). UI should use Grilo to display medias, and grilo will correctly update itself when extra information are known about a displayed media.

Sample code

Grilo

  • grilo filesystem browsing example: examine grilo metadata for files below a given directory. This example code has been enhanced in the Gyokuro release cycle to also print out the URI of the media's thumbnail (if available).

Thumbnailing files

Apertis includes a thumbnailing service named Tumbler. It implements functionality similar to the Thumbnailer Specification with the D-Bus interface "/org/freedesktop/thumbnails/Thumbnailer1". The "Queue" D-Bus method allows clients to request the creation of thumbnails for files. This service supports a wide range of file formats, including most image, office, and PDF documents.

On the command line

The functionality can be tested out with the "dbus-send" command line program. The basic form to request a thumbnail is:

dbus-send \
    --session \
    --dest=org.freedesktop.thumbnails.Thumbnailer1 \
    /org/freedesktop/thumbnails/Thumbnailer1 \
    org.freedesktop.thumbnails.Thumbnailer1.Queue \
    array:string:URI \
    array:string:MIME_TYPE \
    string:FLAVOR \
    string:SCHEDULER \
    uint32:REQUEST_HANDLE_TO_DEQUEUE

Arguments are:

  • URI: the URI of the file to be thumbnailed (eg, "file:///path/to/file.jpg")
  • MIME_TYPE: the MIME type for the file (eg, "image/jpeg")
  • FLAVOR: the type of thumbnail to generate. Choose from "normal" or "large".
  • SCHEDULER: the algorithm to schedule the thumbnailing with. The option "default" is usually best.
  • REQUEST_HANDLE_TO_DEQUEUE: Queue operations return an integer representing the request. This can be used to cancel the operation if it has not completed yet.

Returns:

  • REQUEST_HANDLE: this integer can be used in a future Queue or Dequeue method call to cancel the operation, if it has not yet completed

By default, dbus-send does not wait for the return value. You can force it to print the response (or error, if there is a problem) with the --print-reply option.

For a specific example, to thumbnail the image /usr/share/pixmaps/xoo.png:

dbus-send \
    --session \
    --print-reply \
    --dest=org.freedesktop.thumbnails.Thumbnailer1 \
    /org/freedesktop/thumbnails/Thumbnailer1 \
    org.freedesktop.thumbnails.Thumbnailer1.Queue \
    array:string:"file:///usr/share/pixmaps/xoo.png" \
    array:string:"image/png" \
    string:"normal" \
    string:"default" \
    uint32:0

If you are unsure of the MIME type of a specific file, you can get it with the command:

file --mime-type -b FILE

This method can take any number of files as arguments. You must ensure that the list of MIME types matches the list of files. For example:

dbus-send \
    --session \
    --print-reply \
    --dest=org.freedesktop.thumbnails.Thumbnailer1 \
    /org/freedesktop/thumbnails/Thumbnailer1 \
    org.freedesktop.thumbnails.Thumbnailer1.Queue \
    array:string:"file:///usr/share/pixmaps/xoo.png","file:///usr/share/chaiwala-tests/resources/media/images/320px-European_Common_Frog_Rana_temporaria.jpg" \
    array:string:"image/png","image/jpeg" \
    string:"normal" \
    string:"default" \
    uint32:0

In a C program

// These are the generic name and interface that Tumbler implements
#define THUMBNAILER_SERVICE        "org.freedesktop.thumbnails.Thumbnailer1"
#define THUMBNAILER_PATH           "/org/freedesktop/thumbnails/Thumbnailer1"
#define THUMBNAILER_INTERFACE      "org.freedesktop.thumbnails.Thumbnailer1"

// ...

    const char *uri_strv[] = {
        "file:///usr/share/pixmaps/xoo.png",
        "file:///usr/share/chaiwala-tests/resources/media/images/320px-European_Common_Frog_Rana_temporaria.jpg",
        NULL};
    const char *mime_types_strv = {"image/png","image/jpeg", NULL};
    /* don't try to dequeue any operations at the same time */
    guint handle_to_dequeue = 0;
    normal-size (vs. "large")? */
    const gchar *flavor = "normal";
    const gchar *scheduler = "default";
    GDBusProxy *manager_proxy;
    GDBusConnection *connection;
    GError *error = NULL;

    /* Use the async versions of these functions if it is important that your
     * program not block (eg, if it is a UI).
     *
     * A regular program would store these instead of re-creating them
     * constantly.
     */
    connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
    if (error) {
       g_error ("Failed to connect to D-Bus session bus: %s",
           error->message");
       g_error_free (error);
       return FALSE; // indicating failure
    }
    manager_proxy = g_dbus_proxy_new_sync (connection,
        G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES, NULL,
        THUMBNAILER_SERVICE, THUMBNAILER_PATH, THUMBNAILER_INTERFACE, NULL,
        &error);
    if (error) {
       g_error ("Failed to create thumbnailer proxy: %s", error->message");
       g_error_free (error);
       return FALSE; // indicating failure
    }

    /* to receive the method response (the request handle), include a
     * GAsyncReadyCallback which calls g_dbus_proxy_call_finish() and callback
     * data as the last two arguments */
    g_dbus_proxy_call (manager_proxy, "Queue",
        g_variant_new ("(^as^asssu)",
            uri_strv, mime_types_strv,
            flavor, scheduler, handle_to_dequeue),
        G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL);

    g_object_unref (manager_proxy);
    g_object_unref (connection);

Setting priority

Setting the priority to a given media type is doing via the SetRdfTypes DBus method. For example, setting priority to audio files:

dbus-send \
    --session \
    --print-reply \
    --dest=org.freedesktop.Tracker1.Miner.Extract \
    /org/freedesktop/Tracker1/Extract/Priority \
    org.freedesktop.Tracker1.Extract.Priority.SetRdfTypes \
    array:string:"nfo:Audio"

Possible values are:

 nfo:Document
 nfo:Audio
 nfo:Image
 nfo:Video
 nfo:FilesystemImage
Personal tools
Namespaces

Variants
Actions
Navigation
Tools