Skip to content

Commit

Permalink
TT#146201 update SRTCP index from kernel
Browse files Browse the repository at this point in the history
Change-Id: I320caeb39277c3e3584987f9c9f0c2c7e9cfd7a0
  • Loading branch information
rfuchs committed Jun 16, 2023
1 parent 7bf1595 commit e93b2fd
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 4 deletions.
29 changes: 28 additions & 1 deletion daemon/media_socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -1349,8 +1349,10 @@ static int __k_srtp_crypt(struct rtpengine_srtp *s, struct crypto_context *c,
.rtp_auth_tag_len= c->params.crypto_suite->srtp_auth_tag,
.rtcp_auth_tag_len= c->params.crypto_suite->srtcp_auth_tag,
};
for (unsigned int i = 0; i < RTPE_NUM_SSRC_TRACKING; i++)
for (unsigned int i = 0; i < RTPE_NUM_SSRC_TRACKING; i++) {
s->last_rtp_index[i] = ssrc_ctx[i] ? ssrc_ctx[i]->srtp_index : 0;
s->last_rtcp_index[i] = ssrc_ctx[i] ? ssrc_ctx[i]->srtcp_index : 0;
}
if (c->params.mki_len)
memcpy(s->mki, c->params.mki, c->params.mki_len);
memcpy(s->master_key, c->params.master_key, c->params.crypto_suite->master_key_len);
Expand Down Expand Up @@ -1796,6 +1798,27 @@ static void __stream_consume_stats(struct packet_stream *ps, const struct rtpeng

mutex_unlock(&sink->out_lock);
}

for (GList *l = ps->rtcp_sinks.head; l; l = l->next) {
struct sink_handler *sh = l->data;
struct packet_stream *sink = sh->sink;

if (mutex_trylock(&sink->out_lock))
continue; // will have to skip this

ssrc_ctx = __hunt_ssrc_ctx(ssrc, sink->ssrc_out, u);
if (!ssrc_ctx)
ssrc_ctx = __hunt_ssrc_ctx(ssrc_map_out, sink->ssrc_out, u);

if (ssrc_ctx) {
if (sh->kernel_output_idx >= 0) {
ssrc_ctx->srtcp_index
= stats_info->last_rtcp_index[sh->kernel_output_idx][u];
}
}

mutex_unlock(&sink->out_lock);
}
}
}

Expand Down Expand Up @@ -3501,6 +3524,10 @@ enum thread_looper_action kernel_stats_updater(void) {
ctx->srtp_index = o->encrypt.last_rtp_index[u];
update = true;
}
if (ctx->srtcp_index != o->encrypt.last_rtcp_index[u]) {
ctx->srtcp_index = o->encrypt.last_rtcp_index[u];
update = true;
}
}
mutex_unlock(&sink->out_lock);
}
Expand Down
12 changes: 9 additions & 3 deletions kernel-module/xt_RTPENGINE.c
Original file line number Diff line number Diff line change
Expand Up @@ -1667,10 +1667,11 @@ static void proc_list_crypto_print(struct seq_file *f, struct re_crypto_context

seq_printf(f, " ROC:");
for (i = 0; i < ARRAY_SIZE(c->roc); i++) {
seq_printf(f, "%s %u (%lu)",
seq_printf(f, "%s %u (%lu/%lu)",
(i == 0) ? "" : ",",
(unsigned int) c->roc[i],
(unsigned long) s->last_rtp_index[i]);
(unsigned long) s->last_rtp_index[i],
(unsigned long) s->last_rtcp_index[i]);
}
seq_printf(f, "\n");

Expand Down Expand Up @@ -1883,7 +1884,7 @@ static struct re_dest_addr *find_dest_addr(const struct re_dest_addr_hash *h, co


static void target_retrieve_stats(struct rtpengine_target *g, struct rtpengine_stats_info *i, int reset) {
unsigned int u;
unsigned int u, v;
unsigned long flags;

spin_lock_irqsave(&g->ssrc_stats_lock, flags);
Expand All @@ -1899,6 +1900,11 @@ static void target_retrieve_stats(struct rtpengine_target *g, struct rtpengine_s
}
}

for (u = 0; u < g->target.num_destinations; u++) {
for (v = 0; v < RTPE_NUM_SSRC_TRACKING; v++)
i->last_rtcp_index[u][v] = g->outputs[u].output.encrypt.last_rtcp_index[v];
}

spin_unlock_irqrestore(&g->ssrc_stats_lock, flags);
}

Expand Down
1 change: 1 addition & 0 deletions kernel-module/xt_RTPENGINE.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ struct rtpengine_packet_info {
struct rtpengine_stats_info {
uint32_t ssrc[RTPE_NUM_SSRC_TRACKING];
struct rtpengine_ssrc_stats ssrc_stats[RTPE_NUM_SSRC_TRACKING];
uint64_t last_rtcp_index[RTPE_MAX_FORWARD_DESTINATIONS][RTPE_NUM_SSRC_TRACKING];
};

enum rtpengine_command {
Expand Down

0 comments on commit e93b2fd

Please sign in to comment.