Top |
Types and Values
enum | MediaArtType |
enum | MediaArtError |
enum | MediaArtProcessFlags |
struct | MediaArtProcess |
struct | MediaArtProcessClass |
Description
The libmediaart library supports taking image data that you have extracted
from a media file and saving it into the media art cache, so that future
applications can display the media art without having to extract the image
again. This is done using the media_art_process_file()
or
media_art_process_buffer()
functions.
Extracting new media art from a file needs to be done by your application.
Usually, when an application loads a media file any embedded images will be
made available as a side effect. For example, if you are using GStreamer any
images will be returned through the GstTagList interface as GST_TAG_IMAGE
tags.
The media art cache requires that all images are saved as 'application/jpeg'
files. Embedded images can be in several formats, and
media_art_process_file()
and media_art_process_buffer()
functions will
convert the supplied image data into the correct format if
necessary. There are multiple backends that can be used for this,
and you can choose which is used at build time using the library's
'configure' script.
If there is no embedded media art in a file,
media_art_process_file()
and media_art_process_buffer()
functions will
look in the directory that contains the media file for likely media
art using a simple heuristic.
Functions
media_art_process_new ()
MediaArtProcess *
media_art_process_new (GError **error
);
Initialize a GObject for processing and extracting media art.
This function initializes cache hash tables, backend plugins, storage modules used for removable devices and a connection to D-Bus.
Returns
A new MediaArtProcess object on success or NULL
if
error
is set. This object must be freed using g_object_unref()
.
Since 0.5.0
media_art_process_uri ()
gboolean media_art_process_uri (MediaArtProcess *process
,MediaArtType type
,MediaArtProcessFlags flags
,const gchar *uri
,const gchar *artist
,const gchar *title
,GCancellable *cancellable
,GError **error
);
This function calls media_art_process_file()
, but takes the uri
as
a string rather than a GFile object. Either artist
OR title
can be
NULL
, but they can not both be NULL
.
Parameters
process |
Media art process object |
|
type |
The type of media that contained the image data |
|
flags |
How the media art is processed |
|
uri |
URI of the media file that contained the data |
|
artist |
The artist name |
[allow-none] |
title |
The title for |
[allow-none] |
cancellable |
optional GCancellable object, |
[allow-none] |
error |
Pointer to potential GLib / MediaArt error, or |
Since 0.5.0
media_art_process_file ()
gboolean media_art_process_file (MediaArtProcess *process
,MediaArtType type
,MediaArtProcessFlags flags
,GFile *file
,const gchar *artist
,const gchar *title
,GCancellable *cancellable
,GError **error
);
Process file
and check if media art exists and if it is up to date
with artist
and title
provided. Either artist
OR title
can be
NULL
, but they can not both be NULL
.
NOTE: This function MAY retrieve media art for
artist
and title
combinations. It is not guaranteed and depends
on download services available over DBus at the time.
In cases where download is unavailable, media_art_process_file()
will only try to procure a cache for possible media art found in
directories surrounding the location of file
. If a buffer or
memory chunk needs to be saved to disk which has been retrieved
from an MP3 (for example), you should use
media_art_process_buffer()
.
The modification time (mtime) of file
is checked against the
cached stored for artist
and title
. If the cache is old or
doesn't exist, it will be updated. What this actually does is
update the mtime of the cache (a symlink) on the disk.
If there is no actual media art stored locally (for example, it's stored in a directory on a removable device), it is copied locally (usually to an XDG cache directory).
If file
is on a removable filesystem, the media art file will be
saved in a cache on the removable file system rather than on the
host machine.
Parameters
process |
Media art process object |
|
type |
The type of media |
|
flags |
The options given for how to process the media art |
|
file |
File to be processed |
|
artist |
The artist name |
[allow-none] |
title |
The title for |
[allow-none] |
cancellable |
optional GCancellable object, |
[allow-none] |
error |
a GError location to store the error occurring, or |
Since 0.3.0
media_art_process_buffer ()
gboolean media_art_process_buffer (MediaArtProcess *process
,MediaArtType type
,MediaArtProcessFlags flags
,GFile *related_file
,const guchar *buffer
,gsize len
,const gchar *mime
,const gchar *artist
,const gchar *title
,GCancellable *cancellable
,GError **error
);
Processes a memory buffer represented by buffer
and len
. If you
have extracted any embedded media art and passed this in as
buffer
, the image data will be converted to the correct format and
saved in the media art cache.
Either artist
OR title
can be NULL
, but they can not both be NULL
.
If file
is on a removable filesystem, the media art file will be saved in a
cache on the removable file system rather than on the host machine.
Parameters
process |
Media art process object |
|
type |
The type of media |
|
flags |
The options given for how to process the media art |
|
related_file |
File related to the media art |
|
buffer |
a buffer containing |
[array length=len][allow-none] |
len |
length of |
|
mime |
MIME type of |
|
artist |
The artist name |
[allow-none] |
title |
The title for |
[allow-none] |
cancellable |
optional GCancellable object, |
[allow-none] |
error |
a GError location to store the error occurring, or |
Since 0.5.0
Types and Values
enum MediaArtError
Enumeration values used in errors returned by the MediaArtError API.
Members
Storage information is unknown, we have no knowledge about removable media. |
||
Title is required, but was not provided, or was empty. |
||
A call to |
||
File could not be renamed. |
||
This is given when the XDG_CACHE_HOME directory could not be used to create the 'media-art' subdirectory used for caching media art. This is usually an initiation error. |
Since 0.2.0
enum MediaArtProcessFlags
This type categorized the flags used when processing media art.
Since 0.3.0
struct MediaArtProcess
struct MediaArtProcess { GObject parent; };
A class implementation for processing and extracting media art.