diff --git a/types/sip.js/index.d.ts b/types/sip.js/index.d.ts index 2513f7f585..21c1bae002 100644 --- a/types/sip.js/index.d.ts +++ b/types/sip.js/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for sip.js 0.7 +// Type definitions for sip.js 0.8 // Project: http://sipjs.com // Definitions by: Kir Dergachev // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -71,6 +71,27 @@ export namespace C { } } +export type DescriptionModifier = (description: RTCSessionDescription) => Promise + +export interface SessionDescriptionHandler { + getDescription(options: SessionDescriptionHandlerParameters, modifiers: DescriptionModifier[]): Promise; + setDescription(sessionDescription: string, options: SessionDescriptionHandlerParameters, modifiers: DescriptionModifier[]): Promise; + hasDescription: (contentType: string) => boolean; + close: () => void; + holdModifier: (description: RTCSessionDescription) => Promise; + + on(name: 'userMediaRequest', callback: (constraints: MediaConstraints) => void): void; + on(name: 'userMedia', callback: (stream: MediaStream) => void): void; + on(name: 'userMediaFailed', callback: (error: string) => void): void; + on(name: 'iceCandidate', callback: (candidate: any) => void): void; + on( + name: 'iceGathering' | 'iceGatheringComplete' | 'iceConnection' | 'iceConnectionChecking' | 'iceConnectionConnected' | 'iceConnectionCompleted' | 'iceConnectionFailed' | + 'iceConnectionDisconnected' | 'iceConnectionClosed' | string, + callback: () => void): void; + on(name: 'dataChannel' | 'getDescription' | 'setDescription', callback: (sdpWrapper: { type: string, sdp: string }) => void): void; + on(name: 'addTrack', callback: (track: any) => void): void; +} + export interface Session { startTime?: Date; endTime?: Date; @@ -81,6 +102,7 @@ export interface Session { localIdentity?: NameAddrHeader; remoteIdentity?: NameAddrHeader; data: ClientContext | ServerContext; + sessionDescriptionHandler: SessionDescriptionHandler; dtmf(tone: string | number, options?: Session.DtmfOptions): Session; terminate(options?: Session.CommonOptions): Session; @@ -140,7 +162,7 @@ export namespace Session { }; } - interface DTMF extends Object {} + interface DTMF extends Object { } interface Muted { audio?: boolean; @@ -189,10 +211,26 @@ export namespace WebRTC { on(name: 'iceCandidate', callback: (candidate: any) => void): void; on( name: 'iceGathering' | 'iceGatheringComplete' | 'iceConnection' | 'iceConnectionChecking' | 'iceConnectionConnected' | 'iceConnectionCompleted' | 'iceConnectionFailed' | - 'iceConnectionDisconnected' | 'iceConnectionClosed' | string, + 'iceConnectionDisconnected' | 'iceConnectionClosed' | string, callback: () => void): void; on(name: 'dataChannel' | 'getDescription' | 'setDescription', callback: (sdpWrapper: { type: string, sdp: string }) => void): void; } + + class Simple { + constructor(options: SimpleConfigurationParameters); + + on(name: 'registered', callback: (ua: UA) => void): void; + on(name: 'unregistered', callback: (ua: UA) => void): void; + on(name: 'ringing', callback: (session: Session) => void): void; + on(name: 'connecting', callback: (session: Session) => void): void; + on(name: 'connected', callback: (session: Session) => void): void; + on(name: 'ended', callback: (session: Session) => void): void; + on(name: 'message', callback: (message: Message) => void): void; + + call(target: string | URI): Session; + toggleMute(mute: boolean): void; + hangup: () => Session | void; + } } /* Parameters */ @@ -242,6 +280,39 @@ export interface ConfigurationParameters { wsServerReconnectionTimeout?: number; } +export interface SimpleConfigurationParameters { + ua: { + wsServers?: string | Array; + uri?: string; + authorizationUser?: string; + password?: string; + displayName?: string; + traceSip?: boolean; + userAgentString?: string; + }; + media?: { + remote?: { + audio?: Element; + video?: Element; + }; + local?: { + audio?: Element; + video?: Element; + }; + }; +} + +export interface SessionDescriptionHandlerParameters { + constraints?: any; + peerConnectionOptions?: { + rtcConfiguration: { + iceServers: TurnServer[]; + iceCheckingTimeout: number; + }; + RTCOfferOptions: {}; + }; +} + /* Options */ export interface ExtraHeadersOptions { extraHeaders?: string[];