Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn user when multiple IP routes are being used for the WebRTC streaming #591

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/widgets/VideoPlayer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ watch(selectedICEIPsField, () => {
})

setInterval(() => {
const combinedIps = [...videoStore.availableIceIps, ...availableICEIPs.value]
const combinedIps = [...(videoStore.availableIceIps ?? []), ...availableICEIPs.value]
const uniqueIps = combinedIps.filter((value, index, array) => array.indexOf(value) === index)
videoStore.availableIceIps = uniqueIps
}, 1000)
Expand Down
32 changes: 30 additions & 2 deletions src/stores/video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { saveAs } from 'file-saver'
import localforage from 'localforage'
import { defineStore } from 'pinia'
import Swal from 'sweetalert2'
import { reactive } from 'vue'
import { ref } from 'vue'

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

// Offer download of backuped videos
Expand Down Expand Up @@ -48,5 +48,33 @@ export const useVideoStore = defineStore('video', () => {
})
})

// 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({
html: `
<p>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.</p>
</br>
<p>To prevent issues and archieve an optimum streaming experience, please:</p>
<ol>
<li>1. Open the configuration of one of your video widgets.</li>
<li>2. Choose the IP that should be used for the video streaming.</li>
</ol>
`,
icon: 'warning',
customClass: {
htmlContainer: 'text-left',
},
})
clearInterval(iceIpCheckInterval)
}
}, 5000)

return { availableIceIps, allowedIceIps }
})
Loading