@@ -11,27 +11,41 @@ const props = defineProps<{
11
11
id: string ;
12
12
}>();
13
13
14
+ const emptyStreamSrc = " //:0" ;
14
15
const streamSrc = computed <string >(() => {
15
16
const port =
16
17
useCameraSettingsStore ().currentCameraSettings .stream [props .streamType === " Raw" ? " inputPort" : " outputPort" ];
17
18
18
19
if (! useStateStore ().backendConnected || port === 0 ) {
19
- return loadingImage ;
20
+ return emptyStreamSrc ;
20
21
}
21
22
22
23
return ` http://${inject (" backendHostname" )}:${port }/stream.mjpg ` ;
23
24
});
24
25
const streamDesc = computed <string >(() => ` ${props .streamType } Stream View ` );
25
26
const streamStyle = computed <StyleValue >(() => {
26
27
if (useStateStore ().colorPickingMode ) {
27
- return { width: " 100% " , cursor: " crosshair" };
28
+ return { cursor: " crosshair" };
28
29
}
29
30
30
- return { width: " 100%" };
31
+ return {};
32
+ });
33
+
34
+ const containerStyle = computed <StyleValue >(() => {
35
+ const resolution = useCameraSettingsStore ().currentVideoFormat .resolution ;
36
+ const rotation = useCameraSettingsStore ().currentPipelineSettings .inputImageRotationMode ;
37
+ if (rotation === 1 || rotation === 3 ) {
38
+ return {
39
+ aspectRatio: ` ${resolution .height }/${resolution .width } `
40
+ };
41
+ }
42
+ return {
43
+ aspectRatio: ` ${resolution .width }/${resolution .height } `
44
+ };
31
45
});
32
46
33
47
const overlayStyle = computed <StyleValue >(() => {
34
- if (useStateStore ().colorPickingMode || streamSrc .value == loadingImage ) {
48
+ if (useStateStore ().colorPickingMode || streamSrc .value == emptyStreamSrc ) {
35
49
return { display: " none" };
36
50
} else {
37
51
return {};
@@ -57,13 +71,23 @@ const handleFullscreenRequest = () => {
57
71
const mjpgStream: any = ref (null );
58
72
onBeforeUnmount (() => {
59
73
if (! mjpgStream .value ) return ;
60
- mjpgStream .value [" src" ] = " //:0 " ;
74
+ mjpgStream .value [" src" ] = emptyStreamSrc ;
61
75
});
62
76
</script >
63
77
64
78
<template >
65
- <div class =" stream-container" >
66
- <img :id =" id" ref =" mjpgStream" crossorigin =" anonymous" :src =" streamSrc" :alt =" streamDesc" :style =" streamStyle" />
79
+ <div class =" stream-container" :style =" containerStyle" >
80
+ <img :src =" loadingImage" class =" stream-loading" />
81
+ <img
82
+ :id =" id"
83
+ class =" stream-video"
84
+ ref =" mjpgStream"
85
+ v-show =" streamSrc !== emptyStreamSrc"
86
+ crossorigin =" anonymous"
87
+ :src =" streamSrc"
88
+ :alt =" streamDesc"
89
+ :style =" streamStyle"
90
+ />
67
91
<div class =" stream-overlay" :style =" overlayStyle" >
68
92
<pv-icon
69
93
icon-name =" mdi-camera-image"
@@ -89,7 +113,21 @@ onBeforeUnmount(() => {
89
113
90
114
<style scoped>
91
115
.stream-container {
116
+ display : flex ;
92
117
position : relative ;
118
+ width : 100% ;
119
+ }
120
+
121
+ .stream-loading {
122
+ position : absolute ;
123
+ width : 100% ;
124
+ height : 100% ;
125
+ }
126
+
127
+ .stream-video {
128
+ position : absolute ;
129
+ width : 100% ;
130
+ height : 100% ;
93
131
}
94
132
95
133
.stream-overlay {
0 commit comments