Add Icecast support to profiles.
authorJean-Paul Saman <jpsaman@videolan.org>
Wed, 17 Oct 2007 18:36:22 +0000 (18:36 +0000)
committerJean-Paul Saman <jpsaman@videolan.org>
Wed, 17 Oct 2007 18:36:22 +0000 (18:36 +0000)
include/vlc_streaming.h
src/stream_output/profiles.c

index c1e9e62..b8503cd 100644 (file)
@@ -121,14 +121,20 @@ 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;
+    int32_t i_vb;
+    int32_t i_ab;
+    int32_t i_channels;
     float f_scale;
     vlc_bool_t b_soverlay;
     char *psz_vcodec;
-    char *psz_acodec, *psz_scodec, *psz_venc, *psz_aenc;
+    char *psz_acodec;
+    char *psz_scodec;
+    char *psz_venc;
+    char *psz_aenc;
     char *psz_additional;
 
-    int i_params; sout_param_t **pp_params;
+    int32_t i_params;
+    sout_param_t **pp_params;
 };
 void streaming_TranscodeParametersApply( sout_transcode_t *p_module );
 
@@ -136,9 +142,13 @@ void streaming_TranscodeParametersApply( sout_transcode_t *p_module );
 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;
+    char *psz_mux;
+    char *psz_access;
+    char *psz_url;
+    char *psz_name;
+    char *psz_group;
+    int i_params;
+    sout_param_t **pp_params;
 };
 void streaming_StdParametersApply( sout_std_t *p_module );
 
@@ -150,7 +160,8 @@ struct sout_display_t
 /* Duplicate */
 struct sout_duplicate_t
 {
-    int i_children, i_conditions;
+    int i_children;
+    int i_conditions;
     sout_chain_t **pp_children;
     char **ppsz_conditions;
 };
@@ -201,27 +212,63 @@ struct streaming_profile_t
     sout_chain_t *p_chain;
 };
 
+/** struct for holding account information needed to access the services */
+struct streaming_account_t
+{
+    char *psz_username; /*< username of account */
+    char *psz_password; /*< password of account */
+};
+
 /**************** GUI interaction *****************/
+/** struct to hold user interface information */
 struct sout_gui_descr_t
 {
-    /* Access */
-    vlc_bool_t b_local, b_file, b_http, b_mms, b_rtp, b_udp, b_dump;
-    char *psz_file, *psz_http, *psz_mms, *psz_rtp, *psz_udp;
-    int i_http, i_mms, i_rtp, i_udp;
+    /* Access types */
+    vlc_bool_t b_local;   /*< local access module */
+    vlc_bool_t b_file;    /*< file access module */
+    vlc_bool_t b_http;    /*< http access module */
+    vlc_bool_t b_mms;     /*< mms access module */
+    vlc_bool_t b_rtp;     /*< rtp access module */
+    vlc_bool_t b_udp;     /*< udp access module */
+    vlc_bool_t b_dump;    /*< dump access module */
+    vlc_bool_t b_icecast; /*< icecast access module */
+
+    char *psz_file;     /*< filename */
+    char *psz_http;     /*< HTTP servername or ipaddress */
+    char *psz_mms;      /*< MMS servername or ipaddress */
+    char *psz_rtp;      /*< RTP servername or ipaddress */
+    char *psz_udp;      /*< UDP servername or ipaddress */
+    char *psz_icecast;  /*< Icecast servername or ipaddress*/
+
+    int32_t i_http;     /*< http port number */
+    int32_t i_mms;      /*< mms port number */
+    int32_t i_rtp;      /*< rtp port number */
+    int32_t i_udp;      /*< udp port number */
+    int32_t i_icecast;  /*< icecast port number */
 
     /* Mux */
-    char *psz_mux;
+    char *psz_mux;      /*< name of muxer to use in streaming */
 
     /* Transcode */
-    vlc_bool_t b_soverlay;
-    char *psz_vcodec, *psz_acodec, *psz_scodec;
-    int i_vb, i_ab, i_channels;
-    float f_scale;
+    vlc_bool_t b_soverlay; /*< enable burning overlay in the video */
+    char *psz_vcodec;   /*< video codec to use in transcoding */
+    char *psz_acodec;   /*< audio codec to use in transcoding */
+    char *psz_scodec;   /*< subtitle codec to use in transcoding */
+    int32_t i_vb;       /*< video bitrate to use in transcoding */
+    int32_t i_ab;       /*< audio bitrate to use in transcoding */
+    int32_t i_channels; /*< number of audio channels to use in transcoding */
+    float f_scale;      /*< scaling factor to use in transcoding */
 
     /* Misc */
-    vlc_bool_t b_sap, b_all_es;
-    char *psz_group, *psz_name;
-    int i_ttl;
+    vlc_bool_t b_sap;   /*< send SAP announcement */
+    vlc_bool_t b_all_es;/*< send all elementary streams from source stream */
+    char *psz_group;    /*< SAP Group name */
+    char *psz_name;     /*< SAP name */
+    int32_t i_ttl;      /*< Time To Live (TTL) for network traversal */
+
+    /* Icecast */
+    char *psz_mountpoint;/*< path to Icecast mountpoint */
+    struct streaming_account_t sa_icecast;  /*< Icecast account information */
 };
 
 VLC_EXPORT(void, streaming_GuiDescToChain,(vlc_object_t*, sout_chain_t*, sout_gui_descr_t*));
index b7e2c46..640d1d9 100644 (file)
@@ -264,15 +264,15 @@ void streaming_ParameterApply( sout_param_t *p_param, char **ppsz_dest,
     { \
         pd->b_file = VLC_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 ); \
     } \
-    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 ); \
     } \
-    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 ); \
     } \
@@ -378,6 +378,7 @@ void streaming_GuiDescToChain( vlc_object_t *p_obj, sout_chain_t *p_chain,
 {
     sout_duplicate_t *p_dup = NULL;
     (void)p_obj;
+
     /* Clean up the chain */
     streaming_ChainClean( p_chain );
 
@@ -392,7 +393,7 @@ 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 );
     }
@@ -424,7 +425,8 @@ 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;
@@ -432,6 +434,43 @@ void streaming_GuiDescToChain( vlc_object_t *p_obj, sout_chain_t *p_chain,
             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_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_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" )
 }
@@ -490,11 +529,12 @@ static char * ChainToPsz( sout_chain_t *p_chain, vlc_bool_t b_root )
             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( ":" );
     }