On 15.12.2014 00:33, Lukasz Marek wrote:
List device callback must be able to return valid list without opening device.
This callback should return input values for open function, not vice-versa.
Read header funtion is very likey to fail without proper configuration provided.

Signed-off-by: Lukasz Marek <lukasz.m.lu...@gmail.com>
---
  cmdutils.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/cmdutils.c b/cmdutils.c
index 06ce5d5..51fd777 100644
--- a/cmdutils.c
+++ b/cmdutils.c
@@ -2069,9 +2069,8 @@ static int print_device_sources(AVInputFormat *fmt, 
AVDictionary *opts)
          goto fail;
      }

-    /* TODO: avformat_open_input calls read_header callback which is not 
necessary.
-             Function like avformat_alloc_output_context2 for input could be 
helpful here. */
      av_dict_copy(&tmp_opts, opts, 0);
+    dev->flags |= AVFMT_FLAG_PRIV_OPT;
      if ((ret = avformat_open_input(&dev, NULL, fmt, &tmp_opts)) < 0) {
          printf("Cannot open device: %s.\n", fmt->name);
          goto fail;


I forgot to amend. Updated patch attached.
>From 332bb7456c498518ea72dfdaa0e8c3e76d383f21 Mon Sep 17 00:00:00 2001
From: Lukasz Marek <lukasz.m.lu...@gmail.com>
Date: Mon, 15 Dec 2014 00:31:42 +0100
Subject: [PATCH] cmdutils: dont call read_header before listing devices

List device callback must be able to return valid list without opening device.
This callback should return input values for open function, not vice-versa.
Read header funtion is very likey to fail without proper configuration provided.

Signed-off-by: Lukasz Marek <lukasz.m.lu...@gmail.com>
---
 cmdutils.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/cmdutils.c b/cmdutils.c
index 06ce5d5..3e932db 100644
--- a/cmdutils.c
+++ b/cmdutils.c
@@ -2069,9 +2069,13 @@ static int print_device_sources(AVInputFormat *fmt, AVDictionary *opts)
         goto fail;
     }
 
-    /* TODO: avformat_open_input calls read_header callback which is not necessary.
-             Function like avformat_alloc_output_context2 for input could be helpful here. */
     av_dict_copy(&tmp_opts, opts, 0);
+    dev = avformat_alloc_context();
+    if (!dev) {
+        ret = AVERROR(ENOMEM);
+        goto fail;
+    }
+    dev->flags |= AVFMT_FLAG_PRIV_OPT;
     if ((ret = avformat_open_input(&dev, NULL, fmt, &tmp_opts)) < 0) {
         printf("Cannot open device: %s.\n", fmt->name);
         goto fail;
-- 
1.9.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to