[vlc-devel] [PATCH] [PATCH] Add startseg option for livehttp module

Ray Tiley raytiley at gmail.com
Fri Nov 8 23:58:52 CET 2013


The startseg option allows for passing in the number for the first
segment. This is useful if you want to append to an existing live
stream.
---
 modules/access_output/livehttp.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/modules/access_output/livehttp.c b/modules/access_output/livehttp.c
index 82539bc..50bb0c1 100644
--- a/modules/access_output/livehttp.c
+++ b/modules/access_output/livehttp.c
@@ -104,6 +104,9 @@ static void Close( vlc_object_t * );
 #define RANDOMIV_TEXT N_("Use randomized IV for encryption")
 #define RANDOMIV_LONGTEXT N_("Generate IV instead using segment-number as IV")
 
+#define STARTSEG_TEXT N_("Number of first segment")
+#define STARTSEG_LONGTEXT N_("The number of the segmented generated")
+
 vlc_module_begin ()
     set_description( N_("HTTP Live streaming output") )
     set_shortname( N_("LiveHTTP" ))
@@ -113,6 +116,7 @@ vlc_module_begin ()
     set_subcategory( SUBCAT_SOUT_ACO )
     add_integer( SOUT_CFG_PREFIX "seglen", 10, SEGLEN_TEXT, SEGLEN_LONGTEXT, false )
     add_integer( SOUT_CFG_PREFIX "numsegs", 0, NUMSEGS_TEXT, NUMSEGS_LONGTEXT, false )
+    add_integer( SOUT_CFG_PREFIX "startseg", 1, STARTSEG_TEXT, STARTSEG_LONGTEXT, false )
     add_bool( SOUT_CFG_PREFIX "splitanywhere", false,
               SPLITANYWHERE_TEXT, SPLITANYWHERE_LONGTEXT, true )
     add_bool( SOUT_CFG_PREFIX "delsegs", true,
@@ -153,6 +157,7 @@ static const char *const ppsz_sout_options[] = {
     "key-file",
     "key-loadfile",
     "generate-iv",
+    "startseg",
     NULL
 };
 
@@ -186,6 +191,7 @@ struct sout_access_out_sys_t
     block_t *block_buffer;
     int i_handle;
     unsigned i_numsegs;
+    unsigned i_startseg;
     bool b_delsegs;
     bool b_ratecontrol;
     bool b_splitanywhere;
@@ -230,6 +236,7 @@ static int Open( vlc_object_t *p_this )
     p_sys->block_buffer = NULL;
 
     p_sys->i_numsegs = var_GetInteger( p_access, SOUT_CFG_PREFIX "numsegs" );
+    p_sys->i_startseg = var_GetInteger( p_access, SOUT_CFG_PREFIX "startseg" );
     p_sys->b_splitanywhere = var_GetBool( p_access, SOUT_CFG_PREFIX "splitanywhere" );
     p_sys->b_delsegs = var_GetBool( p_access, SOUT_CFG_PREFIX "delsegs" );
     p_sys->b_ratecontrol = var_GetBool( p_access, SOUT_CFG_PREFIX "ratecontrol") ;
@@ -282,7 +289,7 @@ static int Open( vlc_object_t *p_this )
     }
 
     p_sys->i_handle = -1;
-    p_sys->i_segment = 0;
+    p_sys->i_segment = p_sys->i_startseg > 0 ? p_sys->i_startseg -1 : 0;
     p_sys->psz_cursegPath = NULL;
 
     p_access->pf_write = Write;
@@ -544,8 +551,11 @@ static int updateIndexAndDel( sout_access_out_t *p_access, sout_access_out_sys_t
     uint32_t i_firstseg;
     unsigned i_index_offset = 0;
 
-    if ( p_sys->i_numsegs == 0 || p_sys->i_segment < p_sys->i_numsegs )
-        i_firstseg = 1;
+    if ( p_sys->i_numsegs == 0 || 
+         p_sys->i_segment < ( p_sys->i_numsegs + p_sys->i_startseg ) )
+    {
+        i_firstseg = p_sys->i_startseg == 0 ? 1 : p_sys->i_startseg -1;
+    }
     else
     {
         unsigned numsegs = segmentAmountNeeded( p_sys );
-- 
1.8.3.2




More information about the vlc-devel mailing list