Public feed #891091

alok

public text v1 · immutable
Raw Edit
·published 2008-02-04 10:24 UTC
rendered paste body
Index: acinclude.m4
===================================================================
RCS file: /cvsroot/bluez/utils/acinclude.m4,v
retrieving revision 1.124
diff -u -5 -p -r1.124 acinclude.m4
--- acinclude.m4	1 Feb 2008 12:53:27 -0000	1.124
+++ acinclude.m4	4 Feb 2008 10:23:23 -0000
@@ -60,14 +60,17 @@ AC_DEFUN([AC_INIT_BLUEZ], [
 	else
 		storagedir="${localstatedir}/lib/bluetooth"
 	fi
 
 	servicedir="${libdir}/bluetooth"
+	
+	plugindir="${libdir}/bluetooth"
 
 	AC_DEFINE_UNQUOTED(CONFIGDIR, "${configdir}", [Directory for the configuration files])
 	AC_DEFINE_UNQUOTED(STORAGEDIR, "${storagedir}", [Directory for the storage files])
 	AC_DEFINE_UNQUOTED(SERVICEDIR, "${servicedir}", [Directory for the service programs])
+	AC_DEFINE_UNQUOTED(PLUGINDIR, "${plugindir}", [Directory for the telephony plugins])
 ])
 
 AC_DEFUN([AC_PATH_BLUEZ], [
 	PKG_CHECK_MODULES(BLUEZ, bluez, dummy=yes, AC_MSG_ERROR(Bluetooth library is required))
 	AC_SUBST(BLUEZ_CFLAGS)
Index: audio/Makefile.am
===================================================================
RCS file: /cvsroot/bluez/utils/audio/Makefile.am,v
retrieving revision 1.46
diff -u -5 -p -r1.46 Makefile.am
--- audio/Makefile.am	23 Jan 2008 15:18:15 -0000	1.46
+++ audio/Makefile.am	4 Feb 2008 10:23:23 -0000
@@ -14,11 +14,11 @@ bluetoothd_service_audio_SOURCES = main.
 	manager.h manager.c headset.h headset.c ipc.h ipc.c unix.h unix.c \
 	device.h device.c gateway.h gateway.c \
 	sink.c sink.h avdtp.c avdtp.h a2dp.c a2dp.h control.c control.h
 
 bluetoothd_service_audio_LDADD = $(top_builddir)/common/libhelper.a \
-				@GLIB_LIBS@ @DBUS_LIBS@ @BLUEZ_LIBS@
+				@GLIB_LIBS@ @DBUS_LIBS@ @BLUEZ_LIBS@ @GMODULE_LIBS@
 
 if ALSA
 alsadir = $(libdir)/alsa-lib
 
 alsa_LTLIBRARIES = libasound_module_pcm_bluetooth.la libasound_module_ctl_bluetooth.la
@@ -52,13 +52,12 @@ libgstbluetooth_la_LDFLAGS = -module -av
 libgstbluetooth_la_LIBADD = @SBC_LIBS@ @GSTREAMER_LIBS@ -lgstaudio-0.10 -lgstrtp-0.10
 libgstbluetooth_la_CFLAGS = @GSTREAMER_CFLAGS@ @SBC_CFLAGS@
 endif
 endif
 
-AM_CFLAGS = @BLUEZ_CFLAGS@ @DBUS_CFLAGS@ @GLIB_CFLAGS@
+AM_CFLAGS = @BLUEZ_CFLAGS@ @DBUS_CFLAGS@ @GLIB_CFLAGS@ @GMODULE_CFLAGS@
 
 INCLUDES = -I$(top_srcdir)/common
 
 EXTRA_DIST = audio.service audio.conf audio-api.txt test-audio asound.conf
 
 MAINTAINERCLEANFILES = Makefile.in
-
Index: audio/audio.conf
===================================================================
RCS file: /cvsroot/bluez/utils/audio/audio.conf,v
retrieving revision 1.5
diff -u -5 -p -r1.5 audio.conf
--- audio/audio.conf	23 Jan 2008 13:27:30 -0000	1.5
+++ audio/audio.conf	4 Feb 2008 10:23:23 -0000
@@ -30,9 +30,13 @@ VoiceTags=false
 RejectingCalls=false
 EnhancedCallStatus=false
 EnhancedCallControl=false
 ExtendedErrorResultCodes=false
 
+#HFP telephony plugin options 
+Plugin=default 
+#Values can be openmoko, telepathy or default 
+
 # Just an example of potential config options for the other interfaces
 #[A2DP]
 #SBCSources=1
 #MPEG12Sources=0
Index: audio/manager.c
===================================================================
RCS file: /cvsroot/bluez/utils/audio/manager.c,v
retrieving revision 1.88
diff -u -5 -p -r1.88 manager.c
--- audio/manager.c	23 Jan 2008 13:27:30 -0000	1.88
+++ audio/manager.c	4 Feb 2008 10:23:23 -0000
@@ -35,10 +35,12 @@
 #include <sys/stat.h>
 #include <dirent.h>
 #include <ctype.h>
 #include <signal.h>
 
+#include <gmodule.h>
+
 #include <bluetooth/bluetooth.h>
 #include <bluetooth/hci.h>
 #include <bluetooth/hci_lib.h>
 #include <bluetooth/rfcomm.h>
 #include <bluetooth/sdp.h>
@@ -105,10 +107,12 @@ static uint32_t hs_record_id = 0;
 static uint32_t hf_record_id = 0;
 
 static GIOChannel *hs_server = NULL;
 static GIOChannel *hf_server = NULL;
 
+static GModule *hfp_plugin = NULL;
+
 static struct enabled_interfaces enabled = {
 	.headset	= TRUE,
 	.gateway	= FALSE,
 	.sink		= TRUE,
 	.source		= FALSE,
@@ -1534,10 +1538,39 @@ static GIOChannel *server_socket(uint8_t
 	}
 
 	return io;
 }
 
+int load_hfp_plugin(GKeyFile *config)
+{
+	gchar *str = NULL;
+	GError *err = NULL;
+	char filename[PATH_MAX];
+
+	str = g_key_file_get_string(config, "Headset", "Plugin", &err);
+
+	if (err) {
+		debug("audio.conf: %s", err->message);
+		g_error_free(err);
+		err = NULL;
+		return -1;
+	}
+
+	snprintf(filename, sizeof(filename) - 1, "%s/hfp_plugin_%s.so",PLUGINDIR, str);
+	g_free(str);
+	debug("filename is %s",filename);
+
+	hfp_plugin = g_module_open(filename, G_MODULE_BIND_LAZY);
+
+	if (!hfp_plugin) {
+		debug("Error loading HFP plugin:%s", g_module_error ());
+		return -1;
+	}
+
+	return 0;
+}
+
 static int headset_server_init(DBusConnection *conn, GKeyFile *config)
 {
 	uint8_t chan = DEFAULT_HS_AG_CHANNEL;
 	sdp_buf_t buf;
 	gboolean no_hfp = FALSE;
@@ -1585,11 +1618,14 @@ static int headset_server_init(DBusConne
 
 	hf_server = server_socket(&chan);
 	if (!hf_server)
 		return -1;
 
-	features = headset_config_init(config);
+	if (load_hfp_plugin(config) < 0)
+		return -1;
+
+	features = headset_config_init(config, hfp_plugin);
 
 	if (hfp_ag_record(&buf, chan, features) < 0) {
 		error("Unable to allocate new service record");
 		return -1;
 	}
@@ -1721,10 +1757,14 @@ failed:
 
 void audio_exit(void)
 {
 	server_exit();
 
+	if (hfp_plugin) {
+		if (!g_module_close(hfp_plugin))
+			debug("Error Unloading plugin:%s", g_module_error ());
+	}
 	dbus_connection_destroy_object_path(connection, AUDIO_MANAGER_PATH);
 
 	dbus_connection_unref(connection);
 
 	connection = NULL;
Index: audio/headset.h
===================================================================
RCS file: /cvsroot/bluez/utils/audio/headset.h,v
retrieving revision 1.36
diff -u -5 -p -r1.36 headset.h
--- audio/headset.h	22 Jan 2008 18:01:19 -0000	1.36
+++ audio/headset.h	4 Feb 2008 10:23:23 -0000
@@ -45,11 +45,11 @@ typedef void (*headset_stream_cb_t) (str
 struct headset *headset_init(struct device *dev, sdp_record_t *record,
 				uint16_t svc);
 
 void headset_free(struct device *dev);
 
-uint32_t headset_config_init(GKeyFile *config);
+uint32_t headset_config_init(GKeyFile *config, GModule *hfp_handle);
 
 void headset_update(struct device *dev, sdp_record_t *record, uint16_t svc);
 
 unsigned int headset_request_stream(struct device *dev, headset_stream_cb_t cb,
 					void *user_data);
Index: audio/headset.c
===================================================================
RCS file: /cvsroot/bluez/utils/audio/headset.c,v
retrieving revision 1.166
diff -u -5 -p -r1.166 headset.c
--- audio/headset.c	24 Jan 2008 11:16:15 -0000	1.166
+++ audio/headset.c	4 Feb 2008 10:23:25 -0000
@@ -45,10 +45,11 @@
 #include <bluetooth/rfcomm.h>
 #include <bluetooth/sdp.h>
 #include <bluetooth/sdp_lib.h>
 
 #include <glib.h>
+#include <gmodule.h>
 
 #include <dbus/dbus.h>
 
 #include "dbus.h"
 #include "dbus-helper.h"
@@ -1692,11 +1693,11 @@ register_iface:
 	}
 
 	return hs;
 }
 
-uint32_t headset_config_init(GKeyFile *config)
+uint32_t headset_config_init(GKeyFile *config, GModule *hfp_handle)
 {
 	GError *err = NULL;
 	gboolean value;
 	char *str;