diff -ur streamdev-20070921.orig/Makefile streamdev-20070921/Makefile
--- streamdev-20070921.orig/Makefile	2007-09-21 13:18:40.000000000 +0200
+++ streamdev-20070921/Makefile	2008-03-06 19:12:39.000000000 +0100
@@ -86,7 +86,11 @@
 endif
 
 libdvbmpeg/libdvbmpegtools.a: libdvbmpeg/*.c libdvbmpeg/*.cc libdvbmpeg/*.h libdvbmpeg/*.hh
+ifdef FREEBSD
+	gmake -C ./libdvbmpeg libdvbmpegtools.a FREEBSD=1
+else
 	make -C ./libdvbmpeg libdvbmpegtools.a
+endif
 
 ### Implicit rules:
 
@@ -132,4 +136,8 @@
 
 clean:
 	@-rm -f $(COMMONOBJS) $(CLIENTOBJS) $(SERVEROBJS) $(DEPFILE) *.so *.tgz core* *~
+ifdef FREEBSD
+	gmake -C ./libdvbmpeg clean FREEBSD=1
+else
 	make -C ./libdvbmpeg clean
+endif
diff -ur streamdev-20070921.orig/common.h streamdev-20070921/common.h
--- streamdev-20070921.orig/common.h	2007-09-21 13:18:40.000000000 +0200
+++ streamdev-20070921/common.h	2008-03-06 19:13:28.000000000 +0100
@@ -5,6 +5,12 @@
 #ifndef VDR_STREAMDEV_COMMON_H
 #define VDR_STREAMDEV_COMMON_H
 
+/* FreeBSD has it's own version of isnumber(),
+   but VDR's version is incompatible */
+#ifdef FreeBSD
+#undef isnumber
+#endif
+
 #include <vdr/tools.h>
 #include <vdr/plugin.h>
 
diff -ur streamdev-20070921.orig/libdvbmpeg/Makefile streamdev-20070921/libdvbmpeg/Makefile
--- streamdev-20070921.orig/libdvbmpeg/Makefile	2005-02-08 16:21:19.000000000 +0100
+++ streamdev-20070921/libdvbmpeg/Makefile	2008-03-06 18:38:38.000000000 +0100
@@ -5,6 +5,9 @@
 SRC  = $(wildcard *.c)
 CPPSRC = $(wildcard *.cpp)
 CSRC = $(wildcard *.cc) 
+ifdef FREEBSD
+DEFINES += -DFreeBSD
+endif
 
 DESTDIR = /usr/local
 
diff -ur streamdev-20070921.orig/libdvbmpeg/ctools.c streamdev-20070921/libdvbmpeg/ctools.c
--- streamdev-20070921.orig/libdvbmpeg/ctools.c	2007-03-19 13:05:25.000000000 +0100
+++ streamdev-20070921/libdvbmpeg/ctools.c	2008-03-06 18:29:52.000000000 +0100
@@ -2060,7 +2060,11 @@
 	if (break_up_filename(name,base_name,path,ext) < 0) exit(1);
 
 
+#ifdef FreeBSD
+	if ( (fdin = open(name, O_RDONLY)) < 0){
+#else
 	if ( (fdin = open(name, O_RDONLY|O_LARGEFILE)) < 0){
+#endif
 		fprintf(stderr,"Can't open %s\n",name);
 		exit(1);
 	}
@@ -2101,8 +2105,12 @@
 		sprintf(new_name,"%s-%03d.%s",base_name,i,ext);
 		printf("writing %s\n",new_name);
 
+#ifdef FreeBSD
+		if ( (fdout = open(new_name,O_WRONLY|O_CREAT|O_TRUNC,
+#else
 		if ( (fdout = open(new_name,O_WRONLY|O_CREAT|O_TRUNC
 				   |O_LARGEFILE,
+#endif
 				   S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|
 				   S_IROTH|S_IWOTH)) < 0){
 			fprintf(stderr,"Can't open %s\n",new_name);
@@ -2114,8 +2122,12 @@
 	sprintf(new_name,"%s-%03d.%s",base_name,i,ext);
 	printf("writing %s\n",new_name);
 
+#ifdef FreeBSD
+	if ( (fdout = open(new_name,O_WRONLY|O_CREAT|O_TRUNC,
+#else
 	if ( (fdout = open(new_name,O_WRONLY|O_CREAT|O_TRUNC
 			   |O_LARGEFILE,
+#endif
 			   S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|
 			   S_IROTH|S_IWOTH)) < 0){
 		fprintf(stderr,"Can't open %s\n",new_name);
@@ -2144,7 +2156,11 @@
 	if (break_up_filename(name,base_name,path,ext) < 0) exit(1);
 
 
+#ifdef FreeBSD
+	if ( (fdin = open(name, O_RDONLY)) < 0){
+#else
 	if ( (fdin = open(name, O_RDONLY|O_LARGEFILE)) < 0){
+#endif
 		fprintf(stderr,"Can't open %s\n",name);
 		exit(1);
 	}
@@ -2182,8 +2198,12 @@
 	sprintf(new_name,"%s-1.%s",base_name,ext);
 	printf("writing %s\n",new_name);
 
+#ifdef FreeBSD
+	if ( (fdout = open(new_name,O_WRONLY|O_CREAT|O_TRUNC,
+#else
 	if ( (fdout = open(new_name,O_WRONLY|O_CREAT|O_TRUNC
 			   |O_LARGEFILE,
+#endif
 			   S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|
 			   S_IROTH|S_IWOTH)) < 0){
 		fprintf(stderr,"Can't open %s\n",new_name);
@@ -2195,8 +2215,12 @@
 	sprintf(new_name,"%s-2.%s",base_name,ext);
 	printf("writing %s\n",new_name);
 
+#ifdef FreeBSD
+	if ( (fdout = open(new_name,O_WRONLY|O_CREAT|O_TRUNC,
+#else
 	if ( (fdout = open(new_name,O_WRONLY|O_CREAT|O_TRUNC
 			   |O_LARGEFILE,
+#endif
 			   S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|
 			   S_IROTH|S_IWOTH)) < 0){
 		fprintf(stderr,"Can't open %s\n",new_name);
diff -ur streamdev-20070921.orig/server/connectionVTP.c streamdev-20070921/server/connectionVTP.c
--- streamdev-20070921.orig/server/connectionVTP.c	2007-09-21 14:46:33.000000000 +0200
+++ streamdev-20070921/server/connectionVTP.c	2008-03-06 19:05:45.000000000 +0100
@@ -186,7 +186,11 @@
 	case Event:
 		if (m_Event != NULL) {
 			m_State = Title;
+#ifdef FreeBSD
+			return m_Client->Respond(-215, "E %u %d %d %X", m_Event->EventID(),
+#else
 			return m_Client->Respond(-215, "E %u %ld %d %X", m_Event->EventID(),
+#endif
 			                         m_Event->StartTime(), m_Event->Duration(), 
 			                         m_Event->TableID());
 		} else {
@@ -225,7 +229,11 @@
 	case Vps:
 		m_State = EndEvent;
 		if (m_Event->Vps())
+#ifdef FreeBSD
+			return m_Client->Respond(-215, "V %d", m_Event->Vps());
+#else
 			return m_Client->Respond(-215, "V %ld", m_Event->Vps());
+#endif
 		else
 			return Next(Last);
 		break;
diff -ur streamdev-20070921.orig/tools/socket.c streamdev-20070921/tools/socket.c
--- streamdev-20070921.orig/tools/socket.c	2007-09-21 13:18:42.000000000 +0200
+++ streamdev-20070921/tools/socket.c	2008-03-06 18:24:27.000000000 +0100
@@ -153,5 +153,9 @@
 
 bool cTBSocket::SetDSCP(void) {
 	int dscp = STREAMDEV_DSCP;
+#ifdef FreeBSD
+	return ::setsockopt(*this, IPPROTO_IP, IP_TOS, &dscp, sizeof(dscp)) != -1;
+#else
 	return ::setsockopt(*this, SOL_IP, IP_TOS, &dscp, sizeof(dscp)) != -1;
+#endif
 }
