dpg.broadcast-webrtc
Version:
Modern Broadcast client service library
44 lines (43 loc) • 1.85 kB
TypeScript
import * as IO from "socket.io-client";
import type { Socket as SocketType } from "socket.io-client";
interface SocketData {
readonly socket: SocketType;
readonly routes?: {
[eventName: string]: (...any: any[]) => any | Promise<any>;
};
}
interface SocketDataOwner extends SocketData {
children_db?: {
[socketId: string]: RTCPeerConnection;
};
}
interface SocketConfig extends Partial<IO.ManagerOptions & IO.SocketOptions> {
cid: string;
}
declare class PeerConnectionVisitor implements SocketData {
private peer;
private answer;
readonly routes: SocketData["routes"];
readonly socket: SocketType;
protected initOffer(offer: RTCSessionDescriptionInit): Promise<void>;
protected initAnswer(): Promise<void>;
onTrack(callback: any): void;
constructor(rtcConfig: RTCConfiguration, socketConfig: SocketConfig | SocketType);
}
declare class PeerConnectionOwner implements SocketDataOwner {
private peer;
private readonly RTCConfiguration;
private readonly Stream;
readonly socket: SocketType;
readonly routes: SocketDataOwner["routes"];
private children;
private join;
private setAnswer;
private setCandidate;
constructor(rtcConfig: RTCConfiguration, socketConfig: SocketConfig | SocketType, stream: MediaStream);
}
declare function init(config: RTCConfiguration, socketConfig: SocketConfig | SocketType): PeerConnectionVisitor;
declare function init(config: RTCConfiguration, socketConfig: SocketConfig | SocketType, owner: false, stream?: undefined): PeerConnectionVisitor;
declare function init(config: RTCConfiguration, socketConfig: SocketConfig | SocketType, owner: true, stream: MediaStream | any): PeerConnectionOwner;
export { PeerConnectionVisitor, PeerConnectionOwner };
export default init;