@tessantech/rtc-light
Version:
Verry light package to simplify Webrtc and make a videoconference in a few lines of code.
44 lines (43 loc) • 1.99 kB
TypeScript
import { ExternalPromise } from "./external-promise";
import { TricklePolicy } from "./ice-candidate-manager";
export declare abstract class RTCConnection {
private tricklePolicy;
private static twilioStun;
private static defaultConfig;
private peer;
private onInformation;
protected dataChanels: {
[key: string]: ExternalPromise<RTCDataChannel>;
};
protected constructor(stream: MediaStream | undefined, onInformation: (infos: RTCInformation) => any, createDataChannel?: boolean, configuration?: RTCConfiguration, tricklePolicy?: TricklePolicy, channels?: string[]);
private initChannels;
private createChannel;
private subscribeChannels;
getPeer(): RTCPeerConnection;
protected startOffer(): Promise<void>;
onStream(streamReceived: (stream: MediaStream) => any): void;
addInformations(infos: RTCInformation): Promise<void>;
private getChannel;
send(channelName: string, msg: string | Blob | ArrayBuffer): Promise<this>;
onMsg<T extends string | Blob | ArrayBuffer = string>(channelName: string, action: (msg: T) => any): Promise<() => void>;
}
export declare class RTCInitiator extends RTCConnection {
constructor(stream: MediaStream, onInformation: (infos: RTCInformation) => any, onOfferError?: (error: any) => any, configuration?: InitiatorConfiguration);
}
export declare class RTCReceiver extends RTCConnection {
constructor(stream: MediaStream, onInformation: (infos: RTCInformation) => any, configuration?: PeerConfiguration);
}
export declare class RTCInformation {
type: RTCInformationType;
content: any;
constructor(type: RTCInformationType, content: any);
}
export interface PeerConfiguration {
rtcConfig?: RTCConfiguration;
tricklePolicy?: TricklePolicy;
}
export interface InitiatorConfiguration extends PeerConfiguration {
channels?: string[];
}
export declare type RTCInformationType = "OFFER" | "ANSWER" | "ICECANDIDATE";
export * from "./ice-candidate-manager";