Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;
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()
});
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 tap = require("tap");
const MediaServer = require("../index");
const SemanticSDP = require("semantic-sdp");
const SDPInfo = SemanticSDP.SDPInfo;
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 Setup = SemanticSDP.Setup;
const CodecInfo = SemanticSDP.CodecInfo;
MediaServer.enableLog(false);
//Create RTP properties
const rtp = {
audio : new MediaInfo("audio","audio"),
video : new MediaInfo("video","video")
};
//Add rtp codec info data
const opus = new CodecInfo("opus",96);
const vp8 = new CodecInfo("vp8",97);
vp8.setRTX(98);
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 : {
const EventEmitter = require('events').EventEmitter;
const Logger = require("./Logger");
//Get Semantic SDP objects
const SemanticSDP = require("semantic-sdp");
const SDPInfo = SemanticSDP.SDPInfo;
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 Direction = SemanticSDP.Direction;
const CodecInfo = SemanticSDP.CodecInfo;
class Participant
{
constructor(id,name,room)
{
//Store props
this.id = id;
this.name = name;
//And casting
this.room = room;
const Native = require("./Native");
const EventEmitter = require('events').EventEmitter;
const SemanticSDP = require("semantic-sdp");
const OutgoingStreamTrack = require("./OutgoingStreamTrack");
const uuidV4 = require('uuid/v4');
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;
/**
* The incoming streams represent the media stream sent to a remote peer.
*/
class OutgoingStream
{
/**
* @ignore
* @hideconstructor
* private constructor
*/
constructor(transport,lfsr,info)
{
//Store stream info
this.info = info.constructor.name === "StreamInfo" ? info.clone() : StreamInfo.expand(info);
import Room from './room'
import Server from './server'
import config from './config'
import Logger from './logger'
import * as request from './request'
const MediaServer = require('medooze-media-server')
const SemanticSDP = require('semantic-sdp')
const SDPInfo = SemanticSDP.SDPInfo
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 Direction = SemanticSDP.Direction
const CodecInfo = SemanticSDP.CodecInfo
const log = new Logger('peer')
/**
*
*
* @class Peer
* @extends {EventEmitter}
*/
class Peer extends EventEmitter {
private peerId: string
const Native = require("./Native");
const EventEmitter = require('events').EventEmitter;
const SemanticSDP = require("semantic-sdp");
const IncomingStreamTrack = require("./IncomingStreamTrack");
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;
/**
* The incoming streams represent the recived media stream from a remote peer.
*/
class IncomingStream
{
/**
* @ignore
* @hideconstructor
* private constructor
*/
constructor(transport,receiver,info)
{
//Store stream info
const streamInfo = info.constructor.name === "StreamInfo" ? info.clone() : StreamInfo.expand(info);
const getPort = require('get-port');
const medoozeMediaServer = require('medooze-media-server');
const format = require('string-format');
const execa = require('execa');
const SemanticSDP = require('semantic-sdp');
const SDPInfo = SemanticSDP.SDPInfo;
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 Direction = SemanticSDP.Direction;
const CodecInfo = SemanticSDP.CodecInfo;
const videoPt = 96;
const audioPt = 100;
const videoCodec = 'h264';
const audioCodec = 'opus';
let videoPort = null;
let audioPort = null;
//const RTMP_TO_RTP = 'ffmpeg -fflags nobuffer -i rtmp://ali.wangxiao.eaydu.com/live_bak/x_100_rtc_test -vcodec copy -an -bsf:v h264_mp4toannexb -f rtp -payload_type {pt} rtp://127.0.0.1:{port}'
const Native = require("./Native");
const EventEmitter = require('events').EventEmitter;
const LFSR = require('lfsr');
const uuidV4 = require('uuid/v4');
const SemanticSDP = require("semantic-sdp");
const IncomingStream = require("./IncomingStream");
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 SourceGroupInfo = SemanticSDP.SourceGroupInfo;
const Utils = require("./Utils");
/**
* An emulated transport reads data from a unencrypted pcap file (typically from a transport dump), and acts like if it was a live transport from a remote peer.
* You must create the incoming streams as signaled on the remote SDP as any incoming RTP with an unknown ssrc will be ignored. The emulated transport does not allow creating outgoing streams.
*/
class EmulatedTransport
{
/**
* @ignore
* @hideconstructor
* private constructor
*/