[kurento-utils]: Add types (#19416)

* [kurento-utils]: Add types

* [kurento-utils]: Set noImplicitAny to `true`
This commit is contained in:
Miloslav Nenadál
2017-08-31 02:04:46 +02:00
committed by Mohamed Hegazy
parent ac52d79dde
commit 5ef67e1623
4 changed files with 137 additions and 0 deletions

101
types/kurento-utils/index.d.ts vendored Normal file
View File

@@ -0,0 +1,101 @@
// Type definitions for kurento-utils 6.6
// Project: https://github.com/Kurento/kurento-utils-js
// Definitions by: Miloslav Nenadál <https://github.com/nenadalm>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
export class WebRtcPeer {
/**
* Using this property the user can get the peerConnection and use it directly.
*/
peerConnection: RTCPeerConnection;
constructor(
mode: 'recv' | 'send' | 'sendRecv',
options?: object,
callback?: (error: string | undefined) => void
);
/**
* Use this method for showing the local video.
*/
showLocalVideo: () => void;
/**
* Using this method the user can get the local stream. You can use muted property to silence the audio, if this property is true.
*/
getLocalStream: () => MediaStream;
/**
* Using this method the user can get the remote stream.
*/
getRemoteStream: () => MediaStream;
/**
* Callback function invoked when a SDP answer is received. Developers are expected to invoke this function in order to complete the SDP negotiation. This method has two parameters:
*
* @param sdpAnswer Description of sdpAnswer
* @param callback It is a function with error like parameter. It is called when the remote description has been set successfully.
*/
processAnswer: (
sdpAnswer: string,
callback?: (error: string | undefined) => void
) => void;
/**
* Callback function invoked when a SDP offer is received. Developers are expected to invoke this function in order to complete the SDP negotiation. This method has two parameters:
*
* @param sdpOffer Description of sdpOffer
* @param callback It is a function with error and sdpAnswer like parameters. It is called when the remote description has been set successfully.
*/
processOffer: (
sdpOffer: string,
callback?: (error: string | undefined, sdp: string) => void
) => void;
/**
* This method frees the resources used by WebRtcPeer.
*/
dispose: () => void;
/**
* Callback function invoked when an ICE candidate is received. Developers are expected to invoke this function in order to complete the SDP negotiation. This method has two parameters:
*
* @param iceCandidate Literal object with the ICE candidate description
* @param callback It is a function with error like parameter. It is called when the ICE candidate has been added.
*/
addIceCandidate: (
iceCandidate: RTCIceCandidate,
callback?: () => void
) => void;
/**
* Using this method the user can get peerconnections local session descriptor.
*/
getLocalSessionDescriptor: () => RTCSessionDescription;
/**
* Using this method the user can get peerconnections remote session descriptor.
*/
getRemoteSessionDescriptor: () => RTCSessionDescription;
/**
* Creates an offer that is a request to find a remote peer with a specific configuration.
*/
generateOffer: (error: string | undefined, sdp: string) => void;
/**
* Create a WebRtcPeer as receive only.
*/
static WebRtcPeerRecvonly: (
options: object,
callback: (error: string | undefined) => void
) => WebRtcPeer;
/**
* Create a WebRtcPeer as send only.
*/
static WebRtcPeerSendonly: (
options: object,
callback: (error: string | undefined) => void
) => WebRtcPeer;
/**
* Create a WebRtcPeer as send and receive.
*/
static WebRtcPeerSendrecv: (
options: object,
callback: (error: string | undefined) => void
) => WebRtcPeer;
}

View File

@@ -0,0 +1,12 @@
import * as kurentoUtils from 'kurento-utils';
() => {
const peer = kurentoUtils.WebRtcPeer.WebRtcPeerSendrecv({}, error => {});
peer.showLocalVideo();
peer.getLocalStream().getAudioTracks();
peer.getRemoteStream().getAudioTracks();
peer.processAnswer('answer', error => {});
peer.processOffer('offer', (error, {}) => {});
const rtcPeerConnection = peer.peerConnection;
peer.dispose();
};

View File

@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"kurento-utils-tests.ts"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }