[rygel] media-export: Skip DVDs if lsdvd is not available



commit 85faa1ac90425f9b2004e401630ec03eee3588e6
Author: Jens Georg <mail jensge org>
Date:   Fri Jan 22 22:31:33 2016 +0100

    media-export: Skip DVDs if lsdvd is not available
    
    Instead of blacklisting them. This has the minor drawback that we will process
    them on each tree walk, but can fully extract them once lsdvd is installed
    later on.
    
    Signed-off-by: Jens Georg <mail jensge org>

 .../rygel-media-export-dvd-parser.vala             |    5 ++-
 .../media-export/rygel-media-export-extract.vala   |   30 +++++++++++++++----
 .../rygel-media-export-harvesting-task.vala        |    2 +-
 .../rygel-media-export-item-factory.vala           |    7 ++++-
 .../rygel-media-export-metadata-extractor.vala     |   13 +++++++-
 5 files changed, 44 insertions(+), 13 deletions(-)
---
diff --git a/src/plugins/media-export/rygel-media-export-dvd-parser.vala 
b/src/plugins/media-export/rygel-media-export-dvd-parser.vala
index 22dc3a9..bfd4dbb 100644
--- a/src/plugins/media-export/rygel-media-export-dvd-parser.vala
+++ b/src/plugins/media-export/rygel-media-export-dvd-parser.vala
@@ -21,7 +21,8 @@
  */
 
 internal errordomain DVDParserError {
-    GENERAL;
+    GENERAL,
+    NOT_AVAILABLE;
 }
 
 internal class Rygel.DVDParser : GLib.Object {
@@ -62,7 +63,7 @@ internal class Rygel.DVDParser : GLib.Object {
 
     public async void run () throws Error {
         if (DVDParser.lsdvd_binary_path == null) {
-            throw new DVDParserError.GENERAL ("No DVD extractor found");
+            throw new DVDParserError.NOT_AVAILABLE ("No DVD extractor found");
         }
 
         yield this.get_information ();
diff --git a/src/plugins/media-export/rygel-media-export-extract.vala 
b/src/plugins/media-export/rygel-media-export-extract.vala
index 41353fb..f559298 100644
--- a/src/plugins/media-export/rygel-media-export-extract.vala
+++ b/src/plugins/media-export/rygel-media-export-extract.vala
@@ -38,6 +38,7 @@ const string UPNP_CLASS_PLAYLIST_CONTAINER_DVD =
 
 const string STATUS_LINE_TEMPLATE = "RESULT|%s|%" + size_t.FORMAT + "|%s\n";
 const string ERROR_LINE_TEMPLATE = "ERROR|%s|%d|%s\n";
+const string SKIPPED_LINE_TEMPLATE = "SKIP|%s|-1|0\n";
 
 const string FATAL_ERROR_PREFIX = "FATAL_ERROR|";
 const string FATAL_ERROR_SUFFIX = "\n"; //|0|Killed by signal\n";
@@ -118,13 +119,17 @@ async void run () {
                     }
                     yield process_meta_data (parts[0], info);
                 } catch (Error error) {
-                    warning (_("Failed to discover URI %s: %s"),
-                             parts[0],
-                             error.message);
-                    send_error (File.new_for_uri (parts[0]), error);
-
-                    // Recreate the discoverer on error
-                    discoverer = new Discoverer (10 * Gst.SECOND);
+                    if (error is DVDParserError.NOT_AVAILABLE) {
+                        send_skip (File.new_for_uri (parts[0]));
+                    } else {
+                        warning (_("Failed to discover URI %s: %s"),
+                                 parts[0],
+                                 error.message);
+                        send_error (File.new_for_uri (parts[0]), error);
+
+                        // Recreate the discoverer on error
+                        discoverer = new Discoverer (10 * Gst.SECOND);
+                    }
                 }
                 //discoverer.discover_uri_async (uri);
             } else if (line.has_prefix ("METADATA ")) {
@@ -156,6 +161,17 @@ static void send_extraction_done (File file, Variant v) throws Error {
     output_stream.write_all (data.get_data (), out bytes_written);
 }
 
+static void send_skip (File file) {
+    size_t bytes_written = 0;
+    var status = SKIPPED_LINE_TEMPLATE.printf (file.get_uri ());
+
+    try {
+        output_stream.write_all (status.data, out bytes_written);
+    } catch (Error error) {
+        warning (_("Failed to send error to parent: %s"), error.message);
+    }
+}
+
 static void send_error (File file, Error err) {
     size_t bytes_written = 0;
     var status = ERROR_LINE_TEMPLATE.printf (file.get_uri (),
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 161ed07..2a20dab 100644
--- a/src/plugins/media-export/rygel-media-export-harvesting-task.vala
+++ b/src/plugins/media-export/rygel-media-export-harvesting-task.vala
@@ -306,7 +306,7 @@ public class Rygel.MediaExport.HarvestingTask : Rygel.StateMachine,
     }
 
     private void on_extracted_cb (File               file,
-                                  Variant            info) {
+                                  Variant?           info) {
         if (!file.equal (this.files.peek ().file)) {
             debug ("Not for us, ignoring");
         }
diff --git a/src/plugins/media-export/rygel-media-export-item-factory.vala 
b/src/plugins/media-export/rygel-media-export-item-factory.vala
index a2207c0..f04a83b 100644
--- a/src/plugins/media-export/rygel-media-export-item-factory.vala
+++ b/src/plugins/media-export/rygel-media-export-item-factory.vala
@@ -102,8 +102,13 @@ namespace Rygel.MediaExport.ItemFactory {
 
     static MediaObject? create_from_variant (MediaContainer parent,
                                              File           file,
-                                             Variant        v)
+                                             Variant?       v)
                                              throws Error {
+
+        if (v == null) {
+            return null;
+        }
+
         ItemFactory.check_variant_type (v,"(smvmvmvmvmvmv)");
 
         Variant? upnp_class,
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 287faa2..dda3462 100644
--- a/src/plugins/media-export/rygel-media-export-metadata-extractor.vala
+++ b/src/plugins/media-export/rygel-media-export-metadata-extractor.vala
@@ -43,7 +43,7 @@ public class Rygel.MediaExport.MetadataExtractor: GLib.Object {
     private static VariantType SERIALIZED_DATA_TYPE;
 
     /* Signals */
-    public signal void extraction_done (File file, Variant info);
+    public signal void extraction_done (File file, Variant? info);
 
     /**
      * Signalize that an error occured during metadata extraction
@@ -213,7 +213,8 @@ public class Rygel.MediaExport.MetadataExtractor: GLib.Object {
                 }
 
                 if (!str.has_prefix ("RESULT|") &&
-                    !str.has_prefix ("ERROR|")) {
+                    !str.has_prefix ("ERROR|") &&
+                    !str.has_prefix ("SKIP|")) {
                     warning (_("Received invalid string from child: %s"), str);
 
                     break;
@@ -237,6 +238,14 @@ public class Rygel.MediaExport.MetadataExtractor: GLib.Object {
                 var uri = parts[1];
                 var length = uint64.parse (parts[2]);
 
+                if (parts[0] == "SKIP") {
+                    debug ("Extractor binary told us to skip %s",
+                           uri);
+                    this.extraction_done (File.new_for_uri (uri), null);
+
+                    break;
+                }
+
                 debug ("Found serialized data for uri %s", uri);
                 var buf = new uint8[length];
                 size_t bytes;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]