@bddh/starling-realtime-client
Version:
97 lines (96 loc) • 3.04 kB
TypeScript
/**
* @file lib/Brtc
* @description brtc拉流相关
* @author zhangyue49
*/
import type { BRtcInstance } from '@bddh/starling-brtc';
import { ChromaEffectOptions } from '@bddh/starling-cutout/es/interface';
import { CallbackMsgType } from './interface';
export interface RtcConnectionType {
server: string;
appId: string;
token: string;
roomName: string;
userId: string;
feedId?: number;
chargeId?: number;
}
interface RtcConfig {
[x: string]: any;
videoprofile?: Record<string, any>;
mediaserverip?: string;
displayname?: string;
remotevideoviewid?: string;
localvideoviewid?: string;
bitrate?: number;
showvideobps?: boolean;
usingvideo?: boolean;
usingaudio?: boolean;
aspublisher?: boolean;
usingdatachannel?: boolean;
autoplaymuted?: boolean;
autosubscribe?: boolean;
uploadVideoResolution?: {
width: number;
height: number;
};
uploadVideoBitrate?: number;
}
export interface BizConfig {
autoCheck?: boolean;
isCrash?: boolean;
showMessage?: boolean;
autoReConnect?: boolean;
autoStart?: boolean;
showLocalVideo?: boolean;
welcomeContent?: string;
autoChromaKey?: boolean;
chromaEffects?: ChromaEffectOptions;
}
export interface RtcCallback {
[x: string]: any;
onLocalStream?: (stream: MediaStream, name: string) => void;
onLocalVideoPublished?: () => void;
onRemoteVideoComing?: (id: number) => void;
onRemoteVideoOn?: (id: number) => void;
onRemoteVideoOff?: (id: number) => void;
onRemoteVideoLoading?: (id: number) => void;
onSuccess?: () => void;
onError?: (error: string) => void;
onRemoteVideoConnected?: (id: number, on: boolean) => void;
onRemoteMediaState?: (id: number, medium: MediaStream, on: boolean) => void;
onLocalVideoConnected?: (on: boolean) => void;
onPlayingError: (element: HTMLVideoElement) => void;
onRemotedata: (data: any) => void;
onLocalVideoPublishing: () => void;
onDigitalHumanCallback: (data: CallbackMsgType) => void;
}
interface BrtcClientType {
videoWrapperId: string;
bizConfig: BizConfig;
closeLog?: boolean;
rtcConnection?: RtcConnectionType;
preConnectInfo?: RtcConnectionType;
rtcConfig?: RtcConfig;
rtcCallback?: Partial<RtcCallback>;
}
declare class BrtcClient {
client?: BRtcInstance;
isRtcVideoOn: boolean;
private rtcConnection;
private readonly rtcConfig?;
private readonly bizConfig?;
private readonly rtcCallback?;
private restarting;
private readonly timeoutEvent;
private reopenTimer;
private restartCount;
private readonly closeLog;
private haveVideoOn;
private rtcStateCallback;
constructor(props: BrtcClientType);
openRtc: (rtcConnection: RtcConnectionType) => void;
closeRtc: () => void;
restartRtc: (rtcConnection: RtcConnectionType) => void;
}
export default BrtcClient;