diff options
Diffstat (limited to 'src')
-rwxr-xr-x | src/daq/nginx-lua/s5-nginx-lua-fetch | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/src/daq/nginx-lua/s5-nginx-lua-fetch b/src/daq/nginx-lua/s5-nginx-lua-fetch index 86ef940..7d13ba9 100755 --- a/src/daq/nginx-lua/s5-nginx-lua-fetch +++ b/src/daq/nginx-lua/s5-nginx-lua-fetch @@ -208,15 +208,15 @@ class NGXLuaFetcher(): if len(cs.keys()) == 1: self._content_id = cs.keys()[0] - print 'SFive: only one content-id detected "%s" - will include it in init messages only' % self._content_id +# print 'SFive: only one content-id detected "%s" - will include it in init messages only' % self._content_id if len(fs.keys()) == 1: self._format = fs.keys()[0] - print 'SFive: only one format detected "%s" - will include it in init messages only' % self._format +# print 'SFive: only one format detected "%s" - will include it in init messages only' % self._format if len(qs.keys()) == 1: self._quality = qs.keys()[0] - print 'SFive: only one quality detected "%s" - will include it in init messages only' % self._quality +# print 'SFive: only one quality detected "%s" - will include it in init messages only' % self._quality @@ -241,7 +241,7 @@ class NGXLuaFetcher(): for f in self._streamer[c].keys(): for q in self._streamer[c][f].keys(): if self._connected: - self._sendDataset(self._start_time, self._duration, c, f, q) + self._sendDatasetFull(self._start_time, self._duration, c, f, q) self._streamer[c][f][q].clear() self._start_time = datetime.datetime.utcnow().replace(microsecond=0) @@ -299,8 +299,8 @@ class NGXLuaFetcher(): def socketReady(self): print 'SFive: connection to sfive hub established' self._connected = True - self._sendInit() - # TODO: start callback every self._duration seconds +# we are using datagram sockets for now -> must use stateless protocol +# self._sendInit() def socketError(self): print 'SFive: connection to sfive hub lost - trying reconnect' @@ -309,6 +309,24 @@ class NGXLuaFetcher(): self._connected = False reactor.callLater(3, self._initSocket) + def _sendDatasetFull(self, timestamp, duration, content_id, format, quality): + clients = self._streamer[content_id][format][quality] + data = { "version": 1, "hostname": self._hostname, "tags": self._tags, + "streamer-id": { + "content-id": content_id, + "format": format, + "quality": quality + }, + "start-time": timestamp.isoformat('T') + 'Z', + "duration-ms": duration * 1000, + "data": { + "clients": list(clients.values()), + "client-count": clients.getCnt(), + "bytes-sent": clients.getBytesSent() + } + } + self._proto.sendDatagram('%s\n' % (json.dumps(data))); + def _sendInit(self): initdata = { "version": 1, "hostname": self._hostname, "streamer-id" : { }, |