Skip to content

Commit

Permalink
Q&A: RFC3095/RTP: recording TS delta in context is useless
Browse files Browse the repository at this point in the history
  • Loading branch information
didier-barvaux committed Sep 8, 2019
1 parent dca2965 commit fa6bfbe
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
28 changes: 14 additions & 14 deletions src/comp/schemes/comp_scaled_rtp_ts.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ bool c_create_sc(struct ts_sc_comp *const ts_sc,
ts_sc->ts_offset = 0;
ts_sc->old_ts = 0;
ts_sc->ts = 0;
ts_sc->ts_delta = 0;
ts_sc->old_sn = 0;
ts_sc->sn = 0;
ts_sc->is_deducible = false;
Expand Down Expand Up @@ -125,6 +124,7 @@ void c_add_ts(struct ts_sc_comp *const ts_sc,
const uint16_t sn)
{
uint16_t sn_delta;
uint32_t ts_delta;

ts_debug(ts_sc, "Timestamp = %u", ts);

Expand Down Expand Up @@ -164,24 +164,24 @@ void c_add_ts(struct ts_sc_comp *const ts_sc,
/* abs() on unsigned 32-bit values seems to be a problem sometimes */
if(ts_sc->ts >= ts_sc->old_ts)
{
ts_sc->ts_delta = ts_sc->ts - ts_sc->old_ts;
ts_delta = ts_sc->ts - ts_sc->old_ts;
}
else
{
ts_sc->ts_delta = ts_sc->old_ts - ts_sc->ts;
ts_delta = ts_sc->old_ts - ts_sc->ts;
}
ts_debug(ts_sc, "TS delta = %u", ts_sc->ts_delta);
ts_debug(ts_sc, "TS delta = %u", ts_delta);

/* go back to INIT_TS state if TS is constant */
if(ts_sc->ts_delta == 0)
if(ts_delta == 0)
{
ts_debug(ts_sc, "TS is constant, go in INIT_TS state");
ts_sc->state = INIT_TS;
return;
}

/* go back to INIT_TS state if TS_STRIDE cannot be SDVL-encoded */
if(!sdvl_can_value_be_encoded(ts_sc->ts_delta))
if(!sdvl_can_value_be_encoded(ts_delta))
{
/* TS_STRIDE is too large for SDVL encoding */
ts_debug(ts_sc, "TS_STRIDE is too large for SDVL encoding, "
Expand All @@ -205,15 +205,15 @@ void c_add_ts(struct ts_sc_comp *const ts_sc,
ts_debug(ts_sc, "state INIT_STRIDE");

/* reset INIT_STRIDE counter if TS_STRIDE/TS_OFFSET changed */
if(ts_sc->ts_delta != ts_sc->ts_stride ||
(ts_sc->ts % ts_sc->ts_delta) != ts_sc->ts_offset)
if(ts_delta != ts_sc->ts_stride ||
(ts_sc->ts % ts_delta) != ts_sc->ts_offset)
{
ts_debug(ts_sc, "TS_STRIDE and/or TS_OFFSET changed");
ts_sc->nr_init_stride_packets = 0;
}

/* compute TS_STRIDE, TS_OFFSET and TS_SCALED */
ts_sc->ts_stride = ts_sc->ts_delta;
ts_sc->ts_stride = ts_delta;
ts_debug(ts_sc, "TS_STRIDE = %u", ts_sc->ts_stride);
assert(ts_sc->ts_stride != 0);
ts_sc->ts_offset = ts_sc->ts % ts_sc->ts_stride;
Expand All @@ -234,12 +234,12 @@ void c_add_ts(struct ts_sc_comp *const ts_sc,
ts_debug(ts_sc, "state SEND_SCALED");

/* does TS_STRIDE changed? */
ts_debug(ts_sc, "TS_STRIDE calculated = %u", ts_sc->ts_delta);
ts_debug(ts_sc, "TS_STRIDE calculated = %u", ts_delta);
ts_debug(ts_sc, "previous TS_STRIDE = %u", ts_sc->ts_stride);
if(ts_sc->ts_delta != ts_sc->ts_stride)
if(ts_delta != ts_sc->ts_stride)
{
assert(ts_sc->ts_stride != 0);
if((ts_sc->ts_delta % ts_sc->ts_stride) != 0)
if((ts_delta % ts_sc->ts_stride) != 0)
{
/* TS delta changed and is not a multiple of previous TS_STRIDE:
* record the new value as TS_STRIDE and transmit it several
Expand All @@ -251,9 +251,9 @@ void c_add_ts(struct ts_sc_comp *const ts_sc,
ts_sc->state = INIT_STRIDE;
ts_sc->nr_init_stride_packets = 0;
ts_debug(ts_sc, "state -> INIT_STRIDE");
ts_sc->ts_stride = ts_sc->ts_delta;
ts_sc->ts_stride = ts_delta;
}
else if((ts_sc->ts_delta / ts_sc->ts_stride) != sn_delta)
else if((ts_delta / ts_sc->ts_stride) != sn_delta)
{
/* TS delta changed but is a multiple of previous TS_STRIDE:
* do not change TS_STRIDE, but transmit all TS bits several
Expand Down
3 changes: 0 additions & 3 deletions src/comp/schemes/comp_scaled_rtp_ts.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,6 @@ struct ts_sc_comp
/// The number of packets sent in state INIT_STRIDE
size_t nr_init_stride_packets;

/// The difference between old and current TS
uint32_t ts_delta;

/** The callback function used to manage traces */
rohc_trace_callback2_t trace_callback;
/** The private context of the callback function used to manage traces */
Expand Down

0 comments on commit fa6bfbe

Please sign in to comment.