{"library":"medooze-media-server","title":"Medooze WebRTC Media Server for Node.js","description":"The Medooze Media Server for Node.js (`medooze-media-server`) is a comprehensive WebRTC media server designed to receive, send, and route media streams between remote WebRTC peers. It functions as a Selective Forwarding Unit (SFU) and provides extensive support for key WebRTC features including MP4 multitrack recording (supporting H264, VP8, VP9, OPUS, PCMU/A codecs), VP9 SVC, Simulcast with temporal layer selection, RTP transport wide congestion control, sender-side bitrate estimation, NACK and RTX, Bundle, ICE lite, and Frame Marking. The current stable version is 1.156.2, indicating a project with continuous development and frequent updates. A core differentiator is its focus on robust, low-latency WebRTC SFU capabilities, detailed integration with Perfetto for tracing, and broad platform support including Linux, macOS, and Raspberry Pi, making it adaptable for various deployment environments from cloud infrastructure to edge devices. It relies on a critical peer dependency, `medooze-media-server-src`, for its underlying native components.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install medooze-media-server"],"cli":null},"imports":["import MediaServer from 'medooze-media-server';","const MediaServer = require('medooze-media-server');","import type { IceCandidate } from 'medooze-media-server';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import MediaServer from 'medooze-media-server';\n\n// Enable verbose logging for easier debugging and monitoring\nMediaServer.enableLog(true);\nMediaServer.logLevel = MediaServer.INFO; // Can be set to MediaServer.DEBUG for more detailed logs\n\nconsole.log('Starting Medooze Media Server...');\n\n// Create a new media server instance. This is the entry point for all media operations.\nconst mediaServer = new MediaServer();\n\n// Create an endpoint, which represents a connection to a WebRTC peer (e.g., a browser client).\n// The IP should typically be your server's public IP address, but '127.0.0.1' works for local testing.\n// The port will be dynamically assigned if not specified, but a fixed range is often useful for firewall configuration.\nconst endpoint = mediaServer.createEndpoint({\n  ip: '127.0.0.1',\n  port: 50000 + Math.floor(Math.random() * 1000) // Assigns a random port within a common ephemeral range\n});\n\nconsole.log(`Endpoint created with local ICE IP: ${endpoint.getLocalICE().ip}, Port: ${endpoint.getLocalICE().port}`);\n\n// Event listener for local ICE candidates generated by the endpoint.\n// These candidates must be sent to the remote WebRTC peer via your signaling channel.\nendpoint.onicecandidate = (candidate) => {\n  console.log('Generated local ICE candidate:', candidate);\n  // In a real application, you would send this 'candidate' object\n  // to the remote browser client using your chosen signaling mechanism (e.g., WebSockets, MQTT, HTTP).\n  // Example: ws.send(JSON.stringify({ type: 'iceCandidate', candidate }));\n};\n\n// In a full application, you would also receive remote ICE candidates via signaling\n// and add them to the endpoint using: endpoint.addRemoteCandidate(remoteCandidate);\n\n// Create a WebRTC transport for the endpoint. This handles the SDP offer/answer negotiation and media flow.\nconst transport = endpoint.createTransport({\n  dtls: true, // DTLS is essential for WebRTC security\n  srtp: true, // SRTP encrypts media\n  rtcpmux: true // RTCP-muxing combines RTP and RTCP on a single port\n});\n\n// Generate a local SDP offer that needs to be sent to the remote peer.\nconst offer = transport.createOffer();\nconsole.log('Generated local SDP Offer:\\n', offer.sdp);\n// Send 'offer.sdp' to the remote peer (browser) via your signaling channel.\n\n// Example of how you would set the remote peer's SDP answer (received via signaling):\n/*\nconst remoteSdpAnswer = {\n  type: 'answer',\n  sdp: 'v=0\\r\\no=...\\r\\n...' // The SDP answer string received from the remote WebRTC peer\n};\ntransport.setRemoteProperties(remoteSdpAnswer);\n*/\n\n// Keep the Node.js process alive indefinitely for the media server to operate continuously\nsetInterval(() => {}, 1000 * 60 * 60);","lang":"typescript","description":"This quickstart demonstrates how to initialize the Medooze Media Server, create an endpoint for a WebRTC peer, configure basic logging, handle local ICE candidate generation, and generate an SDP offer to initiate a WebRTC connection. It outlines the foundational steps required before full media routing.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}