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

Function rtpengine_raise_event

modules/rtpengine/rtpengine.c:4787–4848  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4785}
4786
4787static void rtpengine_raise_event(int sender, void *p)
4788{
4789 int err;
4790 cJSON *param;
4791 cJSON *jparams;
4792 str name, jstring;
4793 evi_params_p eparams = NULL;
4794 char *buf = (char *)p;
4795
4796 jparams = cJSON_Parse(buf);
4797 shm_free(p);
4798 if (!jparams) {
4799 LM_ERR("could not parse json notification %s\n", buf);
4800 return;
4801 }
4802
4803 if (!(jparams->type &cJSON_Object)) {
4804 LM_ERR("json is not an object\n");
4805 return;
4806 }
4807
4808 if (!(eparams = evi_get_params())) {
4809 LM_ERR("cannot create parameters list\n");
4810 goto end;
4811 }
4812
4813 for (param = jparams->child; param; param = param->next) {
4814 name.s = param->string;
4815 name.len = strlen(name.s);
4816 switch (param->type) {
4817 case cJSON_Number:
4818 err = evi_param_add_int(eparams, &name, &param->valueint);
4819 break;
4820 case cJSON_String:
4821 jstring.s = param->valuestring;
4822 jstring.len = strlen(jstring.s);
4823 err = evi_param_add_str(eparams, &name, &jstring);
4824 break;
4825 default:
4826 jstring.s = cJSON_PrintUnformatted(param);
4827 if (!jstring.s) {
4828 LM_ERR("cJSON_PrintUnformatted failed\n");
4829 break;
4830 }
4831 jstring.len = strlen(jstring.s);
4832 err = evi_param_add_str(eparams, &name, &jstring);
4833 cJSON_PurgeString(jstring.s);
4834 break;
4835 }
4836 if (err) {
4837 LM_ERR("could not add parameter %s\n", name.s);
4838 evi_free_params(eparams);
4839 goto end;
4840 }
4841 }
4842
4843 /* all good: dispatch job! */
4844 evi_raise_event(rtpengine_notify_event, eparams);

Callers

nothing calls this directly

Calls 8

shm_freeFunction · 0.85
evi_get_paramsFunction · 0.85
cJSON_PurgeStringFunction · 0.85
evi_free_paramsFunction · 0.85
evi_raise_eventFunction · 0.85
cJSON_ParseFunction · 0.50
cJSON_PrintUnformattedFunction · 0.50
cJSON_DeleteFunction · 0.50

Tested by

no test coverage detected