[PD-cvs] externals/OSCx/src dumpOSC.c, 1.7, 1.8 htmsocket.c, 1.5, 1.6 htmsocket.h, 1.3, 1.4 sendOSC.c, 1.7, 1.8

Hans-Christoph Steiner eighthave at users.sourceforge.net
Tue Jan 2 02:38:22 CET 2007


Update of /cvsroot/pure-data/externals/OSCx/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19884/src

Modified Files:
	dumpOSC.c htmsocket.c htmsocket.h sendOSC.c 
Log Message:

committed patch 1612910 to add multicast support to the OSCx objects.  I took
out the changes to configure.ac since it broke the Pd-extended build stuff.


Index: htmsocket.h
===================================================================
RCS file: /cvsroot/pure-data/externals/OSCx/src/htmsocket.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** htmsocket.h	19 Aug 2004 22:01:38 -0000	1.3
--- htmsocket.h	2 Jan 2007 01:38:20 -0000	1.4
***************
*** 39,43 ****
  /* open a socket for HTM communication to given  host on given portnumber */
  /* if host is 0 then UNIX protocol is used (i.e. local communication) */
! void *OpenHTMSocket(char *host, int portnumber);
  
  /* send a buffer of data over htm socket, returns TRUE on success.
--- 39,43 ----
  /* open a socket for HTM communication to given  host on given portnumber */
  /* if host is 0 then UNIX protocol is used (i.e. local communication) */
! void *OpenHTMSocket(char *host, int portnumber, unsigned char multicast_TTL);
  
  /* send a buffer of data over htm socket, returns TRUE on success.

Index: htmsocket.c
===================================================================
RCS file: /cvsroot/pure-data/externals/OSCx/src/htmsocket.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** htmsocket.c	30 Aug 2005 20:54:05 -0000	1.5
--- htmsocket.c	2 Jan 2007 01:38:20 -0000	1.6
***************
*** 105,109 ****
  /* open a socket for HTM communication to given  host on given portnumber */
  /* if host is 0 then UNIX protocol is used (i.e. local communication */
! void *OpenHTMSocket(char *host, int portnumber)
  {
  	struct sockaddr_in  cl_addr;
--- 105,109 ----
  /* open a socket for HTM communication to given  host on given portnumber */
  /* if host is 0 then UNIX protocol is used (i.e. local communication */
! void *OpenHTMSocket(char *host, int portnumber, unsigned char multicast_TTL)
  {
  	struct sockaddr_in  cl_addr;
***************
*** 230,234 ****
  				// enable broadcast: jdl ~2003
  				if(setsockopt(sockfd, SOL_SOCKET, SO_BROADCAST, &oval, sizeof(int)) == -1) {
! 				  perror("setsockopt");
  				}
  
--- 230,239 ----
  				// enable broadcast: jdl ~2003
  				if(setsockopt(sockfd, SOL_SOCKET, SO_BROADCAST, &oval, sizeof(int)) == -1) {
! 				  perror("setsockopt broadcast");
! 				}
! 
! 				// set multicast Time-To-Live: ss
! 				if(setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, &multicast_TTL, sizeof(multicast_TTL)) == -1) {
! 				  perror("setsockopt TTL");
  				}
  
***************
*** 254,257 ****
--- 259,267 ----
  				}
  
+ 				// set multicast Time-To-Live: ss 2006
+ 				if(setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, &multicast_TTL, sizeof(multicast_TTL)) == -1) {
+ 				  perror("setsockopt TTL");
+ 				}
+ 
  				if(bind(sockfd, (struct sockaddr *) &cl_addr, sizeof(cl_addr)) < 0) {
  					perror("could not bind\n");

Index: dumpOSC.c
===================================================================
RCS file: /cvsroot/pure-data/externals/OSCx/src/dumpOSC.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** dumpOSC.c	19 Oct 2006 04:13:27 -0000	1.7
--- dumpOSC.c	2 Jan 2007 01:38:20 -0000	1.8
***************
*** 254,264 ****
  
  static void *dumpOSC_new(t_symbol *compatflag,
! 			 t_floatarg fportno) {
    t_dumpOSC *x;
    struct sockaddr_in server;
    int clilen=sizeof(server);
    int sockfd;
!   int portno=fportno;
    int udp = 1;
  
    //x->x_b = binbuf_new();
--- 254,286 ----
  
  static void *dumpOSC_new(t_symbol *compatflag,
! 			 int argc, t_atom* argv) {
    t_dumpOSC *x;
    struct sockaddr_in server;
    int clilen=sizeof(server);
    int sockfd;
!   int portno=0;
    int udp = 1;
+   t_symbol *castgroup=NULL;
+ 
+   if (argc == 1) {
+ 	  if (argv[0].a_type==A_FLOAT)
+ 		  portno = (int)argv[0].a_w.w_float;
+ 	  else
+ 		  return NULL;
+   }
+ 
+   else if (argc == 2) {
+ 	  if (argv[0].a_type==A_SYMBOL)
+ 		  castgroup = argv[0].a_w.w_symbol;
+ 	  else
+ 		  return NULL;
+ 
+ 	  if (argv[1].a_type==A_FLOAT)
+ 		  portno = (int)argv[1].a_w.w_float;
+ 	  else
+ 		  return NULL;
+   }
+ 
+   else return NULL;
  
    //x->x_b = binbuf_new();
***************
*** 279,282 ****
--- 301,316 ----
    /* assign server port number */
    server.sin_port = htons((u_short)portno);
+ 
+   // ss 2006
+   if (castgroup) {
+ 	  struct ip_mreq mreq;
+ 	  mreq.imr_multiaddr.s_addr = inet_addr(castgroup->s_name);
+ 	  mreq.imr_interface.s_addr = htonl(INADDR_ANY);
+ 	  if (setsockopt(sockfd,IPPROTO_IP,IP_ADD_MEMBERSHIP,&mreq,sizeof(mreq)) < 0) {
+ 		  sys_sockerror("setsockopt");
+ 	  }
+   }
+ 
+ 
    /* name the socket */
    if (bind(sockfd, (struct sockaddr *)&server, sizeof(server)) < 0)
***************
*** 340,345 ****
      dumpOSC_class = class_new(gensym("dumpOSC"),
      	(t_newmethod)dumpOSC_new, (t_method)dumpOSC_free,
!     	sizeof(t_dumpOSC), CLASS_NOINLET, A_DEFFLOAT, A_DEFFLOAT, 
! 	    A_DEFSYM, 0);
      class_sethelpsymbol(dumpOSC_class, gensym("dumpOSC-help.pd"));
  }
--- 374,378 ----
      dumpOSC_class = class_new(gensym("dumpOSC"),
      	(t_newmethod)dumpOSC_new, (t_method)dumpOSC_free,
! 							  sizeof(t_dumpOSC), CLASS_NOINLET, A_GIMME, 0);
      class_sethelpsymbol(dumpOSC_class, gensym("dumpOSC-help.pd"));
  }

Index: sendOSC.c
===================================================================
RCS file: /cvsroot/pure-data/externals/OSCx/src/sendOSC.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** sendOSC.c	19 Oct 2006 04:13:27 -0000	1.7
--- sendOSC.c	2 Jan 2007 01:38:20 -0000	1.8
***************
*** 114,118 ****
  static void sendOSC_closebundle(t_sendOSC *x);
  static void sendOSC_settypetags(t_sendOSC *x, t_float *f);
! static void sendOSC_connect(t_sendOSC *x, t_symbol *hostname, t_floatarg fportno);
  void sendOSC_disconnect(t_sendOSC *x);
  static void sendOSC_sendtyped(t_sendOSC *x, t_symbol *s, int argc, t_atom *argv);
--- 114,118 ----
  static void sendOSC_closebundle(t_sendOSC *x);
  static void sendOSC_settypetags(t_sendOSC *x, t_float *f);
! static void sendOSC_connect(t_sendOSC *x, t_symbol *s, int argc, t_atom *argv);
  void sendOSC_disconnect(t_sendOSC *x);
  static void sendOSC_sendtyped(t_sendOSC *x, t_symbol *s, int argc, t_atom *argv);
***************
*** 188,201 ****
   }
  
! static void sendOSC_connect(t_sendOSC *x, t_symbol *hostname, t_floatarg fportno)
  {
! 	int portno = fportno;
    char *protocolStr;
! 	/* create a socket */
  
  	//	make sure handle is available
    if(x->x_htmsocket == 0)
    {
! 		x->x_htmsocket = OpenHTMSocket(hostname->s_name, portno);
  		if (!x->x_htmsocket)
        post("sendOSC: Couldn't open socket: ");
--- 188,224 ----
   }
  
! static void sendOSC_connect(t_sendOSC *x, t_symbol *s, int argc, t_atom *argv) // t_symbol *hostname, t_floatarg fportno, int argc, t_atom *argv)
  {
!   float fportno=0;
!   t_symbol *hostname;
!   int portno = fportno;
!   unsigned char ttl=1;
    char *protocolStr;
!   /* create a socket */
! 
!   if (argc < 2)
! 	  return;
! 
!   if (argv[0].a_type==A_SYMBOL)
! 	  hostname = argv[0].a_w.w_symbol;
!   else
! 	  return;
! 
!   if (argv[1].a_type==A_FLOAT)
! 	  portno = (int)argv[1].a_w.w_float;
!   else
! 	  return;
! 
!   if (argc >= 3) {
! 	  if (argv[2].a_type==A_FLOAT)
! 		  ttl = (unsigned char)argv[2].a_w.w_float;
! 	  else
! 		  return;
!   }
  
  	//	make sure handle is available
    if(x->x_htmsocket == 0)
    {
! 		x->x_htmsocket = OpenHTMSocket(hostname->s_name, portno, ttl);
  		if (!x->x_htmsocket)
        post("sendOSC: Couldn't open socket: ");
***************
*** 214,219 ****
            break;
  	  }
!       post("sendOSC: connected to port %s:%d (hSock=%d) protocol = %s", 
!         hostname->s_name, portno, x->x_htmsocket, protocolStr);
  			outlet_float(x->x_obj.ob_outlet, 1);
  		}
--- 237,242 ----
            break;
  	  }
!       post("sendOSC: connected to port %s:%d (hSock=%d) protocol = %s ttl = %d", 
!         hostname->s_name, portno, x->x_htmsocket, protocolStr, ttl);
  			outlet_float(x->x_obj.ob_outlet, 1);
  		}
***************
*** 338,342 ****
  			      sizeof(t_sendOSC), 0, A_DEFFLOAT, 0);
      class_addmethod(sendOSC_class, (t_method)sendOSC_connect,
! 		    gensym("connect"), A_SYMBOL, A_FLOAT, 0);
      class_addmethod(sendOSC_class, (t_method)sendOSC_disconnect,
  		    gensym("disconnect"), 0);
--- 361,365 ----
  			      sizeof(t_sendOSC), 0, A_DEFFLOAT, 0);
      class_addmethod(sendOSC_class, (t_method)sendOSC_connect,
! 		    gensym("connect"), A_GIMME, 0);
      class_addmethod(sendOSC_class, (t_method)sendOSC_disconnect,
  		    gensym("disconnect"), 0);





More information about the Pd-cvs mailing list