2023年12月18日发(作者:)

return self.__() def __str__(self): return str(self.__banner)class Minicap(object): def __init__(self, host, port, banner): _size = 4096 = host = port = banner def connect(self): try: self.__socket = (_INET, _STREAM) except : print('2') (1) self.__t((, )) def on_image_transfered(self, data): file_name = str(()) + '.jpg' with open(file_name, 'wb') as f: for b in data: (b) def consume(self): readBannerBytes = 0 bannerLength = 24 readFrameBytes = 0 frameBodyLength = 0 data = [] while True: try: chunk = self.__(_size) except: print('11') (1) cursor = 0 buf_len = len(chunk) while cursor < buf_len: if readBannerBytes < bannerLength: map(lambda i, val: .__setitem__(()[i], val), [i for i in range(len(()))], ("<2b5ibB", chunk)) cursor = buf_len readBannerBytes = bannerLength print() elif readFrameBytes < 4: frameBodyLength += (('B', chunk[cursor])[0] << (readFrameBytes * 8)) >> 0 cursor += 1 readFrameBytes += 1 else: print("frame length:{0} buf_len:{1} cursor:{2}".format(frameBodyLength, buf_len, cursor)) # pic end if buf_len - cursor >= frameBodyLength: (chunk[cursor:cursor + frameBodyLength]) _image_transfered(data) cursor += frameBodyLength frameBodyLength = readFrameBytes = 0 data = [] else: (chunk[cursor:buf_len]) frameBodyLength -= buf_len - cursor readFrameBytes += buf_len - cursor cursor = buf_len