* mux/* implemented pf_mux_capacity.
* avi.c
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
- * $Id: avi.c,v 1.6 2003/02/24 10:45:55 fenrir Exp $
+ * $Id: avi.c,v 1.7 2003/02/24 12:34:29 fenrir Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
static int Open ( vlc_object_t * );
static void Close ( vlc_object_t * );
+static int Capability( int , void *, void * );
static int AddStream( sout_instance_t *, sout_input_t * );
static int DelStream( sout_instance_t *, sout_input_t * );
static int Mux ( sout_instance_t * );
msg_Info( p_sout, "Open" );
- p_sout->pf_mux_capacity = NULL;
+ p_sout->pf_mux_capacity = Capability;
p_sout->pf_mux_addstream = AddStream;
p_sout->pf_mux_delstream = DelStream;
p_sout->pf_mux = Mux;
sout_AccessOutWrite( p_sout->p_access, p_hdr );
}
+static int Capability( int i_query, void *p_args, void *p_answer )
+{
+ switch( i_query )
+ {
+ case SOUT_MUX_CAP_GET_ADD_STREAM_ANY_TIME:
+ *(vlc_bool_t*)p_answer = VLC_TRUE;
+ return( SOUT_MUX_CAP_ERR_OK );
+ default:
+ return( SOUT_MUX_CAP_ERR_UNIMPLEMENTED );
+ }
+}
static int AddStream( sout_instance_t *p_sout, sout_input_t *p_input )
{
* dummy.c
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
- * $Id: dummy.c,v 1.3 2003/02/24 10:45:55 fenrir Exp $
+ * $Id: dummy.c,v 1.4 2003/02/24 12:34:29 fenrir Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Eric Petit <titer@videolan.org>
static int Open ( vlc_object_t * );
static void Close ( vlc_object_t * );
+static int Capability( int, void *, void * );
static int AddStream( sout_instance_t *, sout_input_t * );
static int DelStream( sout_instance_t *, sout_input_t * );
static int Mux ( sout_instance_t * );
msg_Info( p_sout, "Open" );
- p_sout->pf_mux_capacity = NULL;
+ p_sout->pf_mux_capacity = Capability;
p_sout->pf_mux_addstream = AddStream;
p_sout->pf_mux_delstream = DelStream;
p_sout->pf_mux = Mux;
msg_Info( p_sout, "Close" );
}
+static int Capability( int i_query, void *p_args, void *p_answer )
+{
+ switch( i_query )
+ {
+ case SOUT_MUX_CAP_GET_ADD_STREAM_ANY_TIME:
+ *(vlc_bool_t*)p_answer = VLC_TRUE;
+ return( SOUT_MUX_CAP_ERR_OK );
+ default:
+ return( SOUT_MUX_CAP_ERR_UNIMPLEMENTED );
+ }
+}
static int AddStream( sout_instance_t *p_sout, sout_input_t *p_input )
{
* ps.c
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
- * $Id: ps.c,v 1.7 2003/02/24 10:45:55 fenrir Exp $
+ * $Id: ps.c,v 1.8 2003/02/24 12:34:29 fenrir Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Eric Petit <titer@videolan.org>
static int Open ( vlc_object_t * );
static void Close ( vlc_object_t * );
+static int Capability( int , void *, void * );
static int AddStream( sout_instance_t *, sout_input_t * );
static int DelStream( sout_instance_t *, sout_input_t * );
static int Mux ( sout_instance_t * );
p_mux = malloc( sizeof( sout_mux_t ) );
- p_sout->pf_mux_capacity = NULL;
+ p_sout->pf_mux_capacity = Capability;
p_sout->pf_mux_addstream = AddStream;
p_sout->pf_mux_delstream = DelStream;
p_sout->pf_mux = Mux;
p_sout->p_mux_data = NULL;
}
+static int Capability( int i_query, void *p_args, void *p_answer )
+{
+ switch( i_query )
+ {
+ case SOUT_MUX_CAP_GET_ADD_STREAM_ANY_TIME:
+ *(vlc_bool_t*)p_answer = VLC_TRUE;
+ return( SOUT_MUX_CAP_ERR_OK );
+ default:
+ return( SOUT_MUX_CAP_ERR_UNIMPLEMENTED );
+ }
+}
static int AddStream( sout_instance_t *p_sout, sout_input_t *p_input )
{
* ts.c
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
- * $Id: ts.c,v 1.10 2003/02/24 10:45:55 fenrir Exp $
+ * $Id: ts.c,v 1.11 2003/02/24 12:34:29 fenrir Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Eric Petit <titer@videolan.org>
static int Open ( vlc_object_t * );
static void Close ( vlc_object_t * );
+static int Capability( int , void *, void * );
static int AddStream( sout_instance_t *, sout_input_t * );
static int DelStream( sout_instance_t *, sout_input_t * );
static int Mux ( sout_instance_t * );
p_mux = malloc( sizeof( sout_mux_t ) );
- p_sout->pf_mux_capacity = NULL;
+ p_sout->pf_mux_capacity = Capability;
p_sout->pf_mux_addstream = AddStream;
p_sout->pf_mux_delstream = DelStream;
p_sout->pf_mux = Mux;
p_sout->p_mux_data = NULL;
}
+static int Capability( int i_query, void *p_args, void *p_answer )
+{
+ switch( i_query )
+ {
+ case SOUT_MUX_CAP_GET_ADD_STREAM_ANY_TIME:
+ *(vlc_bool_t*)p_answer = VLC_TRUE;
+ return( SOUT_MUX_CAP_ERR_OK );
+ default:
+ return( SOUT_MUX_CAP_ERR_UNIMPLEMENTED );
+ }
+}
static int AddStream( sout_instance_t *p_sout, sout_input_t *p_input )
{
* stream_output.c : stream output module
*****************************************************************************
* Copyright (C) 2002 VideoLAN
- * $Id: stream_output.c,v 1.13 2003/02/16 14:10:44 fenrir Exp $
+ * $Id: stream_output.c,v 1.14 2003/02/24 12:34:29 fenrir Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Laurent Aimar <fenrir@via.ecp.fr>
*****************************************************************************/
static int InitInstance ( sout_instance_t * );
+struct sout_instance_sys_t
+{
+ /* if muxer doesn't support adding stream at any time then we first wait
+ * for stream then we refuse all stream and start muxing */
+ vlc_bool_t b_add_stream_any_time;
+ vlc_bool_t b_waiting_stream;
+
+ /* we wait one second after first stream added */
+ mtime_t i_add_stream_start;
+};
+
+
/*****************************************************************************
* sout_NewInstance: creates a new stream output instance
*****************************************************************************/
p_sout->i_nb_inputs = 0;
p_sout->pp_inputs = NULL;
vlc_mutex_init( p_sout, &p_sout->lock );
+ p_sout->p_sys = malloc( sizeof( sout_instance_sys_t ) );
+ /* fixed after opening muxer */
+ p_sout->p_sys->b_add_stream_any_time = VLC_FALSE;
+ p_sout->p_sys->b_waiting_stream = VLC_TRUE;
+ p_sout->p_sys->i_add_stream_start = -1;
/* Skip the plug-in names */
while( *psz_parser && *psz_parser != ':' )
msg_Err( p_sout, "no suitable mux module for `%s/%s://%s'",
p_sout->psz_access, p_sout->psz_mux, p_sout->psz_name );
- sout_AccessDelete( p_sout->p_access );
+ sout_AccessOutDelete( p_sout->p_access );
return -1;
}
-
+ if( p_sout->pf_mux_capacity )
+ {
+ int b_answer;
+ if( p_sout->pf_mux_capacity( p_sout,
+ SOUT_MUX_CAP_GET_ADD_STREAM_ANY_TIME,
+ NULL, (void*)&b_answer ) != SOUT_MUX_CAP_ERR_OK )
+ {
+ b_answer = VLC_FALSE;
+ }
+ if( b_answer )
+ {
+ msg_Dbg( p_sout, "muxer support adding stream at any time" );
+ p_sout->p_sys->b_add_stream_any_time = VLC_TRUE;
+ p_sout->p_sys->b_waiting_stream = VLC_FALSE;
+ }
+ else
+ {
+ p_sout->p_sys->b_add_stream_any_time = VLC_FALSE;
+ p_sout->p_sys->b_waiting_stream = VLC_TRUE;
+ }
+ }
p_sout->i_nb_inputs = 0;
p_sout->pp_inputs = NULL;
}
if( p_sout->p_access )
{
- sout_AccessDelete( p_sout->p_access );
+ sout_AccessOutDelete( p_sout->p_access );
}
vlc_mutex_destroy( &p_sout->lock );
/*****************************************************************************
* sout_AccessDelete: delete an access out
*****************************************************************************/
-void sout_AccessDelete( sout_access_out_t *p_access )
+void sout_AccessOutDelete( sout_access_out_t *p_access )
{
if( p_access->p_module )
{
/*****************************************************************************
* sout_AccessSeek:
*****************************************************************************/
-int sout_AccessSeek( sout_access_out_t *p_access, off_t i_pos )
+int sout_AccessOutSeek( sout_access_out_t *p_access, off_t i_pos )
{
return( p_access->pf_seek( p_access, i_pos ) );
}
/*****************************************************************************
* sout_AccessWrite:
*****************************************************************************/
-int sout_AccessWrite( sout_access_out_t *p_access, sout_buffer_t *p_buffer )
+int sout_AccessOutWrite( sout_access_out_t *p_access, sout_buffer_t *p_buffer )
{
return( p_access->pf_write( p_access, p_buffer ) );
}
int i_try;
/* search an stream output */
- for( i_try = 0; i_try < 200; i_try++ )
+ for( i_try = 0; i_try < 12; i_try++ )
{
p_sout = vlc_object_find( p_this, VLC_OBJECT_SOUT, FIND_ANYWHERE );
if( !p_sout )
msg_Err( p_this, "cannot find any stream ouput" );
return( NULL );
}
+ if( !p_sout->p_sys->b_add_stream_any_time && !p_sout->p_sys->b_waiting_stream)
+ {
+ msg_Err( p_sout, "cannot add a new stream (unsuported while muxing for this format)" );
+ return( NULL );
+ }
msg_Dbg( p_sout, "adding a new input" );
+ if( p_sout->p_sys->i_add_stream_start < 0 )
+ {
+ /* we wait for one second */
+ p_sout->p_sys->i_add_stream_start = mdate();
+ }
/* create a new sout input */
p_input = malloc( sizeof( sout_input_t ) );
int sout_InputSendBuffer( sout_input_t *p_input, sout_buffer_t *p_buffer )
{
+ sout_instance_sys_t *p_sys = p_input->p_sout->p_sys;
/* msg_Dbg( p_input->p_sout,
"send buffer, size:%d", p_buffer->i_size ); */
{
sout_FifoPut( p_input->p_fifo, p_buffer );
+ if( p_sys->b_waiting_stream )
+ {
+ if( p_sys->i_add_stream_start > 0 &&
+ p_sys->i_add_stream_start + (mtime_t)1000000 < mdate() )
+ {
+ /* more than 1 second, start muxing */
+ p_sys->b_waiting_stream = VLC_FALSE;
+ }
+ else
+ {
+ return( 0 );
+ }
+ }
vlc_mutex_lock( &p_input->p_sout->lock );
p_input->p_sout->pf_mux( p_input->p_sout );
vlc_mutex_unlock( &p_input->p_sout->lock );
-
}
else
{