Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
connection.on('message', (frame) =>
{
//Get cmd
var msg = JSON.parse(frame.utf8Data);
//Get cmd
if (msg.cmd==="OFFER")
{
//Process the sdp
var offer = SDPInfo.process(msg.offer);
//Create recoreder
const recorder = MediaServer.createRecorder ("recordings/"+ Date.now() +".mp4",{
refresh : 15000
});
//Create an DTLS ICE transport in that enpoint
const transport = endpoint.createTransport(offer);
transport.dump("recordings/rec-"+ Date.now()+".pcap",{
incoming : true,
rtcp : true
});
//Set RTP remote properties
transport.setRemoteProperties(offer);
//Create local SDP info
const answer = offer.answer({
//Add it to answer
answer.addMedia(video);
}
//Set RTP local properties
transport.setLocalProperties({
video : answer.getMedia("video")
});
const ts = Date.now();
//Dump contents
//transport.dump("/tmp/"+ts+".pcap");
//Create recoreder
const recorder = MediaServer.createRecorder ("/tmp/"+ts +".mp4");
//For each stream offered
for (let offered of offer.getStreams().values())
{
//Create the remote stream into the transport
const incomingStream = transport.createIncomingStream(offered);
//Create new local stream
const outgoingStream = transport.createOutgoingStream({
audio: false,
video: true
});
//Get local stream info
const info = outgoingStream.getStreamInfo();