Skip to content

Commit

Permalink
Initial commit of SDK files.
Browse files Browse the repository at this point in the history
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
MixMasterMitch committed Sep 21, 2019
1 parent 31d1ce8 commit 9bc7206
Show file tree
Hide file tree
Showing 56 changed files with 14,462 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .editorconfig
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
25 changes: 25 additions & 0 deletions .eslintrc.js
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',
}
}
]
};
14 changes: 14 additions & 0 deletions .gitignore
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
7 changes: 7 additions & 0 deletions .prettierrc.js
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
};
27 changes: 27 additions & 0 deletions LICENSE → LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,30 @@
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.

END OF TERMS AND CONDITIONS

APPENDIX: How to apply the Apache License to your work.

To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
1 change: 0 additions & 1 deletion NOTICE

This file was deleted.

5 changes: 5 additions & 0 deletions NOTICE.txt
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/).
22 changes: 17 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
## My Project
# Amazon Kinesis Video Streams WebRTC SDK for JavaScript

TODO: Fill this README out!
## Running WebRTC Test Page

Be sure to:
1. Run `npm install` to download dependencies.
1. Run `npm run develop` to run the webserver.
1. Open the WebRTC test page at `http://localhost:3001`

* Change the title in this README
* Edit your repository description on GitHub
You will need to provide an AWS region, AWS credentials, and a Channel Name.

The source code for the test page is in the [`examples`](examples) directory.

## Using the SDK
To use the SDK in your own project, you need to import the following:
1. The AWS JS SDK with `AWS.KinesisVideo` and `AWS.KinesisVideoSignaling` clients and `AWS.util`.
A build with these clients is located at [`examples/aws-sdk.beta.min.js`](examples/aws-sdk.beta.min.js)
1. This KVS WebRTC SDK with the `KVSWebRTC.SignalingClient`. Builds are available in the [`dist`](dist) directory.

Documentation for the KVS WebRTC SDK Signaling Client can be found [here](dist/commonjs/SignalingClient.d.ts).
See the test page for a complete usage example.

## License

Expand Down
7 changes: 7 additions & 0 deletions dist/commonjs/Role.d.ts
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"
}
11 changes: 11 additions & 0 deletions dist/commonjs/Role.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/commonjs/Role.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

121 changes: 121 additions & 0 deletions dist/commonjs/SignalingClient.d.ts
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 {};
Loading

0 comments on commit 9bc7206

Please sign in to comment.