1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

for #179, refine dvr, support callback when reap dvr segment.

This commit is contained in:
winlin 2015-02-22 10:45:13 +08:00
parent 849e59b05d
commit 1246989ea9
9 changed files with 281 additions and 50 deletions

View file

@ -253,7 +253,7 @@ class RESTDvrs(object):
return json.dumps(dvrs)
'''
for SRS hook: on_dvr
for SRS hook: on_dvr, on_dvr_reap_segment
on_dvr:
when srs reap a dvr file, call the hook,
the request in the POST data string is a object encode by json:
@ -265,6 +265,17 @@ class RESTDvrs(object):
"cwd": "/usr/local/srs",
"file": "./objs/nginx/html/live/livestream.1420254068776.flv"
}
on_dvr_reap_segment:
when api dvr specifes the callback when reap flv segment, call the hook,
the request in the POST data string is a object encode by json:
{
"action": "on_dvr_reap_segment",
"client_id": 1985,
"vhost": "video.test.com", "app": "live",
"stream": "livestream",
"cwd": "/usr/local/srs",
"file": "./objs/nginx/html/live/livestream.1420254068776.flv"
}
if valid, the hook must return HTTP code 200(Stauts OK) and response
an int value specifies the error code(0 corresponding to success):
0
@ -287,6 +298,8 @@ class RESTDvrs(object):
action = json_req["action"]
if action == "on_dvr":
code = self.__on_dvr(json_req)
if action == "on_dvr_reap_segment":
code = self.__on_dvr_reap_segment(json_req)
else:
trace("invalid request action: %s"%(json_req["action"]))
code = Error.request_invalid_action
@ -308,6 +321,18 @@ class RESTDvrs(object):
return code
def __on_dvr_reap_segment(self, req):
code = Error.success
trace("srs %s: client id=%s, vhost=%s, app=%s, stream=%s, cwd=%s, file=%s"%(
req["action"], req["client_id"], req["vhost"], req["app"], req["stream"],
req["cwd"], req["file"]
))
# TODO: process the on_dvr event
return code
'''
handle the sessions requests: client play/stop stream
'''