};
static char *avrcp_control_path = NULL;
+static char *avrcp_transport_path = NULL;
void _bt_set_control_device_path(const char *path)
{
return control_path;
}
+static char *__bt_get_transport_device_path(void)
+{
+ char *adapter_path;
+ char *transport_path;
+ char connected_address[BT_ADDRESS_STRING_SIZE + 1];
+
+ BT_DBG("+");
+
+ if (avrcp_transport_path != NULL)
+ return avrcp_transport_path;
+
+ retv_if(!_bt_is_headset_type_connected(BT_AVRCP,
+ connected_address), NULL);
+
+ BT_DBG("device address = %s", connected_address);
+
+ adapter_path = _bt_get_device_object_path(connected_address);
+ retv_if(adapter_path == NULL, NULL);
+
+ transport_path = g_strdup_printf(BT_MEDIA_TRANSPORT_PATH, adapter_path);
+ g_free(adapter_path);
+
+ avrcp_transport_path = transport_path;
+ BT_DBG("transport_path = %s", transport_path);
+ return transport_path;
+}
+
static int __bt_media_send_control_msg(const char *name)
{
GVariant *reply = NULL;
return proxy;
}
+GDBusProxy *__bt_get_transport_properties_proxy(void)
+{
+ GDBusProxy *proxy = NULL;
+ GError *error = NULL;
+ char *transport_path = NULL;
+ GDBusConnection *conn = NULL;
+
+ transport_path = __bt_get_transport_device_path();
+ retv_if(transport_path == NULL, NULL);
+ BT_DBG("transport_path = %s", transport_path);
+
+ conn = _bt_gdbus_get_system_gconn();
+ retv_if(conn == NULL, NULL);
+
+ proxy = g_dbus_proxy_new_sync(conn,
+ G_DBUS_PROXY_FLAGS_NONE, NULL,
+ BT_BLUEZ_NAME, transport_path,
+ BT_PROPERTIES_INTERFACE, NULL, &error);
+ if (proxy == NULL) {
+ BT_ERR("Unable to allocate new proxy");
+ if (error) {
+ BT_ERR("%s", error->message);
+ g_clear_error(&error);
+ }
+ return NULL;
+ }
+
+ return proxy;
+}
+
static int __bt_media_attr_to_event(const char *str)
{
if (!strcasecmp(str, "Equalizer"))
return NULL;
}
+static const char *__bt_transport_type_to_str(int type)
+{
+ switch (type) {
+ case DELAY:
+ return "Delay";
+ case VOLUME:
+ return "Volume";
+ }
+ return NULL;
+}
+
static int __bt_media_attrval_to_val(int type, const char *value)
{
int ret = 0;
return BLUETOOTH_ERROR_NONE;
}
+int _bt_avrcp_transport_set_property(int type, unsigned int value)
+{
+ GDBusProxy *proxy = NULL;
+ GError *error = NULL;
+ GVariant *reply, *param;
+ uint16_t property_level = (uint16_t)value;
+
+ switch (type) {
+ case DELAY:
+ param = g_variant_new("q", property_level);
+ BT_INFO("delay level %d", property_level);
+ break;
+ case VOLUME:
+ param = g_variant_new("q", property_level);
+ BT_INFO("volume level %d", property_level);
+ break;
+ default:
+ BT_ERR("Invalid property type: %d", type);
+ return BLUETOOTH_ERROR_INTERNAL;
+ }
+
+ proxy = __bt_get_transport_properties_proxy();
+ retv_if(proxy == NULL, BLUETOOTH_ERROR_NOT_CONNECTED);
+
+ reply = g_dbus_proxy_call_sync(proxy,
+ "Set", g_variant_new("(ssv)", BT_MEDIATRANSPORT_INTERFACE, __bt_transport_type_to_str(type), param),
+ G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+
+ g_object_unref(proxy);
+ g_variant_unref(param);
+
+ if (!reply) {
+ BT_ERR("Can't get managed objects");
+ if (error) {
+ BT_ERR("SetProperty Fail: %s", error->message);
+ g_clear_error(&error);
+ return BLUETOOTH_ERROR_INTERNAL;
+ }
+ }
+
+ g_variant_unref(reply);
+
+ return BLUETOOTH_ERROR_NONE;
+}
+
static int __bt_avrcp_control_parse_properties(
media_metadata_attributes_t *metadata,
GVariant *item)
metadata->genre = g_strdup(value_string);
} else if (strcasecmp(key, "Duration") == 0) {
value_uint = g_variant_get_uint32(value);
+ BT_DBG("Duration : %d", value_uint);
metadata->duration = value_uint;
} else if (strcasecmp(key, "NumberOfTracks") == 0) {
value_uint = g_variant_get_uint32(value);