Compare commits

...

2 Commits

Author SHA1 Message Date
Fierelier 65c68cb6d0 Add definable buffer size of data 2023-11-01 00:45:56 +01:00
Fierelier af3f6c8124 Update README.md 2023-11-01 00:45:19 +01:00
2 changed files with 18 additions and 7 deletions

View File

@ -9,11 +9,12 @@ Accepts data from stdin, and sends it to the specified server.
### Arguments
- **`user`**: Your user's name.
- **`user-password`**: Your user's password.
- **`channel`**: The channel you wanna stream to. Can be any name.
- **`channel-password`**: The channel's password.
- **`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.
- **`bufsize`**: The size of chunks. Defaults to 0 (no set size, lowest delay).
All arguments are optional but for `user`.
All arguments are optional but for `user` and `user-password`.
### Example
`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`
@ -55,4 +56,4 @@ Establish a TCP connection with the server, and send the payload. If the server
## The payload
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.
If you are a watcher, you will now be blasted with data. If you are a broadcaster, you can now blast data.
If you are a watcher, you will now be blasted with data. If you are a broadcaster, you can now blast data.

View File

@ -29,12 +29,22 @@ def clientLoopIn(self):
if cmd[0] == "broadcast":
if not authenticate(args["user"],args["user-password"]): return
if not "bufsize" in args:
bufsize = 0
else:
bufsize = int(args["bufsize"])
if bufsize < 0: bufsize = 0
if bufsize > maxBuffer: bufsize = maxBuffer
buffer = getClientData(self.cID,"buffer")
packet = -1
packetMin = 0
bufferSize = 0
while True:
data = self.connection.recv(connBuffer)
if bufsize == 0:
data = self.connection.recv(connBuffer)
else:
data = recv(self.connection,bufsize)
if data == b"": return
with clientDataLock:
dataSize = len(data)
@ -76,4 +86,4 @@ def clientLoopIn(self):
packet += 1
with clientDataLock:
data = getClientData(watchID,"buffer")[str(packet)]
self.connection.sendall(data)
self.connection.sendall(data)