Просмотр исходного кода

Update after Invercargill refactor

Billy Barrow 1 год назад
Родитель
Сommit
6247d7d041
7 измененных файлов с 58 добавлено и 5 удалено
  1. 1 0
      src/lib/Asset.vala
  2. 1 1
      src/lib/Builder.vala
  3. 1 0
      src/lib/Metadata.vala
  4. 50 0
      src/lib/Ppix.vala
  5. 1 1
      src/lib/Ppub.vala
  6. 3 3
      src/lib/Ppvm.vala
  7. 1 0
      src/lib/meson.build

+ 1 - 0
src/lib/Asset.vala

@@ -1,4 +1,5 @@
 using Invercargill;
+using Invercargill.Convert;
 using Gee;
 
 namespace Ppub {

+ 1 - 1
src/lib/Builder.vala

@@ -5,7 +5,7 @@ namespace Ppub {
 
     public class Builder {
 
-        private Invercargill.Sequence<BuilderAsset> assets = new Invercargill.Sequence<BuilderAsset>();
+        private Series<BuilderAsset> assets = new Series<BuilderAsset>();
 
         private uint64 position = 0;
 

+ 1 - 0
src/lib/Metadata.vala

@@ -1,4 +1,5 @@
 using Invercargill;
+using Invercargill.Convert;
 
 namespace Ppub {
 

+ 50 - 0
src/lib/Ppix.vala

@@ -0,0 +1,50 @@
+using Invercargill;
+
+namespace Ppub {
+    
+    public class Index {
+
+        private const uint8[] MAGIC = { 0x50, 0x50, 0x49, 0x58, 0x00 };
+
+        private DataInputStream stream;
+
+        private int64 publication_index_position;
+        private int64 collection_index_position;
+        private int64 tag_index_position;
+        private int64 word_index_position;
+
+        public string get_publication_filename_by_id(uint32 id) throws Error {
+            lock(stream) {
+                stream.seek(publication_index_position + (id * 6), SeekType.SET);
+                var string_start = stream.read_uint32();
+                var string_length = stream.read_uint16();
+
+                var filename = new uint8[string_length];
+                stream.seek(string_start, SeekType.SET);
+                stream.read(filename);
+
+                return (string)filename;
+            }
+        }
+
+        public uint32[] get_collection_by_id(uint32 id) throws Error {
+            lock(stream) {
+                stream.seek(collection_index_position + (id * 6), SeekType.SET);
+                var collection_start = stream.read_uint32();
+                var collection_items = stream.read_uint16();
+
+                var publication_ids = new uint32[collection_items];
+                stream.seek(collection_start, SeekType.SET);
+                for(var i = 0; i < collection_items; i++) {
+                    publication_ids[i] = stream.read_uint32();
+                }
+
+                return publication_ids;
+            }
+        }
+
+
+
+    }
+
+}

+ 1 - 1
src/lib/Ppub.vala

@@ -30,7 +30,7 @@ namespace Ppub {
             var asset_index_size = int.parse(dis.read_line());
             var asset_index_data = ((string)dis.read_bytes(asset_index_size).get_data()).split("\n");
             
-            var asset_seq = new Invercargill.Sequence<Asset>();
+            var asset_seq = new Series<Asset>();
             foreach (var index_data in asset_index_data) {
                 if(index_data.contains(": ")) {
                     asset_seq.add(new Asset.from_string(index_data));

+ 3 - 3
src/lib/Ppvm.vala

@@ -18,11 +18,11 @@ namespace Ppub {
     
         private Gee.HashMap<string, string> entries { get; set; }
 
-        public Invercargill.Sequence<VideoDescription> streams { get; set; }
+        public Series<VideoDescription> streams { get; set; }
 
         public VideoManifest() {
             entries = new Gee.HashMap<string, string>();
-            streams = Invercargill.empty<VideoDescription>().to_sequence();
+            streams = Invercargill.empty<VideoDescription>().to_series();
         }
     
         public string? get_value(string name) {
@@ -133,7 +133,7 @@ namespace Ppub {
 
             var dis = new DataInputStream(stream);
             entries = new Gee.HashMap<string, string>();
-            streams = new Invercargill.Sequence<VideoDescription>();
+            streams = new Series<VideoDescription>();
 
             var metadata_complete = false;
             string line = dis.read_line();

+ 1 - 0
src/lib/meson.build

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