[pulseaudio-discuss] [RFCv2 02/17] bluetooth: Register Handsfree Audio Agent object path on the bus
jprvita at gmail.com
jprvita at gmail.com
Mon Apr 15 14:53:17 PDT 2013
From: João Paulo Rechi Vita <jprvita at openbossa.org>
This commit creates the Handsfree Audio Agent object path on
/HFPAudioAgent and implements the D-Bus introspection for it.
---
src/modules/bluetooth/bluetooth-util.c | 48 +++++++++++++++++++++++++++-------
1 file changed, 39 insertions(+), 9 deletions(-)
diff --git a/src/modules/bluetooth/bluetooth-util.c b/src/modules/bluetooth/bluetooth-util.c
index 260c24e..9d4f097 100644
--- a/src/modules/bluetooth/bluetooth-util.c
+++ b/src/modules/bluetooth/bluetooth-util.c
@@ -36,6 +36,7 @@
#define HFP_HS_ENDPOINT "/MediaEndpoint/HFPHS"
#define A2DP_SOURCE_ENDPOINT "/MediaEndpoint/A2DPSource"
#define A2DP_SINK_ENDPOINT "/MediaEndpoint/A2DPSink"
+#define HFP_AUDIO_AGENT_PATH "/HFPAudioAgent"
#define ENDPOINT_INTROSPECT_XML \
DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE \
@@ -85,6 +86,24 @@
" </interface>" \
"</node>"
+#define HFP_AUDIO_AGENT_XML \
+ "<node name=\"/test/hf\">" \
+ " <interface name=\"org.freedesktop.DBus.Introspectable\">" \
+ " <method name=\"Introspect\">" \
+ " <arg direction=\"out\" type=\"s\" />" \
+ " </method>" \
+ " </interface>" \
+ " <interface name=\"org.ofono.HandsfreeAudioAgent\">" \
+ " <method name=\"Release\">" \
+ " </method>" \
+ " <method name=\"NewConnection\">" \
+ " <arg direction=\"in\" type=\"o\" name=\"card_path\" />" \
+ " <arg direction=\"in\" type=\"h\" name=\"sco_fd\" />" \
+ " <arg direction=\"in\" type=\"y\" name=\"codec\" />" \
+ " </method>" \
+ " </interface>" \
+ "</node>"
+
typedef enum pa_bluez_version {
BLUEZ_VERSION_UNKNOWN,
BLUEZ_VERSION_4,
@@ -2075,7 +2094,7 @@ fail:
return r;
}
-static DBusHandlerResult endpoint_handler(DBusConnection *c, DBusMessage *m, void *userdata) {
+static DBusHandlerResult dbus_msg_handler(DBusConnection *c, DBusMessage *m, void *userdata) {
struct pa_bluetooth_discovery *y = userdata;
DBusMessage *r = NULL;
DBusError e;
@@ -2092,13 +2111,18 @@ static DBusHandlerResult endpoint_handler(DBusConnection *c, DBusMessage *m, voi
dbus_error_init(&e);
if (!pa_streq(path, A2DP_SOURCE_ENDPOINT) && !pa_streq(path, A2DP_SINK_ENDPOINT) && !pa_streq(path, HFP_AG_ENDPOINT) &&
- !pa_streq(path, HFP_HS_ENDPOINT))
+ !pa_streq(path, HFP_HS_ENDPOINT) && !pa_streq(path, HFP_AUDIO_AGENT_PATH))
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
interface = y->version == BLUEZ_VERSION_4 ? "org.bluez.MediaEndpoint" : "org.bluez.MediaEndpoint1";
if (dbus_message_is_method_call(m, "org.freedesktop.DBus.Introspectable", "Introspect")) {
- const char *xml = y->version == BLUEZ_VERSION_4 ? ENDPOINT_INTROSPECT_XML : MEDIA_ENDPOINT_1_INTROSPECT_XML;
+ const char *xml;
+
+ if (pa_streq(path, HFP_AUDIO_AGENT_PATH))
+ xml = HFP_AUDIO_AGENT_XML;
+ else
+ xml = y->version == BLUEZ_VERSION_4 ? ENDPOINT_INTROSPECT_XML : MEDIA_ENDPOINT_1_INTROSPECT_XML;
pa_assert_se(r = dbus_message_new_method_return(m));
pa_assert_se(dbus_message_append_args(r, DBUS_TYPE_STRING, &xml, DBUS_TYPE_INVALID));
@@ -2109,6 +2133,10 @@ static DBusHandlerResult endpoint_handler(DBusConnection *c, DBusMessage *m, voi
r = endpoint_select_configuration(c, m, userdata);
else if (dbus_message_is_method_call(m, interface, "ClearConfiguration"))
r = endpoint_clear_configuration(c, m, userdata);
+ else if (dbus_message_is_method_call(m, "org.ofono.HandsfreeAudioAgent", "Release"))
+ pa_assert_se(r = dbus_message_new_method_return(m));
+ else if (dbus_message_is_method_call(m, "org.ofono.HandsfreeAudioAgent", "NewConnection"))
+ pa_assert_se(r = dbus_message_new_method_return(m));
else
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
@@ -2125,8 +2153,8 @@ pa_bluetooth_discovery* pa_bluetooth_discovery_get(pa_core *c) {
pa_bluetooth_discovery *y;
DBusConnection *conn;
unsigned i;
- static const DBusObjectPathVTable vtable_endpoint = {
- .message_function = endpoint_handler,
+ static const DBusObjectPathVTable vt = {
+ .message_function = dbus_msg_handler,
};
pa_assert(c);
@@ -2188,10 +2216,11 @@ pa_bluetooth_discovery* pa_bluetooth_discovery_get(pa_core *c) {
goto fail;
}
- pa_assert_se(dbus_connection_register_object_path(conn, HFP_AG_ENDPOINT, &vtable_endpoint, y));
- pa_assert_se(dbus_connection_register_object_path(conn, HFP_HS_ENDPOINT, &vtable_endpoint, y));
- pa_assert_se(dbus_connection_register_object_path(conn, A2DP_SOURCE_ENDPOINT, &vtable_endpoint, y));
- pa_assert_se(dbus_connection_register_object_path(conn, A2DP_SINK_ENDPOINT, &vtable_endpoint, y));
+ pa_assert_se(dbus_connection_register_object_path(conn, HFP_AG_ENDPOINT, &vt, y));
+ pa_assert_se(dbus_connection_register_object_path(conn, HFP_HS_ENDPOINT, &vt, y));
+ pa_assert_se(dbus_connection_register_object_path(conn, A2DP_SOURCE_ENDPOINT, &vt, y));
+ pa_assert_se(dbus_connection_register_object_path(conn, A2DP_SINK_ENDPOINT, &vt, y));
+ pa_assert_se(dbus_connection_register_object_path(conn, HFP_AUDIO_AGENT_PATH, &vt, y));
init_bluez(y);
@@ -2241,6 +2270,7 @@ void pa_bluetooth_discovery_unref(pa_bluetooth_discovery *y) {
dbus_connection_unregister_object_path(pa_dbus_connection_get(y->connection), HFP_HS_ENDPOINT);
dbus_connection_unregister_object_path(pa_dbus_connection_get(y->connection), A2DP_SOURCE_ENDPOINT);
dbus_connection_unregister_object_path(pa_dbus_connection_get(y->connection), A2DP_SINK_ENDPOINT);
+ dbus_connection_unregister_object_path(pa_dbus_connection_get(y->connection), HFP_AUDIO_AGENT_PATH);
pa_dbus_remove_matches(
pa_dbus_connection_get(y->connection),
"type='signal',sender='org.freedesktop.DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged'"
--
1.7.11.7
More information about the pulseaudio-discuss
mailing list