tuikit-atomicx-vue3-electron 5.2.0 → 5.2.1
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.
|
@@ -1,91 +1,105 @@
|
|
|
1
|
-
import { computed as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { objectMerge as
|
|
5
|
-
import { dataReport as
|
|
6
|
-
import { AtomicMetrics as
|
|
7
|
-
import { LiveOrientation as
|
|
8
|
-
import { TUIVideoQuality as
|
|
9
|
-
import { useLiveListState as
|
|
10
|
-
const
|
|
11
|
-
let
|
|
12
|
-
const { currentLive:
|
|
1
|
+
import { computed as g, ref as k, watch as X } from "vue";
|
|
2
|
+
import q, { TRTCVideoResolutionMode as v, TRTCVideoResolution as u, TUIVideoStreamType as G, TRTCMediaMixingEvent as m, TUIResolutionMode as B, TRTCMediaSourceType as p, TRTCCameraCaptureMode as _ } from "@tencentcloud/tuiroom-engine-electron";
|
|
3
|
+
import J from "../../hooks/useRoomEngine.js";
|
|
4
|
+
import { objectMerge as K } from "../../utils/utils.js";
|
|
5
|
+
import { dataReport as N } from "../../report/dataReport.js";
|
|
6
|
+
import { AtomicMetrics as Y } from "../../report/MetricsKey.js";
|
|
7
|
+
import { LiveOrientation as T } from "../../types/live.js";
|
|
8
|
+
import { TUIVideoQuality as n } from "../../types/types.js";
|
|
9
|
+
import { useLiveListState as ee } from "../LiveListState/LiveListState.js";
|
|
10
|
+
const S = "[VideoMixerState]";
|
|
11
|
+
let R;
|
|
12
|
+
const { currentLive: y } = ee(), P = g(() => {
|
|
13
13
|
var e, o;
|
|
14
|
-
return
|
|
14
|
+
return y.value && ((e = y.value) == null ? void 0 : e.layoutTemplate) >= 200 && ((o = y.value) == null ? void 0 : o.layoutTemplate) <= 599 ? T.Landscape : T.Portrait;
|
|
15
15
|
});
|
|
16
|
-
function
|
|
17
|
-
|
|
16
|
+
function D() {
|
|
17
|
+
R || (R = J());
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function oe(e) {
|
|
20
20
|
return {
|
|
21
|
-
[
|
|
21
|
+
[n.kVideoQuality_1080p]: {
|
|
22
22
|
fps: 30,
|
|
23
23
|
bitrate: 3e3
|
|
24
24
|
},
|
|
25
|
-
[
|
|
25
|
+
[n.kVideoQuality_720p]: {
|
|
26
26
|
fps: 30,
|
|
27
27
|
bitrate: 1800
|
|
28
28
|
},
|
|
29
|
-
[
|
|
29
|
+
[n.kVideoQuality_540p]: {
|
|
30
30
|
fps: 30,
|
|
31
31
|
bitrate: 1200
|
|
32
32
|
},
|
|
33
|
-
[
|
|
33
|
+
[n.kVideoQuality_360p]: {
|
|
34
34
|
fps: 30,
|
|
35
35
|
bitrate: 800
|
|
36
36
|
}
|
|
37
37
|
}[e];
|
|
38
38
|
}
|
|
39
|
-
function
|
|
39
|
+
function j(e) {
|
|
40
40
|
return {
|
|
41
|
-
[
|
|
41
|
+
[n.kVideoQuality_1080p]: {
|
|
42
42
|
width: 1920,
|
|
43
43
|
height: 1080
|
|
44
44
|
},
|
|
45
|
-
[
|
|
45
|
+
[n.kVideoQuality_720p]: {
|
|
46
46
|
width: 1280,
|
|
47
47
|
height: 720
|
|
48
48
|
},
|
|
49
|
-
[
|
|
49
|
+
[n.kVideoQuality_540p]: {
|
|
50
50
|
width: 960,
|
|
51
51
|
height: 540
|
|
52
52
|
},
|
|
53
|
-
[
|
|
53
|
+
[n.kVideoQuality_360p]: {
|
|
54
54
|
width: 640,
|
|
55
55
|
height: 360
|
|
56
56
|
}
|
|
57
57
|
}[e];
|
|
58
58
|
}
|
|
59
|
-
function
|
|
59
|
+
function V(e) {
|
|
60
60
|
return {
|
|
61
|
-
[
|
|
62
|
-
[
|
|
63
|
-
[
|
|
64
|
-
[
|
|
65
|
-
[
|
|
61
|
+
[u.TRTCVideoResolution_480_270]: { width: 480, height: 270 },
|
|
62
|
+
[u.TRTCVideoResolution_640_360]: { width: 640, height: 360 },
|
|
63
|
+
[u.TRTCVideoResolution_960_540]: { width: 960, height: 540 },
|
|
64
|
+
[u.TRTCVideoResolution_1280_720]: { width: 1280, height: 720 },
|
|
65
|
+
[u.TRTCVideoResolution_1920_1080]: { width: 1920, height: 1080 }
|
|
66
66
|
}[e] || { width: 1280, height: 720 };
|
|
67
67
|
}
|
|
68
|
-
const
|
|
69
|
-
const { width: e, height: o } =
|
|
70
|
-
return
|
|
71
|
-
}), w =
|
|
72
|
-
const { width: e, height: o } =
|
|
73
|
-
return
|
|
68
|
+
const M = k(n.kVideoQuality_1080p), C = g(() => {
|
|
69
|
+
const { width: e, height: o } = j(M.value);
|
|
70
|
+
return P.value === T.Portrait ? o : e;
|
|
71
|
+
}), w = g(() => {
|
|
72
|
+
const { width: e, height: o } = j(M.value);
|
|
73
|
+
return P.value === T.Portrait ? e : o;
|
|
74
74
|
});
|
|
75
|
-
function
|
|
75
|
+
function ie(e) {
|
|
76
|
+
return {
|
|
77
|
+
[n.kVideoQuality_1080p]: u.TRTCVideoResolution_1920_1080,
|
|
78
|
+
[n.kVideoQuality_720p]: u.TRTCVideoResolution_1280_720,
|
|
79
|
+
[n.kVideoQuality_540p]: u.TRTCVideoResolution_960_540,
|
|
80
|
+
[n.kVideoQuality_360p]: u.TRTCVideoResolution_640_360
|
|
81
|
+
}[e];
|
|
82
|
+
}
|
|
83
|
+
function te(e) {
|
|
84
|
+
return {
|
|
85
|
+
[u.TRTCVideoResolution_1920_1080]: n.kVideoQuality_1080p,
|
|
86
|
+
[u.TRTCVideoResolution_1280_720]: n.kVideoQuality_720p,
|
|
87
|
+
[u.TRTCVideoResolution_960_540]: n.kVideoQuality_540p,
|
|
88
|
+
[u.TRTCVideoResolution_640_360]: n.kVideoQuality_360p
|
|
89
|
+
}[e];
|
|
90
|
+
}
|
|
91
|
+
function ae(e) {
|
|
76
92
|
return {
|
|
77
|
-
[
|
|
78
|
-
[
|
|
79
|
-
[u.kVideoQuality_540p]: d.TRTCVideoResolution_960_540,
|
|
80
|
-
[u.kVideoQuality_360p]: d.TRTCVideoResolution_640_360
|
|
93
|
+
[v.TRTCVideoResolutionModePortrait]: B.kResolutionMode_Portrait,
|
|
94
|
+
[v.TRTCVideoResolutionModeLandscape]: B.kResolutionMode_Landscape
|
|
81
95
|
}[e];
|
|
82
96
|
}
|
|
83
|
-
const
|
|
84
|
-
const { fps: e, bitrate: o } =
|
|
97
|
+
const c = g(() => {
|
|
98
|
+
const { fps: e, bitrate: o } = oe(M.value);
|
|
85
99
|
return {
|
|
86
100
|
videoEncoderParams: {
|
|
87
|
-
videoResolution:
|
|
88
|
-
resMode:
|
|
101
|
+
videoResolution: ie(M.value),
|
|
102
|
+
resMode: P.value === T.Portrait ? v.TRTCVideoResolutionModePortrait : v.TRTCVideoResolutionModeLandscape,
|
|
89
103
|
videoFps: e,
|
|
90
104
|
videoBitrate: o,
|
|
91
105
|
minVideoBitrate: o,
|
|
@@ -94,11 +108,11 @@ const I = M(() => {
|
|
|
94
108
|
canvasColor: 0,
|
|
95
109
|
selectedBorderColor: 16776960
|
|
96
110
|
};
|
|
97
|
-
}),
|
|
111
|
+
}), Q = k(!1), r = k([]), b = g(() => r.value.find((e) => e.isSelected) || null);
|
|
98
112
|
let t;
|
|
99
|
-
async function
|
|
100
|
-
if (
|
|
101
|
-
const i = r.value.find((a) => a.sourceId ===
|
|
113
|
+
async function x(e, o = !1) {
|
|
114
|
+
if (b.value) {
|
|
115
|
+
const i = r.value.find((a) => a.sourceId === b.value.sourceId) || null;
|
|
102
116
|
i && (i.isSelected = !1, o || await t.updateMediaSource(i));
|
|
103
117
|
}
|
|
104
118
|
if (e) {
|
|
@@ -106,159 +120,171 @@ async function P(e, o = !1) {
|
|
|
106
120
|
i && (i.isSelected = !0, o || await t.updateMediaSource(i));
|
|
107
121
|
}
|
|
108
122
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
123
|
+
async function E() {
|
|
124
|
+
var e;
|
|
125
|
+
c.value && await ((e = R.instance) == null ? void 0 : e.updateVideoQualityEx({
|
|
126
|
+
streamType: G.kCameraStream,
|
|
127
|
+
encoderParams: {
|
|
128
|
+
videoResolution: te(c.value.videoEncoderParams.videoResolution),
|
|
129
|
+
fps: c.value.videoEncoderParams.videoFps,
|
|
130
|
+
bitrate: c.value.videoEncoderParams.videoBitrate,
|
|
131
|
+
resolutionMode: ae(c.value.videoEncoderParams.resMode)
|
|
132
|
+
}
|
|
133
|
+
}));
|
|
112
134
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
135
|
+
let U = 1;
|
|
136
|
+
function re() {
|
|
137
|
+
return U += 1, U - 1;
|
|
138
|
+
}
|
|
139
|
+
function I(e, o, i) {
|
|
140
|
+
const a = { ...e }, d = a.right - a.left, s = a.bottom - a.top;
|
|
141
|
+
if (d > o || s > i) {
|
|
142
|
+
const h = d * i > s * o ? o / d : i / s;
|
|
143
|
+
a.right = Math.round(d * h), a.bottom = Math.round(s * h);
|
|
118
144
|
}
|
|
119
145
|
return a;
|
|
120
146
|
}
|
|
121
|
-
function
|
|
122
|
-
if (e.sourceType ===
|
|
123
|
-
const { width: o, height: i } =
|
|
124
|
-
return
|
|
147
|
+
function ne(e) {
|
|
148
|
+
if (e.sourceType === p.kCamera && e.camera) {
|
|
149
|
+
const { width: o, height: i } = V(e.camera.resolution);
|
|
150
|
+
return I({
|
|
125
151
|
left: 0,
|
|
126
152
|
top: 0,
|
|
127
153
|
right: o,
|
|
128
154
|
bottom: i
|
|
129
|
-
},
|
|
130
|
-
} else if (e.sourceType ===
|
|
155
|
+
}, C.value, w.value);
|
|
156
|
+
} else if (e.sourceType === p.kScreen) {
|
|
131
157
|
if (e.width && e.height)
|
|
132
|
-
return
|
|
158
|
+
return I({
|
|
133
159
|
left: 0,
|
|
134
160
|
top: 0,
|
|
135
161
|
right: e.width,
|
|
136
162
|
bottom: e.height
|
|
137
|
-
},
|
|
138
|
-
} else if (e.sourceType ===
|
|
139
|
-
return
|
|
163
|
+
}, C.value, w.value);
|
|
164
|
+
} else if (e.sourceType === p.kImage)
|
|
165
|
+
return I(e.rect, C.value, w.value);
|
|
140
166
|
return { left: 0, top: 0, right: 640, bottom: 360 };
|
|
141
167
|
}
|
|
142
|
-
function
|
|
168
|
+
function de(e) {
|
|
143
169
|
return r.value.some((o) => o.sourceId === e.sourceId && o.sourceType === e.sourceType);
|
|
144
170
|
}
|
|
145
|
-
function
|
|
146
|
-
if (
|
|
171
|
+
function A(e) {
|
|
172
|
+
if (de(e))
|
|
147
173
|
throw new Error("Media source already existed");
|
|
148
174
|
}
|
|
149
|
-
async function
|
|
175
|
+
async function ue(e) {
|
|
150
176
|
var o;
|
|
151
|
-
if (console.log("[VideoMixerState]addMediaSource:", e), t || await
|
|
177
|
+
if (console.log("[VideoMixerState]addMediaSource:", e), t || await F(), !t)
|
|
152
178
|
throw new Error("Failed to initialize MediaSourceManager. Please ensure TUIRoomEngine is ready.");
|
|
153
|
-
if (
|
|
154
|
-
const i =
|
|
179
|
+
if (N.reportAtomicMetrics(Y.LIVE_VIDEO_MIXER_STORE), A(e), e.rect = ne(e), e.zOrder = re(), r.value.push(e), await t.addMediaSource(e), e.sourceType === p.kCamera && ((o = e.camera) != null && o.resolution)) {
|
|
180
|
+
const i = V(e.camera.resolution);
|
|
155
181
|
await t.setCameraCaptureParam(e.sourceId, {
|
|
156
|
-
mode:
|
|
182
|
+
mode: _.TRTCCameraCaptureManual,
|
|
157
183
|
width: i.width,
|
|
158
184
|
height: i.height,
|
|
159
185
|
colorSpace: e.colorSpace,
|
|
160
186
|
colorRange: e.colorRange
|
|
161
187
|
});
|
|
162
188
|
}
|
|
163
|
-
|
|
189
|
+
x(e);
|
|
164
190
|
}
|
|
165
|
-
async function
|
|
166
|
-
var
|
|
191
|
+
async function le(e, o) {
|
|
192
|
+
var d, s, h;
|
|
167
193
|
if (!t)
|
|
168
194
|
throw new Error("Failed to initialize MediaSourceManager. Please ensure TUIRoomEngine is ready.");
|
|
169
|
-
const i =
|
|
195
|
+
const i = K(e, o);
|
|
170
196
|
if (e.sourceId !== i.sourceId) {
|
|
171
197
|
if (console.log("[VideoMixerState] sourceId changed, replacing media source:", {
|
|
172
198
|
oldSourceId: e.sourceId,
|
|
173
199
|
newSourceId: i.sourceId
|
|
174
|
-
}),
|
|
175
|
-
const l =
|
|
200
|
+
}), A(i), await t.removeMediaSource(e), await t.addMediaSource(i), i.sourceType === p.kCamera && ((d = i.camera) != null && d.resolution)) {
|
|
201
|
+
const l = V(i.camera.resolution);
|
|
176
202
|
await t.setCameraCaptureParam(i.sourceId, {
|
|
177
|
-
mode:
|
|
203
|
+
mode: _.TRTCCameraCaptureManual,
|
|
178
204
|
width: l.width,
|
|
179
205
|
height: l.height,
|
|
180
206
|
colorSpace: i.colorSpace,
|
|
181
207
|
colorRange: i.colorRange
|
|
182
208
|
});
|
|
183
209
|
}
|
|
184
|
-
const
|
|
185
|
-
|
|
210
|
+
const f = r.value.findIndex((l) => l.sourceId === e.sourceId);
|
|
211
|
+
f !== -1 && (r.value[f] = i);
|
|
186
212
|
} else {
|
|
187
|
-
if (console.log("[VideoMixerState] sourceId unchanged, updating media source:", i), await t.updateMediaSource(i), i.sourceType ===
|
|
188
|
-
const l = (h = e.camera) == null ? void 0 : h.resolution,
|
|
189
|
-
if (
|
|
190
|
-
const
|
|
213
|
+
if (console.log("[VideoMixerState] sourceId unchanged, updating media source:", i), await t.updateMediaSource(i), i.sourceType === p.kCamera && ((s = i.camera) != null && s.resolution)) {
|
|
214
|
+
const l = (h = e.camera) == null ? void 0 : h.resolution, z = i.camera.resolution, Z = l !== z, H = i.colorSpace !== e.colorSpace, W = i.colorRange !== e.colorRange;
|
|
215
|
+
if (Z || H || W) {
|
|
216
|
+
const L = V(z);
|
|
191
217
|
await t.setCameraCaptureParam(i.sourceId, {
|
|
192
|
-
mode:
|
|
193
|
-
width:
|
|
194
|
-
height:
|
|
218
|
+
mode: _.TRTCCameraCaptureManual,
|
|
219
|
+
width: L.width,
|
|
220
|
+
height: L.height,
|
|
195
221
|
colorSpace: i.colorSpace,
|
|
196
222
|
colorRange: i.colorRange
|
|
197
223
|
});
|
|
198
224
|
}
|
|
199
225
|
}
|
|
200
|
-
const
|
|
201
|
-
|
|
226
|
+
const f = r.value.findIndex((l) => l.sourceId === e.sourceId);
|
|
227
|
+
f !== -1 && (r.value[f] = i);
|
|
202
228
|
}
|
|
203
|
-
e.isSelected &&
|
|
229
|
+
e.isSelected && x(i);
|
|
204
230
|
}
|
|
205
|
-
async function
|
|
231
|
+
async function ce(e) {
|
|
206
232
|
t && await t.removeMediaSource(e), r.value = r.value.filter((o) => o.sourceId !== e.sourceId);
|
|
207
233
|
}
|
|
208
|
-
function
|
|
234
|
+
function se() {
|
|
209
235
|
r.value.forEach(async (e) => {
|
|
210
236
|
await t.removeMediaSource(e);
|
|
211
237
|
}), r.value = [];
|
|
212
238
|
}
|
|
213
|
-
function
|
|
214
|
-
console.log(`${
|
|
239
|
+
function F() {
|
|
240
|
+
console.log(`${S}enableLocalVideoMixer`), D(), Q.value = !0, $();
|
|
215
241
|
}
|
|
216
|
-
async function
|
|
242
|
+
async function $() {
|
|
217
243
|
var e;
|
|
218
|
-
console.log(`${
|
|
219
|
-
|
|
220
|
-
}), t.on(
|
|
244
|
+
console.log(`${S}initMediaSourceManager`), R.instance && (t = (e = R.instance) == null ? void 0 : e.getTRTCCloud().getMediaMixingManager(), await t.startPublish(), await t.updatePublishParams(c.value), await E(), t.on(m.onSourceSelected, (o) => {
|
|
245
|
+
x(o, !0);
|
|
246
|
+
}), t.on(m.onSourceDisconnected, (o) => {
|
|
221
247
|
o && o.sourceId && (r.value = r.value.filter((i) => i.sourceId !== o.sourceId));
|
|
222
|
-
}), t.on(
|
|
223
|
-
const a = r.value.find((
|
|
248
|
+
}), t.on(m.onSourceMoved, (o, i) => {
|
|
249
|
+
const a = r.value.find((d) => d.sourceId === o.sourceId && d.sourceType === o.sourceType) || null;
|
|
224
250
|
a && (a.rect = i);
|
|
225
|
-
}), t.on(
|
|
226
|
-
const a = r.value.find((
|
|
251
|
+
}), t.on(m.onSourceResized, (o, i) => {
|
|
252
|
+
const a = r.value.find((d) => d.sourceId === o.sourceId && d.sourceType === o.sourceType) || null;
|
|
227
253
|
a && (a.rect = i);
|
|
228
|
-
}), t.on(
|
|
254
|
+
}), t.on(m.onRightButtonClicked, (o) => {
|
|
229
255
|
}));
|
|
230
256
|
}
|
|
231
|
-
|
|
232
|
-
() =>
|
|
257
|
+
X(
|
|
258
|
+
() => c.value,
|
|
233
259
|
async () => {
|
|
234
|
-
t && (await t.startPublish(), await t.updatePublishParams(
|
|
260
|
+
t && (await t.startPublish(), await t.updatePublishParams(c.value), await E());
|
|
235
261
|
},
|
|
236
262
|
{ immediate: !0, deep: !0 }
|
|
237
263
|
);
|
|
238
|
-
let
|
|
239
|
-
function
|
|
240
|
-
if (console.log(`${
|
|
241
|
-
console.log(`${
|
|
264
|
+
let O = !1;
|
|
265
|
+
function pe() {
|
|
266
|
+
if (console.log(`${S}initVideoMixerState`), O) {
|
|
267
|
+
console.log(`${S}initVideoMixerState already inited`);
|
|
242
268
|
return;
|
|
243
269
|
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
}),
|
|
270
|
+
D(), q.once("ready", async () => {
|
|
271
|
+
await E(), Q.value && await $();
|
|
272
|
+
}), O = !0;
|
|
247
273
|
}
|
|
248
|
-
function
|
|
249
|
-
return
|
|
250
|
-
isVideoMixerEnabled:
|
|
251
|
-
publishVideoQuality:
|
|
274
|
+
function Ve() {
|
|
275
|
+
return pe(), {
|
|
276
|
+
isVideoMixerEnabled: Q,
|
|
277
|
+
publishVideoQuality: M,
|
|
252
278
|
mediaSourceList: r,
|
|
253
|
-
activeMediaSource:
|
|
254
|
-
enableLocalVideoMixer:
|
|
255
|
-
addMediaSource:
|
|
256
|
-
updateMediaSource:
|
|
257
|
-
removeMediaSource:
|
|
258
|
-
clearMediaSource:
|
|
279
|
+
activeMediaSource: b,
|
|
280
|
+
enableLocalVideoMixer: F,
|
|
281
|
+
addMediaSource: ue,
|
|
282
|
+
updateMediaSource: le,
|
|
283
|
+
removeMediaSource: ce,
|
|
284
|
+
clearMediaSource: se
|
|
259
285
|
};
|
|
260
286
|
}
|
|
261
287
|
export {
|
|
262
|
-
|
|
263
|
-
|
|
288
|
+
Q as isVideoMixerEnabled,
|
|
289
|
+
Ve as useVideoMixerState
|
|
264
290
|
};
|