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

View File

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