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 M, ref as b, watch as H } from "vue";
2
- import W, { TRTCVideoResolutionMode as L, TRTCVideoResolution as d, TRTCMediaMixingEvent as f, TRTCMediaSourceType as s, TRTCCameraCaptureMode as V } from "@tencentcloud/tuiroom-engine-electron";
3
- import X from "../../hooks/useRoomEngine.js";
4
- import { objectMerge as q } from "../../utils/utils.js";
5
- import { dataReport as G } from "../../report/dataReport.js";
6
- import { AtomicMetrics as J } from "../../report/MetricsKey.js";
7
- import { LiveOrientation as g } from "../../types/live.js";
8
- import { TUIVideoQuality as u } from "../../types/types.js";
9
- import { useLiveListState as K } from "../LiveListState/LiveListState.js";
10
- const T = "[VideoMixerState]";
11
- let S;
12
- const { currentLive: R } = K(), k = M(() => {
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 R.value && ((e = R.value) == null ? void 0 : e.layoutTemplate) >= 200 && ((o = R.value) == null ? void 0 : o.layoutTemplate) <= 599 ? g.Landscape : g.Portrait;
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 O() {
17
- S || (S = X());
16
+ function D() {
17
+ R || (R = J());
18
18
  }
19
- function N(e) {
19
+ function oe(e) {
20
20
  return {
21
- [u.kVideoQuality_1080p]: {
21
+ [n.kVideoQuality_1080p]: {
22
22
  fps: 30,
23
23
  bitrate: 3e3
24
24
  },
25
- [u.kVideoQuality_720p]: {
25
+ [n.kVideoQuality_720p]: {
26
26
  fps: 30,
27
27
  bitrate: 1800
28
28
  },
29
- [u.kVideoQuality_540p]: {
29
+ [n.kVideoQuality_540p]: {
30
30
  fps: 30,
31
31
  bitrate: 1200
32
32
  },
33
- [u.kVideoQuality_360p]: {
33
+ [n.kVideoQuality_360p]: {
34
34
  fps: 30,
35
35
  bitrate: 800
36
36
  }
37
37
  }[e];
38
38
  }
39
- function D(e) {
39
+ function j(e) {
40
40
  return {
41
- [u.kVideoQuality_1080p]: {
41
+ [n.kVideoQuality_1080p]: {
42
42
  width: 1920,
43
43
  height: 1080
44
44
  },
45
- [u.kVideoQuality_720p]: {
45
+ [n.kVideoQuality_720p]: {
46
46
  width: 1280,
47
47
  height: 720
48
48
  },
49
- [u.kVideoQuality_540p]: {
49
+ [n.kVideoQuality_540p]: {
50
50
  width: 960,
51
51
  height: 540
52
52
  },
53
- [u.kVideoQuality_360p]: {
53
+ [n.kVideoQuality_360p]: {
54
54
  width: 640,
55
55
  height: 360
56
56
  }
57
57
  }[e];
58
58
  }
59
- function v(e) {
59
+ function V(e) {
60
60
  return {
61
- [d.TRTCVideoResolution_480_270]: { width: 480, height: 270 },
62
- [d.TRTCVideoResolution_640_360]: { width: 640, height: 360 },
63
- [d.TRTCVideoResolution_960_540]: { width: 960, height: 540 },
64
- [d.TRTCVideoResolution_1280_720]: { width: 1280, height: 720 },
65
- [d.TRTCVideoResolution_1920_1080]: { width: 1920, height: 1080 }
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 m = b(u.kVideoQuality_1080p), y = M(() => {
69
- const { width: e, height: o } = D(m.value);
70
- return k.value === g.Portrait ? o : e;
71
- }), w = M(() => {
72
- const { width: e, height: o } = D(m.value);
73
- return k.value === g.Portrait ? e : o;
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 Y(e) {
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
- [u.kVideoQuality_1080p]: d.TRTCVideoResolution_1920_1080,
78
- [u.kVideoQuality_720p]: d.TRTCVideoResolution_1280_720,
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 I = M(() => {
84
- const { fps: e, bitrate: o } = N(m.value);
97
+ const c = g(() => {
98
+ const { fps: e, bitrate: o } = oe(M.value);
85
99
  return {
86
100
  videoEncoderParams: {
87
- videoResolution: Y(m.value),
88
- resMode: k.value === g.Portrait ? L.TRTCVideoResolutionModePortrait : L.TRTCVideoResolutionModeLandscape,
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
- }), x = b(!1), r = b([]), _ = M(() => r.value.find((e) => e.isSelected) || null);
111
+ }), Q = k(!1), r = k([]), b = g(() => r.value.find((e) => e.isSelected) || null);
98
112
  let t;
99
- async function P(e, o = !1) {
100
- if (_.value) {
101
- const i = r.value.find((a) => a.sourceId === _.value.sourceId) || null;
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
- let z = 1;
110
- function ee() {
111
- return z += 1, z - 1;
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
- function C(e, o, i) {
114
- const a = { ...e }, n = a.right - a.left, c = a.bottom - a.top;
115
- if (n > o || c > i) {
116
- const h = n * i > c * o ? o / n : i / c;
117
- a.right = Math.round(n * h), a.bottom = Math.round(c * h);
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 ie(e) {
122
- if (e.sourceType === s.kCamera && e.camera) {
123
- const { width: o, height: i } = v(e.camera.resolution);
124
- return C({
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
- }, y.value, w.value);
130
- } else if (e.sourceType === s.kScreen) {
155
+ }, C.value, w.value);
156
+ } else if (e.sourceType === p.kScreen) {
131
157
  if (e.width && e.height)
132
- return C({
158
+ return I({
133
159
  left: 0,
134
160
  top: 0,
135
161
  right: e.width,
136
162
  bottom: e.height
137
- }, y.value, w.value);
138
- } else if (e.sourceType === s.kImage)
139
- return C(e.rect, y.value, w.value);
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 oe(e) {
168
+ function de(e) {
143
169
  return r.value.some((o) => o.sourceId === e.sourceId && o.sourceType === e.sourceType);
144
170
  }
145
- function U(e) {
146
- if (oe(e))
171
+ function A(e) {
172
+ if (de(e))
147
173
  throw new Error("Media source already existed");
148
174
  }
149
- async function te(e) {
175
+ async function ue(e) {
150
176
  var o;
151
- if (console.log("[VideoMixerState]addMediaSource:", e), t || await j(), !t)
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 (G.reportAtomicMetrics(J.LIVE_VIDEO_MIXER_STORE), U(e), e.rect = ie(e), e.zOrder = ee(), r.value.push(e), await t.addMediaSource(e), e.sourceType === s.kCamera && ((o = e.camera) != null && o.resolution)) {
154
- const i = v(e.camera.resolution);
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: V.TRTCCameraCaptureManual,
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
- P(e);
189
+ x(e);
164
190
  }
165
- async function ae(e, o) {
166
- var n, c, h;
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 = q(e, o);
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
- }), U(i), await t.removeMediaSource(e), await t.addMediaSource(i), i.sourceType === s.kCamera && ((n = i.camera) != null && n.resolution)) {
175
- const l = v(i.camera.resolution);
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: V.TRTCCameraCaptureManual,
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 p = r.value.findIndex((l) => l.sourceId === e.sourceId);
185
- p !== -1 && (r.value[p] = i);
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 === s.kCamera && ((c = i.camera) != null && c.resolution)) {
188
- const l = (h = e.camera) == null ? void 0 : h.resolution, E = i.camera.resolution, $ = l !== E, F = i.colorSpace !== e.colorSpace, Z = i.colorRange !== e.colorRange;
189
- if ($ || F || Z) {
190
- const Q = v(E);
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: V.TRTCCameraCaptureManual,
193
- width: Q.width,
194
- height: Q.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 p = r.value.findIndex((l) => l.sourceId === e.sourceId);
201
- p !== -1 && (r.value[p] = i);
226
+ const f = r.value.findIndex((l) => l.sourceId === e.sourceId);
227
+ f !== -1 && (r.value[f] = i);
202
228
  }
203
- e.isSelected && P(i);
229
+ e.isSelected && x(i);
204
230
  }
205
- async function re(e) {
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 ne() {
234
+ function se() {
209
235
  r.value.forEach(async (e) => {
210
236
  await t.removeMediaSource(e);
211
237
  }), r.value = [];
212
238
  }
213
- function j() {
214
- console.log(`${T}enableLocalVideoMixer`), O(), x.value = !0, A();
239
+ function F() {
240
+ console.log(`${S}enableLocalVideoMixer`), D(), Q.value = !0, $();
215
241
  }
216
- async function A() {
242
+ async function $() {
217
243
  var e;
218
- console.log(`${T}initMediaSourceManager`), S.instance && (t = (e = S.instance) == null ? void 0 : e.getTRTCCloud().getMediaMixingManager(), await t.startPublish(), await t.updatePublishParams(I.value), t.on(f.onSourceSelected, (o) => {
219
- P(o, !0);
220
- }), t.on(f.onSourceDisconnected, (o) => {
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(f.onSourceMoved, (o, i) => {
223
- const a = r.value.find((n) => n.sourceId === o.sourceId && n.sourceType === o.sourceType) || null;
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(f.onSourceResized, (o, i) => {
226
- const a = r.value.find((n) => n.sourceId === o.sourceId && n.sourceType === o.sourceType) || null;
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(f.onRightButtonClicked, (o) => {
254
+ }), t.on(m.onRightButtonClicked, (o) => {
229
255
  }));
230
256
  }
231
- H(
232
- () => I.value,
257
+ X(
258
+ () => c.value,
233
259
  async () => {
234
- t && (await t.startPublish(), await t.updatePublishParams(I.value));
260
+ t && (await t.startPublish(), await t.updatePublishParams(c.value), await E());
235
261
  },
236
262
  { immediate: !0, deep: !0 }
237
263
  );
238
- let B = !1;
239
- function ue() {
240
- if (console.log(`${T}initVideoMixerState`), B) {
241
- console.log(`${T}initVideoMixerState already inited`);
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
- O(), W.once("ready", async () => {
245
- x.value && await A();
246
- }), B = !0;
270
+ D(), q.once("ready", async () => {
271
+ await E(), Q.value && await $();
272
+ }), O = !0;
247
273
  }
248
- function Me() {
249
- return ue(), {
250
- isVideoMixerEnabled: x,
251
- publishVideoQuality: m,
274
+ function Ve() {
275
+ return pe(), {
276
+ isVideoMixerEnabled: Q,
277
+ publishVideoQuality: M,
252
278
  mediaSourceList: r,
253
- activeMediaSource: _,
254
- enableLocalVideoMixer: j,
255
- addMediaSource: te,
256
- updateMediaSource: ae,
257
- removeMediaSource: re,
258
- clearMediaSource: ne
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
- x as isVideoMixerEnabled,
263
- Me as useVideoMixerState
288
+ Q as isVideoMixerEnabled,
289
+ Ve as useVideoMixerState
264
290
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tuikit-atomicx-vue3-electron",
3
- "version": "5.2.0",
3
+ "version": "5.2.1",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",