[rygel] media-export: Simplify fallback extraction
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] media-export: Simplify fallback extraction
- Date: Fri, 7 Jan 2011 16:35:49 +0000 (UTC)
commit af820ac7b36350503b8589e2355d2b73cb568a12
Author: Jens Georg <mail jensge org>
Date: Wed Dec 29 01:19:43 2010 +0100
media-export: Simplify fallback extraction
.../rygel-media-export-harvesting-task.vala | 23 ++---
.../rygel-media-export-metadata-extractor.vala | 106 +++++++++-----------
2 files changed, 54 insertions(+), 75 deletions(-)
---
diff --git a/src/plugins/media-export/rygel-media-export-harvesting-task.vala b/src/plugins/media-export/rygel-media-export-harvesting-task.vala
index 1dc88f1..86c155c 100644
--- a/src/plugins/media-export/rygel-media-export-harvesting-task.vala
+++ b/src/plugins/media-export/rygel-media-export-harvesting-task.vala
@@ -331,22 +331,13 @@ public class Rygel.MediaExport.HarvestingTask : Rygel.StateMachine,
return;
}
- try {
- var info = file.query_info (HARVESTER_ATTRIBUTES,
- FileQueryInfoFlags.NONE,
- this.cancellable);
- string content_type = info.get_content_type ();
- string mime = ContentType.get_mime_type (content_type);
- uint64 size = info.get_size ();
- uint64 mtime = info.get_attribute_uint64
- (FILE_ATTRIBUTE_TIME_MODIFIED);
- this.on_extracted_cb (file, null, mime, size, mtime);
- } catch (Error error) {
- debug ("Could not get basic file information for %s: %s." +
- "Ignoring",
- file.get_uri (),
- error.message);
- }
+ // error is only emitted if even the basic information extraction
+ // failed; there's not much to do here, just print the information and
+ // go to the next file
+
+ debug ("Skipping %s; extraction completely failed: %s",
+ file.get_uri (),
+ error.message);
this.files.poll ();
this.do_update ();
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 e1fe7b5..17db2c6 100644
--- a/src/plugins/media-export/rygel-media-export-metadata-extractor.vala
+++ b/src/plugins/media-export/rygel-media-export-metadata-extractor.vala
@@ -69,6 +69,7 @@ public class Rygel.MediaExport.MetadataExtractor: GLib.Object {
if (this.extract_metadata) {
var gst_timeout = (ClockTime) (this.timeout * Gst.SECOND);
+
this.discoverer = new GUPnP.DLNADiscoverer (gst_timeout,
true,
true);
@@ -92,81 +93,68 @@ public class Rygel.MediaExport.MetadataExtractor: GLib.Object {
this.file_hash.unset (dlna.info.uri);
if ((dlna.info.result & Gst.DiscovererResult.TIMEOUT) != 0) {
- this.error (file,
- new IOChannelError.FAILED ("Pipeline stuck while" +
- "reading file info"));
- return;
+ debug ("Extraction timed out on %s", file.get_uri ());
+
+ // set dlna to null to extract basic file information
+ dlna = null;
} else if ((dlna.info.result & Gst.DiscovererResult.ERROR) != 0) {
this.error (file, err);
return;
}
- try {
- uint64 size, mtime;
- string mime;
-
- this.extract_file_info (file, out mime, out size, out mtime);
- this.extraction_done (file, dlna, mime, size, mtime);
- } catch (Error e) {
- debug ("Failed to extract metadata from %s: %s",
- dlna.info.uri,
- e.message);
- }
+ this.extract_basic_information (file, dlna);
}
- public void extract (File file) {
- if (this.extract_metadata) {
- string uri = file.get_uri ();
- this.file_hash.set (uri, file);
- this.discoverer.discover_uri (uri);
- } else {
- try {
- string mime;
- uint64 size;
- uint64 mtime;
-
- extract_file_info (file,
- out mime,
- out size,
- out mtime);
-
- this.extraction_done (file,
- null,
- mime,
- size,
- mtime);
- } catch (Error error) {
- this.error (file, error);
- }
- }
- }
-
- private void extract_file_info (File file,
- out string mime,
- out uint64 size,
- out uint64 mtime) throws Error {
- FileInfo file_info;
-
+ private void extract_basic_information (File file,
+ DLNAInformation? dlna = null) {
try {
- file_info = file.query_info (FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE
+ FileInfo file_info;
+
+ try {
+ file_info = file.query_info
+ (FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE
+ "," +
FILE_ATTRIBUTE_STANDARD_SIZE + "," +
FILE_ATTRIBUTE_TIME_MODIFIED,
FileQueryInfoFlags.NONE,
null);
- } catch (Error error) {
- warning (_("Failed to query content type for '%s'"),
- file.get_uri ());
+ } catch (Error error) {
+ warning (_("Failed to query content type for '%s'"),
+ file.get_uri ());
- // signal error to parent
- this.error (file, error);
+ // signal error to parent
+ this.error (file, error);
+
+ throw error;
+ }
- throw error;
+ var content_type = file_info.get_content_type ();
+ var mime = ContentType.get_mime_type (content_type);
+ var size = file_info.get_size ();
+ var mtime = file_info.get_attribute_uint64
+ (FILE_ATTRIBUTE_TIME_MODIFIED);
+
+ this.extraction_done (file,
+ dlna,
+ mime,
+ size,
+ mtime);
+ } catch (Error error) {
+ debug ("Failed to extract basic metadata from %s: %s",
+ file.get_uri (),
+ error.message);
+ this.error (file, error);
}
- string content_type = file_info.get_content_type ();
- mime = ContentType.get_mime_type (content_type);
- size = file_info.get_size ();
- mtime = file_info.get_attribute_uint64 (FILE_ATTRIBUTE_TIME_MODIFIED);
+ }
+
+ public void extract (File file) {
+ if (this.extract_metadata) {
+ string uri = file.get_uri ();
+ this.file_hash.set (uri, file);
+ this.discoverer.discover_uri (uri);
+ } else {
+ this.extract_basic_information (file);
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]