Skip to content

Instantly share code, notes, and snippets.

@alalonde
Created April 25, 2018 00:27
Show Gist options
  • Save alalonde/28248e1e22d0960505fd5dbe6743ea1a to your computer and use it in GitHub Desktop.
Save alalonde/28248e1e22d0960505fd5dbe6743ea1a to your computer and use it in GitHub Desktop.
declare module 'twilio-video' {
// this actually returns a CancelablePromise
export function connect(token: string, options: ConnectOptions): Promise<Room>;
export function createLocalTracks(options?: CreateLocalTracksOptions): Promise<LocalTrack[]>;
export interface ConnectOptions {
name: string;
tracks: (LocalTrack | MediaStreamTrack)[];
}
export interface CreateLocalTracksOptions {
audio: boolean | CreateLocalTrackOptions;
logLevel?: LogLevel | LogLevels;
video: boolean | CreateLocalTrackOptions;
}
export interface CreateLocalTrackOptions extends MediaTrackConstraints {
logLevel?: LogLevel | LogLevels;
name?: string;
}
export type LocalTrack = LocalAudioTrack | LocalVideoTrack;
export interface LogLevels {
default?: LogLevel;
media?: LogLevel;
signaling?: LogLevel;
webrtc?: LogLevel;
}
export type LogLevel = string;
export interface Room extends EventEmitter {
isRecording: boolean;
localParticipant: LocalParticipant;
name: string;
participants: Map<Participant.SID, RemoteParticipant>;
disconnect(): Room;
}
export interface RemoteParticipant extends Participant {
}
export interface LocalParticipant extends Participant {
tracks: Map<Track.ID, LocalVideoTrack>;
unpublishTrack: (track: LocalTrack | MediaStreamTrack) => LocalTrackPublication;
}
export interface LocalTrackPublication {
kind: Track.Kind;
track: LocalTrack;
trackName: string;
trackSid: Track.SID;
}
export interface Participant extends EventEmitter {
identity: Participant.Identity;
sid: Participant.SID;
tracks: Map<Track.ID, Track>;
}
export interface EventEmitter {
on: (eventName: string, callback: (params: any) => void) => void;
}
namespace Participant {
export type SID = string;
export type Identity = string;
}
export interface LocalAudioTrack extends Track {
stop(): void;
}
export interface LocalVideoTrack extends Track {
stop(): void;
}
export interface Track {
id: Track.ID;
kind: Track.Kind;
name: string;
}
namespace Track {
export type ID = string;
export type Kind = 'audio' | 'video' | 'data';
export type SID = string;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment