trtc-electron-sdk 9.5.112-beta.2 → 9.5.112-beta.5

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 CHANGED
@@ -1,8 +1,10 @@
1
1
  /// <reference types="node" />
2
2
  import { EventEmitter } from 'events';
3
- import { AudioMusicParam, Rect, TRTCAppScene, TRTCAudioEffectParam, TRTCAudioQuality, TRTCBeautyStyle, TRTCDeviceState, TRTCDeviceType, TRTCLogLevel, TRTCRenderParams, TRTCRoleType, TRTCSwitchRoomParam, TRTCVideoBufferType, TRTCVideoFillMode, TRTCVideoFrame, TRTCVideoPixelFormat, TRTCVideoRotation, TRTCVideoStreamType, TRTCWaterMarkSrcType, PluginInfo } from './trtc_define';
3
+ import { AudioMusicParam, Rect, TRTCAppScene, TRTCAudioEffectParam, TRTCAudioQuality, TRTCBeautyStyle, TRTCDeviceState, TRTCDeviceType, TRTCLogLevel, TRTCRenderParams, TRTCRoleType, TRTCSwitchRoomParam, TRTCVideoBufferType, TRTCVideoFillMode, TRTCVideoFrame, TRTCVideoPixelFormat, TRTCVideoRotation, TRTCVideoStreamType, TRTCWaterMarkSrcType, PluginInfo, TRTCScreenCaptureSourceInfo, TRTCScreenCaptureProperty } from './trtc_define';
4
4
  export * from './trtc_define';
5
5
  export * from './trtc_code';
6
+ export * from './vod_player';
7
+ import { VodPlayer } from './vod_player';
6
8
  /**
7
9
  * 腾讯云视频通话功能的主要接口类
8
10
  *
@@ -40,6 +42,7 @@ declare class TRTCCloud extends EventEmitter {
40
42
  private bgmId;
41
43
  private playAudioEffectIdList;
42
44
  private enableRenderFrame;
45
+ private vodPlayers;
43
46
  constructor();
44
47
  /**
45
48
  * 创建 TRTCCloud 对象单例
@@ -1429,21 +1432,12 @@ declare class TRTCCloud extends EventEmitter {
1429
1432
  * - 共享整个窗口:sourceInfoList 中 type 为 Window 的 source,captureRect 设为 { 0, 0, 0, 0 }
1430
1433
  * - 共享窗口区域:sourceInfoList 中 type 为 Window 的 source,captureRect 设为非 NULL,例如 { 100, 100, 300, 300 }
1431
1434
  *
1432
- * @param {TRTCScreenCaptureSourceType} type - 采集源类型
1433
- * - TRTCScreenCaptureSourceTypeWindow: 该分享目标是某一个Windows窗口
1434
- * - TRTCScreenCaptureSourceTypeScreen: 该分享目标是整个Windows桌面
1435
- * - TRTCScreenCaptureSourceTypeCustom: 该分享目标是自定义窗口区域
1436
- * @param {String} sourceId - 采集源ID,对于窗口,该字段指示窗口句柄;对于屏幕,该字段指示屏幕ID
1437
- * @param {String} sourcename - 采集源名称,UTF8编码
1438
- * @param {Rect} captureRect - 指定捕获的区域
1439
- * @param {Number} captureRect.left - 指定捕获的区域的左坐标
1440
- * @param {Number} captureRect.top - 指定捕获的区域的上坐标
1441
- * @param {Number} captureRect.right - 指定捕获的区域的右坐标
1442
- * @param {Number} captureRect.bottom - 指定捕获的区域的下坐标
1443
- * @param {Boolean} captureMouse - 指定是否捕获鼠标指针
1444
- * @param {Boolean} highlightWindow - 指定是否高亮正在共享的窗口,以及当捕获图像被遮挡时高亮遮挡窗口提示用户移走遮挡
1445
- */
1446
- selectScreenCaptureTarget(type: number, sourceId: string, sourcename: string, captureRect: Rect, captureMouse: boolean, highlightWindow: boolean): any;
1435
+ * @param {TRTCScreenCaptureSourceInfo} source - 指定分享源,详情参考TRTCScreenCaptureSourceInfo 定义
1436
+ * @param {Rect} captureRect - 指定捕获的区域
1437
+ * @param {TRTCScreenCaptureProperty} property - 指定屏幕分享目标的属性,包括捕获鼠标,高亮捕获窗口等,详情参考TRTCScreenCaptureProperty 定义
1438
+ *
1439
+ */
1440
+ selectScreenCaptureTarget(source: TRTCScreenCaptureSourceInfo | number, captureRect: Rect | string, property: TRTCScreenCaptureProperty | string, deprecatedCaptureRect?: Rect, captureMouse?: boolean, highlightWindow?: boolean): any;
1447
1441
  /**
1448
1442
  * 8.7 启动屏幕分享,支持选择使用主路或辅路进行屏幕分享。(暂不支持 mac 平台预览界面)
1449
1443
  *
@@ -1959,6 +1953,7 @@ declare class TRTCCloud extends EventEmitter {
1959
1953
  setMicVolumeOnMixing(volume: number): void;
1960
1954
  addLocalVideoRenderCallback(): void;
1961
1955
  addRemoteVideoRenderCallback(userid: string): void;
1956
+ addVodVideoRenderCallback(): void;
1962
1957
  /**
1963
1958
  * 选择绘制的模式 (webgl/yuvcanvs/)
1964
1959
  * @param {Number} mode -
@@ -1979,6 +1974,30 @@ declare class TRTCCloud extends EventEmitter {
1979
1974
  setPluginCallback(pluginCb: (pluginId: string, errorCode: number, msg: string) => void): void;
1980
1975
  getKey(uid: string, type: TRTCVideoStreamType): string;
1981
1976
  setEnableRenderFrame(enable: boolean): void;
1977
+ /**
1978
+ * 创建 vod player
1979
+ */
1980
+ createVodPlayer(mediaFilePath: string, repeat: boolean): VodPlayer;
1981
+ /**
1982
+ * 销毁 vod player
1983
+ */
1984
+ destroyVodPlayer(vodPlayer: VodPlayer): void;
1985
+ /**
1986
+ * 开始向TRTC发布辅路视频流
1987
+ */
1988
+ publishVodVideo(): void;
1989
+ /**
1990
+ * 开始向TRTC发布辅路音频流
1991
+ */
1992
+ publishVodAudio(): void;
1993
+ /**
1994
+ * 结束向TRTC发布辅路视频流
1995
+ */
1996
+ unpublishVodVideo(): void;
1997
+ /**
1998
+ * 结束向TRTC发布辅路音频流
1999
+ */
2000
+ unpublishVodAudio(): void;
1982
2001
  /**
1983
2002
  * 判断是否支持webGL
1984
2003
  * @returns {boolean}
package/liteav/trtc.js CHANGED
@@ -29,6 +29,8 @@ const trtc = require('../build/Release/trtc_electron_sdk.node');
29
29
  const pkg = require('../package.json');
30
30
  __exportStar(require("./trtc_define"), exports);
31
31
  __exportStar(require("./trtc_code"), exports);
32
+ __exportStar(require("./vod_player"), exports);
33
+ const vod_player_1 = require("./vod_player");
32
34
  // 监听该事件,返回自定义视频渲染数据 ( bgra 格式)
33
35
  const CUSTOM_VIDEO_DATA = 'onVideoData';
34
36
  const SDK_LOG_LEVEL = 2;
@@ -129,6 +131,7 @@ class TRTCCloud extends events_1.EventEmitter {
129
131
  //VideoCallback 本地和远程
130
132
  this.localVideoCallback = null;
131
133
  this.remoteVideoCallback = new Map();
134
+ this.vodPlayers = {};
132
135
  secMethods(this);
133
136
  this.callExperimentalAPI("{\"api\":\"setCurrentEnvironment\",\"params\" :{\"electron\":true}}");
134
137
  }
@@ -2290,26 +2293,28 @@ class TRTCCloud extends events_1.EventEmitter {
2290
2293
  * - 共享整个窗口:sourceInfoList 中 type 为 Window 的 source,captureRect 设为 { 0, 0, 0, 0 }
2291
2294
  * - 共享窗口区域:sourceInfoList 中 type 为 Window 的 source,captureRect 设为非 NULL,例如 { 100, 100, 300, 300 }
2292
2295
  *
2293
- * @param {TRTCScreenCaptureSourceType} type - 采集源类型
2294
- * - TRTCScreenCaptureSourceTypeWindow: 该分享目标是某一个Windows窗口
2295
- * - TRTCScreenCaptureSourceTypeScreen: 该分享目标是整个Windows桌面
2296
- * - TRTCScreenCaptureSourceTypeCustom: 该分享目标是自定义窗口区域
2297
- * @param {String} sourceId - 采集源ID,对于窗口,该字段指示窗口句柄;对于屏幕,该字段指示屏幕ID
2298
- * @param {String} sourcename - 采集源名称,UTF8编码
2299
- * @param {Rect} captureRect - 指定捕获的区域
2300
- * @param {Number} captureRect.left - 指定捕获的区域的左坐标
2301
- * @param {Number} captureRect.top - 指定捕获的区域的上坐标
2302
- * @param {Number} captureRect.right - 指定捕获的区域的右坐标
2303
- * @param {Number} captureRect.bottom - 指定捕获的区域的下坐标
2304
- * @param {Boolean} captureMouse - 指定是否捕获鼠标指针
2305
- * @param {Boolean} highlightWindow - 指定是否高亮正在共享的窗口,以及当捕获图像被遮挡时高亮遮挡窗口提示用户移走遮挡
2306
- */
2307
- selectScreenCaptureTarget(type, sourceId, sourcename, captureRect, captureMouse, highlightWindow) {
2308
- if (sourceId !== null && sourceId !== undefined && sourcename !== null && sourcename !== undefined) {
2309
- return this.rtcCloud.selectScreenCaptureTarget(type, sourceId, sourcename, captureRect.left, captureRect.top, captureRect.right, captureRect.bottom, captureMouse, highlightWindow);
2296
+ * @param {TRTCScreenCaptureSourceInfo} source - 指定分享源,详情参考TRTCScreenCaptureSourceInfo 定义
2297
+ * @param {Rect} captureRect - 指定捕获的区域
2298
+ * @param {TRTCScreenCaptureProperty} property - 指定屏幕分享目标的属性,包括捕获鼠标,高亮捕获窗口等,详情参考TRTCScreenCaptureProperty 定义
2299
+ *
2300
+ */
2301
+ selectScreenCaptureTarget(source, captureRect, property, deprecatedCaptureRect, captureMouse, highlightWindow) {
2302
+ if (source.sourceId && captureRect instanceof trtc_define_1.Rect && property instanceof trtc_define_1.TRTCScreenCaptureProperty) {
2303
+ const realSource = source;
2304
+ return this.rtcCloud.selectScreenCaptureTarget(realSource.type, realSource.sourceId, realSource.sourceName, realSource.isMinimizeWindow, captureRect.left, captureRect.top, captureRect.right, captureRect.bottom, property.enableCaptureMouse, property.enableHighLight, property.enableHighPerformance, property.highLightColor, property.highLightWidth, property.enableCaptureChildWindow);
2305
+ }
2306
+ const type = source;
2307
+ const sourceId = captureRect;
2308
+ const sourcename = property;
2309
+ if (sourceId !== null && sourceId !== undefined && sourcename !== null
2310
+ && sourcename !== undefined && deprecatedCaptureRect !== undefined && captureMouse !== undefined
2311
+ && highlightWindow !== undefined) {
2312
+ const selSource = new trtc_define_1.TRTCScreenCaptureSourceInfo(type, sourceId, sourcename);
2313
+ const selProperty = new trtc_define_1.TRTCScreenCaptureProperty(captureMouse, highlightWindow);
2314
+ return this.rtcCloud.selectScreenCaptureTarget(selSource.type, selSource.sourceId, selSource.sourceName, selSource.isMinimizeWindow, deprecatedCaptureRect.left, deprecatedCaptureRect.top, deprecatedCaptureRect.right, deprecatedCaptureRect.bottom, selProperty.enableCaptureMouse, selProperty.enableHighLight, selProperty.enableHighPerformance, selProperty.highLightColor, selProperty.highLightWidth, selProperty.enableCaptureChildWindow);
2310
2315
  }
2311
2316
  else {
2312
- console.error('selectScreenCaptureTarget, sourceId or sourcename is undefined!');
2317
+ console.error('trtc:selectScreenCaptureTarget, sourceId or sourcename is undefined!');
2313
2318
  }
2314
2319
  }
2315
2320
  /**
@@ -3121,6 +3126,11 @@ class TRTCCloud extends events_1.EventEmitter {
3121
3126
  }
3122
3127
  }, this.pixelformate);
3123
3128
  }
3129
+ addVodVideoRenderCallback() {
3130
+ this.rtcCloud.addVodVideoRenderCallback((id, type, width, height, timestamp, rotation, data) => {
3131
+ // vod 数据
3132
+ });
3133
+ }
3124
3134
  //----------------------------------//
3125
3135
  // Render
3126
3136
  //----------------------------------//
@@ -3131,6 +3141,7 @@ class TRTCCloud extends events_1.EventEmitter {
3131
3141
  * - 2 yuvcanvs
3132
3142
  */
3133
3143
  setRenderMode(mode = 1) {
3144
+ console.debug(`trtc: renderMode current: ${this.renderMode} new: ${mode}`);
3134
3145
  if (this.renderMode !== mode) {
3135
3146
  this.renderMode = mode;
3136
3147
  // 遍历原有的renderer,改为新的渲染模式
@@ -3193,6 +3204,48 @@ class TRTCCloud extends events_1.EventEmitter {
3193
3204
  console.log('setEnableRenderFrame:' + enable);
3194
3205
  this.enableRenderFrame = enable;
3195
3206
  }
3207
+ /**
3208
+ * 创建 vod player
3209
+ */
3210
+ createVodPlayer(mediaFilePath, repeat) {
3211
+ const nativeVodPlayer = this.rtcCloud.createVodPlayer(mediaFilePath, repeat);
3212
+ if (nativeVodPlayer) {
3213
+ const vodPlayer = new vod_player_1.VodPlayer(nativeVodPlayer, mediaFilePath, repeat);
3214
+ vodPlayer.setVodPlayerRenderCallback();
3215
+ vodPlayer.setVodEventCallback();
3216
+ this.vodPlayers[vodPlayer.key] = vodPlayer;
3217
+ return vodPlayer;
3218
+ }
3219
+ return null;
3220
+ }
3221
+ /**
3222
+ * 销毁 vod player
3223
+ */
3224
+ destroyVodPlayer(vodPlayer) {
3225
+ vodPlayer.destroyRender();
3226
+ this.rtcCloud.destroyVodPlayer(vodPlayer.key);
3227
+ delete this.vodPlayers[vodPlayer.key];
3228
+ }
3229
+ /**
3230
+ * 开始向TRTC发布辅路视频流
3231
+ */
3232
+ publishVodVideo() {
3233
+ }
3234
+ /**
3235
+ * 开始向TRTC发布辅路音频流
3236
+ */
3237
+ publishVodAudio() {
3238
+ }
3239
+ /**
3240
+ * 结束向TRTC发布辅路视频流
3241
+ */
3242
+ unpublishVodVideo() {
3243
+ }
3244
+ /**
3245
+ * 结束向TRTC发布辅路音频流
3246
+ */
3247
+ unpublishVodAudio() {
3248
+ }
3196
3249
  /**
3197
3250
  * 判断是否支持webGL
3198
3251
  * @returns {boolean}
@@ -3214,12 +3267,15 @@ class TRTCCloud extends events_1.EventEmitter {
3214
3267
  gl = canvas.getContext('webgl', options) || canvas.getContext('experimental-webgl', options);
3215
3268
  }
3216
3269
  catch (e) {
3270
+ console.warn('trtc:WebGL not supported');
3217
3271
  return false;
3218
3272
  }
3219
3273
  if (gl) {
3274
+ console.warn('trtc:WebGL supported');
3220
3275
  return true;
3221
3276
  }
3222
3277
  else {
3278
+ console.warn('trtc:WebGL not supported');
3223
3279
  return false;
3224
3280
  }
3225
3281
  }
@@ -142,7 +142,29 @@ export declare class TRTCScreenCaptureSourceInfo {
142
142
  constructor(type?: TRTCScreenCaptureSourceType, sourceId?: string, sourceName?: string, thumbBGRA?: TRTCImageBuffer, iconBGRA?: TRTCImageBuffer, isMinimizeWindow?: boolean);
143
143
  }
144
144
  /**
145
- * 3.6 设备信息
145
+ * 3.6 屏幕分享的进阶控制参数
146
+ *
147
+ * 该参数用于屏幕分享相关的接口 [selectScreenCaptureTarget]{@link TRTCCloud#selectScreenCaptureTarget},用于在指定分享目标时设定一系列进阶控制参数。
148
+ * 比如:是否采集鼠标、是否要采集子窗口、是否要在被分享目标周围绘制一个边框等。
149
+ *
150
+ * @param {Boolean} enableCaptureMouse - 是否采集目标内容的同时采集鼠标,默认为 true
151
+ * @param {Boolean} enableHighLight - 是否高亮正在共享的窗口(在被分享目标周围绘制一个边框),默认为 true。
152
+ * @param {Boolean} enableHighPerformance - 是否开启高性能模式(只会在分享屏幕时会生效),默认为 true。【特殊说明】开启后屏幕采集性能最佳,但会丧失抗遮挡能力,如果您同时开启 enableHighLight + enableHighPerformance,远端用户可以看到高亮的边框。
153
+ * @param {Number} highLightColor - 指定高亮边框的颜色,RGB 格式,传入 0 时代表采用默认颜色,默认颜色为 #8CBF26。
154
+ * @param {Number} highLightWidth - 指定高亮边框的宽度,传入0时采用默认描边宽度,默认宽度为 5px,您可以设置的最大值为 50。
155
+ * @param {Boolean} enableCaptureChildWindow - 窗口采集时是否采集子窗口(需要子窗口与被采集窗口具有 Owner 或 Popup 属性),默认为 false。
156
+ */
157
+ export declare class TRTCScreenCaptureProperty {
158
+ enableCaptureMouse: boolean;
159
+ enableHighLight: boolean;
160
+ enableHighPerformance: boolean;
161
+ highLightColor: number;
162
+ highLightWidth: number;
163
+ enableCaptureChildWindow: boolean;
164
+ constructor(enableCaptureMouse?: boolean, enableHighLight?: boolean, enableHighPerformance?: boolean, highLightColor?: number, highLightWidth?: number, enableCaptureChildWindow?: boolean);
165
+ }
166
+ /**
167
+ * 3.7 设备信息
146
168
  *
147
169
  * @param {String} deviceId - 设备PID,字符编码格式是UTF-8
148
170
  * @param {String} deviceName - 设备名称,字符编码格式是UTF-8
@@ -6,7 +6,7 @@
6
6
  *
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.TRTCSwitchRoomParam = exports.AudioMusicParam = exports.TRTCStatistics = exports.TRTCRemoteStatistics = exports.TRTCLocalStatistics = exports.TRTCAudioEffectParam = exports.TRTCAudioRecordingParams = exports.TRTCPublishCDNParam = exports.TRTCTranscodingConfig = exports.TRTCTranscodingConfigMode = exports.TRTCMixUser = exports.Rect = exports.TRTCSpeedTestResult = exports.TRTCVolumeInfo = exports.TRTCQualityInfo = exports.TRTCNetworkQosParam = exports.TRTCRenderParams = exports.TRTCVideoEncParam = exports.TRTCParams = exports.TRTCWaterMarkSrcType = exports.TRTCDeviceType = exports.TRTCDeviceState = exports.TRTCLogLevel = exports.TRTCVideoFrame = exports.TRTCDeviceInfo = exports.TRTCScreenCaptureSourceInfo = exports.TRTCImageBuffer = exports.TRTCAudioQuality = exports.TRTCScreenCaptureSourceType = exports.TRTCAudioFrameFormat = exports.TRTCVideoQosPreference = exports.TRTCQosControlMode = exports.TRTCRoleType = exports.TRTCAppScene = exports.TRTCVideoMirrorType = exports.TRTCVideoBufferType = exports.TRTCVideoPixelFormat = exports.TRTCBeautyStyle = exports.TRTCVideoRotation = exports.TRTCVideoFillMode = exports.TRTCQuality = exports.TRTCVideoStreamType = exports.TRTCVideoResolutionMode = exports.TRTCVideoResolution = void 0;
9
+ exports.TRTCSwitchRoomParam = exports.AudioMusicParam = exports.TRTCStatistics = exports.TRTCRemoteStatistics = exports.TRTCLocalStatistics = exports.TRTCAudioEffectParam = exports.TRTCAudioRecordingParams = exports.TRTCPublishCDNParam = exports.TRTCTranscodingConfig = exports.TRTCTranscodingConfigMode = exports.TRTCMixUser = exports.Rect = exports.TRTCSpeedTestResult = exports.TRTCVolumeInfo = exports.TRTCQualityInfo = exports.TRTCNetworkQosParam = exports.TRTCRenderParams = exports.TRTCVideoEncParam = exports.TRTCParams = exports.TRTCWaterMarkSrcType = exports.TRTCDeviceType = exports.TRTCDeviceState = exports.TRTCLogLevel = exports.TRTCVideoFrame = exports.TRTCDeviceInfo = exports.TRTCScreenCaptureProperty = exports.TRTCScreenCaptureSourceInfo = exports.TRTCImageBuffer = exports.TRTCAudioQuality = exports.TRTCScreenCaptureSourceType = exports.TRTCAudioFrameFormat = exports.TRTCVideoQosPreference = exports.TRTCQosControlMode = exports.TRTCRoleType = exports.TRTCAppScene = exports.TRTCVideoMirrorType = exports.TRTCVideoBufferType = exports.TRTCVideoPixelFormat = exports.TRTCBeautyStyle = exports.TRTCVideoRotation = exports.TRTCVideoFillMode = exports.TRTCQuality = exports.TRTCVideoStreamType = exports.TRTCVideoResolutionMode = exports.TRTCVideoResolution = void 0;
10
10
  /////////////////////////////////////////////////////////////////////////////////
11
11
  //
12
12
  // 【(一)视频相关枚举值定义】
@@ -539,7 +539,31 @@ class TRTCScreenCaptureSourceInfo {
539
539
  exports.TRTCScreenCaptureSourceInfo = TRTCScreenCaptureSourceInfo;
540
540
  ;
541
541
  /**
542
- * 3.6 设备信息
542
+ * 3.6 屏幕分享的进阶控制参数
543
+ *
544
+ * 该参数用于屏幕分享相关的接口 [selectScreenCaptureTarget]{@link TRTCCloud#selectScreenCaptureTarget},用于在指定分享目标时设定一系列进阶控制参数。
545
+ * 比如:是否采集鼠标、是否要采集子窗口、是否要在被分享目标周围绘制一个边框等。
546
+ *
547
+ * @param {Boolean} enableCaptureMouse - 是否采集目标内容的同时采集鼠标,默认为 true
548
+ * @param {Boolean} enableHighLight - 是否高亮正在共享的窗口(在被分享目标周围绘制一个边框),默认为 true。
549
+ * @param {Boolean} enableHighPerformance - 是否开启高性能模式(只会在分享屏幕时会生效),默认为 true。【特殊说明】开启后屏幕采集性能最佳,但会丧失抗遮挡能力,如果您同时开启 enableHighLight + enableHighPerformance,远端用户可以看到高亮的边框。
550
+ * @param {Number} highLightColor - 指定高亮边框的颜色,RGB 格式,传入 0 时代表采用默认颜色,默认颜色为 #8CBF26。
551
+ * @param {Number} highLightWidth - 指定高亮边框的宽度,传入0时采用默认描边宽度,默认宽度为 5px,您可以设置的最大值为 50。
552
+ * @param {Boolean} enableCaptureChildWindow - 窗口采集时是否采集子窗口(需要子窗口与被采集窗口具有 Owner 或 Popup 属性),默认为 false。
553
+ */
554
+ class TRTCScreenCaptureProperty {
555
+ constructor(enableCaptureMouse = true, enableHighLight = true, enableHighPerformance = true, highLightColor = 0, highLightWidth = 5, enableCaptureChildWindow = false) {
556
+ this.enableCaptureMouse = enableCaptureMouse;
557
+ this.enableHighLight = enableHighLight;
558
+ this.enableHighPerformance = enableHighPerformance;
559
+ this.highLightColor = highLightColor;
560
+ this.highLightWidth = highLightWidth;
561
+ this.enableCaptureChildWindow = enableCaptureChildWindow;
562
+ }
563
+ }
564
+ exports.TRTCScreenCaptureProperty = TRTCScreenCaptureProperty;
565
+ /**
566
+ * 3.7 设备信息
543
567
  *
544
568
  * @param {String} deviceId - 设备PID,字符编码格式是UTF-8
545
569
  * @param {String} deviceName - 设备名称,字符编码格式是UTF-8
@@ -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,167 @@
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 realRotation = rotation * 90; //ratation是0, 1, 2, 3. 绘制内部使用0, 90, 180, 270
131
+ let ylen = width * height;
132
+ let ulen = width * height / 4;
133
+ let ydata = new Uint8Array(data, 0, ylen);
134
+ let udata = new Uint8Array(data, ylen, ulen);
135
+ let vdata = new Uint8Array(data, ylen + ulen, ulen);
136
+ this.renderer.drawFrame({
137
+ width: width,
138
+ height: height,
139
+ rotation: realRotation,
140
+ timestamp: timestamp,
141
+ yUint8Array: ydata,
142
+ uUint8Array: udata,
143
+ vUint8Array: vdata,
144
+ isNeedRotate: false
145
+ });
146
+ ydata = null;
147
+ udata = null;
148
+ vdata = null;
149
+ }
150
+ _initRender(view) {
151
+ if (this.renderer) {
152
+ this.destroyRender();
153
+ }
154
+ this.renderer = new Render_1.default.GlRenderer();
155
+ view.innerHTML = ''; // 事先清空一下,避免画面叠加
156
+ this.renderer.bind(view);
157
+ }
158
+ destroyRender() {
159
+ try {
160
+ this.renderer.unbind();
161
+ this.renderer = null;
162
+ }
163
+ catch (err) {
164
+ }
165
+ }
166
+ }
167
+ exports.VodPlayer = VodPlayer;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trtc-electron-sdk",
3
- "version": "9.5.112-beta.2",
3
+ "version": "9.5.112-beta.5",
4
4
  "description": "trtc electron sdk",
5
5
  "main": "./liteav/trtc.js",
6
6
  "types": "./liteav/trtc.d.ts",