<html><head></head><body><div class="gmail_quote">Le 17 juillet 2017 23:40:31 GMT+08:00, Steve Lhomme <robux4@videolabs.io> a écrit :<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="k9mail">--<br />replaces <a href="https://patches.videolan.org/patch/17456">https://patches.videolan.org/patch/17456</a>/<br />- set the flag before opening the packetizer<br />replaces <a href="https://patches.videolan.org/patch/17485">https://patches.videolan.org/patch/17485</a>/<br />- use a callback between module loads to reset the fmt_out<br />- don't copy the fmt_in in the fmt_out<br />replaces <a href="https://patches.videolan.org/patch/17501">https://patches.videolan.org/patch/17501</a>/<br />- fix code moved in the wrong patch<br />---<br /> src/input/decoder.c | 27 ++++++++++++++++++++++-----<br /> src/input/decoder.h |  5 +++++<br /> src/input/demux.c   |  7 ++++++-<br /> 3 files changed, 33 insertions(+), 6 deletions(-)<br /><br />diff --git a/src/input/decoder.c b/src/input/decoder.c<br />index 0cacb4ccfd..cff170462d 100644<br />--- a/src/input/decoder.c<br />+++ b/src/input/decoder.c<br />@@ -151,6 +151,21 @@ struct decoder_owner_sys_t<br /> #define DECODER_SPU_VOUT_WAIT_DURATION ((int)(0.200*CLOCK_FREQ))<br /> #define BLOCK_FLAG_CORE_PRIVATE_RELOADED (1 << BLOCK_FLAG_CORE_PRIVATE_SHIFT)<br /> <br />+int PacketizerLoader(void *func, va_list ap)<br />+{<br />+    decoder_t *p_dec = va_arg(ap, decoder_t *);<br />+    int (*activate)(vlc_object_t *) = func;<br />+<br />+    int res = activate( VLC_OBJECT(p_dec) );<br />+    assert( p_dec->fmt_out.b_packetized );<br />+    if ( res != VLC_SUCCESS )<br />+    {<br />+        es_format_Change( &p_dec->fmt_out, p_dec->fmt_in.i_cat, 0 );<br />+        p_dec->fmt_out.b_packetized = true;<br />+    }<br />+    return res;<br />+}<br />+<br /> /**<br />  * Load a decoder module<br />  */<br />@@ -166,7 +181,6 @@ static int LoadDecoder( decoder_t *p_dec, bool b_packetizer,<br />     p_dec->pf_flush = NULL;<br /> <br />     es_format_Copy( &p_dec->fmt_in, p_fmt );<br />-    es_format_Init( &p_dec->fmt_out, p_fmt->i_cat, 0 );<br /> <br />     /* Find a suitable decoder/packetizer module */<br />     if( !b_packetizer )<br />@@ -180,15 +194,19 @@ static int LoadDecoder( decoder_t *p_dec, bool b_packetizer,<br />                                        "$codec", false );<br />     }<br />     else<br />-        p_dec->p_module = module_need( p_dec, "packetizer", "$packetizer", false );<br />+    {<br />+        es_format_Init( &p_dec->fmt_out, p_fmt->i_cat, 0 );<br />+        p_dec->fmt_out.b_packetized = true;<br />+        p_dec->p_module = vlc_module_load( p_dec, "packetizer", "$packetizer",<br />+                                           false, PacketizerLoader, p_dec );<br />+    }<br /> <br />     if( !p_dec->p_module )<br />     {<br />         es_format_Clean( &p_dec->fmt_in );<br />         return -1;<br />     }<br />-    else<br />-        return 0;<br />+    return 0;<br /> }<br /> <br /> /**<br />@@ -1722,7 +1740,6 @@ static decoder_t * CreateDecoder( vlc_object_t *p_parent,<br />             }<br />             else<br />             {<br />-                p_owner->p_packetizer->fmt_out.b_packetized = true;<br />                 fmt = &p_owner->p_packetizer->fmt_out;<br />             }<br />         }<br />diff --git a/src/input/decoder.h b/src/input/decoder.h<br />index 226ecde862..fdc2e397db 100644<br />--- a/src/input/decoder.h<br />+++ b/src/input/decoder.h<br />@@ -108,4 +108,9 @@ size_t input_DecoderGetFifoSize( decoder_t *p_dec );<br />  */<br /> void input_DecoderGetObjects( decoder_t *, vout_thread_t **, audio_output_t ** );<br /> <br />+/**<br />+ * Function to use to load a packetizer module<br />+ */<br />+int PacketizerLoader(void *func, va_list ap);<br />+<br /> #endif<br />diff --git a/src/input/demux.c b/src/input/demux.c<br />index 109a386775..766b5364e9 100644<br />--- a/src/input/demux.c<br />+++ b/src/input/demux.c<br />@@ -36,6 +36,9 @@<br /> #include <vlc_modules.h><br /> #include <vlc_strings.h><br /> <br />+#include "clock.h"<br />+#include "decoder.h"<br />+<br /> typedef const struct<br /> {<br />     char const key[20];<br />@@ -520,8 +523,10 @@ decoder_t *demux_PacketizerNew( demux_t *p_demux, es_format_t *p_fmt, const char<br /> <br />     p_packetizer->fmt_in = *p_fmt;<br />     es_format_Init( &p_packetizer->fmt_out, p_fmt->i_cat, 0 );<br />+    p_packetizer->fmt_out.b_packetized = true;<br /> <br />-    p_packetizer->p_module = module_need( p_packetizer, "packetizer", NULL, false );<br />+    p_packetizer->p_module = vlc_module_load( p_packetizer, "packetizer", NULL,<br />+                                              false, PacketizerLoader, p_packetizer );<br />     if( !p_packetizer->p_module )<br />     {<br />         es_format_Clean( p_fmt );</pre></blockquote></div><br clear="all">I still don't understand why you don't simply do that before loading the module.<br>
-- <br>
Rémi Denis-Courmont<br>
Typed on an inconvenient virtual keyboard</body></html>