yirtc-sdk-web
Version:
基于WebRTC的实时音视频SDK
73 lines (72 loc) • 2.38 kB
TypeScript
/**
* RTC 适配器接口定义
* 用于抽象不同平台的 WebRTC 实现
*/
/**
* RTC 配置接口
*/
export interface RTCConfig {
iceServers?: RTCIceServer[];
iceTransportPolicy?: RTCIceTransportPolicy;
bundlePolicy?: RTCBundlePolicy;
rtcpMuxPolicy?: RTCRtcpMuxPolicy;
sdpSemantics?: 'unified-plan' | 'plan-b';
peerConnectionOptions?: any;
}
/**
* RTC 适配器接口
*/
export interface RTCInterface {
/**
* 创建对等连接
* @param config RTC配置
* @returns RTCPeerConnection
*/
createPeerConnection(config?: RTCConfig): RTCPeerConnection;
/**
* 创建SDP offer
* @param peerConnection 对等连接
* @param options offer选项
* @returns Promise<RTCSessionDescriptionInit>
*/
createOffer(peerConnection: RTCPeerConnection, options?: RTCOfferOptions): Promise<RTCSessionDescriptionInit>;
/**
* 创建SDP answer
* @param peerConnection 对等连接
* @param options answer选项
* @returns Promise<RTCSessionDescriptionInit>
*/
createAnswer(peerConnection: RTCPeerConnection, options?: RTCAnswerOptions): Promise<RTCSessionDescriptionInit>;
/**
* 设置本地描述
* @param peerConnection 对等连接
* @param description 会话描述
* @returns Promise<void>
*/
setLocalDescription(peerConnection: RTCPeerConnection, description: RTCSessionDescriptionInit): Promise<void>;
/**
* 设置远程描述
* @param peerConnection 对等连接
* @param description 会话描述
* @returns Promise<void>
*/
setRemoteDescription(peerConnection: RTCPeerConnection, description: RTCSessionDescriptionInit): Promise<void>;
/**
* 添加ICE候选
* @param peerConnection 对等连接
* @param candidate ICE候选
* @returns Promise<void>
*/
addIceCandidate(peerConnection: RTCPeerConnection, candidate: RTCIceCandidateInit): Promise<void>;
/**
* 获取统计信息
* @param peerConnection 对等连接
* @returns Promise<RTCStatsReport>
*/
getStats(peerConnection: RTCPeerConnection): Promise<RTCStatsReport>;
/**
* 关闭对等连接
* @param peerConnection 对等连接
*/
closePeerConnection(peerConnection: RTCPeerConnection): void;
}