mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-24 12:40:47 +00:00
avrcp: only parse get element attributes for AVRCP_CTYPE_RESPONSE_IMPLEMENTED_STABLE or AVRCP_CTYPE_RESPONSE_CHANGED_STABLE
This commit is contained in:
parent
849f10d83f
commit
4bb88fd7fc
@ -864,42 +864,45 @@ static void avrcp_handle_l2cap_data_packet_for_signaling_connection(avrcp_connec
|
|||||||
uint8_t num_string_attributes = 0;
|
uint8_t num_string_attributes = 0;
|
||||||
uint16_t total_event_payload_for_string_attributes = HCI_EVENT_PAYLOAD_SIZE-2;
|
uint16_t total_event_payload_for_string_attributes = HCI_EVENT_PAYLOAD_SIZE-2;
|
||||||
uint16_t max_string_attribute_value_len = 0;
|
uint16_t max_string_attribute_value_len = 0;
|
||||||
for (i = 0; i < num_attributes; i++){
|
if (ctype == AVRCP_CTYPE_RESPONSE_IMPLEMENTED_STABLE || ctype == AVRCP_CTYPE_RESPONSE_CHANGED_STABLE){
|
||||||
avrcp_media_attribute_id_t attr_id = big_endian_read_32(packet, pos);
|
for (i = 0; i < num_attributes; i++){
|
||||||
pos += 4;
|
avrcp_media_attribute_id_t attr_id = big_endian_read_32(packet, pos);
|
||||||
// uint16_t character_set = big_endian_read_16(packet, pos);
|
pos += 4;
|
||||||
pos += 2;
|
// uint16_t character_set = big_endian_read_16(packet, pos);
|
||||||
uint16_t attr_value_length = big_endian_read_16(packet, pos);
|
pos += 2;
|
||||||
pos += 2;
|
uint16_t attr_value_length = big_endian_read_16(packet, pos);
|
||||||
|
pos += 2;
|
||||||
|
|
||||||
// debug - to remove later
|
// debug - to remove later
|
||||||
uint8_t value[100];
|
uint8_t value[100];
|
||||||
uint16_t value_len = sizeof(value) <= attr_value_length? sizeof(value) - 1 : attr_value_length;
|
uint16_t value_len = sizeof(value) <= attr_value_length? sizeof(value) - 1 : attr_value_length;
|
||||||
memcpy(value, packet+pos, value_len);
|
memcpy(value, packet+pos, value_len);
|
||||||
value[value_len] = 0;
|
value[value_len] = 0;
|
||||||
// printf("Now Playing Info %s: %s \n", attribute2str(attr_id), value);
|
// printf("Now Playing Info %s: %s \n", attribute2str(attr_id), value);
|
||||||
// end debug
|
// end debug
|
||||||
|
|
||||||
if ((attr_id >= 1) || (attr_id <= AVRCP_MEDIA_ATTR_COUNT)) {
|
if ((attr_id >= 1) || (attr_id <= AVRCP_MEDIA_ATTR_COUNT)) {
|
||||||
items[attr_id-1].len = attr_value_length;
|
items[attr_id-1].len = attr_value_length;
|
||||||
items[attr_id-1].value = &packet[pos];
|
items[attr_id-1].value = &packet[pos];
|
||||||
switch (attr_id){
|
switch (attr_id){
|
||||||
case AVRCP_MEDIA_ATTR_TITLE:
|
case AVRCP_MEDIA_ATTR_TITLE:
|
||||||
case AVRCP_MEDIA_ATTR_ARTIST:
|
case AVRCP_MEDIA_ATTR_ARTIST:
|
||||||
case AVRCP_MEDIA_ATTR_ALBUM:
|
case AVRCP_MEDIA_ATTR_ALBUM:
|
||||||
case AVRCP_MEDIA_ATTR_GENRE:
|
case AVRCP_MEDIA_ATTR_GENRE:
|
||||||
num_string_attributes++;
|
num_string_attributes++;
|
||||||
string_attributes_len += attr_value_length;
|
string_attributes_len += attr_value_length;
|
||||||
if (max_string_attribute_value_len < attr_value_length){
|
if (max_string_attribute_value_len < attr_value_length){
|
||||||
max_string_attribute_value_len = attr_value_length;
|
max_string_attribute_value_len = attr_value_length;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
pos += attr_value_length;
|
||||||
}
|
}
|
||||||
pos += attr_value_length;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// subtract space for fixed fields
|
// subtract space for fixed fields
|
||||||
total_event_payload_for_string_attributes -= 14 + 4; // 4 for '\0'
|
total_event_payload_for_string_attributes -= 14 + 4; // 4 for '\0'
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user