Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const Native = require("./Native");
const EventEmitter = require("events").EventEmitter;
const LayerInfo = require("./LayerInfo");
const SemanticSDP = require("semantic-sdp");
const SDPInfo = SemanticSDP.SDPInfo;
const Setup = SemanticSDP.Setup;
const MediaInfo = SemanticSDP.MediaInfo;
const CandidateInfo = SemanticSDP.CandidateInfo;
const DTLSInfo = SemanticSDP.DTLSInfo;
const ICEInfo = SemanticSDP.ICEInfo;
const StreamInfo = SemanticSDP.StreamInfo;
const TrackInfo = SemanticSDP.TrackInfo;
const TrackEncodingInfo = SemanticSDP.TrackEncodingInfo;
const SourceGroupInfo = SemanticSDP.SourceGroupInfo;
function getStatsFromIncomingSource(source)
{
const stats = {
lostPackets : source.lostPackets,
dropPackets : source.dropPackets,
numPackets : source.numPackets,
numRTCPPackets : source.numRTCPPackets,
totalBytes : source.totalBytes,
totalRTCPBytes : source.totalRTCPBytes,
totalPLIs : source.totalPLIs,
totalNACKs : source.totalNACKs,
bitrate : source.bitrate, // Acumulator window is 1000ms so Instant==InstantAvg
layers : [],
};
const tap = require("tap");
const MediaServer = require("../index");
const SemanticSDP = require("semantic-sdp");
MediaServer.enableLog(false);
MediaServer.enableDebug(false);
MediaServer.enableUltraDebug(false);
const endpoint = MediaServer.createEndpoint("127.0.0.1");
const StreamInfo = SemanticSDP.StreamInfo;
const TrackInfo = SemanticSDP.TrackInfo;
const Setup = SemanticSDP.Setup;
const Direction = SemanticSDP.Direction;
const SourceGroupInfo = SemanticSDP.SourceGroupInfo;
const CodecInfo = SemanticSDP.CodecInfo;
const TrackEncodingInfo = SemanticSDP.TrackEncodingInfo;
tap.test("IncomingMediaStream::create",async function(suite){
//Init test
const transport = endpoint.createTransport({
dtls : SemanticSDP.DTLSInfo.expand({
"hash" : "sha-256",
"fingerprint" : "F2:AA:0E:C3:22:59:5E:14:95:69:92:3D:13:B4:84:24:2C:C2:A2:C0:3E:FD:34:8E:5E:EA:6F:AF:52:CE:E6:0F"
}),
ice : SemanticSDP.ICEInfo.generate()
});
let ssrc = 100;
suite.test("audio+video",async function(test){
//Create stream
const tap = require("tap");
const MediaServer = require("../index");
const SemanticSDP = require("semantic-sdp");
const StreamInfo = SemanticSDP.StreamInfo;
const TrackInfo = SemanticSDP.TrackInfo;
const Setup = SemanticSDP.Setup;
const Direction = SemanticSDP.Direction;
const SourceGroupInfo = SemanticSDP.SourceGroupInfo;
const CodecInfo = SemanticSDP.CodecInfo;
const TrackEncodingInfo = SemanticSDP.TrackEncodingInfo;
MediaServer.enableLog(false);
let ssrc = 1;
tap.test("IncomingStream",function(suite){
//Create UDP server endpoints
const endpoint = MediaServer.createEndpoint("127.0.0.1");
const mirror = MediaServer.createEndpoint("127.0.0.1");
//Init test
const transport = endpoint.createTransport({
dtls : SemanticSDP.DTLSInfo.expand({
"hash" : "sha-256",
const tap = require("tap");
const MediaServer = require("../index");
const SemanticSDP = require("semantic-sdp");
MediaServer.enableLog(false);
MediaServer.enableDebug(false);
MediaServer.enableUltraDebug(false);
const StreamInfo = SemanticSDP.StreamInfo;
const TrackInfo = SemanticSDP.TrackInfo;
const Setup = SemanticSDP.Setup;
const Direction = SemanticSDP.Direction;
const SourceGroupInfo = SemanticSDP.SourceGroupInfo;
const CodecInfo = SemanticSDP.CodecInfo;
const TrackEncodingInfo = SemanticSDP.TrackEncodingInfo;
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
const Capabilities = {
audio : {
codecs : ["opus"],
},
video : {
codecs : ["vp8","h264"],
rtx : true,
rtcpfbs : [
{ "id": "goog-remb"},
{ "id": "transport-cc"},
{ "id": "ccm", "params": ["fir"]},
const Native = require("./Native");
const EventEmitter = require("events").EventEmitter;
const LayerInfo = require("./LayerInfo");
const SemanticSDP = require("semantic-sdp");
const SDPInfo = SemanticSDP.SDPInfo;
const Setup = SemanticSDP.Setup;
const MediaInfo = SemanticSDP.MediaInfo;
const CandidateInfo = SemanticSDP.CandidateInfo;
const DTLSInfo = SemanticSDP.DTLSInfo;
const ICEInfo = SemanticSDP.ICEInfo;
const StreamInfo = SemanticSDP.StreamInfo;
const TrackInfo = SemanticSDP.TrackInfo;
const TrackEncodingInfo = SemanticSDP.TrackEncodingInfo;
const SourceGroupInfo = SemanticSDP.SourceGroupInfo;
/**
* Mirror incoming stream from another endpoint. Used to avoid inter-thread synchronization when attaching multiple output streams.
*/
class IncomingStreamTrackMirrored
{
/**
* @ignore
* @hideconstructor
* private constructor
*/
constructor(incomingStreamTrack,timeService)
{
//Store original track and receiver
this.track = incomingStreamTrack;