WebRTC Implementation for TypeScript (Node.js), includes ICE/DTLS/SCTP/RTP/SRTP/WEBM/MP4
MIT License
To improve compatibility with browsers, undefined candidates are now included in the payload of events such as peerConnection.onIceCandidate when ice gathering is completed.
Published by shinyoshiaki 10 months ago
Move nonstandard module to subpath.
When using subpath, set moduleResolution in tsconfig to node16 or nodenext
Published by shinyoshiaki about 1 year ago
Published by shinyoshiaki almost 2 years ago
Published by shinyoshiaki over 2 years ago
Published by shinyoshiaki over 2 years ago
const pc = new RTCPeerConnection({
codecs: {
audio: [
new RTCRtpCodecParameters({
mimeType: "PCMU",
clockRate: 8000,
channels: 1,
payloadType: 0
}),
],
},
});
Published by shinyoshiaki over 2 years ago
const pc = new RTCPeerConnection({
bundlePolicy: "disable" or "max-compat" or "max-bundle",
});
Default value is max-compat
Published by shinyoshiaki almost 3 years ago
Published by shinyoshiaki about 3 years ago
Published by shinyoshiaki about 3 years ago
Published by shinyoshiaki about 3 years ago
Published by shinyoshiaki about 3 years ago
Video and Audio can be saved to a webm file using Node.js alone, without the need for gStreamer.
example
import { MediaRecorder, RTCPeerConnection } from "werift";
import { Server } from "ws";
// open ./answer.html
const server = new Server({ port: 8888 });
console.log("start");
server.on("connection", async (socket) => {
const recorder = new MediaRecorder([], "./test.webm", {
width: 640,
height: 360,
});
const pc = new RTCPeerConnection();
{
const transceiver = pc.addTransceiver("video");
transceiver.onTrack.subscribe((track) => {
recorder.addTrack(track);
if (recorder.tracks.length === 2) {
recorder.start();
}
setInterval(() => {
transceiver.receiver.sendRtcpPLI(track.ssrc);
}, 15_000);
});
}
{
const transceiver = pc.addTransceiver("audio");
transceiver.onTrack.subscribe((track) => {
recorder.addTrack(track);
if (recorder.tracks.length === 2) {
recorder.start();
}
});
}
await pc.setLocalDescription(await pc.createOffer());
const sdp = JSON.stringify(pc.localDescription);
socket.send(sdp);
socket.on("message", (data: any) => {
pc.setRemoteDescription(JSON.parse(data));
});
});
Published by shinyoshiaki about 3 years ago
Published by shinyoshiaki about 3 years ago
Published by shinyoshiaki over 3 years ago
Published by shinyoshiaki over 3 years ago
Published by shinyoshiaki over 3 years ago