def func(): vclient = Video_Client(IP, PORT, SHOWME, LEVEL, VERSION) vserver = Video_Server(PORT, VERSION) aclient = Audio_Client(IP, PORT + 1, VERSION) aserver = Audio_Server(PORT + 1, VERSION) vclient.start() vserver.start() aclient.start() aserver.start() while True: time.sleep(1) if not vserver.isAlive() or not vclient.isAlive(): print("Video connection lost...") #sys.exit(0) if not aserver.isAlive() or not aclient.isAlive(): print("Audio connection lost...")
class openav(): """选择目标机器开启av""" def __init__(self, ip): PORT = 11111 self.vclient = Video_Client(ip, PORT, 1, 4) self.vserver = Video_Server(PORT - 1, 4) self.aclient = Audio_Client(ip, PORT + 1, 4) self.aserver = Audio_Server(PORT + 2, 4) def start(self): self.vclient.start() self.aclient.start() time.sleep(1) self.vserver.start() self.aserver.start() while True: time.sleep(1) if not self.vserver.isAlive() or not self.vclient.isAlive(): print("Video connection lost...") sys.exit(0) if not self.aserver.isAlive() or not self.aclient.isAlive(): print("Audio connection lost...") sys.exit(0)
parser.add_argument('--sversion', type=int, default=4) # parser.add_argument('--rhost', type=str, default='127.0.0.1') # parser.add_argument('--rport', type=int, default=10087) # parser.add_argument('--rversion', type=int, default=4) parser.add_argument('--noself', type=bool, default=False) parser.add_argument('--level', type=int, default=1) args = parser.parse_args() sIP = args.shost sPORT = args.sport sVERSION = args.sversion # rIP = args.rhost # rPORT = args.rport # rVERSION = args.rversion SHOWME = args.noself LEVEL = args.level if __name__ == '__main__': vclient = Video_Client(sIP, sPORT, sVERSION, SHOWME, LEVEL) vserver = Video_Server(sIP, sPORT + 1, sVERSION) vclient.start() vserver.start() while True: time.sleep(1) if not vserver.isAlive() or not vclient.isAlive(): print("Video connection lost...") sys.exit(0) # if not aserver.isAlive() or not aclient.isAlive(): # print("Audio connection lost...") # sys.exit(0)
PORT = args.port VERSION = args.version SHOWME = not args.noself LEVEL = args.level if __name__ == '__main__': # vclient = Video_Client(IP, PORT, SHOWME, LEVEL, VERSION) vserver = Video_Server(PORT, VERSION) # aclient = Audio_Client(IP, PORT+1, VERSION) aserver = Audio_Server(PORT + 1, VERSION) # vclient.start() vserver.start() # aclient.start() aserver.start() while True: time.sleep(1) if not vserver.isAlive(): print("Video connection lost...") sys.exit(0) if not aserver.isAlive(): print("Audio connection lost...") sys.exit(0) # while True: # time.sleep(1) # if not vserver.isAlive() or not vclient.isAlive(): # print("Video connection lost...") # sys.exit(0) # if not aserver.isAlive() or not aclient.isAlive(): # print("Audio connection lost...") # sys.exit(0)