allow calculation of nominal source frame rates even when the connection is error prone.

This commit is contained in:
Mike Brady
2019-04-02 15:37:38 +01:00
parent ac51c10116
commit 1f45b8c006
4 changed files with 22 additions and 30 deletions
+1 -1
View File
@@ -1191,7 +1191,7 @@ int delay_and_status(snd_pcm_state_t *state, snd_pcm_sframes_t *delay, enum yndk
if (update_timestamp_ns == 0) {
ret = snd_pcm_delay (alsa_handle,delay);
measurement_data_is_valid = 0; // can't really check frame rates
measurement_data_is_valid = 0; // frame rates are likely to be very unreliable if it can't set the update_timestamp, so don't publish them.
} else {
*delay = snd_pcm_status_get_delay(alsa_snd_pcm_status);
+1 -3
View File
@@ -209,7 +209,6 @@ static inline seq_t seq_sum(seq_t a, seq_t b) {
void reset_input_flow_metrics(rtsp_conn_info *conn) {
conn->play_number_after_flush = 0;
conn->packet_count_since_flush = 0;
conn->packet_stream_established = 0;
conn->input_frame_rate_starting_point_is_valid = 0;
conn->initial_reference_time = 0;
conn->initial_reference_timestamp = 0;
@@ -892,8 +891,7 @@ static abuf_t *buffer_get_frame(rtsp_conn_info *conn) {
curframe->given_timestamp; // we will keep buffering until we are
// supposed to start playing this
have_sent_prefiller_silence = 0;
conn->packet_stream_established = 1;
// debug(1, "First packet timestamp is %" PRId64 ".", conn->first_packet_timestamp);
// say we have started playing here
-3
View File
@@ -202,9 +202,6 @@ typedef struct {
uint32_t reference_timestamp;
uint64_t remote_reference_timestamp_time;
int packet_stream_established; // true if a stream of packets is flowing, made true by a first
// packet, false by a flush
// used as the initials values for calculating the rate at which the source thinks it's sending
// frames
uint32_t initial_reference_timestamp;
+20 -23
View File
@@ -381,28 +381,26 @@ void *rtp_control_receiver(void *arg) {
debug_mutex_lock(&conn->reference_time_mutex, 1000, 0);
if (conn->packet_stream_established) {
if (conn->initial_reference_time == 0) {
conn->initial_reference_time = remote_time_of_sync;
conn->initial_reference_timestamp = sync_rtp_timestamp;
if (conn->initial_reference_time == 0) {
conn->initial_reference_time = remote_time_of_sync;
conn->initial_reference_timestamp = sync_rtp_timestamp;
} else {
uint64_t remote_frame_time_interval =
conn->remote_reference_timestamp_time -
conn->initial_reference_time; // here, this should never be zero
if (remote_frame_time_interval) {
conn->remote_frame_rate =
(1.0 * (conn->reference_timestamp - conn->initial_reference_timestamp)) /
remote_frame_time_interval; // an IEEE double calculation with a 32-bit
// numerator and 64-bit denominator
// integers
conn->remote_frame_rate = conn->remote_frame_rate *
(uint64_t)0x100000000; // this should just change the
// [binary] exponent in the IEEE
// FP representation; the
// mantissa should be unaffected.
} else {
uint64_t remote_frame_time_interval =
conn->remote_reference_timestamp_time -
conn->initial_reference_time; // here, this should never be zero
if (remote_frame_time_interval) {
conn->remote_frame_rate =
(1.0 * (conn->reference_timestamp - conn->initial_reference_timestamp)) /
remote_frame_time_interval; // an IEEE double calculation with a 32-bit
// numerator and 64-bit denominator
// integers
conn->remote_frame_rate = conn->remote_frame_rate *
(uint64_t)0x100000000; // this should just change the
// [binary] exponent in the IEEE
// FP representation; the
// mantissa should be unaffected.
} else {
conn->remote_frame_rate = 0.0; // use as a flag.
}
conn->remote_frame_rate = 0.0; // use as a flag.
}
}
@@ -1088,8 +1086,7 @@ int sanitised_source_rate_information(uint32_t *frames, uint64_t *time, rtsp_con
*frames = fs;
uint64_t one_fp = (uint64_t)(0x100000000); // one second in fp form
*time = one_fp;
if ((conn->packet_stream_established) && (conn->initial_reference_time) &&
(conn->initial_reference_timestamp)) {
if ((conn->initial_reference_time) && (conn->initial_reference_timestamp)) {
// uint32_t local_frames = conn->reference_timestamp - conn->initial_reference_timestamp;
uint32_t local_frames =
modulo_32_offset(conn->initial_reference_timestamp, conn->reference_timestamp);