Commit 81ad2fc1 authored by Clément Stenac's avatar Clément Stenac

Simplify transcode handling

parent 702a5518
...@@ -98,7 +98,7 @@ struct sout_transcode_t ...@@ -98,7 +98,7 @@ struct sout_transcode_t
{ {
int i_vb, i_ab, i_channels; int i_vb, i_ab, i_channels;
float f_scale; float f_scale;
vlc_bool_t b_audio, b_video, b_subtitles, b_soverlay; vlc_bool_t b_soverlay;
char *psz_vcodec, *psz_acodec, *psz_scodec, *psz_venc, *psz_aenc; char *psz_vcodec, *psz_acodec, *psz_scodec, *psz_venc, *psz_aenc;
char *psz_additional; char *psz_additional;
}; };
...@@ -115,9 +115,9 @@ struct sout_display_t ...@@ -115,9 +115,9 @@ struct sout_display_t
struct sout_duplicate_t struct sout_duplicate_t
{ {
int i_children; int i_children, i_conditions;
sout_chain_t **pp_children; sout_chain_t **pp_children;
/// Conditions char **ppsz_conditions;
}; };
typedef union typedef union
...@@ -165,7 +165,7 @@ struct sout_gui_descr_t ...@@ -165,7 +165,7 @@ struct sout_gui_descr_t
char *psz_mux; char *psz_mux;
/* Transcode */ /* Transcode */
vlc_bool_t b_video, b_audio, b_subtitles, b_soverlay; vlc_bool_t b_soverlay;
char *psz_vcodec, *psz_acodec, *psz_scodec; char *psz_vcodec, *psz_acodec, *psz_scodec;
int i_vb, i_ab, i_channels; int i_vb, i_ab, i_channels;
float f_scale; float f_scale;
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
*****************************************************************************/ *****************************************************************************/
#include <vlc_streaming.h> #include <vlc_streaming.h>
#include <assert.h>
#define MAX_CHAIN 32768 #define MAX_CHAIN 32768
#define CHAIN_APPEND( format, args... ) { \ #define CHAIN_APPEND( format, args... ) { \
...@@ -73,19 +74,19 @@ sout_display_t *streaming_ChainAddDisplay( sout_chain_t *p_chain ) ...@@ -73,19 +74,19 @@ sout_display_t *streaming_ChainAddDisplay( sout_chain_t *p_chain )
sout_transcode_t *streaming_ChainAddTranscode( sout_chain_t *p_chain, sout_transcode_t *streaming_ChainAddTranscode( sout_chain_t *p_chain,
char *psz_vcodec, char * psz_acodec, char * psz_scodec, 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,
char *psz_additional ) vlc_bool_t b_soverlay, char *psz_additional )
{ {
DECMALLOC_NULL( p_module, sout_module_t ); DECMALLOC_NULL( p_module, sout_module_t );
MALLOC_NULL( TRAM, sout_transcode_t ); MALLOC_NULL( TRAM, sout_transcode_t );
p_module->i_type = SOUT_MOD_TRANSCODE; p_module->i_type = SOUT_MOD_TRANSCODE;
if( psz_vcodec )
{ TRAM->b_video = VLC_TRUE; TRAM->psz_vcodec = strdup( psz_vcodec); } assert( !( b_soverlay && psz_scodec ) );
if( psz_acodec ) if( psz_vcodec ) TRAM->psz_vcodec = strdup( psz_vcodec );
{ TRAM->b_audio = VLC_TRUE; TRAM->psz_acodec = strdup( psz_acodec ); } if( psz_acodec ) TRAM->psz_acodec = strdup( psz_acodec );
TRAM->psz_scodec = strdup( psz_scodec ); if( psz_scodec ) TRAM->psz_scodec = strdup( psz_scodec );
TRAM->i_vb = i_vb; TRAM->i_ab = i_ab; TRAM->f_scale = f_scale; TRAM->i_vb = i_vb; TRAM->i_ab = i_ab; TRAM->f_scale = f_scale;
TRAM->i_channels = i_channels; TRAM->i_channels = i_channels; TRAM->b_soverlay = b_soverlay;
TRAM->psz_additional = strdup( psz_additional ); if( TRAM->psz_additional ) TRAM->psz_additional = strdup( psz_additional );
return TRAM; return TRAM;
} }
...@@ -129,7 +130,6 @@ void streaming_ChainClean( sout_chain_t *p_chain ) ...@@ -129,7 +130,6 @@ void streaming_ChainClean( sout_chain_t *p_chain )
FREENULL( STDM->psz_url ); FREENULL( STDM->psz_url );
FREENULL( STDM->psz_name ); FREENULL( STDM->psz_name );
FREENULL( STDM->psz_group ); FREENULL( STDM->psz_group );
memset( STDM, 0, sizeof( sout_std_t ) );
break; break;
case SOUT_MOD_TRANSCODE: case SOUT_MOD_TRANSCODE:
FREENULL( TRAM->psz_vcodec ); FREENULL( TRAM->psz_vcodec );
...@@ -137,10 +137,11 @@ void streaming_ChainClean( sout_chain_t *p_chain ) ...@@ -137,10 +137,11 @@ void streaming_ChainClean( sout_chain_t *p_chain )
FREENULL( TRAM->psz_scodec ); FREENULL( TRAM->psz_scodec );
FREENULL( TRAM->psz_venc ); FREENULL( TRAM->psz_venc );
FREENULL( TRAM->psz_aenc ); FREENULL( TRAM->psz_aenc );
memset( TRAM, 0, sizeof( sout_transcode_t ) ) ; FREENULL( TRAM->psz_additional );
break; break;
} }
REMOVE_ELEM( p_chain->pp_modules, p_chain->i_modules, i ); REMOVE_ELEM( p_chain->pp_modules, p_chain->i_modules, i );
free( p_module );
} }
} }
} }
...@@ -179,9 +180,8 @@ void streaming_ChainClean( sout_chain_t *p_chain ) ...@@ -179,9 +180,8 @@ void streaming_ChainClean( sout_chain_t *p_chain )
* \param pd the destination gui descriptor object * \param pd the destination gui descriptor object
* \return TRUE if the conversion succeeded, false else * \return TRUE if the conversion succeeded, false else
*/ */
vlc_bool_t streaming_ChainToGuiDesc( vlc_object_t *p_this, vlc_bool_t streaming_ChainToGuiDesc( vlc_object_t *p_this,
sout_chain_t *p_chain, sout_chain_t *p_chain, sout_gui_descr_t *pd )
sout_gui_descr_t *pd )
{ {
int j, i_last = 0; int j, i_last = 0;
sout_module_t *p_module; sout_module_t *p_module;
...@@ -193,13 +193,12 @@ vlc_bool_t streaming_ChainToGuiDesc( vlc_object_t *p_this, ...@@ -193,13 +193,12 @@ vlc_bool_t streaming_ChainToGuiDesc( vlc_object_t *p_this,
p_module = p_chain->pp_modules[0]; p_module = p_chain->pp_modules[0];
i_last++; i_last++;
pd->b_video = TRAM->b_video; pd->b_audio = TRAM->b_audio; pd->b_soverlay = TRAM->b_soverlay;
pd->b_subtitles = TRAM->b_subtitles; pd->b_soverlay = TRAM->b_soverlay;
pd->i_vb = TRAM->i_vb; pd->i_ab = TRAM->i_ab; pd->i_vb = TRAM->i_vb; pd->i_ab = TRAM->i_ab;
pd->i_channels = TRAM->i_channels; pd->f_scale = TRAM->f_scale; pd->i_channels = TRAM->i_channels; pd->f_scale = TRAM->f_scale;
pd->psz_vcodec = strdup( TRAM->psz_vcodec ); if( TRAM->psz_vcodec ) pd->psz_vcodec = strdup( TRAM->psz_vcodec );
pd->psz_acodec = strdup( TRAM->psz_acodec ); if( TRAM->psz_acodec ) pd->psz_acodec = strdup( TRAM->psz_acodec );
pd->psz_scodec = strdup( TRAM->psz_scodec ); if( TRAM->psz_scodec ) pd->psz_scodec = strdup( TRAM->psz_scodec );
} }
if( p_chain->pp_modules[i_last]->i_type == SOUT_MOD_DUPLICATE ) if( p_chain->pp_modules[i_last]->i_type == SOUT_MOD_DUPLICATE )
{ {
...@@ -271,11 +270,12 @@ void streaming_GuiDescToChain( vlc_object_t *p_obj, sout_chain_t *p_chain, ...@@ -271,11 +270,12 @@ void streaming_GuiDescToChain( vlc_object_t *p_obj, sout_chain_t *p_chain,
streaming_ChainClean( p_chain ); streaming_ChainClean( p_chain );
/* Transcode */ /* Transcode */
if( pd->b_video || pd->b_audio || pd->b_subtitles || pd->b_soverlay ) if( pd->psz_vcodec || pd->psz_acodec || pd->psz_scodec || pd->b_soverlay )
{ {
streaming_ChainAddTranscode( p_chain, pd->psz_vcodec, pd->psz_acodec, streaming_ChainAddTranscode( p_chain, pd->psz_vcodec, pd->psz_acodec,
pd->psz_scodec, pd->i_vb, pd->f_scale, pd->psz_scodec, pd->i_vb, pd->f_scale,
pd->i_ab, pd->i_channels, NULL ); pd->i_ab, pd->i_channels,
pd->b_soverlay, NULL );
} }
/* #std{} */ /* #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 +
...@@ -340,22 +340,22 @@ char * streaming_ChainToPsz( sout_chain_t *p_chain ) ...@@ -340,22 +340,22 @@ char * streaming_ChainToPsz( sout_chain_t *p_chain )
{ {
case SOUT_MOD_TRANSCODE: case SOUT_MOD_TRANSCODE:
CHAIN_APPEND( "transcode{" ); CHAIN_APPEND( "transcode{" );
if( TRAM->b_video ) if( TRAM->psz_vcodec )
{ {
CHAIN_APPEND( "vcodec=%s,vb=%i,scale=%f", TRAM->psz_vcodec, CHAIN_APPEND( "vcodec=%s,vb=%i,scale=%f", TRAM->psz_vcodec,
TRAM->i_vb, TRAM->f_scale ); TRAM->i_vb, TRAM->f_scale );
if( TRAM->b_audio || TRAM->b_subtitles || TRAM->b_soverlay ) if( TRAM->psz_acodec || TRAM->psz_scodec || TRAM->b_soverlay )
CHAIN_APPEND( "," ); CHAIN_APPEND( "," );
} }
if( TRAM->b_audio ) if( TRAM->psz_acodec )
{ {
CHAIN_APPEND( "acodec=%s,ab=%i,channels=%i", TRAM->psz_acodec, CHAIN_APPEND( "acodec=%s,ab=%i,channels=%i", TRAM->psz_acodec,
TRAM->i_ab, TRAM->i_channels ); TRAM->i_ab, TRAM->i_channels );
if( TRAM->b_subtitles || TRAM->b_soverlay ) if( TRAM->psz_scodec || TRAM->b_soverlay )
CHAIN_APPEND( "," ); CHAIN_APPEND( "," );
} }
if( TRAM->b_subtitles && TRAM->b_soverlay ) return NULL; assert( !(TRAM->psz_scodec && TRAM->b_soverlay) );
if( TRAM->b_subtitles ) if( TRAM->psz_scodec )
CHAIN_APPEND( "scodec=%s", TRAM->psz_scodec) ; CHAIN_APPEND( "scodec=%s", TRAM->psz_scodec) ;
if( TRAM->b_soverlay ) if( TRAM->b_soverlay )
CHAIN_APPEND( "soverlay" ); CHAIN_APPEND( "soverlay" );
......
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