Remove cache relying on streamlit-webrtc's
Browse files
main.py
CHANGED
@@ -2,19 +2,29 @@ import streamlit as st
|
|
2 |
from streamlit_webrtc import webrtc_streamer, get_hf_ice_servers, get_twilio_ice_servers, __version__ as st_webrtc_version
|
3 |
import aiortc
|
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
frontend_ice_type = st.selectbox("Frontend ICE type", ["Empty", "Google STUN", "Twilio STUN/TURN", "Twilio STUN/TURN and Google STUN", "HF TURN only", "HF TURN and Google STUN", "None configured"])
|
6 |
backend_ice_type = st.selectbox("Backend ICE type", ["Empty", "Google STUN", "Twilio STUN/TURN", "Twilio STUN/TURN and Google STUN", "HF TURN only", "HF TURN and Google STUN", "None configured"])
|
7 |
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
twilio_token=st.secrets["TWILIO_AUTH_TOKEN"],
|
13 |
-
)
|
14 |
|
15 |
-
|
16 |
-
def cached_get_hf_ice_servers():
|
17 |
-
return get_hf_ice_servers(token=st.secrets["HF_TOKEN"])
|
18 |
|
19 |
# google_stun_ice_servers = [{"urls": ["stun:stun.l.google.com:19302"]}]
|
20 |
google_stun_ice_servers = [{"urls": "stun:stun.l.google.com:19302", "url": "stun:stun.l.google.com:19302"}]
|
@@ -29,19 +39,19 @@ elif frontend_ice_type == "Google STUN":
|
|
29 |
}
|
30 |
elif frontend_ice_type == "Twilio STUN/TURN":
|
31 |
frontend_rtc_configuration = {
|
32 |
-
"iceServers":
|
33 |
}
|
34 |
elif frontend_ice_type == "Twilio STUN/TURN and Google STUN":
|
35 |
frontend_rtc_configuration = {
|
36 |
-
"iceServers": google_stun_ice_servers +
|
37 |
}
|
38 |
elif frontend_ice_type == "HF TURN only":
|
39 |
frontend_rtc_configuration = {
|
40 |
-
"iceServers":
|
41 |
}
|
42 |
elif frontend_ice_type == "HF TURN and Google STUN":
|
43 |
frontend_rtc_configuration = {
|
44 |
-
"iceServers":
|
45 |
}
|
46 |
elif frontend_ice_type == "None configured":
|
47 |
frontend_rtc_configuration = None
|
@@ -56,19 +66,19 @@ elif backend_ice_type == "Google STUN":
|
|
56 |
}
|
57 |
elif backend_ice_type == "Twilio STUN/TURN":
|
58 |
backend_rtc_configuration = {
|
59 |
-
"iceServers":
|
60 |
}
|
61 |
elif backend_ice_type == "Twilio STUN/TURN and Google STUN":
|
62 |
backend_rtc_configuration = {
|
63 |
-
"iceServers": google_stun_ice_servers +
|
64 |
}
|
65 |
elif backend_ice_type == "HF TURN only":
|
66 |
backend_rtc_configuration = {
|
67 |
-
"iceServers":
|
68 |
}
|
69 |
elif backend_ice_type == "HF TURN and Google STUN":
|
70 |
backend_rtc_configuration = {
|
71 |
-
"iceServers":
|
72 |
}
|
73 |
elif backend_ice_type == "None configured":
|
74 |
backend_rtc_configuration = None
|
|
|
2 |
from streamlit_webrtc import webrtc_streamer, get_hf_ice_servers, get_twilio_ice_servers, __version__ as st_webrtc_version
|
3 |
import aiortc
|
4 |
|
5 |
+
import logging
|
6 |
+
logging.basicConfig(level=logging.INFO)
|
7 |
+
|
8 |
+
aioice_logger = logging.getLogger("aioice")
|
9 |
+
aioice_logger.setLevel(logging.DEBUG)
|
10 |
+
|
11 |
+
aiortc_logger = logging.getLogger("aiortc")
|
12 |
+
aiortc_logger.setLevel(logging.DEBUG)
|
13 |
+
aiortc_rtcrtpreceiver_logger = logging.getLogger("aiortc.rtcrtpreceiver")
|
14 |
+
aiortc_rtcrtpreceiver_logger.setLevel(logging.INFO)
|
15 |
+
aiortc_rtcrtpsender_logger = logging.getLogger("aiortc.rtcrtpsender")
|
16 |
+
aiortc_rtcrtpsender_logger.setLevel(logging.INFO)
|
17 |
+
|
18 |
+
|
19 |
frontend_ice_type = st.selectbox("Frontend ICE type", ["Empty", "Google STUN", "Twilio STUN/TURN", "Twilio STUN/TURN and Google STUN", "HF TURN only", "HF TURN and Google STUN", "None configured"])
|
20 |
backend_ice_type = st.selectbox("Backend ICE type", ["Empty", "Google STUN", "Twilio STUN/TURN", "Twilio STUN/TURN and Google STUN", "HF TURN only", "HF TURN and Google STUN", "None configured"])
|
21 |
|
22 |
+
TWILIO_ICE_SERVERS = get_twilio_ice_servers(
|
23 |
+
twilio_sid=st.secrets["TWILIO_ACCOUNT_SID"],
|
24 |
+
twilio_token=st.secrets["TWILIO_AUTH_TOKEN"],
|
25 |
+
)
|
|
|
|
|
26 |
|
27 |
+
HF_ICE_SERVERS = get_hf_ice_servers(token=st.secrets["HF_TOKEN"])
|
|
|
|
|
28 |
|
29 |
# google_stun_ice_servers = [{"urls": ["stun:stun.l.google.com:19302"]}]
|
30 |
google_stun_ice_servers = [{"urls": "stun:stun.l.google.com:19302", "url": "stun:stun.l.google.com:19302"}]
|
|
|
39 |
}
|
40 |
elif frontend_ice_type == "Twilio STUN/TURN":
|
41 |
frontend_rtc_configuration = {
|
42 |
+
"iceServers": TWILIO_ICE_SERVERS
|
43 |
}
|
44 |
elif frontend_ice_type == "Twilio STUN/TURN and Google STUN":
|
45 |
frontend_rtc_configuration = {
|
46 |
+
"iceServers": google_stun_ice_servers + TWILIO_ICE_SERVERS
|
47 |
}
|
48 |
elif frontend_ice_type == "HF TURN only":
|
49 |
frontend_rtc_configuration = {
|
50 |
+
"iceServers": HF_ICE_SERVERS
|
51 |
}
|
52 |
elif frontend_ice_type == "HF TURN and Google STUN":
|
53 |
frontend_rtc_configuration = {
|
54 |
+
"iceServers": HF_ICE_SERVERS + google_stun_ice_servers
|
55 |
}
|
56 |
elif frontend_ice_type == "None configured":
|
57 |
frontend_rtc_configuration = None
|
|
|
66 |
}
|
67 |
elif backend_ice_type == "Twilio STUN/TURN":
|
68 |
backend_rtc_configuration = {
|
69 |
+
"iceServers": TWILIO_ICE_SERVERS
|
70 |
}
|
71 |
elif backend_ice_type == "Twilio STUN/TURN and Google STUN":
|
72 |
backend_rtc_configuration = {
|
73 |
+
"iceServers": google_stun_ice_servers + TWILIO_ICE_SERVERS + google_stun_ice_servers
|
74 |
}
|
75 |
elif backend_ice_type == "HF TURN only":
|
76 |
backend_rtc_configuration = {
|
77 |
+
"iceServers": HF_ICE_SERVERS
|
78 |
}
|
79 |
elif backend_ice_type == "HF TURN and Google STUN":
|
80 |
backend_rtc_configuration = {
|
81 |
+
"iceServers": HF_ICE_SERVERS + google_stun_ice_servers
|
82 |
}
|
83 |
elif backend_ice_type == "None configured":
|
84 |
backend_rtc_configuration = None
|