summaryrefslogtreecommitdiff
path: root/www/js/DataModel.js
diff options
context:
space:
mode:
Diffstat (limited to 'www/js/DataModel.js')
-rwxr-xr-xwww/js/DataModel.js137
1 files changed, 113 insertions, 24 deletions
diff --git a/www/js/DataModel.js b/www/js/DataModel.js
index f930be8d..a7badad8 100755
--- a/www/js/DataModel.js
+++ b/www/js/DataModel.js
@@ -848,7 +848,13 @@ angular.module('zmApp.controllers')
if (typeof loginData.disableSimulStreaming == 'undefined') {
loginData.disableSimulStreaming = false;
+
}
+ // iOS it is always off, webkit bug
+
+ if ($rootScope.platformOS=='ios') {
+ loginData.disableSimulStreaming = true;
+ }
if (typeof loginData.exitOnSleep == 'undefined') {
debug("exitOnSleep does not exist. Setting to false");
@@ -1108,12 +1114,8 @@ angular.module('zmApp.controllers')
loginData.showLiveForInProgressEvents = true;
}
-
-
-
-
-
- log("DataModel init recovered this loginData as " + JSON.stringify(loginData));
+
+ log("DataModel init retrieved store loginData");
} else {
log("defaultServer configuration NOT found. Keeping login at defaults");
}
@@ -1125,7 +1127,7 @@ angular.module('zmApp.controllers')
// FIXME: HACK: This is the latest entry point into dataModel init, so start portal login after this
// not the neatest way
- $rootScope.$emit('init-complete');
+ $rootScope.$broadcast('init-complete');
});
monitorsLoaded = 0;
@@ -1142,7 +1144,7 @@ angular.module('zmApp.controllers')
},
setJustResumed: function (val) {
- justResumed = true;
+ justResumed = val;
},
stopNetwork: function (str) {
@@ -1151,10 +1153,11 @@ angular.module('zmApp.controllers')
if (justResumed) {
// we don't call stop as we did stop on pause
log(s + " Not calling window stop as we just resumed");
- justResumed = false;
+
} else {
- log(s + " Calling window.stop()");
- window.stop();
+ log(s + " stopNework: Calling window.stop()");
+ $timeout (function() {window.stop();});
+
}
},
@@ -1395,7 +1398,7 @@ angular.module('zmApp.controllers')
// Skipping monitor number as I only need an auth key
// so no need to generate an image
- var myurl = loginData.url + "/index.php?view=watch&mid=" + mid + "&connkey=" + ck;
+ var myurl = loginData.url + "/index.php?view=watch&mid=" + mid ;
debug("DataModel: Getting auth from " + myurl + " with mid=" + mid);
$http.get(myurl)
.then(function (success) {
@@ -1534,18 +1537,84 @@ angular.module('zmApp.controllers')
return monitors;
},
- killStream: function (ck) {
+ pauseLiveStream: function (ck,url) {
+ if (!url) url = loginData.url;
+
+ var myauthtoken = $rootScope.authSession.replace("&auth=", "");
+ var req = url+'/index.php';
+ req = req + "?view=request&request=stream";
+ req = req + "&connkey="+ck;
+ req = req + "&auth="+myauthtoken;
+ // req = req + "&command=17";
+
+ debug ("DataModel: Pausing live stream ck:"+ck);
+ return $http.get(req+"&command=1")
+ .then (
+ function (s) {
+ debug ("pause success for ck:"+ck+" with:"+JSON.stringify(s));
+
+ },
+ function (e) {debug ("pause success for ck:"+ck+" with:"+JSON.stringify(e));}
+ );
+
+ },
+
+ resumeLiveStream: function (ck,url) {
+ if (!url) url = loginData.url;
+
+ var myauthtoken = $rootScope.authSession.replace("&auth=", "");
+ var req = url+'/index.php';
+ req = req + "?view=request&request=stream";
+ req = req + "&connkey="+ck;
+ req = req + "&auth="+myauthtoken;
+ // req = req + "&command=17";
+
+ debug ("DataModel: Resuming live stream ck:"+ck);
+ return $http.get(req+"&command=2")
+ .then (
+ function (s) {
+ debug ("play success for ck:"+ck+" with:"+JSON.stringify(s));
+
+ },
+ function (e) {debug ("play success for ck:"+ck+" with:"+JSON.stringify(e));}
+ );
+
+ },
+
+ killLiveStream: function (ck,url,name) {
+
+ if (!url) url = loginData.url;
+
+ var myauthtoken = $rootScope.authSession.replace("&auth=", "");
+ var req = url+'/index.php';
+ req = req + "?view=request&request=stream";
+ req = req + "&connkey="+ck;
+ req = req + "&auth="+myauthtoken;
+ // req = req + "&command=17";
+ if (name==undefined) name="";
+ debug ("DataModel: killing "+name+" live stream ck:"+ck);
+ return $http.get(req+"&command=17")
+ .then (
+ function (s) {
+ debug ("kill success for ck:"+ck+" with:"+JSON.stringify(s));
+
+ },
+ function (e) {debug ("kill success for ck:"+ck+" with:"+JSON.stringify(e));}
+ );
+ },
+
+ /*killStream: function (ck) {
debug ("Killing connKey: "+ck);
var myauthtoken = $rootScope.authSession.replace("&auth=", "");
var req = $http(
{
method: 'POST',
- /*timeout: 15000,*/
+
url: loginData.url + '/index.php',
headers:
{
'Content-Type': 'application/x-www-form-urlencoded',
- //'Accept': '*/*',
+ ,
},
transformRequest: function(obj)
{
@@ -1563,26 +1632,27 @@ angular.module('zmApp.controllers')
view: "request",
request: "stream",
connkey: ck,
- command: 17,
+ command: 3,
auth: myauthtoken,
}
})
.then (function (succ) {
- console.log ("KILL OK WITH: " + JSON.stringify(succ));
+ console.log ("STOP/KILL OK WITH: " + JSON.stringify(succ));
},
function (err) {
console.log ("KILL ERROR WITH: " + JSON.stringify(err));
});
- },
+ },*/
regenConnKeys: function () {
- debug ("Regenerating connkeys...");
+ debug ("DataModel: Regenerating connkeys...");
for (var i=0; i < monitors.length; i++){
monitors[i].Monitor.connKey = (Math.floor((Math.random() * 999999) + 1)).toString();
+ monitors[i].Monitor.rndKey = (Math.floor((Math.random() * 999999) + 1)).toString();
}
},
@@ -1610,6 +1680,8 @@ angular.module('zmApp.controllers')
// console.log ("gettign zms port");
getZmsMultiPortSupport()
.then(function (zmsPort) {
+
+ var controlURL = "";
debug ("ZMS Multiport reported: "+zmsPort);
debug ("Monitor URL to fetch is:"+myurl);
@@ -1641,6 +1713,7 @@ angular.module('zmApp.controllers')
monitors[i].Monitor.listDisplay = 'show';
monitors[i].Monitor.isAlarmed = false;
monitors[i].Monitor.connKey = (Math.floor((Math.random() * 999999) + 1)).toString();
+ monitors[i].Monitor.rndKey = (Math.floor((Math.random() * 999999) + 1)).toString();
var serverFound = false;
for (var j = 0; j < multiservers.length; j++) {
@@ -1668,9 +1741,12 @@ angular.module('zmApp.controllers')
var st = "";
var baseurl = "";
var streamingurl = "";
+
st += (s.scheme ? s.scheme : p.scheme) + "://"; // server scheme overrides
+
+
// if server doesn't have a protocol, what we want is in path
if (!s.host) {
s.host = s.path;
@@ -1678,6 +1754,7 @@ angular.module('zmApp.controllers')
}
st += s.host;
+
// console.log ("STEP 1: ST="+st);
if (zmsPort <=0 )
@@ -1688,6 +1765,7 @@ angular.module('zmApp.controllers')
// console.log ("STEP 2 no ZMS: ST="+st);
}
+
}
else {
var sport = parseInt(zmsPort) + parseInt(monitors[i].Monitor.Id);
@@ -1701,6 +1779,7 @@ angular.module('zmApp.controllers')
baseurl = st;
+ controlURL =st;
st += (s.path ? s.path : p.path);
streamingurl += (s.path ? s.path : p.path);
@@ -1712,18 +1791,20 @@ angular.module('zmApp.controllers')
monitors[i].Monitor.streamingURL = st;
monitors[i].Monitor.baseURL = baseurl;
+ monitors[i].Monitor.controlURL = controlURL;
//console.log ("** Streaming="+st+" **base="+baseurl);
// starting 1.30 we have fid=xxx mode to return images
monitors[i].Monitor.imageMode = (versionCompare($rootScope.apiVersion, "1.30") == -1) ? "path" : "fid";
// debug("API " + $rootScope.apiVersion + ": Monitor " + monitors[i].Monitor.Id + " will use " + monitors[i].Monitor.imageMode + " for direct image access");
- debug ("Streaming URL for Monitor " + monitors[i].Monitor.Id + " is " + monitors[i].Monitor.streamingURL );
+ //debug ("Streaming URL for Monitor " + monitors[i].Monitor.Id + " is " + monitors[i].Monitor.streamingURL );
//debug ("Base URL for Monitor " + monitors[i].Monitor.Id + " is " + monitors[i].Monitor.baseURL );
} else {
//monitors[i].Monitor.listDisplay = 'show';
monitors[i].Monitor.isAlarmed = false;
monitors[i].Monitor.connKey = (Math.floor((Math.random() * 999999) + 1)).toString();
+ monitors[i].Monitor.rndKey = (Math.floor((Math.random() * 999999) + 1)).toString();
var st2 = loginData.streamingurl;
@@ -1731,6 +1812,7 @@ angular.module('zmApp.controllers')
// we need to insert minport
st2 = "";
var p2 = URI.parse(loginData.streamingurl);
+ var p3 = URI.parse( loginData.url);
st2 += p2.scheme + "://";
if (!p2.host) {
p2.host = p2.path;
@@ -1739,11 +1821,16 @@ angular.module('zmApp.controllers')
st2 += p2.host;
var sport2 = parseInt(zmsPort) + parseInt(monitors[i].Monitor.Id);
st2 = st2 + ':'+sport2;
+
+ controlURL = st2;
+
if (p2.path) st2 += p2.path;
+ if (p3.path) controlURL +=p3.path;
}
monitors[i].Monitor.streamingURL = st2;
- debug ("Streaming URL for Monitor " + monitors[i].Monitor.Id + " is " + monitors[i].Monitor.streamingURL );
+ monitors[i].Monitor.controlURL = controlURL;
+ //debug ("Streaming URL for Monitor " + monitors[i].Monitor.Id + " is " + monitors[i].Monitor.streamingURL );
//console.log ("NO SERVER MATCH CONSTRUCTED STREAMING PATH="+st2);
monitors[i].Monitor.baseURL = loginData.url;
monitors[i].Monitor.imageMode = (versionCompare($rootScope.apiVersion, "1.30") == -1) ? "path" : "fid";
@@ -1769,6 +1856,7 @@ angular.module('zmApp.controllers')
//monitors[i].Monitor.listDisplay = 'show';
monitors[i].Monitor.isAlarmed = false;
monitors[i].Monitor.connKey = (Math.floor((Math.random() * 999999) + 1)).toString();
+ monitors[i].Monitor.rndKey = (Math.floor((Math.random() * 999999) + 1)).toString();
var st = loginData.streamingurl;
if (zmsPort >0) {
// we need to insert minport
@@ -1789,10 +1877,11 @@ angular.module('zmApp.controllers')
}
monitors[i].Monitor.streamingURL = st;
- console.log ("CONSTRUCTED STREAMING PATH="+st);
+ // console.log ("CONSTRUCTED STREAMING PATH="+st);
monitors[i].Monitor.baseURL = loginData.url;
+
monitors[i].Monitor.imageMode = (versionCompare($rootScope.apiVersion, "1.30") == -1) ? "path" : "fid";
- debug("API " + $rootScope.apiVersion + ": Monitor " + monitors[i].Monitor.Id + " will use " + monitors[i].Monitor.imageMode + " for direct image access");
+ //debug("API " + $rootScope.apiVersion + ": Monitor " + monitors[i].Monitor.Id + " will use " + monitors[i].Monitor.imageMode + " for direct image access");
}
d.resolve(monitors);
@@ -1932,7 +2021,7 @@ angular.module('zmApp.controllers')
isTzSupported = true;
else
isTzSupported = false;
- $rootScope.$emit('tz-updated');
+ $rootScope.$broadcast('tz-updated');
return (d.promise);
},