Compare commits

..

No commits in common. "feature/9128_change_radio_endpoints" and "main" have entirely different histories.

2 changed files with 24 additions and 38 deletions

View File

@ -1,6 +1,5 @@
#! /usr/bin/env python3
import routes
import os
import sys
import requests
@ -19,7 +18,7 @@ swag = Swagger(app)
radios = {}
@app.route(routes.endpoint_routes["b"])
@app.route("/report")
def report():
"""Get streams report from the RTSP relay.
---
@ -41,7 +40,7 @@ def report():
return _error_message_json(e.message), 500
@app.route(routes.endpoint_routes["a"])
@app.route("/radio/report")
def radio_report():
"""List radio devices available to the system.
---
@ -54,6 +53,7 @@ def radio_report():
return jsonify(devices)
@app.route("/radio/<radio>/connect")
def connect(radio):
"""Connect to a radio device, by driver name or serial number.
---
@ -87,7 +87,7 @@ def connect(radio):
return "Radio device not found", 400
@app.route(routes.endpoint_routes["f"])
@app.route("/radio/<radio>/disconnect")
def disconnect(radio):
"""Disconnect from a radio device.
---
@ -112,9 +112,8 @@ def disconnect(radio):
return _error_message_json("Radio not connected"), 400
# TODO: add post parameters...
@app.route(routes.endpoint_routes["c"])
def configure():
@app.route("/radio/<radio>/configure/<frequency>")
def configure(radio, frequency):
"""Tune the radio to a frequency.
You must connect to the radio before attempting to configure it.
The radio must be configured before streaming can be started.
@ -142,7 +141,7 @@ def configure():
return _error_message_json("Radio not connected"), 400
@app.route(routes.endpoint_routes["d"])
@app.route("/radio/<radio>/start")
def start_stream(radio):
"""Start the radio stream.
Once the stream has been started, connect to the stream at:
@ -160,17 +159,14 @@ def start_stream(radio):
400:
description: JSON with error message.
"""
if id is not None:
_start_tuuube_stream(id)
else:
try:
radios[radio].start_stream()
return jsonify("message", "successfully started radio stream"), 200
except Exception as e:
return _error_message_json(e.message), 400
try:
radios[radio].start_stream()
return jsonify("message", "successfully started radio stream"), 200
except Exception as e:
return _error_message_json(e.message), 400
@app.route(routes.endpoint_routes["e"])
@app.route("/radio/<radio>/end")
def end_stream(radio):
"""Terminate the radio stream.
---
@ -186,17 +182,15 @@ def end_stream(radio):
400:
description: JSON with error message.
"""
if id is not None:
_end_tuuube_stream(id)
else:
try:
radios[radio].end_stream()
return jsonify("message", "successfully ended radio stream"), 200
except Exception as e:
return _error_message_json(e.message), 400
try:
radios[radio].end_stream()
return jsonify("message", "successfully ended radio stream"), 200
except Exception as e:
error_message = {"error_message": e.message}
return _error_message_json(e.message), 400
@app.route(routes.endpoint_routes["g"])
@app.route("/radio/<radio>/info")
def radio_info(radio):
"""Get information about a radio.
---
@ -221,7 +215,8 @@ def radio_info(radio):
tubes = {}
def _start_tuuube_stream(id):
@app.route("/tuuube/<id>/start")
def start_tuuube_stream(id):
"""Start streaming from a youtube source.
Once the stream has been started, connect to the stream at:
rtsp://[host]:8554/tuuube/[id]
@ -254,7 +249,8 @@ def _start_tuuube_stream(id):
return _error_message_json(e.message), 400
def _end_tuuube_stream(id):
@app.route("/tuuube/<id>/end")
def end_tuuube_stream(id):
"""Terminate the youtube stream.
---
parameters:

View File

@ -1,10 +0,0 @@
endpoint_routes = {
"a": "",
"b": "",
"c": "",
"d": "",
"e": "",
"f":"",
"g":""
}