MT#55283 convert codec_calc_jitter to int64_t

Change-Id: Ia042d86b6b1091561fadd896e77925f48012c7bd
master
Richard Fuchs 2 weeks ago
parent cf98f9013a
commit b2e75d60db

@ -2117,7 +2117,7 @@ static int handler_func_passthrough(struct codec_handler *h, struct media_packet
uint32_t ts = 0;
if (mp->rtp) {
ts = ntohl(mp->rtp->timestamp);
codec_calc_jitter(mp->ssrc_in, ts, h->source_pt.clock_rate, timeval_from_us(mp->tv));
codec_calc_jitter(mp->ssrc_in, ts, h->source_pt.clock_rate, mp->tv);
codec_calc_lost(mp->ssrc_in, ntohs(mp->rtp->seq_num));
if (ML_ISSET(mp->media->monologue, BLOCK_SHORT) && h->source_pt.codec_def
@ -2415,9 +2415,9 @@ void codec_output_rtp(struct media_packet *mp, struct codec_scheduler *csch,
// this packet is dynamically allocated, so we're able to schedule it.
// determine scheduled time to send
if (csch->first_send.tv_sec && handler->dest_pt.clock_rate) {
if (csch->first_send && handler->dest_pt.clock_rate) {
// scale first_send from first_send_ts to ts
p->ttq_entry.when = csch->first_send;
p->ttq_entry.when = timeval_from_us(csch->first_send);
uint32_t ts_diff = (uint32_t) ts - (uint32_t) csch->first_send_ts; // allow for wrap-around
ts_diff += ts_delay;
ts_diff_us = ts_diff * 1000000LL / handler->dest_pt.clock_rate;
@ -2426,10 +2426,11 @@ void codec_output_rtp(struct media_packet *mp, struct codec_scheduler *csch,
// how far in the future is this?
ts_diff_us = timeval_diff(p->ttq_entry.when, timeval_from_us(rtpe_now));
if (ts_diff_us > 1000000 || ts_diff_us < -1000000) // more than one second, can't be right
csch->first_send.tv_sec = 0; // fix it up below
csch->first_send = 0; // fix it up below
}
if (!csch->first_send.tv_sec || !p->ttq_entry.when.tv_sec) {
p->ttq_entry.when = csch->first_send = timeval_from_us(rtpe_now);
if (!csch->first_send || !p->ttq_entry.when.tv_sec) {
p->ttq_entry.when = timeval_from_us(rtpe_now);
csch->first_send = rtpe_now;
csch->first_send_ts = ts;
}
@ -2953,7 +2954,7 @@ static int handler_func_passthrough_ssrc(struct codec_handler *h, struct media_p
return 0;
uint32_t ts = ntohl(mp->rtp->timestamp);
codec_calc_jitter(mp->ssrc_in, ts, h->source_pt.clock_rate, timeval_from_us(mp->tv));
codec_calc_jitter(mp->ssrc_in, ts, h->source_pt.clock_rate, mp->tv);
codec_calc_lost(mp->ssrc_in, ntohs(mp->rtp->seq_num));
// save original payload in case DTMF mangles it
@ -3977,7 +3978,7 @@ out:
static void __dtx_shutdown(struct dtx_buffer *dtxb) {
if (dtxb->csh) {
__auto_type ch = dtxb->csh;
ch->csch.first_send = (struct timeval) {0};
ch->csch.first_send = 0;
ch->csch.first_ts = 0;
ch->csch.first_ts = 0;
if (ch->encoder) {
@ -4826,15 +4827,13 @@ void codec_update_all_source_handlers(struct call_monologue *ml, const sdp_ng_fl
}
void codec_calc_jitter(struct ssrc_ctx *ssrc, unsigned long ts, unsigned int clockrate,
const struct timeval tv)
{
void codec_calc_jitter(struct ssrc_ctx *ssrc, unsigned long ts, unsigned int clockrate, int64_t tv) {
if (!ssrc || !clockrate)
return;
struct ssrc_entry_call *sec = ssrc->parent;
// RFC 3550 A.8
uint32_t transit = (((timeval_us(tv) / 1000) * clockrate) / 1000) - ts;
uint32_t transit = (((tv / 1000) * clockrate) / 1000) - ts;
mutex_lock(&sec->h.lock);
int32_t d = 0;
if (sec->transit)
@ -4927,7 +4926,7 @@ static int handler_func_transcode(struct codec_handler *h, struct media_packet *
ntohl(mp->rtp->timestamp), mp->payload.len);
codec_calc_jitter(mp->ssrc_in, ntohl(mp->rtp->timestamp), h->input_handler->source_pt.clock_rate,
timeval_from_us(mp->tv));
mp->tv);
if (h->stats_entry) {
unsigned int idx = timeval_from_us(rtpe_now).tv_sec & 1;

@ -345,7 +345,7 @@ static bool __send_timer_send_1(struct rtp_header *rh, struct packet_stream *sin
ntohs(rh->seq_num),
ntohl(rh->timestamp),
ntohl(rh->ssrc));
codec_calc_jitter(cp->ssrc_out, ntohl(rh->timestamp), cp->clockrate, timeval_from_us(rtpe_now));
codec_calc_jitter(cp->ssrc_out, ntohl(rh->timestamp), cp->clockrate, rtpe_now);
}
else
ilog(LOG_DEBUG, "Forward to sink endpoint: local %s -> remote %s%s%s",

@ -103,7 +103,7 @@ struct codec_packet {
struct codec_scheduler {
unsigned long first_ts; // for output TS scaling
unsigned long last_ts; // to detect input lag and handle lost packets
struct timeval first_send;
int64_t first_send;
unsigned long first_send_ts;
long output_skew;
};
@ -151,7 +151,7 @@ struct codec_handler *codec_handler_make_media_player(const rtp_payload_type *sr
str_case_value_ht codec_set);
struct codec_handler *codec_handler_make_dummy(const rtp_payload_type *dst_pt, struct call_media *media,
str_case_value_ht codec_set);
void codec_calc_jitter(struct ssrc_ctx *, unsigned long ts, unsigned int clockrate, const struct timeval);
void codec_calc_jitter(struct ssrc_ctx *, unsigned long ts, unsigned int clockrate, int64_t);
void codec_update_all_handlers(struct call_monologue *ml);
void codec_update_all_source_handlers(struct call_monologue *ml, const sdp_ng_flags *flags);

Loading…
Cancel
Save