Commit 5363e037 authored by Laurent Aimar's avatar Laurent Aimar

* all: lot of cosmetics, and added a MUX_GET_MIME (not yet used).

parent 7fdad1d9
......@@ -29,21 +29,51 @@
#include "vlc_es.h"
/****************************************************************************
* sout_instance_t: p_sout
****************************************************************************/
struct sout_instance_t
{
VLC_COMMON_MEMBERS
typedef struct sout_stream_id_t sout_stream_id_t;
char *psz_sout;
char *psz_chain;
/* for mux */
struct sout_input_t
{
sout_instance_t *p_sout;
/* meta data (Read only) XXX it won't be set before the first packet received */
vlc_meta_t *p_meta;
es_format_t *p_fmt;
block_fifo_t *p_fifo;
int i_out_pace_nocontrol; /* count of output that can't control the space */
void *p_sys;
vlc_mutex_t lock;
sout_stream_t *p_stream;
/* sout private */
sout_instance_sys_t *p_sys;
};
/* for packetizer */
/****************************************************************************
* sout_cfg_t:
****************************************************************************/
struct sout_cfg_t
{
sout_cfg_t *p_next;
char *psz_name;
char *psz_value;
};
#define sout_CfgParse( a, b, c, d ) __sout_CfgParse( VLC_OBJECT(a), b, c, d )
VLC_EXPORT( void, __sout_CfgParse, ( vlc_object_t *, char *psz_prefix, const char **ppsz_options, sout_cfg_t * ) );
VLC_EXPORT( char *, sout_CfgCreate, ( char **, sout_cfg_t **, char * ) );
/****************************************************************************
* sout_stream_id_t: opaque (private for all sout_stream_t)
****************************************************************************/
typedef struct sout_stream_id_t sout_stream_id_t;
/****************************************************************************
* sout_packetizer_input_t: p_sout <-> p_packetizer
****************************************************************************/
struct sout_packetizer_input_t
{
sout_instance_t *p_sout;
......@@ -53,12 +83,17 @@ struct sout_packetizer_input_t
sout_stream_id_t *id;
};
#define sout_NewInstance(a,b) __sout_NewInstance(VLC_OBJECT(a),b)
VLC_EXPORT( sout_instance_t *, __sout_NewInstance, ( vlc_object_t *, char * ) );
VLC_EXPORT( void, sout_DeleteInstance, ( sout_instance_t * ) );
#define SOUT_METHOD_NONE 0x00
#define SOUT_METHOD_FILE 0x10
#define SOUT_METHOD_NETWORK 0x20
VLC_EXPORT( sout_packetizer_input_t *, sout_InputNew,( sout_instance_t *, es_format_t * ) );
VLC_EXPORT( int, sout_InputDelete, ( sout_packetizer_input_t * ) );
VLC_EXPORT( int, sout_InputSendBuffer, ( sout_packetizer_input_t *, block_t* ) );
typedef struct sout_access_out_sys_t sout_access_out_sys_t;
/****************************************************************************
* sout_access_out_t:
****************************************************************************/
struct sout_access_out_t
{
VLC_COMMON_MEMBERS
......@@ -77,24 +112,15 @@ struct sout_access_out_t
int (*pf_write)( sout_access_out_t *, block_t * );
};
/*
* i_query parameter of pf_mux_capacity
*/
/* SOUT_MUX_CAP_GET_ADD_STREAM_ANY_TIME: p_args=NULL, p_answer=&boolean */
#define SOUT_MUX_CAP_GET_ADD_STREAM_ANY_TIME 0x01
/* SOUT_MUX_CAP_GET_STREAMABLE: p_args=NULL, p_answer=&boolean */
#define SOUT_MUX_CAP_GET_STREAMABLE 0x02
/* SOUT_MUX_CAP_GET_ADD_STREAM_WAIT: p_args=NULL, p_answer=&boolean */
#define SOUT_MUX_CAP_GET_ADD_STREAM_WAIT 0x03
/*
* return error code
*/
#define SOUT_MUX_CAP_ERR_OK 0x00
#define SOUT_MUX_CAP_ERR_UNKNOWN 0x01
#define SOUT_MUX_CAP_ERR_UNIMPLEMENTED 0x02
typedef struct sout_mux_sys_t sout_mux_sys_t;
VLC_EXPORT( sout_access_out_t *,sout_AccessOutNew, ( sout_instance_t *, char *psz_access, char *psz_name ) );
VLC_EXPORT( void, sout_AccessOutDelete, ( sout_access_out_t * ) );
VLC_EXPORT( int, sout_AccessOutSeek, ( sout_access_out_t *, off_t ) );
VLC_EXPORT( int, sout_AccessOutRead, ( sout_access_out_t *, block_t * ) );
VLC_EXPORT( int, sout_AccessOutWrite, ( sout_access_out_t *, block_t * ) );
/****************************************************************************
* mux:
****************************************************************************/
struct sout_mux_t
{
VLC_COMMON_MEMBERS
......@@ -107,10 +133,10 @@ struct sout_mux_t
sout_access_out_t *p_access;
int (*pf_capacity)( sout_mux_t *, int, void *, void *);
int (*pf_addstream)( sout_mux_t *, sout_input_t * );
int (*pf_delstream)( sout_mux_t *, sout_input_t * );
int (*pf_mux) ( sout_mux_t * );
int (*pf_control) ( sout_mux_t *, int, va_list );
/* here are all inputs accepted by muxer */
int i_nb_inputs;
......@@ -129,17 +155,46 @@ struct sout_mux_t
mtime_t i_add_stream_start;
};
enum sout_mux_query_e
{
/* capabilities */
MUX_CAN_ADD_STREAM_WHILE_MUXING, /* arg1= vlc_bool_t *, res=cannot fail */
/* properties */
MUX_GET_ADD_STREAM_WAIT, /* arg1= vlc_bool_t *, res=cannot fail */
MUX_GET_MIME, /* arg1= char ** res=can fail */
};
struct sout_cfg_t
struct sout_input_t
{
sout_cfg_t *p_next;
sout_instance_t *p_sout;
char *psz_name;
char *psz_value;
es_format_t *p_fmt;
block_fifo_t *p_fifo;
void *p_sys;
};
typedef struct sout_stream_sys_t sout_stream_sys_t;
VLC_EXPORT( sout_mux_t *, sout_MuxNew, ( sout_instance_t*, char *, sout_access_out_t * ) );
VLC_EXPORT( sout_input_t *, sout_MuxAddStream, ( sout_mux_t *, es_format_t * ) );
VLC_EXPORT( void, sout_MuxDeleteStream, ( sout_mux_t *, sout_input_t * ) );
VLC_EXPORT( void, sout_MuxDelete, ( sout_mux_t * ) );
VLC_EXPORT( void, sout_MuxSendBuffer, ( sout_mux_t *, sout_input_t *, block_t * ) );
static inline int sout_MuxControl( sout_mux_t *p_mux, int i_query, ... )
{
va_list args;
int i_result;
va_start( args, i_query );
i_result = p_mux->pf_control( p_mux, i_query, args );
va_end( args );
return i_result;
}
/****************************************************************************
* sout_stream:
****************************************************************************/
struct sout_stream_t
{
VLC_COMMON_MEMBERS
......@@ -161,31 +216,25 @@ struct sout_stream_t
sout_stream_sys_t *p_sys;
};
typedef struct sout_instance_sys_t sout_instance_sys_t;
struct sout_instance_t
{
VLC_COMMON_MEMBERS
char *psz_sout;
char *psz_chain;
/* meta data (Read only) XXX it won't be set before the first packet received */
vlc_meta_t *p_meta;
int i_out_pace_nocontrol; /* count of output that can't control the space */
vlc_mutex_t lock;
sout_stream_t *p_stream;
/* sout private */
sout_instance_sys_t *p_sys;
};
/* Announce handler structures */
VLC_EXPORT( sout_stream_t *, sout_StreamNew, ( sout_instance_t *, char *psz_chain ) );
VLC_EXPORT( void, sout_StreamDelete, ( sout_stream_t * ) );
/* Session and method descriptors */
static inline sout_stream_id_t *sout_StreamIdAdd( sout_stream_t *s, es_format_t *fmt )
{
return s->pf_add( s, fmt );
}
static inline int sout_StreamIdDel( sout_stream_t *s, sout_stream_id_t *id )
{
return s->pf_del( s, id );
}
static inline int sout_StreamIdSend( sout_stream_t *s, sout_stream_id_t *id, block_t *b )
{
return s->pf_send( s, id, b );
}
/****************************************************************************
* Announce handler mess
****************************************************************************/
struct sap_session_t;
struct session_descriptor_t
......@@ -308,38 +357,6 @@ static inline char *sout_cfg_find_value( sout_cfg_t *p_cfg, char *psz_name )
return NULL;
}
/*****************************************************************************
* Prototypes
*****************************************************************************/
#define sout_NewInstance(a,b) __sout_NewInstance(VLC_OBJECT(a),b)
VLC_EXPORT( sout_instance_t *, __sout_NewInstance, ( vlc_object_t *, char * ) );
VLC_EXPORT( void, sout_DeleteInstance, ( sout_instance_t * ) );
VLC_EXPORT( sout_packetizer_input_t *, sout_InputNew,( sout_instance_t *, es_format_t * ) );
VLC_EXPORT( int, sout_InputDelete, ( sout_packetizer_input_t * ) );
VLC_EXPORT( int, sout_InputSendBuffer, ( sout_packetizer_input_t *, block_t* ) );
VLC_EXPORT( sout_access_out_t *,sout_AccessOutNew, ( sout_instance_t *, char *psz_access, char *psz_name ) );
VLC_EXPORT( void, sout_AccessOutDelete, ( sout_access_out_t * ) );
VLC_EXPORT( int, sout_AccessOutSeek, ( sout_access_out_t *, off_t ) );
VLC_EXPORT( int, sout_AccessOutRead, ( sout_access_out_t *, block_t * ) );
VLC_EXPORT( int, sout_AccessOutWrite, ( sout_access_out_t *, block_t * ) );
VLC_EXPORT( sout_mux_t *, sout_MuxNew, ( sout_instance_t*, char *, sout_access_out_t * ) );
VLC_EXPORT( sout_input_t *, sout_MuxAddStream, ( sout_mux_t *, es_format_t * ) );
VLC_EXPORT( void, sout_MuxDeleteStream, ( sout_mux_t *, sout_input_t * ) );
VLC_EXPORT( void, sout_MuxDelete, ( sout_mux_t * ) );
VLC_EXPORT( void, sout_MuxSendBuffer, ( sout_mux_t *, sout_input_t *, block_t * ) );
#define sout_ParseCfg( a, b, c, d ) __sout_ParseCfg( VLC_OBJECT(a), b, c, d )
VLC_EXPORT( void, __sout_ParseCfg, ( vlc_object_t *, char *psz_prefix, const char **ppsz_options, sout_cfg_t * ) );
VLC_EXPORT( char *, sout_cfg_parser, ( char **, sout_cfg_t **, char * ) );
VLC_EXPORT( sout_stream_t *, sout_stream_new, ( sout_instance_t *, char *psz_chain ) );
VLC_EXPORT( void, sout_stream_delete, ( sout_stream_t *p_stream ) );
/* Announce system */
VLC_EXPORT( int, sout_AnnounceRegister, (sout_instance_t *,session_descriptor_t*, announce_method_t* ) );
VLC_EXPORT(session_descriptor_t*,sout_AnnounceRegisterSDP, (sout_instance_t *,char *, announce_method_t* ) );
......
......@@ -39,7 +39,7 @@
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static void sout_cfg_free( sout_cfg_t * );
static void sout_CfgDestroy( sout_cfg_t * );
#define sout_stream_url_to_chain( p, s ) _sout_stream_url_to_chain( VLC_OBJECT(p), s )
static char *_sout_stream_url_to_chain( vlc_object_t *, char * );
......@@ -138,7 +138,7 @@ sout_instance_t *__sout_NewInstance( vlc_object_t *p_parent, char * psz_dest )
/* attach it for inherit */
vlc_object_attach( p_sout, p_parent );
p_sout->p_stream = sout_stream_new( p_sout, p_sout->psz_chain );
p_sout->p_stream = sout_StreamNew( p_sout, p_sout->psz_chain );
if( p_sout->p_stream == NULL )
{
......@@ -163,7 +163,7 @@ void sout_DeleteInstance( sout_instance_t * p_sout )
vlc_object_detach( p_sout );
/* remove the stream out chain */
sout_stream_delete( p_sout->p_stream );
sout_StreamDelete( p_sout->p_stream );
/* *** free all string *** */
FREE( p_sout->psz_sout );
......@@ -282,7 +282,7 @@ sout_access_out_t *sout_AccessOutNew( sout_instance_t *p_sout,
return NULL;
}
psz_next = sout_cfg_parser( &p_access->psz_access, &p_access->p_cfg,
psz_next = sout_CfgCreate( &p_access->psz_access, &p_access->p_cfg,
psz_access );
if( psz_next )
{
......@@ -323,7 +323,7 @@ void sout_AccessOutDelete( sout_access_out_t *p_access )
}
free( p_access->psz_access );
sout_cfg_free( p_access->p_cfg );
sout_CfgDestroy( p_access->p_cfg );
free( p_access->psz_name );
......@@ -373,13 +373,13 @@ sout_mux_t * sout_MuxNew( sout_instance_t *p_sout, char *psz_mux,
}
p_mux->p_sout = p_sout;
psz_next = sout_cfg_parser( &p_mux->psz_mux, &p_mux->p_cfg, psz_mux );
psz_next = sout_CfgCreate( &p_mux->psz_mux, &p_mux->p_cfg, psz_mux );
if( psz_next )
{
free( psz_next );
}
p_mux->p_access = p_access;
p_mux->pf_capacity = NULL;
p_mux->pf_control = NULL;
p_mux->pf_addstream = NULL;
p_mux->pf_delstream = NULL;
p_mux->pf_mux = NULL;
......@@ -404,12 +404,10 @@ sout_mux_t * sout_MuxNew( sout_instance_t *p_sout, char *psz_mux,
}
/* *** probe mux capacity *** */
if( p_mux->pf_capacity )
if( p_mux->pf_control )
{
int b_answer;
if( p_mux->pf_capacity( p_mux,
SOUT_MUX_CAP_GET_ADD_STREAM_ANY_TIME, NULL,
(void*)&b_answer ) != SOUT_MUX_CAP_ERR_OK )
if( sout_MuxControl( p_mux, MUX_CAN_ADD_STREAM_WHILE_MUXING, &b_answer ) )
{
b_answer = VLC_FALSE;
}
......@@ -419,9 +417,7 @@ sout_mux_t * sout_MuxNew( sout_instance_t *p_sout, char *psz_mux,
p_mux->b_add_stream_any_time = VLC_TRUE;
p_mux->b_waiting_stream = VLC_FALSE;
if( p_mux->pf_capacity( p_mux,
SOUT_MUX_CAP_GET_ADD_STREAM_WAIT, NULL,
(void*)&b_answer ) != SOUT_MUX_CAP_ERR_OK )
if( sout_MuxControl( p_mux, MUX_GET_ADD_STREAM_WAIT, &b_answer ) )
{
b_answer = VLC_FALSE;
}
......@@ -460,7 +456,7 @@ void sout_MuxDelete( sout_mux_t *p_mux )
}
free( p_mux->psz_mux );
sout_cfg_free( p_mux->p_cfg );
sout_CfgDestroy( p_mux->p_cfg );
vlc_object_destroy( p_mux );
}
......@@ -748,7 +744,7 @@ static char *_get_chain_end( char *str )
}
}
char *sout_cfg_parser( char **ppsz_name, sout_cfg_t **pp_cfg, char *psz_chain )
char *sout_CfgCreate( char **ppsz_name, sout_cfg_t **pp_cfg, char *psz_chain )
{
sout_cfg_t *p_cfg = NULL;
char *p = psz_chain;
......@@ -880,7 +876,7 @@ char *sout_cfg_parser( char **ppsz_name, sout_cfg_t **pp_cfg, char *psz_chain )
return NULL;
}
static void sout_cfg_free( sout_cfg_t *p_cfg )
static void sout_CfgDestroy( sout_cfg_t *p_cfg )
{
while( p_cfg != NULL )
{
......@@ -896,7 +892,7 @@ static void sout_cfg_free( sout_cfg_t *p_cfg )
}
}
void __sout_ParseCfg( vlc_object_t *p_this, char *psz_prefix,
void __sout_CfgParse( vlc_object_t *p_this, char *psz_prefix,
const char **ppsz_options, sout_cfg_t *cfg )
{
char *psz_name;
......@@ -999,7 +995,7 @@ void __sout_ParseCfg( vlc_object_t *p_this, char *psz_prefix,
/*
* XXX name and p_cfg are used (-> do NOT free them)
*/
sout_stream_t *sout_stream_new( sout_instance_t *p_sout, char *psz_chain )
sout_stream_t *sout_StreamNew( sout_instance_t *p_sout, char *psz_chain )
{
sout_stream_t *p_stream;
......@@ -1021,7 +1017,7 @@ sout_stream_t *sout_stream_new( sout_instance_t *p_sout, char *psz_chain )
p_stream->p_sys = NULL;
p_stream->psz_next =
sout_cfg_parser( &p_stream->psz_name, &p_stream->p_cfg, psz_chain);
sout_CfgCreate( &p_stream->psz_name, &p_stream->p_cfg, psz_chain);
msg_Dbg( p_sout, "stream=`%s'", p_stream->psz_name );
......@@ -1032,14 +1028,14 @@ sout_stream_t *sout_stream_new( sout_instance_t *p_sout, char *psz_chain )
if( !p_stream->p_module )
{
sout_stream_delete( p_stream );
sout_StreamDelete( p_stream );
return NULL;
}
return p_stream;
}
void sout_stream_delete( sout_stream_t *p_stream )
void sout_StreamDelete( sout_stream_t *p_stream )
{
msg_Dbg( p_stream, "destroying chain... (name=%s)", p_stream->psz_name );
......@@ -1049,7 +1045,7 @@ void sout_stream_delete( sout_stream_t *p_stream )
FREE( p_stream->psz_name );
FREE( p_stream->psz_next );
sout_cfg_free( p_stream->p_cfg );
sout_CfgDestroy( p_stream->p_cfg );
msg_Dbg( p_stream, "destroying chain done" );
vlc_object_destroy( p_stream );
......
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