Node Media Server Rename Session Folders

14 Views Asked by At

I would like to know if there is a way to change the names of session folders in node media server by default they are called as broadcast keys, but I need these folders to have a user name that corresponds to the stream key.

there is nothing unusual about my server setup. The only code that finds a user by stream key:

const User = require('./models/User');
const NodeMediaServer = require('node-media-server');
const { config } = require('./mediaServer/config');

const nms = new NodeMediaServer(config);

nms.on('prePublish', async (id, StreamPath, args) => {
    let stream_key = getStreamKeyFromStreamPath(StreamPath);
    try {
      const user = await User.findOne({ streamKey: stream_key });
      if (!user) {
        let session = nms.getSession(id);
        session.reject();
      }
    } catch (err) {
      console.error("Error finding user:", err);
    }
});

const getStreamKeyFromStreamPath = (path) => {
    let parts = path.split('/');
    return parts[parts.length - 1];
};

module.exports = nms;

so probably the task is still to get the key, find the corresponding user using it, rename the folder and enjoy life :)

I would also like to clarify that I am doing this in order to make the keys invisible because now I am directly making a request to the endpoint containing the broadcast key and everyone who is not too lazy can see it, perhaps there is some other way to implement this rather than renaming folders???

Hello, I would like to know if there is a way to change the names of session folders in node media server by default they are called as broadcast keys, but I need these folders to have a user name that corresponds to the stream key.

0

There are 0 best solutions below