-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Includes signaling client, builds and build tools for common js and web, integration test framework, linting, AWS SDK for JS build with new KVS clients, and WebRTC test page. Deeper testing, more documentation, and enhancements to the test page are still pending.
- Loading branch information
1 parent
31d1ce8
commit 9bc7206
Showing
56 changed files
with
14,462 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[*] | ||
end_of_line = lf | ||
indent_size = 4 | ||
indent_style = space | ||
trim_trailing_whitespace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module.exports = { | ||
parser: '@typescript-eslint/parser', | ||
extends: [ | ||
'plugin:@typescript-eslint/recommended', | ||
'prettier/@typescript-eslint', | ||
'plugin:prettier/recommended', | ||
], | ||
plugins: ['kvs-webrtc'], | ||
parserOptions: { | ||
ecmaVersion: 2017, | ||
sourceType: 'module', | ||
}, | ||
rules: { | ||
'kvs-webrtc/sorted-imports': 'error', | ||
}, | ||
overrides: [ | ||
{ | ||
files: ['*.js'], | ||
'rules': { | ||
'@typescript-eslint/explicit-function-return-type': 'off', | ||
'@typescript-eslint/no-var-requires': 'off', | ||
} | ||
} | ||
] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Logs | ||
npm-debug.log* | ||
|
||
# Dependency directories | ||
node_modules/ | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# IDE | ||
.idea | ||
|
||
# Mac | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module.exports = { | ||
semi: true, | ||
trailingComma: "all", | ||
singleQuote: true, | ||
printWidth: 160, | ||
tabWidth: 4 | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Amazon Kinesis Video Streams WebRTC SDK for JavaScript | ||
Copyright 2019-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
|
||
This product includes software developed at | ||
Amazon Web Services, Inc. (http://aws.amazon.com/). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/** | ||
* Signaling client role. | ||
*/ | ||
export declare enum Role { | ||
MASTER = "MASTER", | ||
VIEWER = "VIEWER" | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
/// <reference types="node" /> | ||
import { EventEmitter } from 'events'; | ||
import { Role } from 'kvs-webrtc/Role'; | ||
import { SigV4RequestSignerDependencies } from 'kvs-webrtc/internal/SigV4RequestSigner'; | ||
declare type WebSocketClientDependencies = SigV4RequestSignerDependencies; | ||
interface WebSocketClientConfig { | ||
credentials: AWS.Credentials; | ||
channelName: string; | ||
channelEndpoint: string; | ||
region: string; | ||
role: Role; | ||
clientId?: string; | ||
} | ||
/** | ||
* Client for sending and receiving messages from a KVS Signaling Channel. The client can operate as either the 'MASTER' or a 'VIEWER'. | ||
* | ||
* Typically, the 'MASTER' listens for ICE candidates and SDP offers and responds with and SDP answer and its own ICE candidates. | ||
* | ||
* Typically, the 'VIEWER' sends an SDP offer and its ICE candidates and then listens for ICE candidates and SDP answers from the 'MASTER'. | ||
*/ | ||
export declare class SignalingClient extends EventEmitter { | ||
private static DEFAULT_CLIENT_ID; | ||
private websocket; | ||
private readonly requestSigner; | ||
private readonly config; | ||
private readonly pendingIceCandidatesByClientId; | ||
private readonly hasReceivedRemoteSDPByClientId; | ||
/** | ||
* Creates a new SignalingClient. The connection with the signaling service must be opened with the 'open' method. | ||
* @param {WebSocketClientConfig} config - Configuration options and parameters. | ||
* @param {WebSocketClientDependencies} [dependencies] - Dependencies that are needed for the SignalingClient to function properly. If a required dependency | ||
* is not provided, it will be loaded from the global scope. | ||
*/ | ||
constructor(config: WebSocketClientConfig, dependencies?: WebSocketClientDependencies); | ||
/** | ||
* Opens the connection with the signaling service. Listen to the 'open' event to be notified when the connection has been opened. | ||
* | ||
* An error is thrown if the connection is already open or being opened. | ||
*/ | ||
open(): void; | ||
/** | ||
* Closes the connection to the KVS Signaling Service. If already closed or closing, no action is taken. Listen to the 'close' event to be notified when the | ||
* connection has been closed. | ||
*/ | ||
close(): void; | ||
/** | ||
* Sends the given SDP offer to the signaling service. | ||
* | ||
* Typically, only the 'VIEWER' role should send an SDP offer. | ||
* @param {RTCSessionDescription} sdpOffer - SDP offer to send. | ||
* @param {string} [recipientClientId] - ID of the client to send the message to. Required for 'MASTER' role. Should not be present for 'VIEWER' role. | ||
*/ | ||
sendSdpOffer(sdpOffer: RTCSessionDescription, recipientClientId?: string): void; | ||
/** | ||
* Sends the given SDP answer to the signaling service. | ||
* | ||
* Typically, only the 'MASTER' role should send an SDP offer. | ||
* @param {RTCSessionDescription} sdpAnswer - SDP answer to send. | ||
* @param {string} [recipientClientId] - ID of the client to send the message to. Required for 'MASTER' role. Should not be present for 'VIEWER' role. | ||
*/ | ||
sendSdpAnswer(sdpAnswer: RTCSessionDescription, recipientClientId?: string): void; | ||
/** | ||
* Sends the given ICE candidate to the signaling service. | ||
* | ||
* Typically, both the 'VIEWER' role and 'MASTER' role should send ICE candidates. | ||
* @param {RTCIceCandidate} iceCandidate - ICE candidate to send. | ||
* @param {string} [recipientClientId] - ID of the client to send the message to. Required for 'MASTER' role. Should not be present for 'VIEWER' role. | ||
*/ | ||
sendIceCandidate(iceCandidate: RTCIceCandidate, recipientClientId?: string): void; | ||
/** | ||
* Validates the WebSocket connection is open and that the recipient client id is present if sending as the 'MASTER'. Encodes the given message payload | ||
* and sends the message to the signaling service. | ||
*/ | ||
private sendMessage; | ||
/** | ||
* Removes all event listeners from the WebSocket and removes the reference to the WebSocket object. | ||
*/ | ||
private cleanupWebSocket; | ||
/** | ||
* WebSocket 'open' event handler. Forwards the event on to listeners. | ||
*/ | ||
private onOpen; | ||
/** | ||
* WebSocket 'message' event handler. Attempts to parse the message and handle it according to the message type. | ||
*/ | ||
private onMessage; | ||
/** | ||
* Takes the given base64 encoded string and decodes it into a JSON object. | ||
*/ | ||
private static parseJSONObjectFromBase64String; | ||
/** | ||
* Takes the given JSON object and encodes it into a base64 string. | ||
*/ | ||
private static serializeJSONObjectAsBase64String; | ||
/** | ||
* If an SDP offer or answer has already been received from the given client, then the given ICE candidate is emitted. Otherwise, it is queued up for when | ||
* an SDP offer or answer is received. | ||
*/ | ||
private emitOrQueueIceCandidate; | ||
/** | ||
* Emits any pending ICE candidates for the given client and records that an SDP offer or answer has been received from the client. | ||
*/ | ||
private emitPendingIceCandidates; | ||
/** | ||
* Throws an error if the recipient client id is null and the current role is 'MASTER' as all messages sent as 'MASTER' should have a recipient client id. | ||
*/ | ||
private validateRecipientClientId; | ||
/** | ||
* Throw an error with a message indicating that a dependency with the given name is not found. | ||
*/ | ||
private static throwMissingDependencyError; | ||
/** | ||
* 'error' event handler. Forwards the error onto listeners. | ||
*/ | ||
private onError; | ||
/** | ||
* 'close' event handler. Forwards the error onto listeners and cleans up the connection. | ||
*/ | ||
private onClose; | ||
} | ||
export {}; |
Oops, something went wrong.