UNPKG

trtc-electron-sdk

Version:

trtc electron sdk

653 lines (652 loc) 34.9 kB
"use strict"; /** * V2Live 关键类型定义 */ Object.defineProperty(exports, "__esModule", { value: true }); exports.V2TXLiveTranscodingConfig = exports.V2TXLiveMixStream = exports.V2TXLiveMixInputType = 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; ///////////////////////////////////////////////////////////////////////////////// // // V2 错误码和警告码 // ///////////////////////////////////////////////////////////////////////////////// /** * V2 错误码和警告码 * * @enum {Number} */ const V2LiveCode_HACK_JSDOC = { /** 没有错误。*/ V2LIVE_OK: 0, /** 暂未归类的通用错误。*/ V2LIVE_ERROR_FAILED: -1, /** 调用 API 时,传入的参数不合法。*/ V2LIVE_ERROR_INVALID_PARAMETER: -2, /** API 调用被拒绝。*/ V2LIVE_ERROR_REFUSED: -3, /** 当前 API 不支持调用。*/ V2LIVE_ERROR_NOT_SUPPORTED: -4, /** license 不合法,调用失败。*/ V2LIVE_ERROR_INVALID_LICENSE: -5, /** 请求服务器超时。*/ V2LIVE_ERROR_REQUEST_TIMEOUT: -6, /** 服务器无法处理您的请求。*/ V2LIVE_ERROR_SERVER_PROCESS_FAILED: -7, /** 连接断开。*/ V2LIVE_ERROR_DISCONNECTED: -8, /** 找不到可用的 HEVC 解码器。*/ V2LIVE_ERROR_NO_AVAILABLE_HEVC_DECODERS: -2304, /** 网络状况不佳:上行带宽太小,上传数据受阻。*/ V2LIVE_WARNING_NETWORK_BUSY: 1101, /** 当前视频播放出现卡顿。*/ V2LIVE_WARNING_VIDEO_BLOCK: 2105, }; var V2LiveCode; (function (V2LiveCode) { V2LiveCode[V2LiveCode["V2LIVE_OK"] = 0] = "V2LIVE_OK"; V2LiveCode[V2LiveCode["V2LIVE_ERROR_FAILED"] = -1] = "V2LIVE_ERROR_FAILED"; V2LiveCode[V2LiveCode["V2LIVE_ERROR_INVALID_PARAMETER"] = -2] = "V2LIVE_ERROR_INVALID_PARAMETER"; V2LiveCode[V2LiveCode["V2LIVE_ERROR_REFUSED"] = -3] = "V2LIVE_ERROR_REFUSED"; V2LiveCode[V2LiveCode["V2LIVE_ERROR_NOT_SUPPORTED"] = -4] = "V2LIVE_ERROR_NOT_SUPPORTED"; V2LiveCode[V2LiveCode["V2LIVE_ERROR_INVALID_LICENSE"] = -5] = "V2LIVE_ERROR_INVALID_LICENSE"; V2LiveCode[V2LiveCode["V2LIVE_ERROR_REQUEST_TIMEOUT"] = -6] = "V2LIVE_ERROR_REQUEST_TIMEOUT"; V2LiveCode[V2LiveCode["V2LIVE_ERROR_SERVER_PROCESS_FAILED"] = -7] = "V2LIVE_ERROR_SERVER_PROCESS_FAILED"; V2LiveCode[V2LiveCode["V2LIVE_ERROR_DISCONNECTED"] = -8] = "V2LIVE_ERROR_DISCONNECTED"; V2LiveCode[V2LiveCode["V2LIVE_ERROR_NO_AVAILABLE_HEVC_DECODERS"] = -2304] = "V2LIVE_ERROR_NO_AVAILABLE_HEVC_DECODERS"; V2LiveCode[V2LiveCode["V2LIVE_WARNING_NETWORK_BUSY"] = 1101] = "V2LIVE_WARNING_NETWORK_BUSY"; V2LiveCode[V2LiveCode["V2LIVE_WARNING_VIDEO_BLOCK"] = 2105] = "V2LIVE_WARNING_VIDEO_BLOCK"; })(V2LiveCode = exports.V2LiveCode || (exports.V2LiveCode = {})); ///////////////////////////////////////////////////////////////////////////////// // // 支持协议 // ///////////////////////////////////////////////////////////////////////////////// /** * 支持协议 * * @enum {Number} */ const V2LiveMode_HACK_JSDOC = { /** 支持协议: RTMP。*/ V2LiveModeRTMP: 0, /** 支持协议: TRTC。*/ V2LiveModeRTC: 1, }; var V2LiveMode; (function (V2LiveMode) { V2LiveMode[V2LiveMode["V2LiveModeRTMP"] = 0] = "V2LiveModeRTMP"; V2LiveMode[V2LiveMode["V2LiveModeRTC"] = 1] = "V2LiveModeRTC"; })(V2LiveMode = exports.V2LiveMode || (exports.V2LiveMode = {})); ///////////////////////////////////////////////////////////////////////////////// // // V2LivePusher 事件定义 // ///////////////////////////////////////////////////////////////////////////////// /** * @namespace V2LivePusherEvent * @description V2LivePusher 事件定义 * */ var V2LivePusherEvent; (function (V2LivePusherEvent) { /** * @description 错误回调:SDK 不可恢复的错误,一定要监听,并分情况给用户适当的界面提示。 * * @event V2LivePusherEvent#onError * @param {Number} errCode - 错误码 * @param {String} errMsg - 错误信息 */ V2LivePusherEvent["onError"] = "onError"; /** * @description 警告回调:SDK 可恢复的错误,需要监听,并给用户适当的界面提示。 * * @event V2LivePusherEvent#onWarning * @param {Number} warnCode - 警告码 * @param {String} warnMsg - 警告信息 */ V2LivePusherEvent["onWarning"] = "onWarning"; /** * @description 音频采集状态回调:音频采集状态回调。 * * @event V2LivePusherEvent#onCaptureFirstAudioFrame */ V2LivePusherEvent["onCaptureFirstAudioFrame"] = "onCaptureFirstAudioFrame"; /** * @description 视频采集状态回调:视频采集状态回调。 * * @event V2LivePusherEvent#onCaptureFirstVideoFrame */ V2LivePusherEvent["onCaptureFirstVideoFrame"] = "onCaptureFirstVideoFrame"; /** * @description 麦克风音量回调:麦克风音量回调。 * * @event V2LivePusherEvent#onMicrophoneVolumeUpdate * @param {Number} volume - 麦克风音量 */ V2LivePusherEvent["onMicrophoneVolumeUpdate"] = "onMicrophoneVolumeUpdate"; /** * @description 推流状态更新回调:推流状态更新回调。 * * @event V2LivePusherEvent#onPushStatusUpdate * @param {Number} status - 推流状态 * @param {String} message - 推流状态信息 */ V2LivePusherEvent["onPushStatusUpdate"] = "onPushStatusUpdate"; /** * @description 推流统计回调:推流统计信息变化时,会回调该接口。 * * @event V2LivePusherEvent#onStatisticsUpdate * @param {V2LivePusherStatistics} statistics - 推流统计信息 */ V2LivePusherEvent["onStatisticsUpdate"] = "onStatisticsUpdate"; })(V2LivePusherEvent = exports.V2LivePusherEvent || (exports.V2LivePusherEvent = {})); ///////////////////////////////////////////////////////////////////////////////// // // V2LivePlayer 事件定义 // ///////////////////////////////////////////////////////////////////////////////// /** * @namespace V2LivePlayerEvent * @description V2LivePlayer 事件定义 * */ var V2LivePlayerEvent; (function (V2LivePlayerEvent) { /** * @description 错误回调:直播播放器错误通知,播放器出现错误时,会回调该通知。 * * @event V2LivePlayerEvent#onError * @param {Number} errCode - 错误码 * @param {String} errMsg - 错误信息 */ V2LivePlayerEvent["onError"] = "onError"; /** * @description 直播播放器警告通知。 * * @event V2LivePlayerEvent#onError * @param {Number} warnCode - 警告码 * @param {String} warnMsg - 警告信息 */ V2LivePlayerEvent["onWarning"] = "onWarning"; /** * @description 直播播放器分辨率变化通知。 * * @event V2LivePlayerEvent#onVideoResolutionChanged * @param {Number} width - 视频宽。 * @param {Number} height - 视频高。 */ V2LivePlayerEvent["onVideoResolutionChanged"] = "onVideoResolutionChanged"; /** * @description 已经成功连接到服务器。 * * @event V2LivePlayerEvent#onConnected */ V2LivePlayerEvent["onConnected"] = "onConnected"; /** * @description 视频播放事件。 * * @event V2LivePlayerEvent#onVideoPlaying * @param {Boolean} firstPlay - 第一次播放标志。 */ V2LivePlayerEvent["onVideoPlaying"] = "onVideoPlaying"; /** * @description 音频播放事件。 * * @event V2LivePlayerEvent#onAudioPlaying * @param {Boolean} firstPlay - 第一次播放标志。 */ V2LivePlayerEvent["onAudioPlaying"] = "onAudioPlaying"; /** * @description 视频加载事件。 * * @event V2LivePlayerEvent#onVideoLoading */ V2LivePlayerEvent["onVideoLoading"] = "onVideoLoading"; /** * @description 音频加载事件。 * * @event V2LivePlayerEvent#onAudioLoading */ V2LivePlayerEvent["onAudioLoading"] = "onAudioLoading"; /** * @description 播放器音量大小回调。 * * @event V2LivePlayerEvent#onPlayoutVolumeUpdate * @param {Number} volume - 音量大小。 */ V2LivePlayerEvent["onPlayoutVolumeUpdate"] = "onPlayoutVolumeUpdate"; /** * @description 直播播放器统计数据回调。 * * @event V2LivePlayerEvent#onStatisticsUpdate * @param {V2TXLivePlayerStatistics} statistics - 播放器统计数据。 */ V2LivePlayerEvent["onStatisticsUpdate"] = "onStatisticsUpdate"; /** * @description 分辨率无缝切换回调。 * * @event V2LivePlayerEvent#onStreamSwitched * @param {String} url - 流地址。 * @param {Number} code - 状态码,0:成功,-1:切换超时,-2:切换失败,服务端错误,-3:切换失败,客户端错误。 */ V2LivePlayerEvent["onStreamSwitched"] = "onStreamSwitched"; })(V2LivePlayerEvent = exports.V2LivePlayerEvent || (exports.V2LivePlayerEvent = {})); ///////////////////////////////////////////////////////////////////////////////// // // (一)视频相关类型定义 // ///////////////////////////////////////////////////////////////////////////////// /** * 视频分辨率 * * @enum {Number} */ const V2LiveVideoResolution_HACK_JSDOC = { /** 分辨率 160*160,码率范围:100Kbps ~ 150Kbps,帧率:15fps。*/ V2LiveVideoResolution160x160: 0, /** 分辨率 270*270,码率范围:200Kbps ~ 300Kbps,帧率:15fps。*/ V2LiveVideoResolution270x270: 1, /** 分辨率 480*480,码率范围:350Kbps ~ 525Kbps,帧率:15fps。*/ V2LiveVideoResolution480x480: 2, /** 分辨率 320*240,码率范围:250Kbps ~ 375Kbps,帧率:15fps。*/ V2LiveVideoResolution320x240: 3, /** 分辨率 480*360,码率范围:400Kbps ~ 600Kbps,帧率:15fps。*/ V2LiveVideoResolution480x360: 4, /** 分辨率 640*480,码率范围:600Kbps ~ 900Kbps,帧率:15fps。*/ V2LiveVideoResolution640x480: 5, /** 分辨率 320*180,码率范围:250Kbps ~ 400Kbps,帧率:15fps。*/ V2LiveVideoResolution320x180: 6, /** 分辨率 480*270,码率范围:350Kbps ~ 550Kbps,帧率:15fps。*/ V2LiveVideoResolution480x270: 7, /** 分辨率 640*360,码率范围:500Kbps ~ 900Kbps,帧率:15fps。*/ V2LiveVideoResolution640x360: 8, /** 分辨率 960*540,码率范围:800Kbps ~ 1500Kbps,帧率:15fps。*/ V2LiveVideoResolution960x540: 9, /** 分辨率 1280*720,码率范围:1000Kbps ~ 1800Kbps,帧率:15fps。*/ V2LiveVideoResolution1280x720: 10, /** 分辨率 1920*1080,码率范围:2500Kbps ~ 3000Kbps,帧率:15fps。*/ V2LiveVideoResolution1920x1080: 11, }; var V2LiveVideoResolution; (function (V2LiveVideoResolution) { V2LiveVideoResolution[V2LiveVideoResolution["V2LiveVideoResolution160x160"] = 0] = "V2LiveVideoResolution160x160"; V2LiveVideoResolution[V2LiveVideoResolution["V2LiveVideoResolution270x270"] = 1] = "V2LiveVideoResolution270x270"; V2LiveVideoResolution[V2LiveVideoResolution["V2LiveVideoResolution480x480"] = 2] = "V2LiveVideoResolution480x480"; V2LiveVideoResolution[V2LiveVideoResolution["V2LiveVideoResolution320x240"] = 3] = "V2LiveVideoResolution320x240"; V2LiveVideoResolution[V2LiveVideoResolution["V2LiveVideoResolution480x360"] = 4] = "V2LiveVideoResolution480x360"; V2LiveVideoResolution[V2LiveVideoResolution["V2LiveVideoResolution640x480"] = 5] = "V2LiveVideoResolution640x480"; V2LiveVideoResolution[V2LiveVideoResolution["V2LiveVideoResolution320x180"] = 6] = "V2LiveVideoResolution320x180"; V2LiveVideoResolution[V2LiveVideoResolution["V2LiveVideoResolution480x270"] = 7] = "V2LiveVideoResolution480x270"; V2LiveVideoResolution[V2LiveVideoResolution["V2LiveVideoResolution640x360"] = 8] = "V2LiveVideoResolution640x360"; V2LiveVideoResolution[V2LiveVideoResolution["V2LiveVideoResolution960x540"] = 9] = "V2LiveVideoResolution960x540"; V2LiveVideoResolution[V2LiveVideoResolution["V2LiveVideoResolution1280x720"] = 10] = "V2LiveVideoResolution1280x720"; V2LiveVideoResolution[V2LiveVideoResolution["V2LiveVideoResolution1920x1080"] = 11] = "V2LiveVideoResolution1920x1080"; })(V2LiveVideoResolution = exports.V2LiveVideoResolution || (exports.V2LiveVideoResolution = {})); /** * 视频宽高比模式 * * 横屏模式下的分辨率: V2LiveVideoResolution640x360 + V2LiveVideoResolutionModeLandscape = 640 × 360。 * 竖屏模式下的分辨率: V2LiveVideoResolution640x360 + V2LiveVideoResolutionModePortrait = 360 × 640。 * * @enum {Number} */ const V2LiveVideoResolutionMode_HACK_JSDOC = { /** 横屏模式。*/ V2LiveVideoResolutionModeLandscape: 0, /** 竖屏模式。*/ V2LiveVideoResolutionModePortrait: 1, }; var V2LiveVideoResolutionMode; (function (V2LiveVideoResolutionMode) { V2LiveVideoResolutionMode[V2LiveVideoResolutionMode["V2LiveVideoResolutionModeLandscape"] = 0] = "V2LiveVideoResolutionModeLandscape"; V2LiveVideoResolutionMode[V2LiveVideoResolutionMode["V2LiveVideoResolutionModePortrait"] = 1] = "V2LiveVideoResolutionModePortrait"; })(V2LiveVideoResolutionMode = exports.V2LiveVideoResolutionMode || (exports.V2LiveVideoResolutionMode = {})); /** * 视频编码参数 * * 该设置决定远端用户看到的画面质量。、 * * @param {V2LiveVideoResolution} videoResolution - 【字段含义】 视频分辨率。 * - 【特别说明】如需使用竖屏分辨率,请指定 videoResolutionMode 为 Portrait,例如: 640 × 360 + Portrait = 360 × 640。 * - 【推荐取值】 * - 注意:桌面平台(Win + Mac):建议选择 640 × 360 及以上分辨率,videoResolutionMode 选择 Landscape,即横屏分辨率。 * @param {V2LiveVideoResolutionMode} videoResolutionMode - 【字段含义】分辨率模式(横屏分辨率 or 竖屏分辨率)。 * - 【推荐取值】桌面平台(Windows、Mac)建议选择 Landscape。 * - 【特别说明】如需使用竖屏分辨率,请指定 resMode 为 Portrait,例如: 640 × 360 + Portrait = 360 × 640。 * @param {Number} videoFps - 【字段含义】视频采集帧率。 * - 【推荐取值】15fps 或 20fps。5fps 以下,卡顿感明显。10fps 以下,会有轻微卡顿感。20fps 以上,会浪费带宽(电影的帧率为 24fps)。 * @param {Number} videoBitrate - 【字段含义】目标视频码率,SDK 会按照目标码率进行编码,只有在弱网络环境下才会主动降低视频码率。 * - 【推荐取值】请参考 V2LiveVideoResolution 在各档位注释的最佳码率,也可以在此基础上适当调高。 * - 比如:V2LiveVideoResolution1280x720 对应 1200kbps 的目标码率,您也可以设置为 1500kbps 用来获得更好的观感清晰度。 * - 【特别说明】您可以通过同时设置 videoBitrate 和 minVideoBitrate 两个参数,用于约束 SDK 对视频码率的调整范围: * - 如果您将 videoBitrate 和 minVideoBitrate 设置为同一个值,等价于关闭 SDK 对视频码率的自适应调节能力。 * @param {Number} minVideoBitrate - 【字段含义】最低视频码率,SDK 会在网络不佳的情况下主动降低视频码率以保持流畅度,最低会降至 minVideoBitrate 所设定的数值。 * - 【推荐取值】您可以通过同时设置 videoBitrate 和 minVideoBitrate 两个参数,用于约束 SDK 对视频码率的调整范围: * - 如果您将 videoBitrate 和 minVideoBitrate 设置为同一个值,等价于关闭 SDK 对视频码率的自适应调节能力。 */ class V2LiveVideoEncoderParam { constructor(videoResolution = V2LiveVideoResolution.V2LiveVideoResolution640x360, videoResolutionMode = V2LiveVideoResolutionMode.V2LiveVideoResolutionModeLandscape, videoFps = 15, videoBitrate = 0, minVideoBitrate = 0) { this.videoResolution = videoResolution; this.videoResolutionMode = videoResolutionMode; this.videoFps = videoFps; this.videoBitrate = videoBitrate; this.minVideoBitrate = minVideoBitrate; } } exports.V2LiveVideoEncoderParam = V2LiveVideoEncoderParam; /** * 本地摄像头镜像类型 * * @enum {Number} */ const V2LiveMirrorType_HACK_JSDOC = { /** 系统默认镜像类型,前置摄像头镜像,后置摄像头不镜像。*/ V2LiveMirrorTypeAuto: 0, /** 前置摄像头和后置摄像头,都切换为镜像模式。*/ V2LiveMirrorTypeEnable: 1, /** 前置摄像头和后置摄像头,都切换为非镜像模式。*/ V2LiveMirrorTypeDisable: 2, }; var V2LiveMirrorType; (function (V2LiveMirrorType) { V2LiveMirrorType[V2LiveMirrorType["V2LiveMirrorTypeAuto"] = 0] = "V2LiveMirrorTypeAuto"; V2LiveMirrorType[V2LiveMirrorType["V2LiveMirrorTypeEnable"] = 1] = "V2LiveMirrorTypeEnable"; V2LiveMirrorType[V2LiveMirrorType["V2LiveMirrorTypeDisable"] = 2] = "V2LiveMirrorTypeDisable"; })(V2LiveMirrorType = exports.V2LiveMirrorType || (exports.V2LiveMirrorType = {})); /** * 视频画面填充模式 * * @enum {Number} */ const V2LiveFillMode_HACK_JSDOC = { /** 图像铺满屏幕,超出显示视窗的视频部分将被裁剪,画面显示可能不完整。*/ V2LiveFillModeFill: 0, /** 图像长边填满屏幕,短边区域会被填充黑色,画面的内容完整。*/ V2LiveFillModeFit: 1, }; var V2LiveFillMode; (function (V2LiveFillMode) { V2LiveFillMode[V2LiveFillMode["V2LiveFillModeFill"] = 0] = "V2LiveFillModeFill"; V2LiveFillMode[V2LiveFillMode["V2LiveFillModeFit"] = 1] = "V2LiveFillModeFit"; })(V2LiveFillMode = exports.V2LiveFillMode || (exports.V2LiveFillMode = {})); /** * 视频画面顺时针旋转角度 * * @enum {Number} */ const V2LiveRotation_HACK_JSDOC = { /** 不旋转。*/ V2LiveRotation0: 0, /** 顺时针旋转90度。*/ V2LiveRotation90: 1, /** 顺时针旋转180度。*/ V2LiveRotation180: 2, /** 顺时针旋转270度。*/ V2LiveRotation270: 3, }; var V2LiveRotation; (function (V2LiveRotation) { V2LiveRotation[V2LiveRotation["V2LiveRotation0"] = 0] = "V2LiveRotation0"; V2LiveRotation[V2LiveRotation["V2LiveRotation90"] = 1] = "V2LiveRotation90"; V2LiveRotation[V2LiveRotation["V2LiveRotation180"] = 2] = "V2LiveRotation180"; V2LiveRotation[V2LiveRotation["V2LiveRotation270"] = 3] = "V2LiveRotation270"; })(V2LiveRotation = exports.V2LiveRotation || (exports.V2LiveRotation = {})); /** * 视频帧的像素格式 * * @enum {Number} */ const V2LivePixelFormat_HACK_JSDOC = { /** 未知。*/ V2LivePixelFormatUnknown: 0, /** I420。*/ V2LivePixelFormatI420: 1, /** BGRA8888。*/ V2LivePixelFormatBGRA32: 2, /** RGBA32。*/ V2LivePixelFormatRGBA32: 3, }; var V2LivePixelFormat; (function (V2LivePixelFormat) { V2LivePixelFormat[V2LivePixelFormat["V2LivePixelFormatUnknown"] = 0] = "V2LivePixelFormatUnknown"; V2LivePixelFormat[V2LivePixelFormat["V2LivePixelFormatI420"] = 1] = "V2LivePixelFormatI420"; V2LivePixelFormat[V2LivePixelFormat["V2LivePixelFormatBGRA32"] = 2] = "V2LivePixelFormatBGRA32"; V2LivePixelFormat[V2LivePixelFormat["V2LivePixelFormatRGBA32"] = 3] = "V2LivePixelFormatRGBA32"; })(V2LivePixelFormat = exports.V2LivePixelFormat || (exports.V2LivePixelFormat = {})); /** * 视频数据包装格式 * * @enum {Number} */ const V2LiveBufferType_HACK_JSDOC = { /** 未知。*/ V2LiveBufferTypeUnknown: 0, /** 二进制Buffer类型。*/ V2LiveBufferTypeByteBuffer: 1, }; var V2LiveBufferType; (function (V2LiveBufferType) { V2LiveBufferType[V2LiveBufferType["V2LiveBufferTypeUnknown"] = 0] = "V2LiveBufferTypeUnknown"; V2LiveBufferType[V2LiveBufferType["V2LiveBufferTypeByteBuffer"] = 1] = "V2LiveBufferTypeByteBuffer"; })(V2LiveBufferType = exports.V2LiveBufferType || (exports.V2LiveBufferType = {})); ///////////////////////////////////////////////////////////////////////////////// // // (二)音频相关类型定义 // ///////////////////////////////////////////////////////////////////////////////// /** * 声音音质 * * @enum {Number} */ const V2LiveAudioQuality_HACK_JSDOC = { /** 语音音质:采样率:16k;单声道;音频码率:16kbps;适合语音通话为主的场景,比如在线会议,语音通话。*/ V2LiveAudioQualitySpeech: 0, /** 默认音质:采样率:48k;单声道;音频码率:50kbps;SDK 默认的音频质量,如无特殊需求推荐选择之。*/ V2LiveAudioQualityDefault: 1, /** 音乐音质:采样率:48k;双声道 + 全频带;音频码率:128kbps;适合需要高保真传输音乐的场景,比如K歌、音乐直播等。*/ V2LiveAudioQualityMusic: 2, }; var V2LiveAudioQuality; (function (V2LiveAudioQuality) { V2LiveAudioQuality[V2LiveAudioQuality["V2LiveAudioQualitySpeech"] = 0] = "V2LiveAudioQualitySpeech"; V2LiveAudioQuality[V2LiveAudioQuality["V2LiveAudioQualityDefault"] = 1] = "V2LiveAudioQualityDefault"; V2LiveAudioQuality[V2LiveAudioQuality["V2LiveAudioQualityMusic"] = 2] = "V2LiveAudioQualityMusic"; })(V2LiveAudioQuality = exports.V2LiveAudioQuality || (exports.V2LiveAudioQuality = {})); ///////////////////////////////////////////////////////////////////////////////// // // (三)推流器和播放器的一些统计指标数据定义 // ///////////////////////////////////////////////////////////////////////////////// /** * 推流器的统计数据 * * @param {Number} appCpu - 当前 App 的 CPU 使用率(%) * @param {Number} systemCpu - 当前系统的 CPU 使用率(%) * @param {Number} width - 视频宽度 * @param {Number} height - 视频高度 * @param {Number} fps - 帧率(fps) * @param {Number} videoBitrate - 视频码率(Kbps) * @param {Number} audioBitrate - 音频码率(Kbps) * @param {Number} rtt - 从 SDK 到云端的往返延时(ms) * @param {Number} netSpeed - 上行速度(kbps) */ class V2LivePusherStatistics { constructor(appCpu = 0, systemCpu = 0, width = 0, height = 0, fps = 0, videoBitrate = 0, audioBitrate = 0, rtt = 0, netSpeed = 0) { this.appCpu = appCpu; this.systemCpu = systemCpu; this.width = width; this.height = height; this.fps = fps; this.videoBitrate = videoBitrate; this.audioBitrate = audioBitrate; this.rtt = rtt; this.netSpeed = netSpeed; } } exports.V2LivePusherStatistics = V2LivePusherStatistics; /** * 推流器的统计数据 * * @param {Number} appCpu - 当前 App 的 CPU 使用率(%) * @param {Number} systemCpu - 当前系统的 CPU 使用率(%) * @param {Number} width - 视频宽度 * @param {Number} height - 视频高度 * @param {Number} fps - 帧率(fps) * @param {Number} videoBitrate - 视频码率(Kbps) * @param {Number} audioBitrate - 音频码率(Kbps) * @param {Number} audioPacketLoss - 网络音频丢包率(%),注:仅支持前缀为 [trtc://] 或 [webrtc://] 的播放地址 * @param {Number} videoPacketLoss - 网络视频丢包率(%),注:仅支持前缀为 [trtc://] 或 [webrtc://] 的播放地址 * @param {Number} jitterBufferDelay - 播放延迟(ms) * @param {Number} audioTotalBlockTime - 音频播放的累计卡顿时长(ms),该时长为区间(2s)内的卡顿时长 * @param {Number} audioBlockRate - 音频播放卡顿率,单位(%) * @param {Number} videoTotalBlockTime - 视频播放的累计卡顿时长(ms),该时长为区间(2s)内的卡顿时长 * @param {Number} videoBlockRate - 视频播放卡顿率,单位(%) * @param {Number} rtt - 从 SDK 到云端的往返延时(ms) * @param {Number} netSpeed - 上行速度(kbps) */ class V2LivePlayerStatistics { 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) { this.appCpu = appCpu; this.systemCpu = systemCpu; this.width = width; this.height = height; this.fps = fps; this.videoBitrate = videoBitrate; this.audioBitrate = audioBitrate; this.audioPacketLoss = audioPacketLoss; this.videoPacketLoss = videoPacketLoss; this.jitterBufferDelay = jitterBufferDelay; this.audioTotalBlockTime = audioTotalBlockTime; this.audioBlockRate = audioBlockRate; this.videoTotalBlockTime = videoTotalBlockTime; this.videoBlockRate = videoBlockRate; this.rtt = rtt; this.netSpeed = netSpeed; } } exports.V2LivePlayerStatistics = V2LivePlayerStatistics; ///////////////////////////////////////////////////////////////////////////////// // // (四)连接状态相关枚举值定义 // ///////////////////////////////////////////////////////////////////////////////// /** * 直播流的连接状态 * * @enum {Number} */ const V2LivePushStatus_HACK_JSDOC = { /** 与服务器断开连接。 */ V2LivePushStatusDisconnected: 0, /** 正在连接服务器。 */ TRTCPublishBigStreamToCdn: 1, /** 连接服务器成功。 */ V2LivePushStatusConnectSuccess: 2, /** 重连服务器中。 */ V2LivePushStatusReconnecting: 3, }; var V2LivePushStatus; (function (V2LivePushStatus) { V2LivePushStatus[V2LivePushStatus["V2LivePushStatusDisconnected"] = 0] = "V2LivePushStatusDisconnected"; V2LivePushStatus[V2LivePushStatus["V2LivePushStatusConnecting"] = 1] = "V2LivePushStatusConnecting"; V2LivePushStatus[V2LivePushStatus["V2LivePushStatusConnectSuccess"] = 2] = "V2LivePushStatusConnectSuccess"; V2LivePushStatus[V2LivePushStatus["V2LivePushStatusReconnecting"] = 3] = "V2LivePushStatusReconnecting"; })(V2LivePushStatus = exports.V2LivePushStatus || (exports.V2LivePushStatus = {})); ///////////////////////////////////////////////////////////////////////////////// // // (五)云端混流结构定义 // ///////////////////////////////////////////////////////////////////////////////// /** * 混流输入类型配置 * * @enum {Number} */ const V2TXLiveMixInputType_HACK_JSDOC = { /** 混入音视频。 */ V2TXLiveMixInputTypeAudioVideo: 0, /** 只混入视频。 */ V2TXLiveMixInputTypePureVideo: 1, /** 只混入音频。 */ V2TXLiveMixInputTypePureAudio: 2, }; var V2TXLiveMixInputType; (function (V2TXLiveMixInputType) { V2TXLiveMixInputType[V2TXLiveMixInputType["V2TXLiveMixInputTypeAudioVideo"] = 0] = "V2TXLiveMixInputTypeAudioVideo"; V2TXLiveMixInputType[V2TXLiveMixInputType["V2TXLiveMixInputTypePureVideo"] = 1] = "V2TXLiveMixInputTypePureVideo"; V2TXLiveMixInputType[V2TXLiveMixInputType["V2TXLiveMixInputTypePureAudio"] = 2] = "V2TXLiveMixInputTypePureAudio"; })(V2TXLiveMixInputType = exports.V2TXLiveMixInputType || (exports.V2TXLiveMixInputType = {})); /** * 云端混流中每一路子画面的位置信息 * * @param {String} userId - 参与混流的 userId * @param {String} streamId - 参与混流的 userId 所在对应的推流 streamId, 空的话表示当前推流 streamId。 * @param {Number} x - 图层位置 x 坐标(绝对像素值)。 * @param {Number} y - 图层位置 y 坐标(绝对像素值)。 * @param {Number} width - 图层位置宽度(绝对像素值)。 * @param {Number} height - 图层位置高度(绝对像素值)。 * @param {Number} zOrder - 图层层次(1 - 15)不可重复。 * @param {V2TXLiveMixInputType} inputType - 该直播流的输入类型。 */ class V2TXLiveMixStream { constructor(userId = '', streamId = '', x = 0, y = 0, width = 0, height = 0, zOrder = 0, inputType = V2TXLiveMixInputType.V2TXLiveMixInputTypeAudioVideo) { this.userId = userId; this.streamId = streamId; this.x = x; this.y = y; this.width = width; this.height = height; this.zOrder = zOrder; this.inputType = inputType; } } exports.V2TXLiveMixStream = V2TXLiveMixStream; /** * 云端混流(转码)配置 * * @param {Number} videoWidth - 【字段含义】最终转码后的视频分辨率的宽度。<br> * 【推荐取值】推荐值:360px ,如果你是纯音频推流,请将 width × height 设为 0px × 0px,否则混流后会携带一条画布背景的视频流。 * @param {Number} videoHeight - 【字段含义】最终转码后的视频分辨率的高度。<br> * 【推荐取值】推荐值:640px ,如果你是纯音频推流,请将 width × height 设为 0px × 0px,否则混流后会携带一条画布背景的视频流。 * @param {Number} videoBitrate - 【字段含义】最终转码后的视频分辨率的码率(kbps)<br> * 【推荐取值】如果填0,后台会根据videoWidth和videoHeight来估算码率,您也可以参考枚举定义TRTCVideoResolution_640_480的注释。 * @param {Number} videoFramerate - 【字段含义】最终转码后的视频分辨率的帧率(FPS)<br> * 【推荐取值】默认值:15fps,取值范围是 (0,30]。 * @param {Number} videoGOP - 【字段含义】最终转码后的视频分辨率的关键帧间隔(又称为 GOP)。<br> * 【推荐取值】默认值:2,单位为秒,取值范围是 [1,8]。 * @param {Number} backgroundColor - 【字段含义】混合后画面的底色颜色,默认为黑色,格式为十六进制数字,比如:“0x61B9F1” 代表 RGB 分别为(97,158,241)。<br> * 【推荐取值】默认值:0x000000,黑色 * @param {String} backgroundImage - 【字段含义】混合后画面的背景图。<br> * 【推荐取值】默认值:'',即不设置背景图<br> * 【特别说明】背景图需要您事先在 “[控制台](https://console.cloud.tencent.com/trtc) => 应用管理 => 功能配置 => 素材管理” 中上传,<br> * 上传成功后可以获得对应的“图片ID”,然后将“图片ID”转换成字符串类型并设置到 backgroundImage 里即可。<br> * 例如:假设“图片ID” 为 63,可以设置 backgroundImage = @"63"; * @param {Number} audioSampleRate - 【字段含义】最终转码后的音频采样率。<br> * 【推荐取值】默认值:48000Hz。支持12000HZ、16000HZ、22050HZ、24000HZ、32000HZ、44100HZ、48000HZ。 * @param {Number} audioBitrate - 【字段含义】最终转码后的音频码率。<br> * 【推荐取值】默认值:64kbps,取值范围是 [32192]。 * @param {Number} audioChannels - 【字段含义】最终转码后的音频声道数<br> * 【推荐取值】默认值:1。取值范围为 [1,2] 中的整型。 * @param {V2TXLiveMixStream[]} mixStreams - 【字段含义】每一路子画面的位置信息 * @param {String} outputStreamId - 【字段含义】输出到 CDN 上的直播流 ID。<br> * 如不设置该参数,SDK 会执行默认逻辑,即房间里的多路流会混合到该接口调用者的视频流上,也就是 A+B =>A;<br> * 如果设置该参数,SDK 会将房间里的多路流混合到您指定的直播流 ID 上,也就是 A+B =>C。<br> * 【推荐取值】默认值:'',即房间里的多路流会混合到该接口调用者的视频流上。 */ class V2TXLiveTranscodingConfig { constructor(videoWidth = 0, videoHeight = 0, videoBitrate = 0, videoFramerate = 15, videoGOP = 2, backgroundColor = 0, backgroundImage = '', audioSampleRate = 64, audioBitrate = 48000, audioChannels = 1, mixStreams = [], outputStreamId = '') { this.videoWidth = videoWidth; this.videoHeight = videoHeight; this.videoBitrate = videoBitrate; this.videoFramerate = videoFramerate; this.videoGOP = videoGOP; this.backgroundColor = backgroundColor; this.backgroundImage = backgroundImage; this.audioSampleRate = audioSampleRate; this.audioBitrate = audioBitrate; this.audioChannels = audioChannels; this.mixStreams = mixStreams; this.outputStreamId = outputStreamId; } } exports.V2TXLiveTranscodingConfig = V2TXLiveTranscodingConfig;