I'm Nodejs beginner, i'm using here rtsp-relay library for live streaming, currently it is working in frontend when URL is inlcuded, when creating a proxy object at server ' url: rtsp://.....@..../Stream/Channel/10,', but i dont want to include it there, i want to include it in frontend (user could write it in TextField)
should i use fetch and send, any advice/help on this ?
English is not my mother language, so could be mistakes.
const express = require('express');
const app = express();
const { proxy, scriptUrl } = require('rtsp-relay')(app);
const handle = proxy({
url: `rtsp://.....@..../Stream/Channel/10`,
// the URL above is credentials
verbose: false,
transport: 'tcp',
});
app.ws('/api/stream', handle );
app.get('/', (req, res) =>
res.send(
`hg`,
),
);
app.listen(5000);
React (material-ui):
const updateUrl = () => {
return (
<React.Fragment>
<Box>
<form
onSubmit={handleUpdate}>
<div>
<Box>
<Button
onClick={nulll}
aria-label="close-settings-popup">
<Close />
</Button>
</Box>
</div>
<FormGroup>
<Box>
<FormControl>
<TextField
type="text"
id="URL"
value={source}
onChange={handleChange}
label={
<Trans i18nKey="form.cameraForm.source">URL</Trans>
}
></TextField>
</FormControl>
</Box>
</FormGroup>
<div>
<Button type="submit" variant="contained" color="primary">
Accept
</Button>
</div>
</form>
</Box>
</React.Fragment>
);
};
this is what rtsp creator wrote:
As far as I can understand with what you have asked, you need to create a websocket connection from the client-side.
const ws = new WebSocket('ws://localhost:3000/ws') //Your url should be here
This is a basic webscoket connection using JavaScript native WebSocket API, you can use either other libraries like socket.io.