mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-23 21:00:01 +08:00
[kurento-utils]: Add types (#19416)
* [kurento-utils]: Add types * [kurento-utils]: Set noImplicitAny to `true`
This commit is contained in:
committed by
Mohamed Hegazy
parent
ac52d79dde
commit
5ef67e1623
101
types/kurento-utils/index.d.ts
vendored
Normal file
101
types/kurento-utils/index.d.ts
vendored
Normal 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 peerconnection’s local session descriptor.
|
||||
*/
|
||||
getLocalSessionDescriptor: () => RTCSessionDescription;
|
||||
/**
|
||||
* Using this method the user can get peerconnection’s 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;
|
||||
}
|
||||
12
types/kurento-utils/kurento-utils-tests.ts
Normal file
12
types/kurento-utils/kurento-utils-tests.ts
Normal 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();
|
||||
};
|
||||
23
types/kurento-utils/tsconfig.json
Normal file
23
types/kurento-utils/tsconfig.json
Normal 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"
|
||||
]
|
||||
}
|
||||
1
types/kurento-utils/tslint.json
Normal file
1
types/kurento-utils/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user