Skip to content

Commit

Permalink
fix: add port to webcam url if port is not 80 (#1566)
Browse files Browse the repository at this point in the history
Co-authored-by: Stefan Dej <meteyou@gmail.com>
  • Loading branch information
dictor93 and meteyou authored Dec 16, 2023
1 parent 59c31e7 commit 20524b0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/components/mixins/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default class BaseMixin extends Vue {
return this.$store.getters['socket/getHostUrl']
}

get hostPort(): boolean {
get hostPort(): number {
return this.$store.state.socket.port ?? 80
}

Expand Down
4 changes: 4 additions & 0 deletions src/components/mixins/webcam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ export default class WebcamMixin extends Mixins(BaseMixin) {
// overwrite url to baseUrl, if it is an absolute URL
if (baseUrl.startsWith('http') || baseUrl.startsWith('://')) url = new URL(baseUrl)

if (baseUrl.startsWith('/webcam') && ![80, 7125, 7130].includes(this.hostPort)) {
url.port = this.hostPort.toString()
}

return decodeURIComponent(url.toString())
}

Expand Down
10 changes: 5 additions & 5 deletions src/components/webcams/streamers/MjpegstreamerAdaptive.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ export default class MjpegstreamerAdaptive extends Mixins(BaseMixin, WebcamMixin
return [90, 270].includes(this.camSettings.rotation ?? 0)
}
get url() {
return this.convertUrl(this.camSettings?.snapshot_url, this.printerUrl)
}
refreshFrame() {
if (this.isVisible) {
this.refresh = new Date().getTime()
Expand All @@ -92,11 +96,7 @@ export default class MjpegstreamerAdaptive extends Mixins(BaseMixin, WebcamMixin
}
async setFrame() {
const baseUrl = this.camSettings.snapshot_url
let url = new URL(baseUrl, this.printerUrl === null ? this.hostUrl.toString() : this.printerUrl)
if (baseUrl.startsWith('http') || baseUrl.startsWith('://')) url = new URL(baseUrl)
let url = new URL(this.url)
url.searchParams.append('bypassCache', this.refresh.toString())
this.request_start_time = performance.now()
Expand Down
7 changes: 1 addition & 6 deletions src/components/webcams/streamers/WebrtcCameraStreamer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,7 @@ export default class WebrtcCameraStreamer extends Mixins(BaseMixin, WebcamMixin)
@Ref() declare stream: HTMLVideoElement
get url() {
const baseUrl = this.camSettings.stream_url
let url = new URL(baseUrl, this.printerUrl === null ? this.hostUrl.toString() : this.printerUrl)
if (baseUrl.startsWith('http') || baseUrl.startsWith('://')) url = new URL(baseUrl)
return decodeURIComponent(url.toString())
return this.convertUrl(this.camSettings?.stream_url, this.printerUrl)
}
get webcamStyle() {
Expand Down

0 comments on commit 20524b0

Please sign in to comment.