Changeset 11fddaa6fa3d16939419a14f7a31a10db8369a52

Show
Ignore:
Timestamp:
15/10/04 17:42:01 (4 years ago)
Author:
Gildas Bazin <gbazin@videolan.org>
git-committer:
Gildas Bazin <gbazin@videolan.org> 1097854921 +0000
git-parent:

[8b1965a7e9f20db5c98a7a2004c5ad95d5c22f7f]

git-author:
Gildas Bazin <gbazin@videolan.org> 1097854921 +0000
Message:

* src/stream_output/stream_output.c:

  • for muxers that request some preparsing before starting muxing,
    we now wait for 1.5 seconds worth of data to be in the fifo instead
    of waiting for 1.5 seconds of real-time.
  • if we have have control over the output pace, we also wait before
    starting muxing (produces nicer streams).
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/stream_output/stream_output.c

    rf0251c5 r11fddaa  
    4242static void sout_CfgDestroy( sout_cfg_t * ); 
    4343 
    44 #define sout_stream_url_to_chain( p, s ) _sout_stream_url_to_chain( VLC_OBJECT(p), s ) 
     44#define sout_stream_url_to_chain( p, s ) \ 
     45    _sout_stream_url_to_chain( VLC_OBJECT(p), s ) 
    4546static char *_sout_stream_url_to_chain( vlc_object_t *, char * ); 
    4647 
     
    365366    char       *psz_next; 
    366367 
    367     p_mux = vlc_object_create( p_sout, 
    368                                sizeof( sout_mux_t ) ); 
     368    p_mux = vlc_object_create( p_sout, sizeof( sout_mux_t ) ); 
    369369    if( p_mux == NULL ) 
    370370    { 
     
    373373    } 
    374374 
    375     p_mux->p_sout       = p_sout; 
     375    p_mux->p_sout = p_sout; 
    376376    psz_next = sout_CfgCreate( &p_mux->psz_mux, &p_mux->p_cfg, psz_mux ); 
    377     if( psz_next ) 
    378     { 
    379         free( psz_next ); 
    380     } 
     377    if( psz_next ) free( psz_next ); 
     378 
    381379    p_mux->p_access     = p_access; 
    382380    p_mux->pf_control   = NULL; 
     
    388386 
    389387    p_mux->p_sys        = NULL; 
    390     p_mux->p_module = NULL; 
     388    p_mux->p_module     = NULL; 
     389 
     390    p_mux->b_add_stream_any_time = VLC_FALSE; 
     391    p_mux->b_waiting_stream = VLC_TRUE; 
     392    p_mux->i_add_stream_start = -1; 
    391393 
    392394    vlc_object_attach( p_mux, p_sout ); 
    393395 
    394     p_mux->p_module    
     396    p_mux->p_module
    395397        module_Need( p_mux, "sout mux", p_mux->psz_mux, VLC_TRUE ); 
    396398 
     
    407409    if( p_mux->pf_control ) 
    408410    { 
    409         int b_answer; 
    410         if( sout_MuxControl( p_mux, MUX_CAN_ADD_STREAM_WHILE_MUXING, &b_answer ) ) 
     411        int b_answer = VLC_FALSE; 
     412 
     413        if( sout_MuxControl( p_mux, MUX_CAN_ADD_STREAM_WHILE_MUXING, 
     414                             &b_answer ) ) 
    411415        { 
    412416            b_answer = VLC_FALSE; 
    413417        } 
     418 
    414419        if( b_answer ) 
    415420        { 
     
    418423            p_mux->b_waiting_stream = VLC_FALSE; 
    419424 
    420             if( sout_MuxControl( p_mux, MUX_GET_ADD_STREAM_WAIT, &b_answer ) ) 
     425            /* If we control the output pace then it's better to wait before 
     426             * starting muxing (generates better streams/files). */ 
     427            if( !p_sout->i_out_pace_nocontrol ) 
     428            { 
     429                b_answer = VLC_TRUE; 
     430            } 
     431            else if( sout_MuxControl( p_mux, MUX_GET_ADD_STREAM_WAIT, 
     432                                      &b_answer ) ) 
    421433            { 
    422434                b_answer = VLC_FALSE; 
    423435            } 
     436 
    424437            if( b_answer ) 
    425438            { 
     
    429442            } 
    430443        } 
    431         else 
    432         { 
    433             p_mux->b_add_stream_any_time = VLC_FALSE; 
    434             p_mux->b_waiting_stream = VLC_TRUE; 
    435         } 
    436     } 
    437     else 
    438     { 
    439         p_mux->b_add_stream_any_time = VLC_FALSE; 
    440         p_mux->b_waiting_stream = VLC_TRUE; 
    441     } 
    442     p_mux->i_add_stream_start = -1; 
     444    } 
    443445 
    444446    return p_mux; 
     
    474476                        "for this format)" ); 
    475477        return NULL; 
    476     } 
    477     if( p_mux->i_add_stream_start < 0 ) 
    478     { 
    479         /* we wait for one second */ 
    480         p_mux->i_add_stream_start = mdate(); 
    481478    } 
    482479 
     
    549546    if( p_mux->b_waiting_stream ) 
    550547    { 
    551         if( p_mux->i_add_stream_start > 0 && 
    552             p_mux->i_add_stream_start + (mtime_t)1500000 < mdate() ) 
    553         { 
    554             /* more than 1.5 second, start muxing */ 
     548        if( p_mux->i_add_stream_start < 0 ) 
     549        { 
     550            p_mux->i_add_stream_start = p_buffer->i_dts; 
     551        } 
     552 
     553        if( p_mux->i_add_stream_start >= 0 && 
     554            p_mux->i_add_stream_start + I64C(15000000) < p_buffer->i_dts ) 
     555        { 
     556            /* Wait until we have more than 1.5 seconds worth of data 
     557             * before start muxing */ 
    555558            p_mux->b_waiting_stream = VLC_FALSE; 
    556559        }