trtc-electron-sdk 12.2.703-beta.2 → 12.2.703
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.
|
@@ -39,6 +39,7 @@ class V2LivePusher {
|
|
|
39
39
|
this.logger = new logger_1.Logger(`V2LivePusher_${this}`);
|
|
40
40
|
this._pusherVideoRenderCallback = this._pusherVideoRenderCallback.bind(this);
|
|
41
41
|
this._cameraTestVideoRenderCallback = this._cameraTestVideoRenderCallback.bind(this);
|
|
42
|
+
this._initPusherRender();
|
|
42
43
|
}
|
|
43
44
|
/**
|
|
44
45
|
* 创建 V2LivePusher 实例
|
|
@@ -93,13 +94,9 @@ class V2LivePusher {
|
|
|
93
94
|
* @param {HTMLElement | null} view - 本地摄像头预览 View。
|
|
94
95
|
*/
|
|
95
96
|
setRenderView(view) {
|
|
97
|
+
var _a;
|
|
96
98
|
this.logger.debug(`setRenderView view:${view}`);
|
|
97
|
-
|
|
98
|
-
this._initPusherRender(view);
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
this._destroyPusherRender();
|
|
102
|
-
}
|
|
99
|
+
(_a = this.pusherVideoRender) === null || _a === void 0 ? void 0 : _a.setRenderView(view);
|
|
103
100
|
}
|
|
104
101
|
/**
|
|
105
102
|
* 设置本地摄像头预览镜像
|
|
@@ -157,9 +154,13 @@ class V2LivePusher {
|
|
|
157
154
|
* @return {Number} - 参考 V2LiveCode 的定义
|
|
158
155
|
*/
|
|
159
156
|
startCamera(cameraId) {
|
|
160
|
-
var _a;
|
|
157
|
+
var _a, _b;
|
|
161
158
|
this.logger.debug(`startCamera cameraId:${cameraId}`);
|
|
162
|
-
|
|
159
|
+
(_a = this.pusherVideoRender) === null || _a === void 0 ? void 0 : _a.createRender();
|
|
160
|
+
this._setVideoRenderBuffer();
|
|
161
|
+
this._addVideoRenderCallback();
|
|
162
|
+
this.enableCustomVideoRender(true, this.pixelFormat, live_define_1.V2LiveBufferType.V2LiveBufferTypeByteBuffer);
|
|
163
|
+
return (_b = this.livePusher) === null || _b === void 0 ? void 0 : _b.startCamera(cameraId);
|
|
163
164
|
}
|
|
164
165
|
/**
|
|
165
166
|
* 关闭本地摄像头
|
|
@@ -167,9 +168,12 @@ class V2LivePusher {
|
|
|
167
168
|
* @return {Number} - 参考 V2LiveCode 的定义
|
|
168
169
|
*/
|
|
169
170
|
stopCamera() {
|
|
170
|
-
var _a;
|
|
171
|
+
var _a, _b;
|
|
171
172
|
this.logger.debug(`stopCamera`);
|
|
172
|
-
|
|
173
|
+
(_a = this.pusherVideoRender) === null || _a === void 0 ? void 0 : _a.destroyRender();
|
|
174
|
+
this._removeVideoRenderCallback();
|
|
175
|
+
this.enableCustomVideoRender(false, this.pixelFormat, live_define_1.V2LiveBufferType.V2LiveBufferTypeByteBuffer);
|
|
176
|
+
return (_b = this.livePusher) === null || _b === void 0 ? void 0 : _b.stopCamera();
|
|
173
177
|
}
|
|
174
178
|
/**
|
|
175
179
|
* 打开麦克风
|
|
@@ -343,6 +347,7 @@ class V2LivePusher {
|
|
|
343
347
|
// camera videoRender
|
|
344
348
|
this.cameraTestVideoRender = new video_render_1.VideoRender();
|
|
345
349
|
this.cameraTestVideoRender.setRenderView(view);
|
|
350
|
+
this.cameraTestVideoRender.setVideoFillMode(trtc_define_1.TRTCVideoFillMode.TRTCVideoFillMode_Fit);
|
|
346
351
|
const trtcPixelFormat = (0, converter_1.convertPixelFormatFromLive)(this.pixelFormat);
|
|
347
352
|
this.cameraTestVideoRender.setVideoPixelFormat(trtcPixelFormat);
|
|
348
353
|
// camera vudeoRender buffer
|
|
@@ -355,8 +360,10 @@ class V2LivePusher {
|
|
|
355
360
|
* 停止摄像头测试
|
|
356
361
|
*/
|
|
357
362
|
stopCameraDeviceTest() {
|
|
363
|
+
var _a;
|
|
358
364
|
this.logger.debug(`stopCameraDeviceTest`);
|
|
359
365
|
this.deviceManager.stopCameraDeviceTest();
|
|
366
|
+
(_a = this.cameraTestVideoRender) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
360
367
|
this.cameraTestVideoRender = null;
|
|
361
368
|
}
|
|
362
369
|
/**
|
|
@@ -519,21 +526,14 @@ class V2LivePusher {
|
|
|
519
526
|
(_a = this.livePusher) === null || _a === void 0 ? void 0 : _a.enableCustomVideoRender(enable, pixelFormat, bufferType);
|
|
520
527
|
}
|
|
521
528
|
// videoRender
|
|
522
|
-
_initPusherRender(
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
const trtcPixelFormat = (0, converter_1.convertPixelFormatFromLive)(this.pixelFormat);
|
|
527
|
-
this.pusherVideoRender.setVideoPixelFormat(trtcPixelFormat);
|
|
528
|
-
// sdk add renderBuffer and callback
|
|
529
|
-
this._setVideoRenderBuffer();
|
|
530
|
-
this._addVideoRenderCallback();
|
|
531
|
-
this.enableCustomVideoRender(true, this.pixelFormat, live_define_1.V2LiveBufferType.V2LiveBufferTypeByteBuffer);
|
|
532
|
-
}
|
|
533
|
-
this.pusherVideoRender.setRenderView(view);
|
|
529
|
+
_initPusherRender() {
|
|
530
|
+
this.pusherVideoRender = new video_render_1.VideoRender();
|
|
531
|
+
const trtcPixelFormat = (0, converter_1.convertPixelFormatFromLive)(this.pixelFormat);
|
|
532
|
+
this.pusherVideoRender.setVideoPixelFormat(trtcPixelFormat);
|
|
534
533
|
}
|
|
535
534
|
_destroyPusherRender() {
|
|
536
535
|
if (this.pusherVideoRender) {
|
|
536
|
+
this.pusherVideoRender.destroy();
|
|
537
537
|
this.pusherVideoRender = null;
|
|
538
538
|
}
|
|
539
539
|
this._removeVideoRenderCallback();
|
|
@@ -5,8 +5,12 @@ export declare class VideoRender {
|
|
|
5
5
|
private pixelFormat;
|
|
6
6
|
private videoBuffer;
|
|
7
7
|
private pixelLength;
|
|
8
|
+
private mode;
|
|
8
9
|
constructor();
|
|
9
|
-
|
|
10
|
+
destroy(): void;
|
|
11
|
+
setRenderView(view: HTMLElement | null): void;
|
|
12
|
+
createRender(): void;
|
|
13
|
+
destroyRender(): void;
|
|
10
14
|
getVideoBuffer(): VideoBufferInfo;
|
|
11
15
|
setVideoFillMode(mode: TRTCVideoFillMode): void;
|
|
12
16
|
setVideoPixelFormat(format: TRTCVideoPixelFormat): void;
|
|
@@ -13,27 +13,38 @@ class VideoRender {
|
|
|
13
13
|
this.pixelFormat = trtc_define_1.TRTCVideoPixelFormat.TRTCVideoPixelFormat_I420;
|
|
14
14
|
this.videoBuffer = new trtc_define_1.VideoBufferInfo();
|
|
15
15
|
this.pixelLength = 1.5;
|
|
16
|
+
this.mode = trtc_define_1.TRTCVideoFillMode.TRTCVideoFillMode_Fill;
|
|
16
17
|
this._initVideoBuffer();
|
|
17
18
|
}
|
|
19
|
+
destroy() {
|
|
20
|
+
this.destroyRender();
|
|
21
|
+
}
|
|
18
22
|
setRenderView(view) {
|
|
19
23
|
if (this.view === view) {
|
|
20
24
|
return;
|
|
21
25
|
}
|
|
22
|
-
|
|
23
|
-
|
|
26
|
+
this.view = view;
|
|
27
|
+
this.destroyRender();
|
|
28
|
+
if (view !== null) {
|
|
29
|
+
this.createRender();
|
|
24
30
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
this.videoRender
|
|
31
|
+
}
|
|
32
|
+
createRender() {
|
|
33
|
+
if (this.view !== null && this.videoRender === null) {
|
|
34
|
+
this.videoRender = (0, index_1.createRenderer)(this.pixelFormat, this.view, { type: index_1.RenderType.Video });
|
|
35
|
+
this.videoRender.setContentMode(this.mode);
|
|
30
36
|
}
|
|
31
|
-
|
|
37
|
+
}
|
|
38
|
+
destroyRender() {
|
|
39
|
+
var _a;
|
|
40
|
+
(_a = this.videoRender) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
41
|
+
this.videoRender = null;
|
|
32
42
|
}
|
|
33
43
|
getVideoBuffer() { return this.videoBuffer; }
|
|
34
44
|
setVideoFillMode(mode) {
|
|
35
45
|
var _a;
|
|
36
|
-
|
|
46
|
+
this.mode = mode;
|
|
47
|
+
(_a = this.videoRender) === null || _a === void 0 ? void 0 : _a.setContentMode(this.mode);
|
|
37
48
|
}
|
|
38
49
|
setVideoPixelFormat(format) {
|
|
39
50
|
if (this.pixelFormat === format) {
|