From patchwork Mon Mar 19 19:35:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Dekker X-Patchwork-Id: 8041 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.1.70 with SMTP id c67csp3020862jad; Mon, 19 Mar 2018 12:36:37 -0700 (PDT) X-Google-Smtp-Source: AG47ELshtiP2ojND9SmZspzRuuZxD0h+QZHpNRdfIJmzeM1r9uHBSRexH5+jumQsMKe+H+mAtFWr X-Received: by 10.223.146.7 with SMTP id 7mr10383056wrj.250.1521488197070; Mon, 19 Mar 2018 12:36:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521488197; cv=none; d=google.com; s=arc-20160816; b=ZnS03pqB9FosOBjaCJfo4VczD1GKBK78ZD78uqSJdPbc6E7rwn7ZRoagYNoBVop2W2 LRPsDKGAgTL41AaQ4apABYq75hSj4/q5IQQ1KeuDgCex40J6gF6DR8IfO5Hxb7g5NUI3 Rr1FdfeUe0tzHfB988iXb670YyC7jD/EIY7fouespm99dwaMzhBD8JN6osrXVuQGLIXS MiZ8xl0NNrUolPSN7HL6DZbxn/Ho5rqcKreE9c+ioXPaQBKImHJ0RcurXmTPq9w+dSIB cjqLWd3C8iBsE9Gwlo6N9TpWhOQJy2cYqafThGPgLfd1PrFpwplvRulur8nmeKT9XwXn utNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:dkim-signature:delivered-to :arc-authentication-results; bh=HvABWq3n5YfFhUM8bHEj/RGXIz+YA+seiKp/N9dmjzs=; b=xuthNLseusEEQEdq0pRrSl9ac7P0Wzx6BT92+Bdv0DCXQzfD2avQQzAtgW01QLjJtm EEPpuDmfkH3X0BWi1eGuaIQk10XiUW+ViZAVe7yUsNUDqjDScYMxiEq5q3IO8wM/qEEt KmGD6FzsbaVfTt10pl9aRJu0LWphDh+auEuvTsghQHQcHBhXErtRqGlRNYJeA/1MLKRp GilMG6I11ibYxFnl9wMfjYQApKw4lAFC3q1yzKukxfyLs2HNLBjegpu95SBcVpgzMki2 AHMbsa0AvrBobuBjxX5YsyWsK6+ePE710zFnwBQ4Ik44lKjq4PBq4HYv8EU7AgaaI/Pl 5bOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@itanimul.li header.s=fm1 header.b=MP4XSQ9Z; dkim=neutral (body hash did not verify) header.i=@messagingengine.com header.s=fm2 header.b=CAJ+E2fH; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id i11si66641wmb.263.2018.03.19.12.36.36; Mon, 19 Mar 2018 12:36:37 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@itanimul.li header.s=fm1 header.b=MP4XSQ9Z; dkim=neutral (body hash did not verify) header.i=@messagingengine.com header.s=fm2 header.b=CAJ+E2fH; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DDA14689E29; Mon, 19 Mar 2018 21:35:46 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 99D11689908 for ; Mon, 19 Mar 2018 21:35:39 +0200 (EET) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id C1F252100E for ; Mon, 19 Mar 2018 15:35:52 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute4.internal (MEProxy); Mon, 19 Mar 2018 15:35:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=itanimul.li; h= date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=h3GXTXjos8Mk2YEhj WfAIjZinu8YkAYFeZo3aFIVafE=; b=MP4XSQ9ZmMKOoeGzzJ1J1mqh/XZ8RD5wA Awd+dCbWFse6YfMYJiMcb6UiFe0Oxf3nVbq8YX+reG1TJIYL3vacRsmi3f9mgynq ElxWs6aX9mrL1rwZScDBm6fvLsK4J1dJk9uum11U69zN3s+g05MvIZDVGU7Z0qTP IU8wOHUuyghcqeC49SYXQWxjvlfPZUDzts6YOnK2KN/l4bjJh0ZICn7YmMx7LsJf V4JWmzJVMWzthPRF+//HFWNS1qE2OuIX0wyfw/W71aHFcltgjADOXOeEIeNs7jVz CULb+o2TtlwA0cXWTutC0MWu6bFe3GzmyB6MNFnmD7RNw/8jOlBxA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=h3GXTXjos8Mk2YEhjWfAIjZinu8YkAYFeZo3aFIVafE=; b=CAJ+E2fH o3zCoYNqKMpHGQHZl9xiXD5ROdYc4plOO/0zSxZBhJeqjdLYUoHV3vCrYzf9VzOT boXjwoafqFHpyb83vCerRRSlLM5etD402VJibrmCc7094l5mgyr0eS/Mas9/kVQA I/QzXLBvelRv+kc4Q7cSpDbqBonimzjqFoz67d9o63EmkOZEGneqTiEa+2mKeZAh IULslOhp97jbGmmqGaUo0WNMftTz/3HHVX+Mr08o/nDGRvhPGm/UJOw8opxu6JPY DJr2T9QiW6aescRiM2kP99zeKBVKATpPImI2zoeRsWEhKSCtn6/fNdZIfNHNeP3A IfQ+AflGC2jiRw== X-ME-Sender: Received: from localhost.localdomain (cpc75394-sotn16-2-0-cust168.15-1.cable.virginm.net [82.22.8.169]) by mail.messagingengine.com (Postfix) with ESMTPA id 3CB8E7E1D3 for ; Mon, 19 Mar 2018 15:35:52 -0400 (EDT) From: Josh de Kock To: ffmpeg-devel@ffmpeg.org Date: Mon, 19 Mar 2018 19:35:38 +0000 Message-Id: <20180319193541.2977-5-josh@itanimul.li> X-Mailer: git-send-email 2.14.3 (Apple Git-98) In-Reply-To: <20180319193541.2977-1-josh@itanimul.li> References: <4d3ccc63-c2f9-37bb-a33a-88cd0538faa8@itanimul.li> <20180319193541.2977-1-josh@itanimul.li> Subject: [FFmpeg-devel] [PATCH v3 4/7] fftools/ff*.c: use iteration API to find formats 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" With the new API, if avdevice_register_all() isn't called av_find_input_format() wont find devices, so switch to the new API to make sure devices would always be checked if they are available even if devices are not registered through the old API. --- fftools/ffmpeg_opt.c | 25 +++++++++++++++++++++---- fftools/ffplay.c | 21 +++++++++++++++------ fftools/ffprobe.c | 21 +++++++++++++++------ 3 files changed, 51 insertions(+), 16 deletions(-) diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index d7a7eb0662..45c26c391e 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -27,6 +27,10 @@ #include "libavcodec/avcodec.h" +#if CONFIG_AVDEVICE +#include "libavdevice/avdevice.h" +#endif + #include "libavfilter/avfilter.h" #include "libavutil/avassert.h" @@ -963,7 +967,7 @@ static int open_input_file(OptionsContext *o, const char *filename) { InputFile *f; AVFormatContext *ic; - AVInputFormat *file_iformat = NULL; + const AVInputFormat *file_iformat = NULL; int err, i, ret; int64_t timestamp; AVDictionary *unused_opts = NULL; @@ -990,12 +994,25 @@ static int open_input_file(OptionsContext *o, const char *filename) } if (o->format) { - if (!(file_iformat = av_find_input_format(o->format))) { - av_log(NULL, AV_LOG_FATAL, "Unknown input format: '%s'\n", o->format); - exit_program(1); + void *opaque = NULL; + + while ((file_iformat = av_demuxer_iterate(&opaque))) { + if (av_match_name(o->format, file_iformat->name)) + goto format_found; } +#if CONFIG_AVDEVICE + opaque = NULL; + while ((file_iformat = av_indev_iterate(&opaque))) { + if (av_match_name(o->format, file_iformat->name)) + goto format_found; + } +#endif + av_log(NULL, AV_LOG_FATAL, "Unknown input format: '%s'\n", o->format); + exit_program(1); } +format_found: + if (!strcmp(filename, "-")) filename = "pipe:"; diff --git a/fftools/ffplay.c b/fftools/ffplay.c index f2028d4b13..64da518d0c 100644 --- a/fftools/ffplay.c +++ b/fftools/ffplay.c @@ -307,7 +307,7 @@ typedef struct VideoState { } VideoState; /* options specified by the user */ -static AVInputFormat *file_iformat; +static const AVInputFormat *file_iformat; static const char *input_filename; static const char *window_title; static int default_width = 640; @@ -3460,12 +3460,21 @@ static int opt_height(void *optctx, const char *opt, const char *arg) static int opt_format(void *optctx, const char *opt, const char *arg) { - file_iformat = av_find_input_format(arg); - if (!file_iformat) { - av_log(NULL, AV_LOG_FATAL, "Unknown input format: %s\n", arg); - return AVERROR(EINVAL); + void *opaque = NULL; + + while ((file_iformat = av_demuxer_iterate(&opaque))) { + if (av_match_name(arg, file_iformat->name)) + return 0; } - return 0; +#if CONFIG_AVDEVICE + opaque = NULL; + while ((file_iformat = av_indev_iterate(&opaque))) { + if (av_match_name(arg, file_iformat->name)) + return 0; + } +#endif + av_log(NULL, AV_LOG_FATAL, "Unknown input format: '%s'\n", arg); + return AVERROR(EINVAL); } static int opt_frame_pix_fmt(void *optctx, const char *opt, const char *arg) diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c index a4ac6972a2..931e321930 100644 --- a/fftools/ffprobe.c +++ b/fftools/ffprobe.c @@ -250,7 +250,7 @@ static const OptionDef *options; /* FFprobe context */ static const char *input_filename; -static AVInputFormat *iformat = NULL; +static const AVInputFormat *iformat = NULL; static struct AVHashContext *hash; @@ -3139,12 +3139,21 @@ static void ffprobe_show_pixel_formats(WriterContext *w) static int opt_format(void *optctx, const char *opt, const char *arg) { - iformat = av_find_input_format(arg); - if (!iformat) { - av_log(NULL, AV_LOG_ERROR, "Unknown input format: %s\n", arg); - return AVERROR(EINVAL); + void *opaque = NULL; + + while ((iformat = av_demuxer_iterate(&opaque))) { + if (av_match_name(arg, iformat->name)) + return 0; } - return 0; +#if CONFIG_AVDEVICE + opaque = NULL; + while ((iformat = av_indev_iterate(&opaque))) { + if (av_match_name(arg, iformat->name)) + return 0; + } +#endif + av_log(NULL, AV_LOG_FATAL, "Unknown input format: '%s'\n", arg); + return AVERROR(EINVAL); } static inline void mark_section_show_entries(SectionID section_id,