mirror of
https://github.com/HumanAIGC-Engineering/gradio-webrtc.git
synced 2026-02-05 01:49:23 +08:00
Simplify Cloudflare config with new endpoint (#135)
Old instructions will still work, but we now have an endpoint that matches the `RTCPeerConnection` signature exactly.
This commit is contained in:
@@ -100,7 +100,7 @@ turn_key_api_token = os.environ.get("TURN_KEY_API_TOKEN")
|
||||
ttl = 86400 # Can modify TTL, here it's set to 24 hours
|
||||
|
||||
response = requests.post(
|
||||
f"https://rtc.live.cloudflare.com/v1/turn/keys/{turn_key_id}/credentials/generate",
|
||||
f"https://rtc.live.cloudflare.com/v1/turn/keys/{turn_key_id}/credentials/generate-ice-servers",
|
||||
headers={
|
||||
"Authorization": f"Bearer {turn_key_api_token}",
|
||||
"Content-Type": "application/json",
|
||||
@@ -108,14 +108,12 @@ response = requests.post(
|
||||
json={"ttl": ttl},
|
||||
)
|
||||
if response.ok:
|
||||
ice_servers = [response.json()["iceServers"]]
|
||||
rtc_configuration = response.json()
|
||||
else:
|
||||
raise Exception(
|
||||
f"Failed to get TURN credentials: {response.status_code} {response.text}"
|
||||
)
|
||||
|
||||
rtc_configuration = {"iceServers": ice_servers}
|
||||
|
||||
stream = Stream(
|
||||
handler=...,
|
||||
rtc_configuration=rtc_configuration,
|
||||
|
||||
Reference in New Issue
Block a user