Browse Source

MT#56861 use SSRC TS for "encoder" TS

Support using the SSRC TS derived from received RTP packets as "encoder"
TS (the "next" expected TS) for passthrough RTP in addition to the FIFO
TS of an actual encoder.

Change-Id: I7c49c27651eb89c5349bbf290b1c0ad160f77e3b
pull/1657/head
Richard Fuchs 3 years ago
parent
commit
93d4fe74c1
3 changed files with 13 additions and 7 deletions
  1. +9
    -3
      daemon/codec.c
  2. +3
    -3
      daemon/dtmf.c
  3. +1
    -1
      include/codec.h

+ 9
- 3
daemon/codec.c View File

@ -2452,9 +2452,15 @@ uint64_t codec_last_dtmf_event(struct codec_ssrc_handler *ch) {
return ev->ts;
}
uint64_t codec_encoder_pts(struct codec_ssrc_handler *ch) {
if (!ch || !ch->encoder)
return 0;
uint64_t codec_encoder_pts(struct codec_ssrc_handler *ch, struct ssrc_ctx *ssrc_in) {
if (!ch || !ch->encoder) {
if (!ssrc_in)
return 0;
uint64_t cur = atomic64_get(&ssrc_in->last_ts);
// return the TS of the next expected packet
cur += ch->ptime * ch->handler->source_pt.clock_rate / 1000;
return cur;
}
return ch->encoder->fifo_pts;
}


+ 3
- 3
daemon/dtmf.c View File

@ -548,7 +548,7 @@ static const char *dtmf_inject_pcm(struct call_media *media, struct call_media *
};
// keep track of how much PCM we've generated
uint64_t encoder_pts = codec_encoder_pts(csh);
uint64_t encoder_pts = codec_encoder_pts(csh, NULL);
uint64_t skip_pts = codec_decoder_unskip_pts(csh); // reset to zero to take up our new samples
ch->dtmf_injector->handler_func(ch->dtmf_injector, &packet);
@ -561,7 +561,7 @@ static const char *dtmf_inject_pcm(struct call_media *media, struct call_media *
ch->dtmf_injector->handler_func(ch->dtmf_injector, &packet);
// skip generated samples
uint64_t pts_offset = codec_encoder_pts(csh) - encoder_pts;
uint64_t pts_offset = codec_encoder_pts(csh, NULL) - encoder_pts;
skip_pts += av_rescale(pts_offset, ch->dest_pt.clock_rate, ch->source_pt.clock_rate);
codec_decoder_skip_pts(csh, skip_pts);
@ -641,7 +641,7 @@ const char *dtmf_inject(struct call_media *media, int code, int volume, int dura
// synthesise start and stop events
uint64_t num_samples = (uint64_t) duration * ch->dest_pt.clock_rate / 1000;
uint64_t start_pts = codec_encoder_pts(csh);
uint64_t start_pts = codec_encoder_pts(csh, ssrc_in);
uint64_t last_end_pts = codec_last_dtmf_event(csh);
if (last_end_pts) {
// shift this new event past the end of the last event plus a pause


+ 1
- 1
include/codec.h View File

@ -150,7 +150,7 @@ bool codec_handlers_update(struct call_media *receiver, struct call_media *sink,
const struct stream_params *);
void codec_add_dtmf_event(struct codec_ssrc_handler *ch, int code, int level, uint64_t ts, bool injected);
uint64_t codec_last_dtmf_event(struct codec_ssrc_handler *ch);
uint64_t codec_encoder_pts(struct codec_ssrc_handler *ch);
uint64_t codec_encoder_pts(struct codec_ssrc_handler *ch, struct ssrc_ctx *);
void codec_decoder_skip_pts(struct codec_ssrc_handler *ch, uint64_t);
uint64_t codec_decoder_unskip_pts(struct codec_ssrc_handler *ch);
void codec_tracker_update(struct codec_store *);


Loading…
Cancel
Save