From 59078d61f579621a4ec26155aeeb16c95edf98e4 Mon Sep 17 00:00:00 2001 From: "ogg.k.ogg.k" Date: Thu, 30 Jul 2009 11:12:22 +0100 Subject: [PATCH] factor the ogg paging code Signed-off-by: Laurent Aimar --- modules/mux/ogg.c | 36 ++++++++++++------------------------ 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/modules/mux/ogg.c b/modules/mux/ogg.c index 2b1acf29cb..7528059455 100644 --- a/modules/mux/ogg.c +++ b/modules/mux/ogg.c @@ -557,14 +557,16 @@ static int DelStream( sout_mux_t *p_mux, sout_input_t *p_input ) /***************************************************************************** * Ogg bitstream manipulation routines *****************************************************************************/ -static block_t *OggStreamFlush( sout_mux_t *p_mux, - ogg_stream_state *p_os, mtime_t i_pts ) +static block_t *OggStreamGetPage( sout_mux_t *p_mux, + ogg_stream_state *p_os, mtime_t i_pts, + bool flush ) { (void)p_mux; block_t *p_og, *p_og_first = NULL; ogg_page og; + int (*pager)( ogg_stream_state*, ogg_page* ) = flush ? ogg_stream_flush : ogg_stream_pageout; - while( ogg_stream_flush( p_os, &og ) ) + while( pager( p_os, &og ) ) { /* Flush all data */ p_og = block_New( p_mux, og.header_len + og.body_len ); @@ -583,30 +585,16 @@ static block_t *OggStreamFlush( sout_mux_t *p_mux, return p_og_first; } +static block_t *OggStreamFlush( sout_mux_t *p_mux, + ogg_stream_state *p_os, mtime_t i_pts ) +{ + return OggStreamGetPage( p_mux, p_os, i_pts, true ); +} + static block_t *OggStreamPageOut( sout_mux_t *p_mux, ogg_stream_state *p_os, mtime_t i_pts ) { - (void)p_mux; - block_t *p_og, *p_og_first = NULL; - ogg_page og; - - while( ogg_stream_pageout( p_os, &og ) ) - { - /* Flush all data */ - p_og = block_New( p_mux, og.header_len + og.body_len ); - - memcpy( p_og->p_buffer, og.header, og.header_len ); - memcpy( p_og->p_buffer + og.header_len, og.body, og.body_len ); - p_og->i_dts = 0; - p_og->i_pts = i_pts; - p_og->i_length = 0; - - i_pts = 0; // write them only once - - block_ChainAppend( &p_og_first, p_og ); - } - - return p_og_first; + return OggStreamGetPage( p_mux, p_os, i_pts, false ); } static block_t *OggCreateHeader( sout_mux_t *p_mux ) -- 2.39.2