|
@@ -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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+}
|