trtc-electron-sdk 10.6.403 → 10.6.404-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/liteav/trtc.d.ts +114 -25
- package/liteav/trtc.js +139 -33
- package/liteav/trtc_define.d.ts +3 -1
- package/liteav/trtc_define.js +3 -1
- package/liteav/vod_player.d.ts +51 -0
- package/liteav/vod_player.js +168 -0
- package/package.json +2 -1
package/liteav/trtc.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { EventEmitter } from 'events';
|
|
3
|
+
import { VodPlayer } from './vod_player';
|
|
3
4
|
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';
|
|
4
5
|
export * from './trtc_define';
|
|
5
6
|
export * from './trtc_code';
|
|
7
|
+
export * from './vod_player';
|
|
6
8
|
/**
|
|
7
9
|
* 腾讯云视频通话功能的主要接口类
|
|
8
10
|
*
|
|
@@ -42,6 +44,7 @@ declare class TRTCCloud extends EventEmitter {
|
|
|
42
44
|
private enableRenderFrame;
|
|
43
45
|
private screenCaptureStreamType;
|
|
44
46
|
private isScreenCapturing;
|
|
47
|
+
private vodPlayers;
|
|
45
48
|
constructor();
|
|
46
49
|
/**
|
|
47
50
|
* 创建 TRTCCloud 对象单例
|
|
@@ -239,7 +242,7 @@ declare class TRTCCloud extends EventEmitter {
|
|
|
239
242
|
* 如果 userId 为 null,表示开始渲染本地采集的摄像头画面,需要您先调用 [startLocalPreview()]{@link TRTCCloud#startLocalPreview} 触发。
|
|
240
243
|
* 如果 userId 不为 null,表示开始渲染远程用户的首帧画面,需要您先调用 [startRemoteView()]{@link TRTCCloud#startRemoteView} 触发。
|
|
241
244
|
*
|
|
242
|
-
* 注意:只有当您调用 startLocalPreview()
|
|
245
|
+
* 注意:只有当您调用 startLocalPreview() 或 startRemoteView() 之后,才会触发该回调。
|
|
243
246
|
*
|
|
244
247
|
* @event TRTCCallback#onFirstVideoFrame
|
|
245
248
|
* @param {String} userId - 本地或远程用户 ID,如果 userId == '' 代表本地,userId != '' 代表远程。
|
|
@@ -807,13 +810,16 @@ declare class TRTCCloud extends EventEmitter {
|
|
|
807
810
|
* 2.3 开始向非腾讯云的直播 CDN 转推
|
|
808
811
|
*
|
|
809
812
|
* 该接口跟 startPublishing() 类似,但 startPublishCDNStream() 支持向非腾讯云的直播 CDN 转推。
|
|
810
|
-
*
|
|
811
|
-
*
|
|
813
|
+
*
|
|
814
|
+
* 注意:
|
|
815
|
+
* - 使用 startPublishing() 绑定腾讯云直播 CDN 不收取额外的费用。
|
|
816
|
+
* - 使用 startPublishCDNStream() 绑定非腾讯云直播 CDN 需要收取转推费用,且需要通过工单联系我们开通。
|
|
812
817
|
*
|
|
813
818
|
* @param {TRTCPublishCDNParam} param - 转推参数
|
|
814
|
-
* @param {Number} param.appId -
|
|
815
|
-
* @param {Number} param.bizId -
|
|
816
|
-
* @param {String} param.url -
|
|
819
|
+
* @param {Number} param.appId - 腾讯云直播服务的 AppID
|
|
820
|
+
* @param {Number} param.bizId - 腾讯云直播服务的 bizid
|
|
821
|
+
* @param {String} param.url - 指定该路音视频流在第三方直播服务商的推流地址,推流 URL 必须为 RTMP 格式,必须符合您的目标直播服务商的规范要求,否则目标服务商会拒绝来自 TRTC 后台服务的推流请求。
|
|
822
|
+
* @param {String} param.streamId - 需要转推的 streamId,默认值:空值。如果不填写,则默认转推调用者的旁路流。
|
|
817
823
|
*/
|
|
818
824
|
startPublishCDNStream(param: any): void;
|
|
819
825
|
/**
|
|
@@ -1435,12 +1441,10 @@ declare class TRTCCloud extends EventEmitter {
|
|
|
1435
1441
|
* - yOffset:水印的坐标,取值范围为0 - 1的浮点数。
|
|
1436
1442
|
* - fWidthRatio:水印的大小比例,取值范围为0 - 1的浮点数。
|
|
1437
1443
|
*
|
|
1438
|
-
* 注意:Windows 平台不支持设置水印
|
|
1439
|
-
*
|
|
1440
1444
|
* @param {TRTCVideoStreamType} streamType - 要设置水印的流类型(TRTCVideoStreamTypeBig、TRTCVideoStreamTypeSub)
|
|
1441
|
-
* @param {ArrayBuffer} srcData - 水印图片源数据(传 null 表示去掉水印)
|
|
1445
|
+
* @param {ArrayBuffer|String} srcData - 水印图片源数据(传 null 表示去掉水印)
|
|
1442
1446
|
* @param {TRTCWaterMarkSrcType} srcType - 水印图片源数据类型
|
|
1443
|
-
* - TRTCWaterMarkSrcTypeFile :
|
|
1447
|
+
* - TRTCWaterMarkSrcTypeFile : 图片文件路径,支持 BMP、GIF、JPEG、PNG、TIFF、Exif、WMF 和 EMF 文件格式
|
|
1444
1448
|
* - TRTCWaterMarkSrcTypeBGRA32: BGRA32格式内存块
|
|
1445
1449
|
* - TRTCWaterMarkSrcTypeRGBA32: RGBA32格式内存块
|
|
1446
1450
|
* @param {Number} nWidth - 水印图片像素宽度(源数据为文件路径时忽略该参数)
|
|
@@ -1449,7 +1453,7 @@ declare class TRTCCloud extends EventEmitter {
|
|
|
1449
1453
|
* @param {Number} yOffset - 水印显示的左上角 y 轴偏移
|
|
1450
1454
|
* @param {Number} fWidthRatio - 水印显示的宽度占画面宽度比例(水印按该参数等比例缩放显示)
|
|
1451
1455
|
*/
|
|
1452
|
-
setWaterMark(streamType: TRTCVideoStreamType, srcData: ArrayBuffer | null, srcType: TRTCWaterMarkSrcType, nWidth: number, nHeight: number, xOffset: number, yOffset: number, fWidthRatio: number): void;
|
|
1456
|
+
setWaterMark(streamType: TRTCVideoStreamType, srcData: ArrayBuffer | string | null, srcType: TRTCWaterMarkSrcType, nWidth: number, nHeight: number, xOffset: number, yOffset: number, fWidthRatio: number): void;
|
|
1453
1457
|
/**
|
|
1454
1458
|
* 8.1 废弃接口: 开始显示远端用户的辅路画面(TRTCVideoStreamTypeSub,一般用于屏幕分享)
|
|
1455
1459
|
*
|
|
@@ -1530,20 +1534,56 @@ declare class TRTCCloud extends EventEmitter {
|
|
|
1530
1534
|
* @param {Rect} captureRect - 指定捕获的区域
|
|
1531
1535
|
* @param {TRTCScreenCaptureProperty} property - 指定屏幕分享目标的属性,包括捕获鼠标,高亮捕获窗口等,详情参考TRTCScreenCaptureProperty 定义
|
|
1532
1536
|
*
|
|
1533
|
-
*
|
|
1534
|
-
*
|
|
1535
|
-
*
|
|
1536
|
-
*
|
|
1537
|
-
*
|
|
1538
|
-
*
|
|
1539
|
-
*
|
|
1540
|
-
*
|
|
1541
|
-
*
|
|
1542
|
-
*
|
|
1543
|
-
*
|
|
1544
|
-
*
|
|
1545
|
-
*
|
|
1546
|
-
*
|
|
1537
|
+
* @example
|
|
1538
|
+
* // 示例1: 选择要分享的窗口或屏幕
|
|
1539
|
+
* import TRTCCloud, {
|
|
1540
|
+
* Rect,
|
|
1541
|
+
* TRTCScreenCaptureProperty
|
|
1542
|
+
* } from 'trtc-electron-sdk';
|
|
1543
|
+
*
|
|
1544
|
+
* const rtcCloud = new TRTCCloud();
|
|
1545
|
+
*
|
|
1546
|
+
* const screenAndWindows = rtcCloud.getScreenCaptureSources(320, 180, 32, 32);
|
|
1547
|
+
*
|
|
1548
|
+
* const selectedScreenOrWindow = screenAndWindows[0];
|
|
1549
|
+
*
|
|
1550
|
+
* const selectRect = new Rect(0, 0, 0, 0);
|
|
1551
|
+
*
|
|
1552
|
+
* const captureProperty = new TRTCScreenCaptureProperty(
|
|
1553
|
+
* true, // enable capture mouse
|
|
1554
|
+
* true, // enable highlight
|
|
1555
|
+
* true, // enable high performance
|
|
1556
|
+
* 0, // default highlight color
|
|
1557
|
+
* 0, // default highlight width
|
|
1558
|
+
* false // disable capture child window
|
|
1559
|
+
* );
|
|
1560
|
+
*
|
|
1561
|
+
* rtcCloud.selectScreenCaptureTarget(
|
|
1562
|
+
* selectedScreenOrWindow,
|
|
1563
|
+
* selectRect,
|
|
1564
|
+
* captureProperty
|
|
1565
|
+
* );
|
|
1566
|
+
*
|
|
1567
|
+
* @example
|
|
1568
|
+
* // 示例2: 选择要分享的窗口或屏幕,废弃的接口调用方式
|
|
1569
|
+
* import TRTCCloud, { Rect } from 'trtc-electron-sdk';
|
|
1570
|
+
*
|
|
1571
|
+
* const rtcCloud = new TRTCCloud();
|
|
1572
|
+
*
|
|
1573
|
+
* const screenAndWindows = rtcCloud.getScreenCaptureSources(320, 180, 32, 32);
|
|
1574
|
+
*
|
|
1575
|
+
* const selectedScreenOrWindow = screenAndWindows[0];
|
|
1576
|
+
*
|
|
1577
|
+
* const selectRect = new Rect(0, 0, 0, 0);
|
|
1578
|
+
*
|
|
1579
|
+
* rtcCloud.selectScreenCaptureTarget(
|
|
1580
|
+
* selectedScreenOrWindow.type,
|
|
1581
|
+
* selectedScreenOrWindow.sourceId,
|
|
1582
|
+
* selectedScreenOrWindow.sourceName,
|
|
1583
|
+
* selectRect,
|
|
1584
|
+
* true, // enable capture mouse
|
|
1585
|
+
* true // enable highlight
|
|
1586
|
+
* );
|
|
1547
1587
|
*/
|
|
1548
1588
|
selectScreenCaptureTarget(source: TRTCScreenCaptureSourceInfo | number, captureRect: Rect | string, property: TRTCScreenCaptureProperty | string, deprecatedCaptureRect?: Rect, captureMouse?: boolean, highlightWindow?: boolean): any;
|
|
1549
1589
|
/**
|
|
@@ -1556,6 +1596,53 @@ declare class TRTCCloud extends EventEmitter {
|
|
|
1556
1596
|
* @param {HTMLElement} view - 承载预览画面的 DOM
|
|
1557
1597
|
* @param {TRTCVideoStreamType} type 屏幕分享使用的线路,可以设置为主路(TRTCVideoStreamTypeBig)或者辅路(TRTCVideoStreamTypeSub),默认使用辅路。
|
|
1558
1598
|
* @param {TRTCVideoEncParam} params 屏幕分享的画面编码参数,可以设置为 null,表示让 SDK 选择最佳的编码参数(分辨率、码率等)。即使在调用 startScreenCapture 时设置 type=TRTCVideoStreamTypeBig,依然可以使用此接口更新屏幕分享的编码参数。
|
|
1599
|
+
*
|
|
1600
|
+
* @example
|
|
1601
|
+
* // 分享屏幕或窗口
|
|
1602
|
+
* import TRTCCloud, {
|
|
1603
|
+
* TRTCVideoStreamType,
|
|
1604
|
+
* TRTCVideoEncParam,
|
|
1605
|
+
* TRTCVideoResolution,
|
|
1606
|
+
* TRTCVideoResolutionMode
|
|
1607
|
+
* } from 'trtc-electron-sdk';
|
|
1608
|
+
*
|
|
1609
|
+
* const rtcCloud = new TRTCCloud();
|
|
1610
|
+
*
|
|
1611
|
+
* const screenAndWindows = rtcCloud.getScreenCaptureSources(320, 180, 32, 32);
|
|
1612
|
+
*
|
|
1613
|
+
* const selectedScreenOrWindow = screenAndWindows[0];
|
|
1614
|
+
*
|
|
1615
|
+
* const selectRect = new Rect(0, 0, 0, 0);
|
|
1616
|
+
*
|
|
1617
|
+
* const captureProperty = new TRTCScreenCaptureProperty(
|
|
1618
|
+
* true, // enable capture mouse
|
|
1619
|
+
* true, // enable highlight
|
|
1620
|
+
* true, // enable high performance
|
|
1621
|
+
* 0, // default highlight color
|
|
1622
|
+
* 0, // default highlight width
|
|
1623
|
+
* false // disable capture child window
|
|
1624
|
+
* );
|
|
1625
|
+
*
|
|
1626
|
+
* rtcCloud.selectScreenCaptureTarget(
|
|
1627
|
+
* selectedScreenOrWindow,
|
|
1628
|
+
* selectRect,
|
|
1629
|
+
* captureProperty
|
|
1630
|
+
* );
|
|
1631
|
+
*
|
|
1632
|
+
* const screenShareEncParam = new TRTCVideoEncParam(
|
|
1633
|
+
* TRTCVideoResolution.TRTCVideoResolution_1280_720,
|
|
1634
|
+
* TRTCVideoResolutionMode.TRTCVideoResolutionModeLandscape,
|
|
1635
|
+
* 15,
|
|
1636
|
+
* 1600,
|
|
1637
|
+
* 0,
|
|
1638
|
+
* true,
|
|
1639
|
+
* );
|
|
1640
|
+
*
|
|
1641
|
+
* rtcCloud.startScreenCapture(
|
|
1642
|
+
* view, // HTML Element
|
|
1643
|
+
* TRTCVideoStreamType.TRTCVideoStreamTypeSub,
|
|
1644
|
+
* screenShareEncParam,
|
|
1645
|
+
* );
|
|
1559
1646
|
*/
|
|
1560
1647
|
startScreenCapture(view?: HTMLElement | null, type?: TRTCVideoStreamType, params?: any): void;
|
|
1561
1648
|
/**
|
|
@@ -2091,6 +2178,8 @@ declare class TRTCCloud extends EventEmitter {
|
|
|
2091
2178
|
getPluginList(): PluginInfo[];
|
|
2092
2179
|
createPlugin(pluginId: string): PluginInfo;
|
|
2093
2180
|
setPluginCallback(pluginCb: (pluginId: string, errorCode: number, msg: string) => void): void;
|
|
2181
|
+
createVodPlayer(mediaFilePath: string, repeat: boolean): VodPlayer;
|
|
2182
|
+
destroyVodPlayer(vodPlayer: VodPlayer): void;
|
|
2094
2183
|
getKey(uid: string, type: TRTCVideoStreamType): string;
|
|
2095
2184
|
setEnableRenderFrame(enable: boolean): void;
|
|
2096
2185
|
_getRenderer(uid: string, type: TRTCVideoStreamType): any;
|
package/liteav/trtc.js
CHANGED
|
@@ -21,6 +21,7 @@ const events_1 = require("events");
|
|
|
21
21
|
const Renderer_1 = require("./Renderer");
|
|
22
22
|
const util_1 = require("./Render/util");
|
|
23
23
|
const yuv_buffer_1 = __importDefault(require("./Renderer/yuv-buffer"));
|
|
24
|
+
const vod_player_1 = require("./vod_player");
|
|
24
25
|
// @ts-ignore
|
|
25
26
|
const YCbCr_1 = __importDefault(require("yuv-canvas/src/YCbCr"));
|
|
26
27
|
const trtc_define_1 = require("./trtc_define");
|
|
@@ -28,6 +29,7 @@ const trtc = require('../build/Release/trtc_electron_sdk.node');
|
|
|
28
29
|
const pkg = require('../package.json');
|
|
29
30
|
__exportStar(require("./trtc_define"), exports);
|
|
30
31
|
__exportStar(require("./trtc_code"), exports);
|
|
32
|
+
__exportStar(require("./vod_player"), exports);
|
|
31
33
|
// 监听该事件,返回自定义视频渲染数据 ( bgra 格式)
|
|
32
34
|
const CUSTOM_VIDEO_DATA = 'onVideoData';
|
|
33
35
|
const CAMERA_DEVICE_TEST_VIEW = 'camera_device_test_view';
|
|
@@ -192,6 +194,7 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
192
194
|
//VideoCallback 本地和远程
|
|
193
195
|
this.localVideoCallback = null;
|
|
194
196
|
this.remoteVideoCallback = new Map();
|
|
197
|
+
this.vodPlayers = {};
|
|
195
198
|
secMethods(this);
|
|
196
199
|
this.callExperimentalAPI("{\"api\":\"setCurrentEnvironment\",\"params\" :{\"electron\":true}}");
|
|
197
200
|
}
|
|
@@ -677,7 +680,7 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
677
680
|
* 如果 userId 为 null,表示开始渲染本地采集的摄像头画面,需要您先调用 [startLocalPreview()]{@link TRTCCloud#startLocalPreview} 触发。
|
|
678
681
|
* 如果 userId 不为 null,表示开始渲染远程用户的首帧画面,需要您先调用 [startRemoteView()]{@link TRTCCloud#startRemoteView} 触发。
|
|
679
682
|
*
|
|
680
|
-
* 注意:只有当您调用 startLocalPreview()
|
|
683
|
+
* 注意:只有当您调用 startLocalPreview() 或 startRemoteView() 之后,才会触发该回调。
|
|
681
684
|
*
|
|
682
685
|
* @event TRTCCallback#onFirstVideoFrame
|
|
683
686
|
* @param {String} userId - 本地或远程用户 ID,如果 userId == '' 代表本地,userId != '' 代表远程。
|
|
@@ -1087,7 +1090,7 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
1087
1090
|
*/
|
|
1088
1091
|
handleOnScreenCaptureStarted() {
|
|
1089
1092
|
this.isScreenCapturing = true;
|
|
1090
|
-
// 只有在 Buffer 为 null 时才新建,否则只能在 handleVideoSizeChange 事件中重新申请 Buffer
|
|
1093
|
+
// 只有在 Buffer 为 null 时才新建,否则只能在 handleVideoSizeChange 事件中重新申请 Buffer
|
|
1091
1094
|
if (!screenVideoBuffer.buffer) {
|
|
1092
1095
|
screenVideoBuffer.userId = '';
|
|
1093
1096
|
screenVideoBuffer.streamType = this.screenCaptureStreamType;
|
|
@@ -1279,7 +1282,7 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
1279
1282
|
}
|
|
1280
1283
|
}
|
|
1281
1284
|
else {
|
|
1282
|
-
console.
|
|
1285
|
+
console.warn(`trtc:handleVideoSizeChange error: ${userId} ${streamType} buffer not exist`);
|
|
1283
1286
|
}
|
|
1284
1287
|
}
|
|
1285
1288
|
else {
|
|
@@ -1552,17 +1555,21 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
1552
1555
|
* 2.3 开始向非腾讯云的直播 CDN 转推
|
|
1553
1556
|
*
|
|
1554
1557
|
* 该接口跟 startPublishing() 类似,但 startPublishCDNStream() 支持向非腾讯云的直播 CDN 转推。
|
|
1555
|
-
*
|
|
1556
|
-
*
|
|
1558
|
+
*
|
|
1559
|
+
* 注意:
|
|
1560
|
+
* - 使用 startPublishing() 绑定腾讯云直播 CDN 不收取额外的费用。
|
|
1561
|
+
* - 使用 startPublishCDNStream() 绑定非腾讯云直播 CDN 需要收取转推费用,且需要通过工单联系我们开通。
|
|
1557
1562
|
*
|
|
1558
1563
|
* @param {TRTCPublishCDNParam} param - 转推参数
|
|
1559
|
-
* @param {Number} param.appId -
|
|
1560
|
-
* @param {Number} param.bizId -
|
|
1561
|
-
* @param {String} param.url -
|
|
1564
|
+
* @param {Number} param.appId - 腾讯云直播服务的 AppID
|
|
1565
|
+
* @param {Number} param.bizId - 腾讯云直播服务的 bizid
|
|
1566
|
+
* @param {String} param.url - 指定该路音视频流在第三方直播服务商的推流地址,推流 URL 必须为 RTMP 格式,必须符合您的目标直播服务商的规范要求,否则目标服务商会拒绝来自 TRTC 后台服务的推流请求。
|
|
1567
|
+
* @param {String} param.streamId - 需要转推的 streamId,默认值:空值。如果不填写,则默认转推调用者的旁路流。
|
|
1562
1568
|
*/
|
|
1563
1569
|
startPublishCDNStream(param) {
|
|
1570
|
+
const streamId = param.streamId ? param.streamId.trim() : "";
|
|
1564
1571
|
if (param instanceof trtc_define_1.TRTCPublishCDNParam) {
|
|
1565
|
-
this.rtcCloud.startPublishCDNStream(param.appId, param.bizId, param.url);
|
|
1572
|
+
this.rtcCloud.startPublishCDNStream(param.appId, param.bizId, param.url, streamId);
|
|
1566
1573
|
}
|
|
1567
1574
|
else {
|
|
1568
1575
|
console.error('trtc:startPublishCDNStream, param is not instanceof TRTCPublishCDNParam!');
|
|
@@ -1693,7 +1700,7 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
1693
1700
|
this._initRender(key, view);
|
|
1694
1701
|
}
|
|
1695
1702
|
// view 为 null 时,可能启动了自定义渲染,所以 Buffer 还是要创建,否则自定义渲染就拿不到数据;
|
|
1696
|
-
// view 非 null 时,当然必须创建 Buffer
|
|
1703
|
+
// view 非 null 时,当然必须创建 Buffer
|
|
1697
1704
|
// 只有在 Buffer 为 null 时才新建,否则只能在 handleVideoSizeChange 事件中重新申请 Buffer
|
|
1698
1705
|
if (!localVideoBuffer.buffer) {
|
|
1699
1706
|
localVideoBuffer.streamType = trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig;
|
|
@@ -1772,7 +1779,7 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
1772
1779
|
this._initRender(key, view);
|
|
1773
1780
|
}
|
|
1774
1781
|
// view 为 null 时,可能启动了自定义渲染,所以 Buffer 还是要创建,否则自定义渲染就拿不到数据;
|
|
1775
|
-
// view 非 null 时,当然必须创建 Buffer
|
|
1782
|
+
// view 非 null 时,当然必须创建 Buffer
|
|
1776
1783
|
const videoBufferInfo = {
|
|
1777
1784
|
userId: userId,
|
|
1778
1785
|
buffer: (0, util_1.allocBuffer)(DEFAULT_VIDEO_WIDTH * DEFAULT_VIDEO_HEIGHT * this.pixelLength, userId, streamType),
|
|
@@ -1945,14 +1952,14 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
1945
1952
|
* - TRTCVideoFillMode_Fit: 图像长边填满屏幕,短边区域会被填充黑色,但画面的内容肯定是完整的。
|
|
1946
1953
|
*/
|
|
1947
1954
|
setLocalViewFillMode(mode) {
|
|
1948
|
-
|
|
1955
|
+
const key = this.getKey('local_video', trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig);
|
|
1949
1956
|
if (this.streams.has(key)) {
|
|
1950
1957
|
const renderer = this.streams.get(key);
|
|
1951
1958
|
this.localFillMode = mode;
|
|
1952
1959
|
renderer.setContentMode(mode);
|
|
1953
1960
|
}
|
|
1954
1961
|
else {
|
|
1955
|
-
console.
|
|
1962
|
+
console.warn('trtc:api setLocalViewFillMode failed. the local stream does not exist.');
|
|
1956
1963
|
}
|
|
1957
1964
|
}
|
|
1958
1965
|
/**
|
|
@@ -2562,12 +2569,10 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
2562
2569
|
* - yOffset:水印的坐标,取值范围为0 - 1的浮点数。
|
|
2563
2570
|
* - fWidthRatio:水印的大小比例,取值范围为0 - 1的浮点数。
|
|
2564
2571
|
*
|
|
2565
|
-
* 注意:Windows 平台不支持设置水印
|
|
2566
|
-
*
|
|
2567
2572
|
* @param {TRTCVideoStreamType} streamType - 要设置水印的流类型(TRTCVideoStreamTypeBig、TRTCVideoStreamTypeSub)
|
|
2568
|
-
* @param {ArrayBuffer} srcData - 水印图片源数据(传 null 表示去掉水印)
|
|
2573
|
+
* @param {ArrayBuffer|String} srcData - 水印图片源数据(传 null 表示去掉水印)
|
|
2569
2574
|
* @param {TRTCWaterMarkSrcType} srcType - 水印图片源数据类型
|
|
2570
|
-
* - TRTCWaterMarkSrcTypeFile :
|
|
2575
|
+
* - TRTCWaterMarkSrcTypeFile : 图片文件路径,支持 BMP、GIF、JPEG、PNG、TIFF、Exif、WMF 和 EMF 文件格式
|
|
2571
2576
|
* - TRTCWaterMarkSrcTypeBGRA32: BGRA32格式内存块
|
|
2572
2577
|
* - TRTCWaterMarkSrcTypeRGBA32: RGBA32格式内存块
|
|
2573
2578
|
* @param {Number} nWidth - 水印图片像素宽度(源数据为文件路径时忽略该参数)
|
|
@@ -2690,20 +2695,56 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
2690
2695
|
* @param {Rect} captureRect - 指定捕获的区域
|
|
2691
2696
|
* @param {TRTCScreenCaptureProperty} property - 指定屏幕分享目标的属性,包括捕获鼠标,高亮捕获窗口等,详情参考TRTCScreenCaptureProperty 定义
|
|
2692
2697
|
*
|
|
2693
|
-
*
|
|
2694
|
-
*
|
|
2695
|
-
*
|
|
2696
|
-
*
|
|
2697
|
-
*
|
|
2698
|
-
*
|
|
2699
|
-
*
|
|
2700
|
-
*
|
|
2701
|
-
*
|
|
2702
|
-
*
|
|
2703
|
-
*
|
|
2704
|
-
*
|
|
2705
|
-
*
|
|
2706
|
-
*
|
|
2698
|
+
* @example
|
|
2699
|
+
* // 示例1: 选择要分享的窗口或屏幕
|
|
2700
|
+
* import TRTCCloud, {
|
|
2701
|
+
* Rect,
|
|
2702
|
+
* TRTCScreenCaptureProperty
|
|
2703
|
+
* } from 'trtc-electron-sdk';
|
|
2704
|
+
*
|
|
2705
|
+
* const rtcCloud = new TRTCCloud();
|
|
2706
|
+
*
|
|
2707
|
+
* const screenAndWindows = rtcCloud.getScreenCaptureSources(320, 180, 32, 32);
|
|
2708
|
+
*
|
|
2709
|
+
* const selectedScreenOrWindow = screenAndWindows[0];
|
|
2710
|
+
*
|
|
2711
|
+
* const selectRect = new Rect(0, 0, 0, 0);
|
|
2712
|
+
*
|
|
2713
|
+
* const captureProperty = new TRTCScreenCaptureProperty(
|
|
2714
|
+
* true, // enable capture mouse
|
|
2715
|
+
* true, // enable highlight
|
|
2716
|
+
* true, // enable high performance
|
|
2717
|
+
* 0, // default highlight color
|
|
2718
|
+
* 0, // default highlight width
|
|
2719
|
+
* false // disable capture child window
|
|
2720
|
+
* );
|
|
2721
|
+
*
|
|
2722
|
+
* rtcCloud.selectScreenCaptureTarget(
|
|
2723
|
+
* selectedScreenOrWindow,
|
|
2724
|
+
* selectRect,
|
|
2725
|
+
* captureProperty
|
|
2726
|
+
* );
|
|
2727
|
+
*
|
|
2728
|
+
* @example
|
|
2729
|
+
* // 示例2: 选择要分享的窗口或屏幕,废弃的接口调用方式
|
|
2730
|
+
* import TRTCCloud, { Rect } from 'trtc-electron-sdk';
|
|
2731
|
+
*
|
|
2732
|
+
* const rtcCloud = new TRTCCloud();
|
|
2733
|
+
*
|
|
2734
|
+
* const screenAndWindows = rtcCloud.getScreenCaptureSources(320, 180, 32, 32);
|
|
2735
|
+
*
|
|
2736
|
+
* const selectedScreenOrWindow = screenAndWindows[0];
|
|
2737
|
+
*
|
|
2738
|
+
* const selectRect = new Rect(0, 0, 0, 0);
|
|
2739
|
+
*
|
|
2740
|
+
* rtcCloud.selectScreenCaptureTarget(
|
|
2741
|
+
* selectedScreenOrWindow.type,
|
|
2742
|
+
* selectedScreenOrWindow.sourceId,
|
|
2743
|
+
* selectedScreenOrWindow.sourceName,
|
|
2744
|
+
* selectRect,
|
|
2745
|
+
* true, // enable capture mouse
|
|
2746
|
+
* true // enable highlight
|
|
2747
|
+
* );
|
|
2707
2748
|
*/
|
|
2708
2749
|
selectScreenCaptureTarget(source, captureRect, property, deprecatedCaptureRect, captureMouse, highlightWindow) {
|
|
2709
2750
|
if (source.sourceId && captureRect instanceof trtc_define_1.Rect && property instanceof trtc_define_1.TRTCScreenCaptureProperty) {
|
|
@@ -2734,6 +2775,53 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
2734
2775
|
* @param {HTMLElement} view - 承载预览画面的 DOM
|
|
2735
2776
|
* @param {TRTCVideoStreamType} type 屏幕分享使用的线路,可以设置为主路(TRTCVideoStreamTypeBig)或者辅路(TRTCVideoStreamTypeSub),默认使用辅路。
|
|
2736
2777
|
* @param {TRTCVideoEncParam} params 屏幕分享的画面编码参数,可以设置为 null,表示让 SDK 选择最佳的编码参数(分辨率、码率等)。即使在调用 startScreenCapture 时设置 type=TRTCVideoStreamTypeBig,依然可以使用此接口更新屏幕分享的编码参数。
|
|
2778
|
+
*
|
|
2779
|
+
* @example
|
|
2780
|
+
* // 分享屏幕或窗口
|
|
2781
|
+
* import TRTCCloud, {
|
|
2782
|
+
* TRTCVideoStreamType,
|
|
2783
|
+
* TRTCVideoEncParam,
|
|
2784
|
+
* TRTCVideoResolution,
|
|
2785
|
+
* TRTCVideoResolutionMode
|
|
2786
|
+
* } from 'trtc-electron-sdk';
|
|
2787
|
+
*
|
|
2788
|
+
* const rtcCloud = new TRTCCloud();
|
|
2789
|
+
*
|
|
2790
|
+
* const screenAndWindows = rtcCloud.getScreenCaptureSources(320, 180, 32, 32);
|
|
2791
|
+
*
|
|
2792
|
+
* const selectedScreenOrWindow = screenAndWindows[0];
|
|
2793
|
+
*
|
|
2794
|
+
* const selectRect = new Rect(0, 0, 0, 0);
|
|
2795
|
+
*
|
|
2796
|
+
* const captureProperty = new TRTCScreenCaptureProperty(
|
|
2797
|
+
* true, // enable capture mouse
|
|
2798
|
+
* true, // enable highlight
|
|
2799
|
+
* true, // enable high performance
|
|
2800
|
+
* 0, // default highlight color
|
|
2801
|
+
* 0, // default highlight width
|
|
2802
|
+
* false // disable capture child window
|
|
2803
|
+
* );
|
|
2804
|
+
*
|
|
2805
|
+
* rtcCloud.selectScreenCaptureTarget(
|
|
2806
|
+
* selectedScreenOrWindow,
|
|
2807
|
+
* selectRect,
|
|
2808
|
+
* captureProperty
|
|
2809
|
+
* );
|
|
2810
|
+
*
|
|
2811
|
+
* const screenShareEncParam = new TRTCVideoEncParam(
|
|
2812
|
+
* TRTCVideoResolution.TRTCVideoResolution_1280_720,
|
|
2813
|
+
* TRTCVideoResolutionMode.TRTCVideoResolutionModeLandscape,
|
|
2814
|
+
* 15,
|
|
2815
|
+
* 1600,
|
|
2816
|
+
* 0,
|
|
2817
|
+
* true,
|
|
2818
|
+
* );
|
|
2819
|
+
*
|
|
2820
|
+
* rtcCloud.startScreenCapture(
|
|
2821
|
+
* view, // HTML Element
|
|
2822
|
+
* TRTCVideoStreamType.TRTCVideoStreamTypeSub,
|
|
2823
|
+
* screenShareEncParam,
|
|
2824
|
+
* );
|
|
2737
2825
|
*/
|
|
2738
2826
|
startScreenCapture(view = null, type = trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSub, params = null) {
|
|
2739
2827
|
if ((type !== trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSub && type !== trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig)) {
|
|
@@ -3651,6 +3739,25 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
3651
3739
|
setPluginCallback(pluginCb) {
|
|
3652
3740
|
this.rtcCloud.setPluginCallback(pluginCb);
|
|
3653
3741
|
}
|
|
3742
|
+
//----------------------------------//
|
|
3743
|
+
// vod apis
|
|
3744
|
+
//----------------------------------//
|
|
3745
|
+
createVodPlayer(mediaFilePath, repeat) {
|
|
3746
|
+
const nativeVodPlayer = this.rtcCloud.createVodPlayer(mediaFilePath, repeat);
|
|
3747
|
+
if (nativeVodPlayer) {
|
|
3748
|
+
const vodPlayer = new vod_player_1.VodPlayer(nativeVodPlayer, mediaFilePath, repeat);
|
|
3749
|
+
vodPlayer.setVodPlayerRenderCallback();
|
|
3750
|
+
vodPlayer.setVodEventCallback();
|
|
3751
|
+
this.vodPlayers[vodPlayer.key] = vodPlayer;
|
|
3752
|
+
return vodPlayer;
|
|
3753
|
+
}
|
|
3754
|
+
return null;
|
|
3755
|
+
}
|
|
3756
|
+
destroyVodPlayer(vodPlayer) {
|
|
3757
|
+
vodPlayer.destroyRender();
|
|
3758
|
+
this.rtcCloud.destroyVodPlayer(vodPlayer.key);
|
|
3759
|
+
delete this.vodPlayers[vodPlayer.key];
|
|
3760
|
+
}
|
|
3654
3761
|
getKey(uid, type) {
|
|
3655
3762
|
return String(uid) + '_' + String(type);
|
|
3656
3763
|
}
|
|
@@ -3757,12 +3864,11 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
3757
3864
|
});
|
|
3758
3865
|
}
|
|
3759
3866
|
_initRender(key, view) {
|
|
3760
|
-
let renderer;
|
|
3761
3867
|
if (this.streams.has(String(key))) {
|
|
3762
3868
|
this._destroyRender(key, null);
|
|
3763
3869
|
}
|
|
3764
3870
|
view.innerHTML = ''; // 事先清空一下,避免画面叠加
|
|
3765
|
-
renderer = (0, Renderer_1.createRenderer)(this.pixelformate, view);
|
|
3871
|
+
const renderer = (0, Renderer_1.createRenderer)(this.pixelformate, view);
|
|
3766
3872
|
this.streams.set(String(key), renderer);
|
|
3767
3873
|
if (key === this.getKey('local_video', trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig)) {
|
|
3768
3874
|
// 只有本地视频, 才设置 local fill mode
|
package/liteav/trtc_define.d.ts
CHANGED
|
@@ -574,13 +574,15 @@ export declare class TRTCTranscodingConfig {
|
|
|
574
574
|
* @param {Number} appId - 腾讯云 AppID,请在 [实时音视频控制台](https://console.cloud.tencent.com/rav) 选择已经创建的应用,单击【帐号信息】后,在“直播信息”中获取
|
|
575
575
|
* @param {Number} bizId - 腾讯云直播 bizId,请在 [实时音视频控制台](https://console.cloud.tencent.com/rav) 选择已经创建的应用,单击【帐号信息】后,在“直播信息”中获取
|
|
576
576
|
* @param {String} url - 旁路转推的 URL
|
|
577
|
+
* @param {String} streamId - 需要转推的 streamId,默认值:空值。如果不填写,则默认转推调用者的旁路流。
|
|
577
578
|
*
|
|
578
579
|
*/
|
|
579
580
|
export declare class TRTCPublishCDNParam {
|
|
580
581
|
appId: number;
|
|
581
582
|
bizId: number;
|
|
582
583
|
url: null | string;
|
|
583
|
-
|
|
584
|
+
streamId: null | string;
|
|
585
|
+
constructor(appId?: number, bizId?: number, url?: null | string, streamId?: null | string);
|
|
584
586
|
}
|
|
585
587
|
/**
|
|
586
588
|
* 5.15 录音参数
|
package/liteav/trtc_define.js
CHANGED
|
@@ -1193,13 +1193,15 @@ exports.TRTCTranscodingConfig = TRTCTranscodingConfig;
|
|
|
1193
1193
|
* @param {Number} appId - 腾讯云 AppID,请在 [实时音视频控制台](https://console.cloud.tencent.com/rav) 选择已经创建的应用,单击【帐号信息】后,在“直播信息”中获取
|
|
1194
1194
|
* @param {Number} bizId - 腾讯云直播 bizId,请在 [实时音视频控制台](https://console.cloud.tencent.com/rav) 选择已经创建的应用,单击【帐号信息】后,在“直播信息”中获取
|
|
1195
1195
|
* @param {String} url - 旁路转推的 URL
|
|
1196
|
+
* @param {String} streamId - 需要转推的 streamId,默认值:空值。如果不填写,则默认转推调用者的旁路流。
|
|
1196
1197
|
*
|
|
1197
1198
|
*/
|
|
1198
1199
|
class TRTCPublishCDNParam {
|
|
1199
|
-
constructor(appId = 0, bizId = 0, url = null) {
|
|
1200
|
+
constructor(appId = 0, bizId = 0, url = null, streamId = null) {
|
|
1200
1201
|
this.appId = appId;
|
|
1201
1202
|
this.bizId = bizId;
|
|
1202
1203
|
this.url = url;
|
|
1204
|
+
this.streamId = streamId;
|
|
1203
1205
|
}
|
|
1204
1206
|
}
|
|
1205
1207
|
exports.TRTCPublishCDNParam = TRTCPublishCDNParam;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { EventEmitter } from 'events';
|
|
4
|
+
import { TRTCVideoRotation } from './trtc_define';
|
|
5
|
+
export declare enum PlayerEvents {
|
|
6
|
+
onVodPlayerStarted = "onVodPlayerStarted",
|
|
7
|
+
onVodPlayerProgress = "onVodPlayerProgress",
|
|
8
|
+
onVodPlayerPaused = "onVodPlayerPaused",
|
|
9
|
+
onVodPlayerResumed = "onVodPlayerResumed",
|
|
10
|
+
onVodPlayerStoped = "onVodPlayerStoped",
|
|
11
|
+
onVodPlayerError = "onVodPlayerError"
|
|
12
|
+
}
|
|
13
|
+
export declare class VodPlayer extends EventEmitter {
|
|
14
|
+
key: number;
|
|
15
|
+
private renderer;
|
|
16
|
+
private nativeVodPlayer;
|
|
17
|
+
private mediaFilePath;
|
|
18
|
+
private repeat;
|
|
19
|
+
private view;
|
|
20
|
+
private isStarted;
|
|
21
|
+
constructor(nativeVodPlayer: any, mediaFilePath: string, repeat: boolean);
|
|
22
|
+
setVodPlayerView(view: HTMLElement): void;
|
|
23
|
+
start(): void;
|
|
24
|
+
pause(): void;
|
|
25
|
+
resume(): void;
|
|
26
|
+
stop(): void;
|
|
27
|
+
seek(msPos: number): void;
|
|
28
|
+
getDuration(): number;
|
|
29
|
+
getWidth(): number;
|
|
30
|
+
getHeight(): number;
|
|
31
|
+
mute(mute: boolean): void;
|
|
32
|
+
setVolume(volume: number): void;
|
|
33
|
+
setRate(rate: number): void;
|
|
34
|
+
attachTRTC(): void;
|
|
35
|
+
detachTRTC(): void;
|
|
36
|
+
publishVideo(): void;
|
|
37
|
+
publishAudio(): void;
|
|
38
|
+
unpublishVideo(): void;
|
|
39
|
+
unpublishAudio(): void;
|
|
40
|
+
setVodPlayerRenderCallback(): void;
|
|
41
|
+
setVodEventCallback(): void;
|
|
42
|
+
_renderVodVideoFrame(frame: {
|
|
43
|
+
data: Buffer;
|
|
44
|
+
width: number;
|
|
45
|
+
height: number;
|
|
46
|
+
timestamp: number;
|
|
47
|
+
rotation: TRTCVideoRotation;
|
|
48
|
+
}): void;
|
|
49
|
+
_initRender(view: HTMLElement): void;
|
|
50
|
+
destroyRender(): void;
|
|
51
|
+
}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.VodPlayer = exports.PlayerEvents = void 0;
|
|
7
|
+
const events_1 = require("events");
|
|
8
|
+
const Render_1 = __importDefault(require("./Render"));
|
|
9
|
+
var PlayerEvents;
|
|
10
|
+
(function (PlayerEvents) {
|
|
11
|
+
PlayerEvents["onVodPlayerStarted"] = "onVodPlayerStarted";
|
|
12
|
+
PlayerEvents["onVodPlayerProgress"] = "onVodPlayerProgress";
|
|
13
|
+
PlayerEvents["onVodPlayerPaused"] = "onVodPlayerPaused";
|
|
14
|
+
PlayerEvents["onVodPlayerResumed"] = "onVodPlayerResumed";
|
|
15
|
+
PlayerEvents["onVodPlayerStoped"] = "onVodPlayerStoped";
|
|
16
|
+
PlayerEvents["onVodPlayerError"] = "onVodPlayerError";
|
|
17
|
+
})(PlayerEvents = exports.PlayerEvents || (exports.PlayerEvents = {}));
|
|
18
|
+
class VodPlayer extends events_1.EventEmitter {
|
|
19
|
+
constructor(nativeVodPlayer, mediaFilePath, repeat) {
|
|
20
|
+
super();
|
|
21
|
+
this.key = nativeVodPlayer.key;
|
|
22
|
+
this.nativeVodPlayer = nativeVodPlayer;
|
|
23
|
+
this.mediaFilePath = mediaFilePath;
|
|
24
|
+
this.repeat = repeat;
|
|
25
|
+
this.view = null;
|
|
26
|
+
this.isStarted = false;
|
|
27
|
+
}
|
|
28
|
+
setVodPlayerView(view) {
|
|
29
|
+
this.view = view;
|
|
30
|
+
this._initRender(this.view);
|
|
31
|
+
}
|
|
32
|
+
start() {
|
|
33
|
+
if (!this.isStarted) {
|
|
34
|
+
this.nativeVodPlayer.start();
|
|
35
|
+
}
|
|
36
|
+
this.isStarted = true;
|
|
37
|
+
}
|
|
38
|
+
pause() {
|
|
39
|
+
this.nativeVodPlayer.pause();
|
|
40
|
+
}
|
|
41
|
+
resume() {
|
|
42
|
+
this.nativeVodPlayer.resume();
|
|
43
|
+
}
|
|
44
|
+
stop() {
|
|
45
|
+
this.isStarted = false;
|
|
46
|
+
this.nativeVodPlayer.stop();
|
|
47
|
+
}
|
|
48
|
+
seek(msPos) {
|
|
49
|
+
this.nativeVodPlayer.seek(msPos);
|
|
50
|
+
}
|
|
51
|
+
getDuration() {
|
|
52
|
+
return this.nativeVodPlayer.getDuration();
|
|
53
|
+
}
|
|
54
|
+
getWidth() {
|
|
55
|
+
return this.nativeVodPlayer.getWidth();
|
|
56
|
+
}
|
|
57
|
+
getHeight() {
|
|
58
|
+
return this.nativeVodPlayer.getHeight();
|
|
59
|
+
}
|
|
60
|
+
mute(mute) {
|
|
61
|
+
this.nativeVodPlayer.mute(mute);
|
|
62
|
+
}
|
|
63
|
+
setVolume(volume) {
|
|
64
|
+
this.nativeVodPlayer.setVolume(volume);
|
|
65
|
+
}
|
|
66
|
+
setRate(rate) {
|
|
67
|
+
this.nativeVodPlayer.setRate(rate);
|
|
68
|
+
}
|
|
69
|
+
attachTRTC() {
|
|
70
|
+
this.nativeVodPlayer.attachTRTC();
|
|
71
|
+
}
|
|
72
|
+
detachTRTC() {
|
|
73
|
+
this.nativeVodPlayer.detachTRTC();
|
|
74
|
+
}
|
|
75
|
+
publishVideo() {
|
|
76
|
+
this.nativeVodPlayer.publishVideo();
|
|
77
|
+
}
|
|
78
|
+
publishAudio() {
|
|
79
|
+
this.nativeVodPlayer.publishAudio();
|
|
80
|
+
}
|
|
81
|
+
unpublishVideo() {
|
|
82
|
+
this.nativeVodPlayer.unpublishVideo();
|
|
83
|
+
}
|
|
84
|
+
unpublishAudio() {
|
|
85
|
+
this.nativeVodPlayer.unpublishAudio();
|
|
86
|
+
}
|
|
87
|
+
setVodPlayerRenderCallback() {
|
|
88
|
+
let callback = (width, height, timestamp, rotation, data) => {
|
|
89
|
+
this._renderVodVideoFrame({
|
|
90
|
+
data, width, height,
|
|
91
|
+
timestamp, rotation
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
this.nativeVodPlayer.setVodPlayerRenderCallback({
|
|
95
|
+
onVodVideoFrame: callback
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
setVodEventCallback() {
|
|
99
|
+
let eventCallback = (eventName, param) => {
|
|
100
|
+
if (eventName === PlayerEvents.onVodPlayerStarted) {
|
|
101
|
+
const msLength = param;
|
|
102
|
+
this.emit(eventName, msLength);
|
|
103
|
+
}
|
|
104
|
+
if (eventName === PlayerEvents.onVodPlayerProgress) {
|
|
105
|
+
const msPos = param;
|
|
106
|
+
this.emit(eventName, msPos);
|
|
107
|
+
}
|
|
108
|
+
if (eventName === PlayerEvents.onVodPlayerPaused) {
|
|
109
|
+
this.emit(eventName);
|
|
110
|
+
}
|
|
111
|
+
if (eventName === PlayerEvents.onVodPlayerResumed) {
|
|
112
|
+
this.emit(eventName);
|
|
113
|
+
}
|
|
114
|
+
if (eventName === PlayerEvents.onVodPlayerStoped) {
|
|
115
|
+
const reason = param;
|
|
116
|
+
this.emit(eventName, reason);
|
|
117
|
+
}
|
|
118
|
+
if (eventName === PlayerEvents.onVodPlayerError) {
|
|
119
|
+
const error = param;
|
|
120
|
+
this.emit(eventName, error);
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
this.nativeVodPlayer.setVodEventCallback(eventCallback);
|
|
124
|
+
}
|
|
125
|
+
_renderVodVideoFrame(frame) {
|
|
126
|
+
const { data, width, height, timestamp, rotation } = frame;
|
|
127
|
+
if (!this.renderer || !this.view) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
const newData = data.slice(0); // Electron 12 及以下版本,来自底层的帧数据必须复制一次,否则 WebGL 渲染阶段会奔溃
|
|
131
|
+
const realRotation = rotation * 90; //ratation是0, 1, 2, 3. 绘制内部使用0, 90, 180, 270
|
|
132
|
+
let ylen = width * height;
|
|
133
|
+
let ulen = width * height / 4;
|
|
134
|
+
let ydata = new Uint8Array(newData, 0, ylen);
|
|
135
|
+
let udata = new Uint8Array(newData, ylen, ulen);
|
|
136
|
+
let vdata = new Uint8Array(newData, ylen + ulen, ulen);
|
|
137
|
+
this.renderer.drawFrame({
|
|
138
|
+
width: width,
|
|
139
|
+
height: height,
|
|
140
|
+
rotation: realRotation,
|
|
141
|
+
timestamp: timestamp,
|
|
142
|
+
yUint8Array: ydata,
|
|
143
|
+
uUint8Array: udata,
|
|
144
|
+
vUint8Array: vdata,
|
|
145
|
+
isNeedRotate: false
|
|
146
|
+
});
|
|
147
|
+
ydata = null;
|
|
148
|
+
udata = null;
|
|
149
|
+
vdata = null;
|
|
150
|
+
}
|
|
151
|
+
_initRender(view) {
|
|
152
|
+
if (this.renderer) {
|
|
153
|
+
this.destroyRender();
|
|
154
|
+
}
|
|
155
|
+
this.renderer = new Render_1.default.GlRenderer();
|
|
156
|
+
view.innerHTML = ''; // 事先清空一下,避免画面叠加
|
|
157
|
+
this.renderer.bind(view);
|
|
158
|
+
}
|
|
159
|
+
destroyRender() {
|
|
160
|
+
try {
|
|
161
|
+
this.renderer.unbind();
|
|
162
|
+
this.renderer = null;
|
|
163
|
+
}
|
|
164
|
+
catch (err) {
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
exports.VodPlayer = VodPlayer;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "trtc-electron-sdk",
|
|
3
|
-
"version": "10.6.
|
|
3
|
+
"version": "10.6.404-beta.1",
|
|
4
4
|
"description": "trtc electron sdk",
|
|
5
5
|
"main": "./liteav/trtc.js",
|
|
6
6
|
"types": "./liteav/trtc.d.ts",
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"rimraf": "^3.0.2",
|
|
15
15
|
"semver": "^6.0.0",
|
|
16
16
|
"signale": "^1.4.0",
|
|
17
|
+
"yuv-buffer": "^1.0.0",
|
|
17
18
|
"yuv-canvas": "^1.2.6"
|
|
18
19
|
},
|
|
19
20
|
"devDependencies": {
|