[vlc-commits] livehttp: try to comply draft 11 section 6.2.2 for how long to keep segments around in sliding window
Ilkka Ollakka
git at videolan.org
Tue Jun 18 20:18:38 CEST 2013
vlc | branch: master | Ilkka Ollakka <ileoo at videolan.org> | Wed Jun 5 14:00:55 2013 +0300| [d00d1822a13a2d1c38b06627223907e76bc28748] | committer: Ilkka Ollakka
livehttp: try to comply draft 11 section 6.2.2 for how long to keep segments around in sliding window
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d00d1822a13a2d1c38b06627223907e76bc28748
---
modules/access_output/livehttp.c | 33 ++++++++++++++++++++++++++++++++-
1 file changed, 32 insertions(+), 1 deletion(-)
diff --git a/modules/access_output/livehttp.c b/modules/access_output/livehttp.c
index c89d849..0c85457 100644
--- a/modules/access_output/livehttp.c
+++ b/modules/access_output/livehttp.c
@@ -166,6 +166,7 @@ typedef struct output_segment
char *psz_uri;
char *psz_key_uri;
char *psz_duration;
+ float f_seglength;
uint32_t i_segment_number;
uint8_t aes_ivs[16];
} output_segment_t;
@@ -489,6 +490,28 @@ static void destroySegment( output_segment_t *segment )
}
/************************************************************************
+ * isFirstItemRemovable: Check for draft 11 section 6.2.2
+ * check that the first item has been around outside playlist
+ * segment->f_seglength + p_sys->i_seglen before it is removed.
+ ************************************************************************/
+static bool isFirstItemRemovable( sout_access_out_sys_t *p_sys, uint32_t i_firstseg, uint32_t i_index_offset )
+{
+ float duration = .0f;
+
+ /* Check that segment has been out of playlist for seglenght + p_sys->i_seglen amount
+ * We check this by calculating duration of the items that replaced first item in playlist
+ */
+ for(int index=0; index < i_index_offset; index++ )
+ {
+ output_segment_t *segment = vlc_array_item_at_index( p_sys->segments_t, p_sys->i_segment - i_firstseg + index );
+ duration += segment->f_seglength;
+ }
+ output_segment_t *first = vlc_array_item_at_index( p_sys->segments_t, 0 );
+
+ return duration >= (first->f_seglength + (float)p_sys->i_seglen);
+}
+
+/************************************************************************
* updateIndexAndDel: If necessary, update index file & delete old segments
************************************************************************/
static int updateIndexAndDel( sout_access_out_t *p_access, sout_access_out_sys_t *p_sys, bool b_isend )
@@ -607,15 +630,22 @@ static int updateIndexAndDel( sout_access_out_t *p_access, sout_access_out_sys_t
}
// Then take care of deletion
- while( p_sys->b_delsegs && p_sys->i_numsegs && ( (vlc_array_count( p_sys->segments_t ) ) > p_sys->i_numsegs ) )
+ // Try to follow pantos draft 11 section 6.2.2
+ while( p_sys->b_delsegs && p_sys->i_numsegs &&
+ isFirstItemRemovable( p_sys, i_firstseg, i_index_offset )
+ )
{
output_segment_t *segment = vlc_array_item_at_index( p_sys->segments_t, 0 );
+ msg_Dbg( p_access, "Removing segment number %d", segment->i_segment_number );
vlc_array_remove( p_sys->segments_t, 0 );
+
if ( segment->psz_filename )
{
vlc_unlink( segment->psz_filename );
}
+
destroySegment( segment );
+ i_index_offset -=1;
}
@@ -656,6 +686,7 @@ static void closeCurrentSegment( sout_access_out_t *p_access, sout_access_out_sy
msg_Err( p_access, "Couldn't set duration on closed segment");
return;
}
+ segment->f_seglength = p_sys->f_seglen;
segment->i_segment_number = p_sys->i_segment;
More information about the vlc-commits
mailing list