streamlit-webrtc 0.56.0__py3-none-any.whl → 0.60.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- streamlit_webrtc/_compat.py +7 -0
- streamlit_webrtc/credentials.py +10 -1
- streamlit_webrtc/frontend/dist/assets/{index-DQOpN3ny.js → index-DV2u3ooX.js} +36 -36
- streamlit_webrtc/frontend/dist/index.html +1 -1
- streamlit_webrtc/webrtc.py +19 -4
- {streamlit_webrtc-0.56.0.dist-info → streamlit_webrtc-0.60.0.dist-info}/METADATA +3 -2
- {streamlit_webrtc-0.56.0.dist-info → streamlit_webrtc-0.60.0.dist-info}/RECORD +9 -9
- {streamlit_webrtc-0.56.0.dist-info → streamlit_webrtc-0.60.0.dist-info}/WHEEL +0 -0
- {streamlit_webrtc-0.56.0.dist-info → streamlit_webrtc-0.60.0.dist-info}/licenses/LICENSE +0 -0
streamlit_webrtc/_compat.py
CHANGED
@@ -103,6 +103,12 @@ except ImportError:
|
|
103
103
|
# streamlit < 1.27.0
|
104
104
|
from streamlit import experimental_rerun as rerun # type: ignore
|
105
105
|
|
106
|
+
try:
|
107
|
+
from streamlit import cache_data # type: ignore
|
108
|
+
except ImportError:
|
109
|
+
# streamlit < 1.18.0
|
110
|
+
from streamlit import experimental_memo as cache_data # type: ignore
|
111
|
+
|
106
112
|
|
107
113
|
__all__ = [
|
108
114
|
"VER_GTE_1_12_0",
|
@@ -114,4 +120,5 @@ __all__ = [
|
|
114
120
|
"SessionInfo",
|
115
121
|
"get_script_run_ctx",
|
116
122
|
"rerun",
|
123
|
+
"cache_data",
|
117
124
|
]
|
streamlit_webrtc/credentials.py
CHANGED
@@ -30,11 +30,16 @@ import urllib.error
|
|
30
30
|
import urllib.request
|
31
31
|
from typing import List, Optional
|
32
32
|
|
33
|
+
from ._compat import cache_data
|
33
34
|
from .config import RTCIceServer
|
34
35
|
|
35
36
|
LOGGER = logging.getLogger(__name__)
|
36
37
|
|
37
38
|
|
39
|
+
HF_ICE_SERVER_TTL = 3600 # 1 hour. Not sure if this is the best value.
|
40
|
+
|
41
|
+
|
42
|
+
@cache_data(ttl=HF_ICE_SERVER_TTL)
|
38
43
|
def get_hf_ice_servers(token: Optional[str] = None) -> List[RTCIceServer]:
|
39
44
|
if token is None:
|
40
45
|
token = os.getenv("HF_TOKEN")
|
@@ -61,6 +66,10 @@ def get_hf_ice_servers(token: Optional[str] = None) -> List[RTCIceServer]:
|
|
61
66
|
raise ValueError("Failed to get credentials from HF turn server")
|
62
67
|
|
63
68
|
|
69
|
+
TWILIO_CRED_TTL = 3600 # 1 hour. Twilio's default is 1 day. Shorter TTL should be ok for this library's use case.
|
70
|
+
|
71
|
+
|
72
|
+
@cache_data(ttl=TWILIO_CRED_TTL)
|
64
73
|
def get_twilio_ice_servers(
|
65
74
|
twilio_sid: Optional[str] = None, twilio_token: Optional[str] = None
|
66
75
|
) -> List[RTCIceServer]:
|
@@ -78,7 +87,7 @@ def get_twilio_ice_servers(
|
|
78
87
|
|
79
88
|
client = Client(twilio_sid, twilio_token)
|
80
89
|
|
81
|
-
token = client.tokens.create()
|
90
|
+
token = client.tokens.create(ttl=TWILIO_CRED_TTL)
|
82
91
|
|
83
92
|
return token.ice_servers
|
84
93
|
|