@twilio/rtc-diagnostics
Advanced tools
Comparing version 1.0.0-beta1 to 1.0.0-beta2
@@ -0,1 +1,96 @@ | ||
1.0.0-beta2 (Sept 25, 2020) | ||
========================= | ||
New Features | ||
------------ | ||
* Support for Video Diagnostics is introduced with the addition of `VideoInputTest` and `testVideoInputDevice`. This test helps to diagnose possible issues with video input devices by capturing a video stream from a user and displaying it on a video element for the user to confirm. See the [API Docs](https://twilio.github.io/rtc-diagnostics/classes/videoinputtest.html) for details. | ||
**Example Usage** | ||
```ts | ||
import { | ||
DiagnosticError, | ||
testVideoInputDevice, | ||
VideoInputTest, | ||
} from '@twilio/rtc-diagnostics'; | ||
const videoEl: HTMLMediaElement = document.getElementById(...); | ||
const test: VideoInputTest = testVideoInputDevice({ | ||
element: videoEl, | ||
}); | ||
test.on(VideoInputTest.Events.End, (report: VideoInputTest.Report) => { ... }); | ||
test.on(VideoInputTest.Events.Error, (error: DiagnosticError) => { ... }); | ||
``` | ||
As soon as the test object is instantiated, an attempt to capture the user video stream will be performed and if successful then the stream will be bound to the video element. When the test is stopped, either by timeout or manually, then the video element is paused and the stream is removed from it. | ||
Changes | ||
------- | ||
* The audio device tests `InputTest` and `OutputTest` no longer perform any analysis on volume data. With this change, `InputTest.Report.didPass` and `OutputTest.Report.didPass` are no longer available and `InputTest.stop()` and `OutputTest.stop()` no longer accept a `pass: boolean` parameter. Your application will need to analyze the volume levels in the `Report.values` property to determine whether or not the volume levels are acceptable. | ||
* The following classes and methods have been changed | ||
| Old | New | | ||
|:-------------------|:-----------------------------| | ||
| `InputTest` | `AudioInputTest` | | ||
| `OutputTest` | `AudioOutputTest` | | ||
| `BitrateTest` | `MediaConnectionBitrateTest` | | ||
| `testInputDevice` | `testAudioInputDevice` | | ||
| `testOutputDevice` | `testAudioOutputDevice` | | ||
| `testBitrate` | `testMediaConnectionBitrate` | | ||
* `MediaConnectionBitrateTest` now uses TURN server on only one of the Peer Connections. With this change, you need to provide a STUN server in addition to the TURN server configurations. See `MediaConnectionBitrateTest.Options.iceServers` for details. | ||
* `MediaConnectionBitrateTest` no longer perform any analysis on bitrate data and `MediaConnectionBitrateTest.Report.didPass` is no longer available. Your application will need to analyze the bitrate values in `MediaConnectionBitrateTest.Report.values` and `MediaConnectionBitrateTest.Report.averageBitrate` properties to determine whether or not the values are acceptable. | ||
* `MediaConnectionBitrateTest` now emits warnings when certain criteria are met. See [WarningNames](https://twilio.github.io/rtc-diagnostics/enums/warningname.html) and [minBitrateThreshold](https://twilio.github.io/rtc-diagnostics/interfaces/mediaconnectionbitratetest.options.html#minbitratethreshold) for details. | ||
Example usage: | ||
```ts | ||
import { MediaConnectionBitrateTest, testMediaConnectionBitrate, WarningName } from '@twilio/rtc-diagnostics'; | ||
const test = testMediaConnectionBitrate({ iceServers: [...], minBitrateThreshold: 500 }); | ||
test.on(MediaConnectionBitrateTest.Events.Warning, (warningName: WarningName) => { | ||
// The application can listen for specific warnings... | ||
if (warningName === WarningName.LowBitrate) { | ||
// update the ui | ||
} | ||
// ...or access all active warnings. | ||
test.activeWarnings.values().forEach(...); | ||
}); | ||
test.on(MediaConnectionBitrateTest.Events.WarningCleared, (warningName: WarningName) => { | ||
// The application can listen for specific warnings... | ||
if (warningName === WarningName.LowBitrate) { | ||
// update the ui | ||
} | ||
// ...or access all active warnings. | ||
test.activeWarnings.values().forEach(...); | ||
}); | ||
``` | ||
* `DiagnosticError` can now be imported directly. Example: | ||
```ts | ||
import { | ||
DiagnosticError, | ||
MediaConnectionBitrateTest, | ||
testMediaConnectionBitrate, | ||
} from '@twilio/rtc-diagnostics'; | ||
const test = testMediaConnectionBitrate(...); | ||
test.on(MediaConnectionBitrateTest.Events.Error, (error: DiagnosticError) => { | ||
console.log(error); | ||
}); | ||
``` | ||
* Updated test names to `audio-input-test`, `audio-output-test`, and `media-connection-bitrate-test` for consistency. | ||
* Removed unused `promise-timed-out` and `invalid-option` error. | ||
1.0.0-beta1 (July 29, 2020) | ||
@@ -2,0 +97,0 @@ ============================ |
@@ -20,2 +20,14 @@ /** | ||
* @private | ||
* Minimum bitrate samples required to emit warnings. | ||
* See [[WarningName.LowBitrate]] | ||
*/ | ||
export declare const MIN_BITRATE_SAMPLE_COUNT = 5; | ||
/** | ||
* @private | ||
* Minimum number of failing bitrate values before emitting a warning. | ||
* See [[WarningName.LowBitrate]] | ||
*/ | ||
export declare const MIN_BITRATE_FAIL_COUNT = 3; | ||
/** | ||
* @private | ||
* Data channel buffered amount | ||
@@ -40,10 +52,2 @@ */ | ||
/** | ||
* @private | ||
* Test names. | ||
*/ | ||
export declare enum TestName { | ||
InputAudioDevice = "input-volume", | ||
OutputAudioDevice = "output-volume" | ||
} | ||
/** | ||
* All of the expected error names to be thrown by the diagnostics tests. | ||
@@ -55,17 +59,28 @@ * These names are set in the error objects as the `.name` member. | ||
DiagnosticError = "diagnostic", | ||
InvalidOptionError = "invalid-option", | ||
InvalidOptionsError = "invalid-options", | ||
InvalidStateError = "invalid-state", | ||
PromiseTimedOutError = "promise-timed-out", | ||
UnsupportedError = "unsupported" | ||
} | ||
/** | ||
* All of the expected warnings to be thrown by the diagnostics tests. | ||
* All of the expected warnings raised by the diagnostics tests. | ||
* A `warning-cleared` event is raised if there is an active warning | ||
* and if the criteria of the warning are no longer met. | ||
* | ||
* Example: | ||
* | ||
* ```ts | ||
* test.on(AudioInputTest.Events.Warning, (warningName: WarningName) => { | ||
* console.log(`Warning detected: ${warningName}`); | ||
* }); | ||
* | ||
* test.on(AudioInputTest.Events.WarningCleared, (warningName: WarningName) => { | ||
* console.log(`Warning cleared: ${warningName}`); | ||
* }); | ||
* ``` | ||
* | ||
*/ | ||
export declare enum WarningName { | ||
/** | ||
* The `low-audio-level` warning is raised when the volume events recorded | ||
* by the input audio device test [[InputTest]] are both low and constant. | ||
* | ||
* The warning criteria is when the following are all true: | ||
* Raised by the [[AudioInputTest]] when the volume events recorded are both low and constant. | ||
* The criteria for raising this warning are: | ||
* - If there are at least three seconds worth of audio samples. | ||
@@ -76,9 +91,11 @@ * - The standard deviation of those samples is less than 1% of the max | ||
* value (255). | ||
* | ||
* When any of the previous criteria are no longer met, the `warning-cleared` | ||
* event for `low-audio-level` is raised if `low-audio-level` has been raised. | ||
* Only one `low-audio-level` warning will be raised until the | ||
* `warning-cleared` event has been raised. | ||
*/ | ||
LowAudioLevel = "low-audio-level" | ||
LowAudioLevel = "low-audio-level", | ||
/** | ||
* Raised by the [[MediaConnectionBitrateTest]] when the recorded bitrates are consistently lower than a certain threshold. | ||
* The criteria for raising this warning are: | ||
* - At least 5 seconds worth of bitrate values have been recorded. | ||
* - 3 out of last 5 bitrate values are less than [[MediaConnectionBitrateTest.Options.minBitrateThreshold]]. | ||
*/ | ||
LowBitrate = "low-bitrate" | ||
} |
@@ -23,2 +23,14 @@ "use strict"; | ||
* @private | ||
* Minimum bitrate samples required to emit warnings. | ||
* See [[WarningName.LowBitrate]] | ||
*/ | ||
exports.MIN_BITRATE_SAMPLE_COUNT = 5; | ||
/** | ||
* @private | ||
* Minimum number of failing bitrate values before emitting a warning. | ||
* See [[WarningName.LowBitrate]] | ||
*/ | ||
exports.MIN_BITRATE_FAIL_COUNT = 3; | ||
/** | ||
* @private | ||
* Data channel buffered amount | ||
@@ -43,11 +55,2 @@ */ | ||
/** | ||
* @private | ||
* Test names. | ||
*/ | ||
var TestName; | ||
(function (TestName) { | ||
TestName["InputAudioDevice"] = "input-volume"; | ||
TestName["OutputAudioDevice"] = "output-volume"; | ||
})(TestName = exports.TestName || (exports.TestName = {})); | ||
/** | ||
* All of the expected error names to be thrown by the diagnostics tests. | ||
@@ -60,10 +63,23 @@ * These names are set in the error objects as the `.name` member. | ||
ErrorName["DiagnosticError"] = "diagnostic"; | ||
ErrorName["InvalidOptionError"] = "invalid-option"; | ||
ErrorName["InvalidOptionsError"] = "invalid-options"; | ||
ErrorName["InvalidStateError"] = "invalid-state"; | ||
ErrorName["PromiseTimedOutError"] = "promise-timed-out"; | ||
ErrorName["UnsupportedError"] = "unsupported"; | ||
})(ErrorName = exports.ErrorName || (exports.ErrorName = {})); | ||
/** | ||
* All of the expected warnings to be thrown by the diagnostics tests. | ||
* All of the expected warnings raised by the diagnostics tests. | ||
* A `warning-cleared` event is raised if there is an active warning | ||
* and if the criteria of the warning are no longer met. | ||
* | ||
* Example: | ||
* | ||
* ```ts | ||
* test.on(AudioInputTest.Events.Warning, (warningName: WarningName) => { | ||
* console.log(`Warning detected: ${warningName}`); | ||
* }); | ||
* | ||
* test.on(AudioInputTest.Events.WarningCleared, (warningName: WarningName) => { | ||
* console.log(`Warning cleared: ${warningName}`); | ||
* }); | ||
* ``` | ||
* | ||
*/ | ||
@@ -73,6 +89,4 @@ var WarningName; | ||
/** | ||
* The `low-audio-level` warning is raised when the volume events recorded | ||
* by the input audio device test [[InputTest]] are both low and constant. | ||
* | ||
* The warning criteria is when the following are all true: | ||
* Raised by the [[AudioInputTest]] when the volume events recorded are both low and constant. | ||
* The criteria for raising this warning are: | ||
* - If there are at least three seconds worth of audio samples. | ||
@@ -83,10 +97,12 @@ * - The standard deviation of those samples is less than 1% of the max | ||
* value (255). | ||
* | ||
* When any of the previous criteria are no longer met, the `warning-cleared` | ||
* event for `low-audio-level` is raised if `low-audio-level` has been raised. | ||
* Only one `low-audio-level` warning will be raised until the | ||
* `warning-cleared` event has been raised. | ||
*/ | ||
WarningName["LowAudioLevel"] = "low-audio-level"; | ||
/** | ||
* Raised by the [[MediaConnectionBitrateTest]] when the recorded bitrates are consistently lower than a certain threshold. | ||
* The criteria for raising this warning are: | ||
* - At least 5 seconds worth of bitrate values have been recorded. | ||
* - 3 out of last 5 bitrate values are less than [[MediaConnectionBitrateTest.Options.minBitrateThreshold]]. | ||
*/ | ||
WarningName["LowBitrate"] = "low-bitrate"; | ||
})(WarningName = exports.WarningName || (exports.WarningName = {})); | ||
//# sourceMappingURL=constants.js.map |
@@ -1,5 +0,8 @@ | ||
import { BitrateTest, testBitrate } from './BitrateTest'; | ||
import { AudioInputTest, testAudioInputDevice } from './AudioInputTest'; | ||
import { AudioOutputTest, testAudioOutputDevice } from './AudioOutputTest'; | ||
import { ErrorName, WarningName } from './constants'; | ||
import { InputTest, testInputDevice } from './InputTest'; | ||
import { OutputTest, testOutputDevice } from './OutputTest'; | ||
import { DiagnosticError } from './errors/DiagnosticError'; | ||
import { MediaConnectionBitrateTest, testMediaConnectionBitrate } from './MediaConnectionBitrateTest'; | ||
import { VideoResolution } from './types'; | ||
import { testVideoInputDevice, VideoInputTest } from './VideoInputTest'; | ||
/** | ||
@@ -20,2 +23,2 @@ * @internalapi | ||
*/ | ||
export { BitrateTest, ErrorName, InputTest, OutputTest, testBitrate, testInputDevice, testOutputDevice, WarningName, }; | ||
export { AudioInputTest, AudioOutputTest, DiagnosticError, MediaConnectionBitrateTest, ErrorName, testAudioInputDevice, testAudioOutputDevice, testMediaConnectionBitrate, testVideoInputDevice, VideoInputTest, VideoResolution, WarningName, }; |
@@ -14,14 +14,19 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var BitrateTest_1 = require("./BitrateTest"); | ||
exports.BitrateTest = BitrateTest_1.BitrateTest; | ||
exports.testBitrate = BitrateTest_1.testBitrate; | ||
var AudioInputTest_1 = require("./AudioInputTest"); | ||
exports.AudioInputTest = AudioInputTest_1.AudioInputTest; | ||
exports.testAudioInputDevice = AudioInputTest_1.testAudioInputDevice; | ||
var AudioOutputTest_1 = require("./AudioOutputTest"); | ||
exports.AudioOutputTest = AudioOutputTest_1.AudioOutputTest; | ||
exports.testAudioOutputDevice = AudioOutputTest_1.testAudioOutputDevice; | ||
var constants_1 = require("./constants"); | ||
exports.ErrorName = constants_1.ErrorName; | ||
exports.WarningName = constants_1.WarningName; | ||
var InputTest_1 = require("./InputTest"); | ||
exports.InputTest = InputTest_1.InputTest; | ||
exports.testInputDevice = InputTest_1.testInputDevice; | ||
var OutputTest_1 = require("./OutputTest"); | ||
exports.OutputTest = OutputTest_1.OutputTest; | ||
exports.testOutputDevice = OutputTest_1.testOutputDevice; | ||
var DiagnosticError_1 = require("./errors/DiagnosticError"); | ||
exports.DiagnosticError = DiagnosticError_1.DiagnosticError; | ||
var MediaConnectionBitrateTest_1 = require("./MediaConnectionBitrateTest"); | ||
exports.MediaConnectionBitrateTest = MediaConnectionBitrateTest_1.MediaConnectionBitrateTest; | ||
exports.testMediaConnectionBitrate = MediaConnectionBitrateTest_1.testMediaConnectionBitrate; | ||
var VideoInputTest_1 = require("./VideoInputTest"); | ||
exports.testVideoInputDevice = VideoInputTest_1.testVideoInputDevice; | ||
exports.VideoInputTest = VideoInputTest_1.VideoInputTest; | ||
/** | ||
@@ -34,5 +39,6 @@ * If the `Twilio` object does not exist, make it. | ||
window.Twilio = window.Twilio || {}; | ||
window.Twilio.Diagnostics = __assign(__assign({}, window.Twilio.Diagnostics), { testBitrate: BitrateTest_1.testBitrate, | ||
testInputDevice: InputTest_1.testInputDevice, | ||
testOutputDevice: OutputTest_1.testOutputDevice }); | ||
window.Twilio.Diagnostics = __assign(__assign({}, window.Twilio.Diagnostics), { testAudioInputDevice: AudioInputTest_1.testAudioInputDevice, | ||
testAudioOutputDevice: AudioOutputTest_1.testAudioOutputDevice, | ||
testMediaConnectionBitrate: MediaConnectionBitrateTest_1.testMediaConnectionBitrate, | ||
testVideoInputDevice: VideoInputTest_1.testVideoInputDevice }); | ||
//# sourceMappingURL=diagnostics.js.map |
export { AlreadyStoppedError } from './AlreadyStoppedError'; | ||
export { DiagnosticError } from './DiagnosticError'; | ||
export { InvalidOptionError } from './InvalidOptionError'; | ||
export { InvalidOptionsError } from './InvalidOptionsError'; | ||
export { InvalidStateError } from './InvalidStateError'; | ||
export { PromiseTimedOutError } from './PromiseTimedOutError'; | ||
export { UnsupportedError } from './UnsupportedError'; |
@@ -7,4 +7,2 @@ "use strict"; | ||
exports.DiagnosticError = DiagnosticError_1.DiagnosticError; | ||
var InvalidOptionError_1 = require("./InvalidOptionError"); | ||
exports.InvalidOptionError = InvalidOptionError_1.InvalidOptionError; | ||
var InvalidOptionsError_1 = require("./InvalidOptionsError"); | ||
@@ -14,6 +12,4 @@ exports.InvalidOptionsError = InvalidOptionsError_1.InvalidOptionsError; | ||
exports.InvalidStateError = InvalidStateError_1.InvalidStateError; | ||
var PromiseTimedOutError_1 = require("./PromiseTimedOutError"); | ||
exports.PromiseTimedOutError = PromiseTimedOutError_1.PromiseTimedOutError; | ||
var UnsupportedError_1 = require("./UnsupportedError"); | ||
exports.UnsupportedError = UnsupportedError_1.UnsupportedError; | ||
//# sourceMappingURL=index.js.map |
@@ -57,3 +57,3 @@ /** | ||
* Native MediaStream Recording APIs definitions | ||
* @internalapi | ||
* @private | ||
*/ | ||
@@ -72,1 +72,9 @@ export declare namespace MediaStreamRecorder { | ||
} | ||
/** | ||
* Description of a video resolution. | ||
* @internalapi | ||
*/ | ||
export interface VideoResolution { | ||
height: number; | ||
width: number; | ||
} |
/** | ||
* The WebRTC API's [RTCIceCandidateStats](https://developer.mozilla.org/en-US/docs/Web/API/RTCIceCandidateStats) | ||
* dictionary which provides information related to an ICE candidate. | ||
* @internalapi | ||
*/ | ||
@@ -10,2 +11,3 @@ export interface RTCIceCandidateStats { | ||
* Represents the WebRTC stats for the ICE candidate pair used to connect to media, if candidates were selected. | ||
* @internalapi | ||
*/ | ||
@@ -26,2 +28,3 @@ export interface RTCSelectedIceCandidatePairStats { | ||
* A WebRTC stats report containing relevant information about selected and gathered ICE candidates. | ||
* @internalapi | ||
*/ | ||
@@ -42,2 +45,3 @@ export interface RTCIceCandidateStatsReport { | ||
* See [RTCStats](https://developer.mozilla.org/en-US/docs/Web/API/RTCStats) | ||
* @internalapi | ||
*/ | ||
@@ -44,0 +48,0 @@ export interface RTCStats { |
@@ -95,3 +95,3 @@ /** | ||
* @internalapi | ||
* Validate input options to the [[InputTest]]. | ||
* Validate input options to the [[AudioInputTest]]. | ||
* @param inputOptions The options to validate. | ||
@@ -98,0 +98,0 @@ * @param config A record of option names to either a single |
@@ -201,3 +201,3 @@ "use strict"; | ||
* @internalapi | ||
* Validate input options to the [[InputTest]]. | ||
* Validate input options to the [[AudioInputTest]]. | ||
* @param inputOptions The options to validate. | ||
@@ -204,0 +204,0 @@ * @param config A record of option names to either a single |
@@ -31,2 +31,3 @@ export declare const name: string; | ||
"@types/mocha": string; | ||
"@types/request": string; | ||
"@types/sinon": string; | ||
@@ -37,2 +38,3 @@ "browserify": string; | ||
"karma-chrome-launcher": string; | ||
"karma-env-preprocessor": string; | ||
"karma-firefox-launcher": string; | ||
@@ -45,4 +47,4 @@ "karma-mocha": string; | ||
"nyc": string; | ||
"request": string; | ||
"sinon": string; | ||
"twilio-release-tool": string; | ||
"travis-multirunner": string; | ||
@@ -53,2 +55,3 @@ "ts-node": string; | ||
"twilio": string; | ||
"twilio-release-tool": string; | ||
"typedoc": string; | ||
@@ -55,0 +58,0 @@ "typedoc-plugin-as-member-of": string; |
{ | ||
"name": "@twilio/rtc-diagnostics", | ||
"version": "1.0.0-beta1", | ||
"version": "1.0.0-beta2", | ||
"description": "Various diagnostics functions to help analyze connections to Twilio", | ||
@@ -20,3 +20,3 @@ "main": "./es5/lib/diagnostics.js", | ||
"test:unit": "nyc mocha -r ts-node/register ./tests/unit/index.ts", | ||
"test:integration": "karma start" | ||
"test:integration": "node ./scripts/env.js && karma start" | ||
}, | ||
@@ -44,2 +44,3 @@ "contributors": [ | ||
"@types/mocha": "5.2.7", | ||
"@types/request": "^2.48.5", | ||
"@types/sinon": "9.0.4", | ||
@@ -50,2 +51,3 @@ "browserify": "16.5.0", | ||
"karma-chrome-launcher": "3.1.0", | ||
"karma-env-preprocessor": "^0.1.1", | ||
"karma-firefox-launcher": "1.2.0", | ||
@@ -58,4 +60,4 @@ "karma-mocha": "1.3.0", | ||
"nyc": "15.0.0", | ||
"request": "^2.88.2", | ||
"sinon": "9.0.2", | ||
"twilio-release-tool": "1.0.1", | ||
"travis-multirunner": "4.6.0", | ||
@@ -66,2 +68,3 @@ "ts-node": "8.5.2", | ||
"twilio": "3.39.1", | ||
"twilio-release-tool": "1.0.1", | ||
"typedoc": "0.16.11", | ||
@@ -68,0 +71,0 @@ "typedoc-plugin-as-member-of": "1.0.2", |
@@ -42,4 +42,10 @@ // Karma configuration | ||
'./**/*.ts': 'karma-typescript', | ||
'./tests/integration/*.ts': 'env', | ||
}, | ||
envPreprocessor: [ | ||
'ACCOUNTSID', | ||
'AUTHTOKEN', | ||
], | ||
// test results reporter to use | ||
@@ -46,0 +52,0 @@ // possible values: 'dots', 'progress' |
@@ -25,2 +25,16 @@ import * as pack from '../package.json'; | ||
* @private | ||
* Minimum bitrate samples required to emit warnings. | ||
* See [[WarningName.LowBitrate]] | ||
*/ | ||
export const MIN_BITRATE_SAMPLE_COUNT = 5; | ||
/** | ||
* @private | ||
* Minimum number of failing bitrate values before emitting a warning. | ||
* See [[WarningName.LowBitrate]] | ||
*/ | ||
export const MIN_BITRATE_FAIL_COUNT = 3; | ||
/** | ||
* @private | ||
* Data channel buffered amount | ||
@@ -50,11 +64,2 @@ */ | ||
/** | ||
* @private | ||
* Test names. | ||
*/ | ||
export enum TestName { | ||
InputAudioDevice = 'input-volume', | ||
OutputAudioDevice = 'output-volume', | ||
} | ||
/** | ||
* All of the expected error names to be thrown by the diagnostics tests. | ||
@@ -66,6 +71,4 @@ * These names are set in the error objects as the `.name` member. | ||
DiagnosticError = 'diagnostic', | ||
InvalidOptionError = 'invalid-option', | ||
InvalidOptionsError = 'invalid-options', | ||
InvalidStateError = 'invalid-state', | ||
PromiseTimedOutError = 'promise-timed-out', | ||
UnsupportedError = 'unsupported', | ||
@@ -75,10 +78,23 @@ } | ||
/** | ||
* All of the expected warnings to be thrown by the diagnostics tests. | ||
* All of the expected warnings raised by the diagnostics tests. | ||
* A `warning-cleared` event is raised if there is an active warning | ||
* and if the criteria of the warning are no longer met. | ||
* | ||
* Example: | ||
* | ||
* ```ts | ||
* test.on(AudioInputTest.Events.Warning, (warningName: WarningName) => { | ||
* console.log(`Warning detected: ${warningName}`); | ||
* }); | ||
* | ||
* test.on(AudioInputTest.Events.WarningCleared, (warningName: WarningName) => { | ||
* console.log(`Warning cleared: ${warningName}`); | ||
* }); | ||
* ``` | ||
* | ||
*/ | ||
export enum WarningName { | ||
/** | ||
* The `low-audio-level` warning is raised when the volume events recorded | ||
* by the input audio device test [[InputTest]] are both low and constant. | ||
* | ||
* The warning criteria is when the following are all true: | ||
* Raised by the [[AudioInputTest]] when the volume events recorded are both low and constant. | ||
* The criteria for raising this warning are: | ||
* - If there are at least three seconds worth of audio samples. | ||
@@ -89,9 +105,12 @@ * - The standard deviation of those samples is less than 1% of the max | ||
* value (255). | ||
* | ||
* When any of the previous criteria are no longer met, the `warning-cleared` | ||
* event for `low-audio-level` is raised if `low-audio-level` has been raised. | ||
* Only one `low-audio-level` warning will be raised until the | ||
* `warning-cleared` event has been raised. | ||
*/ | ||
LowAudioLevel = 'low-audio-level', | ||
/** | ||
* Raised by the [[MediaConnectionBitrateTest]] when the recorded bitrates are consistently lower than a certain threshold. | ||
* The criteria for raising this warning are: | ||
* - At least 5 seconds worth of bitrate values have been recorded. | ||
* - 3 out of last 5 bitrate values are less than [[MediaConnectionBitrateTest.Options.minBitrateThreshold]]. | ||
*/ | ||
LowBitrate = 'low-bitrate', | ||
} |
@@ -1,5 +0,8 @@ | ||
import { BitrateTest, testBitrate } from './BitrateTest'; | ||
import { AudioInputTest, testAudioInputDevice } from './AudioInputTest'; | ||
import { AudioOutputTest, testAudioOutputDevice } from './AudioOutputTest'; | ||
import { ErrorName, WarningName } from './constants'; | ||
import { InputTest, testInputDevice } from './InputTest'; | ||
import { OutputTest, testOutputDevice } from './OutputTest'; | ||
import { DiagnosticError } from './errors/DiagnosticError'; | ||
import { MediaConnectionBitrateTest, testMediaConnectionBitrate } from './MediaConnectionBitrateTest'; | ||
import { VideoResolution } from './types'; | ||
import { testVideoInputDevice, VideoInputTest } from './VideoInputTest'; | ||
@@ -26,5 +29,6 @@ /** | ||
...window.Twilio.Diagnostics, | ||
testBitrate, | ||
testInputDevice, | ||
testOutputDevice, | ||
testAudioInputDevice, | ||
testAudioOutputDevice, | ||
testMediaConnectionBitrate, | ||
testVideoInputDevice, | ||
}; | ||
@@ -36,10 +40,14 @@ | ||
export { | ||
BitrateTest, | ||
AudioInputTest, | ||
AudioOutputTest, | ||
DiagnosticError, | ||
MediaConnectionBitrateTest, | ||
ErrorName, | ||
InputTest, | ||
OutputTest, | ||
testBitrate, | ||
testInputDevice, | ||
testOutputDevice, | ||
testAudioInputDevice, | ||
testAudioOutputDevice, | ||
testMediaConnectionBitrate, | ||
testVideoInputDevice, | ||
VideoInputTest, | ||
VideoResolution, | ||
WarningName, | ||
}; |
export { AlreadyStoppedError } from './AlreadyStoppedError'; | ||
export { DiagnosticError } from './DiagnosticError'; | ||
export { InvalidOptionError } from './InvalidOptionError'; | ||
export { InvalidOptionsError } from './InvalidOptionsError'; | ||
export { InvalidStateError } from './InvalidStateError'; | ||
export { PromiseTimedOutError } from './PromiseTimedOutError'; | ||
export { UnsupportedError } from './UnsupportedError'; |
@@ -65,3 +65,3 @@ // Typescript doesn't yet support `setSinkId`, so we want to add it to the | ||
* Native MediaStream Recording APIs definitions | ||
* @internalapi | ||
* @private | ||
*/ | ||
@@ -80,1 +80,10 @@ export namespace MediaStreamRecorder { | ||
} | ||
/** | ||
* Description of a video resolution. | ||
* @internalapi | ||
*/ | ||
export interface VideoResolution { | ||
height: number; | ||
width: number; | ||
} |
/** | ||
* The WebRTC API's [RTCIceCandidateStats](https://developer.mozilla.org/en-US/docs/Web/API/RTCIceCandidateStats) | ||
* dictionary which provides information related to an ICE candidate. | ||
* @internalapi | ||
*/ | ||
@@ -11,2 +12,3 @@ export interface RTCIceCandidateStats { | ||
* Represents the WebRTC stats for the ICE candidate pair used to connect to media, if candidates were selected. | ||
* @internalapi | ||
*/ | ||
@@ -29,2 +31,3 @@ export interface RTCSelectedIceCandidatePairStats { | ||
* A WebRTC stats report containing relevant information about selected and gathered ICE candidates. | ||
* @internalapi | ||
*/ | ||
@@ -47,2 +50,3 @@ export interface RTCIceCandidateStatsReport { | ||
* See [RTCStats](https://developer.mozilla.org/en-US/docs/Web/API/RTCStats) | ||
* @internalapi | ||
*/ | ||
@@ -49,0 +53,0 @@ export interface RTCStats { |
@@ -203,3 +203,3 @@ import { | ||
* @internalapi | ||
* Validate input options to the [[InputTest]]. | ||
* Validate input options to the [[AudioInputTest]]. | ||
* @param inputOptions The options to validate. | ||
@@ -206,0 +206,0 @@ * @param config A record of option names to either a single |
{ | ||
"name": "@twilio/rtc-diagnostics", | ||
"version": "1.0.0-beta1", | ||
"version": "1.0.0-beta2", | ||
"description": "Various diagnostics functions to help analyze connections to Twilio", | ||
@@ -20,3 +20,3 @@ "main": "./es5/lib/diagnostics.js", | ||
"test:unit": "nyc mocha -r ts-node/register ./tests/unit/index.ts", | ||
"test:integration": "karma start" | ||
"test:integration": "node ./scripts/env.js && karma start" | ||
}, | ||
@@ -44,2 +44,3 @@ "contributors": [ | ||
"@types/mocha": "5.2.7", | ||
"@types/request": "^2.48.5", | ||
"@types/sinon": "9.0.4", | ||
@@ -50,2 +51,3 @@ "browserify": "16.5.0", | ||
"karma-chrome-launcher": "3.1.0", | ||
"karma-env-preprocessor": "^0.1.1", | ||
"karma-firefox-launcher": "1.2.0", | ||
@@ -58,4 +60,4 @@ "karma-mocha": "1.3.0", | ||
"nyc": "15.0.0", | ||
"request": "^2.88.2", | ||
"sinon": "9.0.2", | ||
"twilio-release-tool": "1.0.1", | ||
"travis-multirunner": "4.6.0", | ||
@@ -66,2 +68,3 @@ "ts-node": "8.5.2", | ||
"twilio": "3.39.1", | ||
"twilio-release-tool": "1.0.1", | ||
"typedoc": "0.16.11", | ||
@@ -68,0 +71,0 @@ "typedoc-plugin-as-member-of": "1.0.2", |
@@ -1,9 +0,10 @@ | ||
# Voice Diagnostics SDK | ||
The Voice Diagnostics SDK provides functions to test input and output audio devices, and the functionality to test network bandwidth requirements towards Twilio’s servers. | ||
# RTC Diagnostics SDK | ||
The RTC Diagnostics SDK provides functions to test input and output devices (microphone, speaker, camera) as well as functionality to confirm that you meet the network bandwidth requirements required to make a voice call or join a video room. | ||
This SDK requires the use of Twilio NTS to perform the network tests. Using NTS will incur charges as per [NTS pricing](https://www.twilio.com/stun-turn/pricing). | ||
This SDK requires the use of Twilio NTS or your own STUN/TURN servers to perform the network tests. Using Twilio NTS will mirror how Twilio uses STUN/TURN in Programmable Video when connecting to a Twilio Video Room and will incur charges as per [NTS pricing](https://www.twilio.com/stun-turn/pricing). | ||
## Features | ||
* Input audio device tests include volume calculation | ||
* Output audio device tests are done by playing a sound file to the selected device | ||
* Input audio device tests | ||
* Input video device tests | ||
* Output audio device tests | ||
* Bandwidth requirements tests | ||
@@ -13,3 +14,3 @@ | ||
* A Twilio account. Sign up for free [here](https://www.twilio.com/try-twilio) | ||
* Node.js v10+ | ||
* Node.js v12+ | ||
* NPM v6+ (comes installed with newer Node versions) | ||
@@ -33,2 +34,5 @@ | ||
In order to run integration tests, you'll need to copy over the `credentials.example.json` file | ||
to `credentials.json` in the same folder, and replace the empty fields with valid values. | ||
### NPM | ||
@@ -47,3 +51,3 @@ You can install directly from npm. | ||
```ts | ||
import { testBitrate } from '@twilio/rtc-diagnostics'; | ||
import { testMediaConnectionBitrate } from '@twilio/rtc-diagnostics'; | ||
``` | ||
@@ -59,3 +63,3 @@ | ||
```ts | ||
const { testBitrate } = Twilio.Diagnostics; | ||
const { testMediaConnectionBitrate } = Twilio.Diagnostics; | ||
``` | ||
@@ -66,7 +70,7 @@ | ||
### BitrateTest Example | ||
### MediaConnectionBitrateTest Example | ||
```ts | ||
import { testBitrate } from '@twilio/rtc-diagnostics'; | ||
import { testMediaConnectionBitrate } from '@twilio/rtc-diagnostics'; | ||
const bitrateTest = testBitrate({ | ||
const mediaConnectionBitrateTest = testMediaConnectionBitrate({ | ||
iceServers: [{ | ||
@@ -79,11 +83,11 @@ credential: 'bar', | ||
bitrateTest.on('bitrate', (bitrate) => { | ||
mediaConnectionBitrateTest.on('bitrate', (bitrate) => { | ||
console.log(bitrate); | ||
}); | ||
bitrateTest.on('error', (error) => { | ||
mediaConnectionBitrateTest.on('error', (error) => { | ||
console.log(error); | ||
}); | ||
bitrateTest.on('end', (report) => { | ||
mediaConnectionBitrateTest.on('end', (report) => { | ||
console.log(report); | ||
@@ -93,24 +97,24 @@ }); | ||
setTimeout(() => { | ||
bitrateTest.stop(); | ||
mediaConnectionBitrateTest.stop(); | ||
}, 10000); | ||
``` | ||
See `BitrateTest.Options` for more information for how to obtain the `urls values` | ||
See `MediaConnectionBitrateTest.Options` for more information for how to obtain the `urls values` | ||
### InputTest Example | ||
### AudioInputTest Example | ||
```ts | ||
import { testInputDevice, InputTest } from '@twilio/rtc-diagnostics'; | ||
import { testAudioInputDevice, AudioInputTest } from '@twilio/rtc-diagnostics'; | ||
const outputDeviceTest = testInputDevice({ | ||
const audioInputDeviceTest = testAudioInputDevice({ | ||
deviceId: ..., | ||
}); | ||
inputDeviceTest.on(InputTest.Events.Volume, (volume) => { | ||
audioInputDeviceTest.on(AudioInputTest.Events.Volume, (volume) => { | ||
console.log(volume); | ||
}); | ||
inputDeviceTest.on(InputTest.Events.Error, (error) => { | ||
audioInputDeviceTest.on(AudioInputTest.Events.Error, (error) => { | ||
console.error(error); | ||
}); | ||
inputDeviceTest.on(InputTest.Events.End, (report) => { | ||
audioInputDeviceTest.on(AudioInputTest.Events.End, (report) => { | ||
console.log(report); | ||
@@ -120,23 +124,42 @@ }); | ||
setTimeout(() => { | ||
inputDeviceTest.stop(); | ||
audioInputDeviceTest.stop(); | ||
}, 10000); | ||
``` | ||
### OutputTest Example | ||
### VideoInputTest Example | ||
```ts | ||
import { testOutputDevice, OutputTest } from '@twilio/rtc-diagnostics'; | ||
import { testVideoInputDevice, VideoInputTest } from '@twilio/rtc-diagnostics'; | ||
const outputDeviceTest = testOutputDevice({ | ||
const videoInputDeviceTest = testVideoInputDevice({ element: videoElement }); | ||
videoInputDeviceTest.on(VideoInputTest.Events.Error, (error) => { | ||
console.error(error); | ||
}); | ||
videoInputDeviceTest.on(VideoInputTest.Events.End, (report) => { | ||
console.log(report); | ||
}); | ||
setTimeout(() => { | ||
videoInputDeviceTest.stop(); | ||
}, 10000); | ||
``` | ||
### AudioOutputTest Example | ||
```ts | ||
import { testAudioOutputDevice, AudioOutputTest } from '@twilio/rtc-diagnostics'; | ||
const audioOutputDeviceTest = testAudioOutputDevice({ | ||
deviceId: ..., | ||
}); | ||
outputDeviceTest.on(InputTest.Events.Volume, (volume) => { | ||
audioOutputDeviceTest.on(AudioOutputTest.Events.Volume, (volume) => { | ||
console.log(volume); | ||
}); | ||
outputDeviceTest.on(InputTest.Events.Error, (error) => { | ||
audioOutputDeviceTest.on(AudioOutputTest.Events.Error, (error) => { | ||
console.error(error); | ||
}); | ||
outputDeviceTest.on(InputTest.Events.End, (report) => { | ||
audioOutputDeviceTest.on(AudioOutputTest.Events.End, (report) => { | ||
console.log(report); | ||
@@ -146,3 +169,3 @@ }); | ||
setTimeout(() => { | ||
outputDeviceTest.stop(); | ||
audioOutputDeviceTest.stop(); | ||
}, 10000); | ||
@@ -154,2 +177,4 @@ ``` | ||
* [Twilio Voice Client JS Quickstart](https://github.com/TwilioDevEd/client-quickstart-js) | ||
* [Twilio Video JS SDK](https://github.com/twilio/twilio-video.js) | ||
* [Twilio Video JS Quickstart](https://github.com/twilio/video-quickstart-js) | ||
* [Twilio Client connectivity requirements](https://www.twilio.com/docs/voice/client/javascript/voice-client-js-and-mobile-sdks-network-connectivity-requirements) | ||
@@ -156,0 +181,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
489471
8081
174
31
108
1