chriswiggins / rtsp-streaming-server

Lightweight RTSP/RTP streaming media server written in Javascript
GNU General Public License v3.0
107 stars 21 forks source link

Documentation clarification for newbs #24

Open jimbo1969 opened 3 years ago

jimbo1969 commented 3 years ago

Thanks for sharing, Chris! Here is one detail that may throw off some newbies like me:

In addition to your note about javascript (vs. typescript) needing const RtspServer = require('rtsp-streaming-server').default;, one more change is required in your script to use plain old javascript -- removal of the void type specification for the run() function. In fact, it might not be totally clear that the 'require' business above in intended to replace the import statement.

For a standalone deployment, I create a file called 'app.js', containing the following:

//import RtspServer from 'rtsp-streaming-server'
const RtspServer = require('rtsp-streaming-server').default;  //replaced above typescript import

const server = new RtspServer({
    serverPort: 5554,
    clientPort: 6554,
    rtpPortStart: 10000,
    rtpPortCount: 10000
});

async function run () {   //removed ': void' type specification intended for typescript
    try {
        await server.start();
    } catch (e) {
        console.error(e);
    }
}

run();

Then I run it with node app.js.

I'm a Node.js newbie, and the above surely "goes without saying" for more node-or-javascript -seasoned folks, but it was not obvious at first glance for me.

Thanks!