UNPKG

electron-window-rtc

Version:

Exchange media streams between Electron windows with WebRTC.

50 lines (49 loc) 2.08 kB
import { IpcRendererEvent } from 'electron'; export interface IpcObject { on: (channel: string, callback: (event: IpcRendererEvent, ...args: any[]) => void) => void; removeListener: (channel: string, callback: (event: IpcRendererEvent, ...args: any[]) => void) => void; send: (channel: string, ...args: any[]) => void; invoke: (channel: string, ...args: any[]) => Promise<any>; } declare class WindowRTCEventEmitter { private listeners; dispose(): void; on(channel: WindowRTCEventChannel, listener: (event: WindowRTCEvent) => void): void; off(channel: WindowRTCEventChannel, listener?: (event: WindowRTCEvent) => void): void; protected emit(channel: WindowRTCEventChannel, event: WindowRTCEvent): void; } type WindowRTCEventChannel = string & ('*' | 'icecandidate' | 'iceconnectionstatechange' | 'icecandidateerror' | 'icegatheringstatechange' | 'negotiationneeded' | 'signalingstatechange' | 'track' | 'leave' | 'request-offer' | 'sent-offer' | 'received-offer' | 'received-answer' | 'received-candidate' | 'peer-left' | 'error'); export interface WindowRTCEvent { local: string; remote: string; payload: any; } /** * Defines a global IPC object. * @param { IpcObject } ipc The object that will allow Inter-process communication. */ export declare const defineIpc: (ipc: IpcObject) => void; export declare class WindowRTCPeerConnection extends WindowRTCEventEmitter { readonly name: string; private peer; static with(peer: string): Promise<WindowRTCPeerConnection>; readonly connection: RTCPeerConnection; private senderStream?; private _signalCallback; private constructor(); dispose(): void; addStream(stream: MediaStream, maxBitrate?: { audio: number; video: number; }): Promise<void>; requestOffer(): Promise<void>; get stream(): MediaStream | undefined; private signalCallback; private handleOffer; private handleAnswer; private handleCandidate; private handleLeave; private removeWebRTCListeners; private dispatch; } export {};