Allow audio packets as well as resends on the control port. Add some debug messages.

This commit is contained in:
Mike Brady
2018-04-11 20:05:21 +01:00
parent 70d51b6722
commit fd7c2d7954
3 changed files with 39 additions and 20 deletions
+1 -1
View File
@@ -223,7 +223,7 @@ int dacp_send_command(const char *command, char **body, ssize_t *bodysize) {
if (setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, (const char *)&tv, sizeof tv) == -1)
debug(1, "Error %d setting receive timeout for DACP service.", errno);
int ndata = recv(sockfd, buffer, sizeof(buffer), 0);
debug(3, "Received %d bytes: \"%s\".", ndata, buffer);
// debug(3, "Received %d bytes: \"%s\".", ndata, buffer);
if (ndata <= 0) {
debug(1, "dacp_send_command -- error receiving response for command \"%s\".",
command);
+6 -3
View File
@@ -1173,7 +1173,7 @@ static abuf_t *buffer_get_frame(rtsp_conn_info *conn) {
if (!conn->ab_buffering) {
// check once, after a short period of has elapsed, assuming 352 frames per packet
i = ((250 * 44100) / 352) / 1000; // approx 250 ms
i = ((125 * 44100) / 352) / 1000; // approx 125 ms
if (i < seq_diff(conn->ab_read, conn->ab_write, conn->ab_read)) {
seq_t next = seq_sum(conn->ab_read, i);
abuf = conn->audio_buffer + BUFIDX(next);
@@ -1686,7 +1686,7 @@ static void *player_thread_func(void *arg) {
config.output->play(silence, conn->max_frames_per_packet * conn->output_sample_ratio);
} else if (frames_to_drop) {
if (frames_to_drop > 3 * config.output_rate)
warn("Very large number of frames to drop: %" PRId64 ".",frames_to_drop);
warn("Very large number of frames to drop: %" PRId64 ".", frames_to_drop);
debug(3, "%" PRId64 " frames to drop.", frames_to_drop);
frames_to_drop -= inframe->length;
if (frames_to_drop < 0)
@@ -1888,7 +1888,10 @@ static void *player_thread_func(void *arg) {
(!conn->player_thread_please_stop) && (config.resyncthreshold > 0.0) &&
(abs_sync_error > config.resyncthreshold * config.output_rate)) {
if (abs_sync_error > 3 * config.output_rate) {
warn("Very large sync error: %" PRId64 " frames, with a delay of %" PRId64 "frames.",sync_error,delay);
warn("Very large sync error: %" PRId64 " frames, with delay: %" PRId64
", td_in_frames: %" PRId64 ", rt: %" PRId64 ", nt: %" PRId64
", current_delay: %" PRId64 ", frames.",
sync_error, delay, td_in_frames, rt, nt, current_delay);
}
sync_error_out_of_bounds++;
} else {
+32 -16
View File
@@ -134,6 +134,7 @@ void *rtp_audio_receiver(void *arg) {
if (type == 0x56) {
pktp += 4;
plen -= 4;
debug(1, "resent packet %u received in audio port.", ntohs(*(uint16_t *)(pktp + 2)));
}
seq_t seqno = ntohs(*(uint16_t *)(pktp + 2));
// increment last_seqno and see if it's the same as the incoming seqno
@@ -344,27 +345,42 @@ void *rtp_control_receiver(void *arg) {
} else {
debug(1, "Sync packet received before we got a timing packet back.");
}
} else if (packet[1] == 0xd6) { // resent audio data in the control path -- whaale only?
// debug(1, "Control Port -- Retransmitted Audio Data Packet received.");
pktp = packet + 4;
plen -= 4;
seq_t seqno = ntohs(*(uint16_t *)(pktp + 2));
} else {
uint8_t type = packet[1] & ~0x80;
if ((type == 0x60) ||
(type == 0x56)) { // audio data / resent audio data in the control path -- whaale only?
pktp = packet;
int64_t timestamp = monotonic_timestamp(ntohl(*(uint32_t *)(pktp + 4)), conn);
if (type == 0x56) { // resent audio data in the control path -- whaale only?
// debug(1, "Control Port -- Retransmitted Audio Data Packet received.");
pktp = packet + 4;
plen -= 4;
}
pktp += 12;
plen -= 12;
seq_t seqno = ntohs(*(uint16_t *)(pktp + 2));
if (type == 0x56)
debug(1, "Resent audio packet %u received in the control port.", seqno);
else
debug(1, "Audio packet %u received in the control port.", seqno);
// check if packet contains enough content to be reasonable
if (plen >= 16) {
player_put_packet(seqno, timestamp, pktp, plen, conn);
continue;
int64_t timestamp = monotonic_timestamp(ntohl(*(uint32_t *)(pktp + 4)), conn);
pktp += 12;
plen -= 12;
// check if packet contains enough content to be reasonable
if (plen >= 16) {
player_put_packet(seqno, timestamp, pktp, plen, conn);
continue;
} else {
debug(3, "Too-short retransmitted audio packet received in control port, ignored.");
}
} else {
debug(3, "Too-short retransmitted audio packet received in control port, ignored.");
debug(1, "Control Port -- Unknown RTP packet of type 0x%02X length %d, ignored.", packet[1],
nread);
}
} else
debug(1, "Control Port -- Unknown RTP packet of type 0x%02X length %d, ignored.", packet[1],
nread);
}
}
debug(3, "Control RTP thread interrupted. terminating.");