For #1110, Refine code.

pull/1109/head^2
winlin 7 years ago
parent 455a060fa5
commit 31945c244d

@ -176,7 +176,7 @@ class RESTStreams(object):
"action": "on_publish", "action": "on_publish",
"client_id": 1985, "client_id": 1985,
"ip": "192.168.1.10", "vhost": "video.test.com", "app": "live", "ip": "192.168.1.10", "vhost": "video.test.com", "app": "live",
"stream": "livestream" "stream": "livestream", "param":"?token=xxx&salt=yyy"
} }
on_unpublish: on_unpublish:
when client(encoder) stop publish to vhost/app/stream, call the hook, when client(encoder) stop publish to vhost/app/stream, call the hook,
@ -185,7 +185,7 @@ class RESTStreams(object):
"action": "on_unpublish", "action": "on_unpublish",
"client_id": 1985, "client_id": 1985,
"ip": "192.168.1.10", "vhost": "video.test.com", "app": "live", "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 if valid, the hook must return HTTP code 200(Stauts OK) and response
an int value specifies the error code(0 corresponding to success): an int value specifies the error code(0 corresponding to success):
@ -223,8 +223,8 @@ class RESTStreams(object):
def __on_publish(self, req): def __on_publish(self, req):
code = Error.success code = Error.success
trace("srs %s: client id=%s, ip=%s, vhost=%s, app=%s, stream=%s"%( 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["action"], req["client_id"], req["ip"], req["vhost"], req["app"], req["stream"], req["param"]
)) ))
# TODO: process the on_publish event # TODO: process the on_publish event
@ -234,8 +234,8 @@ class RESTStreams(object):
def __on_unpublish(self, req): def __on_unpublish(self, req):
code = Error.success code = Error.success
trace("srs %s: client id=%s, ip=%s, vhost=%s, app=%s, stream=%s"%( 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["action"], req["client_id"], req["ip"], req["vhost"], req["app"], req["stream"], req["param"]
)) ))
# TODO: process the on_unpublish event # TODO: process the on_unpublish event
@ -263,7 +263,7 @@ class RESTDvrs(object):
"action": "on_dvr", "action": "on_dvr",
"client_id": 1985, "client_id": 1985,
"ip": "192.168.1.10", "vhost": "video.test.com", "app": "live", "ip": "192.168.1.10", "vhost": "video.test.com", "app": "live",
"stream": "livestream", "stream": "livestream", "param":"?token=xxx&salt=yyy",
"cwd": "/usr/local/srs", "cwd": "/usr/local/srs",
"file": "./objs/nginx/html/live/livestream.1420254068776.flv" "file": "./objs/nginx/html/live/livestream.1420254068776.flv"
} }
@ -301,8 +301,8 @@ class RESTDvrs(object):
def __on_dvr(self, req): def __on_dvr(self, req):
code = Error.success code = Error.success
trace("srs %s: client id=%s, ip=%s, vhost=%s, app=%s, stream=%s, cwd=%s, file=%s"%( 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["action"], req["client_id"], req["ip"], req["vhost"], req["app"], req["stream"], req["param"],
req["cwd"], req["file"] req["cwd"], req["file"]
)) ))
@ -325,6 +325,7 @@ class RESTProxy(object):
so we use HTTP GET and use the variable following: so we use HTTP GET and use the variable following:
[app], replace with the app. [app], replace with the app.
[stream], replace with the stream. [stream], replace with the stream.
[param], replace with the param.
[ts_url], replace with the ts url. [ts_url], replace with the ts url.
ignore any return data of server. ignore any return data of server.
''' '''
@ -359,6 +360,7 @@ class RESTHls(object):
so we use HTTP GET and use the variable following: so we use HTTP GET and use the variable following:
[app], replace with the app. [app], replace with the app.
[stream], replace with the stream. [stream], replace with the stream.
[param], replace with the param.
[ts_url], replace with the ts url. [ts_url], replace with the ts url.
ignore any return data of server. ignore any return data of server.
''' '''
@ -382,7 +384,7 @@ class RESTHls(object):
"ip": "192.168.1.10", "ip": "192.168.1.10",
"vhost": "video.test.com", "vhost": "video.test.com",
"app": "live", "app": "live",
"stream": "livestream", "stream": "livestream", "param":"?token=xxx&salt=yyy",
"duration": 9.68, // in seconds "duration": 9.68, // in seconds
"cwd": "/usr/local/srs", "cwd": "/usr/local/srs",
"file": "./objs/nginx/html/live/livestream.1420254068776-100.ts", "file": "./objs/nginx/html/live/livestream.1420254068776-100.ts",
@ -422,8 +424,8 @@ class RESTHls(object):
def __on_hls(self, req): def __on_hls(self, req):
code = Error.success 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"%( 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["duration"], req["action"], req["client_id"], req["ip"], req["vhost"], req["app"], req["stream"], req["param"], req["duration"],
req["cwd"], req["file"], req["seq_no"] req["cwd"], req["file"], req["seq_no"]
)) ))
@ -452,7 +454,7 @@ class RESTSessions(object):
"action": "on_play", "action": "on_play",
"client_id": 1985, "client_id": 1985,
"ip": "192.168.1.10", "vhost": "video.test.com", "app": "live", "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" "pageUrl": "http://www.test.com/live.html"
} }
on_stop: on_stop:
@ -462,7 +464,7 @@ class RESTSessions(object):
"action": "on_stop", "action": "on_stop",
"client_id": 1985, "client_id": 1985,
"ip": "192.168.1.10", "vhost": "video.test.com", "app": "live", "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 if valid, the hook must return HTTP code 200(Stauts OK) and response
an int value specifies the error code(0 corresponding to success): an int value specifies the error code(0 corresponding to success):
@ -500,8 +502,8 @@ class RESTSessions(object):
def __on_play(self, req): def __on_play(self, req):
code = Error.success code = Error.success
trace("srs %s: client id=%s, ip=%s, vhost=%s, app=%s, stream=%s, pageUrl=%s"%( 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["pageUrl"] req["action"], req["client_id"], req["ip"], req["vhost"], req["app"], req["stream"], req["param"], req["pageUrl"]
)) ))
# TODO: process the on_play event # TODO: process the on_play event
@ -511,8 +513,8 @@ class RESTSessions(object):
def __on_stop(self, req): def __on_stop(self, req):
code = Error.success code = Error.success
trace("srs %s: client id=%s, ip=%s, vhost=%s, app=%s, stream=%s"%( 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["action"], req["client_id"], req["ip"], req["vhost"], req["app"], req["stream"], req["param"]
)) ))
# TODO: process the on_stop event # TODO: process the on_stop event

Loading…
Cancel
Save