diff mbox

[FFmpeg-devel] libavformat/fifo: Fix initialization of underlying AVFormatContext

Message ID 1499339114-1984-1-git-send-email-sebechlebskyjan@gmail.com
State Accepted
Commit 5c9dcd5c484f56fb9fb5d277256439f0becce12c
Headers show

Commit Message

sebechlebskyjan@gmail.com July 6, 2017, 11:05 a.m. UTC
From: Jan Sebechlebsky <sebechlebskyjan@gmail.com>

Pass filename to AVFormatContext of underlying muxer.
This commit fixes bug #6308.

Signed-off-by: Jan Sebechlebsky <sebechlebskyjan@gmail.com>
---
 libavformat/fifo.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

wm4 July 6, 2017, 11:15 a.m. UTC | #1
On Thu,  6 Jul 2017 13:05:14 +0200
sebechlebskyjan@gmail.com wrote:

> From: Jan Sebechlebsky <sebechlebskyjan@gmail.com>
> 
> Pass filename to AVFormatContext of underlying muxer.
> This commit fixes bug #6308.
> 
> Signed-off-by: Jan Sebechlebsky <sebechlebskyjan@gmail.com>
> ---
>  libavformat/fifo.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/libavformat/fifo.c b/libavformat/fifo.c
> index 2cbe5c5..c881f31 100644
> --- a/libavformat/fifo.c
> +++ b/libavformat/fifo.c
> @@ -442,13 +442,14 @@ static void *fifo_consumer_thread(void *data)
>      return NULL;
>  }
>  
> -static int fifo_mux_init(AVFormatContext *avf, AVOutputFormat *oformat)
> +static int fifo_mux_init(AVFormatContext *avf, AVOutputFormat *oformat,
> +                         const char *filename)
>  {
>      FifoContext *fifo = avf->priv_data;
>      AVFormatContext *avf2;
>      int ret = 0, i;
>  
> -    ret = avformat_alloc_output_context2(&avf2, oformat, NULL, NULL);
> +    ret = avformat_alloc_output_context2(&avf2, oformat, NULL, filename);
>      if (ret < 0)
>          return ret;
>  
> @@ -505,7 +506,7 @@ static int fifo_init(AVFormatContext *avf)
>          return ret;
>      }
>  
> -    ret = fifo_mux_init(avf, oformat);
> +    ret = fifo_mux_init(avf, oformat, avf->filename);
>      if (ret < 0)
>          return ret;
>  

For what reason?
sebechlebskyjan@gmail.com July 6, 2017, 9:54 p.m. UTC | #2
On 07/06/2017 04:28 PM, wm4 wrote:

> On Thu, 6 Jul 2017 16:16:12 +0200
> Jan Sebechlebsky <sebechlebskyjan@gmail.com> wrote:
>
>> On 07/06/2017 01:15 PM, wm4 wrote:
>>
>>> On Thu,  6 Jul 2017 13:05:14 +0200
>>> sebechlebskyjan@gmail.com wrote:
>>>
>>> For what reason?
>> For example RTSP muxer attempts to access filename (url) from
>> AVFormatContext to extract connection parameters and open connection.
>> When the filename is not set, it initializes the connection with default
>> parameters, which is the cause of bug #6308 from trac:
>>
>> https://trac.ffmpeg.org/ticket/6308
>>
>> This commit fixes #6308 and possibly other problems with muxers
>> accessing filename from AVFormatContext.
> Then that should go into the commit message. Nobody likes to lookup
> trac and try to make sense of the user confusion there. Also, trac
> could get replaced or somehow reset in the future, like it happened in
> the past.
Ok, I'll modify the commit message before pushing to:

libavformat/fifo: Fix initialization of underlying AVFormatContext

Muxers may want to directly access filename in stored in AVFormatContext.
For example in case of RTSP, the filename (url) is used by the muxer to
extract parameters of the connection. These muxers will fail when used
with fifo pseudo-muxer.

This commit fixes this issue by passing filename from AVFormatContext
of fifo pseudo-muxer to all AVFormatContext(s) of underlying muxers during
initialization.
sebechlebskyjan@gmail.com July 13, 2017, 11:15 a.m. UTC | #3
On 07/06/2017 11:54 PM, Jan Sebechlebsky wrote:

> On 07/06/2017 04:28 PM, wm4 wrote:
>
>> On Thu, 6 Jul 2017 16:16:12 +0200
>> Jan Sebechlebsky <sebechlebskyjan@gmail.com> wrote:
>>
>>> On 07/06/2017 01:15 PM, wm4 wrote:
>>>
>>>> On Thu,  6 Jul 2017 13:05:14 +0200
>>>> sebechlebskyjan@gmail.com wrote:
>>>>
>>>> For what reason?
>>> For example RTSP muxer attempts to access filename (url) from
>>> AVFormatContext to extract connection parameters and open connection.
>>> When the filename is not set, it initializes the connection with 
>>> default
>>> parameters, which is the cause of bug #6308 from trac:
>>>
>>> https://trac.ffmpeg.org/ticket/6308
>>>
>>> This commit fixes #6308 and possibly other problems with muxers
>>> accessing filename from AVFormatContext.
>> Then that should go into the commit message. Nobody likes to lookup
>> trac and try to make sense of the user confusion there. Also, trac
>> could get replaced or somehow reset in the future, like it happened in
>> the past.
> Ok, I'll modify the commit message before pushing to:
>
> libavformat/fifo: Fix initialization of underlying AVFormatContext
>
> Muxers may want to directly access filename in stored in AVFormatContext.
> For example in case of RTSP, the filename (url) is used by the muxer to
> extract parameters of the connection. These muxers will fail when used
> with fifo pseudo-muxer.
>
> This commit fixes this issue by passing filename from AVFormatContext
> of fifo pseudo-muxer to all AVFormatContext(s) of underlying muxers 
> during
> initialization.
I'll apply the patch in a few days with modified commit message.

Jan
sebechlebskyjan@gmail.com July 19, 2017, 8:33 a.m. UTC | #4
On 07/13/2017 01:15 PM, Jan Sebechlebsky wrote:

> I'll apply the patch in a few days with modified commit message.
>
> Jan
Applied...
diff mbox

Patch

diff --git a/libavformat/fifo.c b/libavformat/fifo.c
index 2cbe5c5..c881f31 100644
--- a/libavformat/fifo.c
+++ b/libavformat/fifo.c
@@ -442,13 +442,14 @@  static void *fifo_consumer_thread(void *data)
     return NULL;
 }
 
-static int fifo_mux_init(AVFormatContext *avf, AVOutputFormat *oformat)
+static int fifo_mux_init(AVFormatContext *avf, AVOutputFormat *oformat,
+                         const char *filename)
 {
     FifoContext *fifo = avf->priv_data;
     AVFormatContext *avf2;
     int ret = 0, i;
 
-    ret = avformat_alloc_output_context2(&avf2, oformat, NULL, NULL);
+    ret = avformat_alloc_output_context2(&avf2, oformat, NULL, filename);
     if (ret < 0)
         return ret;
 
@@ -505,7 +506,7 @@  static int fifo_init(AVFormatContext *avf)
         return ret;
     }
 
-    ret = fifo_mux_init(avf, oformat);
+    ret = fifo_mux_init(avf, oformat, avf->filename);
     if (ret < 0)
         return ret;