소스 검색

Add basic PPVM support

Billy Barrow 2 년 전
부모
커밋
030602a459
3개의 변경된 파일206개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 1
      src/lib/Metadata.vala
  2. 204 0
      src/lib/Ppvm.vala
  3. 1 0
      src/lib/meson.build

+ 1 - 1
src/lib/Metadata.vala

@@ -46,7 +46,7 @@ namespace Ppub {
 
         public string? author_name {
             owned get {
-                return author?.split("<")[0].chomp();
+                return author?.split("<")[0].chomp().chug();
             }
         }
 

+ 204 - 0
src/lib/Ppvm.vala

@@ -0,0 +1,204 @@
+using Invercargill;
+
+namespace Ppub {
+
+    public class VideoManifest {
+
+        public const string TITLE = "title";
+        public const string AUTHOR = "author";
+        public const string COPYRIGHT = "copyright";
+        public const string LICENCE = "licence";
+        public const string MASTER = "master";
+        public const string POSTER = "poster";
+        public const string RATIO = "ratio";
+        public const string DURATION = "duration";
+        public const string DESCRIPTION_ASSET = "description";
+
+        public const string VIDEO = "video";
+    
+        private Gee.HashMap<string, string> entries { get; set; }
+
+        public Invercargill.Sequence<VideoDescription> streams { get; set; }
+    
+        public string? get_value(string name) {
+            if (entries.has_key(name)) {
+                return entries.get(name);
+            }
+            return null;
+        }
+    
+        public void set_value(string name, string value) {
+            entries.set(name, value);
+        }
+    
+        public string? title {
+            owned get {
+                return get_value(TITLE);
+            }
+            set {
+                set_value(TITLE, value);
+            }
+        }
+    
+        public string? author {
+            owned get {
+                return get_value(AUTHOR);
+            }
+            set {
+                set_value(AUTHOR, value);
+            }
+        }
+    
+        public string? copyright {
+            owned get {
+                return get_value(COPYRIGHT);
+            }
+            set {
+                set_value(COPYRIGHT, value);
+            }
+        }
+    
+        public string? licence {
+            owned get {
+                return get_value(LICENCE);
+            }
+            set {
+                set_value(LICENCE, value);
+            }
+        }
+    
+        public string? master {
+            owned get {
+                return get_value(MASTER);
+            }
+            set {
+                set_value(MASTER, value);
+            }
+        }
+    
+        public string? poster {
+            owned get {
+                return get_value(POSTER);
+            }
+            set {
+                set_value(POSTER, value);
+            }
+        }
+    
+        public string? ratio {
+            owned get {
+                return get_value(RATIO);
+            }
+            set {
+                set_value(RATIO, value);
+            }
+        }
+    
+        public string? duration {
+            owned get {
+                return get_value(DURATION);
+            }
+            set {
+                set_value(DURATION, value);
+            }
+        }
+
+        public string? description_file_name {
+            owned get {
+                return get_value(DESCRIPTION_ASSET);
+            }
+            set {
+                set_value(DESCRIPTION_ASSET, value);
+            }
+        }
+
+        public VideoManifest.from_stream(InputStream stream) throws IOError {
+
+            var dis = new DataInputStream(stream);
+            entries = new Gee.HashMap<string, string>();
+            streams = new Invercargill.Sequence<VideoDescription>();
+
+            string line;
+            while((line = dis.read_line()) != null) {
+                print(@"PPVM: $line\n");
+                if(line.chomp().chug() == "") {
+                    continue;
+                }
+
+                var kv = line.split(": ", 2);
+                if(kv[0] == VIDEO) {
+                    streams.add(new VideoDescription.from_string(kv[1]));
+                }
+                else {
+
+                }
+                entries.set(kv[0], kv[1]);
+            }
+
+        }
+
+
+    }
+
+    public class VideoDescription {
+
+        public string version_label {get; set;}
+        public string file_name {get; set;}
+
+        public const string SIZE = "size";
+        public const string CODECS = "codecs";
+
+        private Gee.HashMap<string, string> properties { get; set; }
+
+        public VideoDescription.from_string(string line) {
+            var fields = line.split(", ", 3);
+            version_label = fields[0];
+            file_name = fields[1];
+
+            properties = new Gee.HashMap<string, string>();
+            var property_items = fields[2].split(";");
+            foreach (var item in property_items) {
+                if(item.chomp().chug() == ""){
+                    continue;
+                }
+
+                var item_parts = item.split("=\"", 2);
+                var name = item_parts[0].chomp().chug();
+                var value = item_parts[1].split("\"")[0];
+                print(@"prop: $(name) = $(value)\n");
+                properties.set(name, value);
+            }
+        }
+
+        public string? get_property(string name) {
+            if (properties.has_key(name)) {
+                return properties.get(name);
+            }
+            return null;
+        }
+    
+        public void set_property(string name, string value) {
+            properties.set(name, value);
+        }
+
+        public string? codecs {
+            owned get {
+                return get_property(CODECS);
+            }
+            set {
+                set_property(CODECS, value);
+            }
+        }
+
+        public string? size {
+            owned get {
+                return get_property(SIZE);
+            }
+            set {
+                set_property(SIZE, value);
+            }
+        }
+
+    }
+
+}

+ 1 - 0
src/lib/meson.build

@@ -12,6 +12,7 @@ sources += files('Metadata.vala')
 sources += files('AssetStream.vala')
 sources += files('Builder.vala')
 sources += files('StreamMonitor.vala')
+sources += files('Ppvm.vala')
 
 ppub = shared_library('libppub', sources,
     name_prefix: '',