Update sip.js to 0.8

This commit is contained in:
Igor Adrov
2017-11-29 12:50:55 +03:00
committed by GitHub
parent 779a35bfdb
commit 6cff3bd86b

View File

@@ -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 <https://github.com/decyrus>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -71,6 +71,27 @@ export namespace C {
}
}
export type DescriptionModifier = (description: RTCSessionDescription) => Promise<RTCSessionDescription>
export interface SessionDescriptionHandler {
getDescription(options: SessionDescriptionHandlerParameters, modifiers: DescriptionModifier[]): Promise<any>;
setDescription(sessionDescription: string, options: SessionDescriptionHandlerParameters, modifiers: DescriptionModifier[]): Promise<any>;
hasDescription: (contentType: string) => boolean;
close: () => void;
holdModifier: (description: RTCSessionDescription) => Promise<RTCSessionDescription>;
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<string | { ws_uri: string; weight?: number }>;
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[];