You've already forked FFmpeg
							
							
				mirror of
				https://github.com/FFmpeg/FFmpeg.git
				synced 2025-10-30 23:18:11 +02:00 
			
		
		
		
	avcodec/videotoolboxenc: fix invalid session on iOS
Cf. comment. Restart the VT session when the APP goes from foreground to background and vice versa. Signed-off-by: Aman Gupta <aman@tmm1.net>
This commit is contained in:
		
				
					committed by
					
						 Aman Gupta
						Aman Gupta
					
				
			
			
				
	
			
			
			
						parent
						
							9e11d27c25
						
					
				
				
					commit
					513e6a30fb
				
			| @@ -2175,8 +2175,27 @@ static int create_cv_pixel_buffer(AVCodecContext   *avctx, | ||||
| #if TARGET_OS_IPHONE | ||||
|     pix_buf_pool = VTCompressionSessionGetPixelBufferPool(vtctx->session); | ||||
|     if (!pix_buf_pool) { | ||||
|         av_log(avctx, AV_LOG_ERROR, "Could not get pixel buffer pool.\n"); | ||||
|         return AVERROR_EXTERNAL; | ||||
|         /* On iOS, the VT session is invalidated when the APP switches from | ||||
|          * foreground to background and vice versa. Fetch the actual error code | ||||
|          * of the VT session to detect that case and restart the VT session | ||||
|          * accordingly. */ | ||||
|         OSStatus vtstatus; | ||||
|  | ||||
|         vtstatus = VTCompressionSessionPrepareToEncodeFrames(vtctx->session); | ||||
|         if (vtstatus == kVTInvalidSessionErr) { | ||||
|             CFRelease(vtctx->session); | ||||
|             vtctx->session = NULL; | ||||
|             status = vtenc_configure_encoder(avctx); | ||||
|             if (status == 0) | ||||
|                 pix_buf_pool = VTCompressionSessionGetPixelBufferPool(vtctx->session); | ||||
|         } | ||||
|         if (!pix_buf_pool) { | ||||
|             av_log(avctx, AV_LOG_ERROR, "Could not get pixel buffer pool.\n"); | ||||
|             return AVERROR_EXTERNAL; | ||||
|         } | ||||
|         else | ||||
|             av_log(avctx, AV_LOG_WARNING, "VT session restarted because of a " | ||||
|                    "kVTInvalidSessionErr error.\n"); | ||||
|     } | ||||
|  | ||||
|     status = CVPixelBufferPoolCreatePixelBuffer(NULL, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user