From dd216e54d3eff6925cb2e18e5e96df22d4672ebd Mon Sep 17 00:00:00 2001 From: Jono Targett Date: Tue, 13 Jun 2023 18:52:51 +0930 Subject: [PATCH] Added RTSP streams report to API --- mediamtx.yml | 4 ++-- microservice.py | 23 ++++++++++++++++++++++- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/mediamtx.yml b/mediamtx.yml index 9965edc..8b8f226 100644 --- a/mediamtx.yml +++ b/mediamtx.yml @@ -38,10 +38,10 @@ udpMaxPayloadSize: 1472 externalAuthenticationURL: # Enable the HTTP API. -api: no +api: yes # Enable Prometheus-compatible metrics. -metrics: no +metrics: yes # Enable pprof-compatible endpoint to monitor performances. pprof: no diff --git a/microservice.py b/microservice.py index 9387f68..776bd47 100755 --- a/microservice.py +++ b/microservice.py @@ -1,5 +1,6 @@ #! /usr/bin/env python3 +import requests import SoapySDR as soapy from radio import Radio from tuuube import Tuuube @@ -13,9 +14,29 @@ swag = Swagger(app) radios = {} +@app.route('/report') +def report(): + """Get streams report from the RTSP relay. + --- + responses: + 200: + description: JSON + """ + try: + r = requests.get("http://localhost:9997/v1/paths/list") + j = r.json() + for item in j['items']: + del j['items'][item]['conf'] + del j['items'][item]['confName'] + + + return jsonify(j) + except: + return "Shat the bed", 500 + @app.route('/radio/report') -def report(): +def radio_report(): """List radio devices available to the system. --- responses: