Re: [Bluez-devel] AVDTP socket?

Brad Midgley
2004-11-19T23:23:09Z

Marcel,

Shouldn't this work to send the header in a separate write() and have a
struct for it?

I thought everything ended up being little-endian on the wire, but

buf[2] = seq_num >> 8;
buf[3] = seq_num & 0xff;

looks big endian to me (00 then 01 for 0x0001). When my code writes to
sequence_number, it comes out little endian (01 then 00 for 0x0001).

Brad

while(!terminate) {
- memset(buf, 0, 12);
- buf[0] = 0x80;
- buf[2] = seq_num >> 8;
- buf[3] = seq_num & 0xff;
- buf[12] = 0xff;
- buf[13] = 0xff;
- size = read(fd, buf + 14, mtu - 14);
+ memset(&packet_header, 0, sizeof(packet_header));
+ packet_header.cc = 8;
+ packet_header.sequence_number = htobs(seq_num);
+ packet_header.csrc[0] = htobl(0xffff0000);
+
+ // dump_packet(&packet_header, sizeof(packet_header)); exit(0);
+
+ size = read(fd, buf, mtu - sizeof(packet_header));
seq_num++;
if(size <= 0) {
terminate = 1;
} else {
- // framing, fragmenting, a2dp headers: avdtp p.45 and a2dp spec p.23
- write(streamfd, buf, size + 14);
+ // avdtp p.45
+ write(streamfd, &packet_header, sizeof(packet_header));
+ // what about framing, fragmenting, a2dp headers (a2dp spec p.23)
+ write(streamfd, buf, size);
}
}
close(fd);