]> git.sesse.net Git - vlc/blobdiff - modules/stream_out/standard.c
Save a few useless strdup() calls
[vlc] / modules / stream_out / standard.c
index 19c742173bd99638cea6d139aec0fbe74bf1abaf..3645802d1f6b9c841edfcaa7be5fd253d7b8d1a6 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * standard.c: standard stream output module
  *****************************************************************************
- * Copyright (C) 2003-2004 VideoLAN
+ * Copyright (C) 2003-2004 the VideoLAN team
  * $Id$
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *****************************************************************************/
 #include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
 
 #include <vlc/vlc.h>
 #include <vlc/sout.h>
 
+#ifdef HAVE_UNISTD_H
+#    include <unistd.h>
+#endif
+
 #include "announce.h"
 #include "network.h"
 
 #define NAME_LONGTEXT N_( \
     "Name of the session that will be announced with SAP or SLP" )
 
+#define GROUP_TEXT N_("Session groupname")
+#define GROUP_LONGTEXT N_( \
+    "Name of the group that will be announced for the session" )
+
 #define SAP_TEXT N_("SAP announcing")
 #define SAP_LONGTEXT N_("Announce this session with SAP")
 
-#define SAPv6_TEXT N_("SAP IPv6 announcing")
-#define SAPv6_LONGTEXT N_("Use IPv6 to announce this session with SAP")
-
 #define SLP_TEXT N_("SLP announcing")
 #define SLP_LONGTEXT N_("Announce this session with SLP")
 
@@ -68,10 +72,13 @@ static void     Close   ( vlc_object_t * );
 #define SOUT_CFG_PREFIX "sout-standard-"
 
 vlc_module_begin();
+    set_shortname( _("Standard"));
     set_description( _("Standard stream output") );
     set_capability( "sout stream", 50 );
     add_shortcut( "standard" );
     add_shortcut( "std" );
+    set_category( CAT_SOUT );
+    set_subcategory( SUBCAT_SOUT_STREAM );
 
     add_string( SOUT_CFG_PREFIX "access", "", NULL, ACCESS_TEXT,
                 ACCESS_LONGTEXT, VLC_FALSE );
@@ -81,10 +88,11 @@ vlc_module_begin();
                 URL_LONGTEXT, VLC_FALSE );
 
     add_bool( SOUT_CFG_PREFIX "sap", 0, NULL, SAP_TEXT, SAP_LONGTEXT, VLC_TRUE );
-    add_string( SOUT_CFG_PREFIX "name", "", NULL, NAME_TEXT,NAME_LONGTEXT
-                                     , VLC_TRUE );
-    add_bool( SOUT_CFG_PREFIX "sap-ipv6", 0, NULL, SAPv6_TEXT, SAPv6_LONGTEXT,
+    add_string( SOUT_CFG_PREFIX "name", "", NULL, NAME_TEXT, NAME_LONGTEXT,
                                         VLC_TRUE );
+    add_string( SOUT_CFG_PREFIX "group", "", NULL, GROUP_TEXT, GROUP_LONGTEXT,
+                                        VLC_TRUE );
+    add_suppressed_bool( SOUT_CFG_PREFIX "sap-ipv6" );
 
     add_bool( SOUT_CFG_PREFIX "slp", 0, NULL, SLP_TEXT, SLP_LONGTEXT, VLC_TRUE );
 
@@ -97,11 +105,9 @@ vlc_module_end();
  *****************************************************************************/
 static const char *ppsz_sout_options[] = {
     "access", "mux", "url",
-    "sap", "name", "sap-ipv6",
-    "slp",NULL
+    "sap", "name", "group", "slp", NULL
 };
 
-#define DEFAULT_IPV6_SCOPE '8'
 #define DEFAULT_PORT 1234
 
 static sout_stream_id_t *Add ( sout_stream_t *, es_format_t * );
@@ -247,7 +253,7 @@ static int Open( vlc_object_t *p_this )
         }
     }
 
-    /* fix or warm of incompatible couple */
+    /* fix or warn of incompatible couple */
     if( psz_mux && psz_access )
     {
         if( !strncmp( psz_access, "mmsh", 4 ) &&
@@ -321,16 +327,18 @@ static int Open( vlc_object_t *p_this )
 
         var_Get( p_stream, SOUT_CFG_PREFIX "name", &val );
         if( *val.psz_string )
-        {
             p_session->psz_name = val.psz_string;
-        }
         else
         {
-            free( val.psz_string );
             p_session->psz_name = strdup( psz_url );
+            free( val.psz_string );
         }
-        var_Get( p_stream, SOUT_CFG_PREFIX "sap-ipv6", &val );
-        p_method->i_ip_version = val.b_bool ? 6 : 4;
+
+        var_Get( p_stream, SOUT_CFG_PREFIX "group", &val );
+        if( *val.psz_string )
+            p_session->psz_group = val.psz_string;
+        else
+            free( val.psz_string );
 
         /* Now, parse the URL to extract host and port */
         vlc_UrlParse( &url, psz_url , 0);
@@ -339,7 +347,7 @@ static int Open( vlc_object_t *p_this )
         {
             if( url.i_port == 0 ) url.i_port = DEFAULT_PORT;
 
-            p_session->psz_uri = url.psz_host;
+            p_session->psz_uri = strdup( url.psz_host );
             p_session->i_port = url.i_port;
             p_session->psz_sdp = NULL;
 
@@ -349,13 +357,11 @@ static int Open( vlc_object_t *p_this )
             msg_Info( p_this, "SAP Enabled");
 
             sout_AnnounceRegister( p_sout, p_session, p_method );
-
-            /* FIXME: Free p_method */
-
             p_stream->p_sys->p_session = p_session;
         }
         vlc_UrlClean( &url );
 
+        /* FIXME: Free p_method */
         if( p_method->psz_address) free( p_method->psz_address );
         free( p_method );
     }