rtp.c
int frame_to_local_time(uint32_t timestamp, uint64_t *time, rtsp_conn_info *conn) {
  debug_mutex_lock(&conn->reference_time_mutex, 1000, 0);
  int result = 0;
  uint64_t time_difference;
  uint32_t frame_difference;
  result = sanitised_source_rate_information(&frame_difference, &time_difference, conn);

  uint64_t timestamp_interval_time;
  uint64_t remote_time_of_timestamp;
  uint32_t timestamp_interval = modulo_32_offset(conn->reference_timestamp, timestamp);
  if (timestamp_interval <=
      conn->input_rate * 3600) { // i.e. timestamp was really after the reference timestamp
    timestamp_interval_time = (timestamp_interval * time_difference) /
                              frame_difference; // this is the nominal time, based on the
                                                // fps specified between current and
                                                // previous sync frame.
    remote_time_of_timestamp = conn->remote_reference_timestamp_time +
                               timestamp_interval_time; // based on the reference timestamp time
                                                        // plus the time interval calculated based
                                                        // on the specified fps.
  } else { // i.e. timestamp was actually before the reference timestamp
    timestamp_interval =
        modulo_32_offset(timestamp, conn->reference_timestamp); // fix the calculation
    timestamp_interval_time = (timestamp_interval * time_difference) /
                              frame_difference; // this is the nominal time, based on the
                                                // fps specified between current and
                                                // previous sync frame.
    remote_time_of_timestamp = conn->remote_reference_timestamp_time -
                               timestamp_interval_time; // based on the reference timestamp time
                                                        // plus the time interval calculated based
                                                        // on the specified fps.
  }
  *time = remote_time_of_timestamp - local_to_remote_time_difference_now(conn);
  debug_mutex_unlock(&conn->reference_time_mutex, 0);
  return result;
}
// the timestamp is a timestamp calculated at the input rate
// the reference timestamps are denominated in terms of the input rate
the timestamp is a timestamp calculated at the input rate
the reference timestamps are denominated in terms of the input rate
the timestamp is a timestamp calculated at the input rate the reference timestamps are denominated in terms of the input rate
int frame_to_local_time(uint32_t timestamp, uint64_t *time, rtsp_conn_info *conn) {
  debug_mutex_lock(&conn->reference_time_mutex, 1000, 0);
  int result = 0;
  uint64_t time_difference;
  uint32_t frame_difference;
  result = sanitised_source_rate_information(&frame_difference, &time_difference, conn);
  uint64_t timestamp_interval_time;
  uint64_t remote_time_of_timestamp;
  uint32_t timestamp_interval = modulo_32_offset(conn->reference_timestamp, timestamp);
  if (timestamp_interval <=
      conn->input_rate * 3600) { 
    timestamp_interval_time = (timestamp_interval * time_difference) /
                              frame_difference; 
    remote_time_of_timestamp = conn->remote_reference_timestamp_time +
                               timestamp_interval_time; 
  } else { 
    timestamp_interval =
        modulo_32_offset(timestamp, conn->reference_timestamp); 
    timestamp_interval_time = (timestamp_interval * time_difference) /
                              frame_difference; 
    remote_time_of_timestamp = conn->remote_reference_timestamp_time -
                               timestamp_interval_time; 
  }
  *time = remote_time_of_timestamp - local_to_remote_time_difference_now(conn);
  debug_mutex_unlock(&conn->reference_time_mutex, 0);
  return result;
}
int frame_to_local_time ( uint32_t timestamp , uint64_t * time , rtsp_conn_info * conn ) { debug_mutex_lock ( & conn -> reference_time_mutex , 1000 , 0 ) ; int result = 0 ; uint64_t time_difference ; uint32_t frame_difference ; result = sanitised_source_rate_information ( & frame_difference , & time_difference , conn ) ; uint64_t timestamp_interval_time ; uint64_t remote_time_of_timestamp ; uint32_t timestamp_interval = modulo_32_offset ( conn -> reference_timestamp , timestamp ) ; if ( timestamp_interval <= conn -> input_rate * 3600 ) { timestamp_interval_time = ( timestamp_interval * time_difference ) / frame_difference ; remote_time_of_timestamp = conn -> remote_reference_timestamp_time + timestamp_interval_time ; } else { timestamp_interval = modulo_32_offset ( timestamp , conn -> reference_timestamp ) ; timestamp_interval_time = ( timestamp_interval * time_difference ) / frame_difference ; remote_time_of_timestamp = conn -> remote_reference_timestamp_time - timestamp_interval_time ; } * time = remote_time_of_timestamp - local_to_remote_time_difference_now ( conn ) ; debug_mutex_unlock ( & conn -> reference_time_mutex , 0 ) ; return result ; }
the timestamp is a timestamp calculated at the input rate
the reference timestamps are denominated in terms of the input rate
the timestamp is a timestamp calculated at the input rate the reference timestamps are denominated in terms of the input rate
// i.e. timestamp was really after the reference timestamp // this is the nominal time, based on the // fps specified between current and // previous sync frame. // based on the reference timestamp time // plus the time interval calculated based // on the specified fps. // i.e. timestamp was actually before the reference timestamp // fix the calculation // this is the nominal time, based on the // fps specified between current and // previous sync frame. // based on the reference timestamp time // plus the time interval calculated based // on the specified fps.