trtc-electron-sdk 12.2.115-beta.2 → 12.2.115-beta.21

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 (34) hide show
  1. package/liteav/MediaMixingDesigner/index.d.ts +12 -8
  2. package/liteav/MediaMixingDesigner/index.js +135 -79
  3. package/liteav/base/DevicePixelRatioObserver.d.ts +12 -0
  4. package/liteav/base/DevicePixelRatioObserver.js +32 -0
  5. package/liteav/base/PromiseStore.d.ts +10 -0
  6. package/liteav/base/PromiseStore.js +58 -0
  7. package/liteav/constant.d.ts +1 -0
  8. package/liteav/constant.js +4 -0
  9. package/liteav/extensions/MediaMixingManager/MediaMixingManager.d.ts +429 -0
  10. package/liteav/extensions/MediaMixingManager/MediaMixingManager.js +1290 -0
  11. package/liteav/extensions/MediaMixingManager/MediaMixingService.d.ts +60 -0
  12. package/liteav/extensions/MediaMixingManager/MediaMixingService.js +80 -0
  13. package/liteav/extensions/MediaMixingManager/StreamLayout/BaseStreamLayoutManager.d.ts +32 -0
  14. package/liteav/extensions/MediaMixingManager/StreamLayout/BaseStreamLayoutManager.js +114 -0
  15. package/liteav/extensions/MediaMixingManager/StreamLayout/CustomStreamLayoutManager.d.ts +11 -0
  16. package/liteav/extensions/MediaMixingManager/StreamLayout/CustomStreamLayoutManager.js +135 -0
  17. package/liteav/extensions/MediaMixingManager/StreamLayout/NoneStreamLayoutManager.d.ts +11 -0
  18. package/liteav/extensions/MediaMixingManager/StreamLayout/NoneStreamLayoutManager.js +73 -0
  19. package/liteav/extensions/MediaMixingManager/StreamLayout/index.d.ts +7 -0
  20. package/liteav/extensions/MediaMixingManager/StreamLayout/index.js +34 -0
  21. package/liteav/extensions/MediaMixingManager/StreamLayout/types.d.ts +25 -0
  22. package/liteav/extensions/MediaMixingManager/StreamLayout/types.js +2 -0
  23. package/liteav/extensions/MediaMixingManager/index.d.ts +4 -227
  24. package/liteav/extensions/MediaMixingManager/index.js +30 -589
  25. package/liteav/extensions/MediaMixingManager/types.d.ts +107 -0
  26. package/liteav/extensions/MediaMixingManager/types.js +26 -0
  27. package/liteav/trtc.d.ts +67 -13
  28. package/liteav/trtc.js +159 -61
  29. package/liteav/trtc_define.d.ts +29 -3
  30. package/liteav/trtc_define.js +97 -29
  31. package/liteav/utils.d.ts +27 -0
  32. package/liteav/utils.js +85 -1
  33. package/package.json +2 -2
  34. package/scripts/download.js +153 -169
@@ -0,0 +1,429 @@
1
+ import { TRTCCameraCaptureParams, Rect, TRTCScreenCaptureProperty } from '../../trtc_define';
2
+ import { TRTCMediaSource, TRTCMediaMixingEncParam, ITRTCMediaMixingManager, TRTCPhoneMirrorParam, TRTCStreamLayout } from './types';
3
+ import { TRTCDeviceManager } from '../DeviceManager';
4
+ declare const NodeTRTCEngine: any;
5
+ /**
6
+ * @namespace TRTCMediaMixingEvent
7
+ * @description 目前只支持 `Windows` 操作系统
8
+ */
9
+ export declare enum TRTCMediaMixingEvent {
10
+ /**
11
+ * @description 媒体源选中事件
12
+ *
13
+ * @event TRTCMediaMixingEvent#onSourceSelected
14
+ * @param {TRTCMediaInfo | null} mediaSource 新选中的媒体源数据,取消选中则为`null`
15
+ */
16
+ onSourceSelected = "onSourceSelected",
17
+ /**
18
+ * @description 媒体源移动事件
19
+ *
20
+ * @event TRTCMediaMixingEvent#onSourceMoved
21
+ * @param {TRTCMediaInfo} mediaSource 被移动的媒体源
22
+ * @param {Rect} rect 移动后的位置、区域数据
23
+ */
24
+ onSourceMoved = "onSourceMoved",
25
+ /**
26
+ * @description 媒体源尺寸变化事件
27
+ *
28
+ * @event TRTCMediaMixingEvent#onSourceResized
29
+ * @param {TRTCMediaInfo} mediaSource 尺寸变化的媒体源
30
+ * @param {Rect} rect 尺寸变化后的位置、区域数据
31
+ */
32
+ onSourceResized = "onSourceResized",
33
+ /**
34
+ * @description 媒体源鼠标右键事件
35
+ *
36
+ * @event TRTCMediaMixingEvent#onRightButtonClicked
37
+ * @param {TRTCMediaInfo} mediaSource 鼠标右键点击的媒体源
38
+ * @param {Object} clickPoint 鼠标右键点击的位置
39
+ * @param {Number} clickPoint.windowX 鼠标右键点击相对窗口的 X 坐标
40
+ * @param {Number} clickPoint.windowY 鼠标右键点击相对窗口的 Y 坐标
41
+ * @param {Number} clickPoint.screenX 鼠标右键点击相对屏幕的 X 坐标
42
+ * @param {Number} clickPoint.screenY 鼠标右键点击相对屏幕的 Y 坐标
43
+ */
44
+ onRightButtonClicked = "onRightButtonClicked",
45
+ /**
46
+ * @description 错误事件
47
+ *
48
+ * @event TRTCMediaMixingEvent#onError
49
+ * @param {TRTCMediaMixingErrorCode} errorCode 错误码
50
+ * @param {String} errorMessage 错误信息
51
+ * @param {TRTCMediaSource|undefined} 错误涉及的媒体源,可能为空
52
+ *
53
+ */
54
+ onError = "onError",
55
+ /**
56
+ * @description 设备插入事件
57
+ *
58
+ * @event TRTCMediaMixingEvent#onSourcePlugged
59
+ * @param {TRTCPhoneMirrorParam} source 投屏手机状态信息
60
+ * @param {String} detail 投屏手机状态变化详情
61
+ */
62
+ onSourcePlugged = "onSourcePlugged",
63
+ /**
64
+ * @description 设备链接事件
65
+ *
66
+ * @event TRTCMediaMixingEvent#onSourceConnected
67
+ * @param {TRTCPhoneMirrorParam} source 投屏手机状态信息
68
+ * @param {String} detail 投屏手机状态变化详情
69
+ */
70
+ onSourceConnected = "onSourceConnected",
71
+ /**
72
+ * @description 设备断开链接事件
73
+ *
74
+ * @event TRTCMediaMixingEvent#onSourceDisconnected
75
+ * @param {TRTCPhoneMirrorParam} source 投屏手机状态信息
76
+ * @param {String} detail 投屏手机状态变化详情
77
+ */
78
+ onSourceDisconnected = "onSourceDisconnected",
79
+ /**
80
+ * @description 设备拔出事件
81
+ *
82
+ * @event TRTCMediaMixingEvent#onSourceUnplugged
83
+ * @param {TRTCPhoneMirrorParam} source 投屏手机状态信息
84
+ * @param {String} detail 投屏手机状态变化详情
85
+ */
86
+ onSourceUnplugged = "onSourceUnplugged",
87
+ /**
88
+ * @description 媒体源画面大小发生变化
89
+ *
90
+ * 当输入媒体源的画面大小发生变化时,会通过该接口返回该输入源最新的尺寸,您可以根据该尺寸来动态调整画面的比例。
91
+ * @event TRTCMediaMixingEvent#onMediaSourceSizeChanged
92
+ * @param {TRTCMediaSource} mediasource 媒体源信息
93
+ * @param {Object} size 媒体源最新的画面大小
94
+ * @param {Number} size.width 媒体源最新宽度
95
+ * @param {Number} size.height 媒体源最新高度
96
+ */
97
+ onMediaSourceSizeChanged = "onMediaSourceSizeChanged",
98
+ onMediaMixingServerLost = "onMediaMixingServerLost"
99
+ }
100
+ /**
101
+ * 本地混流管理器
102
+ *
103
+ * 目前只支持 `Windows` 操作系统
104
+ */
105
+ export declare class TRTCMediaMixingManager implements ITRTCMediaMixingManager {
106
+ private logPrefix;
107
+ private nodeMediaMixingPlugin;
108
+ private nodeTRTCCloud;
109
+ private deviceManager;
110
+ private eventEmitter;
111
+ private promiseStore;
112
+ private publishParams;
113
+ private mediaMixingDesigner;
114
+ private windowID;
115
+ private view;
116
+ private resizeObserver;
117
+ private mixingVideoWidth;
118
+ private mixingVideoHeight;
119
+ private sourceList;
120
+ private streamLayoutManager;
121
+ private trtcParamsStore;
122
+ private paramsStore;
123
+ private autoControlServer;
124
+ constructor(options: {
125
+ deviceManager: TRTCDeviceManager;
126
+ nodeTRTCCloud: typeof NodeTRTCEngine.NodeRemoteTRTCCloud;
127
+ trtcParamsStore: Record<string, any>;
128
+ autoControlServer: boolean;
129
+ });
130
+ destroy(): Promise<void>;
131
+ /**
132
+ * @deprecated
133
+ * @private
134
+ * 设置视频流预览参数
135
+ *
136
+ * @param windowID {Number|Uint8Array} - 操作系统层的窗口 ID,Electron 下可以通过 Electron API [BrowserWindow.getNativeWindowHandle()]{@link https://www.electronjs.org/docs/latest/api/browser-window#wingetnativewindowhandle} 接口获取
137
+ * @param viewOrRegion {HTMLElement | Rect | null} - 本地混流视频显示位置
138
+ * - 传入 HTMLElement 元素,则 SDK 将本地混流视频显示在 HTMLElement 元素内,同时支持点击选中、移动、缩放媒体源,支持触发右键菜单事件。HTMLElement 元素必须是块元素。
139
+ * - 传入 Rect 显示区域,则 SDK 将本地混流视频显示在 Rect 指定区域内,不支持点击选中、移动、缩放媒体源,不支持触发右键菜单事件,这些功能您可以在 Web 页面中自行实现。
140
+ * - 传入 null 则 SDK 将停止显示本地混流视频。
141
+ *
142
+ * @example
143
+ * // Display in HTML Element
144
+ * import TRTCCloud from 'trtc-electron-sdk';
145
+ *
146
+ * const trtcCloud = TRTCCloud.getTRTCShareInstance({
147
+ * isIPCMode: true
148
+ * });
149
+ *
150
+ * const mediaMixingManager = trtcCloud.getMediaMixingManager();
151
+ *
152
+ * const windowID = 0; // Use Electron API BrowserWindow.getNativeWindowHandle()
153
+ * const previewDOM = document.getElementById("preview-local-mixed-media-stream");
154
+ * mediaMixingManager.setDisplayParams(windowID, previewDOM);
155
+ *
156
+ * @example
157
+ * // Display in a rectangle section
158
+ * import TRTCCloud from 'trtc-electron-sdk';
159
+ *
160
+ * const trtcCloud = TRTCCloud.getTRTCShareInstance({
161
+ * isIPCMode: true
162
+ * });
163
+ *
164
+ * const mediaMixingManager = trtcCloud.getMediaMixingManager();
165
+ *
166
+ * const windowID = 0; // Use Electron API BrowserWindow.getNativeWindowHandle()
167
+ * const previewDOM = document.getElementById("preview-local-mixed-media-stream");
168
+ * const domRect = previewDOM.getBoundingClientRect();
169
+ * const rect = {
170
+ * left: domRect.left * window.devicePixelRatio,
171
+ * right: domRect.right * window.devicePixelRatio,
172
+ * top: domRect.top * window.devicePixelRatio,
173
+ * bottom: domRect.bottom * window.devicePixelRatio
174
+ * };
175
+ *
176
+ * mediaMixingManager.setDisplayParams(windowID, rect);
177
+ */
178
+ setDisplayParams(windowID: number | Uint8Array, viewOrRegion: HTMLElement | Rect | null): void;
179
+ /**
180
+ * 设置视频流预览区域
181
+ *
182
+ * @param windowID {Uint8Array|Number} - 操作系统层的窗口 ID,Electron 下可以通过 Electron API [BrowserWindow.getNativeWindowHandle()]{@link https://www.electronjs.org/docs/latest/api/browser-window#wingetnativewindowhandle} 接口获取
183
+ * @param viewOrRegion {HTMLElement | Rect | null} - 本地混流视频显示位置
184
+ * - 传入 HTMLElement 元素,则 SDK 将本地混流视频显示在 HTMLElement 元素内,同时支持点击选中、移动、缩放媒体源,支持触发右键菜单事件。HTMLElement 元素必须是块元素。
185
+ * - 传入 Rect 显示区域,则 SDK 将本地混流视频显示在 Rect 指定区域内,不支持点击选中、移动、缩放媒体源,不支持触发右键菜单事件,这些功能您可以在 Web 页面中自行实现。
186
+ * - 传入 null 则 SDK 将停止显示本地混流视频。
187
+ *
188
+ * @example
189
+ * // Display in HTML Element
190
+ * import TRTCCloud from 'trtc-electron-sdk';
191
+ *
192
+ * const trtcCloud = TRTCCloud.getTRTCShareInstance({
193
+ * isIPCMode: true
194
+ * });
195
+ *
196
+ * const mediaMixingManager = trtcCloud.getMediaMixingManager();
197
+ *
198
+ * const windowID = 0; // Use Electron API BrowserWindow.getNativeWindowHandle()
199
+ * const previewDOM = document.getElementById("preview-local-mixed-media-stream");
200
+ * mediaMixingManager.bindPreviewArea(windowID, previewDOM);
201
+ *
202
+ * @example
203
+ * // Display in a rectangle section
204
+ * import TRTCCloud from 'trtc-electron-sdk';
205
+ *
206
+ * const trtcCloud = TRTCCloud.getTRTCShareInstance({
207
+ * isIPCMode: true
208
+ * });
209
+ *
210
+ * const mediaMixingManager = trtcCloud.getMediaMixingManager();
211
+ *
212
+ * const windowID = 0; // Use Electron API BrowserWindow.getNativeWindowHandle()
213
+ * const previewDOM = document.getElementById("preview-local-mixed-media-stream");
214
+ * const domRect = previewDOM.getBoundingClientRect();
215
+ * const rect = {
216
+ * left: domRect.left * window.devicePixelRatio,
217
+ * right: domRect.right * window.devicePixelRatio,
218
+ * top: domRect.top * window.devicePixelRatio,
219
+ * bottom: domRect.bottom * window.devicePixelRatio
220
+ * };
221
+ *
222
+ * mediaMixingManager.bindPreviewArea(windowID, rect);
223
+ */
224
+ bindPreviewArea(windowID: Uint8Array | number, viewOrRegion: HTMLElement | Rect | null): void;
225
+ /**
226
+ * 添加本地混流媒体源
227
+ * @param mediaSource {TRTCMediaSource} - 媒体源信息
228
+ * @returns {Promise<void>}
229
+ */
230
+ addMediaSource(mediaSource: TRTCMediaSource): Promise<void>;
231
+ /**
232
+ * 删除本地混流媒体源
233
+ * @param mediaSource {TRTCMediaSource} - 媒体源信息
234
+ * @returns {Promise<void>}
235
+ */
236
+ removeMediaSource(mediaSource: TRTCMediaSource): Promise<void>;
237
+ /**
238
+ * 更新本地混流媒体源
239
+ * @param mediaSource {TRTCMediaSource} - 媒体源信息
240
+ * @returns {Promise<void>}
241
+ */
242
+ updateMediaSource(mediaSource: TRTCMediaSource): Promise<void>;
243
+ /**
244
+ * 设置摄像头采集参数
245
+ * @param cameraID {string} - 摄像头 ID
246
+ * @param params {TRTCCameraCaptureParams} - 摄像头采集参数
247
+ */
248
+ setCameraCaptureParam(cameraID: string, params: TRTCCameraCaptureParams): void;
249
+ /**
250
+ * 设置手机投屏参数
251
+ * @param phoneMirrorSourceId {string} - 手机投屏媒体源 ID
252
+ * @param param {TRTCPhoneMirrorParam} - 手机投屏参数
253
+ */
254
+ setPhoneMirrorParam(phoneMirrorSourceId: string, param: TRTCPhoneMirrorParam): void;
255
+ /**
256
+ * 设置屏幕采集参数
257
+ * @param screenOrWindowID {String} - 屏幕 ID 或 窗口 ID
258
+ * @param property {TRTCScreenCaptureProperty} - 屏幕采集属性
259
+ */
260
+ setScreenCaptureProperty(screenOrWindowID: string, property: TRTCScreenCaptureProperty): void;
261
+ /**
262
+ * 本地混流开始推流
263
+ * @returns {Promise<void>}
264
+ */
265
+ startPublish(): Promise<void>;
266
+ /**
267
+ * 本地混流停止推流
268
+ * @returns {Promise<void>}
269
+ */
270
+ stopPublish(): Promise<void>;
271
+ /**
272
+ * 更新本地混流编码参数
273
+ * @param params {TRTCMediaMixingEncParam} - 推流视频编码参数、背景色等参数
274
+ * @returns {Promise<void>}
275
+ */
276
+ updatePublishParams(params: TRTCMediaMixingEncParam): Promise<void>;
277
+ /**
278
+ * 设置连麦视频流布局
279
+ *
280
+ * @param layout {TRTCStreamLayout} - 视频流布局信息
281
+ *
282
+ * @example
283
+ * // 设置自定义连麦布局
284
+ * import TRTCCloud, { TRTCStreamLayout, TRTCStreamLayoutMode, TRTCVideoFillMode } from 'trtc-electron-sdk';
285
+ *
286
+ * const trtcCloud = TRTCCloud.getTRTCShareInstance({
287
+ * isIPCMode: true
288
+ * });
289
+ *
290
+ * const mediaMixingManager = trtcCloud.getMediaMixingManager();
291
+ * if (mediaMixingManager) {
292
+ * const streamLayout: TRTCStreamLayout = {
293
+ * "layoutMode": TRTCStreamLayoutMode.Custom,
294
+ * "userList": [
295
+ * {
296
+ * "userId": "", // 本地用户 userId
297
+ * "rect": {
298
+ * "left": 0,
299
+ * "top": 0,
300
+ * "right": 296,
301
+ * "bottom": 494
302
+ * },
303
+ * "fillMode": TRTCVideoFillMode.TRTCVideoFillMode_Fill, // 视频填满显示区
304
+ * "zOrder": 0
305
+ * },
306
+ * {
307
+ * "userId": "849014",
308
+ * "rect": {
309
+ * "left": 296,
310
+ * "top": 0,
311
+ * "right": 592,
312
+ * "bottom": 247
313
+ * },
314
+ * "fillMode": TRTCVideoFillMode.TRTCVideoFillMode_Fill,
315
+ * "zOrder": 1
316
+ * },
317
+ * {
318
+ * "userId": "p20",
319
+ * "rect": {
320
+ * "left": 296,
321
+ * "top": 247,
322
+ * "right": 592,
323
+ * "bottom": 494
324
+ * },
325
+ * "fillMode": TRTCVideoFillMode.TRTCVideoFillMode_Fill,
326
+ * "zOrder": 2
327
+ * }
328
+ * ]
329
+ * };
330
+ * mediaMixingManager.setStreamLayout(streamLayout);
331
+ * }
332
+ *
333
+ * @example
334
+ * // 清除连麦布局,本地混流恢复居中填充显示(默认效果)
335
+ * import TRTCCloud, { TRTCStreamLayout, TRTCStreamLayoutMode, TRTCVideoFillMode } from 'trtc-electron-sdk';
336
+ *
337
+ * const trtcCloud = TRTCCloud.getTRTCShareInstance({
338
+ * isIPCMode: true
339
+ * });
340
+ *
341
+ * const mediaMixingManager = trtcCloud.getMediaMixingManager();
342
+ * if (mediaMixingManager) {
343
+ * const streamLayout: TRTCStreamLayout = {
344
+ * "layoutMode": TRTCStreamLayoutMode.None
345
+ * };
346
+ * mediaMixingManager.setStreamLayout(streamLayout);
347
+ * }
348
+ */
349
+ setStreamLayout(layout: TRTCStreamLayout): void;
350
+ /**
351
+ * @private
352
+ * @deprecated
353
+ */
354
+ setMediaServerPath(path?: string): Promise<void>;
355
+ /**
356
+ * @private
357
+ * 启动独立混流渲染进程
358
+ *
359
+ * 开发模式,默认路径:node_modules\\trtc-electron-sdk\\build\\Release\\liteav_media_server.exe
360
+ * 构建模式,默认路径:${resourcesPath}\\liteav_media_server.exe
361
+ *
362
+ * 如果用户应用有特殊配置,默认路径可能找不到服务进程程序,需要自行传入路径。
363
+ *
364
+ * @param path {string} - 混流渲染程序路径,不传入参数时,SDK 内部按照默认路径启动服务进程。
365
+ *
366
+ * @returns {Promise<void>}
367
+ */
368
+ startMediaMixingServer(path?: string): Promise<void>;
369
+ /**
370
+ * @private
371
+ * 关闭独立混流渲染进程
372
+ *
373
+ * @returns {Promise<void>}
374
+ */
375
+ stopMediaMixingServer(): Promise<void>;
376
+ /**
377
+ * 注册事件监听
378
+ *
379
+ * @param event {TRTCMediaMixingEvent} - 事件名称
380
+ * @param func {Function} - 事件回调函数
381
+ */
382
+ on(event: TRTCMediaMixingEvent, func: (...args: any[]) => void): void;
383
+ /**
384
+ * 取消事件监听
385
+ *
386
+ * @param event {TRTCMediaMixingEvent} - 事件名
387
+ * @param func {Function} - 事件回调函数
388
+ */
389
+ off(event: TRTCMediaMixingEvent, func: (...args: any[]) => void): void;
390
+ private initResizeObserver;
391
+ private onPreviewAreaResize;
392
+ private onVisibilityChange;
393
+ private setDisplayRect;
394
+ private createDesigner;
395
+ private destroyDesigner;
396
+ private createOrUpdateLayoutManager;
397
+ private destroyLayoutManager;
398
+ private updateMixingVideoSize;
399
+ private listenDesignerEvent;
400
+ private unlistenDesignerEvent;
401
+ private onError;
402
+ private onSourceSelected;
403
+ private onSourceMoved;
404
+ private onSourceResized;
405
+ private onRightButtonClicked;
406
+ private isSameMediaSource;
407
+ private isMediaSourceExisted;
408
+ private findMediaSourceIndex;
409
+ private findSelectedMediaSource;
410
+ private unselectMediaSource;
411
+ private handleCppCallbackEvent;
412
+ private onMediaSourceAdded;
413
+ private onMediaSourceRemoved;
414
+ private onMediaSourceSizeChanged;
415
+ private onPhoneMirrorSourceChanged;
416
+ private onMediaServerState;
417
+ private onMediaMixingServerLost;
418
+ private onCallExperimentalAPIFinish;
419
+ private recoverMediaMixingServer;
420
+ private onDevicePixelRatioChange;
421
+ startCameraDeviceTest(windowID: number | Uint8Array, rect?: Rect): Promise<number>;
422
+ stopCameraDeviceTest(): Promise<number>;
423
+ setCameraTestRenderMirror(mirror: boolean): void;
424
+ setCameraTestDeviceId(cameraId: string): void;
425
+ setCameraTestResolution(width: number, height: number): void;
426
+ setCameraTestVideoPluginPath(path: string): void;
427
+ setCameraTestVideoPluginParameter(params: string): void;
428
+ }
429
+ export default TRTCMediaMixingManager;