diff --git a/android/hal-audio-sbc.c b/android/hal-audio-sbc.c
index 8366978..ad20f51 100644
--- a/android/hal-audio-sbc.c
+++ b/android/hal-audio-sbc.c
#endif
struct media_packet_sbc {
- struct media_packet hdr;
+ struct media_packet_rtp hdr;
struct rtp_payload payload;
uint8_t data[0];
};
static const struct audio_codec codec = {
.type = A2DP_CODEC_SBC,
+ .use_rtp = true,
.get_presets = sbc_get_presets,
diff --git a/android/hal-audio.c b/android/hal-audio.c
index 49393e2..946a835 100644
--- a/android/hal-audio.c
+++ b/android/hal-audio.c
DBG("mtu=%u", mtu);
- payload_len = mtu - sizeof(*ep->mp);
+ payload_len = mtu;
+ if (ep->codec->use_rtp)
+ payload_len -= sizeof(struct rtp_header);
ep->fd = fd;
ep->mp = calloc(mtu, 1);
if (!ep->mp)
goto failed;
- ep->mp->hdr.v = 2;
- ep->mp->hdr.pt = 0x60;
- ep->mp->hdr.ssrc = htonl(1);
+
+ if (ep->codec->use_rtp) {
+ struct media_packet_rtp *mp_rtp =
+ (struct media_packet_rtp *) ep->mp;
+ mp_rtp->hdr.v = 2;
+ mp_rtp->hdr.pt = 0x60;
+ mp_rtp->hdr.ssrc = htonl(1);
+ }
ep->mp_data_len = payload_len;
int ret;
while (true) {
- ret = write(ep->fd, mp, sizeof(*mp) + bytes);
+ ret = write(ep->fd, mp, bytes);
if (ret >= 0)
break;
{
struct audio_endpoint *ep = out->ep;
struct media_packet *mp = (struct media_packet *) ep->mp;
+ struct media_packet_rtp *mp_rtp = (struct media_packet_rtp *) ep->mp;
size_t free_space = ep->mp_data_len;
size_t consumed = 0;
* prepare media packet in advance so we don't waste time after
* wakeup
*/
- mp->hdr.sequence_number = htons(ep->seq++);
- mp->hdr.timestamp = htonl(ep->samples);
+ if (ep->codec->use_rtp) {
+ mp_rtp->hdr.sequence_number = htons(ep->seq++);
+ mp_rtp->hdr.timestamp = htonl(ep->samples);
+ }
read = ep->codec->encode_mediapacket(ep->codec_data,
buffer + consumed,
bytes - consumed, mp,
if (!wait_for_endpoint(ep, &do_write))
return false;
- if (do_write)
+ if (do_write) {
+ if (ep->codec->use_rtp)
+ written += sizeof(struct rtp_header);
+
if (!write_to_endpoint(ep, written))
return false;
+ }
}
/*
diff --git a/android/hal-audio.h b/android/hal-audio.h
index dc1a812..be71473 100644
--- a/android/hal-audio.h
+++ b/android/hal-audio.h
#endif
struct media_packet {
+ uint8_t data[0];
+};
+
+struct media_packet_rtp {
struct rtp_header hdr;
uint8_t data[0];
};
struct audio_codec {
uint8_t type;
+ bool use_rtp;
int (*get_presets) (struct audio_preset *preset, size_t *len);