![]() |
![]() |
![]() |
Tracker Extract Library Reference Manual | ![]() |
---|---|---|---|---|
Top | Description |
#include <libtracker-extract/tracker-extract.h> void (*TrackerExtractMimeFunc) (const gchar *uri
,TrackerSparqlBuilder *metadata
); TrackerExtractData * (*TrackerExtractDataFunc) (void
); TrackerExtractData; TrackerExtractData * tracker_extract_get_data (void
);
The libtracker-extract library is the foundation for Tracker metadata extraction of embedded data in files.
Tracker comes with extractors written for the most common file types (like MP3, JPEG, PNG, etc.), however, for more special cases, 3rd party applications may want to write their own plugin to extract their own file formats. This documentation describes how to do that.
Example 1. Basic extractor example
static void extract_png (const gchar *filename, TrackerSparqlBuilder *metadata); /* Set functions to use to extract different mime types. */ static TrackerExtractData extract_data[] = { { "image/png", extract_png }, { "sketch/png", extract_png }, { NULL, NULL } }; static void extract_png (const gchar *uri, TrackerSparqlBuilder *metadata) { goffset size; gint height, width; gchar *filename = g_filename_from_uri (uri, NULL, NULL); /* Do data extraction. */ height = ... width = ... /* Insert data into TrackerSparqlBuilder object. */ tracker_sparql_builder_subject_iri (metadata, uri); tracker_sparql_builder_predicate (metadata, "a"); tracker_sparql_builder_object (metadata, "nfo:Image"); tracker_sparql_builder_object (metadata, "nmm:Photo"); tracker_sparql_builder_predicate (metadata, "nfo:width"); tracker_sparql_builder_object_int64 (metadata, width); tracker_sparql_builder_predicate (metadata, "nfo:height"); tracker_sparql_builder_object_int64 (metadata, height); g_free (filename); } TrackerExtractData * tracker_extract_get_data (void) { return extract_data; }
void (*TrackerExtractMimeFunc) (const gchar *uri
,TrackerSparqlBuilder *metadata
);
The metadata
is used to populate the extracted metadata from the
file using the TrackerSparqlBuilder APIs.
|
a string representing a URI. |
|
used to populate with metadata. |
Since 0.8
TrackerExtractData * (*TrackerExtractDataFunc) (void
);
This function is used by by tracker-extract to call into each extractor to get a list of mime type and TrackerExtractMimeFunc combinations.
Returns : |
an array of TrackerExtractData which must be NULL terminated and must NOT be freed. |
Since 0.6
typedef struct { const gchar *mime; TrackerExtractMimeFunc func; } TrackerExtractData;
The mime
is usually in the format of "image/png" for example.
The func
is called by tracker-extract if an extractor plugin
matches the mime
.
const gchar * |
a string pointer representing a mime type. |
TrackerExtractMimeFunc |
a function to extract extract the data in. |
Since 0.8
TrackerExtractData * tracker_extract_get_data (void
);
This function must be provided by ALL extractors. This is merely the declaration of the function which must be written by each extractor.
This is checked by tracker-extract by looking up the symbols for each plugin and making sure this function exists. This is only called by tracker-extract if a mime type in any of the TrackerExtractData structures returned matches the mime type of the file being handled.
Returns : |
a TrackerExtractData pointer which should not be freed. This pointer can be an array of TrackerExtractData structures where multiple mime types are supported. |
Since 0.8