[vlc-devel] [PATCH] Set TOS field - UDP streaming

Anders Theodorsen anders.theodorsen at gmail.com
Sun Sep 3 22:04:16 CEST 2006


Attached is a proposed patch to enable the user to set the TOS field
of outgoing UDP packets to a specified value.
Hopefully this will see it into the SVN tree.

Cheers,
Anders
-------------- next part --------------
Index: src/network/udp.c
===================================================================
--- src/network/udp.c	(revision 16503)
+++ src/network/udp.c	(working copy)
@@ -178,6 +178,7 @@
     struct addrinfo hints, *res, *ptr;
     int             i_val, i_handle = -1;
     vlc_bool_t      b_unreach = VLC_FALSE;
+    vlc_value_t					tos;
 
     if( i_port == 0 )
         i_port = 1234; /* historical VLC thing */
@@ -240,6 +241,22 @@
 
         if( connect( fd, ptr->ai_addr, ptr->ai_addrlen ) == 0 )
         {
+				    var_Get( p_this, "sout-udp-tos", &tos );
+				    int i_tos = tos.i_int;
+				    if (i_tos > 0) 
+				   	{
+			  		  	msg_Dbg( p_this, "net: Setting TOS value (udp.c:248)" );
+								/* Set TOS value in IP header */
+          			if( setsockopt( fd, IPPROTO_IP, IP_TOS,
+        												&i_tos, sizeof( i_tos ) ) <0 )
+	         			{
+  	      					msg_Err( p_this, "failed to set tos (%s).",
+    	   	  								strerror(errno) );
+     		    				close( fd );
+  	    	  				return -1;
+ 	        			}
+          			msg_Dbg( p_this, "tos value set (udp.c:260)!" );
+            }
             /* success */
             i_handle = fd;
             break;
Index: modules/access_output/udp.c
===================================================================
--- modules/access_output/udp.c	(revision 16503)
+++ modules/access_output/udp.c	(working copy)
@@ -80,6 +80,10 @@
 #define TTL_TEXT N_("Time-To-Live (TTL)")
 #define TTL_LONGTEXT N_("Time-To-Live of the " \
                         "outgoing stream.")
+                        
+#define TOS_TEXT N_("Type of Service (TOS)")
+#define TOS_LONGTEXT N_("TOS value to set on " \
+												"outgoing packets.")
 
 #define GROUP_TEXT N_("Group packets")
 #define GROUP_LONGTEXT N_("Packets can be sent one by one at the right time " \
@@ -101,6 +105,8 @@
     add_integer( SOUT_CFG_PREFIX "caching", DEFAULT_PTS_DELAY / 1000, NULL, CACHING_TEXT, CACHING_LONGTEXT, VLC_TRUE );
     add_integer( SOUT_CFG_PREFIX "ttl", 0, NULL,TTL_TEXT, TTL_LONGTEXT,
                                  VLC_TRUE );
+    add_integer( SOUT_CFG_PREFIX "tos", 0, NULL, TOS_TEXT, TOS_LONGTEXT,
+    														 VLC_TRUE );
     add_integer( SOUT_CFG_PREFIX "group", 1, NULL, GROUP_TEXT, GROUP_LONGTEXT,
                                  VLC_TRUE );
     add_suppressed_integer( SOUT_CFG_PREFIX "late" );
@@ -120,6 +126,7 @@
 static const char *ppsz_sout_options[] = {
     "caching",
     "ttl",
+    "tos",
     "group",
     "raw",
     NULL


More information about the vlc-devel mailing list