webrtc-test-suite
Advanced tools
Comparing version 1.2.9 to 1.2.10
import getUserMedia from "../utils/user_media"; | ||
import * as _stream from "../utils/media_stream_tools"; | ||
export default function checkMediaCapture(constraints, verbose = false){ | ||
export default function checkMediaCapture(constraints, verbose = false, getStream = false){ | ||
return new Promise((resolve,reject)=>{ | ||
@@ -20,7 +20,19 @@ if(!constraints.audio && !constraints.video) return reject(new Error("Constraints are not correct")); | ||
verbose && console.log(`[media-capture]: Received ${tracks.length} track(s)`); | ||
verbose && console.log(`[media-capture]: Stopping media track(s)`); | ||
_stream.stopMediaStream(stream); | ||
if(!functional) return reject(new Error("All requested tracks are not active")); | ||
if(constraints.video && !videoTrack) return reject(new Error("Video Track not found")); | ||
if(constraints.audio && !audioTrack) return reject(new Error("Audio Track not found")); | ||
if(!functional){ | ||
_stream.stopMediaStream(stream); | ||
return reject(new Error("All requested tracks are not active")); | ||
} | ||
if(constraints.video && !videoTrack) { | ||
_stream.stopMediaStream(stream); | ||
return reject(new Error("Video Track not found")); | ||
} | ||
if(constraints.audio && !audioTrack){ | ||
_stream.stopMediaStream(stream); | ||
return reject(new Error("Audio Track not found")); | ||
} | ||
if(!getStream){ | ||
verbose && console.log(`[media-capture]: Stopping media track(s)`); | ||
_stream.stopMediaStream(stream); | ||
} | ||
if(getStream) return resolve(stream); | ||
return resolve(true); | ||
@@ -27,0 +39,0 @@ } |
{ | ||
"name": "webrtc-test-suite", | ||
"version": "1.2.9", | ||
"version": "1.2.10", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "repository": "git@github.com:theanam/webrtc-test-suite.git", |
@@ -29,3 +29,3 @@ # Real life Capability testing and utilities for WebRTC. | ||
```html | ||
<script src="https://unpkg.com/webrtc-test-suite@1.2.9/dist/index.js"></script> | ||
<script src="https://unpkg.com/webrtc-test-suite@1.2.10/dist/index.js"></script> | ||
``` | ||
@@ -87,3 +87,3 @@ Yoou will get a global object called: `_rtc`. And you can access all the functionalities from that object. | ||
### 1. `checkMediaCapture` and `checkMediaCaptureSilent`: | ||
> `checkMediaCapture(constraints, [verbose = false]); // Returns Promise` | ||
> `checkMediaCapture(constraints, [verbose = false], [getStream = false]); // Returns Promise` | ||
@@ -96,3 +96,3 @@ Example Use: | ||
``` | ||
This function takes [MediaTrackConstraints](https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints) as argument, calls `getUserMedia` API with those constraints, retrieves the Media stream, Checks if audio and video stream is active and according to the [constraints](https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints) provided. Then automatically stops the media capture and returns the result. | ||
This function takes [MediaTrackConstraints](https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints) as argument, calls `getUserMedia` API with those constraints, retrieves the Media stream, Checks if audio and video stream is active and according to the [constraints](https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints) provided. Then automatically stops the media capture and returns the result. If `getStream` is set to true, the `mediaStream` is not stopped, it's returned instead, on success. | ||
@@ -99,0 +99,0 @@ ### 2. `checkPeerConnection` and `checkPeerConnectionSilent`: |
export default function(_promise){ | ||
return new Promise(resolve=>{ | ||
_promise | ||
.then(result=>resolve(result)) | ||
.catch(()=>resolve(null)); | ||
try{ | ||
_promise | ||
.then(result=>resolve(result)) | ||
.catch(()=>resolve(null)); | ||
} | ||
catch(e){ | ||
resolve(null); | ||
} | ||
}) | ||
} |
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
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
48006
346