Przeglądaj źródła

Fix PPVM parsing error

Billy Barrow 2 lat temu
rodzic
commit
d2017c0401
1 zmienionych plików z 13 dodań i 6 usunięć
  1. 13 6
      src/lib/Ppvm.vala

+ 13 - 6
src/lib/Ppvm.vala

@@ -135,21 +135,28 @@ namespace Ppub {
             entries = new Gee.HashMap<string, string>();
             streams = new Invercargill.Sequence<VideoDescription>();
 
-            string line;
+            var metadata_complete = false;
+            string line = dis.read_line();
+            if(line != "PPVM") {
+                throw new IOError.INVALID_DATA("Stream does not begin with PPVM magic number");
+            }
             while((line = dis.read_line()) != null) {
-                print(@"PPVM: $line\n");
                 if(line.chomp().chug() == "") {
+                    metadata_complete = true;
                     continue;
                 }
 
                 var kv = line.split(": ", 2);
-                if(kv[0] == VIDEO) {
-                    streams.add(new VideoDescription.from_string(kv[1]));
+
+                if(!metadata_complete) {
+                    print(@"[Stream reader] Property $(kv[0]) is $(kv[1])\n");
+                    entries.set(kv[0], kv[1]);
                 }
                 else {
-
+                    if(kv[0] == VIDEO) {
+                        streams.add(new VideoDescription.from_string(kv[1]));
+                    }
                 }
-                entries.set(kv[0], kv[1]);
             }
 
         }