[rygel] media-export: Refactor. Remove Extractor.create
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] media-export: Refactor. Remove Extractor.create
- Date: Mon, 7 Jun 2010 14:27:15 +0000 (UTC)
commit 76f73add20c504081db9d584fd6fce553a44fe5a
Author: Jens Georg <mail jensge org>
Date: Fri May 14 23:27:13 2010 +0200
media-export: Refactor. Remove Extractor.create
Since there is a non-hatrvesting mode now, there's no need for a
creation method anymore as we will create the object always and just
not harvest.
.../rygel-media-export-metadata-extractor.vala | 55 ++++++++++----------
.../rygel-media-export-root-container.vala | 2 +-
2 files changed, 29 insertions(+), 28 deletions(-)
---
diff --git a/src/plugins/media-export/rygel-media-export-metadata-extractor.vala b/src/plugins/media-export/rygel-media-export-metadata-extractor.vala
index 7c83a1c..9978d12 100644
--- a/src/plugins/media-export/rygel-media-export-metadata-extractor.vala
+++ b/src/plugins/media-export/rygel-media-export-metadata-extractor.vala
@@ -106,40 +106,26 @@ public class Rygel.MediaExport.MetadataExtractor: GLib.Object {
}
}
- public static MetadataExtractor? create() {
- var config = MetaConfig.get_default ();
- bool extract_metadata;
+ private void create_playbin_factory () {
+ debug ("Checking for gstreamer element 'playbin'...");
+ var factory = ElementFactory.find("playbin2");
+ if (factory != null) {
+ debug (_("Using playbin2"));
+ } else {
+ debug (_("Could not create Playbin2, trying Playbin"));
+ factory = ElementFactory.find ("playbin");
- try {
- extract_metadata = config.get_bool ("MediaExport",
- "extract-metadata");
- } catch (Error error) {
- extract_metadata = false;
- }
-
- if (factory == null && extract_metadata) {
- debug ("Checking for gstreamer element 'playbin'..."));
- var factory = ElementFactory.find("playbin2");
if (factory != null) {
- debug (_("Using playbin2"));
+ debug (_("Using playbin"));
} else {
- debug (_("Could not create Playbin2, trying Playbin"));
- factory = ElementFactory.find ("playbin");
-
- if (factory != null) {
- debug (_("Using playbin"));
- } else {
- warning (_("Could not find any playbin.") + " " +
- _("Please check your gstreamer setup"));
- }
+ warning (_("Could not find any playbin.") + " " +
+ _("Please check your gstreamer setup"));
}
- MetadataExtractor.factory = factory;
}
-
- return new MetadataExtractor ();
+ MetadataExtractor.factory = factory;
}
- private MetadataExtractor () {
+ public MetadataExtractor () {
this.register_custom_tag (TAG_RYGEL_SIZE, typeof (int64));
this.register_custom_tag (TAG_RYGEL_DURATION, typeof (int64));
this.register_custom_tag (TAG_RYGEL_MIME, typeof (string));
@@ -152,6 +138,21 @@ public class Rygel.MediaExport.MetadataExtractor: GLib.Object {
this.file_queue = new GLib.Queue<File> ();
this.tag_list = new Gst.TagList ();
+
+ var config = MetaConfig.get_default ();
+ bool extract_metadata;
+
+ try {
+ extract_metadata = config.get_bool ("MediaExport",
+ "extract-metadata");
+ } catch (Error error) {
+ extract_metadata = false;
+ }
+
+ // lazy-create factory
+ if (extract_metadata && factory == null) {
+ create_playbin_factory ();
+ }
}
public void extract (File file) {
diff --git a/src/plugins/media-export/rygel-media-export-root-container.vala b/src/plugins/media-export/rygel-media-export-root-container.vala
index d123e63..d27e4e7 100644
--- a/src/plugins/media-export/rygel-media-export-root-container.vala
+++ b/src/plugins/media-export/rygel-media-export-root-container.vala
@@ -286,7 +286,7 @@ public class Rygel.MediaExport.RootContainer : Rygel.MediaExport.DBContainer {
base (db, "0", "MediaExportRoot");
- this.extractor = MetadataExtractor.create ();
+ this.extractor = new MetadataExtractor ();
this.harvester = new HashMap<File, Harvester> (file_hash, file_equal);
this.harvester_trash = new ArrayList<Harvester> ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]