import sys import os import subprocess def mainMenu(): print("(S)tream") print("(W)atch") print("(Q)uit") print() x = input ("s/w/q: ").strip().lower() if x in ("s","w","q"): return x else: return 1 def quitLKStream(mainData): #Terminate will raise a ProcessLookupError exception #Close holesail ##holesail.terminate() ##holesail.wait() #Close mediamtx mainData["playerProc"].terminate() mainData["playerProc"].wait() sys.exit() def startLKStream(): #start mediamtx server #start holesail with randomized key #start ffmpeg streaming to mediamtx #For the moment, we won't be doing that but using OBS print("TODO: Start Streaming") return "Fake Key" #return holesail key def watchLKStream(mainData): #Ask for holesail key #Connect to holesail (subprocess?) #Connect to stream with MEDIAPLAYER(subprocess?) mainData["playerProc"] = subprocess.Popen(mainData["player"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) # Use a default stream location if streaming with FFMPEG, with OBS it's the default plus stream key print("TODO Watch Stream") return mainData def connectToHolesail(key): proc = subprocess.Popen(['holesail', key]) return proc def mainMenuHandling(x, mainData): if x == 'q': quitLKStream(mainData) elif x == 's': return startLKStream() elif x == 'w': return watchLKStream(mainData) else: print("invalid option x was: ", x) return 1