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

fix: add port to webcam url if port is not 80 #1566

Merged
merged 3 commits into from
Dec 16, 2023
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/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
Loading