class DASHProxy: def __init__(self, logger, ip, port, configfps, ingestproxy, mcip): self._logger = logger self._ip = ip self._port = port # read all config files and add channels for configfp in configfps: Channel.append(configfp) # create shared memdb self._memdb = MemDB() # handler class for responding to http requests self._myhandler = makehandlerclass(self._logger.getChild("HTTPServer"), ingestproxy, mcip, self._memdb) # self._myhandler.protocol_version = "HTTP/1.1" #-->Do not use HTTP1.1 because handler does not support 206 and byte requests easily. self._myhandler.server_version = "m2u" self._httpd = None # stitcher for concatenating RTP slices into fragments self._stitcher = Stitcher(name="stitcher", args=(self._logger.getChild("Stitcher"), self._memdb)) def serve_requests(self): try: # start stitcher self._stitcher.start() # start HTTP server self._httpd = HTTPServer((self._ip, self._port), self._myhandler) self._logger.info("Handling requests on %s:%d" % (self._ip, self._port)) # This will block and periodically check the shutdown signal self._httpd.serve_forever() except: self.stop() raise def stop(self): if self._httpd is not None: self._httpd.shutdown() self._httpd = None if self._stitcher is not None: self._stitcher.stop() self._stitcher.join(1) self._stitcher = None