File size: 735 Bytes
5a48885 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
import logging
import os
import requests
import streamlit as st
logger = logging.getLogger(__name__)
OPEN_RELAY_API_HOST = os.environ.get("OPEN_RELAY_API_HOST")
OPEN_RELAY_API_KEY = os.environ.get("OPEN_RELAY_API_KEY")
@st.cache_data
def get_ice_servers():
if not OPEN_RELAY_API_HOST or not OPEN_RELAY_API_KEY:
logger.warning(
"Open Relay API host or key is not set. Fallback to a free STUN server from Google." # noqa: E501
)
return [{"urls": ["stun:stun.l.google.com:19302"]}]
# Get response from Open Relay API
response = requests.get(
f"https://{OPEN_RELAY_API_HOST}/api/v1/turn/credentials?apiKey={OPEN_RELAY_API_KEY}" # noqa: E501
)
return response.json()
|