mirror of
https://github.com/HumanAIGC-Engineering/gradio-webrtc.git
synced 2026-02-05 18:09:23 +08:00
Cloudflare turn integration (#264)
* Turn integration * Add code: * type hint * Fix typehint * add code * format * WIP * trickle ice * bump version * Better docs * Modify * code * Mute icon for whisper * Add code * llama 4 demo * code * OpenAI interruptions * fix docs
This commit is contained in:
@@ -73,6 +73,7 @@
|
||||
|
||||
export let server: {
|
||||
offer: (body: any) => Promise<any>;
|
||||
turn: () => Promise<any>;
|
||||
};
|
||||
|
||||
let stream_state: "open" | "closed" | "waiting" = "closed";
|
||||
@@ -148,7 +149,17 @@
|
||||
}
|
||||
_webrtc_id = Math.random().toString(36).substring(2);
|
||||
value = _webrtc_id;
|
||||
stream_state = "waiting";
|
||||
await server.turn().then((rtc_configuration_) => {
|
||||
if (rtc_configuration_.error) {
|
||||
dispatch("error", rtc_configuration_.error);
|
||||
return;
|
||||
}
|
||||
rtc_configuration = rtc_configuration_;
|
||||
console.info("rtc_configuration", rtc_configuration_);
|
||||
});
|
||||
pc = new RTCPeerConnection(rtc_configuration);
|
||||
console.info("created");
|
||||
pc.addEventListener("connectionstatechange", async (event) => {
|
||||
switch (pc.connectionState) {
|
||||
case "connected":
|
||||
@@ -173,7 +184,6 @@
|
||||
break;
|
||||
}
|
||||
});
|
||||
stream_state = "waiting";
|
||||
stream = null;
|
||||
|
||||
try {
|
||||
|
||||
@@ -40,6 +40,14 @@
|
||||
|
||||
$: if (value === "start_webrtc_stream") {
|
||||
_webrtc_id = Math.random().toString(36).substring(2);
|
||||
server
|
||||
.turn()
|
||||
.then((rtc_configuration_) => {
|
||||
rtc_configuration = rtc_configuration_;
|
||||
})
|
||||
.catch((error) => {
|
||||
dispatch("error", error);
|
||||
});
|
||||
value = _webrtc_id;
|
||||
pc = new RTCPeerConnection(rtc_configuration);
|
||||
pc.addEventListener("connectionstatechange", async (event) => {
|
||||
|
||||
Reference in New Issue
Block a user