streamlit-webrtc 0.61.3__py3-none-any.whl → 0.62.1__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.
@@ -597,11 +597,8 @@ def webrtc_streamer(
597
597
  on_ended=on_audio_ended,
598
598
  )
599
599
 
600
- worker_created_in_this_run = None
601
600
  with context._worker_creation_lock: # This point can be reached in parallel so we need to use a lock to make the worker creation process atomic.
602
- should_create_worker_in_this_run = not context._get_worker() and sdp_offer
603
-
604
- if should_create_worker_in_this_run:
601
+ if not context._get_worker() and sdp_offer:
605
602
  LOGGER.debug(
606
603
  "No worker exists though the offer SDP is set. "
607
604
  'Create a new worker (key="%s").',
@@ -621,7 +618,7 @@ def webrtc_streamer(
621
618
  ice_servers = get_available_ice_servers() # NOTE: This may include a yield point where Streamlit's script runner interrupts the execution and may stop the current run.
622
619
  aiortc_rtc_configuration.iceServers = compile_ice_servers(ice_servers)
623
620
 
624
- worker_created_in_this_run = WebRtcWorker(
621
+ worker_created_in_this_run: WebRtcWorker = WebRtcWorker(
625
622
  mode=mode,
626
623
  rtc_configuration=aiortc_rtc_configuration,
627
624
  player_factory=player_factory,
@@ -644,19 +641,23 @@ def webrtc_streamer(
644
641
  sendback_audio=sendback_audio,
645
642
  )
646
643
 
644
+ worker_created_in_this_run.process_offer(
645
+ sdp_offer["sdp"],
646
+ sdp_offer["type"],
647
+ timeout=10, # The timeout of aioice's method that is used in the internal of this method is 5: https://github.com/aiortc/aioice/blob/aaada959aa8de31b880822db36f1c0c0cef75c0e/src/aioice/ice.py#L973. We set a bit longer timeout here.
648
+ )
649
+
647
650
  # Set the worker here within the lock.
648
651
  context._set_worker(worker_created_in_this_run)
649
652
 
653
+ # It's important to lock the entire block including creating the worker, waiting for process_offer(), and calling rerun().
654
+ # Otherwise, `rerun()` may fail because another script run completes during this run is pending to wait for these operations
655
+ # and it sets the `ScriptRequests._state` to `ScriptRequestType.STOP` which denies the rerun request.
656
+ LOGGER.debug("Rerun to send the SDP answer to frontend")
657
+ rerun()
658
+
650
659
  webrtc_worker = context._get_worker()
651
660
  if webrtc_worker and ice_candidates:
652
661
  webrtc_worker.set_ice_candidates_from_offerer(ice_candidates)
653
662
 
654
- if worker_created_in_this_run:
655
- worker_created_in_this_run.process_offer(
656
- sdp_offer["sdp"], sdp_offer["type"], timeout=None
657
- )
658
-
659
- # Rerun to send the SDP answer to frontend
660
- rerun()
661
-
662
663
  return context
@@ -92,6 +92,7 @@ def get_twilio_ice_servers(
92
92
  return token.ice_servers
93
93
 
94
94
 
95
+ @cache_data(ttl=min(HF_ICE_SERVER_TTL, TWILIO_CRED_TTL))
95
96
  def get_available_ice_servers() -> List[RTCIceServer]:
96
97
  try:
97
98
  LOGGER.info("Try to use TURN server from Hugging Face.")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: streamlit-webrtc
3
- Version: 0.61.3
3
+ Version: 0.62.1
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,9 +1,9 @@
1
1
  streamlit_webrtc/__init__.py,sha256=jMWwXoQ9hVyYXPD4Vrps7MyiR9goyC-n7LtkZNFBOxU,2273
2
2
  streamlit_webrtc/_compat.py,sha256=AVRcUGdgWDQcCE7-ufhGr6Hb5P6EHLgejUAA72ArJmg,4384
3
- streamlit_webrtc/component.py,sha256=Imoz2xuLRvgjy2Lxi9VVXgCMdvf-nUriTim2AjdFfC0,27155
3
+ streamlit_webrtc/component.py,sha256=wUxaxKPCMC1YteXnyvJ7WnZ7NjSRWQ7BLSqtp6WAs14,27691
4
4
  streamlit_webrtc/components_callbacks.py,sha256=tdrj2TlV8qcexFEdjm4PVkz8JwHffo4A8imoXOtjNHA,2401
5
5
  streamlit_webrtc/config.py,sha256=yKFIVjIoX2F62_G2qcDrNYm2Qe_qx1E9E0YqAnAibMo,5544
6
- streamlit_webrtc/credentials.py,sha256=3IOk7w1JLQ2Qs6XFP9dxsF81lpjLL2kdRe2ZIhHvaj4,4562
6
+ streamlit_webrtc/credentials.py,sha256=fTs-DhUhScK8m7OEfkgTMw7pKXnS9QNpjtJAvR9oIzs,4619
7
7
  streamlit_webrtc/eventloop.py,sha256=AFmxGlRRxVdl0cTS9pKpRZR2Mnq6v6DgudVZZ425IVw,1333
8
8
  streamlit_webrtc/factory.py,sha256=T35kCwNU8Vm4KL6KJ5HbNVtaouNw13Ilew49XSnm6X8,6820
9
9
  streamlit_webrtc/mix.py,sha256=Uh9gJviP3VLxwBQ-i3RftJ8GQ5qDPGqJKgm2M-vQYo4,8775
@@ -19,7 +19,7 @@ streamlit_webrtc/source.py,sha256=haPqMZ50Xh8tg7Z1yN8Frfk8v7D3oOuKteaD59asbzs,22
19
19
  streamlit_webrtc/webrtc.py,sha256=WzgydYm3Xhoi5c1QHNLc_GiF_E0aGC5ynzmxeAbtJCw,29900
20
20
  streamlit_webrtc/frontend/dist/index.html,sha256=ZY_Iflaf7wRUHHNpw7JMlSMraE3ewM9T_tZA94NIPRs,527
21
21
  streamlit_webrtc/frontend/dist/assets/index-Cz1nSw2-.js,sha256=j126AA3NGo8BLgQSjjMyQR6QwpDRq_jILP9woihrncI,589799
22
- streamlit_webrtc-0.61.3.dist-info/METADATA,sha256=nUJ6oMZtfpG5E0l5dQw_E0UfXX3XrQ1gTxkYEwalntA,18288
23
- streamlit_webrtc-0.61.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
24
- streamlit_webrtc-0.61.3.dist-info/licenses/LICENSE,sha256=pwccNHVA7r4rYofGlMU10aKEU90GLUlQr8uY80PR0NQ,1081
25
- streamlit_webrtc-0.61.3.dist-info/RECORD,,
22
+ streamlit_webrtc-0.62.1.dist-info/METADATA,sha256=nfgcOiaohmwGgMDGOQu7q7L9U6xngk-t1e7XPVQ7BOg,18288
23
+ streamlit_webrtc-0.62.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
24
+ streamlit_webrtc-0.62.1.dist-info/licenses/LICENSE,sha256=pwccNHVA7r4rYofGlMU10aKEU90GLUlQr8uY80PR0NQ,1081
25
+ streamlit_webrtc-0.62.1.dist-info/RECORD,,