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:
Freddy Boulton
2025-04-09 09:36:51 -04:00
committed by GitHub
parent f70b27bd41
commit 837330dcd8
37 changed files with 2914 additions and 780 deletions

View File

@@ -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 {

View File

@@ -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) => {