Skip to content

Commit

Permalink
constify: RFC3095/RTP: do not update TS_STRIDE transmission counter t…
Browse files Browse the repository at this point in the history
…oo early
  • Loading branch information
didier-barvaux committed Sep 8, 2019
1 parent 8a2709d commit f389aec
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 58 deletions.
58 changes: 30 additions & 28 deletions src/comp/c_rtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -965,9 +965,8 @@ static size_t rtp_code_dynamic_rtp_part(const struct rohc_comp_ctxt *const conte
{
const struct rohc_comp_rfc3095_ctxt *const rfc3095_ctxt =
(struct rohc_comp_rfc3095_ctxt *) context->specific;
struct sc_rtp_context *const rtp_context =
const struct sc_rtp_context *const rtp_context =
(struct sc_rtp_context *) rfc3095_ctxt->specific;
const uint8_t oa_repetitions_nr = context->compressor->oa_repetitions_nr;
const struct udphdr *const udp = (struct udphdr *) next_header;
const struct rtphdr *const rtp = (struct rtphdr *) (udp + 1);
uint8_t byte;
Expand Down Expand Up @@ -1072,27 +1071,6 @@ static size_t rtp_code_dynamic_rtp_part(const struct rohc_comp_ctxt *const conte

/* skip the bytes used to encode TS_STRIDE in SDVL */
nr_written += ts_stride_sdvl_len;

/* do we transmit the scaled RTP Timestamp (TS) in the next packet ? */
if(rtp_context->ts_sc.nr_init_stride_packets < oa_repetitions_nr)
{
rtp_context->ts_sc.nr_init_stride_packets++;
}
if(rtp_context->ts_sc.nr_init_stride_packets >= oa_repetitions_nr)
{
rohc_comp_debug(context, "TS_STRIDE transmitted at least %u "
"times, so change from state INIT_STRIDE to "
"SEND_SCALED", oa_repetitions_nr);
rtp_context->ts_sc.state = SEND_SCALED;
}
else
{
rohc_comp_debug(context, "TS_STRIDE transmitted only %zd times, "
"so stay in state INIT_STRIDE (at least %u times "
"are required to change to state SEND_SCALED)",
rtp_context->ts_sc.nr_init_stride_packets,
oa_repetitions_nr);
}
}

/* part 9 not supported yet */
Expand Down Expand Up @@ -1148,6 +1126,7 @@ static void rtp_update_context(struct rohc_comp_ctxt *const context,
const struct rfc3095_tmp_state *const changes,
const rohc_packet_t packet_type)
{
const uint8_t oa_repetitions_nr = context->compressor->oa_repetitions_nr;
struct rohc_comp_rfc3095_ctxt *const rfc3095_ctxt = context->specific;
struct sc_rtp_context *const rtp_context = rfc3095_ctxt->specific;
const struct udphdr *const udp = uncomp_pkt_hdrs->udp;
Expand Down Expand Up @@ -1183,42 +1162,65 @@ static void rtp_update_context(struct rohc_comp_ctxt *const context,
{
rtp_context->udp_checksum_trans_nr = 0;
}
if(rtp_context->udp_checksum_trans_nr < context->compressor->oa_repetitions_nr)
if(rtp_context->udp_checksum_trans_nr < oa_repetitions_nr)
{
rtp_context->udp_checksum_trans_nr++;
}
if(changes->rtp_version_just_changed)
{
rtp_context->rtp_version_trans_nr = 0;
}
if(rtp_context->rtp_version_trans_nr < context->compressor->oa_repetitions_nr)
if(rtp_context->rtp_version_trans_nr < oa_repetitions_nr)
{
rtp_context->rtp_version_trans_nr++;
}
if(changes->rtp_padding_just_changed)
{
rtp_context->rtp_padding_trans_nr = 0;
}
if(rtp_context->rtp_padding_trans_nr < context->compressor->oa_repetitions_nr)
if(rtp_context->rtp_padding_trans_nr < oa_repetitions_nr)
{
rtp_context->rtp_padding_trans_nr++;
}
if(changes->rtp_ext_just_changed)
{
rtp_context->rtp_ext_trans_nr = 0;
}
if(rtp_context->rtp_ext_trans_nr < context->compressor->oa_repetitions_nr)
if(rtp_context->rtp_ext_trans_nr < oa_repetitions_nr)
{
rtp_context->rtp_ext_trans_nr++;
}
if(changes->rtp_pt_just_changed)
{
rtp_context->rtp_pt_trans_nr = 0;
}
if(rtp_context->rtp_pt_trans_nr < context->compressor->oa_repetitions_nr)
if(rtp_context->rtp_pt_trans_nr < oa_repetitions_nr)
{
rtp_context->rtp_pt_trans_nr++;
}

/* do we transmit the scaled RTP Timestamp (TS) in the next packet? */
if(rtp_context->ts_sc.state == INIT_STRIDE)
{
if(rtp_context->ts_sc.nr_init_stride_packets < oa_repetitions_nr)
{
rtp_context->ts_sc.nr_init_stride_packets++;
}
if(rtp_context->ts_sc.nr_init_stride_packets >= oa_repetitions_nr)
{
rohc_comp_debug(context, "TS_STRIDE transmitted at least %u times, "
"so change from state INIT_STRIDE to SEND_SCALED",
oa_repetitions_nr);
rtp_context->ts_sc.state = SEND_SCALED;
}
else
{
rohc_comp_debug(context, "TS_STRIDE transmitted only %zu/%u times, "
"so stay in state INIT_STRIDE",
rtp_context->ts_sc.nr_init_stride_packets,
oa_repetitions_nr);
}
}
}


Expand Down
37 changes: 7 additions & 30 deletions src/comp/rohc_comp_rfc3095.c
Original file line number Diff line number Diff line change
Expand Up @@ -4623,7 +4623,7 @@ static int code_EXT3_rtp_packet(const struct rohc_comp_ctxt *const context,
int counter,
const rohc_packet_t packet_type)
{
struct rohc_comp_rfc3095_ctxt *const rfc3095_ctxt = /* TODO: const */
const struct rohc_comp_rfc3095_ctxt *const rfc3095_ctxt =
(struct rohc_comp_rfc3095_ctxt *) context->specific;
const bool is_rtp = !!(context->profile->id == ROHC_PROFILE_RTP);
ip_header_pos_t innermost_ipv4_non_rnd;
Expand All @@ -4639,11 +4639,11 @@ static int code_EXT3_rtp_packet(const struct rohc_comp_ctxt *const context,
int rtp; /* RTP bit */

const struct rohc_pkt_ip_hdr *inner_ip;
struct ip_header_info *inner_ip_ctxt; /* TODO: const */
const struct ip_header_info *inner_ip_ctxt;
const struct rfc3095_ip_hdr_changes *inner_ip_changes;

const struct rohc_pkt_ip_hdr *outer_ip;
struct ip_header_info *outer_ip_ctxt; /* TODO: const */
const struct ip_header_info *outer_ip_ctxt;
const struct rfc3095_ip_hdr_changes *outer_ip_changes;

const struct sc_rtp_context *const rtp_context =
Expand Down Expand Up @@ -5164,16 +5164,14 @@ static int rtp_header_flags_and_fields(const struct rohc_comp_ctxt *const contex
uint8_t *const dest,
int counter)
{
const uint8_t oa_repetitions_nr = context->compressor->oa_repetitions_nr;
struct rohc_comp_rfc3095_ctxt *rfc3095_ctxt;
struct sc_rtp_context *rtp_context;
const struct rohc_comp_rfc3095_ctxt *const rfc3095_ctxt =
(struct rohc_comp_rfc3095_ctxt *) context->specific;
const struct sc_rtp_context *const rtp_context =
(struct sc_rtp_context *) rfc3095_ctxt->specific;
int tss;
int rpt;
uint8_t byte;

rfc3095_ctxt = (struct rohc_comp_rfc3095_ctxt *) context->specific;
rtp_context = (struct sc_rtp_context *) rfc3095_ctxt->specific;

/* part 1 */
rpt = (changes->rtp_pt_changed ||
changes->rtp_padding_changed);
Expand Down Expand Up @@ -5224,27 +5222,6 @@ static int rtp_header_flags_and_fields(const struct rohc_comp_ctxt *const contex

rohc_comp_debug(context, "TS_STRIDE %u (0x%x) is SDVL-encoded on %zd "
"bit(s)", ts_stride, ts_stride, sdvl_size);

/* do we transmit the scaled RTP Timestamp (TS) in the next packet ? */
if(rtp_context->ts_sc.nr_init_stride_packets < oa_repetitions_nr)
{
rtp_context->ts_sc.nr_init_stride_packets++;
}
if(rtp_context->ts_sc.nr_init_stride_packets >= oa_repetitions_nr)
{
rohc_comp_debug(context, "TS_STRIDE transmitted at least %u times, so "
"change from state INIT_STRIDE to SEND_SCALED",
oa_repetitions_nr);
rtp_context->ts_sc.state = SEND_SCALED;
}
else
{
rohc_comp_debug(context, "TS_STRIDE transmitted only %zd times, so stay "
"in state INIT_STRIDE (at least %u times are required to "
"change to state SEND_SCALED)",
rtp_context->ts_sc.nr_init_stride_packets,
oa_repetitions_nr);
}
}

/* part 5: not supported yet */
Expand Down

0 comments on commit f389aec

Please sign in to comment.