fstream/README.md

60 lines
3.0 KiB
Markdown
Raw Normal View History

2021-04-14 02:32:50 +00:00
# fstream
2022-05-29 13:37:15 +00:00
A TCP multi-broadcast media streaming server/client. [Check out the past source](/Fierelier/fstream/src/commit/1890b316f543f579e9a63f3a2ddb689eeef9c855), for simpler implementation. **Compatible with Python 3.4 and up!**
2021-04-14 02:32:50 +00:00
# Client
2022-05-29 13:24:01 +00:00
## Broadcast
`fstream.py <ip:port> broadcast,[key=value],[key=value],...`
Accepts data from stdin, and sends it to the specified server.
### Arguments
- **`user`**: Your user's name.
2023-10-31 23:45:19 +00:00
- **`user-password`**: Your user's password.
- **`channel`**: The channel you wanna stream to. Can be any name. Defaults to default.
- **`channel-password`**: The channel's password. Can be any password. Defaults to no password.
2023-10-31 23:45:56 +00:00
- **`bufsize`**: The size of chunks. Defaults to 0 (no set size, lowest delay).
2022-05-29 13:24:01 +00:00
2023-10-31 23:45:19 +00:00
All arguments are optional but for `user` and `user-password`.
2022-05-29 13:24:01 +00:00
### Example
2022-05-30 05:00:43 +00:00
`ffmpeg -f gdigrab -framerate 30 -i desktop -vf scale=-2:480 -c:v libx264 -pix_fmt yuv420p -maxrate 1M -f h264 - | fstream.py 127.0.0.1:61920 broadcast,user=fier,user-password=123,channel=exampleChannel,channel-password=456`
2022-05-29 13:24:01 +00:00
2022-05-30 05:00:43 +00:00
Broadcast Windows desktop as `fier` to `127.0.0.1:61920`, supplying `123` as the user password. `exampleChannel` is the channel, `456` is the channel's password. Pipe the output from ffmpeg.
2022-05-29 13:24:01 +00:00
## Watch
`fstream.py <ip:port> broadcast,[key=value],[key=value],...`
Accepts data from the server, and sends it to stdout.
### Arguments
- **`user`**: The user you wanna watch.
- **`channel`**: The user's channel you wanna watch.
- **`channel-password`**: The channel's password.
2022-05-29 13:25:21 +00:00
All arguments are optional but for `user`.
2022-05-29 13:24:01 +00:00
### Example
`fstream.py 127.0.0.1:61920 watch,user=fier,channel=exampleChannel,channel-password=123 | ffplay -i -`
Watch `fier`'s `exampleChannel` channel at `127.0.0.1:61920`, supplying `123` as the password, and pipe it into ffplay for playback.
2021-04-14 02:32:50 +00:00
2022-05-29 13:01:01 +00:00
# Server
## Settings
Edit `modules/settings.py` for generic server/socket-related settings, and `modules/fstream/settings.py` for fstream related settings.
## Creating a user
Make a folder called `users` and make a file in it called `YourUsername.ini`, put this in it:
```ini
[DEFAULT]
password=foobar
```
If you would like to implement your own authentication, make your own module to replace the `authenticate()` function - see `modules/fstream/authent.py` and `modules/fstream/main.mods`.
# The Protocol
2021-04-14 02:32:50 +00:00
## Establishing a connection
Establish a TCP connection with the server, and send the payload. If the server likes your payload, it will stream data to you, or accept more of your data.
## The payload
2022-05-30 05:00:43 +00:00
Send the length of the payload as a 4-byte (32-bit) big endian unsigned integer, a null byte (hex:`00`) and a UTF-8 encoded string identifying the client's intentions follows, for example: `watch,user=fier,channel=exampleChannel,channel-password=123` or `broadcast,user=fier,user-password=123,channel=exampleChannel,channel-password=456`. The length includes only the string message, in bytes, it does not include the length itself, nor the null byte.
2022-05-29 13:24:01 +00:00
2023-10-31 23:45:19 +00:00
If you are a watcher, you will now be blasted with data. If you are a broadcaster, you can now blast data.