[tracker] tracker-extract-gstreamer: Tiny refactor
- From: Martyn James Russell <mr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker] tracker-extract-gstreamer: Tiny refactor
- Date: Fri, 12 Aug 2011 18:49:46 +0000 (UTC)
commit 2ba10f00366081e5bb0793f9188a362c5b214c1e
Author: Sam Thursfield <samthursfield codethink co uk>
Date: Fri Aug 12 19:03:07 2011 +0100
tracker-extract-gstreamer: Tiny refactor
https://bugzilla.gnome.org/show_bug.cgi?id=656419
src/tracker-extract/tracker-extract-gstreamer.c | 91 ++++++++++-------------
1 files changed, 39 insertions(+), 52 deletions(-)
---
diff --git a/src/tracker-extract/tracker-extract-gstreamer.c b/src/tracker-extract/tracker-extract-gstreamer.c
index f9e51fe..e3b2413 100644
--- a/src/tracker-extract/tracker-extract-gstreamer.c
+++ b/src/tracker-extract/tracker-extract-gstreamer.c
@@ -309,6 +309,43 @@ add_keywords_gst_tag (TrackerSparqlBuilder *metadata,
}
}
+static void
+replace_double_gst_tag (TrackerSparqlBuilder *preupdate,
+ const gchar *uri,
+ const gchar *key,
+ GstTagList *tag_list,
+ const gchar *tag)
+{
+ gdouble value;
+ gboolean has_it;
+
+ has_it = gst_tag_list_get_double (tag_list, tag, &value);
+
+ if (! has_it)
+ return;
+
+ tracker_sparql_builder_delete_open (preupdate, NULL);
+ tracker_sparql_builder_subject_iri (preupdate, uri);
+ tracker_sparql_builder_predicate (preupdate, key);
+ tracker_sparql_builder_object_variable (preupdate, "unknown");
+ tracker_sparql_builder_delete_close (preupdate);
+
+ tracker_sparql_builder_where_open (preupdate);
+ tracker_sparql_builder_subject_iri (preupdate, uri);
+ tracker_sparql_builder_predicate (preupdate, key);
+ tracker_sparql_builder_object_variable (preupdate, "unknown");
+ tracker_sparql_builder_where_close (preupdate);
+
+ tracker_sparql_builder_insert_open (preupdate, NULL);
+
+ tracker_sparql_builder_subject_iri (preupdate, uri);
+ tracker_sparql_builder_predicate (preupdate, key);
+ tracker_sparql_builder_object_double (preupdate, value);
+
+ tracker_sparql_builder_insert_close (preupdate);
+}
+
+
static gboolean
get_embedded_album_art (MetadataExtractor *extractor)
{
@@ -494,7 +531,6 @@ extract_metadata (MetadataExtractor *extractor,
if (albumname) {
gboolean has_it;
guint count;
- gdouble gain;
needs_audio = TRUE;
@@ -581,57 +617,8 @@ extract_metadata (MetadataExtractor *extractor,
tracker_sparql_builder_object_iri (preupdate, album_uri);
tracker_sparql_builder_insert_close (preupdate);
- has_it = gst_tag_list_get_double (extractor->tagcache,
- GST_TAG_ALBUM_GAIN,
- &gain);
-
- if (has_it) {
- tracker_sparql_builder_delete_open (preupdate, NULL);
- tracker_sparql_builder_subject_iri (preupdate, album_uri);
- tracker_sparql_builder_predicate (preupdate, "nmm:albumGain");
- tracker_sparql_builder_object_variable (preupdate, "unknown");
- tracker_sparql_builder_delete_close (preupdate);
-
- tracker_sparql_builder_where_open (preupdate);
- tracker_sparql_builder_subject_iri (preupdate, album_uri);
- tracker_sparql_builder_predicate (preupdate, "nmm:albumGain");
- tracker_sparql_builder_object_variable (preupdate, "unknown");
- tracker_sparql_builder_where_close (preupdate);
-
- tracker_sparql_builder_insert_open (preupdate, NULL);
-
- tracker_sparql_builder_subject_iri (preupdate, album_uri);
- tracker_sparql_builder_predicate (preupdate, "nmm:albumGain");
- tracker_sparql_builder_object_double (preupdate, gain);
-
- tracker_sparql_builder_insert_close (preupdate);
- }
-
- has_it = gst_tag_list_get_double (extractor->tagcache,
- GST_TAG_ALBUM_PEAK,
- &gain);
-
- if (has_it) {
- tracker_sparql_builder_delete_open (preupdate, NULL);
- tracker_sparql_builder_subject_iri (preupdate, album_uri);
- tracker_sparql_builder_predicate (preupdate, "nmm:albumPeakGain");
- tracker_sparql_builder_object_variable (preupdate, "unknown");
- tracker_sparql_builder_delete_close (preupdate);
-
- tracker_sparql_builder_where_open (preupdate);
- tracker_sparql_builder_subject_iri (preupdate, album_uri);
- tracker_sparql_builder_predicate (preupdate, "nmm:albumPeakGain");
- tracker_sparql_builder_object_variable (preupdate, "unknown");
- tracker_sparql_builder_where_close (preupdate);
-
- tracker_sparql_builder_insert_open (preupdate, NULL);
-
- tracker_sparql_builder_subject_iri (preupdate, album_uri);
- tracker_sparql_builder_predicate (preupdate, "nmm:albumPeakGain");
- tracker_sparql_builder_object_double (preupdate, gain);
-
- tracker_sparql_builder_insert_close (preupdate);
- }
+ replace_double_gst_tag (preupdate, album_uri, "nmm:albumGain", extractor->tagcache, GST_TAG_ALBUM_GAIN);
+ replace_double_gst_tag (preupdate, album_uri, "nmm:albumPeakGain", extractor->tagcache, GST_TAG_ALBUM_PEAK);
*album = albumname;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]