streamlit-webrtc 0.53.11__py3-none-any.whl → 0.55.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/component.py +1 -1
- streamlit_webrtc/shutdown.py +6 -1
- streamlit_webrtc/webrtc.py +15 -9
- {streamlit_webrtc-0.53.11.dist-info → streamlit_webrtc-0.55.0.dist-info}/METADATA +1 -1
- {streamlit_webrtc-0.53.11.dist-info → streamlit_webrtc-0.55.0.dist-info}/RECORD +7 -7
- {streamlit_webrtc-0.53.11.dist-info → streamlit_webrtc-0.55.0.dist-info}/WHEEL +0 -0
- {streamlit_webrtc-0.53.11.dist-info → streamlit_webrtc-0.55.0.dist-info}/licenses/LICENSE +0 -0
streamlit_webrtc/component.py
CHANGED
@@ -637,7 +637,7 @@ def webrtc_streamer(
|
|
637
637
|
sendback_video=sendback_video,
|
638
638
|
sendback_audio=sendback_audio,
|
639
639
|
)
|
640
|
-
webrtc_worker.process_offer(sdp_offer["sdp"], sdp_offer["type"])
|
640
|
+
webrtc_worker.process_offer(sdp_offer["sdp"], sdp_offer["type"], timeout=None)
|
641
641
|
context._set_worker(webrtc_worker)
|
642
642
|
# Rerun to send the SDP answer to frontend
|
643
643
|
rerun()
|
streamlit_webrtc/shutdown.py
CHANGED
@@ -40,7 +40,7 @@ class SessionShutdownObserver:
|
|
40
40
|
):
|
41
41
|
# Use polling because event-based methods are not available
|
42
42
|
# to observe the session lifecycle.
|
43
|
-
while
|
43
|
+
while True:
|
44
44
|
app_session = app_session_ref()
|
45
45
|
if not app_session:
|
46
46
|
logger.debug("AppSession has removed.")
|
@@ -51,6 +51,11 @@ class SessionShutdownObserver:
|
|
51
51
|
app_session.id,
|
52
52
|
)
|
53
53
|
break
|
54
|
+
if self._polling_thread_stop_event.wait(1.0):
|
55
|
+
logger.debug(
|
56
|
+
"The polling thread should be stopped. Exit the polling loop and return."
|
57
|
+
)
|
58
|
+
return
|
54
59
|
|
55
60
|
# Ensure the flag is set
|
56
61
|
self._polling_thread_stop_event.set()
|
streamlit_webrtc/webrtc.py
CHANGED
@@ -4,7 +4,7 @@ import itertools
|
|
4
4
|
import logging
|
5
5
|
import queue
|
6
6
|
import threading
|
7
|
-
from typing import Callable, Generic, Literal, Optional, Union, cast
|
7
|
+
from typing import TYPE_CHECKING, Callable, Generic, Literal, Optional, Union, cast
|
8
8
|
|
9
9
|
from aiortc import RTCConfiguration, RTCPeerConnection, RTCSessionDescription
|
10
10
|
from aiortc.contrib.media import MediaPlayer, MediaRecorder, MediaRelay
|
@@ -39,6 +39,9 @@ from .process import (
|
|
39
39
|
from .receive import AudioReceiver, VideoReceiver
|
40
40
|
from .relay import get_global_relay
|
41
41
|
|
42
|
+
if TYPE_CHECKING:
|
43
|
+
import concurrent.futures
|
44
|
+
|
42
45
|
__all__ = [
|
43
46
|
"AudioProcessorBase",
|
44
47
|
"AudioProcessorFactory",
|
@@ -48,7 +51,7 @@ __all__ = [
|
|
48
51
|
"MediaRecorderFactory",
|
49
52
|
"VideoProcessorFactory",
|
50
53
|
"WebRtcMode",
|
51
|
-
"
|
54
|
+
"SignallingTimeoutError",
|
52
55
|
"WebRtcWorker",
|
53
56
|
]
|
54
57
|
|
@@ -63,7 +66,7 @@ class WebRtcMode(enum.Enum):
|
|
63
66
|
SENDRECV = enum.auto()
|
64
67
|
|
65
68
|
|
66
|
-
class
|
69
|
+
class SignallingTimeoutError(Exception):
|
67
70
|
pass
|
68
71
|
|
69
72
|
|
@@ -522,7 +525,7 @@ class WebRtcWorker(Generic[VideoProcessorT, AudioProcessorT]):
|
|
522
525
|
if self.pc.iceConnectionState == "failed":
|
523
526
|
await self.pc.close()
|
524
527
|
|
525
|
-
process_offer_task =
|
528
|
+
process_offer_task = asyncio.run_coroutine_threadsafe(
|
526
529
|
_process_offer_coro(
|
527
530
|
self.mode,
|
528
531
|
self.pc,
|
@@ -540,10 +543,11 @@ class WebRtcWorker(Generic[VideoProcessorT, AudioProcessorT]):
|
|
540
543
|
sendback_video=self.sendback_video,
|
541
544
|
sendback_audio=self.sendback_audio,
|
542
545
|
on_track_created=on_track_created,
|
543
|
-
)
|
546
|
+
),
|
547
|
+
loop=loop,
|
544
548
|
)
|
545
549
|
|
546
|
-
def callback(done_task:
|
550
|
+
def callback(done_task: "concurrent.futures.Future"):
|
547
551
|
e = done_task.exception()
|
548
552
|
if e:
|
549
553
|
logger.debug("Error occurred in process_offer")
|
@@ -557,7 +561,7 @@ class WebRtcWorker(Generic[VideoProcessorT, AudioProcessorT]):
|
|
557
561
|
process_offer_task.add_done_callback(callback)
|
558
562
|
|
559
563
|
def process_offer(
|
560
|
-
self, sdp, type_, timeout: Union[float, None] =
|
564
|
+
self, sdp, type_, timeout: Union[float, None] = None
|
561
565
|
) -> RTCSessionDescription:
|
562
566
|
self._process_offer_thread = threading.Thread(
|
563
567
|
target=self._run_process_offer_thread,
|
@@ -574,7 +578,7 @@ class WebRtcWorker(Generic[VideoProcessorT, AudioProcessorT]):
|
|
574
578
|
result = self._answer_queue.get(block=True, timeout=timeout)
|
575
579
|
except queue.Empty:
|
576
580
|
self.stop(timeout=1)
|
577
|
-
raise
|
581
|
+
raise SignallingTimeoutError(
|
578
582
|
"Processing offer and initializing the worker "
|
579
583
|
f"has not finished in {timeout} seconds"
|
580
584
|
)
|
@@ -672,6 +676,8 @@ class WebRtcWorker(Generic[VideoProcessorT, AudioProcessorT]):
|
|
672
676
|
self._relayed_source_video_track = None
|
673
677
|
|
674
678
|
def stop(self, timeout: Union[float, None] = 1.0):
|
679
|
+
logger.debug("Stopping the WebRTC worker")
|
680
|
+
|
675
681
|
self._unset_processors()
|
676
682
|
if self._process_offer_thread:
|
677
683
|
self._process_offer_thread.join(timeout=timeout)
|
@@ -680,7 +686,7 @@ class WebRtcWorker(Generic[VideoProcessorT, AudioProcessorT]):
|
|
680
686
|
if self.pc and self.pc.connectionState != "closed":
|
681
687
|
loop = get_global_event_loop()
|
682
688
|
if loop.is_running():
|
683
|
-
|
689
|
+
asyncio.run_coroutine_threadsafe(self.pc.close(), loop=loop)
|
684
690
|
else:
|
685
691
|
loop.run_until_complete(self.pc.close())
|
686
692
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: streamlit-webrtc
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.55.0
|
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=jMWwXoQ9hVyYXPD4Vrps7MyiR9goyC-n7LtkZNFBOxU,2273
|
2
2
|
streamlit_webrtc/_compat.py,sha256=YQdkF6Qsl_1WO_HIS4tydx2L0jNB3H0C7YnvWDS9mmA,4188
|
3
|
-
streamlit_webrtc/component.py,sha256=
|
3
|
+
streamlit_webrtc/component.py,sha256=3E0YM4GcSLmWkv21xN6334GfuMXxLDk9BWhd_20rohI,26122
|
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=XUSAsKfx50VZstknG99dFq_iBYGbutsvHiGIetyvWKM,3725
|
@@ -14,12 +14,12 @@ streamlit_webrtc/receive.py,sha256=gzv1uZDTAlxJ0hyJ5LweTr0lVuoisrH5xRevGnYkWwo,2
|
|
14
14
|
streamlit_webrtc/relay.py,sha256=2K2h0uNz50ARUOScYZPYlEmZb0uAi0agaYxI9z3mLeI,896
|
15
15
|
streamlit_webrtc/server.py,sha256=5o9E2MRIPoS18lfGPJkyhbd23RWyTwblNVVuAA2kKrA,1489
|
16
16
|
streamlit_webrtc/session_info.py,sha256=V1EdzD2I8dWANXdC84EKSz8XgPM-zugtkYsb4hJm8Qo,2313
|
17
|
-
streamlit_webrtc/shutdown.py,sha256=
|
17
|
+
streamlit_webrtc/shutdown.py,sha256=PUjMoNZcTRGzZCooCmjWARpeVs5EG_9JXAf1Iay7dBM,2353
|
18
18
|
streamlit_webrtc/source.py,sha256=haPqMZ50Xh8tg7Z1yN8Frfk8v7D3oOuKteaD59asbzs,2263
|
19
|
-
streamlit_webrtc/webrtc.py,sha256=
|
19
|
+
streamlit_webrtc/webrtc.py,sha256=Ae72K8OfPHVnjf1M0SkUfsoFj63V-T7BXSe1ME9yadk,27539
|
20
20
|
streamlit_webrtc/frontend/dist/index.html,sha256=mae7QlSxz7tCcSszMZG21Q0qXjbQzPun68zD3bjjO0U,527
|
21
21
|
streamlit_webrtc/frontend/dist/assets/index-DMhSSwr2.js,sha256=01mdY7O01shSnWVGKCBSfhgZYSulgZ2uhkWotKlqHIA,582849
|
22
|
-
streamlit_webrtc-0.
|
23
|
-
streamlit_webrtc-0.
|
24
|
-
streamlit_webrtc-0.
|
25
|
-
streamlit_webrtc-0.
|
22
|
+
streamlit_webrtc-0.55.0.dist-info/METADATA,sha256=QxQLjCD3oVHPoIFt276KKJF-dBfzh7m4t3eIAxK7M8w,18641
|
23
|
+
streamlit_webrtc-0.55.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
24
|
+
streamlit_webrtc-0.55.0.dist-info/licenses/LICENSE,sha256=pwccNHVA7r4rYofGlMU10aKEU90GLUlQr8uY80PR0NQ,1081
|
25
|
+
streamlit_webrtc-0.55.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|