Add an extra field to a buffer for checking purposes.
This commit is contained in:
@@ -462,10 +462,11 @@ static void free_audio_buffers(rtsp_conn_info *conn) {
|
||||
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;
|
||||
|
||||
@@ -518,6 +519,7 @@ void player_put_packet(seq_t seqno, int64_t timestamp, uint8_t *data, int len,
|
||||
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);
|
||||
@@ -550,11 +552,13 @@ void player_put_packet(seq_t seqno, int64_t timestamp, uint8_t *data, int len,
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1890,8 +1894,8 @@ static void *player_thread_func(void *arg) {
|
||||
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 {
|
||||
|
||||
@@ -39,6 +39,7 @@ typedef struct audio_buffer_entry { // decoded audio packets
|
||||
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;
|
||||
@@ -193,7 +194,7 @@ void player_stop(rtsp_conn_info *conn);
|
||||
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,
|
||||
|
||||
@@ -147,7 +147,8 @@ void *rtp_audio_receiver(void *arg) {
|
||||
// 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.");
|
||||
@@ -157,7 +158,7 @@ void *rtp_audio_receiver(void *arg) {
|
||||
|
||||
// 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) {
|
||||
@@ -361,8 +362,9 @@ void *rtp_control_receiver(void *arg) {
|
||||
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;
|
||||
@@ -370,7 +372,7 @@ void *rtp_control_receiver(void *arg) {
|
||||
// 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.");
|
||||
|
||||
Reference in New Issue
Block a user