From fe1886aa0857be59fd81ac0a4fe1b9901bbc837c Mon Sep 17 00:00:00 2001 From: winlin Date: Fri, 10 Apr 2015 15:50:12 +0800 Subject: [PATCH] add proxy for hls --- trunk/research/api-server/server.py | 31 +++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/trunk/research/api-server/server.py b/trunk/research/api-server/server.py index 57baeff4b..ce9880f83 100755 --- a/trunk/research/api-server/server.py +++ b/trunk/research/api-server/server.py @@ -308,6 +308,36 @@ class RESTDvrs(object): return code + +''' +handle the hls proxy requests: hls stream. +''' +class RESTProxy(object): + exposed = True + + ''' + for SRS hook: on_hls_notify + on_hls_notify: + when srs reap a ts file of hls, call this hook, + used to push file to cdn network, by get the ts file from cdn network. + so we use HTTP GET and use the variable following: + [app], replace with the app. + [stream], replace with the stream. + [ts_url], replace with the ts url. + ignore any return data of server. + ''' + def GET(self, *args, **kwargs): + enable_crossdomain() + + hls = { + "args": args, + "kwargs": kwargs + } + + ret = json.dumps(hls) + print ret + return ret + ''' handle the hls requests: hls stream. ''' @@ -1195,6 +1225,7 @@ class V1(object): self.sessions = RESTSessions() self.dvrs = RESTDvrs() self.hls = RESTHls() + self.proxy = RESTProxy() self.chats = RESTChats() self.servers = RESTServers() self.nodes = RESTNodes()