[kurento-client] add recorder endpoint to type defintions (#44010)

* [kurento-client] add recorder endpoint to type defintions

* [kurento-client] improve formatting with prettier

* [kurento-client] export namespace to use types in applications with esModuleInterop flag
This commit is contained in:
Michel Albers 2020-04-26 18:42:17 +02:00 committed by GitHub
parent af355a2991
commit 0d8ef4fe7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 44 additions and 22 deletions

View File

@ -1,22 +1,39 @@
// Type definitions for kurento-client 6.12
// Project: https://github.com/Kurento/kurento-client-js, https://www.kurento.org
// Definitions by: James Hill <https://github.com/jhdevuk>
// Definitions by: James Hill <https://github.com/jhdevuk>, Michel Albers <https://github.com/michelalbers>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
declare namespace KurentoClient {
declare namespace kurento {
interface Constructor {
(ws_uri: string, options?: Options): Promise<ClientInstance>;
getComplexType: (complex: 'IceCandidate') => (value: any) => any;
}
class ClientInstance {
interface RecorderEndpointOptions {
uri: string;
stopOnEndOfStream?: boolean;
}
interface Options {
failAfter?: number;
enableTransactions?: boolean;
useImplicitTransactions?: boolean;
strict?: boolean;
request_timeout?: number;
response_timeout?: number;
duplicates_timeout?: number;
access_token?: string;
socket?: any;
}
interface ClientInstance {
create(type: 'MediaPipeline'): Promise<MediaPipeline>;
create(type: 'WebRtcEndpoint'): Promise<WebRtcEndpoint>;
create(type: 'RecorderEndpoint', options: RecorderEndpointOptions): Promise<RecorderEndpoint>;
on(event: 'OnIceCandidate', callback: (event: IceCandidate) => void): void;
on(event: 'Error', callback: (error: Error) => void): void;
on(event: 'Recording' | 'Paused' | 'Stopped', callback: () => void): void;
getMediaobjectById(objectId: string): Promise<any>;
getMediaobjectById(objectId: string): Promise<MediaPipeline | WebRtcEndpoint | RecorderEndpoint>;
close(): void;
}
@ -27,6 +44,7 @@ declare namespace KurentoClient {
addTag: (key: string, value: string, callback?: Callback<void>) => Promise<void>;
getTag: (key: string, callback?: Callback<string>) => Promise<string>;
getTags: (callback?: Callback<Tag[]>) => Promise<Tag[]>;
getSendTagsInEvents: (callback?: Callback<boolean>) => Promise<boolean>;
removeTag: (key: string, callback?: Callback<void>) => Promise<void>;
getChildren: (callback?: Callback<MediaObject[]>) => Promise<MediaObject[]>;
getCreationTime: (callback?: Callback<number>) => Promise<number>;
@ -49,10 +67,28 @@ declare namespace KurentoClient {
setLatencyStats: (callback?: Callback<string>) => Promise<string>;
}
interface RecorderEndpoint extends ClientInstance, MediaObject, MediaElement {
stopOnEndOfStream: boolean;
uri: string;
record: (callback?: Callback<void>) => Promise<void>;
stopAndWait: (callback?: Callback<void>) => Promise<void>;
getMaxOutputBitrate: (callback?: Callback<number>) => Promise<number>;
getMinOutputBitrate: (callback?: Callback<number>) => Promise<number>;
setMaxOutputBitrate: (bitrate: number, callback?: Callback<number>) => Promise<number>;
setMinOutputBitrate: (bitrate: number, callback?: Callback<number>) => Promise<number>;
}
interface WebRtcEndpoint extends ClientInstance, MediaObject, MediaElement {
addIceCandidate: (candidate: RTCIceCandidate, callback?: Callback<void>) => Promise<void>;
closeDataChannel: (channelId: number, callback?: Callback<void>) => Promise<void>;
createDataChannel: (label?: string, ordered?: boolean, maxPacketLifeTime?: number, maxRetransmits?: number, protocol?: string, callback?: Callback<void>) => Promise<void>;
createDataChannel: (
label?: string,
ordered?: boolean,
maxPacketLifeTime?: number,
maxRetransmits?: number,
protocol?: string,
callback?: Callback<void>,
) => Promise<void>;
gatherCandidates: (callback?: Callback<void>) => Promise<void>;
getConnectionState: (callback?: Callback<any>) => Promise<any>;
getICECandidatePairs: (callback?: Callback<any>) => Promise<any>;
@ -113,20 +149,8 @@ declare namespace KurentoClient {
}
type Callback<T> = (error: Error, result: T) => void;
interface Options {
failAfter?: number;
enableTransactions?: boolean;
useImplicitTransactions?: boolean;
strict?: boolean;
request_timeout?: number;
response_timeout?: number;
duplicates_timeout?: number;
access_token?: string;
socket?: any;
}
}
declare const kurento: KurentoClient.Constructor;
declare const kurento: kurento.Constructor;
export = kurento;

View File

@ -11,9 +11,7 @@ async () => {
endpoint.addIceCandidate(candidate);
endpoint.on('OnIceCandidate', ({ candidate }) => {
const value = kurento.getComplexType('IceCandidate')(
candidate
);
const value = kurento.getComplexType('IceCandidate')(candidate);
endpoint.addIceCandidate(value);
});