Commit 64f8139b authored by Martyn Russell's avatar Martyn Russell

libtracker-extract: Added tracker-extract.h to include other files

    
This has been added for compatibility.
For now, we have removed the TRACKER_ENABLE_INTERNALS check for
libtracker-common so the extractor modules can be built, but ideally
those should not need to use libtracker-common.
parent 41bd19a4
......@@ -29,7 +29,6 @@
#include <gio/gio.h>
#include <libtracker-extract/tracker-extract.h>
#include <libtracker-extract/tracker-utils.h>
#include <libtracker-client/tracker.h>
......
......@@ -22,12 +22,6 @@
#include <glib.h>
G_BEGIN_DECLS
#if !defined (TRACKER_ENABLE_INTERNALS) && !defined (TRACKER_COMPILATION)
#error "TRACKER_ENABLE_INTERNALS not defined, this must be defined to use tracker's internal functions"
#endif
#define __LIBTRACKER_COMMON_INSIDE__
#include "tracker-class.h"
......@@ -50,7 +44,4 @@ G_BEGIN_DECLS
#undef __LIBTRACKER_COMMON_INSIDE__
G_END_DECLS
#endif /* __LIBTRACKER_COMMON_H__ */
......@@ -19,7 +19,7 @@ lib_LTLIBRARIES = libtracker-extract-@TRACKER_API_VERSION@.la
libtracker_extractincdir=$(includedir)/tracker-$(TRACKER_API_VERSION)/libtracker-extract/
libtracker_extract_@TRACKER_API_VERSION@_la_SOURCES = \
tracker-extract.h \
tracker-data.h \
tracker-exif.c \
tracker-exif.h \
tracker-iptc.c \
......@@ -31,7 +31,7 @@ libtracker_extract_@TRACKER_API_VERSION@_la_SOURCES = \
noinst_HEADERS =
libtracker_extractinc_HEADERS = \
tracker-extract.h \
tracker-data.h \
tracker-exif.h \
tracker-iptc.h \
tracker-xmp.h \
......
/*
* Copyright (C) 2010, Nokia
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __LIBTRACKER_EXTRACT_EXTRACTOR_H__
#define __LIBTRACKER_EXTRACT_EXTRACTOR_H__
#if !defined (__LIBTRACKER_EXTRACT_INSIDE__) && !defined (TRACKER_COMPILATION)
#error "only <libtracker-extract/tracker-extract.h> must be included directly."
#endif
#include <glib.h>
#include <libtracker-client/tracker-sparql-builder.h>
G_BEGIN_DECLS
/**
* SECTION:tracker-extract
* @short_description: How to use libtracker-extract
* @stability: Stable
* @include: libtracker-extract/tracker-extract.h
*
* 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>
* <title>Basic extractor example</title>
* An example of how to write an extractor to retrieve PNG embedded
* metadata.
* <programlisting>
* static void extract_png (const gchar *filename,
* TrackerSparqlBuilder *preupdate,
* TrackerSparqlBuilder *metadata);
*
* /&ast; Set functions to use to extract different mime types. &ast;/
* static TrackerExtractData extract_data[] = {
* { "image/png", extract_png },
* { "sketch/png", extract_png },
* { NULL, NULL }
* };
*
* static void
* extract_png (const gchar *uri,
* TrackerSparqlBuilder *preupdate,
* TrackerSparqlBuilder *metadata)
* {
* gint height, width;
*
* /&ast; Do data extraction. &ast;/
* height = ...
* width = ...
*
* /&ast; Insert data into TrackerSparqlBuilder object. &ast;/
* 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;
* }
* </programlisting>
* </example>
*
*/
/**
* TrackerExtractMimeFunc:
* @uri: a string representing a URI.
* @preupdate: used to populate with data updates that
* are a prerequisite for the actual file
* metadata insertion.
* @metadata: used to populate with file metadata predicate/object(s).
*
* Extracts metadata from a file, and inserts it into @metadata.
*
* The @metadata parameter is a #TrackerSparqlBuilder constructed
* through tracker_sparql_builder_new_embedded_insert(), the subject
* is already set to be the file URN, so implementations of this
* function should just provide predicate/object(s) pairs. the data
* triples contained in there at the end of the function will be
* merged with further file information from miners.
*
* Whenever any of the inserted triples rely on entities that
* should also be provided by this extractor (for example, album
* or artist information from a song), such insertions should be
* added to @preupdate, which is a #TrackerSparqlBuilder constructed.
* through tracker_sparql_builder_new_update().
*
* Since: 0.8
**/
typedef void (*TrackerExtractMimeFunc) (const gchar *uri,
TrackerSparqlBuilder *preupdate,
TrackerSparqlBuilder *metadata);
/**
* TrackerExtractData:
* @mime: a string pointer representing a mime type.
* @func: a function to extract extract the data in.
*
* 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.
*
* Since: 0.8
**/
typedef struct {
const gchar *mime;
TrackerExtractMimeFunc func;
} TrackerExtractData;
/**
* TrackerExtractDataFunc:
*
* 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 TrackerExtractData * (*TrackerExtractDataFunc) (void);
/**
* tracker_extract_get_data:
*
*
* 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
*/
TrackerExtractData *tracker_extract_get_data (void);
G_END_DECLS
#endif /* __LIBTRACKER_EXTRACT_EXTRACTOR_H__ */
......@@ -22,6 +22,10 @@
#ifndef __LIBTRACKER_EXTRACT_EXIF_H__
#define __LIBTRACKER_EXTRACT_EXIF_H__
#if !defined (__LIBTRACKER_EXTRACT_INSIDE__) && !defined (TRACKER_COMPILATION)
#error "only <libtracker-extract/tracker-extract.h> must be included directly."
#endif
#include <glib.h>
G_BEGIN_DECLS
......@@ -58,4 +62,3 @@ gboolean tracker_extract_exif_read (const unsigned char *buffer,
G_END_DECLS
#endif /* __LIBTRACKER_EXTRACT_EXIF_H__ */
/*
* Copyright (C) 2010, Nokia
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
* version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __LIBTRACKER_EXTRACT_EXTRACT_H__
#define __LIBTRACKER_EXTRACT_EXTRACT_H__
#ifndef __LIBTRACKER_EXTRACT_H__
#define __LIBTRACKER_EXTRACT_H__
#include <glib.h>
#include <libtracker-client/tracker-sparql-builder.h>
#define __LIBTRACKER_EXTRACT_INSIDE__
G_BEGIN_DECLS
#include "tracker-data.h"
#include "tracker-exif.h"
#include "tracker-iptc.h"
#include "tracker-utils.h"
#include "tracker-xmp.h"
/**
* SECTION:tracker-extract
* @short_description: How to use libtracker-extract
* @stability: Stable
* @include: libtracker-extract/tracker-extract.h
*
* 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>
* <title>Basic extractor example</title>
* An example of how to write an extractor to retrieve PNG embedded
* metadata.
* <programlisting>
* static void extract_png (const gchar *filename,
* TrackerSparqlBuilder *preupdate,
* TrackerSparqlBuilder *metadata);
*
* /&ast; Set functions to use to extract different mime types. &ast;/
* static TrackerExtractData extract_data[] = {
* { "image/png", extract_png },
* { "sketch/png", extract_png },
* { NULL, NULL }
* };
*
* static void
* extract_png (const gchar *uri,
* TrackerSparqlBuilder *preupdate,
* TrackerSparqlBuilder *metadata)
* {
* gint height, width;
*
* /&ast; Do data extraction. &ast;/
* height = ...
* width = ...
*
* /&ast; Insert data into TrackerSparqlBuilder object. &ast;/
* 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;
* }
* </programlisting>
* </example>
*
*/
/**
* TrackerExtractMimeFunc:
* @uri: a string representing a URI.
* @preupdate: used to populate with data updates that
* are a prerequisite for the actual file
* metadata insertion.
* @metadata: used to populate with file metadata predicate/object(s).
*
* Extracts metadata from a file, and inserts it into @metadata.
*
* The @metadata parameter is a #TrackerSparqlBuilder constructed
* through tracker_sparql_builder_new_embedded_insert(), the subject
* is already set to be the file URN, so implementations of this
* function should just provide predicate/object(s) pairs. the data
* triples contained in there at the end of the function will be
* merged with further file information from miners.
*
* Whenever any of the inserted triples rely on entities that
* should also be provided by this extractor (for example, album
* or artist information from a song), such insertions should be
* added to @preupdate, which is a #TrackerSparqlBuilder constructed.
* through tracker_sparql_builder_new_update().
*
* Since: 0.8
**/
typedef void (*TrackerExtractMimeFunc) (const gchar *uri,
TrackerSparqlBuilder *preupdate,
TrackerSparqlBuilder *metadata);
/**
* TrackerExtractData:
* @mime: a string pointer representing a mime type.
* @func: a function to extract extract the data in.
*
* 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.
*
* Since: 0.8
**/
typedef struct {
const gchar *mime;
TrackerExtractMimeFunc func;
} TrackerExtractData;
/**
* TrackerExtractDataFunc:
*
* 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 TrackerExtractData * (*TrackerExtractDataFunc) (void);
/**
* tracker_extract_get_data:
*
*
* 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
*/
TrackerExtractData *tracker_extract_get_data (void);
G_END_DECLS
#undef __LIBTRACKER_EXTRACT_INSIDE__
#endif /* __LIBTRACKER_EXTRACT_EXTRACT_H__ */
#endif /* __LIBTRACKER_EXTRACT_H__ */
......@@ -22,6 +22,10 @@
#ifndef __LIBTRACKER_EXTRACT_IPTC_H__
#define __LIBTRACKER_EXTRACT_IPTC_H__
#if !defined (__LIBTRACKER_EXTRACT_INSIDE__) && !defined (TRACKER_COMPILATION)
#error "only <libtracker-extract/tracker-extract.h> must be included directly."
#endif
#include <glib.h>
/* IPTC Information Interchange Model */
......
......@@ -22,7 +22,9 @@
#ifndef __LIBTRACKER_EXTRACT_UTILS_H__
#define __LIBTRACKER_EXTRACT_UTILS_H__
#include <glib.h>
#if !defined (__LIBTRACKER_EXTRACT_INSIDE__) && !defined (TRACKER_COMPILATION)
#error "only <libtracker-extract/tracker-extract.h> must be included directly."
#endif
/* These are for convenience */
#define tracker_coalesce tracker_extract_coalesce
......
......@@ -21,6 +21,10 @@
#ifndef __LIBTRACKER_EXTRACT_XMP_H__
#define __LIBTRACKER_EXTRACT_XMP_H__
#if !defined (__LIBTRACKER_EXTRACT_INSIDE__) && !defined (TRACKER_COMPILATION)
#error "only <libtracker-extract/tracker-extract.h> must be included directly."
#endif
#include <glib.h>
#include <libtracker-client/tracker-sparql-builder.h>
......
......@@ -37,7 +37,6 @@
#include <libtracker-common/tracker-ontologies.h>
#include <libtracker-extract/tracker-extract.h>
#include <libtracker-extract/tracker-utils.h>
#define NIE_PREFIX TRACKER_NIE_PREFIX
#define NFO_PREFIX TRACKER_NFO_PREFIX
......
......@@ -33,7 +33,6 @@
#include <libtracker-common/tracker-utils.h>
#include <libtracker-extract/tracker-extract.h>
#include <libtracker-extract/tracker-utils.h>
typedef struct {
gchar *title;
......
......@@ -40,7 +40,6 @@ long long int llroundl(long double x);
#include <libtracker-client/tracker.h>
#include <libtracker-extract/tracker-extract.h>
#include <libtracker-extract/tracker-utils.h>
#include "tracker-albumart.h"
#include "tracker-dbus.h"
......
......@@ -29,7 +29,6 @@
#include <libtracker-common/tracker-ontologies.h>
#include <libtracker-extract/tracker-extract.h>
#include <libtracker-extract/tracker-utils.h>
#define RDF_TYPE TRACKER_RDF_PREFIX "type"
......
......@@ -30,8 +30,6 @@
#include <libtracker-common/tracker-os-dependant.h>
#include <libtracker-extract/tracker-extract.h>
#include <libtracker-extract/tracker-xmp.h>
#include <libtracker-extract/tracker-utils.h>
#define NMM_PREFIX TRACKER_NMM_PREFIX
#define NFO_PREFIX TRACKER_NFO_PREFIX
......
......@@ -47,10 +47,6 @@
#include <libtracker-common/tracker-utils.h>
#include <libtracker-extract/tracker-extract.h>
#include <libtracker-extract/tracker-xmp.h>
#include <libtracker-extract/tracker-iptc.h>
#include <libtracker-extract/tracker-exif.h>
#include <libtracker-extract/tracker-utils.h>
#include "tracker-main.h"
......
......@@ -27,7 +27,6 @@
#include <libtracker-common/tracker-utils.h>
#include <libtracker-extract/tracker-extract.h>
#include <libtracker-extract/tracker-utils.h>
#define NMM_PREFIX TRACKER_NMM_PREFIX
#define NFO_PREFIX TRACKER_NFO_PREFIX
......
......@@ -48,7 +48,6 @@
#include <libtracker-client/tracker.h>
#include <libtracker-extract/tracker-extract.h>
#include <libtracker-extract/tracker-utils.h>
#include "tracker-albumart.h"
#include "tracker-dbus.h"
......
......@@ -30,7 +30,6 @@
#include <libtracker-common/tracker-utils.h>
#include <libtracker-extract/tracker-extract.h>
#include <libtracker-extract/tracker-utils.h>
#define NMM_PREFIX TRACKER_NMM_PREFIX
#define NFO_PREFIX TRACKER_NFO_PREFIX
......
......@@ -38,7 +38,6 @@
#include <libtracker-common/tracker-os-dependant.h>
#include <libtracker-extract/tracker-extract.h>
#include <libtracker-extract/tracker-utils.h>
#include "tracker-main.h"
......
......@@ -28,7 +28,6 @@
#include <libtracker-common/tracker-utils.h>
#include <libtracker-extract/tracker-extract.h>
#include <libtracker-extract/tracker-utils.h>
#include "tracker-main.h"
......
......@@ -33,8 +33,6 @@
#include <libtracker-common/tracker-type-utils.h>
#include <libtracker-extract/tracker-extract.h>
#include <libtracker-extract/tracker-xmp.h>
#include <libtracker-extract/tracker-utils.h>
#include "tracker-main.h"
......
......@@ -36,7 +36,6 @@
#include <libtracker-common/tracker-ontologies.h>
#include <libtracker-extract/tracker-extract.h>
#include <libtracker-extract/tracker-utils.h>
#define PLAYLIST_PROPERTY_NO_TRACKS "entryCounter"
#define PLAYLIST_PROPERTY_DURATION "listDuration"
......
......@@ -43,9 +43,6 @@
#include <libtracker-common/tracker-utils.h>
#include <libtracker-extract/tracker-extract.h>
#include <libtracker-extract/tracker-xmp.h>
#include <libtracker-extract/tracker-exif.h>
#include <libtracker-extract/tracker-utils.h>
#define RFC1123_DATE_FORMAT "%d %B %Y %H:%M:%S %z"
......
......@@ -40,7 +40,6 @@
#include <libtracker-common/tracker-ontologies.h>
#include <libtracker-extract/tracker-extract.h>
#include <libtracker-extract/tracker-utils.h>
#ifndef HAVE_GETLINE
......
......@@ -25,7 +25,6 @@
#include <gio/gio.h>
#include <libtracker-extract/tracker-extract.h>
#include <libtracker-extract/tracker-utils.h>
#undef TRY_LOCALE_TO_UTF8_CONVERSION
......
......@@ -38,10 +38,6 @@
#include <libtracker-common/tracker-utils.h>
#include <libtracker-extract/tracker-extract.h>
#include <libtracker-extract/tracker-xmp.h>
#include <libtracker-extract/tracker-iptc.h>
#include <libtracker-extract/tracker-exif.h>
#include <libtracker-extract/tracker-utils.h>
#define EXIF_DATE_FORMAT "%Y:%m:%d %H:%M:%S"
......
......@@ -27,7 +27,6 @@
#include <libtracker-common/tracker-utils.h>
#include <libtracker-extract/tracker-extract.h>
#include <libtracker-extract/tracker-utils.h>
#define NMM_PREFIX TRACKER_NMM_PREFIX
#define NFO_PREFIX TRACKER_NFO_PREFIX
......
......@@ -33,7 +33,6 @@
#include <libtracker-common/tracker-utils.h>
#include <libtracker-extract/tracker-extract.h>
#include <libtracker-extract/tracker-utils.h>
#define NIE_PREFIX TRACKER_NIE_PREFIX
#define NFO_PREFIX TRACKER_NFO_PREFIX
......
......@@ -28,8 +28,6 @@
#include <libtracker-common/tracker-utils.h>
#include <libtracker-extract/tracker-extract.h>
#include <libtracker-extract/tracker-xmp.h>
#include <libtracker-extract/tracker-utils.h>
static void extract_xmp (const gchar *filename,
TrackerSparqlBuilder *preupdate,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment