mirror of
https://git.kernel.org/pub/scm/bluetooth/bluez.git
synced 2024-11-29 07:04:19 +08:00
AVRCP: Parse browsing and searching features bits
This parses browsing and searching features bits and set the respective property.
This commit is contained in:
parent
7508d96899
commit
771594ef67
@ -1976,6 +1976,18 @@ static void avrcp_set_browsed_player(struct avrcp *session,
|
||||
avrcp_set_browsed_player_rsp, session);
|
||||
}
|
||||
|
||||
static void avrcp_player_parse_features(struct avrcp_player *player,
|
||||
uint8_t *features)
|
||||
{
|
||||
struct media_player *mp = player->user_data;
|
||||
|
||||
if (features[7] & 0x08)
|
||||
media_player_set_browsable(mp, true);
|
||||
|
||||
if (features[7] & 0x10)
|
||||
media_player_set_searchable(mp, true);
|
||||
}
|
||||
|
||||
static void avrcp_parse_media_player_item(struct avrcp *session,
|
||||
uint8_t *operands, uint16_t len)
|
||||
{
|
||||
@ -1984,7 +1996,6 @@ static void avrcp_parse_media_player_item(struct avrcp *session,
|
||||
uint16_t id;
|
||||
uint32_t subtype;
|
||||
const char *curval, *strval;
|
||||
uint64_t features[2];
|
||||
char name[255];
|
||||
|
||||
if (len < 28)
|
||||
@ -2009,10 +2020,7 @@ static void avrcp_parse_media_player_item(struct avrcp *session,
|
||||
avrcp_get_play_status(session);
|
||||
}
|
||||
|
||||
features[0] = bt_get_be64(&operands[8]);
|
||||
features[1] = bt_get_be64(&operands[16]);
|
||||
|
||||
media_player_set_features(mp, features);
|
||||
avrcp_player_parse_features(player, &operands[8]);
|
||||
|
||||
if (operands[26] != 0) {
|
||||
memcpy(name, &operands[27], operands[26]);
|
||||
|
@ -67,7 +67,9 @@ struct media_player {
|
||||
char *name; /* Player name */
|
||||
char *type; /* Player type */
|
||||
char *subtype; /* Player subtype */
|
||||
uint64_t features[2]; /* Player features */
|
||||
bool browsable; /* Player browsing feature */
|
||||
bool searchable; /* Player searching feature */
|
||||
uint8_t *features; /* Player features */
|
||||
struct media_folder *folder; /* Player currenct folder */
|
||||
char *path; /* Player object path */
|
||||
GHashTable *settings; /* Player settings */
|
||||
@ -350,6 +352,57 @@ static gboolean get_subtype(const GDBusPropertyTable *property,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean browsable_exists(const GDBusPropertyTable *property, void *data)
|
||||
{
|
||||
struct media_player *mp = data;
|
||||
|
||||
return mp->folder != NULL;
|
||||
}
|
||||
|
||||
static gboolean get_browsable(const GDBusPropertyTable *property,
|
||||
DBusMessageIter *iter, void *data)
|
||||
{
|
||||
struct media_player *mp = data;
|
||||
dbus_bool_t value;
|
||||
|
||||
if (mp->folder == NULL)
|
||||
return FALSE;
|
||||
|
||||
DBG("%s", mp->browsable ? "true" : "false");
|
||||
|
||||
value = mp->browsable;
|
||||
|
||||
dbus_message_iter_append_basic(iter, DBUS_TYPE_BOOLEAN, &value);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean searchable_exists(const GDBusPropertyTable *property,
|
||||
void *data)
|
||||
{
|
||||
struct media_player *mp = data;
|
||||
|
||||
return mp->folder != NULL;
|
||||
}
|
||||
|
||||
static gboolean get_searchable(const GDBusPropertyTable *property,
|
||||
DBusMessageIter *iter, void *data)
|
||||
{
|
||||
struct media_player *mp = data;
|
||||
dbus_bool_t value;
|
||||
|
||||
if (mp->folder == NULL)
|
||||
return FALSE;
|
||||
|
||||
DBG("%s", mp->searchable ? "true" : "false");
|
||||
|
||||
value = mp->searchable;
|
||||
|
||||
dbus_message_iter_append_basic(iter, DBUS_TYPE_BOOLEAN, &value);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static DBusMessage *media_player_play(DBusConnection *conn, DBusMessage *msg,
|
||||
void *data)
|
||||
{
|
||||
@ -510,6 +563,10 @@ static const GDBusPropertyTable media_player_properties[] = {
|
||||
G_DBUS_PROPERTY_FLAG_EXPERIMENTAL },
|
||||
{ "Device", "s", get_device, NULL, NULL,
|
||||
G_DBUS_PROPERTY_FLAG_EXPERIMENTAL },
|
||||
{ "Browsable", "b", get_browsable, NULL, browsable_exists,
|
||||
G_DBUS_PROPERTY_FLAG_EXPERIMENTAL },
|
||||
{ "Searchable", "b", get_searchable, NULL, searchable_exists,
|
||||
G_DBUS_PROPERTY_FLAG_EXPERIMENTAL },
|
||||
{ }
|
||||
};
|
||||
|
||||
@ -843,6 +900,20 @@ void media_player_set_name(struct media_player *mp, const char *name)
|
||||
"Name");
|
||||
}
|
||||
|
||||
void media_player_set_browsable(struct media_player *mp, bool enabled)
|
||||
{
|
||||
DBG("%s", enabled ? "true" : "false");
|
||||
|
||||
mp->browsable = enabled;
|
||||
}
|
||||
|
||||
void media_player_set_searchable(struct media_player *mp, bool enabled)
|
||||
{
|
||||
DBG("%s", enabled ? "true" : "false");
|
||||
|
||||
mp->searchable = enabled;
|
||||
}
|
||||
|
||||
void media_player_set_folder(struct media_player *mp, const char *path,
|
||||
uint32_t items)
|
||||
{
|
||||
|
@ -51,6 +51,8 @@ void media_player_set_type(struct media_player *mp, const char *type);
|
||||
void media_player_set_subtype(struct media_player *mp, const char *subtype);
|
||||
void media_player_set_features(struct media_player *mp, uint64_t *features);
|
||||
void media_player_set_name(struct media_player *mp, const char *name);
|
||||
void media_player_set_browsable(struct media_player *mp, bool enabled);
|
||||
void media_player_set_searchable(struct media_player *mp, bool enabled);
|
||||
void media_player_set_folder(struct media_player *mp, const char *path,
|
||||
uint32_t items);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user