trtc-electron-sdk 12.3.705-beta.0 → 12.3.705-beta.2
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/Live/Player/index.d.ts +167 -0
- package/liteav/Live/Player/index.js +376 -0
- package/liteav/Live/Pusher/index.d.ts +1 -1
- package/liteav/Live/Pusher/index.js +8 -5
- package/liteav/Live/live_define.d.ts +124 -0
- package/liteav/Live/live_define.js +133 -1
- package/liteav/Live/{Pusher/video-render.d.ts → video-render.d.ts} +1 -1
- package/liteav/Live/{Pusher/video-render.js → video-render.js} +3 -3
- package/liteav/index.d.ts +1 -0
- package/liteav/index.js +1 -0
- package/package.json +1 -1
- package/scripts/copy-sdk.js +2 -2
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { V2LiveRotation, V2LiveFillMode, V2LivePlayerEvent } from '../live_define';
|
|
2
|
+
/**
|
|
3
|
+
* 腾讯云直播播放器
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
*
|
|
7
|
+
* // 创建/销毁 V2LivePlayer 对象,以及回调事件监听。
|
|
8
|
+
*
|
|
9
|
+
* import { V2LivePlayer } from 'trtc-electron-sdk';
|
|
10
|
+
* const livePlayer = V2LivePlayer.createV2LivePlayer();
|
|
11
|
+
*
|
|
12
|
+
* subscribeEvents = (livePlayer) => {
|
|
13
|
+
* livePlayer.on('onError', (errcode, errmsg) => {
|
|
14
|
+
* console.info('livePlayer_demo: onError :' + errcode + " msg" + errmsg);
|
|
15
|
+
* });
|
|
16
|
+
* };
|
|
17
|
+
*
|
|
18
|
+
* V2LivePlayer.releaseV2livePlayer(livePlayer);
|
|
19
|
+
*
|
|
20
|
+
*/
|
|
21
|
+
export declare class V2LivePlayer {
|
|
22
|
+
private livePlayer;
|
|
23
|
+
private playerVideoRender;
|
|
24
|
+
private pixelFormat;
|
|
25
|
+
private eventEmitter;
|
|
26
|
+
private logger;
|
|
27
|
+
/**
|
|
28
|
+
* 创建 V2LivePlayer 实例
|
|
29
|
+
*
|
|
30
|
+
* @return {V2LivePlayer} - 播放器实例
|
|
31
|
+
*/
|
|
32
|
+
static createV2LivePlayer(): V2LivePlayer;
|
|
33
|
+
/**
|
|
34
|
+
* 析构 V2LivePlayer 对象
|
|
35
|
+
*
|
|
36
|
+
* @param {V2LivePlayer} livePlayer - 推流器实例
|
|
37
|
+
*/
|
|
38
|
+
static releaseV2LivePlayer(livePlayer: V2LivePlayer): void;
|
|
39
|
+
constructor();
|
|
40
|
+
destroy(): void;
|
|
41
|
+
/**
|
|
42
|
+
* 监听 LivePlayer 对象事件。
|
|
43
|
+
*
|
|
44
|
+
* @param {V2LivePlayerEvent} event - 事件名称。
|
|
45
|
+
* @param {Function} listener - 事件回调函数。
|
|
46
|
+
*/
|
|
47
|
+
on(event: V2LivePlayerEvent | symbol, listener: (...args: any[]) => void): void;
|
|
48
|
+
/**
|
|
49
|
+
* 取消监听 LivePlayer 对象事件。
|
|
50
|
+
*
|
|
51
|
+
* @param {V2LivePlayerEvent} event - 事件名称。
|
|
52
|
+
* @param {Function} listener - 事件回调函数。
|
|
53
|
+
*/
|
|
54
|
+
off(event: V2LivePlayerEvent | symbol, listener: (...args: any[]) => void): void;
|
|
55
|
+
/**
|
|
56
|
+
* 设置播放器的视频渲染 View, 播放器的视频最终会显示到传入的 View 上。
|
|
57
|
+
*
|
|
58
|
+
* @param {HTMLElement | null} view - 播放器的视频渲染 View。
|
|
59
|
+
*/
|
|
60
|
+
setRenderView(view: HTMLElement | null): void;
|
|
61
|
+
/**
|
|
62
|
+
* 设置播放器画面的旋转角度, 默认不旋转。
|
|
63
|
+
*
|
|
64
|
+
* @param {V2LiveRotation} rotation - 播放器画面的旋转角度, 参考 V2LiveRotation 的定义。
|
|
65
|
+
* @return {Number} - 参考 V2LiveCode 的定义
|
|
66
|
+
*/
|
|
67
|
+
setRenderRotation(rotation: V2LiveRotation): number;
|
|
68
|
+
/**
|
|
69
|
+
* 设置画面的填充模式
|
|
70
|
+
*
|
|
71
|
+
* @param {V2LiveFillMode} mode - 画面填充模式,参考 V2LiveFillMode 的定义。
|
|
72
|
+
* @return {Number} - 参考 V2LiveCode 的定义
|
|
73
|
+
*/
|
|
74
|
+
setRenderFillMode(mode: V2LiveFillMode): number;
|
|
75
|
+
/**
|
|
76
|
+
* 开始播放音视频流
|
|
77
|
+
*
|
|
78
|
+
* @param {String} url - 音视频流地址
|
|
79
|
+
* @return {Number} - 参考 V2LiveCode 的定义
|
|
80
|
+
*/
|
|
81
|
+
startPlay(url: string): number;
|
|
82
|
+
/**
|
|
83
|
+
* 停止播放音视频流
|
|
84
|
+
*
|
|
85
|
+
* @return {Number} - 参考 V2LiveCode 的定义
|
|
86
|
+
*/
|
|
87
|
+
stopPlay(): number;
|
|
88
|
+
/**
|
|
89
|
+
* 播放器是否正在播放中
|
|
90
|
+
*
|
|
91
|
+
* @return {Number} - 是否正在播放中, 1 表示正在播放中, 0 表示未在播放中
|
|
92
|
+
*/
|
|
93
|
+
isPlaying(): number;
|
|
94
|
+
/**
|
|
95
|
+
* 暂停播放器的音频流
|
|
96
|
+
*
|
|
97
|
+
* @return {Number} - 参考 V2LiveCode 的定义
|
|
98
|
+
*/
|
|
99
|
+
pauseAudio(): number;
|
|
100
|
+
/**
|
|
101
|
+
* 恢复播放器的音频流
|
|
102
|
+
*
|
|
103
|
+
* @return {Number} - 参考 V2LiveCode 的定义
|
|
104
|
+
*/
|
|
105
|
+
resumeAudio(): number;
|
|
106
|
+
/**
|
|
107
|
+
* 暂停播放器的视频流
|
|
108
|
+
*
|
|
109
|
+
* @return {Number} - 参考 V2LiveCode 的定义
|
|
110
|
+
*/
|
|
111
|
+
pauseVideo(): number;
|
|
112
|
+
/**
|
|
113
|
+
* 恢复播放器的视频流
|
|
114
|
+
*
|
|
115
|
+
* @return {Number} - 参考 V2LiveCode 的定义
|
|
116
|
+
*/
|
|
117
|
+
resumeVideo(): number;
|
|
118
|
+
/**
|
|
119
|
+
* 设置播放器音量
|
|
120
|
+
*
|
|
121
|
+
* @param {Number} volume - 音量大小,取值范围0 - 100。【默认值】: 100
|
|
122
|
+
* @return {Number} - 参考 V2LiveCode 的定义
|
|
123
|
+
*/
|
|
124
|
+
setPlayoutVolume(volume: number): number;
|
|
125
|
+
/**
|
|
126
|
+
* 设置播放器缓存自动调整的最小和最大时间
|
|
127
|
+
*
|
|
128
|
+
* @param {Number} minTime - 缓存自动调整的最小时间,取值需要大于0。【默认值】:1
|
|
129
|
+
* @param {Number} maxTime - 缓存自动调整的最大时间,取值需要大于0。【默认值】:5
|
|
130
|
+
* @return {Number} - 参考 V2LiveCode 的定义
|
|
131
|
+
*/
|
|
132
|
+
setCacheParams(minTime: number, maxTime: number): number;
|
|
133
|
+
/**
|
|
134
|
+
* 直播流无缝切换,支持 FLV 和 LEB
|
|
135
|
+
*
|
|
136
|
+
* @param {String} url - 新的拉流地址
|
|
137
|
+
* @return {Number} - 参考 V2LiveCode 的定义
|
|
138
|
+
*/
|
|
139
|
+
switchStream(newUrl: string): number;
|
|
140
|
+
/**
|
|
141
|
+
* 启用播放音量大小提示
|
|
142
|
+
*
|
|
143
|
+
* @param {Number} intervalMs - onPlayoutVolumeUpdate 回调的触发间隔,单位为ms,最小间隔为100ms,如果小于等于0则会关闭回调,建议设置为300ms;【默认值】:0,不开启。
|
|
144
|
+
* @return {Number} - 参考 V2LiveCode 的定义
|
|
145
|
+
*/
|
|
146
|
+
enableVolumeEvaluation(intervalMs: number): number;
|
|
147
|
+
private enableObserveVideoFrame;
|
|
148
|
+
private _createPlayerRender;
|
|
149
|
+
private _destroyPlayerRender;
|
|
150
|
+
private _setVideoRenderBuffer;
|
|
151
|
+
private _addVideoRenderCallback;
|
|
152
|
+
private _removeVideoRenderCallback;
|
|
153
|
+
private _playerVideoRenderCallback;
|
|
154
|
+
private initObserver;
|
|
155
|
+
fire(event: string, ...args: any): void;
|
|
156
|
+
private handleOnError;
|
|
157
|
+
private handleOnWarning;
|
|
158
|
+
private handleOnVideoResolutionChanged;
|
|
159
|
+
private handleOnConnected;
|
|
160
|
+
private handleOnVideoPlaying;
|
|
161
|
+
private handleOnAudioPlaying;
|
|
162
|
+
private handleOnVideoLoading;
|
|
163
|
+
private handleOnAudioLoading;
|
|
164
|
+
private handleOnPlayoutVolumeUpdate;
|
|
165
|
+
private handleOnStatisticsUpdate;
|
|
166
|
+
private handleOnStreamSwitched;
|
|
167
|
+
}
|
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.V2LivePlayer = void 0;
|
|
4
|
+
const events_1 = require("events");
|
|
5
|
+
const live_define_1 = require("../live_define");
|
|
6
|
+
const video_render_1 = require("../video-render");
|
|
7
|
+
const converter_1 = require("../converter");
|
|
8
|
+
const logger_1 = require("../../logger");
|
|
9
|
+
const NodeTRTCEngine = require('../../../build/Release/trtc_electron_sdk.node');
|
|
10
|
+
/**
|
|
11
|
+
* 腾讯云直播播放器
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
*
|
|
15
|
+
* // 创建/销毁 V2LivePlayer 对象,以及回调事件监听。
|
|
16
|
+
*
|
|
17
|
+
* import { V2LivePlayer } from 'trtc-electron-sdk';
|
|
18
|
+
* const livePlayer = V2LivePlayer.createV2LivePlayer();
|
|
19
|
+
*
|
|
20
|
+
* subscribeEvents = (livePlayer) => {
|
|
21
|
+
* livePlayer.on('onError', (errcode, errmsg) => {
|
|
22
|
+
* console.info('livePlayer_demo: onError :' + errcode + " msg" + errmsg);
|
|
23
|
+
* });
|
|
24
|
+
* };
|
|
25
|
+
*
|
|
26
|
+
* V2LivePlayer.releaseV2livePlayer(livePlayer);
|
|
27
|
+
*
|
|
28
|
+
*/
|
|
29
|
+
class V2LivePlayer {
|
|
30
|
+
constructor() {
|
|
31
|
+
this.livePlayer = new NodeTRTCEngine.NodeV2LivePlayer();
|
|
32
|
+
this.initObserver();
|
|
33
|
+
this.playerVideoRender = null;
|
|
34
|
+
this.pixelFormat = live_define_1.V2LivePixelFormat.V2LivePixelFormatI420;
|
|
35
|
+
this.eventEmitter = new events_1.EventEmitter();
|
|
36
|
+
this.logger = new logger_1.Logger(`V2LivePlayer`);
|
|
37
|
+
this._playerVideoRenderCallback = this._playerVideoRenderCallback.bind(this);
|
|
38
|
+
this._createPlayerRender();
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* 创建 V2LivePlayer 实例
|
|
42
|
+
*
|
|
43
|
+
* @return {V2LivePlayer} - 播放器实例
|
|
44
|
+
*/
|
|
45
|
+
static createV2LivePlayer() {
|
|
46
|
+
return new V2LivePlayer();
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* 析构 V2LivePlayer 对象
|
|
50
|
+
*
|
|
51
|
+
* @param {V2LivePlayer} livePlayer - 推流器实例
|
|
52
|
+
*/
|
|
53
|
+
static releaseV2LivePlayer(livePlayer) {
|
|
54
|
+
livePlayer.destroy();
|
|
55
|
+
}
|
|
56
|
+
destroy() {
|
|
57
|
+
this._destroyPlayerRender();
|
|
58
|
+
this.livePlayer.destroy();
|
|
59
|
+
this.livePlayer = null;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* 监听 LivePlayer 对象事件。
|
|
63
|
+
*
|
|
64
|
+
* @param {V2LivePlayerEvent} event - 事件名称。
|
|
65
|
+
* @param {Function} listener - 事件回调函数。
|
|
66
|
+
*/
|
|
67
|
+
on(event, listener) {
|
|
68
|
+
this.eventEmitter.on(event, listener);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* 取消监听 LivePlayer 对象事件。
|
|
72
|
+
*
|
|
73
|
+
* @param {V2LivePlayerEvent} event - 事件名称。
|
|
74
|
+
* @param {Function} listener - 事件回调函数。
|
|
75
|
+
*/
|
|
76
|
+
off(event, listener) {
|
|
77
|
+
this.eventEmitter.off(event, listener);
|
|
78
|
+
}
|
|
79
|
+
/////////////////////////////////////////////////////////////////////////////////
|
|
80
|
+
//
|
|
81
|
+
// (一)LivePlayer相关接口函数
|
|
82
|
+
//
|
|
83
|
+
/////////////////////////////////////////////////////////////////////////////////
|
|
84
|
+
/**
|
|
85
|
+
* 设置播放器的视频渲染 View, 播放器的视频最终会显示到传入的 View 上。
|
|
86
|
+
*
|
|
87
|
+
* @param {HTMLElement | null} view - 播放器的视频渲染 View。
|
|
88
|
+
*/
|
|
89
|
+
setRenderView(view) {
|
|
90
|
+
var _a;
|
|
91
|
+
this.logger.debug(`setRenderView view:${view}`);
|
|
92
|
+
(_a = this.playerVideoRender) === null || _a === void 0 ? void 0 : _a.setRenderView(view);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* 设置播放器画面的旋转角度, 默认不旋转。
|
|
96
|
+
*
|
|
97
|
+
* @param {V2LiveRotation} rotation - 播放器画面的旋转角度, 参考 V2LiveRotation 的定义。
|
|
98
|
+
* @return {Number} - 参考 V2LiveCode 的定义
|
|
99
|
+
*/
|
|
100
|
+
setRenderRotation(rotation) {
|
|
101
|
+
var _a;
|
|
102
|
+
this.logger.debug(`setRenderRotation rotation:${rotation}`);
|
|
103
|
+
return (_a = this.livePlayer) === null || _a === void 0 ? void 0 : _a.setRenderRotation(rotation);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* 设置画面的填充模式
|
|
107
|
+
*
|
|
108
|
+
* @param {V2LiveFillMode} mode - 画面填充模式,参考 V2LiveFillMode 的定义。
|
|
109
|
+
* @return {Number} - 参考 V2LiveCode 的定义
|
|
110
|
+
*/
|
|
111
|
+
setRenderFillMode(mode) {
|
|
112
|
+
var _a, _b;
|
|
113
|
+
this.logger.debug(`setRenderFillMode mode:${mode}`);
|
|
114
|
+
(_a = this.playerVideoRender) === null || _a === void 0 ? void 0 : _a.setVideoFillMode((0, converter_1.convertFillModeFromLive)(mode));
|
|
115
|
+
return (_b = this.livePlayer) === null || _b === void 0 ? void 0 : _b.setRenderFillMode(mode);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* 开始播放音视频流
|
|
119
|
+
*
|
|
120
|
+
* @param {String} url - 音视频流地址
|
|
121
|
+
* @return {Number} - 参考 V2LiveCode 的定义
|
|
122
|
+
*/
|
|
123
|
+
startPlay(url) {
|
|
124
|
+
var _a, _b;
|
|
125
|
+
this.logger.debug(`startPlay url:${url}`);
|
|
126
|
+
(_a = this.playerVideoRender) === null || _a === void 0 ? void 0 : _a.createRender();
|
|
127
|
+
this._setVideoRenderBuffer();
|
|
128
|
+
this._addVideoRenderCallback();
|
|
129
|
+
this.enableObserveVideoFrame(true, this.pixelFormat, live_define_1.V2LiveBufferType.V2LiveBufferTypeByteBuffer);
|
|
130
|
+
return (_b = this.livePlayer) === null || _b === void 0 ? void 0 : _b.startPlay(url);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* 停止播放音视频流
|
|
134
|
+
*
|
|
135
|
+
* @return {Number} - 参考 V2LiveCode 的定义
|
|
136
|
+
*/
|
|
137
|
+
stopPlay() {
|
|
138
|
+
var _a, _b;
|
|
139
|
+
this.logger.debug(`stopPlay`);
|
|
140
|
+
(_a = this.playerVideoRender) === null || _a === void 0 ? void 0 : _a.destroyRender();
|
|
141
|
+
this._removeVideoRenderCallback();
|
|
142
|
+
this.enableObserveVideoFrame(false, this.pixelFormat, live_define_1.V2LiveBufferType.V2LiveBufferTypeByteBuffer);
|
|
143
|
+
return (_b = this.livePlayer) === null || _b === void 0 ? void 0 : _b.stopPlay();
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* 播放器是否正在播放中
|
|
147
|
+
*
|
|
148
|
+
* @return {Number} - 是否正在播放中, 1 表示正在播放中, 0 表示未在播放中
|
|
149
|
+
*/
|
|
150
|
+
isPlaying() {
|
|
151
|
+
var _a;
|
|
152
|
+
this.logger.debug(`isPlaying`);
|
|
153
|
+
return (_a = this.livePlayer) === null || _a === void 0 ? void 0 : _a.isPlaying();
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* 暂停播放器的音频流
|
|
157
|
+
*
|
|
158
|
+
* @return {Number} - 参考 V2LiveCode 的定义
|
|
159
|
+
*/
|
|
160
|
+
pauseAudio() {
|
|
161
|
+
var _a;
|
|
162
|
+
this.logger.debug(`pauseAudio`);
|
|
163
|
+
return (_a = this.livePlayer) === null || _a === void 0 ? void 0 : _a.pauseAudio();
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* 恢复播放器的音频流
|
|
167
|
+
*
|
|
168
|
+
* @return {Number} - 参考 V2LiveCode 的定义
|
|
169
|
+
*/
|
|
170
|
+
resumeAudio() {
|
|
171
|
+
var _a;
|
|
172
|
+
this.logger.debug(`resumeAudio`);
|
|
173
|
+
return (_a = this.livePlayer) === null || _a === void 0 ? void 0 : _a.resumeAudio();
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* 暂停播放器的视频流
|
|
177
|
+
*
|
|
178
|
+
* @return {Number} - 参考 V2LiveCode 的定义
|
|
179
|
+
*/
|
|
180
|
+
pauseVideo() {
|
|
181
|
+
var _a;
|
|
182
|
+
this.logger.debug(`pauseVideo`);
|
|
183
|
+
return (_a = this.livePlayer) === null || _a === void 0 ? void 0 : _a.pauseVideo();
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* 恢复播放器的视频流
|
|
187
|
+
*
|
|
188
|
+
* @return {Number} - 参考 V2LiveCode 的定义
|
|
189
|
+
*/
|
|
190
|
+
resumeVideo() {
|
|
191
|
+
var _a;
|
|
192
|
+
this.logger.debug(`resumeVideo`);
|
|
193
|
+
return (_a = this.livePlayer) === null || _a === void 0 ? void 0 : _a.resumeVideo();
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* 设置播放器音量
|
|
197
|
+
*
|
|
198
|
+
* @param {Number} volume - 音量大小,取值范围0 - 100。【默认值】: 100
|
|
199
|
+
* @return {Number} - 参考 V2LiveCode 的定义
|
|
200
|
+
*/
|
|
201
|
+
setPlayoutVolume(volume) {
|
|
202
|
+
var _a;
|
|
203
|
+
this.logger.debug(`setPlayoutVolume volume:${volume}`);
|
|
204
|
+
return (_a = this.livePlayer) === null || _a === void 0 ? void 0 : _a.setPlayoutVolume(volume);
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* 设置播放器缓存自动调整的最小和最大时间
|
|
208
|
+
*
|
|
209
|
+
* @param {Number} minTime - 缓存自动调整的最小时间,取值需要大于0。【默认值】:1
|
|
210
|
+
* @param {Number} maxTime - 缓存自动调整的最大时间,取值需要大于0。【默认值】:5
|
|
211
|
+
* @return {Number} - 参考 V2LiveCode 的定义
|
|
212
|
+
*/
|
|
213
|
+
setCacheParams(minTime, maxTime) {
|
|
214
|
+
var _a;
|
|
215
|
+
this.logger.debug(`setCacheParams minTime:${minTime}, maxTime:${maxTime}`);
|
|
216
|
+
return (_a = this.livePlayer) === null || _a === void 0 ? void 0 : _a.setCacheParams(minTime, maxTime);
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* 直播流无缝切换,支持 FLV 和 LEB
|
|
220
|
+
*
|
|
221
|
+
* @param {String} url - 新的拉流地址
|
|
222
|
+
* @return {Number} - 参考 V2LiveCode 的定义
|
|
223
|
+
*/
|
|
224
|
+
switchStream(newUrl) {
|
|
225
|
+
var _a;
|
|
226
|
+
this.logger.debug(`switchStream newUrl:${newUrl}`);
|
|
227
|
+
return (_a = this.livePlayer) === null || _a === void 0 ? void 0 : _a.switchStream(newUrl);
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* 启用播放音量大小提示
|
|
231
|
+
*
|
|
232
|
+
* @param {Number} intervalMs - onPlayoutVolumeUpdate 回调的触发间隔,单位为ms,最小间隔为100ms,如果小于等于0则会关闭回调,建议设置为300ms;【默认值】:0,不开启。
|
|
233
|
+
* @return {Number} - 参考 V2LiveCode 的定义
|
|
234
|
+
*/
|
|
235
|
+
enableVolumeEvaluation(intervalMs) {
|
|
236
|
+
var _a;
|
|
237
|
+
this.logger.debug(`enableVolumeEvaluation intervalMs:${intervalMs}`);
|
|
238
|
+
return (_a = this.livePlayer) === null || _a === void 0 ? void 0 : _a.enableVolumeEvaluation(intervalMs);
|
|
239
|
+
}
|
|
240
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
241
|
+
//
|
|
242
|
+
// 内部接口
|
|
243
|
+
//
|
|
244
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
245
|
+
enableObserveVideoFrame(enable, pixelFormat, bufferType) {
|
|
246
|
+
var _a;
|
|
247
|
+
this.logger.debug(`enableObserveVideoFrame enable:${enable}, pixelFormat:${pixelFormat}, bufferType:${bufferType}`);
|
|
248
|
+
(_a = this.livePlayer) === null || _a === void 0 ? void 0 : _a.enableObserveVideoFrame(enable, pixelFormat, bufferType);
|
|
249
|
+
}
|
|
250
|
+
_createPlayerRender() {
|
|
251
|
+
if (this.playerVideoRender !== null) {
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
this.playerVideoRender = new video_render_1.VideoRender();
|
|
255
|
+
const trtcPixelFormat = (0, converter_1.convertPixelFormatFromLive)(this.pixelFormat);
|
|
256
|
+
this.playerVideoRender.setVideoPixelFormat(trtcPixelFormat);
|
|
257
|
+
}
|
|
258
|
+
_destroyPlayerRender() {
|
|
259
|
+
if (this.playerVideoRender) {
|
|
260
|
+
this.playerVideoRender.destroy();
|
|
261
|
+
this.playerVideoRender = null;
|
|
262
|
+
}
|
|
263
|
+
this._removeVideoRenderCallback();
|
|
264
|
+
this.enableObserveVideoFrame(false, this.pixelFormat, live_define_1.V2LiveBufferType.V2LiveBufferTypeByteBuffer);
|
|
265
|
+
}
|
|
266
|
+
_setVideoRenderBuffer() {
|
|
267
|
+
var _a;
|
|
268
|
+
if (this.playerVideoRender !== null) {
|
|
269
|
+
const videoBuffer = this.playerVideoRender.getVideoBuffer();
|
|
270
|
+
(_a = this.livePlayer) === null || _a === void 0 ? void 0 : _a.setVideoRenderBuffer(videoBuffer.buffer, videoBuffer.width, videoBuffer.height, this.pixelFormat, videoBuffer.id);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
_addVideoRenderCallback() {
|
|
274
|
+
var _a;
|
|
275
|
+
(_a = this.livePlayer) === null || _a === void 0 ? void 0 : _a.addVideoRenderCallback(this._playerVideoRenderCallback);
|
|
276
|
+
}
|
|
277
|
+
_removeVideoRenderCallback() {
|
|
278
|
+
var _a;
|
|
279
|
+
(_a = this.livePlayer) === null || _a === void 0 ? void 0 : _a.removeVideoRenderCallback();
|
|
280
|
+
}
|
|
281
|
+
_playerVideoRenderCallback(args) {
|
|
282
|
+
if (this.playerVideoRender) {
|
|
283
|
+
const [userId, type, width, height, timestamp, rotation, valid, bufferId] = args;
|
|
284
|
+
const result = this.playerVideoRender.renderVideoData(userId, type, width, height, timestamp, rotation, valid, bufferId);
|
|
285
|
+
if (!result) {
|
|
286
|
+
this._setVideoRenderBuffer();
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
initObserver() {
|
|
291
|
+
var _a;
|
|
292
|
+
(_a = this.livePlayer) === null || _a === void 0 ? void 0 : _a.setObserver((args) => {
|
|
293
|
+
const key = args[0];
|
|
294
|
+
const data = args[1];
|
|
295
|
+
switch (key) {
|
|
296
|
+
case 'onError':
|
|
297
|
+
this.handleOnError(data.errCode, data.errMsg);
|
|
298
|
+
break;
|
|
299
|
+
case 'onWarning':
|
|
300
|
+
this.handleOnWarning(data.warningCode, data.warningMsg);
|
|
301
|
+
break;
|
|
302
|
+
case 'onVideoResolutionChanged':
|
|
303
|
+
this.handleOnVideoResolutionChanged(data.width, data.height);
|
|
304
|
+
break;
|
|
305
|
+
case 'onConnected':
|
|
306
|
+
this.handleOnConnected();
|
|
307
|
+
break;
|
|
308
|
+
case 'onVideoPlaying':
|
|
309
|
+
this.handleOnVideoPlaying(data.firstPlay);
|
|
310
|
+
break;
|
|
311
|
+
case 'onAudioPlaying':
|
|
312
|
+
this.handleOnAudioPlaying(data.firstPlay);
|
|
313
|
+
break;
|
|
314
|
+
case 'onVideoLoading':
|
|
315
|
+
this.handleOnVideoLoading();
|
|
316
|
+
break;
|
|
317
|
+
case 'onAudioLoading':
|
|
318
|
+
this.handleOnAudioLoading();
|
|
319
|
+
break;
|
|
320
|
+
case 'onPlayoutVolumeUpdate':
|
|
321
|
+
this.handleOnPlayoutVolumeUpdate(data.volume);
|
|
322
|
+
break;
|
|
323
|
+
case 'onStatisticsUpdate':
|
|
324
|
+
this.handleOnStatisticsUpdate(data.statistics);
|
|
325
|
+
break;
|
|
326
|
+
case 'onStreamSwitched':
|
|
327
|
+
this.handleOnStreamSwitched(data.url, data.code);
|
|
328
|
+
break;
|
|
329
|
+
default:
|
|
330
|
+
this.logger.error(`unknown event: ${key}`);
|
|
331
|
+
break;
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
// Event Handler define
|
|
336
|
+
fire(event, ...args) {
|
|
337
|
+
setImmediate(() => {
|
|
338
|
+
var _a;
|
|
339
|
+
(_a = this.eventEmitter) === null || _a === void 0 ? void 0 : _a.emit(event, ...args);
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
handleOnError(errCode, errMsg) {
|
|
343
|
+
this.fire('onError', errCode, errMsg);
|
|
344
|
+
}
|
|
345
|
+
handleOnWarning(warningCode, warningMsg) {
|
|
346
|
+
this.fire('onWarning', warningCode, warningMsg);
|
|
347
|
+
}
|
|
348
|
+
handleOnVideoResolutionChanged(width, height) {
|
|
349
|
+
this.fire('onVideoResolutionChanged', width, height);
|
|
350
|
+
}
|
|
351
|
+
handleOnConnected() {
|
|
352
|
+
this.fire('onConnected');
|
|
353
|
+
}
|
|
354
|
+
handleOnVideoPlaying(firstPlay) {
|
|
355
|
+
this.fire('onVideoPlaying', firstPlay);
|
|
356
|
+
}
|
|
357
|
+
handleOnAudioPlaying(firstPlay) {
|
|
358
|
+
this.fire('onAudioPlaying', firstPlay);
|
|
359
|
+
}
|
|
360
|
+
handleOnVideoLoading() {
|
|
361
|
+
this.fire('onVideoLoading');
|
|
362
|
+
}
|
|
363
|
+
handleOnAudioLoading() {
|
|
364
|
+
this.fire('onAudioLoading');
|
|
365
|
+
}
|
|
366
|
+
handleOnPlayoutVolumeUpdate(volume) {
|
|
367
|
+
this.fire('onPlayoutVolumeUpdate', volume);
|
|
368
|
+
}
|
|
369
|
+
handleOnStatisticsUpdate(statistics) {
|
|
370
|
+
this.fire('onStatisticsUpdate', statistics);
|
|
371
|
+
}
|
|
372
|
+
handleOnStreamSwitched(url, code) {
|
|
373
|
+
this.fire('onStreamSwitched', url, code);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
exports.V2LivePlayer = V2LivePlayer;
|
|
@@ -331,7 +331,7 @@ export declare class V2LivePusher {
|
|
|
331
331
|
*/
|
|
332
332
|
enableFollowingDefaultAudioDevice(deviceType: TRTCDeviceType, enable: boolean): void;
|
|
333
333
|
private enableCustomVideoRender;
|
|
334
|
-
private
|
|
334
|
+
private _createPusherRender;
|
|
335
335
|
private _destroyPusherRender;
|
|
336
336
|
private _setVideoRenderBuffer;
|
|
337
337
|
private _addVideoRenderCallback;
|
|
@@ -4,7 +4,7 @@ exports.V2LivePusher = void 0;
|
|
|
4
4
|
const events_1 = require("events");
|
|
5
5
|
const live_define_1 = require("../live_define");
|
|
6
6
|
const trtc_define_1 = require("../../trtc_define");
|
|
7
|
-
const video_render_1 = require("
|
|
7
|
+
const video_render_1 = require("../video-render");
|
|
8
8
|
const converter_1 = require("../converter");
|
|
9
9
|
const logger_1 = require("../../logger");
|
|
10
10
|
const NodeTRTCEngine = require('../../../build/Release/trtc_electron_sdk.node');
|
|
@@ -36,10 +36,10 @@ class V2LivePusher {
|
|
|
36
36
|
this.cameraTestVideoRender = null;
|
|
37
37
|
this.pixelFormat = live_define_1.V2LivePixelFormat.V2LivePixelFormatI420;
|
|
38
38
|
this.eventEmitter = new events_1.EventEmitter();
|
|
39
|
-
this.logger = new logger_1.Logger(`
|
|
39
|
+
this.logger = new logger_1.Logger(`V2LivePusher`);
|
|
40
40
|
this._pusherVideoRenderCallback = this._pusherVideoRenderCallback.bind(this);
|
|
41
41
|
this._cameraTestVideoRenderCallback = this._cameraTestVideoRenderCallback.bind(this);
|
|
42
|
-
this.
|
|
42
|
+
this._createPusherRender();
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
45
45
|
* 创建 V2LivePusher 实例
|
|
@@ -56,7 +56,7 @@ class V2LivePusher {
|
|
|
56
56
|
* @param {V2LivePusher} v2livepusher - 推流器实例
|
|
57
57
|
*/
|
|
58
58
|
static releaseV2LivePusher(livePusher) {
|
|
59
|
-
livePusher
|
|
59
|
+
livePusher.destroy();
|
|
60
60
|
}
|
|
61
61
|
destroy() {
|
|
62
62
|
this._destroyPusherRender();
|
|
@@ -526,7 +526,10 @@ class V2LivePusher {
|
|
|
526
526
|
(_a = this.livePusher) === null || _a === void 0 ? void 0 : _a.enableCustomVideoRender(enable, pixelFormat, bufferType);
|
|
527
527
|
}
|
|
528
528
|
// videoRender
|
|
529
|
-
|
|
529
|
+
_createPusherRender() {
|
|
530
|
+
if (this.pusherVideoRender !== null) {
|
|
531
|
+
return;
|
|
532
|
+
}
|
|
530
533
|
this.pusherVideoRender = new video_render_1.VideoRender();
|
|
531
534
|
const trtcPixelFormat = (0, converter_1.convertPixelFormatFromLive)(this.pixelFormat);
|
|
532
535
|
this.pusherVideoRender.setVideoPixelFormat(trtcPixelFormat);
|
|
@@ -76,6 +76,91 @@ export declare enum V2LivePusherEvent {
|
|
|
76
76
|
*/
|
|
77
77
|
onStatisticsUpdate = "onStatisticsUpdate"
|
|
78
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* @namespace V2LivePlayerEvent
|
|
81
|
+
* @description V2LivePlayer 事件定义
|
|
82
|
+
*
|
|
83
|
+
*/
|
|
84
|
+
export declare enum V2LivePlayerEvent {
|
|
85
|
+
/**
|
|
86
|
+
* @description 错误回调:直播播放器错误通知,播放器出现错误时,会回调该通知。
|
|
87
|
+
*
|
|
88
|
+
* @event V2LivePlayerEvent#onError
|
|
89
|
+
* @param {Number} errCode - 错误码
|
|
90
|
+
* @param {String} errMsg - 错误信息
|
|
91
|
+
*/
|
|
92
|
+
onError = "onError",
|
|
93
|
+
/**
|
|
94
|
+
* @description 直播播放器警告通知。
|
|
95
|
+
*
|
|
96
|
+
* @event V2LivePlayerEvent#onError
|
|
97
|
+
* @param {Number} warnCode - 警告码
|
|
98
|
+
* @param {String} warnMsg - 警告信息
|
|
99
|
+
*/
|
|
100
|
+
onWarning = "onWarning",
|
|
101
|
+
/**
|
|
102
|
+
* @description 直播播放器分辨率变化通知。
|
|
103
|
+
*
|
|
104
|
+
* @event V2LivePlayerEvent#onVideoResolutionChanged
|
|
105
|
+
* @param {Number} width - 视频宽。
|
|
106
|
+
* @param {Number} height - 视频高。
|
|
107
|
+
*/
|
|
108
|
+
onVideoResolutionChanged = "onVideoResolutionChanged",
|
|
109
|
+
/**
|
|
110
|
+
* @description 已经成功连接到服务器。
|
|
111
|
+
*
|
|
112
|
+
* @event V2LivePlayerEvent#onConnected
|
|
113
|
+
*/
|
|
114
|
+
onConnected = "onConnected",
|
|
115
|
+
/**
|
|
116
|
+
* @description 视频播放事件。
|
|
117
|
+
*
|
|
118
|
+
* @event V2LivePlayerEvent#onVideoPlaying
|
|
119
|
+
* @param {Boolean} firstPlay - 第一次播放标志。
|
|
120
|
+
*/
|
|
121
|
+
onVideoPlaying = "onVideoPlaying",
|
|
122
|
+
/**
|
|
123
|
+
* @description 音频播放事件。
|
|
124
|
+
*
|
|
125
|
+
* @event V2LivePlayerEvent#onAudioPlaying
|
|
126
|
+
* @param {Boolean} firstPlay - 第一次播放标志。
|
|
127
|
+
*/
|
|
128
|
+
onAudioPlaying = "onAudioPlaying",
|
|
129
|
+
/**
|
|
130
|
+
* @description 视频加载事件。
|
|
131
|
+
*
|
|
132
|
+
* @event V2LivePlayerEvent#onVideoLoading
|
|
133
|
+
*/
|
|
134
|
+
onVideoLoading = "onVideoLoading",
|
|
135
|
+
/**
|
|
136
|
+
* @description 音频加载事件。
|
|
137
|
+
*
|
|
138
|
+
* @event V2LivePlayerEvent#onAudioLoading
|
|
139
|
+
*/
|
|
140
|
+
onAudioLoading = "onAudioLoading",
|
|
141
|
+
/**
|
|
142
|
+
* @description 播放器音量大小回调。
|
|
143
|
+
*
|
|
144
|
+
* @event V2LivePlayerEvent#onPlayoutVolumeUpdate
|
|
145
|
+
* @param {Number} volume - 音量大小。
|
|
146
|
+
*/
|
|
147
|
+
onPlayoutVolumeUpdate = "onPlayoutVolumeUpdate",
|
|
148
|
+
/**
|
|
149
|
+
* @description 直播播放器统计数据回调。
|
|
150
|
+
*
|
|
151
|
+
* @event V2LivePlayerEvent#onStatisticsUpdate
|
|
152
|
+
* @param {V2TXLivePlayerStatistics} statistics - 播放器统计数据。
|
|
153
|
+
*/
|
|
154
|
+
onStatisticsUpdate = "onStatisticsUpdate",
|
|
155
|
+
/**
|
|
156
|
+
* @description 分辨率无缝切换回调。
|
|
157
|
+
*
|
|
158
|
+
* @event V2LivePlayerEvent#onStreamSwitched
|
|
159
|
+
* @param {String} url - 流地址。
|
|
160
|
+
* @param {Number} code - 状态码,0:成功,-1:切换超时,-2:切换失败,服务端错误,-3:切换失败,客户端错误。
|
|
161
|
+
*/
|
|
162
|
+
onStreamSwitched = "onStreamSwitched"
|
|
163
|
+
}
|
|
79
164
|
export declare enum V2LiveVideoResolution {
|
|
80
165
|
V2LiveVideoResolution160x160 = 0,
|
|
81
166
|
V2LiveVideoResolution270x270 = 1,
|
|
@@ -180,6 +265,45 @@ export declare class V2LivePusherStatistics {
|
|
|
180
265
|
netSpeed: number;
|
|
181
266
|
constructor(appCpu?: number, systemCpu?: number, width?: number, height?: number, fps?: number, videoBitrate?: number, audioBitrate?: number, rtt?: number, netSpeed?: number);
|
|
182
267
|
}
|
|
268
|
+
/**
|
|
269
|
+
* 推流器的统计数据
|
|
270
|
+
*
|
|
271
|
+
* @param {Number} appCpu - 当前 App 的 CPU 使用率(%)
|
|
272
|
+
* @param {Number} systemCpu - 当前系统的 CPU 使用率(%)
|
|
273
|
+
* @param {Number} width - 视频宽度
|
|
274
|
+
* @param {Number} height - 视频高度
|
|
275
|
+
* @param {Number} fps - 帧率(fps)
|
|
276
|
+
* @param {Number} videoBitrate - 视频码率(Kbps)
|
|
277
|
+
* @param {Number} audioBitrate - 音频码率(Kbps)
|
|
278
|
+
* @param {Number} audioPacketLoss - 网络音频丢包率(%),注:仅支持前缀为 [trtc://] 或 [webrtc://] 的播放地址
|
|
279
|
+
* @param {Number} videoPacketLoss - 网络视频丢包率(%),注:仅支持前缀为 [trtc://] 或 [webrtc://] 的播放地址
|
|
280
|
+
* @param {Number} jitterBufferDelay - 播放延迟(ms)
|
|
281
|
+
* @param {Number} audioTotalBlockTime - 音频播放的累计卡顿时长(ms),该时长为区间(2s)内的卡顿时长
|
|
282
|
+
* @param {Number} audioBlockRate - 音频播放卡顿率,单位(%)
|
|
283
|
+
* @param {Number} videoTotalBlockTime - 视频播放的累计卡顿时长(ms),该时长为区间(2s)内的卡顿时长
|
|
284
|
+
* @param {Number} videoBlockRate - 视频播放卡顿率,单位(%)
|
|
285
|
+
* @param {Number} rtt - 从 SDK 到云端的往返延时(ms)
|
|
286
|
+
* @param {Number} netSpeed - 上行速度(kbps)
|
|
287
|
+
*/
|
|
288
|
+
export declare class V2LivePlayerStatistics {
|
|
289
|
+
appCpu: number;
|
|
290
|
+
systemCpu: number;
|
|
291
|
+
width: number;
|
|
292
|
+
height: number;
|
|
293
|
+
fps: number;
|
|
294
|
+
videoBitrate: number;
|
|
295
|
+
audioBitrate: number;
|
|
296
|
+
audioPacketLoss: number;
|
|
297
|
+
videoPacketLoss: number;
|
|
298
|
+
jitterBufferDelay: number;
|
|
299
|
+
audioTotalBlockTime: number;
|
|
300
|
+
audioBlockRate: number;
|
|
301
|
+
videoTotalBlockTime: number;
|
|
302
|
+
videoBlockRate: number;
|
|
303
|
+
rtt: number;
|
|
304
|
+
netSpeed: number;
|
|
305
|
+
constructor(appCpu?: number, systemCpu?: number, width?: number, height?: number, fps?: number, videoBitrate?: number, audioBitrate?: number, audioPacketLoss?: number, videoPacketLoss?: number, jitterBufferDelay?: number, audioTotalBlockTime?: number, audioBlockRate?: number, videoTotalBlockTime?: number, videoBlockRate?: number, rtt?: number, netSpeed?: number);
|
|
306
|
+
}
|
|
183
307
|
export declare enum V2LivePushStatus {
|
|
184
308
|
V2LivePushStatusDisconnected = 0,
|
|
185
309
|
V2LivePushStatusConnecting = 1,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* V2Live 关键类型定义
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.V2LivePushStatus = exports.V2LivePusherStatistics = exports.V2LiveAudioQuality = exports.V2LiveBufferType = exports.V2LivePixelFormat = exports.V2LiveRotation = exports.V2LiveFillMode = exports.V2LiveMirrorType = exports.V2LiveVideoEncoderParam = exports.V2LiveVideoResolutionMode = exports.V2LiveVideoResolution = exports.V2LivePusherEvent = exports.V2LiveMode = exports.V2LiveCode = void 0;
|
|
6
|
+
exports.V2LivePushStatus = exports.V2LivePlayerStatistics = exports.V2LivePusherStatistics = exports.V2LiveAudioQuality = exports.V2LiveBufferType = exports.V2LivePixelFormat = exports.V2LiveRotation = exports.V2LiveFillMode = exports.V2LiveMirrorType = exports.V2LiveVideoEncoderParam = exports.V2LiveVideoResolutionMode = exports.V2LiveVideoResolution = exports.V2LivePlayerEvent = exports.V2LivePusherEvent = exports.V2LiveMode = exports.V2LiveCode = void 0;
|
|
7
7
|
/////////////////////////////////////////////////////////////////////////////////
|
|
8
8
|
//
|
|
9
9
|
// V2 错误码和警告码
|
|
@@ -141,6 +141,97 @@ var V2LivePusherEvent;
|
|
|
141
141
|
})(V2LivePusherEvent = exports.V2LivePusherEvent || (exports.V2LivePusherEvent = {}));
|
|
142
142
|
/////////////////////////////////////////////////////////////////////////////////
|
|
143
143
|
//
|
|
144
|
+
// V2LivePlayer 事件定义
|
|
145
|
+
//
|
|
146
|
+
/////////////////////////////////////////////////////////////////////////////////
|
|
147
|
+
/**
|
|
148
|
+
* @namespace V2LivePlayerEvent
|
|
149
|
+
* @description V2LivePlayer 事件定义
|
|
150
|
+
*
|
|
151
|
+
*/
|
|
152
|
+
var V2LivePlayerEvent;
|
|
153
|
+
(function (V2LivePlayerEvent) {
|
|
154
|
+
/**
|
|
155
|
+
* @description 错误回调:直播播放器错误通知,播放器出现错误时,会回调该通知。
|
|
156
|
+
*
|
|
157
|
+
* @event V2LivePlayerEvent#onError
|
|
158
|
+
* @param {Number} errCode - 错误码
|
|
159
|
+
* @param {String} errMsg - 错误信息
|
|
160
|
+
*/
|
|
161
|
+
V2LivePlayerEvent["onError"] = "onError";
|
|
162
|
+
/**
|
|
163
|
+
* @description 直播播放器警告通知。
|
|
164
|
+
*
|
|
165
|
+
* @event V2LivePlayerEvent#onError
|
|
166
|
+
* @param {Number} warnCode - 警告码
|
|
167
|
+
* @param {String} warnMsg - 警告信息
|
|
168
|
+
*/
|
|
169
|
+
V2LivePlayerEvent["onWarning"] = "onWarning";
|
|
170
|
+
/**
|
|
171
|
+
* @description 直播播放器分辨率变化通知。
|
|
172
|
+
*
|
|
173
|
+
* @event V2LivePlayerEvent#onVideoResolutionChanged
|
|
174
|
+
* @param {Number} width - 视频宽。
|
|
175
|
+
* @param {Number} height - 视频高。
|
|
176
|
+
*/
|
|
177
|
+
V2LivePlayerEvent["onVideoResolutionChanged"] = "onVideoResolutionChanged";
|
|
178
|
+
/**
|
|
179
|
+
* @description 已经成功连接到服务器。
|
|
180
|
+
*
|
|
181
|
+
* @event V2LivePlayerEvent#onConnected
|
|
182
|
+
*/
|
|
183
|
+
V2LivePlayerEvent["onConnected"] = "onConnected";
|
|
184
|
+
/**
|
|
185
|
+
* @description 视频播放事件。
|
|
186
|
+
*
|
|
187
|
+
* @event V2LivePlayerEvent#onVideoPlaying
|
|
188
|
+
* @param {Boolean} firstPlay - 第一次播放标志。
|
|
189
|
+
*/
|
|
190
|
+
V2LivePlayerEvent["onVideoPlaying"] = "onVideoPlaying";
|
|
191
|
+
/**
|
|
192
|
+
* @description 音频播放事件。
|
|
193
|
+
*
|
|
194
|
+
* @event V2LivePlayerEvent#onAudioPlaying
|
|
195
|
+
* @param {Boolean} firstPlay - 第一次播放标志。
|
|
196
|
+
*/
|
|
197
|
+
V2LivePlayerEvent["onAudioPlaying"] = "onAudioPlaying";
|
|
198
|
+
/**
|
|
199
|
+
* @description 视频加载事件。
|
|
200
|
+
*
|
|
201
|
+
* @event V2LivePlayerEvent#onVideoLoading
|
|
202
|
+
*/
|
|
203
|
+
V2LivePlayerEvent["onVideoLoading"] = "onVideoLoading";
|
|
204
|
+
/**
|
|
205
|
+
* @description 音频加载事件。
|
|
206
|
+
*
|
|
207
|
+
* @event V2LivePlayerEvent#onAudioLoading
|
|
208
|
+
*/
|
|
209
|
+
V2LivePlayerEvent["onAudioLoading"] = "onAudioLoading";
|
|
210
|
+
/**
|
|
211
|
+
* @description 播放器音量大小回调。
|
|
212
|
+
*
|
|
213
|
+
* @event V2LivePlayerEvent#onPlayoutVolumeUpdate
|
|
214
|
+
* @param {Number} volume - 音量大小。
|
|
215
|
+
*/
|
|
216
|
+
V2LivePlayerEvent["onPlayoutVolumeUpdate"] = "onPlayoutVolumeUpdate";
|
|
217
|
+
/**
|
|
218
|
+
* @description 直播播放器统计数据回调。
|
|
219
|
+
*
|
|
220
|
+
* @event V2LivePlayerEvent#onStatisticsUpdate
|
|
221
|
+
* @param {V2TXLivePlayerStatistics} statistics - 播放器统计数据。
|
|
222
|
+
*/
|
|
223
|
+
V2LivePlayerEvent["onStatisticsUpdate"] = "onStatisticsUpdate";
|
|
224
|
+
/**
|
|
225
|
+
* @description 分辨率无缝切换回调。
|
|
226
|
+
*
|
|
227
|
+
* @event V2LivePlayerEvent#onStreamSwitched
|
|
228
|
+
* @param {String} url - 流地址。
|
|
229
|
+
* @param {Number} code - 状态码,0:成功,-1:切换超时,-2:切换失败,服务端错误,-3:切换失败,客户端错误。
|
|
230
|
+
*/
|
|
231
|
+
V2LivePlayerEvent["onStreamSwitched"] = "onStreamSwitched";
|
|
232
|
+
})(V2LivePlayerEvent = exports.V2LivePlayerEvent || (exports.V2LivePlayerEvent = {}));
|
|
233
|
+
/////////////////////////////////////////////////////////////////////////////////
|
|
234
|
+
//
|
|
144
235
|
// (一)视频相关类型定义
|
|
145
236
|
//
|
|
146
237
|
/////////////////////////////////////////////////////////////////////////////////
|
|
@@ -393,6 +484,47 @@ class V2LivePusherStatistics {
|
|
|
393
484
|
}
|
|
394
485
|
}
|
|
395
486
|
exports.V2LivePusherStatistics = V2LivePusherStatistics;
|
|
487
|
+
/**
|
|
488
|
+
* 推流器的统计数据
|
|
489
|
+
*
|
|
490
|
+
* @param {Number} appCpu - 当前 App 的 CPU 使用率(%)
|
|
491
|
+
* @param {Number} systemCpu - 当前系统的 CPU 使用率(%)
|
|
492
|
+
* @param {Number} width - 视频宽度
|
|
493
|
+
* @param {Number} height - 视频高度
|
|
494
|
+
* @param {Number} fps - 帧率(fps)
|
|
495
|
+
* @param {Number} videoBitrate - 视频码率(Kbps)
|
|
496
|
+
* @param {Number} audioBitrate - 音频码率(Kbps)
|
|
497
|
+
* @param {Number} audioPacketLoss - 网络音频丢包率(%),注:仅支持前缀为 [trtc://] 或 [webrtc://] 的播放地址
|
|
498
|
+
* @param {Number} videoPacketLoss - 网络视频丢包率(%),注:仅支持前缀为 [trtc://] 或 [webrtc://] 的播放地址
|
|
499
|
+
* @param {Number} jitterBufferDelay - 播放延迟(ms)
|
|
500
|
+
* @param {Number} audioTotalBlockTime - 音频播放的累计卡顿时长(ms),该时长为区间(2s)内的卡顿时长
|
|
501
|
+
* @param {Number} audioBlockRate - 音频播放卡顿率,单位(%)
|
|
502
|
+
* @param {Number} videoTotalBlockTime - 视频播放的累计卡顿时长(ms),该时长为区间(2s)内的卡顿时长
|
|
503
|
+
* @param {Number} videoBlockRate - 视频播放卡顿率,单位(%)
|
|
504
|
+
* @param {Number} rtt - 从 SDK 到云端的往返延时(ms)
|
|
505
|
+
* @param {Number} netSpeed - 上行速度(kbps)
|
|
506
|
+
*/
|
|
507
|
+
class V2LivePlayerStatistics {
|
|
508
|
+
constructor(appCpu = 0, systemCpu = 0, width = 0, height = 0, fps = 0, videoBitrate = 0, audioBitrate = 0, audioPacketLoss = 0, videoPacketLoss = 0, jitterBufferDelay = 0, audioTotalBlockTime = 0, audioBlockRate = 0, videoTotalBlockTime = 0, videoBlockRate = 0, rtt = 0, netSpeed = 0) {
|
|
509
|
+
this.appCpu = appCpu;
|
|
510
|
+
this.systemCpu = systemCpu;
|
|
511
|
+
this.width = width;
|
|
512
|
+
this.height = height;
|
|
513
|
+
this.fps = fps;
|
|
514
|
+
this.videoBitrate = videoBitrate;
|
|
515
|
+
this.audioBitrate = audioBitrate;
|
|
516
|
+
this.audioPacketLoss = audioPacketLoss;
|
|
517
|
+
this.videoPacketLoss = videoPacketLoss;
|
|
518
|
+
this.jitterBufferDelay = jitterBufferDelay;
|
|
519
|
+
this.audioTotalBlockTime = audioTotalBlockTime;
|
|
520
|
+
this.audioBlockRate = audioBlockRate;
|
|
521
|
+
this.videoTotalBlockTime = videoTotalBlockTime;
|
|
522
|
+
this.videoBlockRate = videoBlockRate;
|
|
523
|
+
this.rtt = rtt;
|
|
524
|
+
this.netSpeed = netSpeed;
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
exports.V2LivePlayerStatistics = V2LivePlayerStatistics;
|
|
396
528
|
/////////////////////////////////////////////////////////////////////////////////
|
|
397
529
|
//
|
|
398
530
|
// (四)连接状态相关枚举值定义
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TRTCVideoPixelFormat, VideoBufferInfo, TRTCVideoStreamType, TRTCVideoFillMode } from '
|
|
1
|
+
import { TRTCVideoPixelFormat, VideoBufferInfo, TRTCVideoStreamType, TRTCVideoFillMode } from '../trtc_define';
|
|
2
2
|
export declare class VideoRender {
|
|
3
3
|
private view;
|
|
4
4
|
private videoRender;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.VideoRender = void 0;
|
|
4
|
-
const index_1 = require("
|
|
5
|
-
const util_1 = require("
|
|
6
|
-
const trtc_define_1 = require("
|
|
4
|
+
const index_1 = require("../Renderer/index");
|
|
5
|
+
const util_1 = require("../Renderer/util");
|
|
6
|
+
const trtc_define_1 = require("../trtc_define");
|
|
7
7
|
const DEFAULT_VIDEO_WIDTH = 640;
|
|
8
8
|
const DEFAULT_VIDEO_HEIGHT = 360;
|
|
9
9
|
class VideoRender {
|
package/liteav/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export * from './extensions/MediaMixingManager';
|
|
|
7
7
|
export * from './extensions/PluginManager';
|
|
8
8
|
export * from './trtc';
|
|
9
9
|
export * from './Live/Pusher';
|
|
10
|
+
export * from './Live/Player';
|
|
10
11
|
export * from './Live/live_define';
|
|
11
12
|
export * from './LocalMediaTranscoder';
|
|
12
13
|
import TRTCCloud from './trtc';
|
package/liteav/index.js
CHANGED
|
@@ -22,6 +22,7 @@ __exportStar(require("./extensions/MediaMixingManager"), exports);
|
|
|
22
22
|
__exportStar(require("./extensions/PluginManager"), exports);
|
|
23
23
|
__exportStar(require("./trtc"), exports);
|
|
24
24
|
__exportStar(require("./Live/Pusher"), exports);
|
|
25
|
+
__exportStar(require("./Live/Player"), exports);
|
|
25
26
|
__exportStar(require("./Live/live_define"), exports);
|
|
26
27
|
__exportStar(require("./LocalMediaTranscoder"), exports);
|
|
27
28
|
const trtc_1 = __importDefault(require("./trtc"));
|
package/package.json
CHANGED
package/scripts/copy-sdk.js
CHANGED
|
@@ -69,11 +69,11 @@ if (process.platform === "win32") {
|
|
|
69
69
|
path.resolve(SDK_JS_PATH, `build/Release/${process.arch}/trtc_electron_sdk.node`)
|
|
70
70
|
);
|
|
71
71
|
copySync(
|
|
72
|
-
path.resolve(SDK_CPP_PATH, `src/linux/libs/${soPrefix}/`),
|
|
72
|
+
path.resolve(SDK_CPP_PATH, `src/remote-liteav/sdk/linux/libs/${soPrefix}/`),
|
|
73
73
|
path.resolve(SDK_JS_PATH, 'build/Release/')
|
|
74
74
|
);
|
|
75
75
|
copySync(
|
|
76
|
-
path.resolve(SDK_CPP_PATH, `src/linux/libs/${soPrefix}/`),
|
|
76
|
+
path.resolve(SDK_CPP_PATH, `src/remote-liteav/sdk/linux/libs/${soPrefix}/`),
|
|
77
77
|
path.resolve(SDK_JS_PATH, `build/Release/${process.arch}/`)
|
|
78
78
|
);
|
|
79
79
|
}
|