trtc-electron-sdk 10.6.115-beta.2 → 10.6.115-beta.4
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.
- package/liteav/LocalMediaTranscoder/index.d.ts +57 -33
- package/liteav/LocalMediaTranscoder/index.js +88 -39
- package/liteav/Renderer/types.d.ts +2 -2
- package/liteav/trtc.d.ts +3 -3
- package/liteav/trtc.js +37 -7
- package/liteav/trtc_define.d.ts +11 -2
- package/liteav/trtc_define.js +11 -2
- package/package.json +1 -1
|
@@ -112,7 +112,7 @@ export declare enum TRTCLocalMediaTranscodingSourceType {
|
|
|
112
112
|
MediaSourceImage = 2,
|
|
113
113
|
MediaSourceRemoteVideo = 3
|
|
114
114
|
}
|
|
115
|
-
export
|
|
115
|
+
export type TRTCLocalMediaTranscodingSource = {
|
|
116
116
|
sourceType: TRTCLocalMediaTranscodingSourceType;
|
|
117
117
|
cameraDeviceId?: string;
|
|
118
118
|
screenSourceId?: string;
|
|
@@ -120,8 +120,9 @@ export declare type TRTCLocalMediaTranscodingSource = {
|
|
|
120
120
|
userId?: string;
|
|
121
121
|
rect: Rect;
|
|
122
122
|
zOrder: number;
|
|
123
|
+
renderParams: TRTCRenderParams;
|
|
123
124
|
};
|
|
124
|
-
export
|
|
125
|
+
export type TRTCLocalMediaTranscodingParams = {
|
|
125
126
|
inputSourceList: TRTCLocalMediaTranscodingSource[];
|
|
126
127
|
videoEncoderParams: TRTCVideoEncParam;
|
|
127
128
|
canvasColor: number;
|
|
@@ -132,7 +133,7 @@ export declare enum TRTCCameraCaptureMode {
|
|
|
132
133
|
CameraResolutionStrategyHighQuality = 2,
|
|
133
134
|
CameraCaptureManual = 3
|
|
134
135
|
}
|
|
135
|
-
export
|
|
136
|
+
export type TRTCCameraCaptureParams = {
|
|
136
137
|
/** 摄像头采集偏好 */
|
|
137
138
|
mode: TRTCCameraCaptureMode;
|
|
138
139
|
/** 采集图像宽度 */
|
|
@@ -190,43 +191,36 @@ export declare type TRTCCameraCaptureParams = {
|
|
|
190
191
|
* console.log(`onScreenSourceStopped { sourceId:${sourceId}, reason:${reason} }`);
|
|
191
192
|
* });
|
|
192
193
|
* // 监听图片事件
|
|
193
|
-
*
|
|
194
|
+
* localMediaTranscoder.on('onImageSourceStarted', (imagePath: string, errCode: number, errMsg: string) => {
|
|
194
195
|
* console.log(`onImageSourceStarted { imagePath:${imagePath} errCode:${errCode} errMsg:${errMsg} }`);
|
|
195
196
|
* });
|
|
196
|
-
*
|
|
197
|
+
* localMediaTranscoder.on('onImageSourceStopped', (imagePath: string) => {
|
|
197
198
|
* console.log(`onImageSourceStopped { imagePath:${imagePath} }`);
|
|
198
199
|
* });
|
|
199
200
|
*
|
|
200
201
|
* // 开启摄像头一
|
|
201
|
-
* localMediaTranscoder.startCameraSource(
|
|
202
|
+
* localMediaTranscoder.startCameraSource(cameraList[0].deviceId);
|
|
203
|
+
* localMediaTranscoder.setCameraCaptureParams(
|
|
202
204
|
* cameraList[0].deviceId,
|
|
203
205
|
* {
|
|
204
206
|
* mode: TRTCCameraCaptureMode.CameraResolutionStrategyAuto,
|
|
205
|
-
* width:
|
|
206
|
-
* height:
|
|
207
|
-
* },
|
|
208
|
-
* {
|
|
209
|
-
* rotation: TRTCVideoRotation.TRTCVideoRotation0,
|
|
210
|
-
* fillMode: TRTCVideoFillMode.TRTCVideoFillMode_Fit,
|
|
211
|
-
* mirrorType: TRTCVideoMirrorType.TRTCVideoMirrorType_Disable,
|
|
207
|
+
* width: 480,
|
|
208
|
+
* height: 480,
|
|
212
209
|
* }
|
|
213
210
|
* );
|
|
214
211
|
*
|
|
215
212
|
* // 开启摄像头二
|
|
216
|
-
* localMediaTranscoder.startCameraSource(
|
|
213
|
+
* localMediaTranscoder.startCameraSource(cameraList[1].deviceId);
|
|
214
|
+
* localMediaTranscoder.setCameraCaptureParams(
|
|
217
215
|
* cameraList[1].deviceId,
|
|
218
216
|
* {
|
|
219
|
-
*
|
|
220
|
-
*
|
|
221
|
-
*
|
|
222
|
-
* },
|
|
223
|
-
* {
|
|
224
|
-
* rotation: TRTCVideoRotation.TRTCVideoRotation0,
|
|
225
|
-
* fillMode: TRTCVideoFillMode.TRTCVideoFillMode_Fit,
|
|
226
|
-
* mirrorType: TRTCVideoMirrorType.TRTCVideoMirrorType_Disable
|
|
217
|
+
* mode: TRTCCameraCaptureMode.CameraResolutionStrategyAuto,
|
|
218
|
+
* width: 960,
|
|
219
|
+
* height: 540
|
|
227
220
|
* }
|
|
228
221
|
* );
|
|
229
222
|
*
|
|
223
|
+
*
|
|
230
224
|
* // 开启屏幕一
|
|
231
225
|
* localMediaTranscoder.startScreenSource(screenSourceList[0], {top:10, left:10, right:1200, bottom:800});
|
|
232
226
|
*
|
|
@@ -249,14 +243,22 @@ export declare type TRTCCameraCaptureParams = {
|
|
|
249
243
|
* cameraDeviceId: cameraList[0].deviceId,
|
|
250
244
|
* rect: { left: 0, top: 0, right: 320, bottom: 180 },
|
|
251
245
|
* zOrder: 1,
|
|
252
|
-
*
|
|
246
|
+
* renderParams: {
|
|
247
|
+
* rotation: TRTCVideoRotation.TRTCVideoRotation0,
|
|
248
|
+
* fillMode: TRTCVideoFillMode.TRTCVideoFillMode_Fit,
|
|
249
|
+
* mirrorType: TRTCVideoMirrorType.TRTCVideoMirrorType_Disable
|
|
250
|
+
* },
|
|
253
251
|
* },
|
|
254
252
|
* { // camera 2
|
|
255
253
|
* sourceType: TRTCLocalMediaTranscodingSourceType.MediaSourceCamera,
|
|
256
254
|
* cameraDeviceId: cameraList[1].deviceId,
|
|
257
255
|
* rect: {left: 320 + 20, top: 180 + 20, right: 640 + 20, bottom: 360 + 20},
|
|
258
256
|
* zOrder: 2,
|
|
259
|
-
*
|
|
257
|
+
* renderParams: {
|
|
258
|
+
* rotation: TRTCVideoRotation.TRTCVideoRotation90,
|
|
259
|
+
* fillMode: TRTCVideoFillMode.TRTCVideoFillMode_Fill,
|
|
260
|
+
* mirrorType: TRTCVideoMirrorType.TRTCVideoMirrorType_Enable
|
|
261
|
+
* },
|
|
260
262
|
* },
|
|
261
263
|
* {
|
|
262
264
|
* // screen 1
|
|
@@ -264,7 +266,11 @@ export declare type TRTCCameraCaptureParams = {
|
|
|
264
266
|
* screenSourceId: screenSourceList[0].sourceId,
|
|
265
267
|
* rect: {left: 320 + 20, top: 0, right: 640 + 20, bottom: 180},
|
|
266
268
|
* zOrder: 3,
|
|
267
|
-
*
|
|
269
|
+
* renderParams: {
|
|
270
|
+
* rotation: TRTCVideoRotation.TRTCVideoRotation180,
|
|
271
|
+
* fillMode: TRTCVideoFillMode.TRTCVideoFillMode_Fit,
|
|
272
|
+
* mirrorType: TRTCVideoMirrorType.TRTCVideoMirrorType_Enable
|
|
273
|
+
* },
|
|
268
274
|
* },
|
|
269
275
|
* {
|
|
270
276
|
* // screen 2
|
|
@@ -272,21 +278,33 @@ export declare type TRTCCameraCaptureParams = {
|
|
|
272
278
|
* screenSourceId: screenSourceList[1].sourceId,
|
|
273
279
|
* rect: {left: 0, top: 180 + 20, right: 320, bottom: 360 + 20},
|
|
274
280
|
* zOrder: 4,
|
|
275
|
-
*
|
|
281
|
+
* renderParams: {
|
|
282
|
+
* rotation: TRTCVideoRotation.TRTCVideoRotation270,
|
|
283
|
+
* fillMode: TRTCVideoFillMode.TRTCVideoFillMode_Fill,
|
|
284
|
+
* mirrorType: TRTCVideoMirrorType.TRTCVideoMirrorType_Auto
|
|
285
|
+
* },
|
|
276
286
|
* },
|
|
277
287
|
* { // image 1
|
|
278
288
|
* sourceType: TRTCLocalMediaTranscodingSourceType.MediaSourceImage,
|
|
279
289
|
* imagePath: '<please set valid image path>',
|
|
280
290
|
* rect: {left: 0, top: 360 + 40, right: 320, bottom: 540 + 40},
|
|
281
291
|
* zOrder: 5,
|
|
282
|
-
*
|
|
292
|
+
* renderParams: {
|
|
293
|
+
* rotation: TRTCVideoRotation.TRTCVideoRotation90, // 不会生效,参数设置将被忽略
|
|
294
|
+
* fillMode: TRTCVideoFillMode.TRTCVideoFillMode_Fit,
|
|
295
|
+
* mirrorType: TRTCVideoMirrorType.TRTCVideoMirrorType_Enable // 不会生效,参数设置将被忽略
|
|
296
|
+
* },
|
|
283
297
|
* },
|
|
284
298
|
* { // image 2
|
|
285
299
|
* sourceType: TRTCLocalMediaTranscodingSourceType.MediaSourceImage,
|
|
286
300
|
* imagePath: '<please set valid image path>',
|
|
287
301
|
* rect: {left: 320 + 20, top: 360 + 40, right: 640, bottom: 540 + 40},
|
|
288
302
|
* zOrder: 5,
|
|
289
|
-
*
|
|
303
|
+
* renderParams: {
|
|
304
|
+
* rotation: TRTCVideoRotation.TRTCVideoRotation0, // 不会生效,参数设置将被忽略
|
|
305
|
+
* fillMode: TRTCVideoFillMode.TRTCVideoFillMode_Fill,
|
|
306
|
+
* mirrorType: TRTCVideoMirrorType.TRTCVideoMirrorType_Disable // 不会生效,参数设置将被忽略
|
|
307
|
+
* },
|
|
290
308
|
* }
|
|
291
309
|
* ],
|
|
292
310
|
* videoEncoderParams: {
|
|
@@ -343,12 +361,17 @@ declare class TRTCLocalMediaTranscoder extends EventEmitter {
|
|
|
343
361
|
* 启动摄像头采集
|
|
344
362
|
*
|
|
345
363
|
* @param deviceId {String} - 摄像头设备 Id
|
|
346
|
-
* @param transcodeParams {TRTCCameraCaptureParams} - 指定摄像头采集分辨率和帧率
|
|
347
|
-
* @param renderParams {TRTCRenderParams} - 指定摄像头数据源是否旋转、镜像和填充模式
|
|
348
364
|
*
|
|
349
365
|
* @fires [onCameraSourceStarted]{@link TRTCLocalMediaTranscodingEvent#onCameraSourceStarted}
|
|
350
366
|
*/
|
|
351
|
-
startCameraSource(deviceId: string
|
|
367
|
+
startCameraSource(deviceId: string): void;
|
|
368
|
+
/**
|
|
369
|
+
* 设置摄像头采集参数
|
|
370
|
+
*
|
|
371
|
+
* @param deviceId {String} - 摄像头设备 Id
|
|
372
|
+
* @param cameraCaptureParams {TRTCCameraCaptureParams} - 指定摄像头采集分辨率和帧率
|
|
373
|
+
*/
|
|
374
|
+
setCameraCaptureParams(deviceId: string, cameraCaptureParams: TRTCCameraCaptureParams): void;
|
|
352
375
|
/**
|
|
353
376
|
* 停止摄像头采集
|
|
354
377
|
* @param deviceId {String} - 摄像头设备 Id
|
|
@@ -389,10 +412,11 @@ declare class TRTCLocalMediaTranscoder extends EventEmitter {
|
|
|
389
412
|
removeImageSource(path: string): void;
|
|
390
413
|
/**
|
|
391
414
|
* 设置本地混流转码视频预览节点
|
|
392
|
-
* @param el {HTMLElement} -
|
|
415
|
+
* @param el {HTMLElement | null} - 如果传入的是 HTML 元素,必须是块元素;传入 null 时,会停止视频预览
|
|
393
416
|
*/
|
|
394
|
-
setMixedVideoRenderView(el: HTMLElement): void;
|
|
417
|
+
setMixedVideoRenderView(el: HTMLElement | null): void;
|
|
395
418
|
private setMixedVideoFrameRenderCallback;
|
|
419
|
+
private unsetMixedVideoFrameRenderCallback;
|
|
396
420
|
private setEventCallback;
|
|
397
421
|
private renderMixedVideoFrame;
|
|
398
422
|
}
|
|
@@ -165,7 +165,7 @@ var TRTCLocalMediaTranscodingSourceType;
|
|
|
165
165
|
* 当 sourceType 为 TRTCMediaSourceCamera 时此字段有效,不过当前版本的 SDK 还不支持这个能力。
|
|
166
166
|
* @property {Rect} rect - 【字段含义】指定该路画面的坐标区域(单位:像素)。
|
|
167
167
|
* @property {Number} zOrder - 【字段含义】指定该路画面的层级(取值范围:0 - 15,不可重复)。
|
|
168
|
-
* @property {
|
|
168
|
+
* @property {TRTCRenderParams} renderParams - 【字段含义】指定该路数据源是否旋转、镜像和填充模式。
|
|
169
169
|
*/
|
|
170
170
|
const TRTCLocalMediaTranscodingSource_HACK_JSDOC = null;
|
|
171
171
|
/**
|
|
@@ -279,43 +279,36 @@ const TRTCCameraCaptureParams_HACK_JSDOC = null;
|
|
|
279
279
|
* console.log(`onScreenSourceStopped { sourceId:${sourceId}, reason:${reason} }`);
|
|
280
280
|
* });
|
|
281
281
|
* // 监听图片事件
|
|
282
|
-
*
|
|
282
|
+
* localMediaTranscoder.on('onImageSourceStarted', (imagePath: string, errCode: number, errMsg: string) => {
|
|
283
283
|
* console.log(`onImageSourceStarted { imagePath:${imagePath} errCode:${errCode} errMsg:${errMsg} }`);
|
|
284
284
|
* });
|
|
285
|
-
*
|
|
285
|
+
* localMediaTranscoder.on('onImageSourceStopped', (imagePath: string) => {
|
|
286
286
|
* console.log(`onImageSourceStopped { imagePath:${imagePath} }`);
|
|
287
287
|
* });
|
|
288
288
|
*
|
|
289
289
|
* // 开启摄像头一
|
|
290
|
-
* localMediaTranscoder.startCameraSource(
|
|
290
|
+
* localMediaTranscoder.startCameraSource(cameraList[0].deviceId);
|
|
291
|
+
* localMediaTranscoder.setCameraCaptureParams(
|
|
291
292
|
* cameraList[0].deviceId,
|
|
292
293
|
* {
|
|
293
294
|
* mode: TRTCCameraCaptureMode.CameraResolutionStrategyAuto,
|
|
294
|
-
* width:
|
|
295
|
-
* height:
|
|
296
|
-
* },
|
|
297
|
-
* {
|
|
298
|
-
* rotation: TRTCVideoRotation.TRTCVideoRotation0,
|
|
299
|
-
* fillMode: TRTCVideoFillMode.TRTCVideoFillMode_Fit,
|
|
300
|
-
* mirrorType: TRTCVideoMirrorType.TRTCVideoMirrorType_Disable,
|
|
295
|
+
* width: 480,
|
|
296
|
+
* height: 480,
|
|
301
297
|
* }
|
|
302
298
|
* );
|
|
303
299
|
*
|
|
304
300
|
* // 开启摄像头二
|
|
305
|
-
* localMediaTranscoder.startCameraSource(
|
|
301
|
+
* localMediaTranscoder.startCameraSource(cameraList[1].deviceId);
|
|
302
|
+
* localMediaTranscoder.setCameraCaptureParams(
|
|
306
303
|
* cameraList[1].deviceId,
|
|
307
304
|
* {
|
|
308
|
-
*
|
|
309
|
-
*
|
|
310
|
-
*
|
|
311
|
-
* },
|
|
312
|
-
* {
|
|
313
|
-
* rotation: TRTCVideoRotation.TRTCVideoRotation0,
|
|
314
|
-
* fillMode: TRTCVideoFillMode.TRTCVideoFillMode_Fit,
|
|
315
|
-
* mirrorType: TRTCVideoMirrorType.TRTCVideoMirrorType_Disable
|
|
305
|
+
* mode: TRTCCameraCaptureMode.CameraResolutionStrategyAuto,
|
|
306
|
+
* width: 960,
|
|
307
|
+
* height: 540
|
|
316
308
|
* }
|
|
317
309
|
* );
|
|
318
310
|
*
|
|
311
|
+
*
|
|
319
312
|
* // 开启屏幕一
|
|
320
313
|
* localMediaTranscoder.startScreenSource(screenSourceList[0], {top:10, left:10, right:1200, bottom:800});
|
|
321
314
|
*
|
|
@@ -338,14 +331,22 @@ const TRTCCameraCaptureParams_HACK_JSDOC = null;
|
|
|
338
331
|
* cameraDeviceId: cameraList[0].deviceId,
|
|
339
332
|
* rect: { left: 0, top: 0, right: 320, bottom: 180 },
|
|
340
333
|
* zOrder: 1,
|
|
341
|
-
*
|
|
334
|
+
* renderParams: {
|
|
335
|
+
* rotation: TRTCVideoRotation.TRTCVideoRotation0,
|
|
336
|
+
* fillMode: TRTCVideoFillMode.TRTCVideoFillMode_Fit,
|
|
337
|
+
* mirrorType: TRTCVideoMirrorType.TRTCVideoMirrorType_Disable
|
|
338
|
+
* },
|
|
342
339
|
* },
|
|
343
340
|
* { // camera 2
|
|
344
341
|
* sourceType: TRTCLocalMediaTranscodingSourceType.MediaSourceCamera,
|
|
345
342
|
* cameraDeviceId: cameraList[1].deviceId,
|
|
346
343
|
* rect: {left: 320 + 20, top: 180 + 20, right: 640 + 20, bottom: 360 + 20},
|
|
347
344
|
* zOrder: 2,
|
|
348
|
-
*
|
|
345
|
+
* renderParams: {
|
|
346
|
+
* rotation: TRTCVideoRotation.TRTCVideoRotation90,
|
|
347
|
+
* fillMode: TRTCVideoFillMode.TRTCVideoFillMode_Fill,
|
|
348
|
+
* mirrorType: TRTCVideoMirrorType.TRTCVideoMirrorType_Enable
|
|
349
|
+
* },
|
|
349
350
|
* },
|
|
350
351
|
* {
|
|
351
352
|
* // screen 1
|
|
@@ -353,7 +354,11 @@ const TRTCCameraCaptureParams_HACK_JSDOC = null;
|
|
|
353
354
|
* screenSourceId: screenSourceList[0].sourceId,
|
|
354
355
|
* rect: {left: 320 + 20, top: 0, right: 640 + 20, bottom: 180},
|
|
355
356
|
* zOrder: 3,
|
|
356
|
-
*
|
|
357
|
+
* renderParams: {
|
|
358
|
+
* rotation: TRTCVideoRotation.TRTCVideoRotation180,
|
|
359
|
+
* fillMode: TRTCVideoFillMode.TRTCVideoFillMode_Fit,
|
|
360
|
+
* mirrorType: TRTCVideoMirrorType.TRTCVideoMirrorType_Enable
|
|
361
|
+
* },
|
|
357
362
|
* },
|
|
358
363
|
* {
|
|
359
364
|
* // screen 2
|
|
@@ -361,21 +366,33 @@ const TRTCCameraCaptureParams_HACK_JSDOC = null;
|
|
|
361
366
|
* screenSourceId: screenSourceList[1].sourceId,
|
|
362
367
|
* rect: {left: 0, top: 180 + 20, right: 320, bottom: 360 + 20},
|
|
363
368
|
* zOrder: 4,
|
|
364
|
-
*
|
|
369
|
+
* renderParams: {
|
|
370
|
+
* rotation: TRTCVideoRotation.TRTCVideoRotation270,
|
|
371
|
+
* fillMode: TRTCVideoFillMode.TRTCVideoFillMode_Fill,
|
|
372
|
+
* mirrorType: TRTCVideoMirrorType.TRTCVideoMirrorType_Auto
|
|
373
|
+
* },
|
|
365
374
|
* },
|
|
366
375
|
* { // image 1
|
|
367
376
|
* sourceType: TRTCLocalMediaTranscodingSourceType.MediaSourceImage,
|
|
368
377
|
* imagePath: '<please set valid image path>',
|
|
369
378
|
* rect: {left: 0, top: 360 + 40, right: 320, bottom: 540 + 40},
|
|
370
379
|
* zOrder: 5,
|
|
371
|
-
*
|
|
380
|
+
* renderParams: {
|
|
381
|
+
* rotation: TRTCVideoRotation.TRTCVideoRotation90, // 不会生效,参数设置将被忽略
|
|
382
|
+
* fillMode: TRTCVideoFillMode.TRTCVideoFillMode_Fit,
|
|
383
|
+
* mirrorType: TRTCVideoMirrorType.TRTCVideoMirrorType_Enable // 不会生效,参数设置将被忽略
|
|
384
|
+
* },
|
|
372
385
|
* },
|
|
373
386
|
* { // image 2
|
|
374
387
|
* sourceType: TRTCLocalMediaTranscodingSourceType.MediaSourceImage,
|
|
375
388
|
* imagePath: '<please set valid image path>',
|
|
376
389
|
* rect: {left: 320 + 20, top: 360 + 40, right: 640, bottom: 540 + 40},
|
|
377
390
|
* zOrder: 5,
|
|
378
|
-
*
|
|
391
|
+
* renderParams: {
|
|
392
|
+
* rotation: TRTCVideoRotation.TRTCVideoRotation0, // 不会生效,参数设置将被忽略
|
|
393
|
+
* fillMode: TRTCVideoFillMode.TRTCVideoFillMode_Fill,
|
|
394
|
+
* mirrorType: TRTCVideoMirrorType.TRTCVideoMirrorType_Disable // 不会生效,参数设置将被忽略
|
|
395
|
+
* },
|
|
379
396
|
* }
|
|
380
397
|
* ],
|
|
381
398
|
* videoEncoderParams: {
|
|
@@ -407,9 +424,12 @@ class TRTCLocalMediaTranscoder extends events_1.EventEmitter {
|
|
|
407
424
|
destroy() {
|
|
408
425
|
var _a;
|
|
409
426
|
try {
|
|
410
|
-
this.nativeLocalMediaTranscoder
|
|
411
|
-
|
|
412
|
-
|
|
427
|
+
if (this.nativeLocalMediaTranscoder) {
|
|
428
|
+
// 避免重复销毁报错
|
|
429
|
+
this.nativeLocalMediaTranscoder.setVideoFrameRenderCallback(null, this.pixelFormat);
|
|
430
|
+
this.nativeLocalMediaTranscoder.setVideoFrameProcessCallback(trtc_define_1.TRTCVideoPixelFormat.TRTCVideoPixelFormat_Unknown);
|
|
431
|
+
this.nativeLocalMediaTranscoder = null;
|
|
432
|
+
}
|
|
413
433
|
(_a = this.renderer) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
414
434
|
this.renderer = null;
|
|
415
435
|
this.container = null;
|
|
@@ -455,13 +475,20 @@ class TRTCLocalMediaTranscoder extends events_1.EventEmitter {
|
|
|
455
475
|
* 启动摄像头采集
|
|
456
476
|
*
|
|
457
477
|
* @param deviceId {String} - 摄像头设备 Id
|
|
458
|
-
* @param transcodeParams {TRTCCameraCaptureParams} - 指定摄像头采集分辨率和帧率
|
|
459
|
-
* @param renderParams {TRTCRenderParams} - 指定摄像头数据源是否旋转、镜像和填充模式
|
|
460
478
|
*
|
|
461
479
|
* @fires [onCameraSourceStarted]{@link TRTCLocalMediaTranscodingEvent#onCameraSourceStarted}
|
|
462
480
|
*/
|
|
463
|
-
startCameraSource(deviceId
|
|
464
|
-
this.nativeLocalMediaTranscoder.startCameraSource(deviceId
|
|
481
|
+
startCameraSource(deviceId) {
|
|
482
|
+
this.nativeLocalMediaTranscoder.startCameraSource(deviceId);
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* 设置摄像头采集参数
|
|
486
|
+
*
|
|
487
|
+
* @param deviceId {String} - 摄像头设备 Id
|
|
488
|
+
* @param cameraCaptureParams {TRTCCameraCaptureParams} - 指定摄像头采集分辨率和帧率
|
|
489
|
+
*/
|
|
490
|
+
setCameraCaptureParams(deviceId, cameraCaptureParams) {
|
|
491
|
+
this.nativeLocalMediaTranscoder.setCameraCaptureParams(deviceId, cameraCaptureParams);
|
|
465
492
|
}
|
|
466
493
|
/**
|
|
467
494
|
* 停止摄像头采集
|
|
@@ -513,16 +540,35 @@ class TRTCLocalMediaTranscoder extends events_1.EventEmitter {
|
|
|
513
540
|
}
|
|
514
541
|
/**
|
|
515
542
|
* 设置本地混流转码视频预览节点
|
|
516
|
-
* @param el {HTMLElement} -
|
|
543
|
+
* @param el {HTMLElement | null} - 如果传入的是 HTML 元素,必须是块元素;传入 null 时,会停止视频预览
|
|
517
544
|
*/
|
|
518
545
|
setMixedVideoRenderView(el) {
|
|
519
|
-
if (el) {
|
|
520
|
-
this.container
|
|
521
|
-
|
|
522
|
-
|
|
546
|
+
if (el && el instanceof HTMLElement) {
|
|
547
|
+
if (this.container === el) {
|
|
548
|
+
return; // 重复在同一个 HTML 节点内渲染,不用处理,直接退出
|
|
549
|
+
}
|
|
550
|
+
else if (this.renderer) {
|
|
551
|
+
// 渲染的 HTML 节点发生改变,之前已经存在渲染器,先销毁之前渲染器
|
|
552
|
+
this.renderer.destroy();
|
|
553
|
+
this.renderer = null;
|
|
554
|
+
// 重新记录渲染的 HTML 节点并创建渲染器
|
|
555
|
+
this.container = el;
|
|
556
|
+
this.renderer = (0, Renderer_1.createRenderer)(this.pixelFormat, this.container);
|
|
557
|
+
}
|
|
558
|
+
else {
|
|
559
|
+
// 第一次设置渲染的 HTML 节点,并创建渲染器,设置渲染回调
|
|
560
|
+
this.container = el;
|
|
561
|
+
this.renderer = (0, Renderer_1.createRenderer)(this.pixelFormat, this.container);
|
|
562
|
+
this.setMixedVideoFrameRenderCallback();
|
|
563
|
+
}
|
|
523
564
|
}
|
|
524
565
|
else {
|
|
525
|
-
|
|
566
|
+
if (this.renderer) {
|
|
567
|
+
this.renderer.destroy();
|
|
568
|
+
this.renderer = null;
|
|
569
|
+
}
|
|
570
|
+
this.container = null;
|
|
571
|
+
this.unsetMixedVideoFrameRenderCallback();
|
|
526
572
|
}
|
|
527
573
|
}
|
|
528
574
|
setMixedVideoFrameRenderCallback() {
|
|
@@ -532,6 +578,9 @@ class TRTCLocalMediaTranscoder extends events_1.EventEmitter {
|
|
|
532
578
|
};
|
|
533
579
|
this.nativeLocalMediaTranscoder.setVideoFrameRenderCallback(renderCallback, this.pixelFormat);
|
|
534
580
|
}
|
|
581
|
+
unsetMixedVideoFrameRenderCallback() {
|
|
582
|
+
this.nativeLocalMediaTranscoder.setVideoFrameRenderCallback(null, this.pixelFormat);
|
|
583
|
+
}
|
|
535
584
|
setEventCallback() {
|
|
536
585
|
const eventCallback = (eventName, ...params) => {
|
|
537
586
|
// console.log('trtc:local-media-transcoder:event:', eventName, ...params);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TRTCVideoFillMode } from "../trtc_define";
|
|
2
|
-
export
|
|
2
|
+
export type TFrameData = {
|
|
3
3
|
data: Uint8Array | ArrayBuffer;
|
|
4
4
|
width: number;
|
|
5
5
|
height: number;
|
|
@@ -7,7 +7,7 @@ export declare type TFrameData = {
|
|
|
7
7
|
rotation: number;
|
|
8
8
|
isNeedRotate: boolean;
|
|
9
9
|
};
|
|
10
|
-
export
|
|
10
|
+
export type TCanvasImageSourceStyleOptions = {
|
|
11
11
|
contentWidth: number;
|
|
12
12
|
contentHeight: number;
|
|
13
13
|
containerWidth: number;
|
package/liteav/trtc.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { EventEmitter } from 'events';
|
|
3
3
|
import { VodPlayer } from './vod_player';
|
|
4
4
|
import TRTCLocalMediaTranscoder from './LocalMediaTranscoder';
|
|
5
|
-
import { AudioMusicParam, Rect, TRTCAppScene, TRTCAudioEffectParam, TRTCAudioQuality, TRTCBeautyStyle, TRTCDeviceState, TRTCDeviceType, TRTCLogLevel, TRTCRenderParams, TRTCRoleType, TRTCSwitchRoomParam, TRTCVideoBufferType, TRTCVideoFillMode, TRTCVideoFrame, TRTCVideoPixelFormat, TRTCVideoRotation, TRTCVideoStreamType, TRTCWaterMarkSrcType, PluginInfo, TRTCAudioRecordingParams, TRTCScreenCaptureSourceInfo, TRTCScreenCaptureProperty, TRTCSpeedTestParams, TRTCRecordType } from './trtc_define';
|
|
5
|
+
import { AudioMusicParam, Rect, TRTCAppScene, TRTCAudioEffectParam, TRTCAudioQuality, TRTCBeautyStyle, TRTCDeviceState, TRTCDeviceType, TRTCLogLevel, TRTCRenderParams, TRTCRoleType, TRTCSwitchRoomParam, TRTCVideoBufferType, TRTCVideoFillMode, TRTCVideoFrame, TRTCVideoPixelFormat, TRTCVideoRotation, TRTCVideoStreamType, TRTCWaterMarkSrcType, PluginInfo, TRTCAudioRecordingParams, TRTCScreenCaptureSourceInfo, TRTCScreenCaptureProperty, TRTCSpeedTestParams, TRTCRecordType, TRTCDeviceInfo } from './trtc_define';
|
|
6
6
|
export * from './trtc_define';
|
|
7
7
|
export * from './trtc_code';
|
|
8
8
|
export * from './vod_player';
|
|
@@ -1306,7 +1306,7 @@ declare class TRTCCloud extends EventEmitter {
|
|
|
1306
1306
|
* }
|
|
1307
1307
|
* @return {TRTCDeviceInfo[]} 摄像头管理器列表
|
|
1308
1308
|
*/
|
|
1309
|
-
getCameraDevicesList():
|
|
1309
|
+
getCameraDevicesList(): TRTCDeviceInfo[];
|
|
1310
1310
|
/**
|
|
1311
1311
|
* 5.2 设置要使用的摄像头
|
|
1312
1312
|
*
|
|
@@ -2210,7 +2210,7 @@ declare class TRTCCloud extends EventEmitter {
|
|
|
2210
2210
|
/**
|
|
2211
2211
|
* 创建本地多媒体合图实例
|
|
2212
2212
|
*
|
|
2213
|
-
*
|
|
2213
|
+
* 注意:单例模式,多次调用返回的是同一个对象
|
|
2214
2214
|
*
|
|
2215
2215
|
* @param {Object} config - 配置参数
|
|
2216
2216
|
* @param {TRTCVideoPixelFormat} config.pixelFormat - 视频数据的像素格式
|
package/liteav/trtc.js
CHANGED
|
@@ -251,9 +251,15 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
251
251
|
* 清理资源
|
|
252
252
|
*/
|
|
253
253
|
destroy() {
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
254
|
+
try {
|
|
255
|
+
this.firstVideoFrameList = [];
|
|
256
|
+
this.playAudioEffectIdList = [];
|
|
257
|
+
this.destroyLocalMediaTranscoder();
|
|
258
|
+
this.rtcCloud.destroy();
|
|
259
|
+
}
|
|
260
|
+
catch (e) {
|
|
261
|
+
console.warn(`trtc:destroy warning:`, e.message);
|
|
262
|
+
}
|
|
257
263
|
}
|
|
258
264
|
/////////////////////////////////////////////////////////////////////////////////
|
|
259
265
|
//
|
|
@@ -2390,7 +2396,24 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
2390
2396
|
* @return {TRTCDeviceInfo[]} 摄像头管理器列表
|
|
2391
2397
|
*/
|
|
2392
2398
|
getCameraDevicesList() {
|
|
2393
|
-
|
|
2399
|
+
const deviceInfos = this.rtcCloud.getCameraDevicesList();
|
|
2400
|
+
deviceInfos.forEach(item => {
|
|
2401
|
+
try {
|
|
2402
|
+
if (item.deviceProperties) {
|
|
2403
|
+
const properties = JSON.parse(item.deviceProperties);
|
|
2404
|
+
item.deviceProperties = properties;
|
|
2405
|
+
}
|
|
2406
|
+
else {
|
|
2407
|
+
// 虚拟摄像头没有 deviceProperties 字段
|
|
2408
|
+
item.deviceProperties = {};
|
|
2409
|
+
}
|
|
2410
|
+
}
|
|
2411
|
+
catch (e) {
|
|
2412
|
+
console.warn('trtc:camera device properties parse error.', JSON.stringify(item));
|
|
2413
|
+
item.deviceProperties = {};
|
|
2414
|
+
}
|
|
2415
|
+
});
|
|
2416
|
+
return deviceInfos;
|
|
2394
2417
|
}
|
|
2395
2418
|
/**
|
|
2396
2419
|
* 5.2 设置要使用的摄像头
|
|
@@ -4039,7 +4062,7 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
4039
4062
|
/**
|
|
4040
4063
|
* 创建本地多媒体合图实例
|
|
4041
4064
|
*
|
|
4042
|
-
*
|
|
4065
|
+
* 注意:单例模式,多次调用返回的是同一个对象
|
|
4043
4066
|
*
|
|
4044
4067
|
* @param {Object} config - 配置参数
|
|
4045
4068
|
* @param {TRTCVideoPixelFormat} config.pixelFormat - 视频数据的像素格式
|
|
@@ -4061,8 +4084,15 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
4061
4084
|
*/
|
|
4062
4085
|
destroyLocalMediaTranscoder() {
|
|
4063
4086
|
if (this.localMediaTranscoder) {
|
|
4064
|
-
|
|
4065
|
-
|
|
4087
|
+
try {
|
|
4088
|
+
this.localMediaTranscoder.destroy();
|
|
4089
|
+
this.localMediaTranscoder = null;
|
|
4090
|
+
this.rtcCloud.destroyLocalMediaTranscoding();
|
|
4091
|
+
}
|
|
4092
|
+
catch (e) {
|
|
4093
|
+
// 重复销毁会有报错提示
|
|
4094
|
+
console.warn(`trtc:destroyLocalMediaTranscoder warning:`, e.message);
|
|
4095
|
+
}
|
|
4066
4096
|
}
|
|
4067
4097
|
}
|
|
4068
4098
|
}
|
package/liteav/trtc_define.d.ts
CHANGED
|
@@ -141,6 +141,8 @@ export declare class TRTCImageBuffer {
|
|
|
141
141
|
* @param {TRTCImageBuffer} thumbBGRA - 缩略图内容
|
|
142
142
|
* @param {TRTCImageBuffer} iconBGRA - 图标内容
|
|
143
143
|
* @param {Boolean} isMinimizeWindow - 是否最小化窗口
|
|
144
|
+
* @param {Number} width - 屏幕/窗口宽,单位:像素
|
|
145
|
+
* @param {Number} height - 屏幕/窗口高,单位:像素
|
|
144
146
|
*
|
|
145
147
|
*/
|
|
146
148
|
export declare class TRTCScreenCaptureSourceInfo {
|
|
@@ -150,7 +152,9 @@ export declare class TRTCScreenCaptureSourceInfo {
|
|
|
150
152
|
thumbBGRA: TRTCImageBuffer;
|
|
151
153
|
iconBGRA: TRTCImageBuffer;
|
|
152
154
|
isMinimizeWindow: boolean;
|
|
153
|
-
|
|
155
|
+
width: number;
|
|
156
|
+
height: number;
|
|
157
|
+
constructor(type?: TRTCScreenCaptureSourceType, sourceId?: string, sourceName?: string, thumbBGRA?: TRTCImageBuffer, iconBGRA?: TRTCImageBuffer, isMinimizeWindow?: boolean, width?: number, height?: number);
|
|
154
158
|
}
|
|
155
159
|
/**
|
|
156
160
|
* 3.6 屏幕分享的进阶控制参数
|
|
@@ -179,12 +183,17 @@ export declare class TRTCScreenCaptureProperty {
|
|
|
179
183
|
*
|
|
180
184
|
* @param {String} deviceId - 设备PID,字符编码格式是UTF-8
|
|
181
185
|
* @param {String} deviceName - 设备名称,字符编码格式是UTF-8
|
|
186
|
+
* @param {Object} deviceProperties - 设备属性
|
|
187
|
+
* - 只支持摄像头,包含摄像头支持的采集分辨率。
|
|
188
|
+
* @param {Array} deviceProperties.SupportedResolution - 支持的采集分辨率数组,每个数据是一个对象,包含 `width` 和 `height` 两个属性,属性值都是整形数值。
|
|
189
|
+
* - 注意:虚拟摄像头该字段不存在。
|
|
182
190
|
*
|
|
183
191
|
*/
|
|
184
192
|
export declare class TRTCDeviceInfo {
|
|
185
193
|
deviceId: string;
|
|
186
194
|
deviceName: string;
|
|
187
|
-
|
|
195
|
+
deviceProperties: Record<string, any>;
|
|
196
|
+
constructor(deviceId: string, deviceName: string, deviceProperties: {});
|
|
188
197
|
}
|
|
189
198
|
/**
|
|
190
199
|
* 3.8 视频帧数据
|
package/liteav/trtc_define.js
CHANGED
|
@@ -552,16 +552,20 @@ exports.TRTCImageBuffer = TRTCImageBuffer;
|
|
|
552
552
|
* @param {TRTCImageBuffer} thumbBGRA - 缩略图内容
|
|
553
553
|
* @param {TRTCImageBuffer} iconBGRA - 图标内容
|
|
554
554
|
* @param {Boolean} isMinimizeWindow - 是否最小化窗口
|
|
555
|
+
* @param {Number} width - 屏幕/窗口宽,单位:像素
|
|
556
|
+
* @param {Number} height - 屏幕/窗口高,单位:像素
|
|
555
557
|
*
|
|
556
558
|
*/
|
|
557
559
|
class TRTCScreenCaptureSourceInfo {
|
|
558
|
-
constructor(type = TRTCScreenCaptureSourceType.TRTCScreenCaptureSourceTypeUnknown, sourceId = '', sourceName = '', thumbBGRA = new TRTCImageBuffer(), iconBGRA = new TRTCImageBuffer(), isMinimizeWindow = false) {
|
|
560
|
+
constructor(type = TRTCScreenCaptureSourceType.TRTCScreenCaptureSourceTypeUnknown, sourceId = '', sourceName = '', thumbBGRA = new TRTCImageBuffer(), iconBGRA = new TRTCImageBuffer(), isMinimizeWindow = false, width = 0, height = 0) {
|
|
559
561
|
this.type = type;
|
|
560
562
|
this.sourceId = sourceId;
|
|
561
563
|
this.sourceName = sourceName;
|
|
562
564
|
this.thumbBGRA = thumbBGRA;
|
|
563
565
|
this.iconBGRA = iconBGRA;
|
|
564
566
|
this.isMinimizeWindow = isMinimizeWindow;
|
|
567
|
+
this.width = width;
|
|
568
|
+
this.height = height;
|
|
565
569
|
}
|
|
566
570
|
}
|
|
567
571
|
exports.TRTCScreenCaptureSourceInfo = TRTCScreenCaptureSourceInfo;
|
|
@@ -595,12 +599,17 @@ exports.TRTCScreenCaptureProperty = TRTCScreenCaptureProperty;
|
|
|
595
599
|
*
|
|
596
600
|
* @param {String} deviceId - 设备PID,字符编码格式是UTF-8
|
|
597
601
|
* @param {String} deviceName - 设备名称,字符编码格式是UTF-8
|
|
602
|
+
* @param {Object} deviceProperties - 设备属性
|
|
603
|
+
* - 只支持摄像头,包含摄像头支持的采集分辨率。
|
|
604
|
+
* @param {Array} deviceProperties.SupportedResolution - 支持的采集分辨率数组,每个数据是一个对象,包含 `width` 和 `height` 两个属性,属性值都是整形数值。
|
|
605
|
+
* - 注意:虚拟摄像头该字段不存在。
|
|
598
606
|
*
|
|
599
607
|
*/
|
|
600
608
|
class TRTCDeviceInfo {
|
|
601
|
-
constructor(deviceId = '', deviceName = '') {
|
|
609
|
+
constructor(deviceId = '', deviceName = '', deviceProperties) {
|
|
602
610
|
this.deviceId = deviceId;
|
|
603
611
|
this.deviceName = deviceName;
|
|
612
|
+
this.deviceProperties = deviceProperties;
|
|
604
613
|
}
|
|
605
614
|
}
|
|
606
615
|
exports.TRTCDeviceInfo = TRTCDeviceInfo;
|