#include <vlc/vlc.h>
+/***********************************************************************
+ * Predefined lists of streaming data
+ ***********************************************************************/
+
#ifdef WIN32
#define VCODECS_NUMBER 13
#else
#define MUXERS_NUMBER 10
enum
{
- MUX_PS,
- MUX_TS,
- MUX_MPEG,
- MUX_OGG,
- MUX_RAW,
- MUX_ASF,
- MUX_AVI,
- MUX_MP4,
- MUX_MOV,
- MUX_WAV,
+ MUX_PS, MUX_TS, MUX_MPEG, MUX_OGG, MUX_RAW,
+ MUX_ASF, MUX_AVI, MUX_MP4, MUX_MOV, MUX_WAV,
};
-enum
-{
- ACCESS_HTTP,
- ACCESS_UDP,
- ACCESS_MMS,
- ACCESS_RTP,
- ACCESS_FILE
-};
+enum { ACCESS_HTTP, ACCESS_UDP, ACCESS_MMS, ACCESS_RTP, ACCESS_FILE };
struct codec_desc_t {
char *psz_display;
//static const char *abitrates_array[] =
//{ "512", "256", "192", "128", "96", "64", "32", "16" } ;
+//
+
+
+/***********************************************************************
+ * Streaming profiles
+ ***********************************************************************/
+
+/****************** Parameters handling *********************/
+struct sout_param_t
+{
+ int i_type;
+ int i_element;
+ char *psz_id;
+ char *psz_string;
+ vlc_value_t value;
+};
+
+struct sout_pcat_t
+{
+ char *psz_name;
+ int i_params;
+ sout_param_t **pp_params;
+};
+void streaming_ParameterApply( sout_param_t *p_param, char **ppsz_dest,
+ int *pi_dest, float *pf_dest, vlc_bool_t *pb_dest );
+
+
+/******** Module types definitions and parametrable elements ***************/
+
+/* Transcode */
+enum { I_VB, I_AB, I_CHANNELS, F_SCALE, B_SOVERLAY, PSZ_VC, PSZ_AC, PSZ_SC,
+ PSZ_VE, PSZ_AE };
struct sout_transcode_t
{
int i_vb, i_ab, i_channels;
vlc_bool_t b_soverlay;
char *psz_vcodec, *psz_acodec, *psz_scodec, *psz_venc, *psz_aenc;
char *psz_additional;
+
+ int i_params; sout_param_t **pp_params;
};
+void streaming_TranscodeParametersApply( sout_transcode_t *p_module );
-struct sout_std_t
+/* Standard */
+enum { PSZ_MUX, PSZ_ACCESS, PSZ_URL, PSZ_NAME, PSZ_GROUP };
+struct sout_std_t
{
char *psz_mux, *psz_access;
char *psz_url, *psz_name, *psz_group;
+ int i_params; sout_param_t **pp_params;
};
+void streaming_StdParametersApply( sout_std_t *p_module );
-struct sout_display_t
+/* Display */
+struct sout_display_t
{
};
+/* Duplicate */
struct sout_duplicate_t
{
int i_children, i_conditions;
char **ppsz_conditions;
};
+/******* Generic profile structures and manipulation functions ********/
typedef union
{
sout_transcode_t *p_transcode;
sout_display_t *p_display;
} sout_module_type_t;
-
struct sout_module_t
{
int i_type;
sout_module_t *p_parent;
};
-enum
-{
- SOUT_MOD_TRANSCODE,
- SOUT_MOD_STD,
- SOUT_MOD_RTP,
- SOUT_MOD_DUPLICATE,
- SOUT_MOD_DISPLAY
-};
+enum { SOUT_MOD_TRANSCODE, SOUT_MOD_STD, SOUT_MOD_RTP, SOUT_MOD_DUPLICATE,
+ SOUT_MOD_DISPLAY };
struct sout_chain_t
{
int i_options;
char **ppsz_options;
+
+ int i_pcats;
+ sout_pcat_t **pp_pcats;
};
-struct sout_gui_descr_t
+static inline sout_chain_t *streaming_ChainNew()
+{
+ DECMALLOC_NULL( p_chain, sout_chain_t );
+ memset( p_chain, 0, sizeof( sout_chain_t ) );
+ p_chain->i_options = 0;
+ return p_chain;
+}
+
+struct streaming_profile_t
+{
+ char *psz_title;
+ char *psz_description;
+ sout_chain_t *p_chain;
+};
+
+/**************** GUI interaction *****************/
+struct sout_gui_descr_t
{
/* Access */
vlc_bool_t b_local, b_file, b_http, b_mms, b_rtp, b_udp, b_dump;
int i_ttl;
};
-struct streaming_profile_t
-{
- i18n_string_t *p_title;
- i18n_string_t *p_description;
- sout_chain_t *p_chain;
-};
-
-static inline sout_chain_t *streaming_ChainNew()
-{
- DECMALLOC_NULL( p_chain, sout_chain_t );
- memset( p_chain, 0, sizeof( sout_chain_t ) );
- p_chain->i_options = 0;
- return p_chain;
-}
-
+/***************** Profile parsing ***********************/
struct profile_parser_t
{
streaming_profile_t *p_profile;
};
-
-
-//VLC_XEXPORT( char *, streaming_ChainToPsz, (sout_chain_t * ) );
-
#endif
* Copyright (C) 2006 the VideoLAN team
* $Id$
*
- * Authors: Cl�ent Stenac <zorglub@videolan.org>
+ * Authors: Clément Stenac <zorglub@videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
/**********************************************************************
* General chain manipulation
**********************************************************************/
+/** Add a new duplicate element to a streaming chain
+ * \return the new element
+ */
sout_duplicate_t *streaming_ChainAddDup( sout_chain_t *p_chain )
{
DECMALLOC_NULL( p_module, sout_module_t );
p_module->i_type = SOUT_MOD_DUPLICATE;
DUPM->i_children = 0;
DUPM->pp_children = NULL;
- INSERT_ELEM( p_chain->pp_modules, p_chain->i_modules, p_chain->i_modules,
- p_module );
- return p_module->typed.p_duplicate;
+ TAB_APPEND( p_chain->i_modules, p_chain->pp_modules, p_module );
+ return DUPM;
}
+/** Add a new standard element to a streaming chain
+ * \return the new element
+ */
sout_std_t *streaming_ChainAddStd( sout_chain_t *p_chain, char *psz_access,
char *psz_mux, char *psz_url )
{
STDM->psz_mux = strdup( psz_mux );
STDM->psz_access = strdup( psz_access );
STDM->psz_url = strdup( psz_url );
- INSERT_ELEM( p_chain->pp_modules, p_chain->i_modules, p_chain->i_modules,
- p_module );
+ TAB_APPEND( p_chain->i_modules, p_chain->pp_modules, p_module );
return STDM;
}
-
+/** Add a new display element to a streaming chain
+ * \return the new element
+ */
sout_display_t *streaming_ChainAddDisplay( sout_chain_t *p_chain )
{
DECMALLOC_NULL( p_module, sout_module_t );
MALLOC_NULL( DISM, sout_display_t );
p_module->i_type = SOUT_MOD_DISPLAY;
+ TAB_APPEND( p_chain->i_modules, p_chain->pp_modules, p_module );
return DISM;
}
+/** Add a new transcode element to a streaming chain
+ * \return the new element
+ */
sout_transcode_t *streaming_ChainAddTranscode( sout_chain_t *p_chain,
char *psz_vcodec, char * psz_acodec, char * psz_scodec,
- int i_vb, float f_scale, int i_ab, int i_channels,
+ int i_vb, float f_scale, int i_ab, int i_channels,
vlc_bool_t b_soverlay, char *psz_additional )
{
DECMALLOC_NULL( p_module, sout_module_t );
TRAM->i_vb = i_vb; TRAM->i_ab = i_ab; TRAM->f_scale = f_scale;
TRAM->i_channels = i_channels; TRAM->b_soverlay = b_soverlay;
if( TRAM->psz_additional ) TRAM->psz_additional = strdup( psz_additional );
+ TAB_APPEND( p_chain->i_modules, p_chain->pp_modules, p_module );
return TRAM;
}
-
+
+/** Add a new clean child chain to an existing duplicate element */
void streaming_DupAddChild( sout_duplicate_t *p_dup )
{
- if( p_dup )
- {
- sout_chain_t * p_child = streaming_ChainNew();
- INSERT_ELEM( p_dup->pp_children, p_dup->i_children,
- p_dup->i_children, p_child );
- }
+ assert( p_dup );
+ sout_chain_t * p_child = streaming_ChainNew();
+ TAB_APPEND( p_dup->i_children, p_dup->pp_children, p_child );
}
#define DUP_OR_CHAIN p_dup ? p_dup->pp_children[p_dup->i_children-1] : p_chain
psz_opt );\
free( psz_opt ); }
+/** Clean up a chain (recursively if it has some children) */
void streaming_ChainClean( sout_chain_t *p_chain )
{
int i,j;
case SOUT_MOD_DUPLICATE:
if( DUPM->i_children == 0 ) break;
for( j = DUPM->i_children - 1 ; j >= 0; j-- )
- {
streaming_ChainClean( DUPM->pp_children[j] );
- }
break;
case SOUT_MOD_STD:
FREENULL( STDM->psz_url );
}
}
+/**********************************************************************
+ * Parameters handling
+ **********************************************************************/
+
+#define APPLY_PSZ( element, field ) case element: \
+streaming_ParameterApply( p_param, &p_module->field, NULL, NULL, NULL ); break;
+#define APPLY_INT( element, field ) case element: \
+streaming_ParameterApply( p_param, NULL, &p_module->field, NULL, NULL ); break;
+#define APPLY_FLOAT( element, field ) case element: \
+streaming_ParameterApply( p_param, NULL, NULL, &p_module->field, NULL ); break;
+#define APPLY_BOOL( element, field ) case element: \
+streaming_ParameterApply( p_param, NULL, NULL, NULL, &p_module->field ); break;
+
+/** Apply the parameters for the Std module. It will copy the values from
+ * the parameters to the fields themselves
+ */
+void streaming_StdParametersApply( sout_std_t *p_module )
+{
+ int i;
+ for( i = 0 ; i< p_module->i_params; i++ )
+ {
+ sout_param_t *p_param = p_module->pp_params[i];
+ switch( p_param->i_element )
+ {
+ APPLY_PSZ( PSZ_MUX, psz_mux );
+ APPLY_PSZ( PSZ_ACCESS, psz_access );
+ APPLY_PSZ( PSZ_URL, psz_url );
+ APPLY_PSZ( PSZ_NAME, psz_name );
+ APPLY_PSZ( PSZ_GROUP, psz_group );
+ }
+ }
+}
+
+/** Apply the parameters for the Transcode module. It will copy the values from
+ * the parameters to the fields themselves
+ */
+void streaming_TranscodeParametersApply( sout_transcode_t *p_module )
+{
+ int i;
+ for( i = 0 ; i< p_module->i_params; i++ )
+ {
+ sout_param_t *p_param = p_module->pp_params[i];
+ switch( p_param->i_element )
+ {
+ APPLY_INT( I_VB, i_vb ); APPLY_INT( I_AB, i_ab );
+ APPLY_INT( I_CHANNELS, i_channels ) ;
+ APPLY_FLOAT( F_SCALE, f_scale );
+ APPLY_BOOL( B_SOVERLAY, b_soverlay );
+ APPLY_PSZ( PSZ_VC, psz_vcodec );
+ APPLY_PSZ( PSZ_AC, psz_acodec );
+ APPLY_PSZ( PSZ_SC, psz_scodec );
+ APPLY_PSZ( PSZ_VE, psz_venc ); APPLY_PSZ( PSZ_AE, psz_aenc );
+ }
+ }
+}
+
+/** Apply a single parameter
+ * \param p_param the parameter to apply
+ * \param ppsz_dest target string, if param is a string
+ * \param pi_dest target int, if param is an integer
+ * \param pf_dest target float, if param is a float
+ * \param pb_dest target bool, if param is a bool
+ */
+void streaming_ParameterApply( sout_param_t *p_param, char **ppsz_dest,
+ int *pi_dest, float *pf_dest, vlc_bool_t *pb_dest )
+{
+ /* Todo : Handle psz_string like formatting */
+ if( p_param->psz_string )
+ {
+ assert( ppsz_dest );
+ fprintf( stderr, "Unsupported !\n" );
+ }
+ else
+ {
+ switch( p_param->i_type )
+ {
+ case VLC_VAR_INTEGER:
+ assert( pi_dest );
+ *pi_dest = p_param->value.i_int;
+ break;
+ case VLC_VAR_FLOAT:
+ assert( pf_dest );
+ *pf_dest = p_param->value.f_float;
+ break;
+ case VLC_VAR_STRING:
+ assert( ppsz_dest );
+ FREENULL( **ppsz_dest );
+ *ppsz_dest = p_param->value.psz_string ?
+ strdup( p_param->value.psz_string ) :
+ NULL;
+ break;
+ case VLC_VAR_BOOL:
+ assert( pb_dest );
+ *pb_dest = p_param->value.b_bool;
+ break;
+ }
+ }
+}
+
/**********************************************************************
* Interaction with streaming GUI descriptors
**********************************************************************/
/**
- * Try to convert a chain to a gui descriptor. This is only possible for
- * "simple" chains.
+ * Try to convert a chain to a gui descriptor. This is only possible for
+ * "simple" chains.
* \param p_this vlc object
* \param p_chain the source streaming chain
* \param pd the destination gui descriptor object
if( p_chain->pp_modules[i_last]->i_type == SOUT_MOD_DUPLICATE )
{
p_module = p_chain->pp_modules[i_last];
-
+
// Nothing allowed after duplicate. Duplicate mustn't be empty
- if( p_chain->i_modules > i_last +1 || !DUPM->i_children )
+ if( p_chain->i_modules > i_last +1 || !DUPM->i_children )
return VLC_FALSE;
for( j = 0 ; j< DUPM->i_children ; j++ )
{
{
streaming_ChainAddTranscode( p_chain, pd->psz_vcodec, pd->psz_acodec,
pd->psz_scodec, pd->i_vb, pd->f_scale,
- pd->i_ab, pd->i_channels,
+ pd->i_ab, pd->i_channels,
pd->b_soverlay, NULL );
}
/* #std{} */
- if( pd->b_local + pd->b_file + pd->b_http + pd->b_mms + pd->b_rtp +
+ if( pd->b_local + pd->b_file + pd->b_http + pd->b_mms + pd->b_rtp +
pd->b_udp > 1 )
{
p_dup = streaming_ChainAddDup( p_chain );
if( pd->b_sap )
{
pd->b_sap = VLC_TRUE;
- p_std->psz_name = strdup( pd->psz_name );
+ p_std->psz_name = strdup( pd->psz_name );
p_std->psz_group = pd->psz_group ? strdup( pd->psz_group ) : NULL;
}
}
/**
* List the available profiles. Fills the pp_profiles list with preinitialized
- * values. Only metadata is decoded
+ * values.
* \param p_this vlc object
* \param pi_profiles number of listed profiles
* \param pp_profiles array of profiles
*/
-void streaming_ProfilesList( vlc_object_t *p_this, int *pi_profiles,
+void streaming_ProfilesList( vlc_object_t *p_this, int *pi_profiles,
streaming_profile_t **pp_profiles )
{
}