Skip to content

Commit

Permalink
Merge branch 'develop' into feat/spoolman
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrolamas authored Jul 31, 2023
2 parents 6472589 + 6d095b0 commit 3a47ca8
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 30 deletions.
20 changes: 19 additions & 1 deletion src/components/settings/cameras/CameraConfigDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
<v-divider />
</template>

<app-setting :title="$t('app.setting.label.camera_url')">
<app-setting :title="$t('app.setting.label.camera_url_stream')">
<v-text-field
v-model="camera.urlStream"
type="url"
Expand All @@ -146,6 +146,24 @@
/>
</app-setting>

<v-divider />

<app-setting :title="$t('app.setting.label.camera_url_snapshot')">
<v-text-field
v-model="camera.urlSnapshot"
type="url"
spellcheck="false"
class="mt-5"
filled
dense
single-line
hide-details="auto"
:rules="[
$rules.required
]"
/>
</app-setting>

<template v-if="camera.service === 'iframe'">
<v-divider />

Expand Down
3 changes: 2 additions & 1 deletion src/components/settings/cameras/Cameras.vue
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ export default class CameraSettings extends Vue {
service: 'mjpegstreamer-adaptive',
targetFps: 15,
targetFpsIdle: 5,
urlStream: Globals.DEFAULTS.CAMERA_URL
urlStream: Globals.DEFAULTS.CAMERA_URL_STREAM,
urlSnapshot: Globals.DEFAULTS.CAMERA_URL_SNAPSHOT
}
this.dialogState = {
Expand Down
2 changes: 1 addition & 1 deletion src/components/widgets/camera/services/HlsstreamCamera.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default class HlsstreamCamera extends Mixins(CameraMixin) {
hls: Hls | null = null
startPlayback () {
const url = this.cameraUrl
const url = this.buildAbsoluteUrl(this.camera.urlStream || '').toString()
if (Hls.isSupported()) {
this.hls?.destroy()
Expand Down
6 changes: 4 additions & 2 deletions src/components/widgets/camera/services/IframeCamera.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ export default class IframeCamera extends Mixins(CameraMixin) {
cameraIFrameSource = ''
startPlayback () {
this.cameraIFrameSource = this.cameraUrl
const url = this.buildAbsoluteUrl(this.camera.urlStream || '').toString()
this.$emit('raw-camera-url', this.cameraUrl)
this.cameraIFrameSource = url
this.$emit('raw-camera-url', url)
}
stopPlayback () {
Expand Down
6 changes: 4 additions & 2 deletions src/components/widgets/camera/services/IpstreamCamera.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ export default class IpstreamCamera extends Mixins(CameraMixin) {
cameraVideoSource = ''
startPlayback () {
this.cameraVideoSource = this.cameraUrl
const url = this.buildAbsoluteUrl(this.camera.urlStream || '').toString()
this.$emit('raw-camera-url', this.cameraUrl)
this.cameraVideoSource = url
this.$emit('raw-camera-url', url)
}
stopPlayback () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,19 @@ export default class MjpegstreamerAdaptiveCamera extends Mixins(CameraMixin) {
}
startPlayback () {
const url = new URL(this.cameraUrl)
const url = this.buildAbsoluteUrl(this.camera.urlSnapshot || '')
this.requestStartTime = performance.now()
if (!url.searchParams.get('action')?.startsWith('snapshot')) {
url.searchParams.set('action', 'snapshot')
}
url.searchParams.set('cacheBust', Date.now().toString())
this.cameraImageSource = url.toString()
url.searchParams.set('action', 'stream')
const rawUrl = this.buildAbsoluteUrl(this.camera.urlStream || '')
rawUrl.searchParams.set('cacheBust', Date.now().toString())
this.$emit('raw-camera-url', url.toString())
this.$emit('raw-camera-url', rawUrl.toString())
}
stopPlayback () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ export default class MjpegstreamerCamera extends Mixins(CameraMixin) {
cameraImageSource = ''
startPlayback () {
const url = new URL(this.cameraUrl)
if (!url.searchParams.get('action')?.startsWith('stream')) {
url.searchParams.set('action', 'stream')
}
const url = this.buildAbsoluteUrl(this.camera.urlStream || '')
url.searchParams.set('cacheBust', Date.now().toString())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default class WebrtcCamerastreamerCamera extends Mixins(CameraMixin) {
remoteId: string | null = null
startPlayback () {
const url = this.cameraUrl
const url = this.buildAbsoluteUrl(this.camera.urlStream || '')
this.pc?.close()
Expand Down
3 changes: 2 additions & 1 deletion src/globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ export const Globals = Object.freeze({
APP_NAME: 'fluidd',
HEADER_HEIGHT: 56,
DEFAULTS: {
CAMERA_URL: '/webcam?action=stream'
CAMERA_URL_STREAM: '/webcam?action=stream',
CAMERA_URL_SNAPSHOT: '/webcam?action=snapshot'
},
NETWORK_REQUEST_TIMEOUT: 0,
KLIPPY_RETRY_DELAY: 1500,
Expand Down
3 changes: 2 additions & 1 deletion src/locales/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,8 @@ app:
rawstream: Raw stream
camera_rotate_by: Rotate by
camera_stream_type: Stream type
camera_url: Camera Url
camera_url_snapshot: Camera Url Snapshot
camera_url_stream: Camera Url Stream
card: Card
collector: Collector
confirm_on_estop: Require confirm on Emergency Stop
Expand Down
14 changes: 6 additions & 8 deletions src/mixins/camera.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,6 @@ export default class CameraMixin extends Vue {
return this.$store.state.config.apiUrl
}

get cameraUrl () {
const baseUrl = this.camera.urlStream || this.camera.urlSnapshot || ''

const { origin } = new URL(this.apiUrl)

return new URL(baseUrl, origin).toString()
}

get cameraStyle () {
return {
transform: this.cameraTransformStyle || undefined
Expand Down Expand Up @@ -95,6 +87,12 @@ export default class CameraMixin extends Vue {
}
}

buildAbsoluteUrl (url: string) {
const { origin } = new URL(this.apiUrl)

return new URL(url, origin)
}

startPlayback () {
// noop
}
Expand Down

0 comments on commit 3a47ca8

Please sign in to comment.