2024-09-10 18:17:41 -07:00
|
|
|
import { invoke } from "./@tauri-apps/api/index.js";
|
2024-08-24 15:06:16 -07:00
|
|
|
import { rtc_init } from "./rtc.js";
|
|
|
|
|
|
|
|
function call_camera_connect() {
|
|
|
|
invoke("connect_to_camera", {})
|
|
|
|
.then(() => {
|
|
|
|
let cam_button = document.getElementById("camera_connect_button");
|
|
|
|
cam_button.innerText = "Connecting to Camera";
|
|
|
|
cam_button.classList.remove("text-semibold");
|
|
|
|
cam_button.classList.remove("text-white");
|
|
|
|
cam_button.classList.add("text-neutral-400")
|
|
|
|
})
|
|
|
|
.catch((e) => console.error(e));
|
|
|
|
}
|
|
|
|
|
|
|
|
async function init() {
|
|
|
|
console.log("Setting up");
|
2024-09-10 18:17:41 -07:00
|
|
|
document.getElementById("camera_connect_button").addEventListener("click", call_camera_connect);
|
2024-09-18 12:11:18 -07:00
|
|
|
|
|
|
|
let webrtc_support = supports_webrtc();
|
|
|
|
|
|
|
|
invoke("supports_webrtc", { has_support: webrtc_support });
|
|
|
|
if (webrtc_support) {
|
|
|
|
await rtc_init();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function supports_webrtc() {
|
|
|
|
var isWebRTCSupported = false;
|
|
|
|
|
|
|
|
['RTCPeerConnection', 'webkitRTCPeerConnection', 'mozRTCPeerConnection', 'RTCIceGatherer'].forEach(function(item) {
|
|
|
|
if (isWebRTCSupported) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (item in window) {
|
|
|
|
isWebRTCSupported = true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return isWebRTCSupported;
|
2024-08-24 15:06:16 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
export { init };
|