streamlit-webrtc 0.63.2__py3-none-any.whl → 0.63.3__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.
@@ -30,7 +30,7 @@ from streamlit_webrtc.models import (
30
30
  VideoFrameCallback,
31
31
  )
32
32
 
33
- from ._compat import VER_GTE_1_36_0, rerun
33
+ from ._compat import VER_GTE_1_36_0, cache_data, rerun
34
34
  from .components_callbacks import register_callback
35
35
  from .config import (
36
36
  DEFAULT_AUDIO_HTML_ATTRS,
@@ -94,7 +94,6 @@ class WebRtcStreamerContext(Generic[VideoProcessorT, AudioProcessorT]):
94
94
 
95
95
  _component_value_snapshot: Union[ComponentValueSnapshot, None]
96
96
  _worker_creation_lock: threading.Lock
97
- _frontend_rtc_configuration: Optional[Union[Dict[str, Any], RTCConfiguration]]
98
97
  _sdp_answer_json: Optional[str]
99
98
  _is_sdp_answer_sent: bool
100
99
 
@@ -107,7 +106,6 @@ class WebRtcStreamerContext(Generic[VideoProcessorT, AudioProcessorT]):
107
106
  self._set_state(state)
108
107
  self._component_value_snapshot = None
109
108
  self._worker_creation_lock = threading.Lock()
110
- self._frontend_rtc_configuration = None
111
109
  self._sdp_answer_json = None
112
110
  self._is_sdp_answer_sent = False
113
111
 
@@ -222,6 +220,25 @@ def compile_state(component_value) -> WebRtcStreamerState:
222
220
  return WebRtcStreamerState(playing=playing, signalling=signalling)
223
221
 
224
222
 
223
+ @cache_data
224
+ def enhance_frontend_rtc_configuration(
225
+ user_frontend_rtc_configuration: Optional[
226
+ Union[Dict[str, Any], RTCConfiguration]
227
+ ] = None,
228
+ ) -> Union[Dict[str, Any], RTCConfiguration]:
229
+ config = (
230
+ copy.deepcopy(user_frontend_rtc_configuration)
231
+ if user_frontend_rtc_configuration
232
+ else {}
233
+ )
234
+ if config.get("iceServers") is None:
235
+ LOGGER.info(
236
+ "frontend_rtc_configuration.iceServers is not set. Try to set it automatically."
237
+ )
238
+ config["iceServers"] = get_available_ice_servers()
239
+ return config
240
+
241
+
225
242
  @overload
226
243
  def webrtc_streamer(
227
244
  key: str,
@@ -475,16 +492,6 @@ def webrtc_streamer(
475
492
  )
476
493
  st.session_state[key] = context
477
494
 
478
- if context._frontend_rtc_configuration is None:
479
- context._frontend_rtc_configuration = copy.deepcopy(frontend_rtc_configuration)
480
- if context._frontend_rtc_configuration is None:
481
- context._frontend_rtc_configuration = {}
482
- if context._frontend_rtc_configuration.get("iceServers") is None:
483
- LOGGER.info(
484
- "frontend_rtc_configuration.iceServers is not set. Try to set it automatically."
485
- )
486
- context._frontend_rtc_configuration["iceServers"] = get_available_ice_servers()
487
-
488
495
  if context._sdp_answer_json:
489
496
  # Set the flag not to trigger rerun() any more as `context._sdp_answer_json` is already set and will have been sent to the frontend in this run.
490
497
  context._is_sdp_answer_sent = True
@@ -514,7 +521,9 @@ def webrtc_streamer(
514
521
  key=frontend_key,
515
522
  sdp_answer_json=context._sdp_answer_json,
516
523
  mode=mode.name,
517
- rtc_configuration=context._frontend_rtc_configuration,
524
+ rtc_configuration=enhance_frontend_rtc_configuration(
525
+ frontend_rtc_configuration
526
+ ),
518
527
  media_stream_constraints=media_stream_constraints,
519
528
  video_html_attrs=video_html_attrs,
520
529
  audio_html_attrs=audio_html_attrs,
@@ -569,8 +578,6 @@ def webrtc_streamer(
569
578
  key,
570
579
  )
571
580
 
572
- context._frontend_rtc_configuration = None
573
-
574
581
  webrtc_worker_to_stop = context._get_worker()
575
582
  if webrtc_worker_to_stop:
576
583
  LOGGER.debug("Stop the worker (key=%s).", key)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: streamlit-webrtc
3
- Version: 0.63.2
3
+ Version: 0.63.3
4
4
  Summary: Real-time video and audio processing on Streamlit
5
5
  Project-URL: Repository, https://github.com/whitphx/streamlit-webrtc
6
6
  Author-email: "Yuichiro Tachibana (Tsuchiya)" <t.yic.yt@gmail.com>
@@ -1,6 +1,6 @@
1
1
  streamlit_webrtc/__init__.py,sha256=dzw8DtZ0D_FAXPeS7qT7QaKPTcxp9XAekpmcthwjF3I,2465
2
2
  streamlit_webrtc/_compat.py,sha256=AVRcUGdgWDQcCE7-ufhGr6Hb5P6EHLgejUAA72ArJmg,4384
3
- streamlit_webrtc/component.py,sha256=pixNqGXrTlogxXjXx6fSgMx2xPo0dj2fsXKenvWeqQk,28269
3
+ streamlit_webrtc/component.py,sha256=3EJiVNZijQ3GhiH6AwVtp9lb-ndKM7PUZZm02uy97c4,28209
4
4
  streamlit_webrtc/components_callbacks.py,sha256=tdrj2TlV8qcexFEdjm4PVkz8JwHffo4A8imoXOtjNHA,2401
5
5
  streamlit_webrtc/config.py,sha256=yKFIVjIoX2F62_G2qcDrNYm2Qe_qx1E9E0YqAnAibMo,5544
6
6
  streamlit_webrtc/credentials.py,sha256=fTs-DhUhScK8m7OEfkgTMw7pKXnS9QNpjtJAvR9oIzs,4619
@@ -19,7 +19,7 @@ streamlit_webrtc/source.py,sha256=-bcvQYMyXcrhnsQNL3VlHwLT4KGjJ4jIZcPLKrbczZM,42
19
19
  streamlit_webrtc/webrtc.py,sha256=WzgydYm3Xhoi5c1QHNLc_GiF_E0aGC5ynzmxeAbtJCw,29900
20
20
  streamlit_webrtc/frontend/dist/index.html,sha256=68D6PDNx0C4SAHnTcjTbJXf7rUFKm8SFhU9gu5xsRyA,527
21
21
  streamlit_webrtc/frontend/dist/assets/index-4jnSNRmM.js,sha256=JaUM7ss0KLDvThxYulCxA16l5OMlXOHjD84yi2B5hY8,586448
22
- streamlit_webrtc-0.63.2.dist-info/METADATA,sha256=VOPRi6SSYbFXAGfhIC3_4O9PnCvAu_vimOOajSu3aP8,18288
23
- streamlit_webrtc-0.63.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
24
- streamlit_webrtc-0.63.2.dist-info/licenses/LICENSE,sha256=pwccNHVA7r4rYofGlMU10aKEU90GLUlQr8uY80PR0NQ,1081
25
- streamlit_webrtc-0.63.2.dist-info/RECORD,,
22
+ streamlit_webrtc-0.63.3.dist-info/METADATA,sha256=6IqXuEeC2Y3cRbqLTdr0O1C02YL382St7MjDh2f-ZcA,18288
23
+ streamlit_webrtc-0.63.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
24
+ streamlit_webrtc-0.63.3.dist-info/licenses/LICENSE,sha256=pwccNHVA7r4rYofGlMU10aKEU90GLUlQr8uY80PR0NQ,1081
25
+ streamlit_webrtc-0.63.3.dist-info/RECORD,,