MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / pv_get_rtpquery_f

Function pv_get_rtpquery_f

modules/rtpengine/rtpengine.c:4548–4598  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4546}
4547
4548static int
4549pv_get_rtpquery_f(struct sip_msg *msg, pv_param_t *param,
4550 pv_value_t *res)
4551{
4552 static char query_buf[512];
4553 bencode_buffer_t bencbuf;
4554 bencode_item_t *dict;
4555 struct rtpe_ctx *ctx;
4556 cJSON *out = NULL;
4557 str ret;
4558
4559 if (rtpe_fetch_stats(msg, &bencbuf, &dict) < 0)
4560 return -1;
4561 ctx = rtpe_ctx_tryget();
4562
4563 /* TODO: handle reply */
4564 out = bson2json(dict);
4565 if (!out) {
4566 LM_ERR("cannot convert bson to json!\n");
4567 goto error;
4568 }
4569 if (ctx) {
4570 /* we have ctx, just print it there */
4571 ret.s = cJSON_PrintUnformatted(out);
4572 if (!ret.s) {
4573 LM_ERR("cannot print unformatted json!\n");
4574 goto error;
4575 }
4576 ret.len = strlen(ret.s);
4577 ctx->stats->json = ret;
4578 } else {
4579 if (cJSON_PrintPreallocated(out, query_buf, sizeof(query_buf), 0) == 0) {
4580 LM_ERR("cannot print in preallocated buffer!\n");
4581 goto error;
4582 }
4583 ret.s = query_buf;
4584 ret.len = strlen(ret.s);
4585 /* also release the buffer */
4586 bencode_buffer_free(&bencbuf);
4587 }
4588
4589 cJSON_Delete(out);
4590 return pv_get_strval(msg, param, res, &ret);
4591
4592error:
4593 if (!ctx)
4594 bencode_buffer_free(&bencbuf);
4595 if (out)
4596 cJSON_Delete(out);
4597 return -1;
4598}
4599
4600
4601static int _add_rtpengine_from_database(void)

Callers

nothing calls this directly

Calls 7

rtpe_fetch_statsFunction · 0.85
bson2jsonFunction · 0.85
cJSON_PrintPreallocatedFunction · 0.85
bencode_buffer_freeFunction · 0.85
pv_get_strvalFunction · 0.85
cJSON_PrintUnformattedFunction · 0.50
cJSON_DeleteFunction · 0.50

Tested by

no test coverage detected