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;
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){
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({
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()
});
suite.test("create",async function(test){
let ssrc = 100;
//Create stream
const streamInfo = new StreamInfo("stream0");
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;
//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 = 110;
//Create stream
const streamInfo = new StreamInfo("sream1");
//Create track
let track = new TrackInfo("audio", "track2");
//Add ssrc
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"},
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;
//Create event emitter
this.emitter = new EventEmitter();
//Get the Medooze Media Server interface
const MediaServer = require("medooze-media-server");
//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;
//Create new streamer
const streamer = MediaServer.createStreamer();
//Create new video session codecs
const video = new MediaInfo("video","video");
//Add h264 codec
video.addCodec(new CodecInfo("h264",96));
//Create session for video
const session = streamer.createSession(video,{
local : {
port: 5004
}
//Get the Medooze Media Server interface
const MediaServer = require("medooze-media-server");
//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;
const Capabilities = {
video : {
codecs : ["vp9"],
rtx : true,
rtcpfbs : [
{ "id": "transport-cc"},
{ "id": "ccm", "params": ["fir"]},
{ "id": "nack"},
{ "id": "nack", "params": ["pli"]}
],
extensions : [ "http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01"]
}
};
module.exports = function(request,protocol,endpoint)
//Get the Medooze Media Server interface
const MediaServer = require("medooze-media-server");
//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;
const Capabilities = {
audio : {
codecs : ["opus"],
extensions : [ "urn:ietf:params:rtp-hdrext:ssrc-audio-level", "http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01"]
},
video : {
codecs : ["vp9","h264;packetization-mode=1"],
rtx : true,
rtcpfbs : [
{ "id": "transport-cc"},
{ "id": "ccm", "params": ["fir"]},
{ "id": "nack"},
{ "id": "nack", "params": ["pli"]}
],
extensions : [ "http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01"]
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 RTMP_TO_RTP = "gst-launch-1.0 -v rtmpsrc location=rtmp://ali.wangxiao.eaydu.com/live_bak/x_100_rtc_test ! flvdemux ! h264parse ! rtph264pay config-interval=-1 pt={pt} ! udpsink host=127.0.0.1 port={port}"