Skip to content

Commit

Permalink
For #1110, Refine code.
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Aug 5, 2018
1 parent 455a060 commit 31945c2
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions trunk/research/api-server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def GET(self):
"action": "on_publish",
"client_id": 1985,
"ip": "192.168.1.10", "vhost": "video.test.com", "app": "live",
"stream": "livestream"
"stream": "livestream", "param":"?token=xxx&salt=yyy"
}
on_unpublish:
when client(encoder) stop publish to vhost/app/stream, call the hook,
Expand All @@ -185,7 +185,7 @@ def GET(self):
"action": "on_unpublish",
"client_id": 1985,
"ip": "192.168.1.10", "vhost": "video.test.com", "app": "live",
"stream": "livestream"
"stream": "livestream", "param":"?token=xxx&salt=yyy"
}
if valid, the hook must return HTTP code 200(Stauts OK) and response
an int value specifies the error code(0 corresponding to success):
Expand Down Expand Up @@ -223,8 +223,8 @@ def OPTIONS(self, *args, **kwargs):
def __on_publish(self, req):
code = Error.success

trace("srs %s: client id=%s, ip=%s, vhost=%s, app=%s, stream=%s"%(
req["action"], req["client_id"], req["ip"], req["vhost"], req["app"], req["stream"]
trace("srs %s: client id=%s, ip=%s, vhost=%s, app=%s, stream=%s, param=%s"%(
req["action"], req["client_id"], req["ip"], req["vhost"], req["app"], req["stream"], req["param"]
))

# TODO: process the on_publish event
Expand All @@ -234,8 +234,8 @@ def __on_publish(self, req):
def __on_unpublish(self, req):
code = Error.success

trace("srs %s: client id=%s, ip=%s, vhost=%s, app=%s, stream=%s"%(
req["action"], req["client_id"], req["ip"], req["vhost"], req["app"], req["stream"]
trace("srs %s: client id=%s, ip=%s, vhost=%s, app=%s, stream=%s, param=%s"%(
req["action"], req["client_id"], req["ip"], req["vhost"], req["app"], req["stream"], req["param"]
))

# TODO: process the on_unpublish event
Expand Down Expand Up @@ -263,7 +263,7 @@ def GET(self):
"action": "on_dvr",
"client_id": 1985,
"ip": "192.168.1.10", "vhost": "video.test.com", "app": "live",
"stream": "livestream",
"stream": "livestream", "param":"?token=xxx&salt=yyy",
"cwd": "/usr/local/srs",
"file": "./objs/nginx/html/live/livestream.1420254068776.flv"
}
Expand Down Expand Up @@ -301,8 +301,8 @@ def OPTIONS(self, *args, **kwargs):
def __on_dvr(self, req):
code = Error.success

trace("srs %s: client id=%s, ip=%s, vhost=%s, app=%s, stream=%s, cwd=%s, file=%s"%(
req["action"], req["client_id"], req["ip"], req["vhost"], req["app"], req["stream"],
trace("srs %s: client id=%s, ip=%s, vhost=%s, app=%s, stream=%s, param=%s, cwd=%s, file=%s"%(
req["action"], req["client_id"], req["ip"], req["vhost"], req["app"], req["stream"], req["param"],
req["cwd"], req["file"]
))

Expand All @@ -325,6 +325,7 @@ class RESTProxy(object):
so we use HTTP GET and use the variable following:
[app], replace with the app.
[stream], replace with the stream.
[param], replace with the param.
[ts_url], replace with the ts url.
ignore any return data of server.
'''
Expand Down Expand Up @@ -359,6 +360,7 @@ class RESTHls(object):
so we use HTTP GET and use the variable following:
[app], replace with the app.
[stream], replace with the stream.
[param], replace with the param.
[ts_url], replace with the ts url.
ignore any return data of server.
'''
Expand All @@ -382,7 +384,7 @@ def GET(self, *args, **kwargs):
"ip": "192.168.1.10",
"vhost": "video.test.com",
"app": "live",
"stream": "livestream",
"stream": "livestream", "param":"?token=xxx&salt=yyy",
"duration": 9.68, // in seconds
"cwd": "/usr/local/srs",
"file": "./objs/nginx/html/live/livestream.1420254068776-100.ts",
Expand Down Expand Up @@ -422,8 +424,8 @@ def OPTIONS(self, *args, **kwargs):
def __on_hls(self, req):
code = Error.success

trace("srs %s: client id=%s, ip=%s, vhost=%s, app=%s, stream=%s, duration=%s, cwd=%s, file=%s, seq_no=%s"%(
req["action"], req["client_id"], req["ip"], req["vhost"], req["app"], req["stream"], req["duration"],
trace("srs %s: client id=%s, ip=%s, vhost=%s, app=%s, stream=%s, param=%s, duration=%s, cwd=%s, file=%s, seq_no=%s"%(
req["action"], req["client_id"], req["ip"], req["vhost"], req["app"], req["stream"], req["param"], req["duration"],
req["cwd"], req["file"], req["seq_no"]
))

Expand Down Expand Up @@ -452,7 +454,7 @@ def GET(self):
"action": "on_play",
"client_id": 1985,
"ip": "192.168.1.10", "vhost": "video.test.com", "app": "live",
"stream": "livestream",
"stream": "livestream", "param":"?token=xxx&salt=yyy",
"pageUrl": "http://www.test.com/live.html"
}
on_stop:
Expand All @@ -462,7 +464,7 @@ def GET(self):
"action": "on_stop",
"client_id": 1985,
"ip": "192.168.1.10", "vhost": "video.test.com", "app": "live",
"stream": "livestream"
"stream": "livestream", "param":"?token=xxx&salt=yyy"
}
if valid, the hook must return HTTP code 200(Stauts OK) and response
an int value specifies the error code(0 corresponding to success):
Expand Down Expand Up @@ -500,8 +502,8 @@ def OPTIONS(self, *args, **kwargs):
def __on_play(self, req):
code = Error.success

trace("srs %s: client id=%s, ip=%s, vhost=%s, app=%s, stream=%s, pageUrl=%s"%(
req["action"], req["client_id"], req["ip"], req["vhost"], req["app"], req["stream"], req["pageUrl"]
trace("srs %s: client id=%s, ip=%s, vhost=%s, app=%s, stream=%s, param=%s, pageUrl=%s"%(
req["action"], req["client_id"], req["ip"], req["vhost"], req["app"], req["stream"], req["param"], req["pageUrl"]
))

# TODO: process the on_play event
Expand All @@ -511,8 +513,8 @@ def __on_play(self, req):
def __on_stop(self, req):
code = Error.success

trace("srs %s: client id=%s, ip=%s, vhost=%s, app=%s, stream=%s"%(
req["action"], req["client_id"], req["ip"], req["vhost"], req["app"], req["stream"]
trace("srs %s: client id=%s, ip=%s, vhost=%s, app=%s, stream=%s, param=%s"%(
req["action"], req["client_id"], req["ip"], req["vhost"], req["app"], req["stream"], req["param"]
))

# TODO: process the on_stop event
Expand Down

0 comments on commit 31945c2

Please sign in to comment.