summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>2015-11-22 21:20:28 +0100
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2015-12-01 10:42:28 +0200
commit8e36432fde853262c241abb283f4435c7928239f (patch)
treeea64db7e8be09bfa8542561f12d2d5078cc955ab
parent3b0536837611d7c3bc4a881586138aff8f776e74 (diff)
downloadbluez-8e36432fde853262c241abb283f4435c7928239f.tar.gz
monitor/avdtp: Decode basic Media Codec capabilities
> ACL Data RX: Handle 256 flags 0x02 dlen 20 Channel: 66 len 16 [PSM 25 mode 0] {chan 2} AVDTP: Get Capabilities (0x02) Response Accept (0x02) type 0x00 label 1 nosp 0 Service Category: Media Transport (0x01) Service Category: Media Codec (0x07) Media Type: Audio (0x00) Media Codec: SBC (0x00) 3f ff 02 35 ?..5 Service Category: Content Protection (0x04) 02 00 ..
-rw-r--r--monitor/avdtp.c66
1 files changed, 62 insertions, 4 deletions
diff --git a/monitor/avdtp.c b/monitor/avdtp.c
index 3b2271e6e..8041d35f6 100644
--- a/monitor/avdtp.c
+++ b/monitor/avdtp.c
@@ -181,6 +181,24 @@ static const char *mediatype2str(uint8_t media_type)
}
}
+static const char *mediacodec2str(uint8_t codec)
+{
+ switch (codec) {
+ case 0x00:
+ return "SBC";
+ case 0x01:
+ return "MPEG-1,2 Audio";
+ case 0x02:
+ return "MPEG-2,4 AAC";
+ case 0x04:
+ return "ATRAC Family";
+ case 0xff:
+ return "Non-A2DP";
+ default:
+ return "Reserved";
+ }
+}
+
static const char *servicecat2str(uint8_t service_cat)
{
switch (service_cat) {
@@ -218,6 +236,34 @@ static bool avdtp_reject_common(struct avdtp_frame *avdtp_frame)
return true;
}
+static bool service_media_codec(struct avdtp_frame *avdtp_frame, uint8_t losc)
+{
+ struct l2cap_frame *frame = &avdtp_frame->l2cap_frame;
+ uint8_t type = 0;
+ uint8_t codec = 0;
+
+ if (losc < 2)
+ return false;
+
+ l2cap_frame_get_u8(frame, &type);
+ l2cap_frame_get_u8(frame, &codec);
+
+ losc -= 2;
+
+ print_field("%*cMedia Type: %s (0x%02x)", 2, ' ',
+ mediatype2str(type >> 4), type >> 4);
+
+ print_field("%*cMedia Codec: %s (0x%02x)", 2, ' ',
+ mediacodec2str(codec), codec);
+
+ /* TODO: decode codec specific information */
+
+ packet_hexdump(frame->data, losc);
+ l2cap_frame_pull(frame, frame, losc);
+
+ return true;
+}
+
static bool decode_capabilities(struct avdtp_frame *avdtp_frame)
{
struct l2cap_frame *frame = &avdtp_frame->l2cap_frame;
@@ -234,11 +280,23 @@ static bool decode_capabilities(struct avdtp_frame *avdtp_frame)
if (frame->size < losc)
return false;
- /* TODO: decode service capabilities */
-
- packet_hexdump(frame->data, losc);
+ switch (service_cat) {
+ case AVDTP_MEDIA_CODEC:
+ if (!service_media_codec(avdtp_frame, losc))
+ return false;
+ break;
+ case AVDTP_MEDIA_TRANSPORT:
+ case AVDTP_REPORTING:
+ case AVDTP_RECOVERY:
+ case AVDTP_CONTENT_PROTECTION:
+ case AVDTP_HEADER_COMPRESSION:
+ case AVDTP_MULTIPLEXING:
+ case AVDTP_DELAY_REPORTING:
+ default:
+ packet_hexdump(frame->data, losc);
+ l2cap_frame_pull(frame, frame, losc);
+ }
- l2cap_frame_pull(frame, frame, losc);
}
return true;