]> git.sesse.net Git - vlc/blobdiff - src/stream_output/profiles.c
Remove VLC_OBJECT_SOUT
[vlc] / src / stream_output / profiles.c
index f7ec13b0ed840d7eca68eab54364dd9e0159bf4c..70e0349e592207868200447d1acf11f0c4992a27 100644 (file)
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.h>
 #include <vlc_streaming.h>
 #include <assert.h>
 
@@ -40,7 +45,7 @@
 /** Add a new duplicate element to a streaming chain
  * \return the new element
  */
-sout_duplicate_t *streaming_ChainAddDup( sout_chain_t *p_chain )
+static sout_duplicate_t *streaming_ChainAddDup( sout_chain_t *p_chain )
 {
     DECMALLOC_NULL( p_module, sout_module_t );
     MALLOC_NULL( DUPM, sout_duplicate_t );
@@ -54,8 +59,10 @@ sout_duplicate_t *streaming_ChainAddDup( sout_chain_t *p_chain )
 /** 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 )
+static sout_std_t *streaming_ChainAddStd( sout_chain_t *p_chain,
+                                          const char *psz_access,
+                                          const char *psz_mux,
+                                          const char *psz_url )
 {
     DECMALLOC_NULL( p_module, sout_module_t );
     MALLOC_NULL( STDM, sout_std_t );
@@ -66,10 +73,11 @@ sout_std_t *streaming_ChainAddStd( sout_chain_t *p_chain, char *psz_access,
     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 )
+static sout_display_t *streaming_ChainAddDisplay( sout_chain_t *p_chain )
 {
     DECMALLOC_NULL( p_module, sout_module_t );
     MALLOC_NULL( DISM, sout_display_t );
@@ -81,28 +89,28 @@ sout_display_t *streaming_ChainAddDisplay( sout_chain_t *p_chain )
 /** Add a new transcode element to a streaming chain
  * \return the new element
  */
-sout_transcode_t *streaming_ChainAddTranscode( sout_chain_t *p_chain,
+static 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,
-                        vlc_bool_t b_soverlay, char *psz_additional )
+                        bool b_soverlay, char *psz_additional )
 {
     DECMALLOC_NULL( p_module, sout_module_t );
     MALLOC_NULL( TRAM, sout_transcode_t );
     p_module->i_type = SOUT_MOD_TRANSCODE;
-
+    memset( TRAM, 0, sizeof( sout_transcode_t ) );
     assert( !( b_soverlay && psz_scodec ) );
     if( psz_vcodec ) TRAM->psz_vcodec = strdup( psz_vcodec );
     if( psz_acodec ) TRAM->psz_acodec = strdup( psz_acodec );
     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_channels = i_channels; TRAM->b_soverlay = b_soverlay;
-    if( TRAM->psz_additional ) TRAM->psz_additional = strdup( psz_additional );
+    if( 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 )
+static void streaming_DupAddChild( sout_duplicate_t *p_dup )
 {
     assert( p_dup );
     sout_chain_t * p_child = streaming_ChainNew();
@@ -118,7 +126,7 @@ void streaming_DupAddChild( sout_duplicate_t *p_dup )
     free( psz_opt ); }
 
 /** Clean up a chain (recursively if it has some children) */
-void streaming_ChainClean( sout_chain_t *p_chain )
+static void streaming_ChainClean( sout_chain_t *p_chain )
 {
     int i,j;
     sout_module_t *p_module;
@@ -218,7 +226,7 @@ void streaming_TranscodeParametersApply( sout_transcode_t *p_module )
  * \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 )
+                             int *pi_dest, float *pf_dest, bool *pb_dest )
 {
     /* Todo : Handle psz_string like formatting */
     if( p_param->psz_string )
@@ -240,7 +248,7 @@ void streaming_ParameterApply( sout_param_t *p_param, char **ppsz_dest,
             break;
         case VLC_VAR_STRING:
             assert( ppsz_dest );
-            FREENULL( **ppsz_dest );
+            free( *ppsz_dest );
             *ppsz_dest = p_param->value.psz_string ?
                                 strdup( p_param->value.psz_string ) :
                                 NULL;
@@ -259,26 +267,26 @@ void streaming_ParameterApply( sout_param_t *p_param, char **ppsz_dest,
 #define DO_ENABLE_ACCESS \
     if( !strcmp( STDM->psz_access, "file" ) )\
     { \
-        pd->b_file = VLC_TRUE; pd->psz_file = strdup( STDM->psz_url ); \
+        pd->b_file = true; pd->psz_file = strdup( STDM->psz_url ); \
     } \
-    else if(  !strcmp( STDM->psz_access, "http" ) )\
+    else if( !strcmp( STDM->psz_access, "http" ) )\
     { \
-        pd->b_http = VLC_TRUE; pd->psz_http = strdup( STDM->psz_url ); \
+        pd->b_http = true; pd->psz_http = strdup( STDM->psz_url ); \
     } \
-    else if(  !strcmp( STDM->psz_access, "mms" ) )\
+    else if( !strcmp( STDM->psz_access, "mms" ) )\
     { \
-        pd->b_mms = VLC_TRUE; pd->psz_mms = strdup( STDM->psz_url ); \
+        pd->b_mms = true; pd->psz_mms = strdup( STDM->psz_url ); \
     } \
-    else if(  !strcmp( STDM->psz_access, "udp" ) )\
+    else if( !strcmp( STDM->psz_access, "udp" ) )\
     { \
-        pd->b_udp = VLC_TRUE; pd->psz_udp = strdup( STDM->psz_url ); \
+        pd->b_udp = true; pd->psz_udp = strdup( STDM->psz_url ); \
     } \
     else \
     { \
         msg_Err( p_this, "unahandled access %s", STDM->psz_access ); \
     }
 
-
+#if 0
 /**
  * Try to convert a chain to a gui descriptor. This is only possible for
  * "simple" chains.
@@ -287,16 +295,16 @@ void streaming_ParameterApply( sout_param_t *p_param, char **ppsz_dest,
  * \param pd the destination gui descriptor object
  * \return TRUE if the conversion succeeded, false else
  */
-vlc_bool_t streaming_ChainToGuiDesc( vlc_object_t *p_this,
+bool streaming_ChainToGuiDesc( vlc_object_t *p_this,
                                   sout_chain_t *p_chain, sout_gui_descr_t *pd )
 {
     int j, i_last = 0;
     sout_module_t *p_module;
-    if( p_chain->i_modules == 0 || p_chain->i_modules > 2 ) return VLC_FALSE;
+    if( p_chain->i_modules == 0 || p_chain->i_modules > 2 ) return false;
 
     if( p_chain->pp_modules[0]->i_type == SOUT_MOD_TRANSCODE )
     {
-        if( p_chain->i_modules == 1 ) return VLC_FALSE;
+        if( p_chain->i_modules == 1 ) return false;
         p_module = p_chain->pp_modules[0];
         i_last++;
 
@@ -313,22 +321,22 @@ vlc_bool_t streaming_ChainToGuiDesc( vlc_object_t *p_this,
 
         // Nothing allowed after duplicate. Duplicate mustn't be empty
         if( p_chain->i_modules > i_last +1 || !DUPM->i_children )
-            return VLC_FALSE;
+            return false;
         for( j = 0 ; j<  DUPM->i_children ; j++ )
         {
             sout_chain_t *p_child = DUPM->pp_children[j];
-            if( p_child->i_modules != 1 ) return VLC_FALSE;
+            if( p_child->i_modules != 1 ) return false;
             p_module = p_child->pp_modules[0];
             if( p_module->i_type == SOUT_MOD_STD )
             {
                 DO_ENABLE_ACCESS
             }
             else if( p_module->i_type == SOUT_MOD_DISPLAY )
-                pd->b_local = VLC_TRUE;
+                pd->b_local = true;
             else if( p_module->i_type == SOUT_MOD_RTP )
             {
                 msg_Err( p_this, "RTP unhandled" );
-                return VLC_FALSE;
+                return false;
             }
         }
         i_last++;
@@ -340,20 +348,21 @@ vlc_bool_t streaming_ChainToGuiDesc( vlc_object_t *p_this,
     }
     else if( p_chain->pp_modules[i_last]->i_type == SOUT_MOD_DISPLAY )
     {
-        pd->b_local = VLC_TRUE;
+        pd->b_local = true;
     }
     else if( p_chain->pp_modules[i_last]->i_type == SOUT_MOD_RTP )
     {
         msg_Err( p_this, "RTP unhandled" );
-        return VLC_FALSE;
+        return false;
 
     }
-    return VLC_TRUE;
+    return true;
 
 }
+#endif
 
 #define HANDLE_GUI_URL( type, access ) if( pd->b_##type ) { \
-        streaming_DupAddChild( p_dup ); \
+        if( p_dup ) streaming_DupAddChild( p_dup ); \
         if( pd->i_##type > 0 ) \
         { \
             char *psz_url; \
@@ -373,12 +382,15 @@ void streaming_GuiDescToChain( vlc_object_t *p_obj, sout_chain_t *p_chain,
                                sout_gui_descr_t *pd )
 {
     sout_duplicate_t *p_dup = NULL;
+    (void)p_obj;
+
     /* Clean up the chain */
     streaming_ChainClean( p_chain );
 
     /* Transcode */
     if( pd->psz_vcodec || pd->psz_acodec || pd->psz_scodec || pd->b_soverlay )
     {
+        fprintf( stderr, "382 vcodec %s\n", pd->psz_vcodec );
         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,
@@ -386,25 +398,25 @@ void streaming_GuiDescToChain( vlc_object_t *p_obj, sout_chain_t *p_chain,
     }
     /* #std{} */
     if( pd->b_local + pd->b_file + pd->b_http + pd->b_mms + pd->b_rtp +
-        pd->b_udp > 1 )
+        pd->b_udp + pd->b_icecast > 1 )
     {
         p_dup = streaming_ChainAddDup( p_chain );
     }
     if( pd->b_local )
     {
-        streaming_DupAddChild( p_dup );
-        streaming_ChainAddDisplay(  DUP_OR_CHAIN );
+        if( p_dup ) streaming_DupAddChild( p_dup );
+        streaming_ChainAddDisplay( DUP_OR_CHAIN );
     }
     if( pd->b_file )
     {
-        streaming_DupAddChild( p_dup );
+        if( p_dup ) streaming_DupAddChild( p_dup );
         streaming_ChainAddStd( DUP_OR_CHAIN, "file", pd->psz_mux,
                                pd->psz_file );
     }
     if( pd->b_udp )
     {
         sout_std_t *p_std;
-        streaming_DupAddChild( p_dup );
+        if( p_dup ) streaming_DupAddChild( p_dup );
         if( pd->i_udp > 0 )
         {
             char *psz_url;
@@ -418,14 +430,52 @@ void streaming_GuiDescToChain( vlc_object_t *p_obj, sout_chain_t *p_chain,
             p_std = streaming_ChainAddStd( DUP_OR_CHAIN, "udp",
                                            pd->psz_mux, pd->psz_udp );
         }
-        if( pd->i_ttl ) ADD_OPT( "ttl=%i", pd->i_ttl );
+        if( pd->i_ttl )
+            ADD_OPT( "ttl=%i", pd->i_ttl );
         if( pd->b_sap )
         {
-            pd->b_sap = VLC_TRUE;
+            pd->b_sap = true;
             p_std->psz_name = strdup( pd->psz_name );
             p_std->psz_group = pd->psz_group ? strdup( pd->psz_group ) : NULL;
         }
     }
+    if( pd->b_icecast )
+    {
+        sout_std_t *p_std;
+        char *psz_username;
+
+        if( p_dup ) streaming_DupAddChild( p_dup );
+
+        if( !strcmp( pd->sa_icecast.psz_username, "" ) )
+        {
+            asprintf( &psz_username, "%s", "" );
+        }
+        else
+        {
+            asprintf( &psz_username, "%s:%s@", pd->sa_icecast.psz_username,
+                      pd->sa_icecast.psz_password );
+        }
+        if( pd->i_icecast > 0 )
+        {
+            char *psz_url;
+            asprintf( &psz_url, "%s%s:%i%s", psz_username, pd->psz_icecast,
+                      pd->i_icecast, pd->psz_icecast_mountpoint );
+            p_std = streaming_ChainAddStd( DUP_OR_CHAIN, "shout",
+                                           pd->psz_mux, psz_url );
+            free( psz_url );
+        }
+        else
+        {
+            char *psz_url;
+            asprintf( &psz_url, "%s:%s@%s%s", pd->sa_icecast.psz_username,
+                      pd->sa_icecast.psz_password, pd->psz_icecast,
+                      pd->psz_icecast_mountpoint );
+            p_std = streaming_ChainAddStd( DUP_OR_CHAIN, "shout",
+                                           pd->psz_mux, psz_url );
+            free( psz_url );
+        }
+        free( psz_username );
+    }
     HANDLE_GUI_URL( http, "http" )
     HANDLE_GUI_URL( mms, "mms" )
 }
@@ -434,17 +484,31 @@ void streaming_GuiDescToChain( vlc_object_t *p_obj, sout_chain_t *p_chain,
 /**********************************************************************
  * Create a sout string from a chain
  **********************************************************************/
-char * streaming_ChainToPsz( sout_chain_t *p_chain )
+static char * ChainToPsz( sout_chain_t *p_chain, bool b_root )
 {
-    int i;
+    int i, j;
     char psz_output[MAX_CHAIN];
     char psz_temp[MAX_CHAIN];
-    sprintf( psz_output, "#" );
+    if( b_root ) sprintf( psz_output, "#" );
+    else psz_output[0] = '\0';
+
     for( i = 0 ; i< p_chain->i_modules; i++ )
     {
         sout_module_t *p_module = p_chain->pp_modules[i];
         switch( p_module->i_type )
         {
+        case SOUT_MOD_DUPLICATE:
+            CHAIN_APPEND( "duplicate{" );
+            for( j = 0 ; j < DUPM->i_children ; j ++ )
+            {
+                char *psz_child = ChainToPsz( DUPM->pp_children[j], false);
+                fprintf(stderr, "child %s\n", psz_child);
+                CHAIN_APPEND( "dst=%s", psz_child );
+                free( psz_child );
+                if( j != DUPM->i_children - 1 ) CHAIN_APPEND( "," );
+            }
+            CHAIN_APPEND( "}" );
+            break;
         case SOUT_MOD_TRANSCODE:
             CHAIN_APPEND( "transcode{" );
             if( TRAM->psz_vcodec )
@@ -470,20 +534,28 @@ char * streaming_ChainToPsz( sout_chain_t *p_chain )
             break;
 
         case SOUT_MOD_DISPLAY:
-            CHAIN_APPEND( "display" )
+            CHAIN_APPEND( "display" );
             break;
         case SOUT_MOD_STD:
-            CHAIN_APPEND( "std{access=%s,url=%s,mux=%s}", STDM->psz_access,
+            CHAIN_APPEND( "std{access=%s,dst=%s,mux=%s}", STDM->psz_access,
                           STDM->psz_url, STDM->psz_mux );
+            break;
         }
+        if( i != p_chain->i_modules - 1 ) CHAIN_APPEND( ":" );
     }
     return strdup( psz_output );
 }
 
+char * streaming_ChainToPsz( sout_chain_t *p_chain )
+{
+    return ChainToPsz( p_chain, true );
+}
+
 /**********************************************************************
  * Handle streaming profiles
  **********************************************************************/
 
+#if 0
 /**
  * List the available profiles. Fills the pp_profiles list with preinitialized
  * values.
@@ -511,7 +583,7 @@ int streaming_ProfileParse( vlc_object_t *p_this,streaming_profile_t *p_profile,
     p_this->p_private = (void *)p_parser;
 
     /* And call the module ! All work is done now */
-    p_module = module_Need( p_this, "profile parser", "", VLC_TRUE );
+    p_module = module_Need( p_this, "profile parser", "", true );
     if( !p_module )
     {
         msg_Warn( p_this, "parsing profile failed" );
@@ -519,3 +591,4 @@ int streaming_ProfileParse( vlc_object_t *p_this,streaming_profile_t *p_profile,
     }
     return VLC_SUCCESS;
 }
+#endif