You are not logged in.
Pages: 1
For all of you who use mt-daapd I have made a patch to have it use avahi instead of howl. Thanks to codemac for the help. Anywho I'd like some people to test it for me.
# Maintainer: William Rea <sillywilly@gmail.com>
pkgname=mt-daapd
pkgver=0.2.3
pkgrel=5
pkgdesc="A multi-threaded DAAP server compatible with iTunes music sharing"
url="http://www.mt-daapd.org/"
license="LGPL"
backup=(etc/mt-daapd/mt-daapd.conf etc/mt-daapd/sample.playlist)
depends=('libid3tag' 'gdbm' 'avahi')
source=(http://dl.sourceforge.net/$pkgname/$pkgname-$pkgver.tar.gz
mt-daapd mt-daapd-stable-avahi.diff)
md5sums=('17aa3fa0601cbe172d18f53489141e5a' '33e2962287f561d3bc35907b90c31b3a'
'2a6f0aad854d10a9d4792017ed348ec4')
build() {
cd $startdir/src/$pkgname-$pkgver
patch -p1 -i ../mt-daapd-stable-avahi.diff
autoreconf -i
./configure --prefix=/usr --sysconfdir=/etc/mt-daapd --enable-avahi
find -name main.c -exec
sed -i 's|DEFAULT_CONFIGFILE "/etc/mt-daapd.conf"|DEFAULT_CONFIGFILE "/etc/mt-daapd/mt-daapd.conf"|' {} ;
make || return 1
make prefix=$startdir/pkg/usr install || return 1
install -D -m775 $startdir/src/$pkgname-$pkgver/contrib/mt-daapd.playlist $startdir/pkg/etc/mt-daapd/sample.playlist
install -D -m775 $startdir/src/$pkgname-$pkgver/contrib/mt-daapd.conf $startdir/pkg/etc/mt-daapd/mt-daapd.conf
install -D -m755 $startdir/src/mt-daapd $startdir/pkg/etc/rc.d/mt-daapd
}
--- mt-daapd-0.2.3/src/daapd.h 2005-01-29 22:58:36.000000000 -0800
+++ mt-daapd-0.2.3-new/src/daapd.h 2006-02-16 22:46:44.000000000 -0800
@@ -48,6 +48,7 @@
int stop; /**< Time to exit? */
int reload; /**< Time to reload and/or rescan the database? */
char *configfile; /**< path to config file */
+ char *iface; /**< interface to advertise on */
char *web_root; /**< path to the directory containing the admin-root files */
int port; /**< port to listen on */
int rescan_interval; /**< How often to do a background rescan of the file system */
--- mt-daapd-0.2.3/src/configfile.c 2005-01-29 20:32:35.000000000 -0800
+++ mt-daapd-0.2.3-new/src/configfile.c 2006-02-16 21:26:57.000000000 -0800
@@ -27,7 +27,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include "config.h"
#endif
#define _POSIX_PTHREAD_SEMANTICS
@@ -116,6 +116,7 @@
{ 1,0,0,CONFIG_TYPE_INT,"compress",(void*)&config.compress,config_emit_int },
{ 1,0,0,CONFIG_TYPE_STRING,"playlist",(void*)&config.playlist,config_emit_string },
{ 1,0,0,CONFIG_TYPE_STRING,"extensions",(void*)&config.extensions,config_emit_string },
+ { 1,0,0,CONFIG_TYPE_STRING,"interface",(void*)&config.iface,config_emit_string },
{ 1,0,0,CONFIG_TYPE_STRING,"password",(void*)&config.readpassword, config_emit_string },
{ 1,0,0,CONFIG_TYPE_STRING,"logfile",(void*)&config.logfile, config_emit_string },
{ 0,0,0,CONFIG_TYPE_SPECIAL,"release",(void*)VERSION,config_emit_literal },
@@ -262,6 +263,7 @@
config.web_root=NULL;
config.adminpassword=NULL;
config.readpassword=NULL;
+ config.iface=NULL;
config.mp3dir=NULL;
config.playlist=NULL;
config.runas=NULL;
--- mt-daapd-0.2.3/src/Makefile.am 2005-02-05 12:54:55.000000000 -0800
+++ mt-daapd-0.2.3-new/src/Makefile.am 2006-02-18 08:21:45.000000000 -0800
@@ -14,6 +14,10 @@
HRENDSRC=rend-howl.c rend-unix.c
endif
+if COND_REND_AVAHI
+ARENDSRC=rend-avahi.c
+endif
+
if COND_REND_OSX
ORENDSRC=rend-osx.c rend-unix.c
endif
@@ -28,10 +32,10 @@
mp3-scanner.h mp3-scanner.c playlist.c playlist.h
rend-unix.h lexer.l parser.y strcasestr.c strcasestr.h strsep.c
redblack.c redblack.h dynamic-art.c dynamic-art.h query.c query.h
- $(PRENDSRC) $(ORENDSRC) $(HRENDSRC) $(OGGVORBISSRC)
+ $(PRENDSRC) $(ORENDSRC) $(HRENDSRC) $(OGGVORBISSRC) rend-avahi.c rend-avahi.h
EXTRA_DIST = mDNS.c mDNSClientAPI.h mDNSDebug.h mDNSPosix.c
mDNSUNP.c mDNSPlatformFunctions.h mDNSPosix.h mDNSUNP.h
rend-howl.c rend-posix.c rend-osx.c db-memory.c
db-gdbm.c strcasestr.h redblack.c redblack.h db-memory.c
- parser.h ogg.c
+ parser.h ogg.c rend-avahi.c rend-avahi.h
--- mt-daapd-0.2.3/configure.in 2005-09-11 12:17:51.000000000 -0700
+++ mt-daapd-0.2.3-new/configure.in 2006-02-18 20:42:16.000000000 -0800
@@ -30,7 +30,7 @@
AC_ARG_ENABLE(mdns,[ --enable-mdns Enable mDNS support],
[ case "${enableval}" in
yes) ;;
- no) rend_posix=false; rend_howl=false; CPPFLAGS="${CPPFLAGS} -DWITHOUT_MDNS";;
+ no) rend_posix=false; rend_howl=false; rend_avahi=false; CPPFLAGS="${CPPFLAGS}";;
*) AC_MSG_ERROR(bad value ${enableval} for --disable-mdns);;
esac ])
@@ -41,18 +41,28 @@
AC_ARG_ENABLE(howl,[ --enable-howl Use howl 0.9.2 or later],
[ case "${enableval}" in
- yes) rend_howl=true; rend_posix=false; LDFLAGS="${LDFLAGS} -lhowl";
+ yes) rend_howl=true; rend_posix=false; rend_avahi=false; LDFLAGS="${LDFLAGS} -lhowl";
CPPFLAGS="${CPPFLAGS} -DWITH_HOWL";;
no) rend_howl=false;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-howl);;
esac ])
+AC_ARG_ENABLE(avahi,[ --enable-avahi Use avahi 0.6 or later],
+ [ case "${enableval}" in
+ yes) PKG_CHECK_MODULES(AVAHI, [ avahi-client >= 0.6 ]);
+ rend_avahi=true; rend_howl=false; rend_posix=false; LDFLAGS="${LDFLAGS} $AVAHI_LIBS";
+ CPPFLAGS="${CPPFLAGS} $AVAHI_CFLAGS -DWITH_AVAHI -DWITHOUT_MDNS";;
+ no) rend_avahi=false;;
+ *) AC_MSG_ERROR(bad value ${enableval} for --enable-howl);;
+ esac ])
+
AC_ARG_ENABLE(oggvorbis,[ --enable-oggvorbis Enable Ogg/Vorbis support],
use_oggvorbis=true;
# LDFLAGS="${LDFLAGS} -logg -lvorbis";
CPPFLAGS="${CPPFLAGS} -DOGGVORBIS")
AM_CONDITIONAL(COND_REND_HOWL, test x$rend_howl = xtrue)
+AM_CONDITIONAL(COND_REND_AVAHI, test x$rend_avahi = xtrue)
AM_CONDITIONAL(COND_REND_POSIX, test x$rend_posix = xtrue)
AM_CONDITIONAL(COND_OGGVORBIS, test x$use_oggvorbis = xtrue)
--- mt-daapd-0.2.3/src/main.c 2005-02-05 12:54:55.000000000 -0800
+++ mt-daapd-0.2.3-new/src/main.c 2006-02-16 19:03:43.000000000 -0800
@@ -50,7 +50,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include "config.h"
#endif
#include <errno.h>
@@ -81,7 +81,11 @@
#include "dynamic-art.h"
#ifndef WITHOUT_MDNS
-# include "rend.h"
+#include "rend.h"
+#endif
+
+#ifdef WITH_AVAHI
+#include "rend-avahi.h"
#endif
/**
@@ -895,6 +899,12 @@
}
#endif
+#ifdef WITH_AVAHI
+ if(config.use_mdns) {
+ DPRINTF(E_LOG, L_MAIN|L_REND, "Registering rendezvous names via avahin");
+ rend_avahi_start(config.servername,config.port,config.iface);
+ }
+#endif
end_time=time(NULL);
DPRINTF(E_LOG,L_MAIN,"Scanned %d songs in %d secondsn",db_get_song_count(),
@@ -939,6 +949,12 @@
}
#endif
+#ifdef WITH_AVAHI
+ if(config.use_mdns) {
+ DPRINTF(E_LOG, L_MAIN|L_REND, "Stop publishing daap with avahin");
+ rend_avahi_stop();
+ }
+#endif
DPRINTF(E_LOG,L_MAIN,"Stopping signal handlern");
if(!pthread_kill(signal_tid,SIGINT)) {
--- mt-daapd-0.2.3/src/rend-avahi.c 1969-12-31 16:00:00.000000000 -0800
+++ mt-daapd-0.2.3-new/src/rend-avahi.c 2006-02-16 17:53:44.000000000 -0800
@@ -0,0 +1,193 @@
+/*
+ * Rendezvous support with avahi
+ *
+ * Copyright (C) 2005 Sebastian Dröge <slomo@ubuntu.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <assert.h>
+#include <pthread.h>
+#include <net/if.h>
+
+#include <avahi-client/client.h>
+#include <avahi-client/publish.h>
+
+#include <avahi-client/client.h>
+#include <avahi-common/alternative.h>
+#include <avahi-common/error.h>
+#include <avahi-common/simple-watch.h>
+#include <avahi-common/timeval.h>
+#include <avahi-common/malloc.h>
+
+#include "err.h"
+
+static AvahiClient *mdns_client = NULL;
+static AvahiEntryGroup *mdns_group = NULL;
+static AvahiSimplePoll *simple_poll = NULL;
+
+static char *mdns_name = NULL;
+static int mdns_port = 0;
+static AvahiIfIndex mdns_interface = AVAHI_IF_UNSPEC;
+
+static pthread_t rend_tid;
+
+static void add_services(AvahiClient *client);
+
+static void entry_group_callback(AvahiEntryGroup *g, AvahiEntryGroupState state, AVAHI_GCC_UNUSED void *userdata) {
+ assert(g == mdns_group);
+
+ char *new_name = NULL;
+ switch (state) {
+ case AVAHI_ENTRY_GROUP_ESTABLISHED:
+ DPRINTF(E_DBG, L_REND, "Successfully added mdns servicesn");
+ break;
+ case AVAHI_ENTRY_GROUP_COLLISION:
+ new_name = avahi_alternative_service_name(mdns_name);
+ DPRINTF(E_WARN, L_REND, "mdns service name collision. Renamed service %s -> %sn", mdns_name, new_name);
+ free(mdns_name);
+ mdns_name = new_name;
+ add_services(avahi_entry_group_get_client(g));
+ break;
+ case AVAHI_ENTRY_GROUP_FAILURE :
+ avahi_simple_poll_quit(simple_poll);
+ break;
+ case AVAHI_ENTRY_GROUP_UNCOMMITED:
+ case AVAHI_ENTRY_GROUP_REGISTERING:
+ break;
+ }
+}
+
+static void add_services(AvahiClient *client) {
+ int ret = 0;
+
+ if (mdns_group == NULL) {
+ if (!(mdns_group = avahi_entry_group_new(client, entry_group_callback, NULL))) {
+ DPRINTF(E_WARN, L_REND, "Could not create AvahiEntryGroup: %sn", avahi_strerror(avahi_client_errno(client)));
+ return;
+ }
+ }
+
+ if ((ret = avahi_entry_group_add_service(mdns_group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0,
+ mdns_name, "_http._tcp", NULL, NULL, mdns_port, "txtvers=1",
+ "Database ID=beddab1edeadbea7", NULL)) < 0) {
+ DPRINTF(E_WARN, L_REND, "Could not add mdns services: %sn", avahi_strerror(ret));
+ return;
+ }
+
+ if ((ret = avahi_entry_group_add_service(mdns_group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0,
+ mdns_name, "_daap._tcp", NULL, NULL, mdns_port, "txtvers=1",
+ "Database ID=beddab1edeadbea7", NULL)) < 0) {
+ DPRINTF(E_WARN, L_REND, "Could not add mdns services: %sn", avahi_strerror(avahi_client_errno(ret)));
+ return;
+ }
+
+ if ((ret = avahi_entry_group_commit(mdns_group)) < 0) {
+ DPRINTF(E_WARN, L_REND, "Could not commit mdns services: %sn", avahi_strerror(avahi_client_errno(ret)));
+ return;
+ }
+}
+
+static void *rend_poll(void *arg) {
+ int ret;
+ while((ret = avahi_simple_poll_iterate(simple_poll ,-1)) == 0);
+
+ if (ret < 0) {
+ DPRINTF(E_WARN, L_REND, "Avahi poll thread quit with error: %sn", avahi_strerror(avahi_client_errno(ret)));
+ } else {
+ DPRINTF(E_DBG, L_REND, "Avahi poll thread quitn");
+ }
+
+ return NULL;
+}
+
+static void client_callback(AvahiClient *c, AvahiClientState state, AVAHI_GCC_UNUSED void * userdata) {
+ assert(c);
+ switch(state) {
+ case AVAHI_CLIENT_S_RUNNING:
+ DPRINTF(E_DBG, L_REND, "Adding mdns servicesn");
+ add_services(c);
+ break;
+ case AVAHI_CLIENT_S_COLLISION:
+ if (mdns_group)
+ avahi_entry_group_reset(mdns_group);
+ break;
+ case AVAHI_CLIENT_FAILURE:
+ DPRINTF(E_WARN, L_REND, "Client failure: %sn", avahi_strerror(avahi_client_errno(c)));
+ avahi_simple_poll_quit(simple_poll);
+ break;
+ case AVAHI_CLIENT_S_REGISTERING:
+ break;
+ }
+}
+
+int rend_avahi_start(char *name, int port, char *interface) {
+ const AvahiPoll *poll_api = NULL;
+ int error;
+
+ assert(name != NULL);
+ assert(port != 0);
+
+ mdns_name = strdup(name);
+ mdns_port = port;
+ if ((interface != NULL) && (if_nametoindex(interface) != 0))
+ mdns_interface = if_nametoindex(interface);
+ else
+ mdns_interface = AVAHI_IF_UNSPEC;
+
+ DPRINTF(E_DBG, L_REND, "Initializing avahin");
+ simple_poll = avahi_simple_poll_new();
+ poll_api = avahi_simple_poll_get(simple_poll);
+
+ if (!(mdns_client = avahi_client_new(avahi_simple_poll_get(simple_poll), 0, client_callback, NULL, &error))) {
+ DPRINTF(E_WARN, L_REND, "Error initializing avahi: %sn", avahi_strerror(avahi_client_errno(error)));
+ avahi_simple_poll_free(simple_poll);
+ return -1;
+ }
+
+ DPRINTF(E_DBG, L_REND, "Starting avahi polling threadn");
+
+ if (pthread_create(&rend_tid, NULL, rend_poll, NULL)) {
+ DPRINTF(E_FATAL, L_REND, "Could not start avahi polling thread. Terminatingn");
+ /* should kill parent, too */
+ exit(EXIT_FAILURE);
+ }
+
+ return 0;
+}
+
+int rend_avahi_stop() {
+ avahi_simple_poll_quit(simple_poll);
+
+ if (mdns_name != NULL)
+ free(mdns_name);
+ if (mdns_group != NULL)
+ avahi_entry_group_free(mdns_group);
+ if (mdns_client != NULL)
+ avahi_client_free(mdns_client);
+ return 0;
+}
+
+int rend_running(void) {
+ return 0;
+}
diff -Naur mt-daapd-old/src/rend-avahi.h mt-daapd/src/rend-avahi.h
--- mt-daapd-old/src/rend-avahi.h 1970-01-01 01:00:00.000000000 +0100
+++ mt-daapd/src/rend-avahi.h 2005-11-02 19:57:04.278253000 +0100
@@ -0,0 +1,28 @@
+/*
+ * Rendezvous support with avahi
+ *
+ * Copyright (C) 2005 Sebastian Dröge <slomo@ubuntu.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef _REND_AVAHI_H_
+#define _REND_AVAHI_H_
+
+extern int rend_avahi_start(char *name, int port, char *interface);
+extern int rend_avahi_stop(void);
+extern int rend_avahi_running(void);
+
+#endif /* _REND_AVAHI_H */
Offline
now add virtual hosts and it will have everything i need!
Offline
:-P
Offline
I just uploaded mt-daapd with avahi support. Have fun.
Offline
Pages: 1