From 9783ac8a3b50ef8c112bb9cfd1f648db0bb4176b Mon Sep 17 00:00:00 2001
From: Sami Spets <savasp@utu.fi>
Date: Mon, 25 Nov 2019 13:24:10 +0200
Subject: [PATCH] Debugging the VideoPlayer

---
 web-service/server/src/public/js/bundle.js    | 29 +++++++------------
 .../server/src/public/js/lib/VideoPlayer.js   | 29 +++++++------------
 2 files changed, 20 insertions(+), 38 deletions(-)

diff --git a/web-service/server/src/public/js/bundle.js b/web-service/server/src/public/js/bundle.js
index 0ad0a5707..f89fba88b 100644
--- a/web-service/server/src/public/js/bundle.js
+++ b/web-service/server/src/public/js/bundle.js
@@ -4825,16 +4825,16 @@ VideoPlayer.prototype._handle_onload = function(peer, decodedURI, uri) {
 
     var decode = function(pckg) {
         if (!that.running) { return; }
-        console.log("DECODE FUNKKARI ALKU")
+        console.log("DECODE FUNKKARI ALKU", pckg)
         var err;
-        if (pckg == null) { return; }
-        else{
-
+        if (pckg == null) { console.log("NULL NULL NULL NULL"); return; 
+        } else {
             try {
                 var tmp = pckg
                 err = decoder.push_data(tmp);
-            } catch(err) {
-                console.log(err);
+                console.log("ERROR TRY:n sisällä", err, tmp)
+            } catch(e) {
+                console.log(e);
                 err = decoder.flush();
                 return;
             }
@@ -4855,14 +4855,14 @@ VideoPlayer.prototype._handle_onload = function(peer, decodedURI, uri) {
         }
 
         decoder.decode(function(err) {
+            console.log("TÄSÄ KUSEE", err)
             switch(err) {
             case libde265.DE265_ERROR_WAITING_FOR_INPUT_DATA:
                 console.log("DE265_ERROR_WAITING_FOR_INPUT_DATA");
-                setTimeout(decode(null), 0);
-                return;
 
             default:
                 if (!libde265.de265_isOK(err)) {
+                    console.log("PIIPPIIP")
                     that._set_error(err, libde265.de265_get_error_text(err));
                     return;
                 }
@@ -4870,21 +4870,20 @@ VideoPlayer.prototype._handle_onload = function(peer, decodedURI, uri) {
 
             if (decoder.has_more()) {
                 console.log("has more");
-                setTimeout(decode(null), 0);
                 return;
             }
 
             decoder.free();
             that.stop();
+            console.log("PITÄIS LOGATA");
         });
-        console.log("DECODE FUNKKARIN LOPPU")
     }
 
 
     peer.bind(decodedURI, (latency, streampckg, pckg) => {
         console.log(pckg[0])
         if(pckg[0] === 0){
-            decode([pckg[5]]);
+            decode(pckg[5]);
         };
     })
     // Start the transaction
@@ -4898,14 +4897,6 @@ VideoPlayer.prototype.playback = function(peer, decodedURI, uri) {
     console.log(peer);
     console.log(uri)
     this._handle_onload(peer, decodedURI, uri)
-    // var that = this;
-
-    // peer.sock.onopen = function() {
-    //     console.log("Stream open");
-    //     that._handle_onload(ws);
-    // };
-
-    // ws.onclose = function() { console.log("Connection closed."); }
     this._set_status("loading");
     this.running = true;
     console.log("piippiip")
diff --git a/web-service/server/src/public/js/lib/VideoPlayer.js b/web-service/server/src/public/js/lib/VideoPlayer.js
index c7ed3ef00..f4f3fee2c 100644
--- a/web-service/server/src/public/js/lib/VideoPlayer.js
+++ b/web-service/server/src/public/js/lib/VideoPlayer.js
@@ -102,16 +102,16 @@ VideoPlayer.prototype._handle_onload = function(peer, decodedURI, uri) {
 
     var decode = function(pckg) {
         if (!that.running) { return; }
-        console.log("DECODE FUNKKARI ALKU")
+        console.log("DECODE FUNKKARI ALKU", pckg)
         var err;
-        if (pckg == null) { return; }
-        else{
-
+        if (pckg == null) { console.log("NULL NULL NULL NULL"); return; 
+        } else {
             try {
                 var tmp = pckg
                 err = decoder.push_data(tmp);
-            } catch(err) {
-                console.log(err);
+                console.log("ERROR TRY:n sisällä", err, tmp)
+            } catch(e) {
+                console.log(e);
                 err = decoder.flush();
                 return;
             }
@@ -132,14 +132,14 @@ VideoPlayer.prototype._handle_onload = function(peer, decodedURI, uri) {
         }
 
         decoder.decode(function(err) {
+            console.log("TÄSÄ KUSEE", err)
             switch(err) {
             case libde265.DE265_ERROR_WAITING_FOR_INPUT_DATA:
                 console.log("DE265_ERROR_WAITING_FOR_INPUT_DATA");
-                setTimeout(decode(null), 0);
-                return;
 
             default:
                 if (!libde265.de265_isOK(err)) {
+                    console.log("PIIPPIIP")
                     that._set_error(err, libde265.de265_get_error_text(err));
                     return;
                 }
@@ -147,21 +147,20 @@ VideoPlayer.prototype._handle_onload = function(peer, decodedURI, uri) {
 
             if (decoder.has_more()) {
                 console.log("has more");
-                setTimeout(decode(null), 0);
                 return;
             }
 
             decoder.free();
             that.stop();
+            console.log("PITÄIS LOGATA");
         });
-        console.log("DECODE FUNKKARIN LOPPU")
     }
 
 
     peer.bind(decodedURI, (latency, streampckg, pckg) => {
         console.log(pckg[0])
         if(pckg[0] === 0){
-            decode([pckg[5]]);
+            decode(pckg[5]);
         };
     })
     // Start the transaction
@@ -175,14 +174,6 @@ VideoPlayer.prototype.playback = function(peer, decodedURI, uri) {
     console.log(peer);
     console.log(uri)
     this._handle_onload(peer, decodedURI, uri)
-    // var that = this;
-
-    // peer.sock.onopen = function() {
-    //     console.log("Stream open");
-    //     that._handle_onload(ws);
-    // };
-
-    // ws.onclose = function() { console.log("Connection closed."); }
     this._set_status("loading");
     this.running = true;
     console.log("piippiip")
-- 
GitLab