import { Client, LocalStream } from 'trtc-js-sdk'; import { GetVoiceSign } from '../typings/live/GetVoiceSign'; import { RTCType } from '../typings/rtc/type'; import { CoreRTC } from './CoreRTC'; /** * TRTC 实例接口(内部使用) */ export interface ITrtcInstance { /** * TRTC 客户端实例 */ client: Client | null; /** * 本地音视频流 */ stream: LocalStream | null; } /** * 浏览器端 TRTC RTC 实现 * * 基于腾讯云 TRTC SDK 实现的浏览器端 RTC 类。 * 适用于在浏览器环境中进行实时语音通信。 * * @example * ```typescript * const rtc = new BrowserRTC({ * getVoiceSign: async (params) => { * const response = await fetch('/api/get-voice-sign', { * method: 'POST', * body: JSON.stringify(params) * }) * return response.json() * }, * autoPlayConfirm: (opts) => { * // 处理自动播放确认 * opts.onConfirm() * } * }) * * // 加入房间 * await rtc.join({ * voiceId: 'voice-id', * userId: 'user-id', * roomId: 'room-id', * type: RTCType.RealseeBrowserRTC * }) * * // 切换麦克风 * await rtc.toggleMicro(true) * ``` */ export declare class BrowserRTC extends CoreRTC { type: RTCType; joined: boolean; micro: boolean; voiceId: string; private _getVoiceSign; private _autoPlayConfirm; /** * 检查系统要求 * * 检查浏览器是否满足 TRTC 的系统要求。 * * @returns 系统要求检查结果 */ checkRequirement: () => Promise; /** * DOM 容器(内部使用) */ private $dom; /** * TRTC 实例(内部使用) */ private _trtc; /** * 创建 BrowserRTC 实例 * * @param options 配置选项 * @param options.getVoiceSign 获取语音签名的函数,必需 * @param options.autoPlayConfirm 自动播放确认回调(可选),用于处理浏览器的自动播放策略 */ constructor(options: { getVoiceSign: GetVoiceSign; autoPlayConfirm?: (opts: { onConfirm: () => void; }) => void; }); private _initParentDom; join: (options: { voiceId: string; userId: string; roomId: string; type: RTCType; }) => Promise; quit(): Promise; detectMicro(): Promise; toggleMicro(flag?: boolean): Promise; shock(): void; private _registerRtcEvent; private _handleStreamAdded; private _handleStreamSubscribed; }