free(conn->audio_buffer[i].data);
}
-void player_put_packet(seq_t seqno, int64_t timestamp, uint8_t *data, int len,
+void player_put_packet(seq_t seqno, uint32_t actual_timestamp, int64_t timestamp, uint8_t *data, int len,
rtsp_conn_info *conn) {
// all timestamps are done at the output rate
+ // the "actual_timestamp" is the one that comes in the packet, and is carried over for debugging and checking only.
int64_t ltimestamp = timestamp * conn->output_sample_ratio;
abuf = conn->audio_buffer + BUFIDX(seq_sum(conn->ab_write, i));
abuf->ready = 0; // to be sure, to be sure
abuf->timestamp = 0;
+ abuf->given_timestamp = 0;
abuf->sequence_number = 0;
}
// debug(1,"N %d s %u.",seq_diff(ab_write,PREDECESSOR(seqno))+1,ab_write);
abuf->ready = 1;
abuf->length = datalen;
abuf->timestamp = ltimestamp;
+ abuf->given_timestamp = actual_timestamp;
abuf->sequence_number = seqno;
} else {
debug(1, "Bad audio packet detected and discarded.");
abuf->ready = 0;
abuf->timestamp = 0;
+ abuf->given_timestamp = 0;
abuf->sequence_number = 0;
}
}
if (abs_sync_error > 3 * config.output_rate) {
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);
+ ", current_delay: %" PRId64 ", seqno: %u, given timestamp: %" PRIu32 ".",
+ sync_error, delay, td_in_frames, rt, nt, current_delay, inframe->sequence_number, inframe->given_timestamp);
}
sync_error_out_of_bounds++;
} else {
int ready;
int64_t timestamp;
seq_t sequence_number;
+ uint32_t given_timestamp; // for debugging and checking
signed short *data;
int length; // the length of the decoded data
} abuf_t;
void player_volume(double f, rtsp_conn_info *conn);
void player_volume_without_notification(double f, rtsp_conn_info *conn);
void player_flush(int64_t timestamp, rtsp_conn_info *conn);
-void player_put_packet(seq_t seqno, int64_t timestamp, uint8_t *data, int len,
+void player_put_packet(seq_t seqno, uint32_t actual_timestamp, int64_t timestamp, uint8_t *data, int len,
rtsp_conn_info *conn);
int64_t monotonic_timestamp(uint32_t timestamp,
// debug(3, "RTP: Packets out of sequence: expected: %d, got %d.", last_seqno, seqno);
last_seqno = seqno; // reset warning...
}
- int64_t timestamp = monotonic_timestamp(ntohl(*(uint32_t *)(pktp + 4)), conn);
+ uint32_t actual_timestamp = ntohl(*(uint32_t *)(pktp + 4));
+ int64_t timestamp = monotonic_timestamp(actual_timestamp, conn);
// if (packet[1]&0x10)
// debug(1,"Audio packet Extension bit set.");
// check if packet contains enough content to be reasonable
if (plen >= 16) {
- player_put_packet(seqno, timestamp, pktp, plen, conn);
+ player_put_packet(seqno, actual_timestamp, timestamp, pktp, plen, conn);
continue;
}
if (type == 0x56 && seqno == 0) {
debug(3,"Resent audio packet %u received in the control port.",seqno);
else
debug(1,"Audio packet %u received in the control port.",seqno);
+ uint32_t actual_timestamp = ntohl(*(uint32_t *)(pktp + 4));
- int64_t timestamp = monotonic_timestamp(ntohl(*(uint32_t *)(pktp + 4)), conn);
+ int64_t timestamp = monotonic_timestamp(actual_timestamp, 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);
+ player_put_packet(seqno, actual_timestamp, timestamp, pktp, plen, conn);
continue;
} else {
debug(3, "Too-short retransmitted audio packet received in control port, ignored.");