Add microphone mute (#158)

* Add code

* add code
This commit is contained in:
Freddy Boulton
2025-03-10 14:53:08 -04:00
committed by GitHub
parent ed59834378
commit 51f1fafa3a
14 changed files with 1579 additions and 1520 deletions

View File

@@ -51,10 +51,10 @@ export async function start(
server_fn,
webrtc_id,
modality: "video" | "audio" = "video",
on_change_cb: (msg: "change" | "tick") => void = () => { },
on_change_cb: (msg: "change" | "tick") => void = () => {},
rtp_params = {},
additional_message_cb: (msg: object) => void = () => { },
reject_cb: (msg: object) => void = () => { },
additional_message_cb: (msg: object) => void = () => {},
reject_cb: (msg: object) => void = () => {},
) {
pc = createPeerConnection(pc, node);
const data_channel = pc.createDataChannel("text");
@@ -105,7 +105,11 @@ export async function start(
return pc;
}
function make_offer(server_fn: any, body, reject_cb: (msg: object) => void = () => { }): Promise<object> {
function make_offer(
server_fn: any,
body,
reject_cb: (msg: object) => void = () => {},
): Promise<object> {
return new Promise((resolve, reject) => {
server_fn(body).then((data) => {
console.debug("data", data);
@@ -123,7 +127,7 @@ async function negotiate(
pc: RTCPeerConnection,
server_fn: any,
webrtc_id: string,
reject_cb: (msg: object) => void = () => { },
reject_cb: (msg: object) => void = () => {},
): Promise<void> {
return pc
.createOffer()
@@ -150,11 +154,15 @@ async function negotiate(
})
.then(() => {
var offer = pc.localDescription;
return make_offer(server_fn, {
sdp: offer.sdp,
type: offer.type,
webrtc_id: webrtc_id,
}, reject_cb);
return make_offer(
server_fn,
{
sdp: offer.sdp,
type: offer.type,
webrtc_id: webrtc_id,
},
reject_cb,
);
})
.then((response) => {
return response;