Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Guillem <thomas@gllm.fr>2018-06-14 18:48:07 +0300
committerAman Gupta <aman@tmm1.net>2018-06-18 21:49:38 +0300
commit33fcbb4372e8fd148970453e1a839dfaac625e80 (patch)
tree167037290bfdeac4999de55a9f430fdc7b4c84d4
parenta56eb4d56c5bc319eb0bc4536b498d7d8a80c183 (diff)
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> (cherry picked from commit 513e6a30fb013ca34812ccaaf3d090680ac868c5)
-rw-r--r--libavcodec/videotoolboxenc.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index 1060055ba5..ac847358ab 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -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,