bfg-common 1.3.467 → 1.3.468

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/assets/scss/common/normalize.scss +340 -340
  2. package/components/atoms/TheIcon2.vue +1353 -1353
  3. package/components/atoms/loader/Loader.vue +30 -30
  4. package/components/atoms/loader/PreLoader.vue +38 -38
  5. package/components/atoms/switch/Switch.vue +111 -111
  6. package/components/atoms/table/compact/Compact.vue +526 -526
  7. package/components/common/adapterManager/ui/table/Header.vue +93 -93
  8. package/components/common/adapterManager/ui/table/Table.vue +162 -162
  9. package/components/common/context/Context.vue +99 -99
  10. package/components/common/layout/theHeader/LanguageSwitch.vue +102 -0
  11. package/components/common/layout/theHeader/TheHeader.vue +91 -0
  12. package/components/common/layout/theHeader/TheHeaderNew.vue +229 -0
  13. package/components/common/layout/theHeader/TheHeaderOld.vue +241 -0
  14. package/components/common/layout/theHeader/feedback/Feedback.vue +104 -0
  15. package/components/common/layout/theHeader/feedback/FeedbackNew.vue +63 -0
  16. package/components/common/layout/theHeader/feedback/FeedbackOld.vue +73 -0
  17. package/components/common/layout/theHeader/helpMenu/About.vue +110 -0
  18. package/components/common/layout/theHeader/helpMenu/HelpMenu.vue +45 -0
  19. package/components/common/layout/theHeader/helpMenu/helpMenuNew/HelpMenuNew.vue +112 -0
  20. package/components/common/layout/theHeader/helpMenu/helpMenuNew/lib/config/dropMenu.ts +25 -0
  21. package/components/common/layout/theHeader/helpMenu/helpMenuOld/HelpMenuOld.vue +69 -0
  22. package/components/common/layout/theHeader/helpMenu/helpMenuOld/lib/config/dropMenu.ts +22 -0
  23. package/components/common/layout/theHeader/helpMenu/helpMenuOld/lib/models/types.ts +1 -0
  24. package/components/common/layout/theHeader/lib/models/types.ts +5 -0
  25. package/components/common/layout/theHeader/modals/Reconnect.vue +98 -0
  26. package/components/common/layout/theHeader/modals/RedirectLogin.vue +60 -0
  27. package/components/common/layout/theHeader/userMenu/UserMenu.vue +95 -0
  28. package/components/common/layout/theHeader/userMenu/lib/models/interfaces.ts +32 -0
  29. package/components/common/layout/theHeader/userMenu/modals/changePassword/ChangePassword.vue +210 -0
  30. package/components/common/layout/theHeader/userMenu/modals/changePassword/lib/config/form.ts +31 -0
  31. package/components/common/layout/theHeader/userMenu/modals/changePassword/lib/models/interfaces.ts +12 -0
  32. package/components/common/layout/theHeader/userMenu/modals/preferences/Inventory.vue +43 -0
  33. package/components/common/layout/theHeader/userMenu/modals/preferences/Preferences.vue +119 -0
  34. package/components/common/layout/theHeader/userMenu/modals/preferences/View.vue +113 -0
  35. package/components/common/layout/theHeader/userMenu/modals/preferences/changeLanguage/ChangeLanguage.vue +148 -0
  36. package/components/common/layout/theHeader/userMenu/modals/preferences/changeLanguage/lib/config/lang.ts +10 -0
  37. package/components/common/layout/theHeader/userMenu/modals/preferences/changeLanguage/lib/config/radioOptions.ts +22 -0
  38. package/components/common/layout/theHeader/userMenu/modals/preferences/changeLanguage/lib/models/enums.ts +9 -0
  39. package/components/common/layout/theHeader/userMenu/modals/preferences/changeLanguage/lib/models/interfaces.ts +11 -0
  40. package/components/common/layout/theHeader/userMenu/modals/preferences/changeLanguage/lib/models/types.ts +1 -0
  41. package/components/common/layout/theHeader/userMenu/modals/preferences/defaultConsole/DefaultConsole.vue +66 -0
  42. package/components/common/layout/theHeader/userMenu/modals/preferences/defaultConsole/lib/config/consoleOptions.ts +30 -0
  43. package/components/common/layout/theHeader/userMenu/modals/preferences/defaultConsole/lib/models/interfaces.ts +5 -0
  44. package/components/common/layout/theHeader/userMenu/modals/preferences/lib/config/preferencesTabs.ts +68 -0
  45. package/components/common/layout/theHeader/userMenu/modals/preferences/lib/models/types.ts +1 -0
  46. package/components/common/layout/theHeader/userMenu/modals/preferences/timeFormat/TimeFormat.vue +67 -0
  47. package/components/common/layout/theHeader/userMenu/modals/preferences/timeFormat/lib/config/formatOptions.ts +27 -0
  48. package/components/common/layout/theHeader/userMenu/modals/preferences/timeFormat/lib/models/types.ts +1 -0
  49. package/components/common/layout/theHeader/userMenu/userMenuNew/UserMenuNew.vue +114 -0
  50. package/components/common/layout/theHeader/userMenu/userMenuNew/lib/config/dropMenu.ts +28 -0
  51. package/components/common/layout/theHeader/userMenu/userMenuOld/UserMenuOld.vue +36 -0
  52. package/components/common/layout/theHeader/userMenu/userMenuOld/lib/config/dropMenu.ts +36 -0
  53. package/components/common/layout/theHeader/userMenu/userMenuOld/lib/models/types.ts +5 -0
  54. package/components/common/lib/config/states.ts +160 -160
  55. package/components/common/mainNavigationPanel/MainNavigationPanel.vue +142 -142
  56. package/components/common/mainNavigationPanel/MainNavigationPanelNew.vue +248 -248
  57. package/components/common/mainNavigationPanel/MainNavigationPanelOld.vue +288 -288
  58. package/components/common/readyToComplete/ReadyToComplete.vue +15 -15
  59. package/components/common/resource/progressBlock/ProgressBlock.vue +142 -142
  60. package/components/common/split/horizontal/Horizontal.vue +70 -70
  61. package/components/common/vm/actions/clone/Clone.vue +511 -511
  62. package/components/common/vm/actions/common/customizeHardware/CustomizeHardware.vue +273 -273
  63. package/components/common/vm/actions/common/customizeHardware/virtualHardware/VirtualHardware.vue +697 -697
  64. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/Cpu.vue +400 -400
  65. package/components/common/vm/actions/common/customizeHardware/virtualHardware/memory/Memory.vue +329 -329
  66. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newNetwork/NewNetwork.vue +305 -305
  67. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/NewPciDevice.vue +168 -168
  68. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newUsbController/NewUsbController.vue +82 -82
  69. package/components/common/vm/actions/common/customizeHardware/virtualHardware/other/Other.vue +32 -32
  70. package/components/common/vm/actions/common/customizeHardware/virtualHardware/videoCard/VideoCard.vue +182 -182
  71. package/components/common/vm/actions/common/customizeHardware/vmoptions/bootOptions/BootOptions.vue +114 -114
  72. package/components/common/vm/actions/common/customizeHardware/vmoptions/generalOptions/GeneralOptions.vue +192 -192
  73. package/components/common/vm/actions/common/customizeHardware/vmoptions/tools/Tools.vue +72 -72
  74. package/components/common/vm/actions/common/select/computeResource/ComputeResource.vue +164 -164
  75. package/components/common/vm/actions/common/select/name/Name.vue +235 -235
  76. package/components/common/vm/actions/common/select/storage/Storage.vue +198 -198
  77. package/components/common/vm/actions/editSettings/EditSettings.vue +316 -316
  78. package/components/common/weekSelect/lib/config/options.ts +10 -10
  79. package/components/common/wizards/datastore/add/Add.vue +436 -436
  80. package/components/common/wizards/datastore/add/lib/config/stepItems.ts +191 -191
  81. package/components/common/wizards/datastore/add/lib/models/interfaces.ts +38 -38
  82. package/components/common/wizards/datastore/add/lib/utils.ts +70 -70
  83. package/components/common/wizards/datastore/add/local/createName/CreateName.vue +160 -160
  84. package/components/common/wizards/datastore/add/nfs/Nfs.vue +112 -112
  85. package/components/common/wizards/datastore/add/nfs/accessibility/Accessibility.vue +104 -104
  86. package/components/common/wizards/datastore/add/nfs/accessibility/tablesView/lib/config/compatibleTable.ts +62 -62
  87. package/components/common/wizards/datastore/add/nfs/accessibility/tablesView/lib/config/hostsTableItems.ts +53 -53
  88. package/components/common/wizards/datastore/add/readyComplete/ReadyComplete.vue +86 -86
  89. package/components/common/wizards/datastore/add/readyComplete/lib/config/propertiesDetails.ts +184 -184
  90. package/components/common/wizards/datastore/add/sharedStorm/deviceSelection/DeviceSelection.vue +459 -459
  91. package/components/common/wizards/datastore/add/types/Types.vue +80 -80
  92. package/components/common/wizards/datastore/add/types/lib/config/typeOptions.ts +49 -49
  93. package/composables/useAppVersion.ts +22 -22
  94. package/composables/useEnvLanguage.ts +20 -20
  95. package/lib/utils/sendTask.ts +73 -73
  96. package/minify.js +146 -146
  97. package/package.json +2 -1
  98. package/plugins/spice-console/spice.console.ts +147 -147
  99. package/public/spice-console/application/codec.js +263 -263
  100. package/public/spice-console/lib/rasterEngine.js +907 -907
  101. package/public/spice-console/network/spicechannel.js +375 -375
  102. package/store/main/lib/interfaces.ts +9 -9
  103. package/store/tasks/actions.ts +133 -133
  104. package/store/tasks/getters.ts +25 -25
  105. package/store/tasks/lib/models/interfaces.ts +18 -18
  106. package/store/tasks/mutations.ts +58 -58
  107. package/store/tasks/state.ts +16 -16
  108. /package/components/{layout → common/layout}/theHeader/lib/models/enums.ts +0 -0
  109. /package/components/{layout → common/layout}/theHeader/lib/utils/localization.ts +0 -0
@@ -1,263 +1,263 @@
1
- wdi.CodecH264 = {
2
- video: {},
3
- jmuxer: {},
4
- loadedVideo: {},
5
- queues: {},
6
- isReady: {},
7
-
8
- create: function (streamId) {
9
- if (this.video[streamId]) return
10
-
11
- const video = document.createElement('video')
12
- video.id = `video${streamId}`
13
- video.setAttribute('autoplay', '')
14
-
15
- this.video[streamId] = video
16
-
17
- this.jmuxer[streamId] = new JMuxer({
18
- node: video,
19
- mode: 'video',
20
- flushingTime: 0,
21
- fps: 60,
22
- onReady: () => {
23
- this.isReady[streamId] = true
24
- },
25
- })
26
- },
27
-
28
- addQueue: function (streamId, imageData) {
29
- if (!this.queues[streamId]) this.queues[streamId] = []
30
- this.queues[streamId].push(imageData)
31
- },
32
-
33
- resetQueues: function (streamId) {
34
- this.queues[streamId] = []
35
- },
36
-
37
- feed: function (streamId, data) {
38
- this._addListener(streamId)
39
-
40
- if (this.queues[streamId]?.length) {
41
- this.queues[streamId].forEach((queue) => {
42
- this.jmuxer[streamId].feed({
43
- video: queue,
44
- })
45
- })
46
- this.resetQueues(streamId)
47
- }
48
-
49
- this.jmuxer[streamId].feed({
50
- video: data,
51
- })
52
- },
53
-
54
- destroy: function (streamId) {
55
- this._removeListener(streamId)
56
- this.video[streamId]?.remove()
57
- this.video = {}
58
- this.jmuxer = {}
59
- this.loadedVideo = {}
60
- },
61
-
62
- _addListener: function (streamId) {
63
- this.video[streamId]?.removeEventListener(
64
- 'loadedmetadata',
65
- this.loadedVideo[streamId]
66
- )
67
- this.video[streamId].addEventListener(
68
- 'loadedmetadata',
69
- this.loadedVideo[streamId]
70
- )
71
- },
72
-
73
- _removeListener: function (streamId) {
74
- this.video[streamId]?.removeEventListener(
75
- 'loadedmetadata',
76
- this.loadedVideo[streamId]
77
- )
78
- },
79
- }
80
-
81
- wdi.CodecVp8 = {
82
- decoders: {},
83
-
84
- create: function (streamId) {
85
- this.decoders[streamId] = new vp8_decoder_ctx()
86
- },
87
-
88
- destroy: function () {
89
- this.decoders = {}
90
- },
91
-
92
- feed: function (streamId, imageData, context, box) {
93
- const errorCode = vp8_dixie_decode_frame(
94
- this.decoders[streamId],
95
- imageData,
96
- imageData.length
97
- )
98
- if (VPX_CODEC_OK === errorCode) {
99
- this._I420toRGBA(this.decoders[streamId].ref_frames[0].img, context, box)
100
- }
101
- },
102
-
103
- _I420toRGBA: function (vp8, context, box) {
104
- const yuvwidth = vp8.w
105
- const height = vp8.d_h
106
- const width = vp8.d_w
107
-
108
- let output = context.createImageData(width, height)
109
- let outputData = output.data
110
- let R, G, B
111
-
112
- for (let h = 0; h < height; h++) {
113
- for (let w = 0; w < width; w++) {
114
- const Y = vp8.planes[0][vp8.planes_off[0] + 0 + w + yuvwidth * h]
115
- const U =
116
- vp8.planes[1][
117
- vp8.planes_off[1] + 0 + (w >> 1) + (yuvwidth >> 1) * (h >> 1)
118
- ]
119
- const V =
120
- vp8.planes[2][
121
- vp8.planes_off[2] + 0 + (w >> 1) + (yuvwidth >> 1) * (h >> 1)
122
- ]
123
-
124
- R = Math.round(Y + 1.13983 * (V - 128))
125
- G = Math.round(Y - 0.39465 * (U - 128) - 0.5806 * (V - 128))
126
- B = Math.round(Y + 2.03211 * (U - 128))
127
-
128
- // outputData[0 + w * 4 + width * 4 * h] = R
129
- // outputData[1 + w * 4 + width * 4 * h] = G
130
- // outputData[2 + w * 4 + width * 4 * h] = B
131
- // outputData[3 + w * 4 + width * 4 * h] = 255
132
- // Изменим порядок записи пикселей, чтобы перевернуть изображение
133
- const flippedIndex = ((height - 1 - h) * width + w) * 4
134
- outputData[flippedIndex] = R
135
- outputData[flippedIndex + 1] = G
136
- outputData[flippedIndex + 2] = B
137
- outputData[flippedIndex + 3] = 255
138
- }
139
- }
140
-
141
- context.putImageData(output, box.x, box.y)
142
- },
143
- }
144
-
145
- wdi.CodecH265 = {
146
- queue: {},
147
- configed: {},
148
- isReady: {},
149
- decoders: {},
150
- pendingFrames: {},
151
- underflow: {},
152
- baseTime: {},
153
-
154
- create: async function (streamId, context, box) {
155
- const init = {
156
- output: this._handleFrame.bind(this, streamId, context, box),
157
- error: (e) => {
158
- console.log(e)
159
- },
160
- }
161
- const config = {
162
- codec: wdi.SpiceVideoCodecValue[wdi.currentCodec],
163
- codedWidth: 640,
164
- codedHeight: 480,
165
- }
166
- const { supported } = await VideoDecoder.isConfigSupported(config)
167
- // Проверяем поддерживает ли браузер VideoDecoder
168
- if (supported) {
169
- this.decoders[streamId] = new VideoDecoder(init)
170
- this.decoders[streamId].configure(config)
171
- this.isReady[streamId] = true
172
- } else {
173
- // Try another config.
174
- console.log('not supported')
175
- }
176
- },
177
-
178
- destroy: function () {
179
- this.queue = {}
180
- this.configed = {}
181
- this.isReady = {}
182
- this.decoders = {}
183
- this.pendingFrames = {}
184
- this.underflow = {}
185
- this.baseTime = {}
186
- },
187
-
188
- addQueue: function (streamId, imageData) {
189
- if (!this.queues[streamId]) this.queues[streamId] = []
190
- this.queues[streamId].push(imageData)
191
- },
192
-
193
- resetQueues: function (streamId) {
194
- this.queues[streamId] = []
195
- },
196
-
197
- setConfig: function (streamId, box) {
198
- const config = {
199
- codec: wdi.SpiceVideoCodecValue[wdi.currentCodec],
200
- codedWidth: box.width,
201
- codedHeight: box.height,
202
- }
203
- this.decoders[streamId].configure(config)
204
- this.configed[streamId] = true
205
- },
206
-
207
- decode: function (streamId, imageData) {
208
- if (this.queue[streamId]?.length) {
209
- this.queue[streamId].forEach((data) => {
210
- const chunk = new EncodedVideoChunk({
211
- type: 'key',
212
- data: data,
213
- timestamp: performance.now(),
214
- })
215
- this.decoders[streamId].decode(chunk)
216
- })
217
- this.resetQueues(streamId)
218
- }
219
-
220
- const chunk = new EncodedVideoChunk({
221
- type: 'key',
222
- data: imageData,
223
- timestamp: performance.now(),
224
- })
225
- this.decoders[streamId].decode(chunk)
226
- },
227
-
228
- _handleFrame: function (streamId, context, box, frame) {
229
- if (!this.pendingFrames[streamId]) this.pendingFrames[streamId] = []
230
- this.pendingFrames[streamId].push(frame)
231
-
232
- if (this.underflow[streamId] === undefined) this.underflow[streamId] = true
233
- if (this.underflow[streamId])
234
- setTimeout(this._renderFrame.bind(this, streamId, context, box), 0)
235
- },
236
- _renderFrame: async function (streamId, context, box) {
237
- this.underflow[streamId] = this.pendingFrames[streamId].length === 0
238
- if (this.underflow[streamId]) return
239
-
240
- const frame = this.pendingFrames[streamId].shift()
241
-
242
- // Based on the frame's timestamp calculate how much of real time waiting
243
- // is needed before showing the next frame.
244
- const timeUntilNextFrame = this._calculateTimeUntilNextFrame(
245
- frame.timestamp,
246
- streamId
247
- )
248
- await new Promise((r) => {
249
- setTimeout(r, timeUntilNextFrame)
250
- })
251
-
252
- context.drawImage(frame, box.x, box.y, box.width, box.height)
253
- frame.close()
254
-
255
- // Immediately schedule rendering of the next frame
256
- setTimeout(this._renderFrame.bind(this, streamId, context, box), 0)
257
- },
258
- _calculateTimeUntilNextFrame: function (timestamp, streamId) {
259
- if (!this.baseTime[streamId]) this.baseTime[streamId] = performance.now()
260
- const mediaTime = performance.now() - this.baseTime[streamId]
261
- return Math.max(0, timestamp / 1000 - mediaTime)
262
- },
263
- }
1
+ wdi.CodecH264 = {
2
+ video: {},
3
+ jmuxer: {},
4
+ loadedVideo: {},
5
+ queues: {},
6
+ isReady: {},
7
+
8
+ create: function (streamId) {
9
+ if (this.video[streamId]) return
10
+
11
+ const video = document.createElement('video')
12
+ video.id = `video${streamId}`
13
+ video.setAttribute('autoplay', '')
14
+
15
+ this.video[streamId] = video
16
+
17
+ this.jmuxer[streamId] = new JMuxer({
18
+ node: video,
19
+ mode: 'video',
20
+ flushingTime: 0,
21
+ fps: 60,
22
+ onReady: () => {
23
+ this.isReady[streamId] = true
24
+ },
25
+ })
26
+ },
27
+
28
+ addQueue: function (streamId, imageData) {
29
+ if (!this.queues[streamId]) this.queues[streamId] = []
30
+ this.queues[streamId].push(imageData)
31
+ },
32
+
33
+ resetQueues: function (streamId) {
34
+ this.queues[streamId] = []
35
+ },
36
+
37
+ feed: function (streamId, data) {
38
+ this._addListener(streamId)
39
+
40
+ if (this.queues[streamId]?.length) {
41
+ this.queues[streamId].forEach((queue) => {
42
+ this.jmuxer[streamId].feed({
43
+ video: queue,
44
+ })
45
+ })
46
+ this.resetQueues(streamId)
47
+ }
48
+
49
+ this.jmuxer[streamId].feed({
50
+ video: data,
51
+ })
52
+ },
53
+
54
+ destroy: function (streamId) {
55
+ this._removeListener(streamId)
56
+ this.video[streamId]?.remove()
57
+ this.video = {}
58
+ this.jmuxer = {}
59
+ this.loadedVideo = {}
60
+ },
61
+
62
+ _addListener: function (streamId) {
63
+ this.video[streamId]?.removeEventListener(
64
+ 'loadedmetadata',
65
+ this.loadedVideo[streamId]
66
+ )
67
+ this.video[streamId].addEventListener(
68
+ 'loadedmetadata',
69
+ this.loadedVideo[streamId]
70
+ )
71
+ },
72
+
73
+ _removeListener: function (streamId) {
74
+ this.video[streamId]?.removeEventListener(
75
+ 'loadedmetadata',
76
+ this.loadedVideo[streamId]
77
+ )
78
+ },
79
+ }
80
+
81
+ wdi.CodecVp8 = {
82
+ decoders: {},
83
+
84
+ create: function (streamId) {
85
+ this.decoders[streamId] = new vp8_decoder_ctx()
86
+ },
87
+
88
+ destroy: function () {
89
+ this.decoders = {}
90
+ },
91
+
92
+ feed: function (streamId, imageData, context, box) {
93
+ const errorCode = vp8_dixie_decode_frame(
94
+ this.decoders[streamId],
95
+ imageData,
96
+ imageData.length
97
+ )
98
+ if (VPX_CODEC_OK === errorCode) {
99
+ this._I420toRGBA(this.decoders[streamId].ref_frames[0].img, context, box)
100
+ }
101
+ },
102
+
103
+ _I420toRGBA: function (vp8, context, box) {
104
+ const yuvwidth = vp8.w
105
+ const height = vp8.d_h
106
+ const width = vp8.d_w
107
+
108
+ let output = context.createImageData(width, height)
109
+ let outputData = output.data
110
+ let R, G, B
111
+
112
+ for (let h = 0; h < height; h++) {
113
+ for (let w = 0; w < width; w++) {
114
+ const Y = vp8.planes[0][vp8.planes_off[0] + 0 + w + yuvwidth * h]
115
+ const U =
116
+ vp8.planes[1][
117
+ vp8.planes_off[1] + 0 + (w >> 1) + (yuvwidth >> 1) * (h >> 1)
118
+ ]
119
+ const V =
120
+ vp8.planes[2][
121
+ vp8.planes_off[2] + 0 + (w >> 1) + (yuvwidth >> 1) * (h >> 1)
122
+ ]
123
+
124
+ R = Math.round(Y + 1.13983 * (V - 128))
125
+ G = Math.round(Y - 0.39465 * (U - 128) - 0.5806 * (V - 128))
126
+ B = Math.round(Y + 2.03211 * (U - 128))
127
+
128
+ // outputData[0 + w * 4 + width * 4 * h] = R
129
+ // outputData[1 + w * 4 + width * 4 * h] = G
130
+ // outputData[2 + w * 4 + width * 4 * h] = B
131
+ // outputData[3 + w * 4 + width * 4 * h] = 255
132
+ // Изменим порядок записи пикселей, чтобы перевернуть изображение
133
+ const flippedIndex = ((height - 1 - h) * width + w) * 4
134
+ outputData[flippedIndex] = R
135
+ outputData[flippedIndex + 1] = G
136
+ outputData[flippedIndex + 2] = B
137
+ outputData[flippedIndex + 3] = 255
138
+ }
139
+ }
140
+
141
+ context.putImageData(output, box.x, box.y)
142
+ },
143
+ }
144
+
145
+ wdi.CodecH265 = {
146
+ queue: {},
147
+ configed: {},
148
+ isReady: {},
149
+ decoders: {},
150
+ pendingFrames: {},
151
+ underflow: {},
152
+ baseTime: {},
153
+
154
+ create: async function (streamId, context, box) {
155
+ const init = {
156
+ output: this._handleFrame.bind(this, streamId, context, box),
157
+ error: (e) => {
158
+ console.log(e)
159
+ },
160
+ }
161
+ const config = {
162
+ codec: wdi.SpiceVideoCodecValue[wdi.currentCodec],
163
+ codedWidth: 640,
164
+ codedHeight: 480,
165
+ }
166
+ const { supported } = await VideoDecoder.isConfigSupported(config)
167
+ // Проверяем поддерживает ли браузер VideoDecoder
168
+ if (supported) {
169
+ this.decoders[streamId] = new VideoDecoder(init)
170
+ this.decoders[streamId].configure(config)
171
+ this.isReady[streamId] = true
172
+ } else {
173
+ // Try another config.
174
+ console.log('not supported')
175
+ }
176
+ },
177
+
178
+ destroy: function () {
179
+ this.queue = {}
180
+ this.configed = {}
181
+ this.isReady = {}
182
+ this.decoders = {}
183
+ this.pendingFrames = {}
184
+ this.underflow = {}
185
+ this.baseTime = {}
186
+ },
187
+
188
+ addQueue: function (streamId, imageData) {
189
+ if (!this.queues[streamId]) this.queues[streamId] = []
190
+ this.queues[streamId].push(imageData)
191
+ },
192
+
193
+ resetQueues: function (streamId) {
194
+ this.queues[streamId] = []
195
+ },
196
+
197
+ setConfig: function (streamId, box) {
198
+ const config = {
199
+ codec: wdi.SpiceVideoCodecValue[wdi.currentCodec],
200
+ codedWidth: box.width,
201
+ codedHeight: box.height,
202
+ }
203
+ this.decoders[streamId].configure(config)
204
+ this.configed[streamId] = true
205
+ },
206
+
207
+ decode: function (streamId, imageData) {
208
+ if (this.queue[streamId]?.length) {
209
+ this.queue[streamId].forEach((data) => {
210
+ const chunk = new EncodedVideoChunk({
211
+ type: 'key',
212
+ data: data,
213
+ timestamp: performance.now(),
214
+ })
215
+ this.decoders[streamId].decode(chunk)
216
+ })
217
+ this.resetQueues(streamId)
218
+ }
219
+
220
+ const chunk = new EncodedVideoChunk({
221
+ type: 'key',
222
+ data: imageData,
223
+ timestamp: performance.now(),
224
+ })
225
+ this.decoders[streamId].decode(chunk)
226
+ },
227
+
228
+ _handleFrame: function (streamId, context, box, frame) {
229
+ if (!this.pendingFrames[streamId]) this.pendingFrames[streamId] = []
230
+ this.pendingFrames[streamId].push(frame)
231
+
232
+ if (this.underflow[streamId] === undefined) this.underflow[streamId] = true
233
+ if (this.underflow[streamId])
234
+ setTimeout(this._renderFrame.bind(this, streamId, context, box), 0)
235
+ },
236
+ _renderFrame: async function (streamId, context, box) {
237
+ this.underflow[streamId] = this.pendingFrames[streamId].length === 0
238
+ if (this.underflow[streamId]) return
239
+
240
+ const frame = this.pendingFrames[streamId].shift()
241
+
242
+ // Based on the frame's timestamp calculate how much of real time waiting
243
+ // is needed before showing the next frame.
244
+ const timeUntilNextFrame = this._calculateTimeUntilNextFrame(
245
+ frame.timestamp,
246
+ streamId
247
+ )
248
+ await new Promise((r) => {
249
+ setTimeout(r, timeUntilNextFrame)
250
+ })
251
+
252
+ context.drawImage(frame, box.x, box.y, box.width, box.height)
253
+ frame.close()
254
+
255
+ // Immediately schedule rendering of the next frame
256
+ setTimeout(this._renderFrame.bind(this, streamId, context, box), 0)
257
+ },
258
+ _calculateTimeUntilNextFrame: function (timestamp, streamId) {
259
+ if (!this.baseTime[streamId]) this.baseTime[streamId] = performance.now()
260
+ const mediaTime = performance.now() - this.baseTime[streamId]
261
+ return Math.max(0, timestamp / 1000 - mediaTime)
262
+ },
263
+ }