Skip to content

Commit

Permalink
Create routine to warn the user if the allowed IPs for the WebRTC ICE…
Browse files Browse the repository at this point in the history
… candidates were not yet defined
  • Loading branch information
rafaellehmkuhl committed Nov 24, 2023
1 parent 233f6c2 commit 792b373
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/stores/video.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,30 @@
import { useStorage } from '@vueuse/core'
import { defineStore } from 'pinia'
import Swal from 'sweetalert2'
import { ref } from 'vue'

export const useVideoStore = defineStore('video', () => {
const availableIceIps = ref<string[] | undefined>(undefined)
const allowedIceIps = useStorage<string[]>('cockpit-allowed-stream-ips', [])

// Routine to make sure the user has chosen the allowed ICE candidate IPs, so the stream works as expected
const iceIpCheckInterval = setInterval(() => {
// Pass if there are no available IPs yet or if the user has already set the allowed ones
if (availableIceIps.value === undefined || !allowedIceIps.value.isEmpty()) {
return
}
// If there's more than one IP candidate available, send a warning an clear the check routine
if (availableIceIps.value.length >= 1) {
Swal.fire({
text: `Cockpit detected more than one IP being used to route the video streaming.
This situation often leads to video stuterring, specially if one of the IPs is from a non-wired connection.
To prevent issues and have an optimum streaming experience, please open the configuration of one of your
video widgets and choose the IP that should be used for the video streamings.`,
icon: 'warning',
})
clearInterval(iceIpCheckInterval)
}
}, 5000)

return { availableIceIps, allowedIceIps }
})

0 comments on commit 792b373

Please sign in to comment.