trtc-electron-sdk 11.7.504-beta.0 → 11.7.602-beta.0
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 +413 -413
- package/liteav/LocalMediaTranscoder/index.js +601 -601
- package/liteav/Render/BGRAVideoRenderer/index.js +114 -114
- package/liteav/Render/Canvas3DRGBARenderer/index.js +241 -241
- package/liteav/Render/GlRenderer/index.js +439 -439
- package/liteav/Render/GlRenderer/webgl-utils.js +1337 -1337
- package/liteav/Render/I420VideoRenderer/index.js +106 -106
- package/liteav/Render/RGBAVideoRenderer/index.js +115 -115
- package/liteav/Render/RGBRenderer/index.js +112 -112
- package/liteav/Render/SoftwareRenderer/index.js +153 -153
- package/liteav/Render/index.d.ts +58 -58
- package/liteav/Render/index.js +63 -63
- package/liteav/Render/util.d.ts +46 -46
- package/liteav/Render/util.js +140 -140
- package/liteav/Renderer/Canvas2DRenderer/index.d.ts +25 -25
- package/liteav/Renderer/Canvas2DRenderer/index.js +228 -228
- package/liteav/Renderer/Canvas3DRenderer/I420Canvas3DRenderer.d.ts +23 -23
- package/liteav/Renderer/Canvas3DRenderer/I420Canvas3DRenderer.js +280 -280
- package/liteav/Renderer/Canvas3DRenderer/ICanvas3DRenderer.d.ts +4 -4
- package/liteav/Renderer/Canvas3DRenderer/ICanvas3DRenderer.js +2 -2
- package/liteav/Renderer/Canvas3DRenderer/RGBACanvas3DRenderer.d.ts +8 -8
- package/liteav/Renderer/Canvas3DRenderer/RGBACanvas3DRenderer.js +167 -167
- package/liteav/Renderer/Canvas3DRenderer/index.d.ts +32 -32
- package/liteav/Renderer/Canvas3DRenderer/index.js +242 -242
- package/liteav/Renderer/Canvas3DRenderer/webgl-utils.js +1337 -1337
- package/liteav/Renderer/IRenderer.d.ts +9 -9
- package/liteav/Renderer/IRenderer.js +2 -2
- package/liteav/Renderer/VideoRenderer/index.d.ts +26 -26
- package/liteav/Renderer/VideoRenderer/index.js +159 -159
- package/liteav/Renderer/index.d.ts +14 -14
- package/liteav/Renderer/index.js +60 -64
- package/liteav/Renderer/types.d.ts +19 -19
- package/liteav/Renderer/types.js +2 -2
- package/liteav/Renderer/util.d.ts +51 -53
- package/liteav/Renderer/util.js +183 -185
- package/liteav/Renderer/yuv-buffer.d.ts +189 -189
- package/liteav/Renderer/yuv-buffer.js +264 -264
- package/liteav/logger.d.ts +15 -15
- package/liteav/logger.js +78 -76
- package/liteav/trtc.d.ts +2490 -2474
- package/liteav/trtc.js +4743 -4696
- package/liteav/trtc_code.d.ts +515 -515
- package/liteav/trtc_code.js +534 -534
- package/liteav/trtc_define.d.ts +930 -879
- package/liteav/trtc_define.js +1628 -1565
- package/liteav/validate-util.d.ts +5 -5
- package/liteav/validate-util.js +23 -23
- package/liteav/vod_player.d.ts +47 -51
- package/liteav/vod_player.js +197 -167
- package/package.json +19 -6
- package/scripts/copy-sdk.js +78 -0
- package/scripts/download.js +7 -0
- package/scripts/publish-doc.js +1 -1
|
@@ -1,413 +1,413 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { EventEmitter } from 'events';
|
|
3
|
-
import { TRTCVideoStreamType, TRTCScreenCaptureSourceInfo, Rect, TRTCVideoEncParam, TRTCVideoPixelFormat, TRTCRenderParams, TRTCCameraCaptureParams } from '../trtc_define';
|
|
4
|
-
export declare enum TRTCLocalMediaTranscodingError {
|
|
5
|
-
Success = 0,
|
|
6
|
-
Error = -1,
|
|
7
|
-
InvalidParams = -2,
|
|
8
|
-
NotFoundSource = -3,
|
|
9
|
-
ImageSourceLoadFailed = -4
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* @namespace TRTCLocalMediaTranscodingEvent
|
|
13
|
-
* @description 目前只支持 Windows
|
|
14
|
-
*/
|
|
15
|
-
export declare enum TRTCLocalMediaTranscodingEvents {
|
|
16
|
-
/**
|
|
17
|
-
* @description 本地混流转码开启的事件
|
|
18
|
-
*
|
|
19
|
-
* 当您调用 [startTranscoding]{@link TRTCLocalMediaTranscoder#startTranscoding} 时启动本地混流转码时,是否启动成功会通过此回调同步给您。
|
|
20
|
-
*
|
|
21
|
-
* @event TRTCLocalMediaTranscodingEvent#onTranscodingStarted
|
|
22
|
-
* @param {TRTCLocalMediaTranscodingError} errCode - 错误码。
|
|
23
|
-
* @param {String} errMsg - 错误信息。
|
|
24
|
-
*/
|
|
25
|
-
onTranscodingStarted = "onTranscodingStarted",
|
|
26
|
-
/**
|
|
27
|
-
* @description 本地混流转码停止的事件
|
|
28
|
-
*
|
|
29
|
-
* 当您通过 [stopTranscoding]{@link TRTCLocalMediaTranscoder#stopTranscoding} 停止本地混流转码时,SDK 便会抛出此事件。
|
|
30
|
-
*
|
|
31
|
-
* @event TRTCLocalMediaTranscodingEvent#onTranscodingStopped
|
|
32
|
-
* @param {Number} reason - 停止原因,0:用户主动停止;1:被动停止,有可能采集源失效了
|
|
33
|
-
* @param {String} errMsg - 停止原因描述信息。
|
|
34
|
-
*/
|
|
35
|
-
onTranscodingStopped = "onTranscodingStopped",
|
|
36
|
-
/**
|
|
37
|
-
* @description 本地摄像头开启的事件
|
|
38
|
-
* 当您调用 [startCameraSource]{@link TRTCLocalMediaTranscoder#startCameraSource} 打开摄像头时,是否启动成功会通过此回调同步给您。
|
|
39
|
-
*
|
|
40
|
-
* @event TRTCLocalMediaTranscodingEvent#onCameraSourceStarted
|
|
41
|
-
* @param {String} deviceId - 摄像头设备 Id 。
|
|
42
|
-
* @param {TRTCLocalMediaTranscodingError} errCode - 错误码。
|
|
43
|
-
* @param {String} errMsg - 错误信息。
|
|
44
|
-
*/
|
|
45
|
-
onCameraSourceStarted = "onCameraSourceStarted",
|
|
46
|
-
/**
|
|
47
|
-
* @description 本地摄像头停止的事件
|
|
48
|
-
*
|
|
49
|
-
* @event TRTCLocalMediaTranscodingEvent#onCameraSourceStopped
|
|
50
|
-
* @param {String} deviceId - 摄像头设备 Id 。
|
|
51
|
-
* @param {String} reasonMsg - 停止原因描述信息。
|
|
52
|
-
*/
|
|
53
|
-
onCameraSourceStopped = "onCameraSourceStopped",
|
|
54
|
-
/**
|
|
55
|
-
* @description 图片混流开启的事件
|
|
56
|
-
* 当您调用 [addImageSource]{@link TRTCLocalMediaTranscoder#addImageSource} 打开摄像头时,是否启动成功会通过此回调同步给您。
|
|
57
|
-
*
|
|
58
|
-
* @event TRTCLocalMediaTranscodingEvent#onImageSourceStarted
|
|
59
|
-
* @param {String} imagePath - 图片路径 。
|
|
60
|
-
* @param {TRTCLocalMediaTranscodingError} errCode - 错误码。
|
|
61
|
-
* @param {String} errMsg - 错误信息。
|
|
62
|
-
*/
|
|
63
|
-
onImageSourceStarted = "onImageSourceStarted",
|
|
64
|
-
/**
|
|
65
|
-
* @description 图片混流停止的事件
|
|
66
|
-
* @event TRTCLocalMediaTranscodingEvent#onImageSourceStopped
|
|
67
|
-
* @param {String} imagePath - 图片路径 。
|
|
68
|
-
*/
|
|
69
|
-
onImageSourceStopped = "onImageSourceStopped",
|
|
70
|
-
/**
|
|
71
|
-
* @description 屏幕分享开启的事件
|
|
72
|
-
* * 当您通过 [startScreenSource]{@link TRTCLocalMediaTranscoder#startScreenSource} 等相关接口启动屏幕分享时,SDK 便会抛出此事件回调。
|
|
73
|
-
*
|
|
74
|
-
* @event TRTCLocalMediaTranscodingEvent#onScreenSourceStarted
|
|
75
|
-
* @param {String} sourceId - 屏幕或者窗口 Id 。
|
|
76
|
-
* @param {TRTCLocalMediaTranscodingError} errCode - 错误码。
|
|
77
|
-
* @param {String} errMsg - 错误信息。
|
|
78
|
-
*/
|
|
79
|
-
onScreenSourceStarted = "onScreenSourceStarted",
|
|
80
|
-
/**
|
|
81
|
-
* @description 屏幕分享暂停的事件
|
|
82
|
-
* @event TRTCLocalMediaTranscodingEvent#onScreenSourcePaused
|
|
83
|
-
* @param {String} sourceId - 屏幕或者窗口 Id 。
|
|
84
|
-
* @param {int} reason - 原因:
|
|
85
|
-
* - 1:注意此字段的含义在 MAC 和 Windows
|
|
86
|
-
* 平台有稍微差异。屏幕窗口不可见暂停(Mac)。表示设置屏幕分享参数导致的暂停(Windows)。
|
|
87
|
-
* - 2:表示屏幕分享窗口被最小化导致的暂停(仅 Windows)。
|
|
88
|
-
* - 3:表示屏幕分享窗口被隐藏导致的暂停(仅 Windows)。
|
|
89
|
-
*/
|
|
90
|
-
onScreenSourcePaused = "onScreenSourcePaused",
|
|
91
|
-
/**
|
|
92
|
-
* @description 屏幕分享恢复的事件
|
|
93
|
-
* @event TRTCLocalMediaTranscodingEvent#onScreenSourceResumed
|
|
94
|
-
* @param {String} sourceId - 屏幕或者窗口 Id 。
|
|
95
|
-
* @param {int} reason - 原因:
|
|
96
|
-
* - 1:注意此字段的含义在 MAC 和 Windows
|
|
97
|
-
* 平台有稍微差异。屏幕窗口恢复可见从而恢复分享(Mac)。屏幕分享参数设置完毕后自动恢复(Windows)。
|
|
98
|
-
* - 2:表示屏幕分享窗口从最小化被恢复(仅 Windows)。
|
|
99
|
-
* - 3:表示屏幕分享窗口从隐藏被恢复(仅 Windows)。
|
|
100
|
-
*/
|
|
101
|
-
onScreenSourceResumed = "onScreenSourceResumed",
|
|
102
|
-
/**
|
|
103
|
-
* @description 屏幕分享停止的事件
|
|
104
|
-
* 当您通过 [stopScreenSource]{@link TRTCLocalMediaTranscoder#stopScreenSource} 停止屏幕分享时,SDK 便会抛出此事件回调。
|
|
105
|
-
*
|
|
106
|
-
* @event TRTCLocalMediaTranscodingEvent#onScreenSourceStopped
|
|
107
|
-
* @param {String} sourceId - 屏幕或者窗口 Id 。
|
|
108
|
-
* @param {int} reason - 原因:0:用户主动停止;1:屏幕窗口关闭导致停止;2:表示屏幕分享的显示屏状态变更(如接口被拔出、投影模式变更等)。
|
|
109
|
-
*/
|
|
110
|
-
onScreenSourceStopped = "onScreenSourceStopped"
|
|
111
|
-
}
|
|
112
|
-
export declare enum TRTCLocalMediaTranscodingSourceType {
|
|
113
|
-
MediaSourceCamera = 0,
|
|
114
|
-
MediaSourceScreen = 1,
|
|
115
|
-
MediaSourceImage = 2,
|
|
116
|
-
MediaSourceRemoteVideo = 3
|
|
117
|
-
}
|
|
118
|
-
export type TRTCLocalMediaTranscodingSource = {
|
|
119
|
-
sourceType: TRTCLocalMediaTranscodingSourceType;
|
|
120
|
-
cameraDeviceId?: string;
|
|
121
|
-
screenSourceId?: string;
|
|
122
|
-
imagePath?: string;
|
|
123
|
-
userId?: string;
|
|
124
|
-
rect: Rect;
|
|
125
|
-
zOrder: number;
|
|
126
|
-
renderParams: TRTCRenderParams;
|
|
127
|
-
};
|
|
128
|
-
export type TRTCLocalMediaTranscodingParams = {
|
|
129
|
-
inputSourceList: TRTCLocalMediaTranscodingSource[];
|
|
130
|
-
videoEncoderParams: TRTCVideoEncParam;
|
|
131
|
-
canvasColor: number;
|
|
132
|
-
};
|
|
133
|
-
/**
|
|
134
|
-
* @description 本地媒体流混流转码(目前只支持 Windows)
|
|
135
|
-
*
|
|
136
|
-
* @extends EventEmitter
|
|
137
|
-
*
|
|
138
|
-
* @example
|
|
139
|
-
* // 运行示例
|
|
140
|
-
* import TRTCCloud, {
|
|
141
|
-
* TRTCCameraCaptureMode,
|
|
142
|
-
* TRTCVideoRotation,
|
|
143
|
-
* TRTCVideoFillMode,
|
|
144
|
-
* TRTCVideoMirrorType,
|
|
145
|
-
* TRTCVideoStreamType,
|
|
146
|
-
* TRTCLocalMediaTranscodingSourceType,
|
|
147
|
-
* TRTCVideoResolution,
|
|
148
|
-
* TRTCVideoResolutionMode,
|
|
149
|
-
* TRTCVideoPixelFormat
|
|
150
|
-
* } from 'trtc-electron-sdk';
|
|
151
|
-
*
|
|
152
|
-
* const trtcCloud = new TRTCCloud();
|
|
153
|
-
* const cameraList =trtcCloud.getCameraDevicesList();
|
|
154
|
-
*
|
|
155
|
-
* // 获取本地合图转码推流对象
|
|
156
|
-
* const localMediaTranscoder =trtcCloud.createLocalMediaTranscoder({
|
|
157
|
-
* pixelFormat: TRTCVideoPixelFormat.TRTCVideoPixelFormat_I420,
|
|
158
|
-
* });
|
|
159
|
-
*
|
|
160
|
-
* // 注册事件监听
|
|
161
|
-
* // 监听合图开始、结束事件
|
|
162
|
-
* localMediaTranscoder.on('onTranscodingStarted', (errCode: number, errMsg: string) => {
|
|
163
|
-
* console.log(`onTranscodingStarted { errCode:${errCode} errMsg:${errMsg}`);
|
|
164
|
-
* });
|
|
165
|
-
* localMediaTranscoder.on('onTranscodingStopped', (reason: number, reasonMsg: string) => {
|
|
166
|
-
* console.log(`onTranscodingStopped { reason:${reason} reasonMsg:${reasonMsg} }`);
|
|
167
|
-
* });
|
|
168
|
-
* // 监听摄像头事件
|
|
169
|
-
* localMediaTranscoder.on('onCameraSourceStarted', (deviceId: string, errCode: number, errMsg: string) => {
|
|
170
|
-
* console.log(`onCameraSourceStarted { deviceId:${deviceId} errCode:${errCode} errMsg:${errMsg} }`);
|
|
171
|
-
* });
|
|
172
|
-
* localMediaTranscoder.on('onCameraSourceStopped', (deviceId: string, reasonMsg: string) => {
|
|
173
|
-
* console.log(`onCameraSourceStopped { deviceId:${deviceId} reasonMsg:${reasonMsg}}`);
|
|
174
|
-
* });
|
|
175
|
-
* // 监听屏幕、窗口分享事件
|
|
176
|
-
* localMediaTranscoder.on('onScreenSourceStarted', (sourceId: string, errCode: number, errMsg: string) => {
|
|
177
|
-
* console.log(`onScreenSourceStarted { sourceId:${sourceId} errCode:${errCode} errMsg:${errMsg} }`);
|
|
178
|
-
* });
|
|
179
|
-
* localMediaTranscoder.on('onScreenSourceStopped', (sourceId: string, reason: number) => {
|
|
180
|
-
* console.log(`onScreenSourceStopped { sourceId:${sourceId}, reason:${reason} }`);
|
|
181
|
-
* });
|
|
182
|
-
* // 监听图片事件
|
|
183
|
-
* localMediaTranscoder.on('onImageSourceStarted', (imagePath: string, errCode: number, errMsg: string) => {
|
|
184
|
-
* console.log(`onImageSourceStarted { imagePath:${imagePath} errCode:${errCode} errMsg:${errMsg} }`);
|
|
185
|
-
* });
|
|
186
|
-
* localMediaTranscoder.on('onImageSourceStopped', (imagePath: string) => {
|
|
187
|
-
* console.log(`onImageSourceStopped { imagePath:${imagePath} }`);
|
|
188
|
-
* });
|
|
189
|
-
*
|
|
190
|
-
* // 开启摄像头一
|
|
191
|
-
* localMediaTranscoder.startCameraSource(cameraList[0].deviceId);
|
|
192
|
-
* localMediaTranscoder.setCameraCaptureParams(
|
|
193
|
-
* cameraList[0].deviceId,
|
|
194
|
-
* {
|
|
195
|
-
* mode: TRTCCameraCaptureMode.TRTCCameraResolutionStrategyAuto,
|
|
196
|
-
* width: 480,
|
|
197
|
-
* height: 480,
|
|
198
|
-
* }
|
|
199
|
-
* );
|
|
200
|
-
*
|
|
201
|
-
* // 开启摄像头二
|
|
202
|
-
* localMediaTranscoder.startCameraSource(cameraList[1].deviceId);
|
|
203
|
-
* localMediaTranscoder.setCameraCaptureParams(
|
|
204
|
-
* cameraList[1].deviceId,
|
|
205
|
-
* {
|
|
206
|
-
* mode: TRTCCameraCaptureMode.TRTCCameraResolutionStrategyAuto,
|
|
207
|
-
* width: 960,
|
|
208
|
-
* height: 540
|
|
209
|
-
* }
|
|
210
|
-
* );
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
* // 开启屏幕一
|
|
214
|
-
* localMediaTranscoder.startScreenSource(screenSourceList[0], {top:10, left:10, right:1200, bottom:800});
|
|
215
|
-
*
|
|
216
|
-
* // 开启屏幕二
|
|
217
|
-
* localMediaTranscoder.startScreenSource(screenSourceList[1], {top:0, left:0, right:0, bottom:0});
|
|
218
|
-
*
|
|
219
|
-
* // 加载图片一
|
|
220
|
-
* localMediaTranscoder.addImageSource('<please set valid image path>', 15);
|
|
221
|
-
*
|
|
222
|
-
* // 加载图片二
|
|
223
|
-
* localMediaTranscoder.addImageSource('<please set valid image path>', 15);
|
|
224
|
-
*
|
|
225
|
-
* // 启动合图转码并推流
|
|
226
|
-
* localMediaTranscoder.startTranscoding(
|
|
227
|
-
* TRTCVideoStreamType.TRTCVideoStreamTypeBig,
|
|
228
|
-
* {
|
|
229
|
-
* inputSourceList: [
|
|
230
|
-
* { // camera 1
|
|
231
|
-
* sourceType: TRTCLocalMediaTranscodingSourceType.MediaSourceCamera,
|
|
232
|
-
* cameraDeviceId: cameraList[0].deviceId,
|
|
233
|
-
* rect: { left: 0, top: 0, right: 320, bottom: 180 },
|
|
234
|
-
* zOrder: 1,
|
|
235
|
-
* renderParams: {
|
|
236
|
-
* rotation: TRTCVideoRotation.TRTCVideoRotation0,
|
|
237
|
-
* fillMode: TRTCVideoFillMode.TRTCVideoFillMode_Fit,
|
|
238
|
-
* mirrorType: TRTCVideoMirrorType.TRTCVideoMirrorType_Disable
|
|
239
|
-
* },
|
|
240
|
-
* },
|
|
241
|
-
* { // camera 2
|
|
242
|
-
* sourceType: TRTCLocalMediaTranscodingSourceType.MediaSourceCamera,
|
|
243
|
-
* cameraDeviceId: cameraList[1].deviceId,
|
|
244
|
-
* rect: {left: 320 + 20, top: 180 + 20, right: 640 + 20, bottom: 360 + 20},
|
|
245
|
-
* zOrder: 2,
|
|
246
|
-
* renderParams: {
|
|
247
|
-
* rotation: TRTCVideoRotation.TRTCVideoRotation90,
|
|
248
|
-
* fillMode: TRTCVideoFillMode.TRTCVideoFillMode_Fill,
|
|
249
|
-
* mirrorType: TRTCVideoMirrorType.TRTCVideoMirrorType_Enable
|
|
250
|
-
* },
|
|
251
|
-
* },
|
|
252
|
-
* {
|
|
253
|
-
* // screen 1
|
|
254
|
-
* sourceType: TRTCLocalMediaTranscodingSourceType.MediaSourceScreen,
|
|
255
|
-
* screenSourceId: screenSourceList[0].sourceId,
|
|
256
|
-
* rect: {left: 320 + 20, top: 0, right: 640 + 20, bottom: 180},
|
|
257
|
-
* zOrder: 3,
|
|
258
|
-
* renderParams: {
|
|
259
|
-
* rotation: TRTCVideoRotation.TRTCVideoRotation180,
|
|
260
|
-
* fillMode: TRTCVideoFillMode.TRTCVideoFillMode_Fit,
|
|
261
|
-
* mirrorType: TRTCVideoMirrorType.TRTCVideoMirrorType_Enable
|
|
262
|
-
* },
|
|
263
|
-
* },
|
|
264
|
-
* {
|
|
265
|
-
* // screen 2
|
|
266
|
-
* sourceType: TRTCLocalMediaTranscodingSourceType.MediaSourceScreen,
|
|
267
|
-
* screenSourceId: screenSourceList[1].sourceId,
|
|
268
|
-
* rect: {left: 0, top: 180 + 20, right: 320, bottom: 360 + 20},
|
|
269
|
-
* zOrder: 4,
|
|
270
|
-
* renderParams: {
|
|
271
|
-
* rotation: TRTCVideoRotation.TRTCVideoRotation270,
|
|
272
|
-
* fillMode: TRTCVideoFillMode.TRTCVideoFillMode_Fill,
|
|
273
|
-
* mirrorType: TRTCVideoMirrorType.TRTCVideoMirrorType_Auto
|
|
274
|
-
* },
|
|
275
|
-
* },
|
|
276
|
-
* { // image 1
|
|
277
|
-
* sourceType: TRTCLocalMediaTranscodingSourceType.MediaSourceImage,
|
|
278
|
-
* imagePath: '<please set valid image path>',
|
|
279
|
-
* rect: {left: 0, top: 360 + 40, right: 320, bottom: 540 + 40},
|
|
280
|
-
* zOrder: 5,
|
|
281
|
-
* renderParams: {
|
|
282
|
-
* rotation: TRTCVideoRotation.TRTCVideoRotation90, // 不会生效,参数设置将被忽略
|
|
283
|
-
* fillMode: TRTCVideoFillMode.TRTCVideoFillMode_Fit,
|
|
284
|
-
* mirrorType: TRTCVideoMirrorType.TRTCVideoMirrorType_Enable // 不会生效,参数设置将被忽略
|
|
285
|
-
* },
|
|
286
|
-
* },
|
|
287
|
-
* { // image 2
|
|
288
|
-
* sourceType: TRTCLocalMediaTranscodingSourceType.MediaSourceImage,
|
|
289
|
-
* imagePath: '<please set valid image path>',
|
|
290
|
-
* rect: {left: 320 + 20, top: 360 + 40, right: 640, bottom: 540 + 40},
|
|
291
|
-
* zOrder: 5,
|
|
292
|
-
* renderParams: {
|
|
293
|
-
* rotation: TRTCVideoRotation.TRTCVideoRotation0, // 不会生效,参数设置将被忽略
|
|
294
|
-
* fillMode: TRTCVideoFillMode.TRTCVideoFillMode_Fill,
|
|
295
|
-
* mirrorType: TRTCVideoMirrorType.TRTCVideoMirrorType_Disable // 不会生效,参数设置将被忽略
|
|
296
|
-
* },
|
|
297
|
-
* }
|
|
298
|
-
* ],
|
|
299
|
-
* videoEncoderParams: {
|
|
300
|
-
* videoResolution: TRTCVideoResolution.TRTCVideoResolution_960_720,
|
|
301
|
-
* resMode: TRTCVideoResolutionMode.TRTCVideoResolutionModeLandscape,
|
|
302
|
-
* videoFps: 30,
|
|
303
|
-
* videoBitrate: 800,
|
|
304
|
-
* minVideoBitrate: 0,
|
|
305
|
-
* enableAdjustRes: false,
|
|
306
|
-
* },
|
|
307
|
-
* canvasColor: 0xff0000, // 0x61b9f1,
|
|
308
|
-
* }
|
|
309
|
-
* );
|
|
310
|
-
*
|
|
311
|
-
* // 设置本地预览
|
|
312
|
-
* const view = document.getElementById("preview-view");
|
|
313
|
-
* localMediaTranscoder.setMixedVideoRenderView(view as HTMLElement);
|
|
314
|
-
*/
|
|
315
|
-
declare class TRTCLocalMediaTranscoder extends EventEmitter {
|
|
316
|
-
private nativeLocalMediaTranscoder;
|
|
317
|
-
private renderer;
|
|
318
|
-
private container;
|
|
319
|
-
private pixelFormat;
|
|
320
|
-
constructor(nativeLocalMediaTranscoder: any, pixelFormat?: TRTCVideoPixelFormat);
|
|
321
|
-
destroy(): void;
|
|
322
|
-
private validateTranscodingConfig;
|
|
323
|
-
/**
|
|
324
|
-
* 启动本地混流转码
|
|
325
|
-
*
|
|
326
|
-
* @param streamType {TRTCVideoStreamType} - 指定使用 TRTC 的 TRTCVideoStreamTypeBig 来推流,还是 TRTCVideoStreamTypeSub 来推流。
|
|
327
|
-
* @param params {TRTCLocalMediaTranscodingParams} - 指定本地混流转码的参数
|
|
328
|
-
* @param params.inputSourceList {TRTCLocalMediaTranscodingSource} - 【字段含义】指定转码流中的每一路输入媒体源配置的信息。
|
|
329
|
-
* -【推荐取值】该字段是一个 TRTCLocalMediaTranscodingSource 类型的数组,数组中的每一个元素都用来代表每一路输入媒体源的信息。
|
|
330
|
-
* -【特别说明】媒体源信息不支持留空,否则 TRTCLocalMediaTranscoder 的 onTranscodingStarted 会报错。
|
|
331
|
-
* @param params.videoEncoderParams {TRTCVideoEncParam} -【字段含义】转码流的视频编码参数
|
|
332
|
-
* @param params.canvasColor {Number} - 【字段含义】指定混合画面的底色。
|
|
333
|
-
* -【推荐取值】默认值:0x000000 代表黑色。格式为十六进制数字,比如:“0x61B9F1” 代表 RGB 分别为(97、158、241)。
|
|
334
|
-
*
|
|
335
|
-
* @fires [onTranscodingStarted]{@link TRTCLocalMediaTranscodingEvent#onTranscodingStarted}
|
|
336
|
-
*/
|
|
337
|
-
startTranscoding(streamType: TRTCVideoStreamType, params: TRTCLocalMediaTranscodingParams): void;
|
|
338
|
-
/**
|
|
339
|
-
* 更新本地混流转码参数
|
|
340
|
-
*
|
|
341
|
-
* @param params {TRTCLocalMediaTranscodingParams} - 指定本地混流转码的参数
|
|
342
|
-
*/
|
|
343
|
-
updateTranscodingParams(params: TRTCLocalMediaTranscodingParams): void;
|
|
344
|
-
/**
|
|
345
|
-
* 停止本地混流转码
|
|
346
|
-
*
|
|
347
|
-
* @fires [onTranscodingStopped]{@link TRTCLocalMediaTranscodingEvent#onTranscodingStopped}
|
|
348
|
-
*/
|
|
349
|
-
stopTranscoding(): void;
|
|
350
|
-
/**
|
|
351
|
-
* 启动摄像头采集
|
|
352
|
-
*
|
|
353
|
-
* @param deviceId {String} - 摄像头设备 Id
|
|
354
|
-
*
|
|
355
|
-
* @fires [onCameraSourceStarted]{@link TRTCLocalMediaTranscodingEvent#onCameraSourceStarted}
|
|
356
|
-
*/
|
|
357
|
-
startCameraSource(deviceId: string): void;
|
|
358
|
-
/**
|
|
359
|
-
* 设置摄像头采集参数
|
|
360
|
-
*
|
|
361
|
-
* @param deviceId {String} - 摄像头设备 Id
|
|
362
|
-
* @param cameraCaptureParams {TRTCCameraCaptureParams} - 指定摄像头采集分辨率和帧率
|
|
363
|
-
*/
|
|
364
|
-
setCameraCaptureParams(deviceId: string, cameraCaptureParams: TRTCCameraCaptureParams): void;
|
|
365
|
-
/**
|
|
366
|
-
* 停止摄像头采集
|
|
367
|
-
* @param deviceId {String} - 摄像头设备 Id
|
|
368
|
-
*
|
|
369
|
-
* @fires [onCameraSourceStopped]{@link TRTCLocalMediaTranscodingEvent#onCameraSourceStopped}
|
|
370
|
-
*/
|
|
371
|
-
stopCameraSource(deviceId: string): void;
|
|
372
|
-
/**
|
|
373
|
-
* 启动屏幕/窗口采集
|
|
374
|
-
*
|
|
375
|
-
* @param source {TRTCScreenCaptureSourceInfo} - 屏幕/窗口采集的详细参数
|
|
376
|
-
* @param rect {Rect} - 指定捕获的区域
|
|
377
|
-
*
|
|
378
|
-
* @fires [onScreenSourceStarted]{@link TRTCLocalMediaTranscodingEvent#onScreenSourceStarted}
|
|
379
|
-
*/
|
|
380
|
-
startScreenSource(source: TRTCScreenCaptureSourceInfo, rect: Rect): void;
|
|
381
|
-
/**
|
|
382
|
-
* 停止屏幕/窗口采集
|
|
383
|
-
* @param sourceId {String} - 屏幕/窗口的 Id
|
|
384
|
-
*
|
|
385
|
-
* @fires [onScreenSourceStopped]{@link TRTCLocalMediaTranscodingEvent#onScreenSourceStopped}
|
|
386
|
-
*/
|
|
387
|
-
stopScreenSource(sourceId: string): void;
|
|
388
|
-
/**
|
|
389
|
-
* 启动图片采集
|
|
390
|
-
* @param path {String} - 图片路径 ,目前只支持 BMP、JPG、PNG、GIF 四种格式
|
|
391
|
-
* @param fps {Number} - 采集输出帧率,可以不设置由 SDK 做最佳决策
|
|
392
|
-
*
|
|
393
|
-
* @fires [onImageSourceStarted]{@link TRTCLocalMediaTranscodingEvent#onImageSourceStarted}
|
|
394
|
-
*/
|
|
395
|
-
addImageSource(path: string, fps: number): void;
|
|
396
|
-
/**
|
|
397
|
-
* 停止图片采集
|
|
398
|
-
* @param path {String} - 图片路径
|
|
399
|
-
*
|
|
400
|
-
* @fires [onImageSourceStopped]{@link TRTCLocalMediaTranscodingEvent#onImageSourceStopped}
|
|
401
|
-
*/
|
|
402
|
-
removeImageSource(path: string): void;
|
|
403
|
-
/**
|
|
404
|
-
* 设置本地混流转码视频预览节点
|
|
405
|
-
* @param view {HTMLElement | null} - 如果传入的是 HTML 元素,必须是块元素;传入 null 时,会停止视频预览
|
|
406
|
-
*/
|
|
407
|
-
setMixedVideoRenderView(view: HTMLElement | null): void;
|
|
408
|
-
private setMixedVideoFrameRenderCallback;
|
|
409
|
-
private unsetMixedVideoFrameRenderCallback;
|
|
410
|
-
private setEventCallback;
|
|
411
|
-
private renderMixedVideoFrame;
|
|
412
|
-
}
|
|
413
|
-
export default TRTCLocalMediaTranscoder;
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { EventEmitter } from 'events';
|
|
3
|
+
import { TRTCVideoStreamType, TRTCScreenCaptureSourceInfo, Rect, TRTCVideoEncParam, TRTCVideoPixelFormat, TRTCRenderParams, TRTCCameraCaptureParams } from '../trtc_define';
|
|
4
|
+
export declare enum TRTCLocalMediaTranscodingError {
|
|
5
|
+
Success = 0,
|
|
6
|
+
Error = -1,
|
|
7
|
+
InvalidParams = -2,
|
|
8
|
+
NotFoundSource = -3,
|
|
9
|
+
ImageSourceLoadFailed = -4
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* @namespace TRTCLocalMediaTranscodingEvent
|
|
13
|
+
* @description 目前只支持 Windows
|
|
14
|
+
*/
|
|
15
|
+
export declare enum TRTCLocalMediaTranscodingEvents {
|
|
16
|
+
/**
|
|
17
|
+
* @description 本地混流转码开启的事件
|
|
18
|
+
*
|
|
19
|
+
* 当您调用 [startTranscoding]{@link TRTCLocalMediaTranscoder#startTranscoding} 时启动本地混流转码时,是否启动成功会通过此回调同步给您。
|
|
20
|
+
*
|
|
21
|
+
* @event TRTCLocalMediaTranscodingEvent#onTranscodingStarted
|
|
22
|
+
* @param {TRTCLocalMediaTranscodingError} errCode - 错误码。
|
|
23
|
+
* @param {String} errMsg - 错误信息。
|
|
24
|
+
*/
|
|
25
|
+
onTranscodingStarted = "onTranscodingStarted",
|
|
26
|
+
/**
|
|
27
|
+
* @description 本地混流转码停止的事件
|
|
28
|
+
*
|
|
29
|
+
* 当您通过 [stopTranscoding]{@link TRTCLocalMediaTranscoder#stopTranscoding} 停止本地混流转码时,SDK 便会抛出此事件。
|
|
30
|
+
*
|
|
31
|
+
* @event TRTCLocalMediaTranscodingEvent#onTranscodingStopped
|
|
32
|
+
* @param {Number} reason - 停止原因,0:用户主动停止;1:被动停止,有可能采集源失效了
|
|
33
|
+
* @param {String} errMsg - 停止原因描述信息。
|
|
34
|
+
*/
|
|
35
|
+
onTranscodingStopped = "onTranscodingStopped",
|
|
36
|
+
/**
|
|
37
|
+
* @description 本地摄像头开启的事件
|
|
38
|
+
* 当您调用 [startCameraSource]{@link TRTCLocalMediaTranscoder#startCameraSource} 打开摄像头时,是否启动成功会通过此回调同步给您。
|
|
39
|
+
*
|
|
40
|
+
* @event TRTCLocalMediaTranscodingEvent#onCameraSourceStarted
|
|
41
|
+
* @param {String} deviceId - 摄像头设备 Id 。
|
|
42
|
+
* @param {TRTCLocalMediaTranscodingError} errCode - 错误码。
|
|
43
|
+
* @param {String} errMsg - 错误信息。
|
|
44
|
+
*/
|
|
45
|
+
onCameraSourceStarted = "onCameraSourceStarted",
|
|
46
|
+
/**
|
|
47
|
+
* @description 本地摄像头停止的事件
|
|
48
|
+
*
|
|
49
|
+
* @event TRTCLocalMediaTranscodingEvent#onCameraSourceStopped
|
|
50
|
+
* @param {String} deviceId - 摄像头设备 Id 。
|
|
51
|
+
* @param {String} reasonMsg - 停止原因描述信息。
|
|
52
|
+
*/
|
|
53
|
+
onCameraSourceStopped = "onCameraSourceStopped",
|
|
54
|
+
/**
|
|
55
|
+
* @description 图片混流开启的事件
|
|
56
|
+
* 当您调用 [addImageSource]{@link TRTCLocalMediaTranscoder#addImageSource} 打开摄像头时,是否启动成功会通过此回调同步给您。
|
|
57
|
+
*
|
|
58
|
+
* @event TRTCLocalMediaTranscodingEvent#onImageSourceStarted
|
|
59
|
+
* @param {String} imagePath - 图片路径 。
|
|
60
|
+
* @param {TRTCLocalMediaTranscodingError} errCode - 错误码。
|
|
61
|
+
* @param {String} errMsg - 错误信息。
|
|
62
|
+
*/
|
|
63
|
+
onImageSourceStarted = "onImageSourceStarted",
|
|
64
|
+
/**
|
|
65
|
+
* @description 图片混流停止的事件
|
|
66
|
+
* @event TRTCLocalMediaTranscodingEvent#onImageSourceStopped
|
|
67
|
+
* @param {String} imagePath - 图片路径 。
|
|
68
|
+
*/
|
|
69
|
+
onImageSourceStopped = "onImageSourceStopped",
|
|
70
|
+
/**
|
|
71
|
+
* @description 屏幕分享开启的事件
|
|
72
|
+
* * 当您通过 [startScreenSource]{@link TRTCLocalMediaTranscoder#startScreenSource} 等相关接口启动屏幕分享时,SDK 便会抛出此事件回调。
|
|
73
|
+
*
|
|
74
|
+
* @event TRTCLocalMediaTranscodingEvent#onScreenSourceStarted
|
|
75
|
+
* @param {String} sourceId - 屏幕或者窗口 Id 。
|
|
76
|
+
* @param {TRTCLocalMediaTranscodingError} errCode - 错误码。
|
|
77
|
+
* @param {String} errMsg - 错误信息。
|
|
78
|
+
*/
|
|
79
|
+
onScreenSourceStarted = "onScreenSourceStarted",
|
|
80
|
+
/**
|
|
81
|
+
* @description 屏幕分享暂停的事件
|
|
82
|
+
* @event TRTCLocalMediaTranscodingEvent#onScreenSourcePaused
|
|
83
|
+
* @param {String} sourceId - 屏幕或者窗口 Id 。
|
|
84
|
+
* @param {int} reason - 原因:
|
|
85
|
+
* - 1:注意此字段的含义在 MAC 和 Windows
|
|
86
|
+
* 平台有稍微差异。屏幕窗口不可见暂停(Mac)。表示设置屏幕分享参数导致的暂停(Windows)。
|
|
87
|
+
* - 2:表示屏幕分享窗口被最小化导致的暂停(仅 Windows)。
|
|
88
|
+
* - 3:表示屏幕分享窗口被隐藏导致的暂停(仅 Windows)。
|
|
89
|
+
*/
|
|
90
|
+
onScreenSourcePaused = "onScreenSourcePaused",
|
|
91
|
+
/**
|
|
92
|
+
* @description 屏幕分享恢复的事件
|
|
93
|
+
* @event TRTCLocalMediaTranscodingEvent#onScreenSourceResumed
|
|
94
|
+
* @param {String} sourceId - 屏幕或者窗口 Id 。
|
|
95
|
+
* @param {int} reason - 原因:
|
|
96
|
+
* - 1:注意此字段的含义在 MAC 和 Windows
|
|
97
|
+
* 平台有稍微差异。屏幕窗口恢复可见从而恢复分享(Mac)。屏幕分享参数设置完毕后自动恢复(Windows)。
|
|
98
|
+
* - 2:表示屏幕分享窗口从最小化被恢复(仅 Windows)。
|
|
99
|
+
* - 3:表示屏幕分享窗口从隐藏被恢复(仅 Windows)。
|
|
100
|
+
*/
|
|
101
|
+
onScreenSourceResumed = "onScreenSourceResumed",
|
|
102
|
+
/**
|
|
103
|
+
* @description 屏幕分享停止的事件
|
|
104
|
+
* 当您通过 [stopScreenSource]{@link TRTCLocalMediaTranscoder#stopScreenSource} 停止屏幕分享时,SDK 便会抛出此事件回调。
|
|
105
|
+
*
|
|
106
|
+
* @event TRTCLocalMediaTranscodingEvent#onScreenSourceStopped
|
|
107
|
+
* @param {String} sourceId - 屏幕或者窗口 Id 。
|
|
108
|
+
* @param {int} reason - 原因:0:用户主动停止;1:屏幕窗口关闭导致停止;2:表示屏幕分享的显示屏状态变更(如接口被拔出、投影模式变更等)。
|
|
109
|
+
*/
|
|
110
|
+
onScreenSourceStopped = "onScreenSourceStopped"
|
|
111
|
+
}
|
|
112
|
+
export declare enum TRTCLocalMediaTranscodingSourceType {
|
|
113
|
+
MediaSourceCamera = 0,
|
|
114
|
+
MediaSourceScreen = 1,
|
|
115
|
+
MediaSourceImage = 2,
|
|
116
|
+
MediaSourceRemoteVideo = 3
|
|
117
|
+
}
|
|
118
|
+
export declare type TRTCLocalMediaTranscodingSource = {
|
|
119
|
+
sourceType: TRTCLocalMediaTranscodingSourceType;
|
|
120
|
+
cameraDeviceId?: string;
|
|
121
|
+
screenSourceId?: string;
|
|
122
|
+
imagePath?: string;
|
|
123
|
+
userId?: string;
|
|
124
|
+
rect: Rect;
|
|
125
|
+
zOrder: number;
|
|
126
|
+
renderParams: TRTCRenderParams;
|
|
127
|
+
};
|
|
128
|
+
export declare type TRTCLocalMediaTranscodingParams = {
|
|
129
|
+
inputSourceList: TRTCLocalMediaTranscodingSource[];
|
|
130
|
+
videoEncoderParams: TRTCVideoEncParam;
|
|
131
|
+
canvasColor: number;
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* @description 本地媒体流混流转码(目前只支持 Windows)
|
|
135
|
+
*
|
|
136
|
+
* @extends EventEmitter
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
* // 运行示例
|
|
140
|
+
* import TRTCCloud, {
|
|
141
|
+
* TRTCCameraCaptureMode,
|
|
142
|
+
* TRTCVideoRotation,
|
|
143
|
+
* TRTCVideoFillMode,
|
|
144
|
+
* TRTCVideoMirrorType,
|
|
145
|
+
* TRTCVideoStreamType,
|
|
146
|
+
* TRTCLocalMediaTranscodingSourceType,
|
|
147
|
+
* TRTCVideoResolution,
|
|
148
|
+
* TRTCVideoResolutionMode,
|
|
149
|
+
* TRTCVideoPixelFormat
|
|
150
|
+
* } from 'trtc-electron-sdk';
|
|
151
|
+
*
|
|
152
|
+
* const trtcCloud = new TRTCCloud();
|
|
153
|
+
* const cameraList =trtcCloud.getCameraDevicesList();
|
|
154
|
+
*
|
|
155
|
+
* // 获取本地合图转码推流对象
|
|
156
|
+
* const localMediaTranscoder =trtcCloud.createLocalMediaTranscoder({
|
|
157
|
+
* pixelFormat: TRTCVideoPixelFormat.TRTCVideoPixelFormat_I420,
|
|
158
|
+
* });
|
|
159
|
+
*
|
|
160
|
+
* // 注册事件监听
|
|
161
|
+
* // 监听合图开始、结束事件
|
|
162
|
+
* localMediaTranscoder.on('onTranscodingStarted', (errCode: number, errMsg: string) => {
|
|
163
|
+
* console.log(`onTranscodingStarted { errCode:${errCode} errMsg:${errMsg}`);
|
|
164
|
+
* });
|
|
165
|
+
* localMediaTranscoder.on('onTranscodingStopped', (reason: number, reasonMsg: string) => {
|
|
166
|
+
* console.log(`onTranscodingStopped { reason:${reason} reasonMsg:${reasonMsg} }`);
|
|
167
|
+
* });
|
|
168
|
+
* // 监听摄像头事件
|
|
169
|
+
* localMediaTranscoder.on('onCameraSourceStarted', (deviceId: string, errCode: number, errMsg: string) => {
|
|
170
|
+
* console.log(`onCameraSourceStarted { deviceId:${deviceId} errCode:${errCode} errMsg:${errMsg} }`);
|
|
171
|
+
* });
|
|
172
|
+
* localMediaTranscoder.on('onCameraSourceStopped', (deviceId: string, reasonMsg: string) => {
|
|
173
|
+
* console.log(`onCameraSourceStopped { deviceId:${deviceId} reasonMsg:${reasonMsg}}`);
|
|
174
|
+
* });
|
|
175
|
+
* // 监听屏幕、窗口分享事件
|
|
176
|
+
* localMediaTranscoder.on('onScreenSourceStarted', (sourceId: string, errCode: number, errMsg: string) => {
|
|
177
|
+
* console.log(`onScreenSourceStarted { sourceId:${sourceId} errCode:${errCode} errMsg:${errMsg} }`);
|
|
178
|
+
* });
|
|
179
|
+
* localMediaTranscoder.on('onScreenSourceStopped', (sourceId: string, reason: number) => {
|
|
180
|
+
* console.log(`onScreenSourceStopped { sourceId:${sourceId}, reason:${reason} }`);
|
|
181
|
+
* });
|
|
182
|
+
* // 监听图片事件
|
|
183
|
+
* localMediaTranscoder.on('onImageSourceStarted', (imagePath: string, errCode: number, errMsg: string) => {
|
|
184
|
+
* console.log(`onImageSourceStarted { imagePath:${imagePath} errCode:${errCode} errMsg:${errMsg} }`);
|
|
185
|
+
* });
|
|
186
|
+
* localMediaTranscoder.on('onImageSourceStopped', (imagePath: string) => {
|
|
187
|
+
* console.log(`onImageSourceStopped { imagePath:${imagePath} }`);
|
|
188
|
+
* });
|
|
189
|
+
*
|
|
190
|
+
* // 开启摄像头一
|
|
191
|
+
* localMediaTranscoder.startCameraSource(cameraList[0].deviceId);
|
|
192
|
+
* localMediaTranscoder.setCameraCaptureParams(
|
|
193
|
+
* cameraList[0].deviceId,
|
|
194
|
+
* {
|
|
195
|
+
* mode: TRTCCameraCaptureMode.TRTCCameraResolutionStrategyAuto,
|
|
196
|
+
* width: 480,
|
|
197
|
+
* height: 480,
|
|
198
|
+
* }
|
|
199
|
+
* );
|
|
200
|
+
*
|
|
201
|
+
* // 开启摄像头二
|
|
202
|
+
* localMediaTranscoder.startCameraSource(cameraList[1].deviceId);
|
|
203
|
+
* localMediaTranscoder.setCameraCaptureParams(
|
|
204
|
+
* cameraList[1].deviceId,
|
|
205
|
+
* {
|
|
206
|
+
* mode: TRTCCameraCaptureMode.TRTCCameraResolutionStrategyAuto,
|
|
207
|
+
* width: 960,
|
|
208
|
+
* height: 540
|
|
209
|
+
* }
|
|
210
|
+
* );
|
|
211
|
+
*
|
|
212
|
+
*
|
|
213
|
+
* // 开启屏幕一
|
|
214
|
+
* localMediaTranscoder.startScreenSource(screenSourceList[0], {top:10, left:10, right:1200, bottom:800});
|
|
215
|
+
*
|
|
216
|
+
* // 开启屏幕二
|
|
217
|
+
* localMediaTranscoder.startScreenSource(screenSourceList[1], {top:0, left:0, right:0, bottom:0});
|
|
218
|
+
*
|
|
219
|
+
* // 加载图片一
|
|
220
|
+
* localMediaTranscoder.addImageSource('<please set valid image path>', 15);
|
|
221
|
+
*
|
|
222
|
+
* // 加载图片二
|
|
223
|
+
* localMediaTranscoder.addImageSource('<please set valid image path>', 15);
|
|
224
|
+
*
|
|
225
|
+
* // 启动合图转码并推流
|
|
226
|
+
* localMediaTranscoder.startTranscoding(
|
|
227
|
+
* TRTCVideoStreamType.TRTCVideoStreamTypeBig,
|
|
228
|
+
* {
|
|
229
|
+
* inputSourceList: [
|
|
230
|
+
* { // camera 1
|
|
231
|
+
* sourceType: TRTCLocalMediaTranscodingSourceType.MediaSourceCamera,
|
|
232
|
+
* cameraDeviceId: cameraList[0].deviceId,
|
|
233
|
+
* rect: { left: 0, top: 0, right: 320, bottom: 180 },
|
|
234
|
+
* zOrder: 1,
|
|
235
|
+
* renderParams: {
|
|
236
|
+
* rotation: TRTCVideoRotation.TRTCVideoRotation0,
|
|
237
|
+
* fillMode: TRTCVideoFillMode.TRTCVideoFillMode_Fit,
|
|
238
|
+
* mirrorType: TRTCVideoMirrorType.TRTCVideoMirrorType_Disable
|
|
239
|
+
* },
|
|
240
|
+
* },
|
|
241
|
+
* { // camera 2
|
|
242
|
+
* sourceType: TRTCLocalMediaTranscodingSourceType.MediaSourceCamera,
|
|
243
|
+
* cameraDeviceId: cameraList[1].deviceId,
|
|
244
|
+
* rect: {left: 320 + 20, top: 180 + 20, right: 640 + 20, bottom: 360 + 20},
|
|
245
|
+
* zOrder: 2,
|
|
246
|
+
* renderParams: {
|
|
247
|
+
* rotation: TRTCVideoRotation.TRTCVideoRotation90,
|
|
248
|
+
* fillMode: TRTCVideoFillMode.TRTCVideoFillMode_Fill,
|
|
249
|
+
* mirrorType: TRTCVideoMirrorType.TRTCVideoMirrorType_Enable
|
|
250
|
+
* },
|
|
251
|
+
* },
|
|
252
|
+
* {
|
|
253
|
+
* // screen 1
|
|
254
|
+
* sourceType: TRTCLocalMediaTranscodingSourceType.MediaSourceScreen,
|
|
255
|
+
* screenSourceId: screenSourceList[0].sourceId,
|
|
256
|
+
* rect: {left: 320 + 20, top: 0, right: 640 + 20, bottom: 180},
|
|
257
|
+
* zOrder: 3,
|
|
258
|
+
* renderParams: {
|
|
259
|
+
* rotation: TRTCVideoRotation.TRTCVideoRotation180,
|
|
260
|
+
* fillMode: TRTCVideoFillMode.TRTCVideoFillMode_Fit,
|
|
261
|
+
* mirrorType: TRTCVideoMirrorType.TRTCVideoMirrorType_Enable
|
|
262
|
+
* },
|
|
263
|
+
* },
|
|
264
|
+
* {
|
|
265
|
+
* // screen 2
|
|
266
|
+
* sourceType: TRTCLocalMediaTranscodingSourceType.MediaSourceScreen,
|
|
267
|
+
* screenSourceId: screenSourceList[1].sourceId,
|
|
268
|
+
* rect: {left: 0, top: 180 + 20, right: 320, bottom: 360 + 20},
|
|
269
|
+
* zOrder: 4,
|
|
270
|
+
* renderParams: {
|
|
271
|
+
* rotation: TRTCVideoRotation.TRTCVideoRotation270,
|
|
272
|
+
* fillMode: TRTCVideoFillMode.TRTCVideoFillMode_Fill,
|
|
273
|
+
* mirrorType: TRTCVideoMirrorType.TRTCVideoMirrorType_Auto
|
|
274
|
+
* },
|
|
275
|
+
* },
|
|
276
|
+
* { // image 1
|
|
277
|
+
* sourceType: TRTCLocalMediaTranscodingSourceType.MediaSourceImage,
|
|
278
|
+
* imagePath: '<please set valid image path>',
|
|
279
|
+
* rect: {left: 0, top: 360 + 40, right: 320, bottom: 540 + 40},
|
|
280
|
+
* zOrder: 5,
|
|
281
|
+
* renderParams: {
|
|
282
|
+
* rotation: TRTCVideoRotation.TRTCVideoRotation90, // 不会生效,参数设置将被忽略
|
|
283
|
+
* fillMode: TRTCVideoFillMode.TRTCVideoFillMode_Fit,
|
|
284
|
+
* mirrorType: TRTCVideoMirrorType.TRTCVideoMirrorType_Enable // 不会生效,参数设置将被忽略
|
|
285
|
+
* },
|
|
286
|
+
* },
|
|
287
|
+
* { // image 2
|
|
288
|
+
* sourceType: TRTCLocalMediaTranscodingSourceType.MediaSourceImage,
|
|
289
|
+
* imagePath: '<please set valid image path>',
|
|
290
|
+
* rect: {left: 320 + 20, top: 360 + 40, right: 640, bottom: 540 + 40},
|
|
291
|
+
* zOrder: 5,
|
|
292
|
+
* renderParams: {
|
|
293
|
+
* rotation: TRTCVideoRotation.TRTCVideoRotation0, // 不会生效,参数设置将被忽略
|
|
294
|
+
* fillMode: TRTCVideoFillMode.TRTCVideoFillMode_Fill,
|
|
295
|
+
* mirrorType: TRTCVideoMirrorType.TRTCVideoMirrorType_Disable // 不会生效,参数设置将被忽略
|
|
296
|
+
* },
|
|
297
|
+
* }
|
|
298
|
+
* ],
|
|
299
|
+
* videoEncoderParams: {
|
|
300
|
+
* videoResolution: TRTCVideoResolution.TRTCVideoResolution_960_720,
|
|
301
|
+
* resMode: TRTCVideoResolutionMode.TRTCVideoResolutionModeLandscape,
|
|
302
|
+
* videoFps: 30,
|
|
303
|
+
* videoBitrate: 800,
|
|
304
|
+
* minVideoBitrate: 0,
|
|
305
|
+
* enableAdjustRes: false,
|
|
306
|
+
* },
|
|
307
|
+
* canvasColor: 0xff0000, // 0x61b9f1,
|
|
308
|
+
* }
|
|
309
|
+
* );
|
|
310
|
+
*
|
|
311
|
+
* // 设置本地预览
|
|
312
|
+
* const view = document.getElementById("preview-view");
|
|
313
|
+
* localMediaTranscoder.setMixedVideoRenderView(view as HTMLElement);
|
|
314
|
+
*/
|
|
315
|
+
declare class TRTCLocalMediaTranscoder extends EventEmitter {
|
|
316
|
+
private nativeLocalMediaTranscoder;
|
|
317
|
+
private renderer;
|
|
318
|
+
private container;
|
|
319
|
+
private pixelFormat;
|
|
320
|
+
constructor(nativeLocalMediaTranscoder: any, pixelFormat?: TRTCVideoPixelFormat);
|
|
321
|
+
destroy(): void;
|
|
322
|
+
private validateTranscodingConfig;
|
|
323
|
+
/**
|
|
324
|
+
* 启动本地混流转码
|
|
325
|
+
*
|
|
326
|
+
* @param streamType {TRTCVideoStreamType} - 指定使用 TRTC 的 TRTCVideoStreamTypeBig 来推流,还是 TRTCVideoStreamTypeSub 来推流。
|
|
327
|
+
* @param params {TRTCLocalMediaTranscodingParams} - 指定本地混流转码的参数
|
|
328
|
+
* @param params.inputSourceList {TRTCLocalMediaTranscodingSource} - 【字段含义】指定转码流中的每一路输入媒体源配置的信息。
|
|
329
|
+
* -【推荐取值】该字段是一个 TRTCLocalMediaTranscodingSource 类型的数组,数组中的每一个元素都用来代表每一路输入媒体源的信息。
|
|
330
|
+
* -【特别说明】媒体源信息不支持留空,否则 TRTCLocalMediaTranscoder 的 onTranscodingStarted 会报错。
|
|
331
|
+
* @param params.videoEncoderParams {TRTCVideoEncParam} -【字段含义】转码流的视频编码参数
|
|
332
|
+
* @param params.canvasColor {Number} - 【字段含义】指定混合画面的底色。
|
|
333
|
+
* -【推荐取值】默认值:0x000000 代表黑色。格式为十六进制数字,比如:“0x61B9F1” 代表 RGB 分别为(97、158、241)。
|
|
334
|
+
*
|
|
335
|
+
* @fires [onTranscodingStarted]{@link TRTCLocalMediaTranscodingEvent#onTranscodingStarted}
|
|
336
|
+
*/
|
|
337
|
+
startTranscoding(streamType: TRTCVideoStreamType, params: TRTCLocalMediaTranscodingParams): void;
|
|
338
|
+
/**
|
|
339
|
+
* 更新本地混流转码参数
|
|
340
|
+
*
|
|
341
|
+
* @param params {TRTCLocalMediaTranscodingParams} - 指定本地混流转码的参数
|
|
342
|
+
*/
|
|
343
|
+
updateTranscodingParams(params: TRTCLocalMediaTranscodingParams): void;
|
|
344
|
+
/**
|
|
345
|
+
* 停止本地混流转码
|
|
346
|
+
*
|
|
347
|
+
* @fires [onTranscodingStopped]{@link TRTCLocalMediaTranscodingEvent#onTranscodingStopped}
|
|
348
|
+
*/
|
|
349
|
+
stopTranscoding(): void;
|
|
350
|
+
/**
|
|
351
|
+
* 启动摄像头采集
|
|
352
|
+
*
|
|
353
|
+
* @param deviceId {String} - 摄像头设备 Id
|
|
354
|
+
*
|
|
355
|
+
* @fires [onCameraSourceStarted]{@link TRTCLocalMediaTranscodingEvent#onCameraSourceStarted}
|
|
356
|
+
*/
|
|
357
|
+
startCameraSource(deviceId: string): void;
|
|
358
|
+
/**
|
|
359
|
+
* 设置摄像头采集参数
|
|
360
|
+
*
|
|
361
|
+
* @param deviceId {String} - 摄像头设备 Id
|
|
362
|
+
* @param cameraCaptureParams {TRTCCameraCaptureParams} - 指定摄像头采集分辨率和帧率
|
|
363
|
+
*/
|
|
364
|
+
setCameraCaptureParams(deviceId: string, cameraCaptureParams: TRTCCameraCaptureParams): void;
|
|
365
|
+
/**
|
|
366
|
+
* 停止摄像头采集
|
|
367
|
+
* @param deviceId {String} - 摄像头设备 Id
|
|
368
|
+
*
|
|
369
|
+
* @fires [onCameraSourceStopped]{@link TRTCLocalMediaTranscodingEvent#onCameraSourceStopped}
|
|
370
|
+
*/
|
|
371
|
+
stopCameraSource(deviceId: string): void;
|
|
372
|
+
/**
|
|
373
|
+
* 启动屏幕/窗口采集
|
|
374
|
+
*
|
|
375
|
+
* @param source {TRTCScreenCaptureSourceInfo} - 屏幕/窗口采集的详细参数
|
|
376
|
+
* @param rect {Rect} - 指定捕获的区域
|
|
377
|
+
*
|
|
378
|
+
* @fires [onScreenSourceStarted]{@link TRTCLocalMediaTranscodingEvent#onScreenSourceStarted}
|
|
379
|
+
*/
|
|
380
|
+
startScreenSource(source: TRTCScreenCaptureSourceInfo, rect: Rect): void;
|
|
381
|
+
/**
|
|
382
|
+
* 停止屏幕/窗口采集
|
|
383
|
+
* @param sourceId {String} - 屏幕/窗口的 Id
|
|
384
|
+
*
|
|
385
|
+
* @fires [onScreenSourceStopped]{@link TRTCLocalMediaTranscodingEvent#onScreenSourceStopped}
|
|
386
|
+
*/
|
|
387
|
+
stopScreenSource(sourceId: string): void;
|
|
388
|
+
/**
|
|
389
|
+
* 启动图片采集
|
|
390
|
+
* @param path {String} - 图片路径 ,目前只支持 BMP、JPG、PNG、GIF 四种格式
|
|
391
|
+
* @param fps {Number} - 采集输出帧率,可以不设置由 SDK 做最佳决策
|
|
392
|
+
*
|
|
393
|
+
* @fires [onImageSourceStarted]{@link TRTCLocalMediaTranscodingEvent#onImageSourceStarted}
|
|
394
|
+
*/
|
|
395
|
+
addImageSource(path: string, fps: number): void;
|
|
396
|
+
/**
|
|
397
|
+
* 停止图片采集
|
|
398
|
+
* @param path {String} - 图片路径
|
|
399
|
+
*
|
|
400
|
+
* @fires [onImageSourceStopped]{@link TRTCLocalMediaTranscodingEvent#onImageSourceStopped}
|
|
401
|
+
*/
|
|
402
|
+
removeImageSource(path: string): void;
|
|
403
|
+
/**
|
|
404
|
+
* 设置本地混流转码视频预览节点
|
|
405
|
+
* @param view {HTMLElement | null} - 如果传入的是 HTML 元素,必须是块元素;传入 null 时,会停止视频预览
|
|
406
|
+
*/
|
|
407
|
+
setMixedVideoRenderView(view: HTMLElement | null): void;
|
|
408
|
+
private setMixedVideoFrameRenderCallback;
|
|
409
|
+
private unsetMixedVideoFrameRenderCallback;
|
|
410
|
+
private setEventCallback;
|
|
411
|
+
private renderMixedVideoFrame;
|
|
412
|
+
}
|
|
413
|
+
export default TRTCLocalMediaTranscoder;
|