medooze-rtmp-server
TypeScript icon, indicating that this package has built-in type declarations

0.22.0 • Public • Published

rtmp-server-node-test

rtmp-server-node

RTMP server for node

Install

Just add the Medooze media server as a dependency to your node proyect:

    npm i --save rtmp-media-server

Example

const brige	= RTMPServer.createIncomingStreamBridge();
const demo	= RTMPServer.createApplication();
const rtmp	= RTMPServer.createServer();

rtmp.addApplication("demo",demo);
rtmp.start(1935);

demo.on("connect",(client)=>{
	console.log("connected on "+client.getAppName());
	
	client.on("stream",(stream)=>{
		console.log("got stream ",stream.getId());
		
		stream.on("cmd",(cmd,...params)=>{
			console.log("got cmd "+cmd.name,params);
			
			if (cmd.name=="publish")
			{
				try { 
					//Start publishing
					stream.attachTo(brige);
					///Started
					stream.sendStatus(RTMPServer.NetStream.Publish.Start);
				} catch (e) {
					//Log it
					console.error(e);
					//Errror
					stream.sendStatus(RTMPServer.NetStream.Failed,e.toString());
				}
			}
		});
		
		stream.on("stopped",()=>{
			console.log("stream stopped");
		});
	});
	
	client.accept();
});

Author

Sergio Garcia Murillo @ Medooze

Contributing

To get started, Sign the Contributor License Agreement.

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i medooze-rtmp-server

Weekly Downloads

469

Version

0.22.0

License

MIT

Unpacked Size

3.42 MB

Total Files

609

Last publish

Collaborators

  • murillo128