Commit 59078d61 authored by ogg.k.ogg.k's avatar ogg.k.ogg.k Committed by Laurent Aimar

factor the ogg paging code

Signed-off-by: default avatarLaurent Aimar <fenrir@videolan.org>
parent 47318ef3
...@@ -557,14 +557,16 @@ static int DelStream( sout_mux_t *p_mux, sout_input_t *p_input ) ...@@ -557,14 +557,16 @@ static int DelStream( sout_mux_t *p_mux, sout_input_t *p_input )
/***************************************************************************** /*****************************************************************************
* Ogg bitstream manipulation routines * Ogg bitstream manipulation routines
*****************************************************************************/ *****************************************************************************/
static block_t *OggStreamFlush( sout_mux_t *p_mux, static block_t *OggStreamGetPage( sout_mux_t *p_mux,
ogg_stream_state *p_os, mtime_t i_pts ) ogg_stream_state *p_os, mtime_t i_pts,
bool flush )
{ {
(void)p_mux; (void)p_mux;
block_t *p_og, *p_og_first = NULL; block_t *p_og, *p_og_first = NULL;
ogg_page og; 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 */ /* Flush all data */
p_og = block_New( p_mux, og.header_len + og.body_len ); 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, ...@@ -583,30 +585,16 @@ static block_t *OggStreamFlush( sout_mux_t *p_mux,
return p_og_first; return p_og_first;
} }
static block_t *OggStreamPageOut( sout_mux_t *p_mux, static block_t *OggStreamFlush( sout_mux_t *p_mux,
ogg_stream_state *p_os, mtime_t i_pts ) ogg_stream_state *p_os, mtime_t i_pts )
{ {
(void)p_mux; return OggStreamGetPage( p_mux, p_os, i_pts, true );
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; static block_t *OggStreamPageOut( sout_mux_t *p_mux,
ogg_stream_state *p_os, mtime_t i_pts )
{
return OggStreamGetPage( p_mux, p_os, i_pts, false );
} }
static block_t *OggCreateHeader( sout_mux_t *p_mux ) static block_t *OggCreateHeader( sout_mux_t *p_mux )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment