From c027bdf34e5117e3b97c44adbe0bcf7aa7900a90 Mon Sep 17 00:00:00 2001
From: Nicolas Pope <nwpope@utu.fi>
Date: Tue, 26 May 2020 20:23:00 +0300
Subject: [PATCH] Check for bad packet order

---
 web-service/public/js/bundle.js               | 26 +++++++++++++++++++
 web-service/public/js/index.js                | 25 ++++++++++++++++++
 .../public/js/lib/dist/video-converter.js     |  1 +
 3 files changed, 52 insertions(+)

diff --git a/web-service/public/js/bundle.js b/web-service/public/js/bundle.js
index 170f36ce3..1d13b2af7 100644
--- a/web-service/public/js/bundle.js
+++ b/web-service/public/js/bundle.js
@@ -59979,6 +59979,11 @@ webSocketTest = () => {
     peer.send("update_cfg", "ftl://utu.fi#reconstruction_default/0/renderer/cool_effect", "true")    
 }
 
+function FTLFrameset(id) {
+	this.id = id;
+	this.sources = {};
+}
+
 function FTLStream(peer, uri, element) {
 	this.uri = uri;
 	this.peer = peer;
@@ -59988,6 +59993,10 @@ function FTLStream(peer, uri, element) {
 	this.current_source = 0;
 	this.current_channel = 0;
 
+	this.framesets = {};
+
+	this.handlers = {};
+
 	//this.elements_ = {};
 	//this.converters_ = {};
 
@@ -60226,6 +60235,22 @@ function FTLStream(peer, uri, element) {
 	}
 }
 
+FTLStream.prototype.on = function(name, cb) {
+	if (!this.handlers.hasOwnProperty(name)) {
+		this.handlers[name] = [];
+	}
+	this.handlers[name].push(cb);
+}
+
+FTLStream.prototype.notify = function (name, ...args) {
+	if (this.handlers.hasOwnProperty(name)) {
+		let a = this.handlers[name];
+		for (let i=0; i<a.length; ++i) {
+			a[i].apply(this, args);
+		}
+	}
+}
+
 FTLStream.prototype.pause = function() {
 	this.paused = !this.paused;
 	if (!this.paused) {
@@ -61669,6 +61694,7 @@ var VideoConverter = (function () {
                 this.queue.push(data);
             }
             else {
+				if (this.queue.length > 0) console.error("DATA IN QUEUE");
                 this.doAppend(data);
             }
         }
diff --git a/web-service/public/js/index.js b/web-service/public/js/index.js
index 856efa79b..b2047a552 100644
--- a/web-service/public/js/index.js
+++ b/web-service/public/js/index.js
@@ -125,6 +125,11 @@ webSocketTest = () => {
     peer.send("update_cfg", "ftl://utu.fi#reconstruction_default/0/renderer/cool_effect", "true")    
 }
 
+function FTLFrameset(id) {
+	this.id = id;
+	this.sources = {};
+}
+
 function FTLStream(peer, uri, element) {
 	this.uri = uri;
 	this.peer = peer;
@@ -134,6 +139,10 @@ function FTLStream(peer, uri, element) {
 	this.current_source = 0;
 	this.current_channel = 0;
 
+	this.framesets = {};
+
+	this.handlers = {};
+
 	//this.elements_ = {};
 	//this.converters_ = {};
 
@@ -372,6 +381,22 @@ function FTLStream(peer, uri, element) {
 	}
 }
 
+FTLStream.prototype.on = function(name, cb) {
+	if (!this.handlers.hasOwnProperty(name)) {
+		this.handlers[name] = [];
+	}
+	this.handlers[name].push(cb);
+}
+
+FTLStream.prototype.notify = function (name, ...args) {
+	if (this.handlers.hasOwnProperty(name)) {
+		let a = this.handlers[name];
+		for (let i=0; i<a.length; ++i) {
+			a[i].apply(this, args);
+		}
+	}
+}
+
 FTLStream.prototype.pause = function() {
 	this.paused = !this.paused;
 	if (!this.paused) {
diff --git a/web-service/public/js/lib/dist/video-converter.js b/web-service/public/js/lib/dist/video-converter.js
index 9b99eaa2d..2e91f4b25 100644
--- a/web-service/public/js/lib/dist/video-converter.js
+++ b/web-service/public/js/lib/dist/video-converter.js
@@ -143,6 +143,7 @@ var VideoConverter = (function () {
                 this.queue.push(data);
             }
             else {
+				if (this.queue.length > 0) console.error("DATA IN QUEUE");
                 this.doAppend(data);
             }
         }
-- 
GitLab