portability or VDR on FreeBSD

Message ID 20080306191453.B44873@unqrf.nqzva.sez2
State New
Headers

Commit Message

Joerg Pulz March 6, 2008, 6:49 p.m. UTC
  -----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Hello list.

As the subject already says, this is about VDR portability, or how to get 
VDR up  and running on a FreeBSD system.
In times where we have such really nice plugins like softdevice and 
streamdev, we no longer need real MPEG2 or DVB hardware in a VDR system.
As i want to use my FreeBSD systems to watch TV or play VDR recordings i 
decided to give porting VDR to FreeBSD a try.
Attached you can find the results.
In short terms: It simply works!
The only missing feature right now is, starting VDR as root and switching 
to another user (-u command line option).
For now it is possible to watch any recording made by a VDR with real 
hardware if the video directory is directly accessible over the network 
(mountable by the client) or the use the streamdev plugin to stream VDR to 
VDR.
All tests where done using a Linux system with two FF-DVB-S devices, 
streamdev-server plugin and NFS exported video directory plus a wired and 
a wireless FreeBSD-7.0 client running VDR with streamdev-client and 
softdevice plugin.
As far as i could test the whole setup until now, everything works the 
same way on FreeBSD as it does under Linux and i now have real 
channel-hopping.

The patches are made in a way that a patched VDR will still compile under 
Linux. Every modification, to the source or to the Makefiles is ifdef'd 
out. So unless you say you want to compile VDR for FreeBSD you have an 
unmodified version of source.

In case the ML software strips the attachments, the files are also 
available for download at: ftp://ftp.frm2.tum.de/pub/jpulz/VDR/

Thoughts or comments from others are welcome.

regards
Joerg

- -- 
The beginning is the most important part of the work.
  				-Plato
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.4 (FreeBSD)

iD8DBQFH0Dy8SPOsGF+KA+MRAmVBAJ9Tzfxg0zWNN/fEX8vfeMOW2muvSACgivha
raTzC4R92jZ+Petp9Mqwr9E=
=f08n
-----END PGP SIGNATURE-----
  

Comments

Joerg Pulz March 7, 2008, 7:08 p.m. UTC | #1
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Replying to myself.

The next patches are ready, this time for the mp3/mplayer plugins and the 
dvd plugin.
The patches can be found at ftp://ftp.frm2.tum.de/pub/jpulz/VDR/ .
I've written a small README.FreeBSD as quickstart guide available at the 
above link too.
I've not attached the patches to this mail to not pollute the list with 
stuff of lower interest for the bigger part of the VDR community.

FYI,
Joerg

- -- 
The beginning is the most important part of the work.
 				-Plato
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.4 (FreeBSD)

iD8DBQFH0ZLJSPOsGF+KA+MRAkBuAKDL+IlOqmNV3Ovvhta8ZIOYnem4UwCeMpkw
pUelj8VUSSJuw7rutnvFnos=
=3dLl
-----END PGP SIGNATURE-----
  
Joerg Pulz March 11, 2008, 7:32 p.m. UTC | #2
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


On Fri, 7 Mar 2008, Joerg Pulz wrote:

> Replying to myself.
>
> The next patches are ready, this time for the mp3/mplayer plugins and the
> dvd plugin.
> The patches can be found at ftp://ftp.frm2.tum.de/pub/jpulz/VDR/ .
> I've written a small README.FreeBSD as quickstart guide available at the
> above link too.
> I've not attached the patches to this mail to not pollute the list with
> stuff of lower interest for the bigger part of the VDR community.

And again, replying to myself.

The next round of patches is there. Available at the same place as 
mentioned above. The README got an update too.
There is still full Linux compatibility, so the patched version of VDR and 
the plugins can be compiled on a Linux box without any difference to the 
unpatched version.

As always, comments are welcome.

FYI,
Joerg

- -- 
The beginning is the most important part of the work.
 				-Plato
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.4 (FreeBSD)

iD8DBQFH1t5ISPOsGF+KA+MRAgYUAKDMAdZJe75PMFp1iztlkD1ldl9f5QCfQEKt
G+3Tz55z0J/9pyjfuWPcEto=
=M+bc
-----END PGP SIGNATURE-----
  
Juergen Lock July 10, 2010, 8:55 p.m. UTC | #3
In article <20080311202112.I44873@unqrf.nqzva.sez2> you write:
>-----BEGIN PGP SIGNED MESSAGE-----
>Hash: SHA1
>
>
>On Fri, 7 Mar 2008, Joerg Pulz wrote:
>
>> Replying to myself.
>>
>> The next patches are ready, this time for the mp3/mplayer plugins and the
>> dvd plugin.
>> The patches can be found at ftp://ftp.frm2.tum.de/pub/jpulz/VDR/ .
>> I've written a small README.FreeBSD as quickstart guide available at the
>> above link too.
>> I've not attached the patches to this mail to not pollute the list with
>> stuff of lower interest for the bigger part of the VDR community.
>
>And again, replying to myself.
>
>The next round of patches is there. Available at the same place as 
>mentioned above. The README got an update too.
>There is still full Linux compatibility, so the patched version of VDR and 
>the plugins can be compiled on a Linux box without any difference to the 
>unpatched version.
>
>As always, comments are welcome.

Hi!

 (This is mostly for the list since Joerg already knows...)

 I meanwhile have ported a few more plugins and the live and
vdradmin-am webinterfaces and am updating a preliminary shar that
can be used to install all that the FreeBSD /usr/ports way.  (tho
there are still rough edges and the ports are not commit-ready yet.)
See here:

	http://people.freebsd.org/~nox/dvb/

 And yes you can now also use tuners on FreeBSD mainly thanx to
webcamd: (I am using a PCTV 452e Sat HDTV Pro USB dvb-s2 one.)

	http://www.freshports.org/multimedia/webcamd

 Back to portability:  I you look at the patches in the shar,

	http://people.freebsd.org/~nox/dvb/vdrdevel-preliminary.shar

i.e. everything called */vdr*/files/patch-* in there (many are
from Joerg but I meanwhile also added quite a few), I think at least
those parts that touch C(++) sources and headers should be ready to
be merged back upstream (Makefile patches maybe less so) - so maybe
we should start submitting them back to the individual maintainers...

 Anyway, now you know. :)

 Cheers,
	Juergen
  

Patch

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
 }