streamlit-webrtc 0.55.0__py3-none-any.whl → 0.56.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 +22 -17
- streamlit_webrtc/credentials.py +10 -3
- streamlit_webrtc/frontend/dist/assets/{index-DMhSSwr2.js → index-DQOpN3ny.js} +29 -29
- streamlit_webrtc/frontend/dist/index.html +1 -1
- streamlit_webrtc/webrtc.py +40 -3
- {streamlit_webrtc-0.55.0.dist-info → streamlit_webrtc-0.56.0.dist-info}/METADATA +1 -1
- {streamlit_webrtc-0.55.0.dist-info → streamlit_webrtc-0.56.0.dist-info}/RECORD +9 -9
- {streamlit_webrtc-0.55.0.dist-info → streamlit_webrtc-0.56.0.dist-info}/WHEEL +0 -0
- {streamlit_webrtc-0.55.0.dist-info → streamlit_webrtc-0.56.0.dist-info}/licenses/LICENSE +0 -0
streamlit_webrtc/component.py
CHANGED
@@ -219,6 +219,7 @@ def compile_state(component_value) -> WebRtcStreamerState:
|
|
219
219
|
def webrtc_streamer(
|
220
220
|
key: str,
|
221
221
|
mode: WebRtcMode = WebRtcMode.SENDRECV,
|
222
|
+
rtc_configuration: Optional[Union[Dict[str, Any], RTCConfiguration]] = None,
|
222
223
|
server_rtc_configuration: Optional[Union[Dict[str, Any], RTCConfiguration]] = None,
|
223
224
|
frontend_rtc_configuration: Optional[
|
224
225
|
Union[Dict[str, Any], RTCConfiguration]
|
@@ -250,7 +251,6 @@ def webrtc_streamer(
|
|
250
251
|
# Deprecated. Just for backward compatibility
|
251
252
|
video_transformer_factory: None = None,
|
252
253
|
async_transform: Optional[bool] = None,
|
253
|
-
rtc_configuration: Optional[Union[Dict[str, Any], RTCConfiguration]] = None,
|
254
254
|
) -> WebRtcStreamerContext:
|
255
255
|
# XXX: We wanted something like `WebRtcStreamerContext[None, None]`
|
256
256
|
# as the return value, but could not find a good solution
|
@@ -263,6 +263,7 @@ def webrtc_streamer(
|
|
263
263
|
def webrtc_streamer(
|
264
264
|
key: str,
|
265
265
|
mode: WebRtcMode = WebRtcMode.SENDRECV,
|
266
|
+
rtc_configuration: Optional[Union[Dict[str, Any], RTCConfiguration]] = None,
|
266
267
|
server_rtc_configuration: Optional[Union[Dict[str, Any], RTCConfiguration]] = None,
|
267
268
|
frontend_rtc_configuration: Optional[
|
268
269
|
Union[Dict[str, Any], RTCConfiguration]
|
@@ -294,7 +295,6 @@ def webrtc_streamer(
|
|
294
295
|
# Deprecated. Just for backward compatibility
|
295
296
|
video_transformer_factory: None = None,
|
296
297
|
async_transform: Optional[bool] = None,
|
297
|
-
rtc_configuration: Optional[Union[Dict[str, Any], RTCConfiguration]] = None,
|
298
298
|
) -> WebRtcStreamerContext[VideoProcessorT, Any]:
|
299
299
|
pass
|
300
300
|
|
@@ -303,6 +303,7 @@ def webrtc_streamer(
|
|
303
303
|
def webrtc_streamer(
|
304
304
|
key: str,
|
305
305
|
mode: WebRtcMode = WebRtcMode.SENDRECV,
|
306
|
+
rtc_configuration: Optional[Union[Dict[str, Any], RTCConfiguration]] = None,
|
306
307
|
server_rtc_configuration: Optional[Union[Dict[str, Any], RTCConfiguration]] = None,
|
307
308
|
frontend_rtc_configuration: Optional[
|
308
309
|
Union[Dict[str, Any], RTCConfiguration]
|
@@ -334,7 +335,6 @@ def webrtc_streamer(
|
|
334
335
|
# Deprecated. Just for backward compatibility
|
335
336
|
video_transformer_factory: None = None,
|
336
337
|
async_transform: Optional[bool] = None,
|
337
|
-
rtc_configuration: Optional[Union[Dict[str, Any], RTCConfiguration]] = None,
|
338
338
|
) -> WebRtcStreamerContext[Any, AudioProcessorT]:
|
339
339
|
pass
|
340
340
|
|
@@ -343,6 +343,7 @@ def webrtc_streamer(
|
|
343
343
|
def webrtc_streamer(
|
344
344
|
key: str,
|
345
345
|
mode: WebRtcMode = WebRtcMode.SENDRECV,
|
346
|
+
rtc_configuration: Optional[Union[Dict[str, Any], RTCConfiguration]] = None,
|
346
347
|
server_rtc_configuration: Optional[Union[Dict[str, Any], RTCConfiguration]] = None,
|
347
348
|
frontend_rtc_configuration: Optional[
|
348
349
|
Union[Dict[str, Any], RTCConfiguration]
|
@@ -374,7 +375,6 @@ def webrtc_streamer(
|
|
374
375
|
# Deprecated. Just for backward compatibility
|
375
376
|
video_transformer_factory: None = None,
|
376
377
|
async_transform: Optional[bool] = None,
|
377
|
-
rtc_configuration: Optional[Union[Dict[str, Any], RTCConfiguration]] = None,
|
378
378
|
) -> WebRtcStreamerContext[VideoProcessorT, AudioProcessorT]:
|
379
379
|
pass
|
380
380
|
|
@@ -382,6 +382,7 @@ def webrtc_streamer(
|
|
382
382
|
def webrtc_streamer(
|
383
383
|
key: str,
|
384
384
|
mode: WebRtcMode = WebRtcMode.SENDRECV,
|
385
|
+
rtc_configuration: Optional[Union[Dict[str, Any], RTCConfiguration]] = None,
|
385
386
|
server_rtc_configuration: Optional[Union[Dict[str, Any], RTCConfiguration]] = None,
|
386
387
|
frontend_rtc_configuration: Optional[
|
387
388
|
Union[Dict[str, Any], RTCConfiguration]
|
@@ -413,7 +414,6 @@ def webrtc_streamer(
|
|
413
414
|
# Deprecated. Just for backward compatibility
|
414
415
|
video_transformer_factory=None,
|
415
416
|
async_transform: Optional[bool] = None,
|
416
|
-
rtc_configuration: Optional[Union[Dict[str, Any], RTCConfiguration]] = None,
|
417
417
|
) -> WebRtcStreamerContext[VideoProcessorT, AudioProcessorT]:
|
418
418
|
# Backward compatibility
|
419
419
|
if video_transformer_factory is not None:
|
@@ -434,14 +434,13 @@ def webrtc_streamer(
|
|
434
434
|
stacklevel=2,
|
435
435
|
)
|
436
436
|
async_processing = async_transform
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
DeprecationWarning,
|
442
|
-
stacklevel=2,
|
443
|
-
)
|
437
|
+
|
438
|
+
# `rtc_configuration` is a shorthand to configure both frontend and server.
|
439
|
+
# `frontend_rtc_configuration` or `server_rtc_configuration` are prioritized.
|
440
|
+
if frontend_rtc_configuration is None:
|
444
441
|
frontend_rtc_configuration = rtc_configuration
|
442
|
+
if server_rtc_configuration is None:
|
443
|
+
server_rtc_configuration = rtc_configuration
|
445
444
|
|
446
445
|
if media_stream_constraints is None:
|
447
446
|
media_stream_constraints = DEFAULT_MEDIA_STREAM_CONSTRAINTS
|
@@ -475,11 +474,9 @@ def webrtc_streamer(
|
|
475
474
|
context._frontend_rtc_configuration = {}
|
476
475
|
if context._frontend_rtc_configuration.get("iceServers") is None:
|
477
476
|
LOGGER.info(
|
478
|
-
"
|
477
|
+
"frontend_rtc_configuration.iceServers is not set. Try to set it automatically."
|
479
478
|
)
|
480
|
-
context._frontend_rtc_configuration["iceServers"] =
|
481
|
-
{"urls": "stun:stun.l.google.com:19302"}
|
482
|
-
]
|
479
|
+
context._frontend_rtc_configuration["iceServers"] = get_available_ice_servers()
|
483
480
|
|
484
481
|
webrtc_worker = context._get_worker()
|
485
482
|
|
@@ -561,8 +558,10 @@ def webrtc_streamer(
|
|
561
558
|
)
|
562
559
|
|
563
560
|
sdp_offer = None
|
561
|
+
ice_candidates = None
|
564
562
|
if component_value:
|
565
563
|
sdp_offer = component_value.get("sdpOffer")
|
564
|
+
ice_candidates = component_value.get("iceCandidates")
|
566
565
|
|
567
566
|
if not context.state.playing and not context.state.signalling:
|
568
567
|
LOGGER.debug(
|
@@ -607,7 +606,6 @@ def webrtc_streamer(
|
|
607
606
|
if server_rtc_configuration and isinstance(server_rtc_configuration, dict)
|
608
607
|
else AiortcRTCConfiguration()
|
609
608
|
)
|
610
|
-
|
611
609
|
if aiortc_rtc_configuration.iceServers is None:
|
612
610
|
LOGGER.info(
|
613
611
|
"rtc_configuration.iceServers is not set. Try to set it automatically."
|
@@ -638,9 +636,16 @@ def webrtc_streamer(
|
|
638
636
|
sendback_audio=sendback_audio,
|
639
637
|
)
|
640
638
|
webrtc_worker.process_offer(sdp_offer["sdp"], sdp_offer["type"], timeout=None)
|
639
|
+
|
640
|
+
if ice_candidates:
|
641
|
+
webrtc_worker.set_ice_candidates_from_offerer(ice_candidates)
|
642
|
+
|
641
643
|
context._set_worker(webrtc_worker)
|
642
644
|
# Rerun to send the SDP answer to frontend
|
643
645
|
rerun()
|
644
646
|
|
647
|
+
if webrtc_worker and ice_candidates:
|
648
|
+
webrtc_worker.set_ice_candidates_from_offerer(ice_candidates)
|
649
|
+
|
645
650
|
context._set_worker(webrtc_worker)
|
646
651
|
return context
|
streamlit_webrtc/credentials.py
CHANGED
@@ -86,19 +86,26 @@ def get_twilio_ice_servers(
|
|
86
86
|
def get_available_ice_servers() -> List[RTCIceServer]:
|
87
87
|
try:
|
88
88
|
LOGGER.info("Try to use TURN server from Hugging Face.")
|
89
|
-
|
89
|
+
hf_turn_servers = get_hf_ice_servers()
|
90
90
|
LOGGER.info("Successfully got TURN credentials from Hugging Face.")
|
91
|
+
LOGGER.info("Using TURN server from Hugging Face and STUN server from Google.")
|
92
|
+
ice_servers = hf_turn_servers + [
|
93
|
+
RTCIceServer(urls="stun:stun.l.google.com:19302"),
|
94
|
+
]
|
91
95
|
return ice_servers
|
92
96
|
except Exception as e:
|
93
97
|
LOGGER.info("Failed to get TURN credentials from Hugging Face: %s", e)
|
94
98
|
|
95
99
|
try:
|
96
|
-
LOGGER.info("Try to use TURN server from Twilio.")
|
100
|
+
LOGGER.info("Try to use STUN/TURN server from Twilio.")
|
97
101
|
ice_servers = get_twilio_ice_servers()
|
98
|
-
LOGGER.info("Successfully got TURN credentials from Twilio.")
|
102
|
+
LOGGER.info("Successfully got STUN/TURN credentials from Twilio.")
|
99
103
|
return ice_servers
|
100
104
|
except Exception as e:
|
101
105
|
LOGGER.info("Failed to get TURN credentials from Twilio: %s", e)
|
102
106
|
|
107
|
+
# NOTE: aiortc anyway uses this STUN server by default if the ICE server config is not set.
|
108
|
+
# Ref: https://github.com/aiortc/aiortc/blob/3ff9bdd03f22bf511a8d304df30f29392338a070/src/aiortc/rtcicetransport.py#L204-L209
|
109
|
+
# We set the STUN server here as this will be used on the browser side as well.
|
103
110
|
LOGGER.info("Use STUN server from Google.")
|
104
111
|
return [RTCIceServer(urls="stun:stun.l.google.com:19302")]
|