Remove delay
This commit is contained in:
parent
77e862f280
commit
a69d881f95
|
@ -12,14 +12,13 @@ Accepts data from stdin, and sends it to the specified server.
|
|||
- **`user-password`**: Your user's password.
|
||||
- **`channel`**: The channel you wanna stream to. Can be any name.
|
||||
- **`channel-password`**: The channel's password.
|
||||
- **`loop-delay`**: How long should the server wait between each acquisition of data, in seconds? Higher values will cause more delay, but will also store more data in the backlog (good for laggy watchers). Lower values for lower delay.
|
||||
|
||||
All arguments are optional but for `user`.
|
||||
|
||||
### 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,delay=0.1,channel=exampleChannel,channel-password=456`
|
||||
`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`
|
||||
|
||||
Broadcast Windows desktop as `fier` to `127.0.0.1:61920`, supplying `123` as the user password with a server loop-delay of `0.1` seconds. `exampleChannel` is the channel, `456` is the channel's password. Pipe the output from ffmpeg.
|
||||
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.
|
||||
|
||||
## Watch
|
||||
`fstream.py <ip:port> broadcast,[key=value],[key=value],...`
|
||||
|
@ -54,6 +53,6 @@ If you would like to implement your own authentication, make your own module to
|
|||
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
|
||||
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,delay=0.1,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.
|
||||
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.
|
|
@ -1,7 +1,5 @@
|
|||
global select
|
||||
import select
|
||||
global time
|
||||
import time
|
||||
|
||||
global clientLoopIn
|
||||
def clientLoopIn(self):
|
||||
|
@ -16,11 +14,6 @@ def clientLoopIn(self):
|
|||
|
||||
if not "channel" in args: args["channel"] = "default"
|
||||
if not "channel-password" in args: args["channel-password"] = ""
|
||||
if not "delay" in args: args["delay"] = 0.1
|
||||
if not "user-password" in args: args["user-password"] = ""
|
||||
args["delay"] = float(args["delay"])
|
||||
if args["delay"] < minDelay: args["delay"] = minDelay
|
||||
if args["delay"] > maxDelay: args["delay"] = maxDelay
|
||||
|
||||
if not authenticate(args["user"],args["user-password"]): return
|
||||
|
||||
|
@ -41,9 +34,7 @@ def clientLoopIn(self):
|
|||
packet = -1
|
||||
packetMin = 0
|
||||
bufferSize = 0
|
||||
lastReceived = time.process_time()
|
||||
while True:
|
||||
args["delay"] = 0
|
||||
data = self.connection.recv(connBuffer)
|
||||
if data == b"": return
|
||||
with clientDataLock:
|
||||
|
@ -61,12 +52,6 @@ def clientLoopIn(self):
|
|||
for cID in clients:
|
||||
if getClientData(cID,"type") == "watch" and getClientData(cID,"args")["user"] == args["user"] and getClientData(cID,"args")["channel"] == args["channel"] and getClientData(cID,"args")["channel-password"] == args["channel-password"]:
|
||||
getClientData(cID,"queue").put("")
|
||||
|
||||
now = time.process_time()
|
||||
timeSpent = now - lastReceived
|
||||
wait = args["delay"] - timeSpent
|
||||
if wait > 0: time.sleep(wait)
|
||||
lastReceived = now
|
||||
|
||||
if cmd[0] == "watch":
|
||||
packet = -1
|
||||
|
|
|
@ -5,6 +5,3 @@ bufferCost = 1024 # Virtually add extra cost to each buffer piece to prevent cli
|
|||
global maxBuffer
|
||||
maxBuffer = 20*1024*1024 # The maximum buffer size of a stream in bytes. Old buffers are discarded, clients that depend on them get disconnected.
|
||||
global minDelay
|
||||
minDelay = 0.05 # The minimum delay (pause between each buffer iteration) the user can set in seconds. Lower values cause higher CPU usage.
|
||||
global maxDelay
|
||||
maxDelay = 1 # The maximum delay the user can set.
|
Loading…
Reference in New Issue