diff --git a/README.md b/README.md index 2782cb0..ecc1acd 100644 --- a/README.md +++ b/README.md @@ -12,13 +12,18 @@ Streaming is supported with a local rtmp instance on nginx, producing HLS, which # Configuration overview -## controller.py -- Change the password in the psql connect string -- `BBB_URL` = Your BBB server or loadbalancer endpoint -- `BBB_SECRET` = Your BBB secret -- `BBB_RTMP_PATH` = `'rtmp://192.168.178.23:1935/live/'`; The IP and port on which nginx listens for rtmp connections; Firewall from the internet -- `BBB_WEB_STREAM` = `'https://bbb.example.com/streams/'`; The base-URL of your streams. Individual streams will look like `https://bbb.example.com/streams/xyz-123-zyx-412/`, depending on the room's path. -- `BBB_RES` = Resolution for the stream, e.g., `'1920x1080'`; The higher the resolution, the higher the load on the machine. +## config.json +- `daemon` = True/False - If using crontab model of execution or systemd +- `bbb_url` = Your BBB server or loadbalancer endpoint +- `bbb_secret` = Your BBB secret +- `rtmp_path` = `'rtmp://192.168.178.23:1935/live/'`; The IP and port on which nginx listens for rtmp connections; Firewall from the internet +- `web_stream` = `'https://bbb.example.com/streams/'`; The base-URL of your streams. Individual streams will look like `https://bbb.example.com/streams/xyz-123-zyx-412/`, depending on the room's path. +- `bbb_res` = Resolution for the stream, e.g., `'1920x1080'`; The higher the resolution, the higher the load on the machine. +- `postgresql` = configure postgresql + - `user` = postgresql username + - `password` = postgresql password + - `host` = postgresql host (defaults to password) + - `port` = postgresql port (defaults to 5433) ## index.html - Set URL in `src` variable according to your infrastructure (could be done better, i know) diff --git a/config.json.example b/config.json.example new file mode 100644 index 0000000..8dfd966 --- /dev/null +++ b/config.json.example @@ -0,0 +1,15 @@ +{ + "daemon": true, + "postgresql": { + "db": "greenlight_production", + "user": "postgres", + "password": "PASSWORD", + "host": "localhost", + "port": "5433" + }, + "bbb_url": "https://bbb.example.com/bigbluebutton/", + "bbb_secret": "BBB_SECRET", + "rtmp_path": "rtmp://192.168.178.23:1935/live/", + "web_stream": "https://bbb.example.com/streams/", + "bbb_res": "1920x1080" +} diff --git a/controller.py b/controller.py index 0711a1e..1e44548 100755 --- a/controller.py +++ b/controller.py @@ -131,14 +131,46 @@ from xml.etree import ElementTree import psycopg2 -conn_auth = psycopg2.connect("dbname=greenlight_production user=postgres password=PASSWORD host=localhost") -DAEMON=False -BBB_URL = "https://bbb.example.com/bigbluebutton/" -BBB_SECRET = "BBB_SECRET" -BBB_RTMP_PATH = 'rtmp://192.168.178.23:1935/live/' -BBB_WEB_STREAM = 'https://bbb.example.com/streams/' -BBB_RES = '1920x1080' +with open("config.json") as json_config_file: + config = json.load(json_config_file) + +POSTGRESHOST = "localhost" +POSTGRESPORT = 5433 +if "postgresql" in config: + if "db" in config["postgresql"] and "user" in config["postgresql"] and "password" in config["postgresql"]: + POSTGRESDB = config["postgresql"]["db"] + POSTGRESUSER = config["postgresql"]["user"] + POSTGRESPASS = config["postgresql"]["password"] + else: + print('Missing postgresql config') + sys.exit(1) + if "port" in config["postgresql"]: + POSTGRESPORT = config["postgresql"]["port"] + if "host" in config["postgresql"]: + POSTGRESHOST = config["postgresql"]["host"] + +conn_auth = psycopg2.connect("dbname=" + POSTGRESDB + " user=" + POSTGRESUSER + " password=" + POSTGRESPASS + " host=" + POSTGRESHOST + " port=" + POSTGRESPORT) + +DAEMON = False +BBB_URL = "" +BBB_SECRET = "" +BBB_RTMP_PATH = "" +BBB_WEB_STREAM = "" +BBB_RES = "1920x1080" + +if "daemon" in config: + DAEMON = config["daemon"] +if "bbb_url" in config: + BBB_URL = config["bbb_url"] +if "bbb_secret" in config: + BBB_SECRET = config["bbb_secret"] +if "rtmp_path" in config: + BBB_RTMP_PATH = config["rtmp_path"] +if "web_stream" in config: + BBB_WEB_STREAM = config["web_stream"] +if "bbb_res" in config: + BBB_RES = config['bbb_res'] client = docker.from_env()