From patchwork Tue Sep 3 01:02:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aman Karmani X-Patchwork-Id: 14862 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id C0BA3449F2B for ; Tue, 3 Sep 2019 04:03:20 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A1DE3687F9F; Tue, 3 Sep 2019 04:03:20 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ot1-f66.google.com (mail-ot1-f66.google.com [209.85.210.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D99FE687FC2 for ; Tue, 3 Sep 2019 04:03:18 +0300 (EEST) Received: by mail-ot1-f66.google.com with SMTP id g16so3193386otp.12 for ; Mon, 02 Sep 2019 18:03:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tmm1-net.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vFqCSJgbZH9TmuPHlVdMglEYvY7YR0BfwIkOw/zk8NY=; b=t8EwHzgiKdwr+9Funlqp8jgNUOyTBxsqE02ovFDXw3rvi0r0ihdJohhzl4p1fXdnWC kzfgyC9wk0K+zUJiqUJmp68hVkS73OMv2EFBfuGv2FIoS9yU0aDz+jgnnddbRl94IQzZ BrpK2kcIDuiA9ZlhZpqigF8mCnQJs/EQM8YIjqqOL9kizKYolkaqUnZCnKsajIGZm7On Y6e4FvQnnQPEiUKpA7/2eH9jfqica0M7vF05dm4GwZDwmxdDrRl2S7AYODhRs36+Zilv 8FWwUDa+88Bf9a+edKxbfYzhWpOn9c7GLnoR39HGYtaGswCRcleQNBtJInLqz01KgVq3 J0oQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=vFqCSJgbZH9TmuPHlVdMglEYvY7YR0BfwIkOw/zk8NY=; b=uRhs1G0FjFpc+7AeFpVgu7eDcXOBlqO+ZWyFI5X/lQ2Hfp8IaxAXYfA2xVUmBE1cQF MGWHppxXGjWgVbi4ZscybsXfyKEf75BDVcSKBQObja5yoqjraU34Yt3HHqwTluMpenEy MhRjEw3OtF3byI0xWC3eTr61t1JBsSk8rS/vOY3nk2yqiLVGWHQ8FFEkmx56PUfbNPo5 bacc2YKHGfQ9kp3X54U3tOIkdy0KR62StU3WY0kX5HUex9E8UCq++YNMf/ZzlrFjoORg QEO9RiFjNT96sajjB2OilSNKevKRX5chVT0it4+01lN6s8L8EJyNZUOL14TM+YN0/gmu VX9Q== X-Gm-Message-State: APjAAAVX3vRy2YOGQ5WvUxtvhhnLUG2tjPo5R09JFT/FaaheFMo0p02P ZXHaJfKmJwFaGtE1ZbFBqCUFID58UBo= X-Google-Smtp-Source: APXvYqyAjGTdwVNxaCROIbfJZo5oepBtwyNArZ3De+MGtvCXNBSo2GXPEEvBe38IcuiELsBZMDutHA== X-Received: by 2002:a05:6830:51:: with SMTP id d17mr1103237otp.358.1567472597274; Mon, 02 Sep 2019 18:03:17 -0700 (PDT) Received: from tmm1-imac.lan (ip184-189-221-177.sb.sd.cox.net. [184.189.221.177]) by smtp.gmail.com with ESMTPSA id a21sm4299633oie.9.2019.09.02.18.03.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 02 Sep 2019 18:03:16 -0700 (PDT) From: Aman Gupta To: ffmpeg-devel@ffmpeg.org Date: Mon, 2 Sep 2019 18:02:23 -0700 Message-Id: <20190903010230.96236-19-ffmpeg@tmm1.net> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190903010230.96236-1-ffmpeg@tmm1.net> References: <20190903010230.96236-1-ffmpeg@tmm1.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 18/25] avcodec/v4l2_context: expose timeout for dequeue_frame X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: lorusak@gmail.com, Aman Gupta , jorge.ramirez.ortiz@gmail.com, Aman Gupta Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Aman Gupta Signed-off-by: Aman Gupta --- libavcodec/v4l2_context.c | 6 +++--- libavcodec/v4l2_context.h | 3 ++- libavcodec/v4l2_m2m_dec.c | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/libavcodec/v4l2_context.c b/libavcodec/v4l2_context.c index 32246cf564..26e06273be 100644 --- a/libavcodec/v4l2_context.c +++ b/libavcodec/v4l2_context.c @@ -616,16 +616,16 @@ int ff_v4l2_context_enqueue_packet(V4L2Context* ctx, const AVPacket* pkt) return ff_v4l2_buffer_enqueue(avbuf); } -int ff_v4l2_context_dequeue_frame(V4L2Context* ctx, AVFrame* frame) +int ff_v4l2_context_dequeue_frame(V4L2Context* ctx, AVFrame* frame, int timeout) { V4L2Buffer* avbuf = NULL; /* - * blocks until: + * timeout=-1 blocks until: * 1. decoded frame available * 2. an input buffer is ready to be dequeued */ - avbuf = v4l2_dequeue_v4l2buf(ctx, -1); + avbuf = v4l2_dequeue_v4l2buf(ctx, timeout); if (!avbuf) { if (ctx->done) return AVERROR_EOF; diff --git a/libavcodec/v4l2_context.h b/libavcodec/v4l2_context.h index f9d02b748f..64c53d07b5 100644 --- a/libavcodec/v4l2_context.h +++ b/libavcodec/v4l2_context.h @@ -160,9 +160,10 @@ int ff_v4l2_context_dequeue_packet(V4L2Context* ctx, AVPacket* pkt); * The frame must be non NULL. * @param[in] ctx The V4L2Context to dequeue from. * @param[inout] f The AVFrame to dequeue to. + * @param[in] timeout The timeout for dequeue (-1 to block, 0 to return immediately or milliseconds) * @return 0 in case of success, AVERROR(EAGAIN) if no buffer was ready, another negative error in case of error. */ -int ff_v4l2_context_dequeue_frame(V4L2Context* ctx, AVFrame* f); +int ff_v4l2_context_dequeue_frame(V4L2Context* ctx, AVFrame* f, int timeout); /** * Enqueues a buffer to a V4L2Context from an AVPacket diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c index 6b73d2ffd9..b37b6ac7d9 100644 --- a/libavcodec/v4l2_m2m_dec.c +++ b/libavcodec/v4l2_m2m_dec.c @@ -172,7 +172,7 @@ static int v4l2_receive_frame(AVCodecContext *avctx, AVFrame *frame) dequeue: av_packet_unref(&avpkt); - return ff_v4l2_context_dequeue_frame(capture, frame); + return ff_v4l2_context_dequeue_frame(capture, frame, -1); } static av_cold int v4l2_decode_init(AVCodecContext *avctx)