tomclegg.net |
Audio Logger and MP3 Streaming Service Posted May 3, 2003 Install FreeBSD (make sure you install the kernel source code). Log in as root. Build a new kernel with sound support, install it, and reboot to load it. cd /usr/src/sys/i386/conf cp -p -i GENERIC MYKERNEL echo device pcm >>MYKERNEL config MYKERNEL cd ../../compile/MYKERNEL make make install reboot Install cd /usr/ports/sysutils/psmisc make install clean Install daemontools from ports. cd /usr/ports/sysutils/daemontools make install clean Arrange for mkdir /service /var/service cat <<'EOF' >/usr/local/etc/rc.d/000.svscan.sh #!/bin/sh PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin case "$1" in start) exec env - PATH="$PATH" \ svscan /service 2>/dev/null >/dev/null & ;; stop) killall svscan cd /service svc -dx * svc -dx */log ;; esac EOF chmod +x /usr/local/etc/rc.d/000.svscan.sh Start /usr/local/etc/rc.d/000.svscan.sh start Install ucspi-tcp from ports. cd /usr/ports/sysutils/ucspi-tcp && make install clean Install lame from ports. cd /usr/ports/audio/lame && make install clean cd /usr/local/src fetch http://tomclegg.net/software/dsprec-0.2.tar.gz tar xzf dsprec-0.2.tar.gz cd dsprec-0.2 make make install cd /usr/local/src fetch http://tomclegg.net/software/mp3cat-0.4.tar.gz tar xzf mp3cat-0.4.tar.gz cd mp3cat-0.4 make make install Set up a logging service. Raw audio is read from cd /var/service pw useradd mp3log -d /nonexistent -s /usr/bin/true pw useradd mp3logl -d /nonexistent -s /usr/bin/true mp3log-conf mp3log mp3logl /var/service/mp3log /var/log/mp3log /dev/dsp 32 Start the MP3 logging and cleaning services. chown root:mp3log /dev/dsp chmod 660 /dev/dsp ln -s /var/service/mp3log /service/ ln -s /var/service/mp3log-clean /service/ Optional: set up an MP3 streaming service. cd /var/service pw useradd mp3stream -d /nonexistent -s /usr/bin/true pw useradd mp3streaml -d /nonexistent -s /usr/bin/true mp3stream-conf mp3stream mp3streaml /var/service/mp3stream /var/log/mp3log YOUR.IP.ADDR.HERE Start the MP3 stream service. ln -s /var/service/mp3stream /service/ Wait 5 seconds for |-svscan-+-supervise---multilog(mp3streaml) | |-supervise---tcpserver(mp3stream) | |-supervise---sh(mp3log)---sleep | |-supervise---multilog(mp3logl) | `-supervise---sh(mp3log)-+-dsprec | |-lame | `-mp3cat Listen to the stream by opening uname -a | mail -s 'my logger works!' tom@tomclegg.net |