]> git.sesse.net Git - vlc/commitdiff
Added sout-mux-caching option. It allow to set the initial muxer cache value
authorLaurent Aimar <fenrir@videolan.org>
Fri, 12 Oct 2007 23:41:31 +0000 (23:41 +0000)
committerLaurent Aimar <fenrir@videolan.org>
Fri, 12 Oct 2007 23:41:31 +0000 (23:41 +0000)
in millisecond.
 Original patch created by Jeff Hansen.

src/libvlc-module.c
src/stream_output/stream_output.c

index 1e59c0a4bffea32d8e9f51eb90311bab403131d3..3f7e94ae13cf702fae2186db71c3a836cf9b84e4 100644 (file)
@@ -844,6 +844,11 @@ static const char *ppsz_clock_descriptions[] =
     "multiple playlist item (automatically insert the gather stream output " \
     "if not specified)" )
 
+#define SOUT_MUX_CACHING_TEXT N_("Stream output muxer caching (ms)")
+#define SOUT_MUX_CACHING_LONGTEXT N_( \
+    "This allow you to configure the initial caching amount for stream output " \
+    " muxer. This value should be set in milliseconds." )
+
 #define PACKETIZER_TEXT N_("Preferred packetizer list")
 #define PACKETIZER_LONGTEXT N_( \
     "This allows you to select the order in which VLC will choose its " \
@@ -1686,6 +1691,8 @@ vlc_module_begin();
                                 SOUT_VIDEO_LONGTEXT, VLC_TRUE );
     add_bool( "sout-spu", 1, NULL, SOUT_SPU_TEXT,
                                 SOUT_SPU_LONGTEXT, VLC_TRUE );
+    add_integer( "sout-mux-caching", 1500, NULL, SOUT_MUX_CACHING_TEXT,
+                                SOUT_MUX_CACHING_LONGTEXT, VLC_TRUE );
 
     set_section( N_("VLM"), NULL );
     add_string( "vlm-conf", NULL, NULL, VLM_CONF_TEXT,
index 1d12e1cd0cf2185e533285ec16407ea735eecceb..2d512e664eafad2a7bf2f56c3f8f026b9290be7e 100644 (file)
@@ -103,8 +103,11 @@ sout_instance_t *__sout_NewInstance( vlc_object_t *p_parent, char * psz_dest )
     /* attach it for inherit */
     vlc_object_attach( p_sout, p_parent );
 
-    p_sout->p_stream = sout_StreamNew( p_sout, p_sout->psz_chain );
+    /* */
+    var_Create( p_sout, "sout-mux-caching", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
 
+    /* */
+    p_sout->p_stream = sout_StreamNew( p_sout, p_sout->psz_chain );
     if( p_sout->p_stream == NULL )
     {
         msg_Err( p_sout, "stream chain failed for `%s'", p_sout->psz_chain );
@@ -470,7 +473,7 @@ sout_input_t *sout_MuxAddStream( sout_mux_t *p_mux, es_format_t *p_fmt )
     if( !p_mux->b_add_stream_any_time && !p_mux->b_waiting_stream )
     {
         msg_Err( p_mux, "cannot add a new stream (unsupported while muxing "
-                        "to this format)" );
+                        "to this format). You can try increasing sout-mux-caching value" );
         return NULL;
     }
 
@@ -551,22 +554,16 @@ void sout_MuxSendBuffer( sout_mux_t *p_mux, sout_input_t *p_input,
 
     if( p_mux->b_waiting_stream )
     {
+        const int64_t i_caching = var_GetInteger( p_mux->p_sout, "sout-mux-caching" ) * I64C(1000);
+
         if( p_mux->i_add_stream_start < 0 )
-        {
             p_mux->i_add_stream_start = p_buffer->i_dts;
-        }
 
-        if( p_mux->i_add_stream_start >= 0 &&
-            p_mux->i_add_stream_start + I64C(1500000) < p_buffer->i_dts )
-        {
-            /* Wait until we have more than 1.5 seconds worth of data
-             * before start muxing */
-            p_mux->b_waiting_stream = VLC_FALSE;
-        }
-        else
-        {
+        /* Wait until we have enought data before muxing */
+        if( p_mux->i_add_stream_start < 0 ||
+            p_buffer->i_dts < p_mux->i_add_stream_start + i_caching )
             return;
-        }
+        p_mux->b_waiting_stream = VLC_FALSE;
     }
     p_mux->pf_mux( p_mux );
 }