Commit 6192caae authored by Clément Stenac's avatar Clément Stenac

* Handle parameters in streaming profiles

* Remove i18n_string stuff
parent 5a3ae4a1
......@@ -335,6 +335,8 @@ typedef struct announce_method_t announce_method_t;
typedef struct announce_handler_t announce_handler_t;
typedef struct sap_handler_t sap_handler_t;
typedef struct sout_param_t sout_param_t;
typedef struct sout_pcat_t sout_pcat_t;
typedef struct sout_std_t sout_std_t;
typedef struct sout_display_t sout_display_t;
typedef struct sout_duplicate_t sout_duplicate_t;
......@@ -369,8 +371,6 @@ typedef struct iso639_lang_t iso639_lang_t;
typedef struct device_t device_t;
typedef struct device_probe_t device_probe_t;
typedef struct probe_sys_t probe_sys_t;
typedef struct localized_string_t localized_string_t;
typedef struct i18n_string_t i18n_string_t;
/* block */
typedef struct block_t block_t;
......
......@@ -26,6 +26,10 @@
#include <vlc/vlc.h>
/***********************************************************************
* Predefined lists of streaming data
***********************************************************************/
#ifdef WIN32
#define VCODECS_NUMBER 13
#else
......@@ -38,26 +42,11 @@
#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;
......@@ -93,7 +82,39 @@ struct mux_desc_t {
//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;
......@@ -101,18 +122,27 @@ struct sout_transcode_t
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 );
/* 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 );
/* Display */
struct sout_display_t
{
};
/* Duplicate */
struct sout_duplicate_t
{
int i_children, i_conditions;
......@@ -120,6 +150,7 @@ struct sout_duplicate_t
char **ppsz_conditions;
};
/******* Generic profile structures and manipulation functions ********/
typedef union
{
sout_transcode_t *p_transcode;
......@@ -128,7 +159,6 @@ typedef union
sout_display_t *p_display;
} sout_module_type_t;
struct sout_module_t
{
int i_type;
......@@ -136,14 +166,8 @@ struct sout_module_t
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
{
......@@ -152,8 +176,27 @@ struct sout_chain_t
int i_options;
char **ppsz_options;
int i_pcats;
sout_pcat_t **pp_pcats;
};
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 */
......@@ -176,21 +219,7 @@ struct sout_gui_descr_t
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
{
......@@ -198,8 +227,4 @@ struct profile_parser_t
streaming_profile_t *p_profile;
};
//VLC_XEXPORT( char *, streaming_ChainToPsz, (sout_chain_t * ) );
#endif
......@@ -34,38 +34,6 @@
VLC_EXPORT( void, resolve_xml_special_chars, ( char *psz_value ) );
VLC_EXPORT( char *, convert_xml_special_chars, ( const char *psz_content ) );
struct localized_string_t
{
char *psz_lang;
char *psz_text;
};
struct i18n_string_t
{
int i_langs;
localized_string_t **pp_langs;
};
static inline void i18n_AddLang( i18n_string_t *p_src,
char *psz_lang, char *psz_text )
{
DECMALLOC_VOID( pl10n, localized_string_t );
pl10n->psz_lang = strdup( psz_lang );
pl10n->psz_text = strdup( psz_text );
INSERT_ELEM( p_src->pp_langs, p_src->i_langs, p_src->i_langs, pl10n );
};
static inline char *i18n_Get( i18n_string_t *p_src, char *psz_lang )
{
int i;
for( i = 0 ; i < p_src->i_langs; i++ )
{
if( !strcmp( p_src->pp_langs[i]->psz_lang, psz_lang ) )
return p_src->pp_langs[i]->psz_text;
}
return strdup( "" );
};
/**
* @}
*/
......
......@@ -4,7 +4,7 @@
* Copyright (C) 2006 the VideoLAN team
* $Id$
*
* Authors: Clent 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
......@@ -37,6 +37,9 @@
/**********************************************************************
* 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 );
......@@ -44,11 +47,13 @@ sout_duplicate_t *streaming_ChainAddDup( sout_chain_t *p_chain )
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 )
{
......@@ -58,19 +63,24 @@ sout_std_t *streaming_ChainAddStd( sout_chain_t *p_chain, char *psz_access,
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,
......@@ -87,17 +97,16 @@ sout_transcode_t *streaming_ChainAddTranscode( sout_chain_t *p_chain,
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 )
{
assert( 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 );
}
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
......@@ -108,6 +117,7 @@ void streaming_DupAddChild( sout_duplicate_t *p_dup )
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;
......@@ -122,9 +132,7 @@ void streaming_ChainClean( sout_chain_t *p_chain )
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 );
......@@ -146,6 +154,105 @@ void streaming_ChainClean( sout_chain_t *p_chain )
}
}
/**********************************************************************
* 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
**********************************************************************/
......@@ -379,7 +486,7 @@ char * streaming_ChainToPsz( sout_chain_t *p_chain )
/**
* 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
......
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