Improved corrupt frame handling
	
		
			
	
		
	
	
		
	
		
			Some checks reported errors
		
		
	
	
		
			
				
	
				continuous-integration/drone Build was killed
				
			
		
		
	
	
				
					
				
			
		
			Some checks reported errors
		
		
	
	continuous-integration/drone Build was killed
				
			This commit is contained in:
		
							
								
								
									
										30
									
								
								camdetect.py
									
									
									
									
									
								
							
							
						
						
									
										30
									
								
								camdetect.py
									
									
									
									
									
								
							| @@ -376,26 +376,28 @@ async def download(resp, queue): | |||||||
|                 blob = buf + data[:marker+2] |                 blob = buf + data[:marker+2] | ||||||
|  |  | ||||||
|                 # Parse DCT coefficients |                 # Parse DCT coefficients | ||||||
|                 dct = loads(blob) |  | ||||||
|  |  | ||||||
|                 now = datetime.utcnow() |  | ||||||
|                 gauge_last_frame.labels("download").set(now.timestamp()) |  | ||||||
|                 try: |                 try: | ||||||
|                     # Convert Y component to 16 bit for easier handling |                     dct = loads(blob) | ||||||
|                     queue.put_nowait(( |                 except RuntimeError: | ||||||
|                         now, |                     counter_frames.labels("corrupted").inc() | ||||||
|                         blob, |                 else: | ||||||
|                         dct, |                     now = datetime.utcnow() | ||||||
|                         generate_thumbnail(dct))) |                     gauge_last_frame.labels("download").set(now.timestamp()) | ||||||
|                 except asyncio.QueueFull: |                     try: | ||||||
|                     counter_dropped_frames.labels("download").inc() |                         queue.put_nowait(( | ||||||
|                 gauge_queue_frames.labels("download").set(queue.qsize()) |                             now, | ||||||
|  |                             blob, | ||||||
|  |                             dct, | ||||||
|  |                             generate_thumbnail(dct))) | ||||||
|  |                     except asyncio.QueueFull: | ||||||
|  |                         counter_dropped_frames.labels("download").inc() | ||||||
|  |                     gauge_queue_frames.labels("download").set(queue.qsize()) | ||||||
|                 data = data[marker+2:] |                 data = data[marker+2:] | ||||||
|                 buf = b"" |                 buf = b"" | ||||||
|                 counter_receive_frames.inc() |                 counter_receive_frames.inc() | ||||||
|  |  | ||||||
|         # seek begin |         # seek begin | ||||||
|         marker = data.find(b"\xff\xd8") |         marker = data.rfind(b"\xff\xd8") | ||||||
|         if marker >= 0: |         if marker >= 0: | ||||||
|             buf = data[marker:] |             buf = data[marker:] | ||||||
|         else: |         else: | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user