[tracker/tracker-0.10] tracker-extract: Make JPEG module handle DLNA profiles
- From: Martyn James Russell <mr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/tracker-0.10] tracker-extract: Make JPEG module handle DLNA profiles
- Date: Thu, 4 Aug 2011 16:10:33 +0000 (UTC)
commit ebd78e91ea1fde5c13878543b694615eadb31e2c
Author: Carlos Garnacho <carlosg gnome org>
Date: Fri May 27 17:53:25 2011 +0200
tracker-extract: Make JPEG module handle DLNA profiles
In this extractor makes little sense to perform calls to any
dlna library as we have all the necessary data right there.
src/tracker-extract/tracker-extract-jpeg.c | 51 ++++++++++++++++++++++++++++
1 files changed, 51 insertions(+), 0 deletions(-)
---
diff --git a/src/tracker-extract/tracker-extract-jpeg.c b/src/tracker-extract/tracker-extract-jpeg.c
index 61f158a..dca4014 100644
--- a/src/tracker-extract/tracker-extract-jpeg.c
+++ b/src/tracker-extract/tracker-extract-jpeg.c
@@ -103,6 +103,51 @@ extract_jpeg_error_exit (j_common_ptr cinfo)
longjmp (h->setjmp_buffer, 1);
}
+static gboolean
+guess_dlna_profile (gint width,
+ gint height,
+ const gchar **dlna_profile,
+ const gchar **dlna_mimetype)
+{
+ gchar *profile = NULL;
+
+ if (dlna_profile) {
+ *dlna_profile = NULL;
+ }
+
+ if (dlna_mimetype) {
+ *dlna_mimetype = NULL;
+ }
+
+ if (width == 48 && height == 48) {
+ profile = "JPEG_SM_ICO";
+ } else if (width == 120 && height == 120) {
+ profile = "JPEG_LRG_ICO";
+ } else if (width <= 160 && height <= 160) {
+ profile = "JPEG_TN";
+ } else if (width <= 640 && height <= 480) {
+ profile = "JPEG_SM";
+ } else if (width <= 1024 && height <= 768) {
+ profile = "JPEG_MED";
+ } else if (width <= 4096 && height <= 4096) {
+ profile = "JPEG_LRG";
+ }
+
+ if (profile) {
+ if (dlna_profile) {
+ *dlna_profile = profile;
+ }
+
+ if (dlna_mimetype) {
+ *dlna_mimetype = "image/jpeg";
+ }
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
static void
extract_jpeg (const gchar *uri,
TrackerSparqlBuilder *preupdate,
@@ -119,6 +164,7 @@ extract_jpeg (const gchar *uri,
goffset size;
gchar *filename;
gchar *comment = NULL;
+ const gchar *dlna_profile;
GPtrArray *keywords;
guint i;
GString *where = NULL;
@@ -276,6 +322,11 @@ extract_jpeg (const gchar *uri,
tracker_sparql_builder_predicate (metadata, "nfo:height");
tracker_sparql_builder_object_int64 (metadata, cinfo.image_height);
+ if (guess_dlna_profile (cinfo.image_width, cinfo.image_height, &dlna_profile, NULL)) {
+ tracker_sparql_builder_predicate (metadata, "nmm:dlnaProfile");
+ tracker_sparql_builder_object_string (metadata, dlna_profile);
+ }
+
if (id->contact) {
gchar *uri = tracker_sparql_escape_uri_printf ("urn:contact:%s", id->contact);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]