diff --git a/Makefile.plugins b/Makefile.plugins
index 7644041..97335d6 100644
--- a/Makefile.plugins
+++ b/Makefile.plugins
builtin_modules += policy
builtin_sources += plugins/policy.c
+builtin_sources += profiles/audio/media.h profiles/audio/media.c \
+ profiles/audio/transport.h profiles/audio/transport.c \
+ profiles/audio/player.h profiles/audio/player.c
+
if ADMIN
builtin_modules += admin
builtin_sources += plugins/admin.c
profiles/audio/sink.h profiles/audio/sink.c \
profiles/audio/a2dp.h profiles/audio/a2dp.c \
profiles/audio/avdtp.h profiles/audio/avdtp.c \
- profiles/audio/media.h profiles/audio/media.c \
- profiles/audio/transport.h profiles/audio/transport.c \
profiles/audio/a2dp-codecs.h
endif
builtin_modules += avrcp
builtin_sources += profiles/audio/control.h profiles/audio/control.c \
profiles/audio/avctp.h profiles/audio/avctp.c \
- profiles/audio/avrcp.h profiles/audio/avrcp.c \
- profiles/audio/player.h profiles/audio/player.c
+ profiles/audio/avrcp.h profiles/audio/avrcp.c
endif
if NETWORK
diff --git a/configure.ac b/configure.ac
index 01f0f2b..964206b 100644
--- a/configure.ac
+++ b/configure.ac
AC_ARG_ENABLE(avrcp, AS_HELP_STRING([--disable-avrcp],
[disable AVRCP profile]), [enable_avrcp=${enableval}])
AM_CONDITIONAL(AVRCP, test "${enable_avrcp}" != "no")
+if test "${enable_avrcp}" != "no"; then
+ AC_DEFINE(HAVE_AVRCP, 1, [Define to 1 if you have AVRCP support.])
+fi
AC_ARG_ENABLE(network, AS_HELP_STRING([--disable-network],
[disable network profiles]), [enable_network=${enableval}])
diff --git a/profiles/audio/media.c b/profiles/audio/media.c
index 062475e..69c6dc6 100644
--- a/profiles/audio/media.c
+++ b/profiles/audio/media.c
#include "media.h"
#include "transport.h"
#include "a2dp.h"
+
+#ifdef HAVE_AVRCP
#include "avrcp.h"
+#endif
#define MEDIA_INTERFACE "org.bluez.Media1"
#define MEDIA_ENDPOINT_INTERFACE "org.bluez.MediaEndpoint1"
char *path; /* Application object path */
struct queue *proxies; /* Application proxies */
struct queue *endpoints; /* Application endpoints */
+#ifdef HAVE_AVRCP
struct queue *players; /* Application players */
+#endif
int err;
};
struct btd_adapter *btd_adapter;
struct queue *apps; /* Application list */
GSList *endpoints; /* Endpoints list */
+#ifdef HAVE_AVRCP
GSList *players; /* Players list */
+#endif
};
struct endpoint_request {
int8_t media_player_get_device_volume(struct btd_device *device)
{
+#ifdef HAVE_AVRCP
struct avrcp_player *target_player;
struct media_adapter *adapter;
GSList *l;
}
done:
+#endif /* HAVE_AVRCP */
/* If media_player doesn't exists use device_volume */
return btd_device_get_volume(device);
}
return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
}
+#ifdef HAVE_AVRCP
static struct media_player *media_adapter_find_player(
struct media_adapter *adapter,
const char *sender,
return mp;
}
+#endif /* HAVE_AVRCP */
static DBusMessage *register_player(DBusConnection *conn, DBusMessage *msg,
void *data)
{
+#ifdef HAVE_AVRCP
struct media_adapter *adapter = data;
struct media_player *mp;
DBusMessageIter args;
}
return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
+#else
+ return btd_error_not_supported(msg);
+#endif
}
static DBusMessage *unregister_player(DBusConnection *conn, DBusMessage *msg,
void *data)
{
+#ifdef HAVE_AVRCP
struct media_adapter *adapter = data;
struct media_player *player;
const char *sender, *path;
media_player_remove(player);
return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
+#else
+ return btd_error_not_supported(msg);
+#endif
}
static void app_free(void *data)
queue_destroy(app->proxies, NULL);
queue_destroy(app->endpoints, media_endpoint_remove);
+#ifdef HAVE_AVRCP
queue_destroy(app->players, media_player_remove);
+#endif
if (app->client) {
g_dbus_client_set_disconnect_watch(app->client, NULL, NULL);
static void app_register_player(void *data, void *user_data)
{
+#ifdef HAVE_AVRCP
struct media_app *app = user_data;
GDBusProxy *proxy = data;
const char *iface = g_dbus_proxy_get_interface(proxy);
error("Unable to register player %s:%s: %s", app->sender, path,
strerror(-app->err));
media_player_destroy(player);
+#endif /* HAVE_AVRCP */
}
static void remove_app(void *data)
goto reply;
}
+#ifdef HAVE_AVRCP
if ((queue_isempty(app->endpoints) && queue_isempty(app->players))) {
+#else
+ if (queue_isempty(app->endpoints)) {
+#endif
error("No valid external Media objects found");
fail = true;
reply = btd_error_failed(app->reg,
return !strcmp(endpoint->path, path);
}
+#ifdef HAVE_AVRCP
static bool match_player_by_path(const void *a, const void *b)
{
const struct media_player *player = a;
return !strcmp(player->path, path);
}
+#endif
static void proxy_removed_cb(GDBusProxy *proxy, void *user_data)
{
struct media_app *app = user_data;
struct media_endpoint *endpoint;
- struct media_player *player;
const char *iface, *path;
iface = g_dbus_proxy_get_interface(proxy);
DBG("Proxy removed - removing endpoint: %s", endpoint->path);
media_endpoint_remove(endpoint);
+#ifdef HAVE_AVRCP
} else if (!strcmp(iface, MEDIA_PLAYER_INTERFACE)) {
+ struct media_player *player;
+
player = queue_remove_if(app->players, match_player_by_path,
(void *) path);
if (!player)
DBG("Proxy removed - removing player: %s", player->path);
media_player_remove(player);
+#endif
}
}
app->proxies = queue_new();
app->endpoints = queue_new();
+#ifdef HAVE_AVRCP
app->players = queue_new();
+#endif
app->reg = dbus_message_ref(msg);
g_dbus_client_set_disconnect_watch(app->client, client_disconnect_cb,
release_endpoint(endpoint);
}
+#ifdef HAVE_AVRCP
for (l = adapter->players; l;) {
struct media_player *mp = l->data;
media_player_destroy(mp);
}
+#endif
adapters = g_slist_remove(adapters, adapter);
diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c
index dbebb1e..1b9c66e 100644
--- a/profiles/audio/transport.c
+++ b/profiles/audio/transport.c
return a2dp->volume;
}
+#ifdef HAVE_AVRCP
static int transport_a2dp_src_set_volume(struct media_transport *transport,
int8_t level)
{
return avrcp_set_volume(transport->device, level, notify);
}
+#endif
static int transport_a2dp_snk_set_delay(struct media_transport *transport,
uint16_t delay)
static const struct media_transport_ops transport_ops[] = {
A2DP_OPS(A2DP_SOURCE_UUID, transport_a2dp_src_init,
+#ifdef HAVE_AVRCP
transport_a2dp_src_set_volume,
+#else
+ NULL,
+#endif
NULL,
transport_a2dp_src_destroy),
A2DP_OPS(A2DP_SINK_UUID, transport_a2dp_snk_init,
+#ifdef HAVE_AVRCP
transport_a2dp_snk_set_volume,
+#else
+ NULL,
+#endif
transport_a2dp_snk_set_delay,
transport_a2dp_snk_destroy),
BAP_UC_OPS(PAC_SOURCE_UUID),