winlin

add hls api to api-server

@@ -378,6 +378,11 @@ class RESTServers(object): @@ -378,6 +378,11 @@ class RESTServers(object):
378 url = "http://%s:8080/%s.html"%(self.__server_ip, stream) 378 url = "http://%s:8080/%s.html"%(self.__server_ip, stream)
379 elif action == "rtmp": 379 elif action == "rtmp":
380 url = "../../players/srs_player.html?server=%s&vhost=%s&app=%s&stream=%s&autostart=true"%(self.__server_ip, self.__server_ip, stream.split("/")[0], stream.split("/")[1]) 380 url = "../../players/srs_player.html?server=%s&vhost=%s&app=%s&stream=%s&autostart=true"%(self.__server_ip, self.__server_ip, stream.split("/")[0], stream.split("/")[1])
  381 + elif action == "hls":
  382 + hls_url = "http://%s:8080/%s"%(self.__server_ip, stream);
  383 + if stream.startswith("http://"):
  384 + hls_url = stream;
  385 + return self.__generate_hls(hls_url.replace(".m3u8.m3u8", ".m3u8"))
381 else: 386 else:
382 url = "http://%s:8080/api/v1/versions"%(self.__server_ip) 387 url = "http://%s:8080/api/v1/versions"%(self.__server_ip)
383 # others, default. 388 # others, default.
@@ -582,6 +587,7 @@ class V1(object): @@ -582,6 +587,7 @@ class V1(object):
582 }, 587 },
583 "GET id=ingest&action=play&stream=live/livestream": "play the ingest HLS stream on raspberry-pi", 588 "GET id=ingest&action=play&stream=live/livestream": "play the ingest HLS stream on raspberry-pi",
584 "GET id=ingest&action=rtmp&stream=live/livestream": "play the ingest RTMP stream on raspberry-pi", 589 "GET id=ingest&action=rtmp&stream=live/livestream": "play the ingest RTMP stream on raspberry-pi",
  590 + "GET id=ingest&action=hls&stream=live/livestream.m3u8": "play the ingest HLS stream on raspberry-pi",
585 "GET id=ingest&action=mgmt": "open the HTTP api url of raspberry-pi", 591 "GET id=ingest&action=mgmt": "open the HTTP api url of raspberry-pi",
586 "GET id=meeting": "redirect to local raspberry-pi meeting url(local ignored)", 592 "GET id=meeting": "redirect to local raspberry-pi meeting url(local ignored)",
587 "GET id=meeting&local=false&index=0": "play the first(index=0) meeting HLS stream on demo.chnvideo.com(not local)", 593 "GET id=meeting&local=false&index=0": "play the first(index=0) meeting HLS stream on demo.chnvideo.com(not local)",