[vlc-devel] [PATCH 02/18] core: force the output to b_packetized when a packetizer is opened successfully

Rémi Denis-Courmont remi at remlab.net
Tue Jul 18 05:56:00 CEST 2017


Le 17 juillet 2017 23:40:31 GMT+08:00, Steve Lhomme <robux4 at videolabs.io> a écrit :
>--
>replaces https://patches.videolan.org/patch/17456/
>- set the flag before opening the packetizer
>replaces https://patches.videolan.org/patch/17485/
>- use a callback between module loads to reset the fmt_out
>- don't copy the fmt_in in the fmt_out
>replaces https://patches.videolan.org/patch/17501/
>- fix code moved in the wrong patch
>---
> src/input/decoder.c | 27 ++++++++++++++++++++++-----
> src/input/decoder.h |  5 +++++
> src/input/demux.c   |  7 ++++++-
> 3 files changed, 33 insertions(+), 6 deletions(-)
>
>diff --git a/src/input/decoder.c b/src/input/decoder.c
>index 0cacb4ccfd..cff170462d 100644
>--- a/src/input/decoder.c
>+++ b/src/input/decoder.c
>@@ -151,6 +151,21 @@ struct decoder_owner_sys_t
> #define DECODER_SPU_VOUT_WAIT_DURATION ((int)(0.200*CLOCK_FREQ))
>#define BLOCK_FLAG_CORE_PRIVATE_RELOADED (1 <<
>BLOCK_FLAG_CORE_PRIVATE_SHIFT)
> 
>+int PacketizerLoader(void *func, va_list ap)
>+{
>+    decoder_t *p_dec = va_arg(ap, decoder_t *);
>+    int (*activate)(vlc_object_t *) = func;
>+
>+    int res = activate( VLC_OBJECT(p_dec) );
>+    assert( p_dec->fmt_out.b_packetized );
>+    if ( res != VLC_SUCCESS )
>+    {
>+        es_format_Change( &p_dec->fmt_out, p_dec->fmt_in.i_cat, 0 );
>+        p_dec->fmt_out.b_packetized = true;
>+    }
>+    return res;
>+}
>+
> /**
>  * Load a decoder module
>  */
>@@ -166,7 +181,6 @@ static int LoadDecoder( decoder_t *p_dec, bool
>b_packetizer,
>     p_dec->pf_flush = NULL;
> 
>     es_format_Copy( &p_dec->fmt_in, p_fmt );
>-    es_format_Init( &p_dec->fmt_out, p_fmt->i_cat, 0 );
> 
>     /* Find a suitable decoder/packetizer module */
>     if( !b_packetizer )
>@@ -180,15 +194,19 @@ static int LoadDecoder( decoder_t *p_dec, bool
>b_packetizer,
>                                        "$codec", false );
>     }
>     else
>-        p_dec->p_module = module_need( p_dec, "packetizer",
>"$packetizer", false );
>+    {
>+        es_format_Init( &p_dec->fmt_out, p_fmt->i_cat, 0 );
>+        p_dec->fmt_out.b_packetized = true;
>+        p_dec->p_module = vlc_module_load( p_dec, "packetizer",
>"$packetizer",
>+                                           false, PacketizerLoader,
>p_dec );
>+    }
> 
>     if( !p_dec->p_module )
>     {
>         es_format_Clean( &p_dec->fmt_in );
>         return -1;
>     }
>-    else
>-        return 0;
>+    return 0;
> }
> 
> /**
>@@ -1722,7 +1740,6 @@ static decoder_t * CreateDecoder( vlc_object_t
>*p_parent,
>             }
>             else
>             {
>-                p_owner->p_packetizer->fmt_out.b_packetized = true;
>                 fmt = &p_owner->p_packetizer->fmt_out;
>             }
>         }
>diff --git a/src/input/decoder.h b/src/input/decoder.h
>index 226ecde862..fdc2e397db 100644
>--- a/src/input/decoder.h
>+++ b/src/input/decoder.h
>@@ -108,4 +108,9 @@ size_t input_DecoderGetFifoSize( decoder_t *p_dec
>);
>  */
>void input_DecoderGetObjects( decoder_t *, vout_thread_t **,
>audio_output_t ** );
> 
>+/**
>+ * Function to use to load a packetizer module
>+ */
>+int PacketizerLoader(void *func, va_list ap);
>+
> #endif
>diff --git a/src/input/demux.c b/src/input/demux.c
>index 109a386775..766b5364e9 100644
>--- a/src/input/demux.c
>+++ b/src/input/demux.c
>@@ -36,6 +36,9 @@
> #include <vlc_modules.h>
> #include <vlc_strings.h>
> 
>+#include "clock.h"
>+#include "decoder.h"
>+
> typedef const struct
> {
>     char const key[20];
>@@ -520,8 +523,10 @@ decoder_t *demux_PacketizerNew( demux_t *p_demux,
>es_format_t *p_fmt, const char
> 
>     p_packetizer->fmt_in = *p_fmt;
>     es_format_Init( &p_packetizer->fmt_out, p_fmt->i_cat, 0 );
>+    p_packetizer->fmt_out.b_packetized = true;
> 
>-    p_packetizer->p_module = module_need( p_packetizer, "packetizer",
>NULL, false );
>+    p_packetizer->p_module = vlc_module_load( p_packetizer,
>"packetizer", NULL,
>+                                              false, PacketizerLoader,
>p_packetizer );
>     if( !p_packetizer->p_module )
>     {
>         es_format_Clean( p_fmt );
>-- 
>2.12.1
>
>_______________________________________________
>vlc-devel mailing list
>To unsubscribe or modify your subscription options:
>https://mailman.videolan.org/listinfo/vlc-devel

I still don't understand why you don't simply do that before loading the module.
-- 
Rémi Denis-Courmont
Typed on an inconvenient virtual keyboard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20170718/974f7e04/attachment.html>


More information about the vlc-devel mailing list